From 3b5793fd5540f8eee3c9a0ef49e2688c9505920c Mon Sep 17 00:00:00 2001 From: Jani Laakso Date: Tue, 4 Dec 2007 19:51:22 +0000 Subject: [PATCH] License header parametrized Cleanup performed Organized imports Format svn changeset:3162/svn branch:trunk --- src/com/itmill/toolkit/Application.java | 96 +++----- src/com/itmill/toolkit/data/Buffered.java | 36 +-- .../toolkit/data/BufferedValidatable.java | 30 +-- src/com/itmill/toolkit/data/Container.java | 30 +-- src/com/itmill/toolkit/data/Item.java | 30 +-- src/com/itmill/toolkit/data/Property.java | 30 +-- src/com/itmill/toolkit/data/Validatable.java | 30 +-- src/com/itmill/toolkit/data/Validator.java | 32 +-- .../itmill/toolkit/data/util/BeanItem.java | 72 ++---- .../util/ContainerHierarchicalWrapper.java | 64 ++--- .../data/util/ContainerOrderedWrapper.java | 60 ++--- .../data/util/FilesystemContainer.java | 56 ++--- .../data/util/HierarchicalContainer.java | 58 ++--- .../toolkit/data/util/IndexedContainer.java | 177 ++++++------- .../toolkit/data/util/MethodProperty.java | 72 ++---- .../toolkit/data/util/ObjectProperty.java | 46 +--- .../toolkit/data/util/PropertysetItem.java | 42 +--- .../toolkit/data/util/QueryContainer.java | 58 ++--- .../data/validator/CompositeValidator.java | 56 ++--- .../toolkit/data/validator/NullValidator.java | 30 +-- .../data/validator/StringLengthValidator.java | 38 +-- src/com/itmill/toolkit/demo/BrowserDemo.java | 12 +- .../toolkit/demo/BufferedComponents.java | 16 +- src/com/itmill/toolkit/demo/CachingDemo.java | 10 +- src/com/itmill/toolkit/demo/Calc.java | 10 +- .../itmill/toolkit/demo/CustomLayoutDemo.java | 18 +- src/com/itmill/toolkit/demo/FilterSelect.java | 16 +- src/com/itmill/toolkit/demo/HelloWorld.java | 6 +- .../itmill/toolkit/demo/KeyboardShortcut.java | 24 +- src/com/itmill/toolkit/demo/LayoutDemo.java | 23 +- src/com/itmill/toolkit/demo/ModalWindow.java | 14 +- .../itmill/toolkit/demo/NativeWindowing.java | 12 +- .../itmill/toolkit/demo/NotificationDemo.java | 8 +- src/com/itmill/toolkit/demo/Parameters.java | 37 +-- .../toolkit/demo/QueryContainerDemo.java | 36 +-- src/com/itmill/toolkit/demo/SelectDemo.java | 12 +- src/com/itmill/toolkit/demo/TableDemo.java | 33 +-- .../itmill/toolkit/demo/TreeFilesystem.java | 22 +- .../toolkit/demo/TreeFilesystemContainer.java | 27 +- .../itmill/toolkit/demo/UpgradingSample.java | 33 +-- .../itmill/toolkit/demo/WindowedDemos.java | 14 +- .../toolkit/demo/colorpicker/ColorPicker.java | 6 +- .../colorpicker/ColorPickerApplication.java | 6 +- .../gwt/client/ColorPickerWidgetSet.java | 8 +- .../gwt/client/ui/GwtColorPicker.java | 22 +- .../gwt/client/ui/IColorPicker.java | 4 + .../demo/featurebrowser/ButtonExample.java | 18 +- .../featurebrowser/ClientCachingExample.java | 10 +- .../demo/featurebrowser/ComboBoxExample.java | 12 +- .../EmbeddedBrowserExample.java | 8 +- .../demo/featurebrowser/FeatureBrowser.java | 70 +++--- .../demo/featurebrowser/LabelExample.java | 8 +- .../demo/featurebrowser/LayoutExample.java | 10 +- .../featurebrowser/NotificationExample.java | 8 +- .../demo/featurebrowser/RichTextExample.java | 13 +- .../demo/featurebrowser/SelectExample.java | 14 +- .../demo/featurebrowser/TableExample.java | 58 +++-- .../demo/featurebrowser/TreeExample.java | 27 +- .../featurebrowser/ValueInputExample.java | 16 +- .../demo/featurebrowser/WindowingExample.java | 28 ++- .../demo/reservation/CalendarDemo.java | 14 +- .../demo/reservation/CalendarField.java | 37 +-- .../toolkit/demo/reservation/GoogleMap.java | 26 +- .../reservation/ReservationApplication.java | 60 ++--- .../ResourceNotAvailableException.java | 4 + .../reservation/ResourceSelectorPanel.java | 56 +++-- .../toolkit/demo/reservation/SampleDB.java | 122 ++++----- .../gwt/client/ReservationWidgetSet.java | 8 +- .../gwt/client/ui/ICalendarField.java | 100 ++++---- .../reservation/gwt/client/ui/IGoogleMap.java | 27 +- .../demo/util/SampleCalendarDatabase.java | 25 +- .../toolkit/demo/util/SampleDatabase.java | 19 +- .../toolkit/demo/util/SampleDirectory.java | 6 +- src/com/itmill/toolkit/event/Action.java | 30 +-- src/com/itmill/toolkit/event/EventRouter.java | 52 ++-- .../itmill/toolkit/event/ListenerMethod.java | 54 ++-- .../toolkit/event/MethodEventSource.java | 30 +-- .../itmill/toolkit/event/ShortcutAction.java | 8 +- .../launcher/ITMillToolkitDesktopMode.java | 39 +-- .../launcher/ITMillToolkitWebMode.java | 26 +- .../launcher/util/BrowserLauncher.java | 21 +- .../toolkit/service/ApplicationContext.java | 30 +-- .../toolkit/service/FileTypeResolver.java | 53 ++-- .../toolkit/terminal/ApplicationResource.java | 30 +-- .../toolkit/terminal/ClassResource.java | 38 +-- .../terminal/CompositeErrorMessage.java | 40 +-- .../toolkit/terminal/DownloadStream.java | 30 +-- .../itmill/toolkit/terminal/ErrorMessage.java | 30 +-- .../toolkit/terminal/ExternalResource.java | 30 +-- .../itmill/toolkit/terminal/FileResource.java | 36 +-- .../itmill/toolkit/terminal/KeyMapper.java | 36 +-- .../toolkit/terminal/PaintException.java | 30 +-- .../itmill/toolkit/terminal/PaintTarget.java | 30 +-- .../itmill/toolkit/terminal/Paintable.java | 30 +-- .../toolkit/terminal/ParameterHandler.java | 30 +-- src/com/itmill/toolkit/terminal/Resource.java | 30 +-- .../itmill/toolkit/terminal/Scrollable.java | 30 +-- src/com/itmill/toolkit/terminal/Sizeable.java | 30 +-- .../toolkit/terminal/StreamResource.java | 38 +-- .../itmill/toolkit/terminal/SystemError.java | 34 +-- src/com/itmill/toolkit/terminal/Terminal.java | 30 +-- .../toolkit/terminal/ThemeResource.java | 30 +-- .../itmill/toolkit/terminal/URIHandler.java | 30 +-- .../itmill/toolkit/terminal/UploadStream.java | 30 +-- .../itmill/toolkit/terminal/UserError.java | 32 +-- .../toolkit/terminal/VariableOwner.java | 30 +-- .../gwt/client/ApplicationConnection.java | 91 +++---- .../toolkit/terminal/gwt/client/Caption.java | 12 +- .../terminal/gwt/client/CaptionWrapper.java | 4 + .../toolkit/terminal/gwt/client/Console.java | 4 + .../terminal/gwt/client/Container.java | 4 + .../gwt/client/ContainerResizedListener.java | 4 + .../terminal/gwt/client/DateLocale.java | 12 +- .../terminal/gwt/client/DateTimeService.java | 46 ++-- .../terminal/gwt/client/DebugConsole.java | 8 +- .../terminal/gwt/client/DefaultWidgetSet.java | 10 +- .../terminal/gwt/client/ErrorMessage.java | 16 +- .../gwt/client/LocaleNotLoadedException.java | 4 + .../terminal/gwt/client/LocaleService.java | 52 ++-- .../terminal/gwt/client/NullConsole.java | 4 + .../terminal/gwt/client/Paintable.java | 4 + .../terminal/gwt/client/StyleConstants.java | 4 + .../toolkit/terminal/gwt/client/UIDL.java | 134 +++++----- .../toolkit/terminal/gwt/client/Util.java | 52 ++-- .../terminal/gwt/client/WidgetSet.java | 4 + .../terminal/gwt/client/ui/Action.java | 6 +- .../terminal/gwt/client/ui/AlignmentInfo.java | 4 + .../terminal/gwt/client/ui/CalendarEntry.java | 6 +- .../terminal/gwt/client/ui/CalendarPanel.java | 50 ++-- .../terminal/gwt/client/ui/ContextMenu.java | 10 +- .../terminal/gwt/client/ui/IButton.java | 10 +- .../terminal/gwt/client/ui/ICheckBox.java | 8 +- .../gwt/client/ui/ICustomComponent.java | 8 +- .../terminal/gwt/client/ui/ICustomLayout.java | 49 ++-- .../terminal/gwt/client/ui/IDateField.java | 54 ++-- .../gwt/client/ui/IDateFieldCalendar.java | 6 +- .../terminal/gwt/client/ui/IEmbedded.java | 12 +- .../terminal/gwt/client/ui/IExpandLayout.java | 110 +++++---- .../terminal/gwt/client/ui/IFilterSelect.java | 123 +++++----- .../toolkit/terminal/gwt/client/ui/IForm.java | 6 +- .../terminal/gwt/client/ui/IFormLayout.java | 19 +- .../terminal/gwt/client/ui/IGridLayout.java | 28 ++- .../client/ui/IHorizontalExpandLayout.java | 4 + .../terminal/gwt/client/ui/ILabel.java | 6 +- .../toolkit/terminal/gwt/client/ui/ILink.java | 10 +- .../terminal/gwt/client/ui/IListSelect.java | 12 +- .../terminal/gwt/client/ui/INativeSelect.java | 10 +- .../terminal/gwt/client/ui/IOptionGroup.java | 16 +- .../gwt/client/ui/IOptionGroupBase.java | 10 +- .../gwt/client/ui/IOrderedLayout.java | 78 +++--- .../client/ui/IOrderedLayoutHorizontal.java | 4 + .../gwt/client/ui/IOrderedLayoutVertical.java | 4 + .../terminal/gwt/client/ui/IPanel.java | 40 +-- .../gwt/client/ui/IPasswordField.java | 4 + .../gwt/client/ui/IPopupCalendar.java | 14 +- .../gwt/client/ui/IProgressIndicator.java | 15 +- .../terminal/gwt/client/ui/IScrollTable.java | 209 ++++++++-------- .../terminal/gwt/client/ui/ISlider.java | 64 ++--- .../terminal/gwt/client/ui/ISplitPanel.java | 22 +- .../gwt/client/ui/ISplitPanelHorizontal.java | 4 + .../gwt/client/ui/ISplitPanelVertical.java | 4 + .../terminal/gwt/client/ui/ITablePaging.java | 71 +++--- .../terminal/gwt/client/ui/ITabsheet.java | 70 +++--- .../gwt/client/ui/ITabsheetPanel.java | 6 +- .../terminal/gwt/client/ui/ITextArea.java | 4 + .../terminal/gwt/client/ui/ITextField.java | 42 ++-- .../terminal/gwt/client/ui/ITextualDate.java | 19 +- .../toolkit/terminal/gwt/client/ui/ITree.java | 44 ++-- .../gwt/client/ui/ITwinColSelect.java | 51 ++-- .../gwt/client/ui/IUnknownComponent.java | 6 +- .../terminal/gwt/client/ui/IUpload.java | 6 +- .../toolkit/terminal/gwt/client/ui/IView.java | 34 +-- .../terminal/gwt/client/ui/IWindow.java | 57 +++-- .../toolkit/terminal/gwt/client/ui/Icon.java | 6 +- .../terminal/gwt/client/ui/MarginInfo.java | 4 + .../terminal/gwt/client/ui/MenuBar.java | 43 ++-- .../terminal/gwt/client/ui/MenuItem.java | 6 +- .../terminal/gwt/client/ui/Notification.java | 8 +- .../gwt/client/ui/ShortcutActionHandler.java | 28 ++- .../toolkit/terminal/gwt/client/ui/Table.java | 4 + .../toolkit/terminal/gwt/client/ui/Time.java | 45 ++-- .../gwt/client/ui/ToolkitOverlay.java | 4 + .../terminal/gwt/client/ui/TreeAction.java | 4 + .../terminal/gwt/client/ui/TreeImages.java | 4 + .../client/ui/richtextarea/IRichTextArea.java | 8 +- .../ui/richtextarea/RichTextToolbar.java | 34 +-- .../terminal/gwt/client/util/DateLocale.java | 4 + .../terminal/gwt/client/util/Pattern.java | 48 ++-- .../gwt/client/util/SimpleDateFormat.java | 10 +- .../gwt/client/util/SimpleDateParser.java | 25 +- .../gwt/server/ApplicationServlet.java | 187 +++++++------- .../gwt/server/CommunicationManager.java | 193 +++++++-------- .../terminal/gwt/server/HttpUploadStream.java | 38 +-- .../terminal/gwt/server/JsonPaintTarget.java | 81 +++--- .../gwt/server/WebApplicationContext.java | 59 ++--- .../terminal/gwt/server/WebBrowser.java | 12 +- .../terminal/web/ApplicationServlet.java | 4 + .../itmill/toolkit/tests/BasicRandomTest.java | 72 +++--- .../tests/PerformanceTestSubTreeCaching.java | 16 +- .../toolkit/tests/RandomLayoutStress.java | 28 ++- .../itmill/toolkit/tests/TableSelectTest.java | 12 +- src/com/itmill/toolkit/tests/TestBench.java | 64 ++--- .../toolkit/tests/TestCaptionWrapper.java | 66 ++--- .../tests/TestComponentsAndLayouts.java | 105 ++++---- .../itmill/toolkit/tests/TestDateField.java | 15 +- .../toolkit/tests/TestForAlignments.java | 26 +- ...cationLayoutThatUsesWholeBrosersSpace.java | 14 +- .../tests/TestForBasicApplicationLayout.java | 25 +- .../tests/TestForChildComponentRendering.java | 26 +- .../tests/TestForContainerFilterable.java | 10 +- .../toolkit/tests/TestForExpandLayout.java | 14 +- ...tForGridLayoutChildComponentRendering.java | 28 ++- .../tests/TestForMultipleStyleNames.java | 21 +- .../toolkit/tests/TestForNativeWindowing.java | 12 +- .../tests/TestForPreconfiguredComponents.java | 14 +- .../toolkit/tests/TestForRichTextEditor.java | 6 +- ...ablesInitialColumnWidthLogicRendering.java | 12 +- .../itmill/toolkit/tests/TestForTrees.java | 18 +- .../itmill/toolkit/tests/TestForUpload.java | 24 +- .../toolkit/tests/TestForWindowOpen.java | 12 +- .../toolkit/tests/TestForWindowing.java | 82 ++++--- src/com/itmill/toolkit/tests/TestIFrames.java | 12 +- .../TestSelectAndDatefieldInDeepLayouts.java | 18 +- .../tests/TestSetVisibleAndCaching.java | 6 +- .../itmill/toolkit/tests/TestSplitPanel.java | 6 +- .../toolkit/tests/UsingObjectsInSelect.java | 27 +- .../toolkit/tests/featurebrowser/Feature.java | 46 +--- .../tests/featurebrowser/FeatureBrowser.java | 51 ++-- .../featurebrowser/FeatureBuffering.java | 42 +--- .../tests/featurebrowser/FeatureButton.java | 38 +-- .../featurebrowser/FeatureContainers.java | 42 +--- .../featurebrowser/FeatureCustomLayout.java | 42 +--- .../featurebrowser/FeatureDateField.java | 40 +-- .../tests/featurebrowser/FeatureEmbedded.java | 50 +--- .../tests/featurebrowser/FeatureForm.java | 42 +--- .../featurebrowser/FeatureGridLayout.java | 40 +-- .../tests/featurebrowser/FeatureItems.java | 42 +--- .../tests/featurebrowser/FeatureLabel.java | 36 +-- .../tests/featurebrowser/FeatureLink.java | 36 +-- .../featurebrowser/FeatureOrderedLayout.java | 38 +-- .../tests/featurebrowser/FeaturePanel.java | 40 +-- .../featurebrowser/FeatureParameters.java | 62 ++--- .../featurebrowser/FeatureProperties.java | 42 +--- .../tests/featurebrowser/FeatureSelect.java | 36 +-- .../tests/featurebrowser/FeatureTabSheet.java | 34 +-- .../tests/featurebrowser/FeatureTable.java | 48 +--- .../featurebrowser/FeatureTextField.java | 38 +-- .../tests/featurebrowser/FeatureTree.java | 56 ++--- .../tests/featurebrowser/FeatureUpload.java | 34 +-- .../tests/featurebrowser/FeatureUtil.java | 6 +- .../featurebrowser/FeatureValidators.java | 42 +--- .../tests/featurebrowser/FeatureWindow.java | 41 +--- .../featurebrowser/FeaturesApplication.java | 34 +-- .../tests/featurebrowser/IntroBasic.java | 42 +--- .../tests/featurebrowser/IntroComponents.java | 42 +--- .../featurebrowser/IntroDataHandling.java | 42 +--- .../tests/featurebrowser/IntroDataModel.java | 42 +--- .../featurebrowser/IntroItemContainers.java | 42 +--- .../tests/featurebrowser/IntroLayouts.java | 42 +--- .../tests/featurebrowser/IntroTerminal.java | 34 +-- .../tests/featurebrowser/IntroWelcome.java | 48 +--- .../tests/featurebrowser/PropertyPanel.java | 109 ++++---- .../tests/magi/DefaultButtonExample.java | 6 +- .../toolkit/tests/magi/EmbeddedButton.java | 4 + .../tests/magi/MagiTestApplication.java | 113 +++++---- .../itmill/toolkit/tests/magi/MyUploader.java | 18 +- .../itmill/toolkit/tests/magi/SSNField.java | 16 +- .../toolkit/tests/magi/SelectExample.java | 4 + .../toolkit/tests/magi/TabSheetExample.java | 107 ++++---- .../toolkit/tests/magi/TableExample.java | 4 + .../itmill/toolkit/tests/magi/TheButton.java | 4 + .../itmill/toolkit/tests/magi/TheButtons.java | 4 + .../toolkit/tests/magi/TheButtons2.java | 4 + .../toolkit/tests/magi/TheButtons3.java | 4 + .../toolkit/tests/magi/WindowOpener.java | 6 +- .../toolkit/tests/testbench/TestBench.java | 64 ++--- .../tests/testbench/TestForAlignments.java | 26 +- .../TestForBasicApplicationLayout.java | 31 ++- .../testbench/TestForContainerFilterable.java | 18 +- .../testbench/TestForMultipleStyleNames.java | 21 +- .../TestForPreconfiguredComponents.java | 14 +- .../testbench/TestForRichTextEditor.java | 6 +- .../toolkit/tests/testbench/TestForTrees.java | 18 +- .../tests/testbench/TestForUpload.java | 24 +- .../tests/testbench/TestForWindowOpen.java | 12 +- .../tests/testbench/TestForWindowing.java | 82 ++++--- .../testbench/TestSetVisibleAndCaching.java | 6 +- .../tests/testbench/TestSplitPanel.java | 6 +- .../itmill/toolkit/ui/AbstractComponent.java | 46 +--- .../ui/AbstractComponentContainer.java | 50 +--- src/com/itmill/toolkit/ui/AbstractField.java | 83 +++---- src/com/itmill/toolkit/ui/AbstractLayout.java | 4 + src/com/itmill/toolkit/ui/AbstractSelect.java | 129 ++++------ .../itmill/toolkit/ui/BaseFieldFactory.java | 37 +-- src/com/itmill/toolkit/ui/Button.java | 38 +-- src/com/itmill/toolkit/ui/CheckBox.java | 4 + src/com/itmill/toolkit/ui/ComboBox.java | 5 +- src/com/itmill/toolkit/ui/Component.java | 32 +-- .../itmill/toolkit/ui/ComponentContainer.java | 34 +-- .../itmill/toolkit/ui/CustomComponent.java | 38 +-- src/com/itmill/toolkit/ui/CustomLayout.java | 46 +--- src/com/itmill/toolkit/ui/DateField.java | 52 ++-- src/com/itmill/toolkit/ui/Embedded.java | 36 +-- src/com/itmill/toolkit/ui/ExpandLayout.java | 10 +- src/com/itmill/toolkit/ui/Field.java | 30 +-- src/com/itmill/toolkit/ui/FieldFactory.java | 30 +-- src/com/itmill/toolkit/ui/Form.java | 115 ++++----- src/com/itmill/toolkit/ui/FormLayout.java | 4 + src/com/itmill/toolkit/ui/GridLayout.java | 92 +++---- .../itmill/toolkit/ui/InlineDateField.java | 5 +- src/com/itmill/toolkit/ui/Label.java | 36 +-- src/com/itmill/toolkit/ui/Layout.java | 30 +-- src/com/itmill/toolkit/ui/Link.java | 32 +-- src/com/itmill/toolkit/ui/ListSelect.java | 4 + src/com/itmill/toolkit/ui/NativeSelect.java | 4 + src/com/itmill/toolkit/ui/OptionGroup.java | 5 +- src/com/itmill/toolkit/ui/OrderedLayout.java | 49 +--- src/com/itmill/toolkit/ui/Panel.java | 60 ++--- src/com/itmill/toolkit/ui/PopupDateField.java | 5 +- .../itmill/toolkit/ui/ProgressIndicator.java | 30 +-- src/com/itmill/toolkit/ui/RichTextArea.java | 4 + src/com/itmill/toolkit/ui/Select.java | 64 ++--- src/com/itmill/toolkit/ui/Slider.java | 30 ++- src/com/itmill/toolkit/ui/SplitPanel.java | 32 +-- src/com/itmill/toolkit/ui/TabSheet.java | 64 ++--- src/com/itmill/toolkit/ui/Table.java | 232 ++++++++---------- src/com/itmill/toolkit/ui/TextField.java | 40 +-- src/com/itmill/toolkit/ui/Tree.java | 105 ++++---- src/com/itmill/toolkit/ui/TwinColSelect.java | 5 +- src/com/itmill/toolkit/ui/Upload.java | 58 ++--- src/com/itmill/toolkit/ui/Window.java | 90 +++---- 331 files changed, 4569 insertions(+), 6514 deletions(-) diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java index 1ae6dd98d7..28355b9847 100644 --- a/src/com/itmill/toolkit/Application.java +++ b/src/com/itmill/toolkit/Application.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit; @@ -130,7 +106,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * Mapping from window name to window instance. */ - private Hashtable windows = new Hashtable(); + private final Hashtable windows = new Hashtable(); /** * Main window of the application. @@ -180,9 +156,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * Application resource mapping: key <-> resource. */ - private Hashtable resourceKeyMap = new Hashtable(); + private final Hashtable resourceKeyMap = new Hashtable(); - private Hashtable keyResourceMap = new Hashtable(); + private final Hashtable keyResourceMap = new Hashtable(); private long lastResourceKeyNumber = 0; @@ -230,7 +206,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener } // Gets the window by name - Window window = (Window) windows.get(name); + final Window window = (Window) windows.get(name); return window; } @@ -324,8 +300,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener private void fireWindowAttachEvent(Window window) { // Fires the window attach event if (windowAttachListeners != null) { - Object[] listeners = windowAttachListeners.toArray(); - WindowAttachEvent event = new WindowAttachEvent(window); + final Object[] listeners = windowAttachListeners.toArray(); + final WindowAttachEvent event = new WindowAttachEvent(window); for (int i = 0; i < listeners.length; i++) { ((WindowAttachListener) listeners[i]).windowAttached(event); } @@ -361,8 +337,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener private void fireWindowDetachEvent(Window window) { // Fires the window detach event if (windowDetachListeners != null) { - Object[] listeners = windowDetachListeners.toArray(); - WindowDetachEvent event = new WindowDetachEvent(window); + final Object[] listeners = windowDetachListeners.toArray(); + final WindowDetachEvent event = new WindowDetachEvent(window); for (int i = 0; i < listeners.length; i++) { ((WindowDetachListener) listeners[i]).windowDetached(event); } @@ -394,12 +370,12 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * the new user. */ public void setUser(Object user) { - Object prevUser = this.user; + final Object prevUser = this.user; if (user != prevUser && (user == null || !user.equals(prevUser))) { this.user = user; if (userChangeListeners != null) { - Object[] listeners = userChangeListeners.toArray(); - UserChangeEvent event = new UserChangeEvent(this, user, + final Object[] listeners = userChangeListeners.toArray(); + final UserChangeEvent event = new UserChangeEvent(this, user, prevUser); for (int i = 0; i < listeners.length; i++) { ((UserChangeListener) listeners[i]) @@ -502,11 +478,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener public void setTheme(String theme) { // Collect list of windows not having the current or future theme - LinkedList toBeUpdated = new LinkedList(); - String myTheme = getTheme(); - for (Iterator i = getWindows().iterator(); i.hasNext();) { - Window w = (Window) i.next(); - String windowTheme = w.getTheme(); + final LinkedList toBeUpdated = new LinkedList(); + final String myTheme = getTheme(); + for (final Iterator i = getWindows().iterator(); i.hasNext();) { + final Window w = (Window) i.next(); + final String windowTheme = w.getTheme(); if ((windowTheme == null) || (!theme.equals(windowTheme) && windowTheme .equals(myTheme))) { @@ -518,7 +494,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener this.theme = theme; // Ask windows to update themselves - for (Iterator i = toBeUpdated.iterator(); i.hasNext();) { + for (final Iterator i = toBeUpdated.iterator(); i.hasNext();) { ((Window) i.next()).requestRepaint(); } } @@ -586,7 +562,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener } // Generate key - String key = String.valueOf(++lastResourceKeyNumber); + final String key = String.valueOf(++lastResourceKeyNumber); // Add the resource to mappings resourceKeyMap.put(resource, key); @@ -600,7 +576,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * the resource to remove. */ public void removeResource(ApplicationResource resource) { - Object key = resourceKeyMap.get(resource); + final Object key = resourceKeyMap.get(resource); if (key != null) { resourceKeyMap.remove(resource); keyResourceMap.remove(key); @@ -617,14 +593,14 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener public String getRelativeLocation(ApplicationResource resource) { // Gets the key - String key = (String) resourceKeyMap.get(resource); + final String key = (String) resourceKeyMap.get(resource); // If the resource is not registered, return null if (key == null) { return null; } - String filename = resource.getFilename(); + final String filename = resource.getFilename(); if (filename == null) { return "APP/" + key + "/"; } else { @@ -644,7 +620,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener // Resolves the prefix String prefix = relativeUri; - int index = relativeUri.indexOf('/'); + final int index = relativeUri.indexOf('/'); if (index >= 0) { prefix = relativeUri.substring(0, index); } @@ -653,12 +629,12 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener if (prefix.equals("APP")) { // Handles the resource request - int next = relativeUri.indexOf('/', index + 1); + final int next = relativeUri.indexOf('/', index + 1); if (next < 0) { return null; } - String key = relativeUri.substring(index + 1, next); - ApplicationResource resource = (ApplicationResource) keyResourceMap + final String key = relativeUri.substring(index + 1, next); + final ApplicationResource resource = (ApplicationResource) keyResourceMap .get(key); if (resource != null) { return resource.getStream(); @@ -674,11 +650,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener URL windowContext; try { windowContext = new URL(context, prefix + "/"); - String windowUri = relativeUri.length() > prefix.length() + 1 ? relativeUri + final String windowUri = relativeUri.length() > prefix.length() + 1 ? relativeUri .substring(prefix.length() + 1) : ""; return window.handleURI(windowContext, windowUri); - } catch (MalformedURLException e) { + } catch (final MalformedURLException e) { return null; } } @@ -737,12 +713,12 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * New user of the application. */ - private Object newUser; + private final Object newUser; /** * Previous user of the application. */ - private Object prevUser; + private final Object prevUser; /** * Constructor for user change event. @@ -849,7 +825,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener */ private static final long serialVersionUID = 3544669568644691769L; - private Window window; + private final Window window; /** * Creates a event. @@ -891,7 +867,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener */ private static final long serialVersionUID = 3977578104367822392L; - private Window window; + private final Window window; /** * Creates a event. @@ -1066,7 +1042,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener // Shows the error in AbstractComponent if (owner instanceof AbstractComponent) { - Throwable e = event.getThrowable(); + final Throwable e = event.getThrowable(); if (e instanceof ErrorMessage) { ((AbstractComponent) owner).setComponentError((ErrorMessage) e); } else { @@ -1099,7 +1075,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * @return Focused component or null if none is focused. */ public Component.Focusable consumeFocus() { - Component.Focusable f = pendingFocus; + final Component.Focusable f = pendingFocus; pendingFocus = null; return f; } diff --git a/src/com/itmill/toolkit/data/Buffered.java b/src/com/itmill/toolkit/data/Buffered.java index 94f7c3649e..bddcb8489e 100644 --- a/src/com/itmill/toolkit/data/Buffered.java +++ b/src/com/itmill/toolkit/data/Buffered.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data; @@ -175,7 +151,7 @@ public interface Buffered { private static final long serialVersionUID = 3256720671781630518L; /** Source class implementing the buffered interface */ - private Buffered source; + private final Buffered source; /** Original cause of the source exception */ private Throwable[] causes = {}; @@ -266,7 +242,7 @@ public interface Buffered { int level = Integer.MIN_VALUE; for (int i = 0; i < causes.length; i++) { - int causeLevel = (causes[i] instanceof ErrorMessage) ? ((ErrorMessage) causes[i]) + final int causeLevel = (causes[i] instanceof ErrorMessage) ? ((ErrorMessage) causes[i]) .getErrorLevel() : ErrorMessage.ERROR; if (causeLevel > level) { @@ -280,7 +256,7 @@ public interface Buffered { /* Documented in super interface */ public void paint(PaintTarget target) throws PaintException { target.startTag("error"); - int level = getErrorLevel(); + final int level = getErrorLevel(); if (level > 0 && level <= ErrorMessage.INFORMATION) { target.addAttribute("level", "info"); } else if (level <= ErrorMessage.WARNING) { diff --git a/src/com/itmill/toolkit/data/BufferedValidatable.java b/src/com/itmill/toolkit/data/BufferedValidatable.java index f5fd3566df..756936710a 100644 --- a/src/com/itmill/toolkit/data/BufferedValidatable.java +++ b/src/com/itmill/toolkit/data/BufferedValidatable.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data; diff --git a/src/com/itmill/toolkit/data/Container.java b/src/com/itmill/toolkit/data/Container.java index d57ae6af30..46cedf8e25 100644 --- a/src/com/itmill/toolkit/data/Container.java +++ b/src/com/itmill/toolkit/data/Container.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data; diff --git a/src/com/itmill/toolkit/data/Item.java b/src/com/itmill/toolkit/data/Item.java index a06a9dd72d..4645dbae98 100644 --- a/src/com/itmill/toolkit/data/Item.java +++ b/src/com/itmill/toolkit/data/Item.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data; diff --git a/src/com/itmill/toolkit/data/Property.java b/src/com/itmill/toolkit/data/Property.java index aa9a79b6d0..2b5543c4d3 100644 --- a/src/com/itmill/toolkit/data/Property.java +++ b/src/com/itmill/toolkit/data/Property.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data; diff --git a/src/com/itmill/toolkit/data/Validatable.java b/src/com/itmill/toolkit/data/Validatable.java index 9219dc8b85..a80ed776b8 100644 --- a/src/com/itmill/toolkit/data/Validatable.java +++ b/src/com/itmill/toolkit/data/Validatable.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data; diff --git a/src/com/itmill/toolkit/data/Validator.java b/src/com/itmill/toolkit/data/Validator.java index 2dcbb5bb43..b56186bf69 100644 --- a/src/com/itmill/toolkit/data/Validator.java +++ b/src/com/itmill/toolkit/data/Validator.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data; @@ -157,7 +133,7 @@ public interface Validator { target.addAttribute("level", "error"); // Error message - String message = getLocalizedMessage(); + final String message = getLocalizedMessage(); if (message != null) { target.addText(message); } diff --git a/src/com/itmill/toolkit/data/util/BeanItem.java b/src/com/itmill/toolkit/data/util/BeanItem.java index d5cb263274..330b592634 100644 --- a/src/com/itmill/toolkit/data/util/BeanItem.java +++ b/src/com/itmill/toolkit/data/util/BeanItem.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -50,7 +26,7 @@ public class BeanItem extends PropertysetItem { /** * The bean which this Item is based on. */ - private Object bean; + private final Object bean; /** *

@@ -76,23 +52,23 @@ public class BeanItem extends PropertysetItem { // Try to introspect, if it fails, we just have an empty Item try { // Create bean information - BeanInfo info = Introspector.getBeanInfo(bean.getClass()); - PropertyDescriptor[] pd = info.getPropertyDescriptors(); + final BeanInfo info = Introspector.getBeanInfo(bean.getClass()); + final PropertyDescriptor[] pd = info.getPropertyDescriptors(); // Add all the bean properties as MethodProperties to this Item for (int i = 0; i < pd.length; i++) { - Method getMethod = pd[i].getReadMethod(); - Method setMethod = pd[i].getWriteMethod(); - Class type = pd[i].getPropertyType(); - String name = pd[i].getName(); + final Method getMethod = pd[i].getReadMethod(); + final Method setMethod = pd[i].getWriteMethod(); + final Class type = pd[i].getPropertyType(); + final String name = pd[i].getName(); if ((getMethod != null) && (setMethod != null)) { - Property p = new MethodProperty(type, bean, getMethod, - setMethod); + final Property p = new MethodProperty(type, bean, + getMethod, setMethod); addItemProperty(name, p); } } - } catch (java.beans.IntrospectionException ignored) { + } catch (final java.beans.IntrospectionException ignored) { } } @@ -121,27 +97,27 @@ public class BeanItem extends PropertysetItem { // Try to introspect, if it fails, we just have an empty Item try { // Create bean information - BeanInfo info = Introspector.getBeanInfo(bean.getClass()); - PropertyDescriptor[] pd = info.getPropertyDescriptors(); + final BeanInfo info = Introspector.getBeanInfo(bean.getClass()); + final PropertyDescriptor[] pd = info.getPropertyDescriptors(); // Add all the bean properties as MethodProperties to this Item - for (Iterator iter = propertyIds.iterator(); iter.hasNext();) { - Object id = iter.next(); + for (final Iterator iter = propertyIds.iterator(); iter.hasNext();) { + final Object id = iter.next(); for (int i = 0; i < pd.length; i++) { - String name = pd[i].getName(); + final String name = pd[i].getName(); if (name.equals(id)) { - Method getMethod = pd[i].getReadMethod(); - Method setMethod = pd[i].getWriteMethod(); - Class type = pd[i].getPropertyType(); + final Method getMethod = pd[i].getReadMethod(); + final Method setMethod = pd[i].getWriteMethod(); + final Class type = pd[i].getPropertyType(); - Property p = new MethodProperty(type, bean, getMethod, - setMethod); + final Property p = new MethodProperty(type, bean, + getMethod, setMethod); addItemProperty(name, p); } } } - } catch (java.beans.IntrospectionException ignored) { + } catch (final java.beans.IntrospectionException ignored) { } } diff --git a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java index 6246775f1f..6285854873 100644 --- a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java +++ b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -60,7 +36,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier { /** The wrapped container */ - private Container container; + private final Container container; /** Set of IDs of those contained Items that can't have children. */ private HashSet noChildrenAllowed = null; @@ -130,23 +106,23 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, else { // Calculate the set of all items in the hierarchy - HashSet s = new HashSet(); + final HashSet s = new HashSet(); s.add(parent.keySet()); s.add(children.keySet()); s.addAll(roots); // Remove unnecessary items - for (Iterator i = s.iterator(); i.hasNext();) { - Object id = i.next(); + for (final Iterator i = s.iterator(); i.hasNext();) { + final Object id = i.next(); if (!container.containsId(id)) { removeFromHierarchyWrapper(id); } } // Add all the missing items - Collection ids = container.getItemIds(); - for (Iterator i = ids.iterator(); i.hasNext();) { - Object id = i.next(); + final Collection ids = container.getItemIds(); + for (final Iterator i = ids.iterator(); i.hasNext();) { + final Object id = i.next(); if (!s.contains(id)) { addToHierarchyWrapper(id); s.add(id); @@ -171,9 +147,9 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, if (isRoot(itemId)) { roots.remove(itemId); } - Object p = parent.get(itemId); + final Object p = parent.get(itemId); if (p != null) { - LinkedList c = (LinkedList) children.get(p); + final LinkedList c = (LinkedList) children.get(p); if (c != null) { c.remove(itemId); } @@ -221,7 +197,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, return ((Container.Hierarchical) container).getChildren(itemId); } - Collection c = (Collection) children.get(itemId); + final Collection c = (Collection) children.get(itemId); if (c == null) { return null; } @@ -361,7 +337,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, } // Get the old parent - Object oldParentId = parent.get(itemId); + final Object oldParentId = parent.get(itemId); // Check if no change is necessary if ((newParentId == null && oldParentId == null) @@ -373,7 +349,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, if (newParentId == null) { // Remove from old parents children list - LinkedList l = (LinkedList) children.get(itemId); + final LinkedList l = (LinkedList) children.get(itemId); if (l != null) { l.remove(itemId); if (l.isEmpty()) { @@ -418,7 +394,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, if (oldParentId == null) { roots.remove(itemId); } else { - LinkedList l = (LinkedList) children.get(oldParentId); + final LinkedList l = (LinkedList) children.get(oldParentId); if (l != null) { l.remove(itemId); if (l.isEmpty()) { @@ -441,7 +417,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, */ public Object addItem() throws UnsupportedOperationException { - Object id = container.addItem(); + final Object id = container.addItem(); if (id != null) { addToHierarchyWrapper(id); } @@ -460,7 +436,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, */ public Item addItem(Object itemId) throws UnsupportedOperationException { - Item item = container.addItem(itemId); + final Item item = container.addItem(itemId); if (item != null) { addToHierarchyWrapper(itemId); } @@ -477,7 +453,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, */ public boolean removeAllItems() throws UnsupportedOperationException { - boolean success = container.removeAllItems(); + final boolean success = container.removeAllItems(); if (success) { roots.clear(); @@ -502,7 +478,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, public boolean removeItem(Object itemId) throws UnsupportedOperationException { - boolean success = container.removeItem(itemId); + final boolean success = container.removeItem(itemId); if (success) { removeFromHierarchyWrapper(itemId); diff --git a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java index b2fc22e8f8..c5d8ee1e8c 100644 --- a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java +++ b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -60,7 +36,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, /** * The wrapped container */ - private Container container; + private final Container container; /** * Ordering information, ie. the mapping from Item ID to the next item ID @@ -123,8 +99,8 @@ public class ContainerOrderedWrapper implements Container.Ordered, */ private void removeFromOrderWrapper(Object id) { if (id != null) { - Object pid = prev.get(id); - Object nid = next.get(id); + final Object pid = prev.get(id); + final Object nid = next.get(id); if (first.equals(id)) { first = nid; } @@ -202,7 +178,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, if (!ordered) { - Collection ids = container.getItemIds(); + final Collection ids = container.getItemIds(); // Recreates ordering if some parts of it are missing if (next == null || first == null || last == null || prev != null) { @@ -213,17 +189,17 @@ public class ContainerOrderedWrapper implements Container.Ordered, } // Filter out all the missing items - LinkedList l = new LinkedList(next.keySet()); - for (Iterator i = l.iterator(); i.hasNext();) { - Object id = i.next(); + final LinkedList l = new LinkedList(next.keySet()); + for (final Iterator i = l.iterator(); i.hasNext();) { + final Object id = i.next(); if (!container.containsId(id)) { removeFromOrderWrapper(id); } } // Adds missing items - for (Iterator i = ids.iterator(); i.hasNext();) { - Object id = i.next(); + for (final Iterator i = ids.iterator(); i.hasNext();) { + final Object id = i.next(); if (!next.containsKey(id)) { addToOrderWrapper(id); } @@ -332,7 +308,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, */ public Object addItem() throws UnsupportedOperationException { - Object id = container.addItem(); + final Object id = container.addItem(); if (id != null) { addToOrderWrapper(id); } @@ -350,7 +326,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, * if the addItem is not supported. */ public Item addItem(Object itemId) throws UnsupportedOperationException { - Item item = container.addItem(itemId); + final Item item = container.addItem(itemId); if (item != null) { addToOrderWrapper(itemId); } @@ -366,7 +342,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, * if the removeAllItems is not supported. */ public boolean removeAllItems() throws UnsupportedOperationException { - boolean success = container.removeAllItems(); + final boolean success = container.removeAllItems(); if (success) { first = last = null; next.clear(); @@ -389,7 +365,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, public boolean removeItem(Object itemId) throws UnsupportedOperationException { - boolean success = container.removeItem(itemId); + final boolean success = container.removeItem(itemId); if (success) { removeFromOrderWrapper(itemId); } @@ -536,7 +512,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, } // Adds the item to container - Item item = container.addItem(newItemId); + final Item item = container.addItem(newItemId); // Puts the new item to its correct place if (item != null) { @@ -558,7 +534,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, } // Adds the item to container - Object id = container.addItem(); + final Object id = container.addItem(); // Puts the new item to its correct place if (id != null) { diff --git a/src/com/itmill/toolkit/data/util/FilesystemContainer.java b/src/com/itmill/toolkit/data/util/FilesystemContainer.java index 789dd110aa..9493533223 100644 --- a/src/com/itmill/toolkit/data/util/FilesystemContainer.java +++ b/src/com/itmill/toolkit/data/util/FilesystemContainer.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -104,7 +80,7 @@ public class FilesystemContainer implements Container.Hierarchical { FILEITEM_NAME = FileItem.class.getMethod("getName", new Class[] {}); FILEITEM_ICON = FileItem.class.getMethod("getIcon", new Class[] {}); FILEITEM_SIZE = FileItem.class.getMethod("getSize", new Class[] {}); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { } } @@ -189,7 +165,7 @@ public class FilesystemContainer implements Container.Hierarchical { */ public void addRoot(File root) { if (root != null) { - File[] newRoots = new File[roots.length + 1]; + final File[] newRoots = new File[roots.length + 1]; for (int i = 0; i < roots.length; i++) { newRoots[i] = roots[i]; } @@ -234,7 +210,7 @@ public class FilesystemContainer implements Container.Hierarchical { return Collections.unmodifiableCollection(new LinkedList()); } - List l = Arrays.asList(f); + final List l = Arrays.asList(f); Collections.sort(l); return Collections.unmodifiableCollection(l); @@ -312,7 +288,7 @@ public class FilesystemContainer implements Container.Hierarchical { return Collections.unmodifiableCollection(new LinkedList()); } - List l = Arrays.asList(f); + final List l = Arrays.asList(f); Collections.sort(l); return Collections.unmodifiableCollection(l); @@ -376,7 +352,7 @@ public class FilesystemContainer implements Container.Hierarchical { try { val |= ((File) itemId).getCanonicalPath().startsWith( roots[i].getCanonicalPath()); - } catch (IOException e) { + } catch (final IOException e) { // Exception ignored } @@ -416,11 +392,11 @@ public class FilesystemContainer implements Container.Hierarchical { } else { l = f.listFiles(); } - List ll = Arrays.asList(l); + final List ll = Arrays.asList(l); Collections.sort(ll); - for (Iterator i = ll.iterator(); i.hasNext();) { - File lf = (File) i.next(); + for (final Iterator i = ll.iterator(); i.hasNext();) { + final File lf = (File) i.next(); if (lf.isDirectory()) { addItemIds(col, lf); } else { @@ -436,7 +412,7 @@ public class FilesystemContainer implements Container.Hierarchical { public Collection getItemIds() { if (recursive) { - Collection col = new ArrayList(); + final Collection col = new ArrayList(); for (int i = 0; i < roots.length; i++) { addItemIds(col, roots[i]); } @@ -457,7 +433,7 @@ public class FilesystemContainer implements Container.Hierarchical { return Collections.unmodifiableCollection(new LinkedList()); } - List l = Arrays.asList(f); + final List l = Arrays.asList(f); Collections.sort(l); return Collections.unmodifiableCollection(l); } @@ -612,7 +588,7 @@ public class FilesystemContainer implements Container.Hierarchical { /** * The wrapped file. */ - private File file; + private final File file; /** * Constructs a FileItem from a existing file. @@ -664,7 +640,7 @@ public class FilesystemContainer implements Container.Hierarchical { if (obj == null || !(obj instanceof FileItem)) { return false; } - FileItem fi = (FileItem) obj; + final FileItem fi = (FileItem) obj; return fi.getHost() == getHost() && fi.file.equals(file); } @@ -759,7 +735,7 @@ public class FilesystemContainer implements Container.Hierarchical { */ public class FileExtensionFilter implements FilenameFilter { - private String filter; + private final String filter; /** * Constructs a new FileExtensionFilter using given extension. diff --git a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java index 81ff28546e..096c83f455 100644 --- a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java +++ b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -52,22 +28,22 @@ public class HierarchicalContainer extends IndexedContainer implements /** * Set of IDs of those contained Items that can't have children. */ - private HashSet noChildrenAllowed = new HashSet(); + private final HashSet noChildrenAllowed = new HashSet(); /** * Mapping from Item ID to parent Item. */ - private Hashtable parent = new Hashtable(); + private final Hashtable parent = new Hashtable(); /** * Mapping from Item ID to a list of child IDs. */ - private Hashtable children = new Hashtable(); + private final Hashtable children = new Hashtable(); /** * List that contains all root elements of the container. */ - private LinkedList roots = new LinkedList(); + private final LinkedList roots = new LinkedList(); /* * Can the specified Item have any children? Don't add a JavaDoc comment @@ -83,7 +59,7 @@ public class HierarchicalContainer extends IndexedContainer implements * interface. */ public Collection getChildren(Object itemId) { - Collection c = (Collection) children.get(itemId); + final Collection c = (Collection) children.get(itemId); if (c == null) { return null; } @@ -187,7 +163,7 @@ public class HierarchicalContainer extends IndexedContainer implements } // Gets the old parent - Object oldParentId = parent.get(itemId); + final Object oldParentId = parent.get(itemId); // Checks if no change is necessary if ((newParentId == null && oldParentId == null) @@ -199,7 +175,7 @@ public class HierarchicalContainer extends IndexedContainer implements if (newParentId == null) { // Removes from old parents children list - LinkedList l = (LinkedList) children.get(itemId); + final LinkedList l = (LinkedList) children.get(itemId); if (l != null) { l.remove(itemId); if (l.isEmpty()) { @@ -244,7 +220,7 @@ public class HierarchicalContainer extends IndexedContainer implements if (oldParentId == null) { roots.remove(itemId); } else { - LinkedList l = (LinkedList) children.get(oldParentId); + final LinkedList l = (LinkedList) children.get(oldParentId); if (l != null) { l.remove(itemId); if (l.isEmpty()) { @@ -260,7 +236,7 @@ public class HierarchicalContainer extends IndexedContainer implements * @see com.itmill.toolkit.data.Container#addItem() */ public Object addItem() { - Object id = super.addItem(); + final Object id = super.addItem(); if (id != null && !roots.contains(id)) { roots.add(id); } @@ -272,7 +248,7 @@ public class HierarchicalContainer extends IndexedContainer implements * @see com.itmill.toolkit.data.Container#addItem(Object) */ public Item addItem(Object itemId) { - Item item = super.addItem(itemId); + final Item item = super.addItem(itemId); if (item != null) { roots.add(itemId); } @@ -283,7 +259,7 @@ public class HierarchicalContainer extends IndexedContainer implements * @see com.itmill.toolkit.data.Container#removeAllItems() */ public boolean removeAllItems() { - boolean success = super.removeAllItems(); + final boolean success = super.removeAllItems(); if (success) { roots.clear(); @@ -298,16 +274,16 @@ public class HierarchicalContainer extends IndexedContainer implements * @see com.itmill.toolkit.data.Container#removeItem(Object) */ public boolean removeItem(Object itemId) { - boolean success = super.removeItem(itemId); + final boolean success = super.removeItem(itemId); if (success) { if (isRoot(itemId)) { roots.remove(itemId); } children.remove(itemId); - Object p = parent.get(itemId); + final Object p = parent.get(itemId); if (p != null) { - LinkedList c = (LinkedList) children.get(p); + final LinkedList c = (LinkedList) children.get(p); if (c != null) { c.remove(itemId); } diff --git a/src/com/itmill/toolkit/data/util/IndexedContainer.java b/src/com/itmill/toolkit/data/util/IndexedContainer.java index 00bd098548..cf8d81ccaf 100644 --- a/src/com/itmill/toolkit/data/util/IndexedContainer.java +++ b/src/com/itmill/toolkit/data/util/IndexedContainer.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -145,7 +121,7 @@ public class IndexedContainer implements Container, Container.Indexed, public IndexedContainer(Collection itemIds) { if (items != null) { - for (Iterator i = itemIds.iterator(); i.hasNext();) { + for (final Iterator i = itemIds.iterator(); i.hasNext();) { this.addItem(i.next()); } } @@ -290,7 +266,7 @@ public class IndexedContainer implements Container, Container.Indexed, // If default value is given, set it if (defaultValue != null) { - for (Iterator i = itemIds.iterator(); i.hasNext();) { + for (final Iterator i = itemIds.iterator(); i.hasNext();) { getItem(i.next()).getItemProperty(propertyId).setValue( defaultValue); } @@ -339,7 +315,7 @@ public class IndexedContainer implements Container, Container.Indexed, public Object addItem() { // Creates a new id - Object id = new Object(); + final Object id = new Object(); // Adds the Item into container addItem(id); @@ -367,7 +343,7 @@ public class IndexedContainer implements Container, Container.Indexed, // Adds the Item to container itemIds.add(itemId); items.put(itemId, new Hashtable()); - Item item = getItem(itemId); + final Item item = getItem(itemId); if (filteredItemIds != null) { if (passesFilters(item)) { filteredItemIds.add(itemId); @@ -424,7 +400,7 @@ public class IndexedContainer implements Container, Container.Indexed, types.remove(propertyId); // If remove the Property from all Items - for (Iterator i = itemIds.iterator(); i.hasNext();) { + for (final Iterator i = itemIds.iterator(); i.hasNext();) { ((Hashtable) items.get(i.next())).remove(propertyId); } @@ -447,8 +423,8 @@ public class IndexedContainer implements Container, Container.Indexed, return filteredItemIds.iterator().next(); } return itemIds.get(0); - } catch (IndexOutOfBoundsException e) { - } catch (NoSuchElementException e) { + } catch (final IndexOutOfBoundsException e) { + } catch (final NoSuchElementException e) { } return null; } @@ -461,7 +437,7 @@ public class IndexedContainer implements Container, Container.Indexed, public Object lastItemId() { try { if (filteredItemIds != null) { - Iterator i = filteredItemIds.iterator(); + final Iterator i = filteredItemIds.iterator(); Object last = null; while (i.hasNext()) { last = i.next(); @@ -469,7 +445,7 @@ public class IndexedContainer implements Container, Container.Indexed, return last; } return itemIds.get(itemIds.size() - 1); - } catch (IndexOutOfBoundsException e) { + } catch (final IndexOutOfBoundsException e) { } return null; } @@ -488,7 +464,7 @@ public class IndexedContainer implements Container, Container.Indexed, if (!filteredItemIds.contains(itemId)) { return null; } - Iterator i = filteredItemIds.iterator(); + final Iterator i = filteredItemIds.iterator(); if (itemId == null) { return null; } @@ -502,7 +478,7 @@ public class IndexedContainer implements Container, Container.Indexed, } try { return itemIds.get(itemIds.indexOf(itemId) + 1); - } catch (IndexOutOfBoundsException e) { + } catch (final IndexOutOfBoundsException e) { return null; } } @@ -521,7 +497,7 @@ public class IndexedContainer implements Container, Container.Indexed, if (!filteredItemIds.contains(itemId)) { return null; } - Iterator i = filteredItemIds.iterator(); + final Iterator i = filteredItemIds.iterator(); if (itemId == null) { return null; } @@ -534,7 +510,7 @@ public class IndexedContainer implements Container, Container.Indexed, } try { return itemIds.get(itemIds.indexOf(itemId) - 1); - } catch (IndexOutOfBoundsException e) { + } catch (final IndexOutOfBoundsException e) { return null; } } @@ -551,9 +527,9 @@ public class IndexedContainer implements Container, Container.Indexed, public boolean isFirstId(Object itemId) { if (filteredItemIds != null) { try { - Object first = filteredItemIds.iterator().next(); + final Object first = filteredItemIds.iterator().next(); return (itemId != null && itemId.equals(first)); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { return false; } } @@ -573,15 +549,15 @@ public class IndexedContainer implements Container, Container.Indexed, if (filteredItemIds != null) { try { Object last = null; - for (Iterator i = filteredItemIds.iterator(); i.hasNext();) { + for (final Iterator i = filteredItemIds.iterator(); i.hasNext();) { last = i.next(); } return (itemId != null && itemId.equals(last)); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { return false; } } - int s = size(); + final int s = size(); return (s >= 1 && itemIds.get(s - 1).equals(itemId)); } @@ -635,12 +611,12 @@ public class IndexedContainer implements Container, Container.Indexed, throw new IndexOutOfBoundsException(); } try { - Iterator i = filteredItemIds.iterator(); + final Iterator i = filteredItemIds.iterator(); while (index-- > 0) { i.next(); } return i.next(); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { throw new IndexOutOfBoundsException(); } } @@ -663,12 +639,12 @@ public class IndexedContainer implements Container, Container.Indexed, return -1; } try { - for (Iterator i = filteredItemIds.iterator(); itemId.equals(i - .next());) { + for (final Iterator i = filteredItemIds.iterator(); itemId + .equals(i.next());) { index++; } return index; - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { return -1; } } @@ -704,7 +680,7 @@ public class IndexedContainer implements Container, Container.Indexed, public Object addItemAt(int index) { // Creates a new id - Object id = new Object(); + final Object id = new Object(); // Adds the Item into container addItemAt(index, id); @@ -894,8 +870,8 @@ public class IndexedContainer implements Container, Container.Indexed, // Sends event to listeners listening all value changes if (propertyValueChangeListeners != null) { - Object[] l = propertyValueChangeListeners.toArray(); - Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent( + final Object[] l = propertyValueChangeListeners.toArray(); + final Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent( source); for (int i = 0; i < l.length; i++) { ((Property.ValueChangeListener) l[i]).valueChange(event); @@ -904,15 +880,16 @@ public class IndexedContainer implements Container, Container.Indexed, // Sends event to single property value change listeners if (singlePropertyValueChangeListeners != null) { - Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners + final Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners .get(source.propertyId); if (propertySetToListenerListMap != null) { - LinkedList listenerList = (LinkedList) propertySetToListenerListMap + final LinkedList listenerList = (LinkedList) propertySetToListenerListMap .get(source.itemId); if (listenerList != null) { - Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent( + final Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent( source); - for (Iterator i = listenerList.iterator(); i.hasNext();) { + for (final Iterator i = listenerList.iterator(); i + .hasNext();) { ((Property.ValueChangeListener) i.next()) .valueChange(event); } @@ -927,8 +904,8 @@ public class IndexedContainer implements Container, Container.Indexed, */ private void fireContainerPropertySetChange() { if (propertySetChangeListeners != null) { - Object[] l = propertySetChangeListeners.toArray(); - Container.PropertySetChangeEvent event = new IndexedContainer.PropertySetChangeEvent( + final Object[] l = propertySetChangeListeners.toArray(); + final Container.PropertySetChangeEvent event = new IndexedContainer.PropertySetChangeEvent( this); for (int i = 0; i < l.length; i++) { ((Container.PropertySetChangeListener) l[i]) @@ -942,8 +919,8 @@ public class IndexedContainer implements Container, Container.Indexed, */ private void fireContentsChange() { if (itemSetChangeListeners != null) { - Object[] l = itemSetChangeListeners.toArray(); - Container.ItemSetChangeEvent event = new IndexedContainer.ItemSetChangeEvent( + final Object[] l = itemSetChangeListeners.toArray(); + final Container.ItemSetChangeEvent event = new IndexedContainer.ItemSetChangeEvent( this); for (int i = 0; i < l.length; i++) { ((Container.ItemSetChangeListener) l[i]) @@ -998,10 +975,10 @@ public class IndexedContainer implements Container, Container.Indexed, private void removeSinglePropertyChangeListener(Object propertyId, Object itemId, Property.ValueChangeListener listener) { if (listener != null && singlePropertyValueChangeListeners != null) { - Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners + final Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners .get(propertyId); if (propertySetToListenerListMap != null) { - LinkedList listenerList = (LinkedList) propertySetToListenerListMap + final LinkedList listenerList = (LinkedList) propertySetToListenerListMap .get(itemId); if (listenerList != null) { listenerList.remove(listener); @@ -1033,7 +1010,7 @@ public class IndexedContainer implements Container, Container.Indexed, /** * Item ID in the host container for this Item. */ - private Object itemId; + private final Object itemId; /** * Constructs a new ListItem instance and connects it to a host @@ -1086,8 +1063,8 @@ public class IndexedContainer implements Container, Container.Indexed, public String toString() { String retValue = ""; - for (Iterator i = propertyIds.iterator(); i.hasNext();) { - Object propertyId = i.next(); + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { + final Object propertyId = i.next(); retValue += getItemProperty(propertyId).toString(); if (i.hasNext()) { retValue += " "; @@ -1123,7 +1100,7 @@ public class IndexedContainer implements Container, Container.Indexed, || !obj.getClass().equals(IndexedContainerItem.class)) { return false; } - IndexedContainerItem li = (IndexedContainerItem) obj; + final IndexedContainerItem li = (IndexedContainerItem) obj; return getHost() == li.getHost() && itemId.equals(li.itemId); } @@ -1175,12 +1152,12 @@ public class IndexedContainer implements Container, Container.Indexed, /** * ID of the Item, where the Property resides. */ - private Object itemId; + private final Object itemId; /** * Id of the Property. */ - private Object propertyId; + private final Object propertyId; /** * Constructs a new ListProperty object and connect it to a ListItem and @@ -1275,7 +1252,7 @@ public class IndexedContainer implements Container, Container.Indexed, throws Property.ReadOnlyException, Property.ConversionException { // Gets the Property set - Hashtable propertySet = (Hashtable) items.get(itemId); + final Hashtable propertySet = (Hashtable) items.get(itemId); // Support null values on all types if (newValue == null) { @@ -1286,14 +1263,14 @@ public class IndexedContainer implements Container, Container.Indexed, try { // Gets the string constructor - Constructor constr = getType().getConstructor( + final Constructor constr = getType().getConstructor( new Class[] { String.class }); // Creates new object from the string propertySet.put(propertyId, constr .newInstance(new Object[] { newValue.toString() })); - } catch (java.lang.Exception e) { + } catch (final java.lang.Exception e) { throw new Property.ConversionException( "Conversion for value '" + newValue + "' of class " + newValue.getClass().getName() + " to " @@ -1313,7 +1290,7 @@ public class IndexedContainer implements Container, Container.Indexed, * the Property */ public String toString() { - Object value = getValue(); + final Object value = getValue(); if (value == null) { return null; } @@ -1348,7 +1325,7 @@ public class IndexedContainer implements Container, Container.Indexed, || !obj.getClass().equals(IndexedContainerProperty.class)) { return false; } - IndexedContainerProperty lp = (IndexedContainerProperty) obj; + final IndexedContainerProperty lp = (IndexedContainerProperty) obj; return lp.getHost() == getHost() && lp.propertyId.equals(propertyId) && lp.itemId.equals(itemId); @@ -1389,9 +1366,9 @@ public class IndexedContainer implements Container, Container.Indexed, public synchronized void sort(Object[] propertyId, boolean[] ascending) { // Removes any non-sortable property ids - ArrayList ids = new ArrayList(); - ArrayList orders = new ArrayList(); - Collection sortable = getSortableContainerPropertyIds(); + final ArrayList ids = new ArrayList(); + final ArrayList orders = new ArrayList(); + final Collection sortable = getSortableContainerPropertyIds(); for (int i = 0; i < propertyId.length; i++) { if (sortable.contains(propertyId[i])) { ids.add(propertyId[i]); @@ -1428,10 +1405,10 @@ public class IndexedContainer implements Container, Container.Indexed, */ public Collection getSortableContainerPropertyIds() { - LinkedList list = new LinkedList(); - for (Iterator i = propertyIds.iterator(); i.hasNext();) { - Object id = i.next(); - Class type = getType(id); + final LinkedList list = new LinkedList(); + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { + final Object id = i.next(); + final Class type = getType(id); if (type != null && Comparable.class.isAssignableFrom(type)) { list.add(id); } @@ -1451,12 +1428,12 @@ public class IndexedContainer implements Container, Container.Indexed, for (int i = 0; i < sortPropertyId.length; i++) { // Get the compared properties - Property pp1 = getContainerProperty(o1, sortPropertyId[i]); - Property pp2 = getContainerProperty(o2, sortPropertyId[i]); + final Property pp1 = getContainerProperty(o1, sortPropertyId[i]); + final Property pp2 = getContainerProperty(o2, sortPropertyId[i]); // Get the compared values - Object p1 = pp1 == null ? null : pp1.getValue(); - Object p2 = pp2 == null ? null : pp2.getValue(); + final Object p1 = pp1 == null ? null : pp1.getValue(); + final Object p2 = pp2 == null ? null : pp2.getValue(); // Result of the comparison int r = 0; @@ -1498,7 +1475,7 @@ public class IndexedContainer implements Container, Container.Indexed, public Object clone() throws CloneNotSupportedException { // Creates the clone - IndexedContainer nc = new IndexedContainer(); + final IndexedContainer nc = new IndexedContainer(); // Clone the shallow properties nc.itemIds = itemIds != null ? (ArrayList) itemIds.clone() : null; @@ -1535,9 +1512,9 @@ public class IndexedContainer implements Container, Container.Indexed, nc.items = null; } else { nc.items = new Hashtable(); - for (Iterator i = items.keySet().iterator(); i.hasNext();) { - Object id = i.next(); - Hashtable it = (Hashtable) items.get(id); + for (final Iterator i = items.keySet().iterator(); i.hasNext();) { + final Object id = i.next(); + final Hashtable it = (Hashtable) items.get(id); nc.items.put(id, it.clone()); } } @@ -1554,7 +1531,7 @@ public class IndexedContainer implements Container, Container.Indexed, if (!(obj instanceof IndexedContainer)) { return false; } - IndexedContainer o = (IndexedContainer) obj; + final IndexedContainer o = (IndexedContainer) obj; // Checks the properties one by one if (itemIds != o.itemIds && o.itemIds != null @@ -1664,7 +1641,7 @@ public class IndexedContainer implements Container, Container.Indexed, if (!(obj instanceof Filter)) { return false; } - Filter o = (Filter) obj; + final Filter o = (Filter) obj; // Checks the properties one by one if (propertyId != o.propertyId && o.propertyId != null @@ -1714,8 +1691,8 @@ public class IndexedContainer implements Container, Container.Indexed, if (filters == null || propertyId == null) { return; } - for (Iterator i = filters.iterator(); i.hasNext();) { - Filter f = (Filter) i.next(); + for (final Iterator i = filters.iterator(); i.hasNext();) { + final Filter f = (Filter) i.next(); if (propertyId.equals(f.propertyId)) { i.remove(); } @@ -1743,8 +1720,8 @@ public class IndexedContainer implements Container, Container.Indexed, } // Filter - for (Iterator i = itemIds.iterator(); i.hasNext();) { - Object id = i.next(); + for (final Iterator i = itemIds.iterator(); i.hasNext();) { + final Object id = i.next(); if (passesFilters(new IndexedContainerItem(id))) { filteredItemIds.add(id); } @@ -1760,15 +1737,15 @@ public class IndexedContainer implements Container, Container.Indexed, if (item == null) { return false; } - for (Iterator i = filters.iterator(); i.hasNext();) { - Filter f = (Filter) i.next(); - String s1 = f.ignoreCase ? f.filterString.toLowerCase() + for (final Iterator i = filters.iterator(); i.hasNext();) { + final Filter f = (Filter) i.next(); + final String s1 = f.ignoreCase ? f.filterString.toLowerCase() : f.filterString; - Property p = item.getItemProperty(f.propertyId); + final Property p = item.getItemProperty(f.propertyId); if (p == null || p.toString() == null) { return false; } - String s2 = f.ignoreCase ? p.toString().toLowerCase() : p + final String s2 = f.ignoreCase ? p.toString().toLowerCase() : p .toString(); if (f.onlyMatchPrefix) { if (s2.indexOf(s1) != 0) { diff --git a/src/com/itmill/toolkit/data/util/MethodProperty.java b/src/com/itmill/toolkit/data/util/MethodProperty.java index e28ce8f385..04ed811b63 100644 --- a/src/com/itmill/toolkit/data/util/MethodProperty.java +++ b/src/com/itmill/toolkit/data/util/MethodProperty.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -65,7 +41,7 @@ public class MethodProperty implements Property { /** * The object that includes the property the MethodProperty is bound to. */ - private Object instance; + private final Object instance; /** * Argument arrays for the getter and setter methods. @@ -132,12 +108,12 @@ public class MethodProperty implements Property { */ public MethodProperty(Object instance, String beanPropertyName) { - Class beanClass = instance.getClass(); + final Class beanClass = instance.getClass(); // Assure that the first letter is upper cased (it is a common // mistake to write firstName, not FirstName). if (Character.isLowerCase(beanPropertyName.charAt(0))) { - char[] buf = beanPropertyName.toCharArray(); + final char[] buf = beanPropertyName.toCharArray(); buf[0] = Character.toUpperCase(buf[0]); beanPropertyName = new String(buf); } @@ -147,15 +123,15 @@ public class MethodProperty implements Property { try { getMethod = beanClass.getMethod("get" + beanPropertyName, new Class[] {}); - } catch (java.lang.NoSuchMethodException ignored) { + } catch (final java.lang.NoSuchMethodException ignored) { try { getMethod = beanClass.getMethod("is" + beanPropertyName, new Class[] {}); - } catch (java.lang.NoSuchMethodException ignoredAsWell) { + } catch (final java.lang.NoSuchMethodException ignoredAsWell) { try { getMethod = beanClass.getMethod("are" + beanPropertyName, new Class[] {}); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { throw new MethodProperty.MethodException("Bean property " + beanPropertyName + " can not be found"); } @@ -170,7 +146,7 @@ public class MethodProperty implements Property { try { setMethod = beanClass.getMethod("set" + beanPropertyName, new Class[] { type }); - } catch (java.lang.NoSuchMethodException skipped) { + } catch (final java.lang.NoSuchMethodException skipped) { } // Gets the return type from get method @@ -313,7 +289,7 @@ public class MethodProperty implements Property { this.type = type; // Find set and get -methods - Method[] m = instance.getClass().getMethods(); + final Method[] m = instance.getClass().getMethods(); // Finds get method boolean found = false; @@ -332,7 +308,7 @@ public class MethodProperty implements Property { } // Tests the parameter types - Class[] c = m[i].getParameterTypes(); + final Class[] c = m[i].getParameterTypes(); if (c.length != getArgs.length) { // not the right amount of parameters, try next method @@ -381,7 +357,7 @@ public class MethodProperty implements Property { } // Checks parameter compatibility - Class[] c = m[i].getParameterTypes(); + final Class[] c = m[i].getParameterTypes(); if (c.length != setArgs.length) { // not the right amount of parameters, try next method @@ -554,7 +530,7 @@ public class MethodProperty implements Property { public Object getValue() { try { return getMethod.invoke(instance, getArgs); - } catch (Throwable e) { + } catch (final Throwable e) { throw new MethodProperty.MethodException(e); } } @@ -567,7 +543,7 @@ public class MethodProperty implements Property { * @return String representation of the value stored in the Property */ public String toString() { - Object value = getValue(); + final Object value = getValue(); if (value == null) { return null; } @@ -634,13 +610,13 @@ public class MethodProperty implements Property { try { // Gets the string constructor - Constructor constr = getType().getConstructor( + final Constructor constr = getType().getConstructor( new Class[] { String.class }); value = constr .newInstance(new Object[] { newValue.toString() }); - } catch (java.lang.Exception e) { + } catch (final java.lang.Exception e) { throw new Property.ConversionException(e); } @@ -664,16 +640,16 @@ public class MethodProperty implements Property { } else { // Sets the value to argument array - Object[] args = new Object[setArgs.length]; + final Object[] args = new Object[setArgs.length]; for (int i = 0; i < setArgs.length; i++) { args[i] = (i == setArgumentIndex) ? value : setArgs[i]; } setMethod.invoke(instance, args); } - } catch (InvocationTargetException e) { - Throwable targetException = e.getTargetException(); + } catch (final InvocationTargetException e) { + final Throwable targetException = e.getTargetException(); throw new MethodProperty.MethodException(targetException); - } catch (Exception e) { + } catch (final Exception e) { throw new MethodProperty.MethodException(e); } } @@ -685,7 +661,7 @@ public class MethodProperty implements Property { * the new read-only status of the Property. */ public void setReadOnly(boolean newStatus) { - boolean prevStatus = readOnly; + final boolean prevStatus = readOnly; if (newStatus) { readOnly = true; } else { @@ -825,8 +801,8 @@ public class MethodProperty implements Property { */ private void fireReadOnlyStatusChange() { if (readOnlyStatusChangeListeners != null) { - Object[] l = readOnlyStatusChangeListeners.toArray(); - Property.ReadOnlyStatusChangeEvent event = new MethodProperty.ReadOnlyStatusChangeEvent( + final Object[] l = readOnlyStatusChangeListeners.toArray(); + final Property.ReadOnlyStatusChangeEvent event = new MethodProperty.ReadOnlyStatusChangeEvent( this); for (int i = 0; i < l.length; i++) { ((Property.ReadOnlyStatusChangeListener) l[i]) diff --git a/src/com/itmill/toolkit/data/util/ObjectProperty.java b/src/com/itmill/toolkit/data/util/ObjectProperty.java index eddb870973..503eabeffe 100644 --- a/src/com/itmill/toolkit/data/util/ObjectProperty.java +++ b/src/com/itmill/toolkit/data/util/ObjectProperty.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -59,7 +35,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, /** * Data type of the Property's value. */ - private Class type; + private final Class type; /** * Internal list of registered value change listeners. @@ -147,7 +123,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, * ObjectProperty */ public String toString() { - Object value = getValue(); + final Object value = getValue(); if (value != null) { return value.toString(); } else { @@ -210,14 +186,14 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, try { // Gets the string constructor - Constructor constr = getType().getConstructor( + final Constructor constr = getType().getConstructor( new Class[] { String.class }); // Creates new object from the string value = constr .newInstance(new Object[] { newValue.toString() }); - } catch (java.lang.Exception e) { + } catch (final java.lang.Exception e) { throw new Property.ConversionException(e); } } @@ -356,8 +332,8 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, */ private void fireValueChange() { if (valueChangeListeners != null) { - Object[] l = valueChangeListeners.toArray(); - Property.ValueChangeEvent event = new ObjectProperty.ValueChangeEvent( + final Object[] l = valueChangeListeners.toArray(); + final Property.ValueChangeEvent event = new ObjectProperty.ValueChangeEvent( this); for (int i = 0; i < l.length; i++) { ((Property.ValueChangeListener) l[i]).valueChange(event); @@ -370,8 +346,8 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, */ private void fireReadOnlyStatusChange() { if (readOnlyStatusChangeListeners != null) { - Object[] l = readOnlyStatusChangeListeners.toArray(); - Property.ReadOnlyStatusChangeEvent event = new ObjectProperty.ReadOnlyStatusChangeEvent( + final Object[] l = readOnlyStatusChangeListeners.toArray(); + final Property.ReadOnlyStatusChangeEvent event = new ObjectProperty.ReadOnlyStatusChangeEvent( this); for (int i = 0; i < l.length; i++) { ((Property.ReadOnlyStatusChangeListener) l[i]) diff --git a/src/com/itmill/toolkit/data/util/PropertysetItem.java b/src/com/itmill/toolkit/data/util/PropertysetItem.java index 355538326d..457a51321f 100644 --- a/src/com/itmill/toolkit/data/util/PropertysetItem.java +++ b/src/com/itmill/toolkit/data/util/PropertysetItem.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -158,8 +134,8 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, public String toString() { String retValue = ""; - for (Iterator i = getItemPropertyIds().iterator(); i.hasNext();) { - Object propertyId = i.next(); + for (final Iterator i = getItemPropertyIds().iterator(); i.hasNext();) { + final Object propertyId = i.next(); retValue += getItemProperty(propertyId).toString(); if (i.hasNext()) { retValue += " "; @@ -232,8 +208,8 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, */ private void fireItemPropertySetChange() { if (propertySetChangeListeners != null) { - Object[] l = propertySetChangeListeners.toArray(); - Item.PropertySetChangeEvent event = new PropertysetItem.PropertySetChangeEvent( + final Object[] l = propertySetChangeListeners.toArray(); + final Item.PropertySetChangeEvent event = new PropertysetItem.PropertySetChangeEvent( this); for (int i = 0; i < l.length; i++) { ((Item.PropertySetChangeListener) l[i]) @@ -265,7 +241,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, */ public Object clone() throws CloneNotSupportedException { - PropertysetItem npsi = new PropertysetItem(); + final PropertysetItem npsi = new PropertysetItem(); npsi.list = list != null ? (LinkedList) list.clone() : null; npsi.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners @@ -293,7 +269,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, return false; } - PropertysetItem other = (PropertysetItem) obj; + final PropertysetItem other = (PropertysetItem) obj; if (other.list != list) { if (other.list == null) { diff --git a/src/com/itmill/toolkit/data/util/QueryContainer.java b/src/com/itmill/toolkit/data/util/QueryContainer.java index a3ab78e5c0..9f8704e933 100644 --- a/src/com/itmill/toolkit/data/util/QueryContainer.java +++ b/src/com/itmill/toolkit/data/util/QueryContainer.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.util; @@ -83,15 +59,15 @@ public class QueryContainer implements Container, Container.Ordered, private int resultSetConcurrency = DEFAULT_RESULTSET_CONCURRENCY; - private String queryStatement; + private final String queryStatement; - private Connection connection; + private final Connection connection; private ResultSet result; private Collection propertyIds; - private HashMap propertyTypes = new HashMap(); + private final HashMap propertyTypes = new HashMap(); private int size = -1; @@ -151,12 +127,12 @@ public class QueryContainer implements Container, Container.Ordered, refresh(); ResultSetMetaData metadata; metadata = result.getMetaData(); - int count = metadata.getColumnCount(); - ArrayList list = new ArrayList(count); + final int count = metadata.getColumnCount(); + final ArrayList list = new ArrayList(count); for (int i = 1; i <= count; i++) { - String columnName = metadata.getColumnName(i); + final String columnName = metadata.getColumnName(i); list.add(columnName); - Property p = getContainerProperty(new Integer(1), columnName); + final Property p = getContainerProperty(new Integer(1), columnName); propertyTypes.put(columnName, p == null ? Object.class : p .getType()); } @@ -227,7 +203,7 @@ public class QueryContainer implements Container, Container.Ordered, * @return collection of Item IDs */ public Collection getItemIds() { - Collection c = new ArrayList(size); + final Collection c = new ArrayList(size); for (int i = 1; i <= size; i++) { c.add(new Integer(i)); } @@ -257,7 +233,7 @@ public class QueryContainer implements Container, Container.Ordered, try { result.absolute(((Integer) itemId).intValue()); value = result.getObject((String) propertyId); - } catch (Exception e) { + } catch (final Exception e) { return null; } @@ -299,7 +275,7 @@ public class QueryContainer implements Container, Container.Ordered, if (!(id instanceof Integer)) { return false; } - int i = ((Integer) id).intValue(); + final int i = ((Integer) id).intValue(); if (i < 1) { return false; } @@ -485,7 +461,7 @@ public class QueryContainer implements Container, Container.Ordered, if (size < 1 || !(id instanceof Integer)) { return null; } - int i = ((Integer) id).intValue(); + final int i = ((Integer) id).intValue(); if (i >= size) { return null; } @@ -503,7 +479,7 @@ public class QueryContainer implements Container, Container.Ordered, if (size < 1 || !(id instanceof Integer)) { return null; } - int i = ((Integer) id).intValue(); + final int i = ((Integer) id).intValue(); if (i <= 1) { return null; } @@ -589,7 +565,7 @@ public class QueryContainer implements Container, Container.Ordered, public void finalize() { try { close(); - } catch (SQLException ignored) { + } catch (final SQLException ignored) { } } @@ -653,7 +629,7 @@ public class QueryContainer implements Container, Container.Ordered, if (size < 1 || !(id instanceof Integer)) { return -1; } - int i = ((Integer) id).intValue(); + final int i = ((Integer) id).intValue(); if (i >= size || i < 1) { return -1; } diff --git a/src/com/itmill/toolkit/data/validator/CompositeValidator.java b/src/com/itmill/toolkit/data/validator/CompositeValidator.java index 3abe1d40d9..be16c2633e 100644 --- a/src/com/itmill/toolkit/data/validator/CompositeValidator.java +++ b/src/com/itmill/toolkit/data/validator/CompositeValidator.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.validator; @@ -77,7 +53,7 @@ public class CompositeValidator implements Validator { /** * List of contained validators. */ - private LinkedList validators = new LinkedList(); + private final LinkedList validators = new LinkedList(); /** * Error message. @@ -121,18 +97,18 @@ public class CompositeValidator implements Validator { public void validate(Object value) throws Validator.InvalidValueException { switch (mode) { case MODE_AND: - for (Iterator i = validators.iterator(); i.hasNext();) { + for (final Iterator i = validators.iterator(); i.hasNext();) { ((Validator) i.next()).validate(value); } return; case MODE_OR: Validator.InvalidValueException first = null; - for (Iterator i = validators.iterator(); i.hasNext();) { + for (final Iterator i = validators.iterator(); i.hasNext();) { try { ((Validator) i.next()).validate(value); return; - } catch (Validator.InvalidValueException e) { + } catch (final Validator.InvalidValueException e) { if (first == null) { first = e; } @@ -141,7 +117,7 @@ public class CompositeValidator implements Validator { if (first == null) { return; } - String em = getErrorMessage(); + final String em = getErrorMessage(); if (em != null) { throw new Validator.InvalidValueException(em); } else { @@ -165,8 +141,8 @@ public class CompositeValidator implements Validator { public boolean isValid(Object value) { switch (mode) { case MODE_AND: - for (Iterator i = validators.iterator(); i.hasNext();) { - Validator v = (Validator) i.next(); + for (final Iterator i = validators.iterator(); i.hasNext();) { + final Validator v = (Validator) i.next(); if (!v.isValid(value)) { return false; } @@ -174,8 +150,8 @@ public class CompositeValidator implements Validator { return true; case MODE_OR: - for (Iterator i = validators.iterator(); i.hasNext();) { - Validator v = (Validator) i.next(); + for (final Iterator i = validators.iterator(); i.hasNext();) { + final Validator v = (Validator) i.next(); if (v.isValid(value)) { return true; } @@ -286,15 +262,15 @@ public class CompositeValidator implements Validator { return null; } - HashSet found = new HashSet(); - for (Iterator i = validators.iterator(); i.hasNext();) { - Validator v = (Validator) i.next(); + final HashSet found = new HashSet(); + for (final Iterator i = validators.iterator(); i.hasNext();) { + final Validator v = (Validator) i.next(); if (validatorType.isAssignableFrom(v.getClass())) { found.add(v); } if (v instanceof CompositeValidator && ((CompositeValidator) v).getMode() == MODE_AND) { - Collection c = ((CompositeValidator) v) + final Collection c = ((CompositeValidator) v) .getSubValidators(validatorType); if (c != null) { found.addAll(c); diff --git a/src/com/itmill/toolkit/data/validator/NullValidator.java b/src/com/itmill/toolkit/data/validator/NullValidator.java index 24cb25b339..ad627f88c1 100644 --- a/src/com/itmill/toolkit/data/validator/NullValidator.java +++ b/src/com/itmill/toolkit/data/validator/NullValidator.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.validator; diff --git a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java index 68ddfe46fb..b622ea08ed 100644 --- a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java +++ b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.data.validator; @@ -94,11 +70,11 @@ public class StringLengthValidator implements Validator { if (value == null && !allowNull) { throw new Validator.InvalidValueException(errorMessage); } - String s = value.toString(); + final String s = value.toString(); if (s == null && !allowNull) { throw new Validator.InvalidValueException(errorMessage); } - int len = s.length(); + final int len = s.length(); if ((minLength >= 0 && len < minLength) || (maxLength >= 0 && len > maxLength)) { throw new Validator.InvalidValueException(errorMessage); @@ -116,11 +92,11 @@ public class StringLengthValidator implements Validator { if (value == null && !allowNull) { return true; } - String s = value.toString(); + final String s = value.toString(); if (s == null && !allowNull) { return true; } - int len = s.length(); + final int len = s.length(); if ((minLength >= 0 && len < minLength) || (maxLength >= 0 && len > maxLength)) { return false; diff --git a/src/com/itmill/toolkit/demo/BrowserDemo.java b/src/com/itmill/toolkit/demo/BrowserDemo.java index 5a03dce9d9..13d4bc5d0c 100644 --- a/src/com/itmill/toolkit/demo/BrowserDemo.java +++ b/src/com/itmill/toolkit/demo/BrowserDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -25,18 +29,18 @@ public class BrowserDemo extends com.itmill.toolkit.Application implements public void init() { // Create and set main window - Window browser = new Window("IT Mill Browser"); + final Window browser = new Window("IT Mill Browser"); setMainWindow(browser); // Use the expand layout to allow one component to use as much // space as // possible. - ExpandLayout exl = new ExpandLayout(); + final ExpandLayout exl = new ExpandLayout(); browser.setLayout(exl); exl.setSizeFull(); // create the address combobox - Select select = new Select(); + final Select select = new Select(); // allow input select.setNewItemsAllowed(true); // no empty selection @@ -62,7 +66,7 @@ public class BrowserDemo extends com.itmill.toolkit.Application implements } public void valueChange(ValueChangeEvent event) { - String url = (String) event.getProperty().getValue(); + final String url = (String) event.getProperty().getValue(); if (url != null) { // the selected url has changed, let's go there emb.setSource(new ExternalResource(url)); diff --git a/src/com/itmill/toolkit/demo/BufferedComponents.java b/src/com/itmill/toolkit/demo/BufferedComponents.java index 8f4a39df5d..752ac00788 100644 --- a/src/com/itmill/toolkit/demo/BufferedComponents.java +++ b/src/com/itmill/toolkit/demo/BufferedComponents.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.Application; @@ -17,11 +21,11 @@ public class BufferedComponents extends Application { public void init() { - Window w = new Window("Buffered UI components demo"); + final Window w = new Window("Buffered UI components demo"); addWindow(w); // Create property - Float floatValue = new Float(1.0f); + final Float floatValue = new Float(1.0f); property = new ObjectProperty(floatValue); // Textfield @@ -32,12 +36,12 @@ public class BufferedComponents extends Application { w.addComponent(text); // Property state - Label propertyState = new Label(property); + final Label propertyState = new Label(property); propertyState.setCaption("Property (data source) state"); w.addComponent(propertyState); // Button state - Label textState = new Label(text); + final Label textState = new Label(text); textState.setCaption("TextField state"); w.addComponent(textState); @@ -45,7 +49,7 @@ public class BufferedComponents extends Application { w.addComponent(new Button("increase property value", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - Float currentValue = (Float) property.getValue(); + final Float currentValue = (Float) property.getValue(); property.setValue(new Float( currentValue.floatValue() + 1.0)); } @@ -69,7 +73,7 @@ public class BufferedComponents extends Application { // (easier debugging when you dont have to restart the server to // make // code changes) - Button restart = new Button("restart", this, "close"); + final Button restart = new Button("restart", this, "close"); restart.addStyleName(Button.STYLE_LINK); w.addComponent(restart); } diff --git a/src/com/itmill/toolkit/demo/CachingDemo.java b/src/com/itmill/toolkit/demo/CachingDemo.java index 4cc47719f5..8b44aa0119 100644 --- a/src/com/itmill/toolkit/demo/CachingDemo.java +++ b/src/com/itmill/toolkit/demo/CachingDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.terminal.PaintException; @@ -21,12 +25,12 @@ public class CachingDemo extends com.itmill.toolkit.Application { public void init() { - Window main = new Window("Client-side caching example"); + final Window main = new Window("Client-side caching example"); setMainWindow(main); setTheme("example"); - TabSheet ts = new TabSheet(); + final TabSheet ts = new TabSheet(); main.addComponent(ts); Layout layout = new OrderedLayout(); @@ -46,7 +50,7 @@ public class CachingDemo extends com.itmill.toolkit.Application { public void paintContent(PaintTarget target) throws PaintException { try { Thread.sleep(3000); - } catch (Exception e) { + } catch (final Exception e) { // IGNORED } super.paintContent(target); diff --git a/src/com/itmill/toolkit/demo/Calc.java b/src/com/itmill/toolkit/demo/Calc.java index 5a3788ac52..e3655239f2 100644 --- a/src/com/itmill/toolkit/demo/Calc.java +++ b/src/com/itmill/toolkit/demo/Calc.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.ui.Button; @@ -57,7 +61,7 @@ public class Calc extends com.itmill.toolkit.Application implements public void init() { // Create a new layout for the components used by the calculator - GridLayout layout = new GridLayout(4, 5); + final GridLayout layout = new GridLayout(4, 5); // Create a new label component for displaying the result display = new Label(Double.toString(current)); @@ -68,7 +72,7 @@ public class Calc extends com.itmill.toolkit.Application implements // Create the buttons and place them in the grid for (int i = 0; i < captions.length; i++) { - Button button = new Button(captions[i], this); + final Button button = new Button(captions[i], this); layout.addComponent(button); } @@ -102,7 +106,7 @@ public class Calc extends com.itmill.toolkit.Application implements current = current * 10 + Double.parseDouble(event.getButton().getCaption()); display.setValue(Double.toString(current)); - } catch (java.lang.NumberFormatException e) { + } catch (final java.lang.NumberFormatException e) { // Operation button pressed if (operation.equals("+")) { diff --git a/src/com/itmill/toolkit/demo/CustomLayoutDemo.java b/src/com/itmill/toolkit/demo/CustomLayoutDemo.java index 0bf256b409..b683fc763a 100644 --- a/src/com/itmill/toolkit/demo/CustomLayoutDemo.java +++ b/src/com/itmill/toolkit/demo/CustomLayoutDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.ui.Button; @@ -29,21 +33,21 @@ public class CustomLayoutDemo extends com.itmill.toolkit.Application implements private CustomLayout mainLayout = null; - private Panel bodyPanel = new Panel(); + private final Panel bodyPanel = new Panel(); - private TextField username = new TextField("Username"); + private final TextField username = new TextField("Username"); - private TextField loginPwd = new TextField("Password"); + private final TextField loginPwd = new TextField("Password"); - private Button loginButton = new Button("Login", this, "loginClicked"); + private final Button loginButton = new Button("Login", this, "loginClicked"); - private Tree menu = new Tree(); + private final Tree menu = new Tree(); /** * Initialize Application. Demo components are added to main window. */ public void init() { - Window mainWindow = new Window("CustomLayout demo"); + final Window mainWindow = new Window("CustomLayout demo"); setMainWindow(mainWindow); // set the application to use example -theme @@ -52,7 +56,7 @@ public class CustomLayoutDemo extends com.itmill.toolkit.Application implements // Create custom layout, themes/example/layout/mainLayout.html mainLayout = new CustomLayout("mainLayout"); // wrap custom layout inside a panel - Panel customLayoutPanel = new Panel( + final Panel customLayoutPanel = new Panel( "Panel containing custom layout (mainLayout.html)"); customLayoutPanel.addComponent(mainLayout); diff --git a/src/com/itmill/toolkit/demo/FilterSelect.java b/src/com/itmill/toolkit/demo/FilterSelect.java index d2bd119897..25a12b38b1 100644 --- a/src/com/itmill/toolkit/demo/FilterSelect.java +++ b/src/com/itmill/toolkit/demo/FilterSelect.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.ui.OrderedLayout; @@ -39,11 +43,11 @@ public class FilterSelect extends com.itmill.toolkit.Application { * - Create new window for the application - Give the window a visible * title - Set the window to be the main window of the application */ - Window main = new Window("Filter select demo"); + final Window main = new Window("Filter select demo"); setMainWindow(main); // default filterin (Starts with) - Select s1 = new Select(); + final Select s1 = new Select(); for (int i = 0; i < 105; i++) { s1 .addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))] @@ -53,7 +57,7 @@ public class FilterSelect extends com.itmill.toolkit.Application { s1.setImmediate(true); // contains filter - Select s2 = new Select(); + final Select s2 = new Select(); for (int i = 0; i < 500; i++) { s2 .addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))] @@ -63,11 +67,11 @@ public class FilterSelect extends com.itmill.toolkit.Application { s2.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); // Add selects to UI using ordered layout and panels - OrderedLayout orderedLayout = new OrderedLayout( + final OrderedLayout orderedLayout = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); - Panel panel1 = new Panel("Select with default filter"); - Panel panel2 = new Panel("Select with contains filter"); + final Panel panel1 = new Panel("Select with default filter"); + final Panel panel2 = new Panel("Select with contains filter"); panel1.addComponent(s1); panel2.addComponent(s2); diff --git a/src/com/itmill/toolkit/demo/HelloWorld.java b/src/com/itmill/toolkit/demo/HelloWorld.java index ace0e95913..35ac5fcf31 100644 --- a/src/com/itmill/toolkit/demo/HelloWorld.java +++ b/src/com/itmill/toolkit/demo/HelloWorld.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.ui.Label; @@ -26,7 +30,7 @@ public class HelloWorld extends com.itmill.toolkit.Application { * - Create new window for the application - Give the window a visible * title - Set the window to be the main window of the application */ - Window main = new Window("Hello window"); + final Window main = new Window("Hello window"); setMainWindow(main); /* diff --git a/src/com/itmill/toolkit/demo/KeyboardShortcut.java b/src/com/itmill/toolkit/demo/KeyboardShortcut.java index bfc6532805..3dd157ea8c 100644 --- a/src/com/itmill/toolkit/demo/KeyboardShortcut.java +++ b/src/com/itmill/toolkit/demo/KeyboardShortcut.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.util.Date; @@ -57,31 +61,31 @@ public class KeyboardShortcut extends Application implements Handler { private final Action ACTION_RESTART = new ShortcutAction("Restart ", ShortcutAction.KeyCode.ESCAPE, null); - private Action[] actions = new Action[] { ACTION_A, ACTION_Z, ACTION_X, - ACTION_RESTART }; + private final Action[] actions = new Action[] { ACTION_A, ACTION_Z, + ACTION_X, ACTION_RESTART }; private TextField f; public void init() { - Window w = new Window("Keyboard shortcuts demo"); - ExpandLayout main = new ExpandLayout(); + final Window w = new Window("Keyboard shortcuts demo"); + final ExpandLayout main = new ExpandLayout(); main.setMargin(true); main.setSpacing(true); setMainWindow(w); w.setLayout(main); - Panel p = new Panel("Test application for shortcut actions"); + final Panel p = new Panel("Test application for shortcut actions"); p.addComponent(instructions); - OrderedLayout buttons = new OrderedLayout( + final OrderedLayout buttons = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); // Restart button - Button close = new Button("restart", this, "close"); - Button a = new Button("Button A", this, "actionAHandler"); - Button z = new Button("Button Z", this, "actionZHandler"); - Button x = new Button("Button X", this, "actionXHandler"); + final Button close = new Button("restart", this, "close"); + final Button a = new Button("Button A", this, "actionAHandler"); + final Button z = new Button("Button Z", this, "actionZHandler"); + final Button x = new Button("Button X", this, "actionXHandler"); f = new TextField(); buttons.addComponent(close); diff --git a/src/com/itmill/toolkit/demo/LayoutDemo.java b/src/com/itmill/toolkit/demo/LayoutDemo.java index 60b6c02aef..a3a671dffe 100644 --- a/src/com/itmill/toolkit/demo/LayoutDemo.java +++ b/src/com/itmill/toolkit/demo/LayoutDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.terminal.ClassResource; @@ -25,13 +29,13 @@ public class LayoutDemo extends com.itmill.toolkit.Application { * Initialize Application. Demo components are added to main window. */ public void init() { - Window mainWindow = new Window("Layout demo"); + final Window mainWindow = new Window("Layout demo"); setMainWindow(mainWindow); // // Create horizontal ordered layout // - OrderedLayout layoutA = new OrderedLayout( + final OrderedLayout layoutA = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); // Add 4 panels fillLayout(layoutA, 4); @@ -39,7 +43,7 @@ public class LayoutDemo extends com.itmill.toolkit.Application { // // Create vertical ordered layout // - OrderedLayout layoutB = new OrderedLayout( + final OrderedLayout layoutB = new OrderedLayout( OrderedLayout.ORIENTATION_VERTICAL); // Add 4 panels fillLayout(layoutB, 4); @@ -47,14 +51,14 @@ public class LayoutDemo extends com.itmill.toolkit.Application { // // Create grid layout // - GridLayout layoutG = new GridLayout(4, 4); + final GridLayout layoutG = new GridLayout(4, 4); // Add 16 panels components fillLayout(layoutG, 16); // // Create grid layout // - GridLayout layoutG2 = new GridLayout(4, 4); + final GridLayout layoutG2 = new GridLayout(4, 4); // Add 4 panels with absolute coordinates (diagonally) layoutG2.addComponent(getExampleComponent("x=0, y=0"), 0, 0); layoutG2.addComponent(getExampleComponent("x=1, y=1"), 1, 1); @@ -69,7 +73,7 @@ public class LayoutDemo extends com.itmill.toolkit.Application { // // Create TabSheet // - TabSheet tabsheet = new TabSheet(); + final TabSheet tabsheet = new TabSheet(); tabsheet .setCaption("Tabsheet, above layouts are added to this component"); tabsheet.addTab(layoutA, "Horizontal ordered layout", null); @@ -106,14 +110,15 @@ public class LayoutDemo extends com.itmill.toolkit.Application { } private Component getExamplePicture(String caption) { - ClassResource cr = new ClassResource("features/m-bullet-blue.gif", this); - Embedded em = new Embedded("Embedded " + caption, cr); + final ClassResource cr = new ClassResource( + "features/m-bullet-blue.gif", this); + final Embedded em = new Embedded("Embedded " + caption, cr); em.setWidth(170); return em; } private Component getExampleComponent(String caption) { - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Panel component " + caption); panel .addComponent(new Label( diff --git a/src/com/itmill/toolkit/demo/ModalWindow.java b/src/com/itmill/toolkit/demo/ModalWindow.java index fa0a6a44a3..c394c1ec62 100644 --- a/src/com/itmill/toolkit/demo/ModalWindow.java +++ b/src/com/itmill/toolkit/demo/ModalWindow.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.ui.Button; @@ -26,17 +30,17 @@ public class ModalWindow extends com.itmill.toolkit.Application implements public void init() { // Create main window - Window main = new Window("ModalWindow demo"); + final Window main = new Window("ModalWindow demo"); setMainWindow(main); main.addComponent(new Label("ModalWindow demo")); // Main window textfield - TextField f = new TextField(); + final TextField f = new TextField(); f.setTabIndex(1); main.addComponent(f); // Main window button - Button b = new Button("Test Button in main window"); + final Button b = new Button("Test Button in main window"); b.addListener(this); b.setTabIndex(2); main.addComponent(b); @@ -65,13 +69,13 @@ public class ModalWindow extends com.itmill.toolkit.Application implements "You have to close this window before accessing others.")); // Textfield for modal window - TextField f = new TextField(); + final TextField f = new TextField(); f.setTabIndex(4); test.addComponent(f); f.focus(); // Modal window button - Button b = new Button("Test Button in modal window"); + final Button b = new Button("Test Button in modal window"); b.setTabIndex(5); b.addListener(this); test.addComponent(b); diff --git a/src/com/itmill/toolkit/demo/NativeWindowing.java b/src/com/itmill/toolkit/demo/NativeWindowing.java index 9b4429262b..7dadd7c4bb 100644 --- a/src/com/itmill/toolkit/demo/NativeWindowing.java +++ b/src/com/itmill/toolkit/demo/NativeWindowing.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.net.MalformedURLException; @@ -31,7 +35,7 @@ public class NativeWindowing extends Application { w.setWidth(100); w.setHeight(400); - Button closebutton = new Button("Close " + final Button closebutton = new Button("Close " + w.getCaption(), new Button.ClickListener() { public void buttonClick(ClickEvent event) { main.removeWindow(w); @@ -83,7 +87,7 @@ public class NativeWindowing extends Application { .currentTimeMillis() + "/")), null); - } catch (MalformedURLException e) { + } catch (final MalformedURLException e) { } } })); @@ -94,13 +98,13 @@ public class NativeWindowing extends Application { public Window getWindow(String name) { - Window w = super.getWindow(name); + final Window w = super.getWindow(name); if (w != null) { return w; } if (name != null && name.startsWith("mainwin-")) { - String postfix = name.substring("mainwin-".length()); + final String postfix = name.substring("mainwin-".length()); final Window ww = new Window("Window: " + postfix); ww.setName(name); ww.addComponent(new Label( diff --git a/src/com/itmill/toolkit/demo/NotificationDemo.java b/src/com/itmill/toolkit/demo/NotificationDemo.java index e7a0dcb7e4..860b54f243 100644 --- a/src/com/itmill/toolkit/demo/NotificationDemo.java +++ b/src/com/itmill/toolkit/demo/NotificationDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import com.itmill.toolkit.data.Item; @@ -33,7 +37,7 @@ public class NotificationDemo extends com.itmill.toolkit.Application { public void init() { // Create new window for the application and give the window a visible. - Window main = new Window("Notification demo"); + final Window main = new Window("Notification demo"); // set as main window setMainWindow(main); @@ -73,7 +77,7 @@ public class NotificationDemo extends com.itmill.toolkit.Application { main.addComponent(message); // add to layout // Button to show the notification - Button b = new Button("Show notification", new ClickListener() { + final Button b = new Button("Show notification", new ClickListener() { // this is an inline ClickListener public void buttonClick(ClickEvent event) { // show the notification diff --git a/src/com/itmill/toolkit/demo/Parameters.java b/src/com/itmill/toolkit/demo/Parameters.java index 14142c96cd..204860e44b 100644 --- a/src/com/itmill/toolkit/demo/Parameters.java +++ b/src/com/itmill/toolkit/demo/Parameters.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.net.URL; @@ -7,6 +11,7 @@ import java.util.Map; import com.itmill.toolkit.terminal.DownloadStream; import com.itmill.toolkit.terminal.ExternalResource; import com.itmill.toolkit.terminal.ParameterHandler; +import com.itmill.toolkit.terminal.Sizeable; import com.itmill.toolkit.terminal.URIHandler; import com.itmill.toolkit.ui.ExpandLayout; import com.itmill.toolkit.ui.Label; @@ -25,41 +30,41 @@ import com.itmill.toolkit.ui.Window; public class Parameters extends com.itmill.toolkit.Application implements URIHandler, ParameterHandler { - private Label context = new Label(); + private final Label context = new Label(); - private Label relative = new Label(); + private final Label relative = new Label(); - private Table params = new Table(); + private final Table params = new Table(); public void init() { - Window main = new Window("Parameters demo"); + final Window main = new Window("Parameters demo"); setMainWindow(main); // This class acts both as URI handler and parameter handler main.addURIHandler(this); main.addParameterHandler(this); - ExpandLayout layout = new ExpandLayout(); - Label info = new Label("To test URI and Parameter Handlers, " + final ExpandLayout layout = new ExpandLayout(); + final Label info = new Label("To test URI and Parameter Handlers, " + "add get parameters to URL. For example try examples below: "); info.setCaption("Usage info"); layout.addComponent(info); try { - URL u1 = new URL(getURL(), "test/uri?test=1&test=2"); - URL u2 = new URL(getURL(), "foo/bar?mary=john&count=3"); + final URL u1 = new URL(getURL(), "test/uri?test=1&test=2"); + final URL u2 = new URL(getURL(), "foo/bar?mary=john&count=3"); layout.addComponent(new Link(u1.toString(), new ExternalResource(u1))); layout.addComponent(new Label("Or this: ")); layout.addComponent(new Link(u2.toString(), new ExternalResource(u2))); - } catch (Exception e) { + } catch (final Exception e) { System.out.println("Couldn't get hostname for this machine: " + e.toString()); e.printStackTrace(); } // URI - Panel panel1 = new Panel("URI Handler"); + final Panel panel1 = new Panel("URI Handler"); context.setCaption("Last URI handler context"); panel1.addComponent(context); relative.setCaption("Last relative URI"); @@ -68,11 +73,11 @@ public class Parameters extends com.itmill.toolkit.Application implements params.addContainerProperty("Key", String.class, ""); params.addContainerProperty("Value", String.class, ""); - Panel panel2 = new Panel("Parameter Handler"); + final Panel panel2 = new Panel("Parameter Handler"); params.setHeight(100); - params.setHeightUnits(Table.UNITS_PERCENTAGE); + params.setHeightUnits(Sizeable.UNITS_PERCENTAGE); panel2.setHeight(100); - panel2.setHeightUnits(Panel.UNITS_PERCENTAGE); + panel2.setHeightUnits(Sizeable.UNITS_PERCENTAGE); panel2.setLayout(new ExpandLayout()); panel2.getLayout().setMargin(true); @@ -106,9 +111,9 @@ public class Parameters extends com.itmill.toolkit.Application implements */ public void handleParameters(Map parameters) { params.removeAllItems(); - for (Iterator i = parameters.keySet().iterator(); i.hasNext();) { - String name = (String) i.next(); - String[] values = (String[]) parameters.get(name); + for (final Iterator i = parameters.keySet().iterator(); i.hasNext();) { + final String name = (String) i.next(); + final String[] values = (String[]) parameters.get(name); String v = ""; for (int j = 0; j < values.length; j++) { if (v.length() > 0) { diff --git a/src/com/itmill/toolkit/demo/QueryContainerDemo.java b/src/com/itmill/toolkit/demo/QueryContainerDemo.java index 746057ee60..c378375cfc 100644 --- a/src/com/itmill/toolkit/demo/QueryContainerDemo.java +++ b/src/com/itmill/toolkit/demo/QueryContainerDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.sql.SQLException; @@ -37,35 +41,37 @@ public class QueryContainerDemo extends com.itmill.toolkit.Application + " dynamically loaded rows from example SQL table"; // Table component where SQL rows are attached (using QueryContainer) - private Table table = new Table(); + private final Table table = new Table(); - private Label tableLastAction = new Label("No action selected for table."); + private final Label tableLastAction = new Label( + "No action selected for table."); // Select component where SQL rows are attached (using QueryContainer) - private Select select = new Select(); + private final Select select = new Select(); // Tree component that uses select as datasource - private Tree tree = new Tree(); + private final Tree tree = new Tree(); - private Label treeLastAction = new Label("No action selected for tree."); + private final Label treeLastAction = new Label( + "No action selected for tree."); // Database provided with sample data private SampleDatabase sampleDatabase; // Example Actions for table - private Action ACTION1 = new Action("Upload"); + private final Action ACTION1 = new Action("Upload"); - private Action ACTION2 = new Action("Download"); + private final Action ACTION2 = new Action("Download"); - private Action ACTION3 = new Action("Show history"); + private final Action ACTION3 = new Action("Show history"); - private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; + private final Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; /** * Initialize Application. Demo components are added to main window. */ public void init() { - Window main = new Window("QueryContainer demo"); + final Window main = new Window("QueryContainer demo"); setMainWindow(main); // Main window contains heading, table, select and tree @@ -111,10 +117,10 @@ public class QueryContainerDemo extends com.itmill.toolkit.Application // populate Toolkit table component with test SQL table rows try { - QueryContainer qc = new QueryContainer("SELECT * FROM employee", - sampleDatabase.getConnection()); + final QueryContainer qc = new QueryContainer( + "SELECT * FROM employee", sampleDatabase.getConnection()); table.setContainerDataSource(qc); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); } // define which columns should be visible on Table component @@ -134,11 +140,11 @@ public class QueryContainerDemo extends com.itmill.toolkit.Application // populate Toolkit select component with test SQL table rows try { - QueryContainer qc = new QueryContainer( + final QueryContainer qc = new QueryContainer( "SELECT DISTINCT UNIT FROM employee", sampleDatabase .getConnection()); select.setContainerDataSource(qc); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); } } diff --git a/src/com/itmill/toolkit/demo/SelectDemo.java b/src/com/itmill/toolkit/demo/SelectDemo.java index cc6816206d..c356901295 100644 --- a/src/com/itmill/toolkit/demo/SelectDemo.java +++ b/src/com/itmill/toolkit/demo/SelectDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.sql.SQLException; @@ -32,11 +36,11 @@ public class SelectDemo extends com.itmill.toolkit.Application { * Initialize Application. Demo components are added to main window. */ public void init() { - Window main = new Window("Select demo"); + final Window main = new Window("Select demo"); setMainWindow(main); // Main window contains heading, table, select and tree - Panel panel = new Panel("Select demo (a.k.a Google Suggests)"); + final Panel panel = new Panel("Select demo (a.k.a Google Suggests)"); panel.addComponent(lazySelect); panel.addComponent(new Label("


", Label.CONTENT_XHTML)); panel.addComponent(select); @@ -54,12 +58,12 @@ public class SelectDemo extends com.itmill.toolkit.Application { select.setItemCaptionPropertyId("WORKER"); // populate Toolkit select component with test SQL table rows try { - QueryContainer qc = new QueryContainer( + final QueryContainer qc = new QueryContainer( "SELECT ID, UNIT||', '||LASTNAME||' '||FIRSTNAME" + " AS WORKER FROM employee ORDER BY WORKER", sampleDatabase.getConnection()); select.setContainerDataSource(qc); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); } diff --git a/src/com/itmill/toolkit/demo/TableDemo.java b/src/com/itmill/toolkit/demo/TableDemo.java index df7572e1b0..263b322d18 100644 --- a/src/com/itmill/toolkit/demo/TableDemo.java +++ b/src/com/itmill/toolkit/demo/TableDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.sql.SQLException; @@ -29,43 +33,44 @@ public class TableDemo extends com.itmill.toolkit.Application implements + " dynamically loaded rows from example SQL table"; // Table component where SQL rows are attached (using QueryContainer) - private Table table = new Table(); + private final Table table = new Table(); // Label which displays last performed action against table row - private Label tableLastAction = new Label("No action selected for table."); + private final Label tableLastAction = new Label( + "No action selected for table."); // Database provided with sample data private SampleDatabase sampleDatabase; // Example Actions for table - private Action ACTION1 = new Action("Upload"); + private final Action ACTION1 = new Action("Upload"); - private Action ACTION2 = new Action("Download"); + private final Action ACTION2 = new Action("Download"); - private Action ACTION3 = new Action("Show history"); + private final Action ACTION3 = new Action("Show history"); - private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; + private final Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; // Button which is used to disable or enable table // note: when button click event occurs, tableEnabler() method is called - private Button tableEnabler = new Button("Disable table", this, + private final Button tableEnabler = new Button("Disable table", this, "tableEnabler"); // Button which is used to hide or show table // note: when button click event occurs, tableVisibility() method is called - private Button tableVisibility = new Button("Hide table", this, + private final Button tableVisibility = new Button("Hide table", this, "tableVisibility"); // Button which is used to hide or show table // note: when button click event occurs, tableVisibility() method is called - private Button tableCaption = new Button("Hide caption", this, + private final Button tableCaption = new Button("Hide caption", this, "tableCaption"); /** * Initialize Application. Demo components are added to main window. */ public void init() { - Window main = new Window("Table demo"); + final Window main = new Window("Table demo"); setMainWindow(main); // create demo database @@ -78,7 +83,7 @@ public class TableDemo extends com.itmill.toolkit.Application implements + "Rows are loaded from the server as they are needed.
" + "Try scrolling the table to see it in action.

" + ACTION_DESCRIPTION, Label.CONTENT_XHTML)); - OrderedLayout layout = new OrderedLayout( + final OrderedLayout layout = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); // TODO: disabled until #655 fixed // layout.addComponent(tableVisibility); @@ -111,10 +116,10 @@ public class TableDemo extends com.itmill.toolkit.Application implements // populate Toolkit table component with test SQL table rows try { - QueryContainer qc = new QueryContainer("SELECT * FROM employee", - sampleDatabase.getConnection()); + final QueryContainer qc = new QueryContainer( + "SELECT * FROM employee", sampleDatabase.getConnection()); table.setContainerDataSource(qc); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); } // define which columns should be visible on Table component diff --git a/src/com/itmill/toolkit/demo/TreeFilesystem.java b/src/com/itmill/toolkit/demo/TreeFilesystem.java index fc729f970a..7fa1f3a1f4 100644 --- a/src/com/itmill/toolkit/demo/TreeFilesystem.java +++ b/src/com/itmill/toolkit/demo/TreeFilesystem.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.io.File; @@ -24,12 +28,12 @@ public class TreeFilesystem extends com.itmill.toolkit.Application implements Tree.ExpandListener { // Filesystem explorer panel and it's components - private Panel explorerPanel = new Panel("Filesystem explorer"); + private final Panel explorerPanel = new Panel("Filesystem explorer"); - private Tree tree = new Tree(); + private final Tree tree = new Tree(); public void init() { - Window main = new Window("Tree filesystem demo"); + final Window main = new Window("Tree filesystem demo"); setMainWindow(main); // Main window contains heading and panel @@ -44,7 +48,7 @@ public class TreeFilesystem extends com.itmill.toolkit.Application implements tree.addListener(this); // Get sample directory - File sampleDir = SampleDirectory.getDirectory(this); + final File sampleDir = SampleDirectory.getDirectory(this); // populate tree's root node with example directory if (sampleDir != null) { populateNode(sampleDir.getAbsolutePath(), null); @@ -56,7 +60,7 @@ public class TreeFilesystem extends com.itmill.toolkit.Application implements * and directories. */ public void nodeExpand(ExpandEvent event) { - Item i = tree.getItem(event.getItemId()); + final Item i = tree.getItem(event.getItemId()); if (!tree.hasChildren(i)) { // populate tree's node which was expanded populateNode(event.getItemId().toString(), event.getItemId()); @@ -75,12 +79,12 @@ public class TreeFilesystem extends com.itmill.toolkit.Application implements * node */ private void populateNode(String file, Object parent) { - File subdir = new File(file); - File[] files = subdir.listFiles(); + final File subdir = new File(file); + final File[] files = subdir.listFiles(); for (int x = 0; x < files.length; x++) { try { // add new item (String) to tree - String path = files[x].getCanonicalPath().toString(); + final String path = files[x].getCanonicalPath().toString(); tree.addItem(path); // set parent if this item has one if (parent != null) { @@ -94,7 +98,7 @@ public class TreeFilesystem extends com.itmill.toolkit.Application implements // no, childrens therefore do not exists tree.setChildrenAllowed(path, false); } - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } diff --git a/src/com/itmill/toolkit/demo/TreeFilesystemContainer.java b/src/com/itmill/toolkit/demo/TreeFilesystemContainer.java index 4606b3797a..6ccc7522ec 100644 --- a/src/com/itmill/toolkit/demo/TreeFilesystemContainer.java +++ b/src/com/itmill/toolkit/demo/TreeFilesystemContainer.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.io.File; @@ -5,6 +9,7 @@ import java.io.File; import com.itmill.toolkit.data.util.FilesystemContainer; import com.itmill.toolkit.data.util.FilesystemContainer.FileItem; import com.itmill.toolkit.demo.util.SampleDirectory; +import com.itmill.toolkit.terminal.Sizeable; import com.itmill.toolkit.ui.ExpandLayout; import com.itmill.toolkit.ui.Field; import com.itmill.toolkit.ui.Label; @@ -29,19 +34,19 @@ public class TreeFilesystemContainer extends com.itmill.toolkit.Application implements Listener { // Filesystem explorer panel and it's components - private Panel explorerPanel = new Panel("Filesystem explorer"); + private final Panel explorerPanel = new Panel("Filesystem explorer"); - private Tree filesystem = new Tree(); + private final Tree filesystem = new Tree(); // File properties panel and it's components - private Panel propertyPanel = new Panel("File properties"); + private final Panel propertyPanel = new Panel("File properties"); - private Label fileProperties = new Label(); + private final Label fileProperties = new Label(); public void init() { - Window w = new Window("Tree FilesystemContainer demo"); + final Window w = new Window("Tree FilesystemContainer demo"); setMainWindow(w); - ExpandLayout main = new ExpandLayout(); + final ExpandLayout main = new ExpandLayout(); w.setLayout(main); main.setMargin(true); main.setSpacing(true); @@ -49,7 +54,7 @@ public class TreeFilesystemContainer extends com.itmill.toolkit.Application propertyPanel.setHeight(120); main.addComponent(propertyPanel); explorerPanel.setHeight(100); - explorerPanel.setHeightUnits(Panel.UNITS_PERCENTAGE); + explorerPanel.setHeightUnits(Sizeable.UNITS_PERCENTAGE); main.addComponent(explorerPanel); main.expand(explorerPanel); @@ -62,9 +67,9 @@ public class TreeFilesystemContainer extends com.itmill.toolkit.Application propertyPanel.setEnabled(false); // Get sample directory - File sampleDir = SampleDirectory.getDirectory(this); + final File sampleDir = SampleDirectory.getDirectory(this); // Populate tree with FilesystemContainer - FilesystemContainer fsc = new FilesystemContainer(sampleDir, true); + final FilesystemContainer fsc = new FilesystemContainer(sampleDir, true); filesystem.setContainerDataSource(fsc); // "this" handles all filesystem events // e.g. node clicked, expanded etc. @@ -83,8 +88,8 @@ public class TreeFilesystemContainer extends com.itmill.toolkit.Application // Check if event is about changing value if (event.getClass() == Field.ValueChangeEvent.class) { // Update property panel contents - FileItem fileItem = (FileItem) filesystem.getItem(filesystem - .getValue()); + final FileItem fileItem = (FileItem) filesystem + .getItem(filesystem.getValue()); fileProperties.setIcon(fileItem.getIcon()); fileProperties.setCaption(fileItem.getName() + ", size " + fileItem.getSize() + " bytes."); diff --git a/src/com/itmill/toolkit/demo/UpgradingSample.java b/src/com/itmill/toolkit/demo/UpgradingSample.java index 922c129932..a2a2c31f66 100644 --- a/src/com/itmill/toolkit/demo/UpgradingSample.java +++ b/src/com/itmill/toolkit/demo/UpgradingSample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; // @@ -34,27 +38,28 @@ public class UpgradingSample extends Application implements Property.ValueChangeListener { /* Menu for navigating inside the application. */ - private Tree menu = new Tree(); + private final Tree menu = new Tree(); /* Contents of the website */ - private String[][] pages = { { "Welcome", "Welcome to our website..." }, + private final String[][] pages = { + { "Welcome", "Welcome to our website..." }, { "Products", "Public product information." }, { "Contact", "Public contact information." }, { "CRM", "CRM Database requiring login." }, { "Intranet", "Internal information database." } }; /* Application layout */ - private GridLayout layout = new GridLayout(2, 1); + private final GridLayout layout = new GridLayout(2, 1); /* Initialize the application */ public void init() { // Create the main window of the application - Window main = new Window("Login example", layout); + final Window main = new Window("Login example", layout); setMainWindow(main); // Add menu and loginbox to the application - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); layout.addComponent(l, 0, 0); l.addComponent(menu); l.addComponent(new LoginBox()); @@ -88,10 +93,10 @@ public class UpgradingSample extends Application implements // Handle menu selection and update visible page public void valueChange(Property.ValueChangeEvent event) { layout.removeComponent(1, 0); - String title = (String) menu.getValue(); + final String title = (String) menu.getValue(); for (int i = 0; i < pages.length; i++) { if (pages[i][0].equals(title)) { - Panel p = new Panel(pages[i][0]); + final Panel p = new Panel(pages[i][0]); p.addComponent(new Label(pages[i][1])); p.setStyle("strong"); layout.addComponent(p, 1, 0); @@ -104,18 +109,18 @@ public class UpgradingSample extends Application implements Application.UserChangeListener { // The components this loginbox is composed of - private TextField loginName = new TextField("Name"); + private final TextField loginName = new TextField("Name"); - private Button loginButton = new Button("Enter", this, "login"); + private final Button loginButton = new Button("Enter", this, "login"); - private Panel loginPanel = new Panel("Login"); + private final Panel loginPanel = new Panel("Login"); - private Panel statusPanel = new Panel(); + private final Panel statusPanel = new Panel(); - private Button logoutButton = new Button("Logout", + private final Button logoutButton = new Button("Logout", UpgradingSample.this, "close"); - private Label statusLabel = new Label(); + private final Label statusLabel = new Label(); // Initialize login component public LoginBox() { @@ -138,7 +143,7 @@ public class UpgradingSample extends Application implements // Login into application public void login() { - String name = (String) loginName.getValue(); + final String name = (String) loginName.getValue(); if (name != null && name.length() > 0) { setUser(name); } diff --git a/src/com/itmill/toolkit/demo/WindowedDemos.java b/src/com/itmill/toolkit/demo/WindowedDemos.java index 840f153ed2..6ec59bf629 100644 --- a/src/com/itmill/toolkit/demo/WindowedDemos.java +++ b/src/com/itmill/toolkit/demo/WindowedDemos.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo; import java.util.HashMap; @@ -35,20 +39,20 @@ public class WindowedDemos extends com.itmill.toolkit.Application { public void init() { // Create new window for the application and give the window a visible. - Window main = new Window("IT Mill Toolkit 5 Windowed Demos"); + final Window main = new Window("IT Mill Toolkit 5 Windowed Demos"); // set as main window setMainWindow(main); // Create menu window. - Window menu = new Window("Select demo"); + final Window menu = new Window("Select demo"); menu.setWidth(200); menu.setHeight(400); main.addWindow(menu); // add to layout // Create a menu button for each demo - for (Iterator it = servlets.keySet().iterator(); it.hasNext();) { - String name = (String) it.next(); - Button b = new Button(name, new Button.ClickListener() { + for (final Iterator it = servlets.keySet().iterator(); it.hasNext();) { + final String name = (String) it.next(); + final Button b = new Button(name, new Button.ClickListener() { public void buttonClick(ClickEvent event) { show(event.getButton().getCaption()); } diff --git a/src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java b/src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java index 12ecb24dbf..a6a6ff249e 100644 --- a/src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java +++ b/src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.colorpicker; import java.util.Map; @@ -50,7 +54,7 @@ public class ColorPicker extends AbstractField { public void changeVariables(Object source, Map variables) { // Sets the currently selected color if (variables.containsKey("colorname") && !isReadOnly()) { - String newValue = (String) variables.get("colorname"); + final String newValue = (String) variables.get("colorname"); // Changing the property of the component will // trigger a ValueChangeEvent setValue(newValue, true); diff --git a/src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java b/src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java index 248b4a5af2..e1fd2a1a8c 100644 --- a/src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java +++ b/src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.colorpicker; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -39,7 +43,7 @@ public class ColorPickerApplication extends com.itmill.toolkit.Application { main.addComponent(colorname); // Server-side manipulation of the component state - Button button = new Button("Set to white"); + final Button button = new Button("Set to white"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { colorselector.setColor("white"); diff --git a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ColorPickerWidgetSet.java b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ColorPickerWidgetSet.java index f6d43e5f0b..77409e5686 100644 --- a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ColorPickerWidgetSet.java +++ b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ColorPickerWidgetSet.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.colorpicker.gwt.client; import com.google.gwt.user.client.ui.Widget; @@ -8,7 +12,7 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL; public class ColorPickerWidgetSet extends DefaultWidgetSet { /** Creates a widget according to its class name. */ public Widget createWidget(UIDL uidl) { - String className = resolveWidgetTypeName(uidl); + final String className = resolveWidgetTypeName(uidl); if ("com.itmill.toolkit.demo.colorpicker.gwt.client.ui.IColorPicker" .equals(className)) { return new IColorPicker(); @@ -20,7 +24,7 @@ public class ColorPickerWidgetSet extends DefaultWidgetSet { /** Resolves UIDL tag name to class name. */ protected String resolveWidgetTypeName(UIDL uidl) { - String tag = uidl.getTag(); + final String tag = uidl.getTag(); if ("colorpicker".equals(tag)) { return "com.itmill.toolkit.demo.colorpicker.gwt.client.ui.IColorPicker"; } diff --git a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java index 38b83f1961..b4d060d528 100644 --- a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java +++ b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.colorpicker.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -20,15 +24,15 @@ public class GwtColorPicker extends Composite implements ClickListener { public GwtColorPicker() { // Create a 4x4 grid of buttons with names for 16 colors - Grid grid = new Grid(4, 4); - String[] colors = new String[] { "aqua", "black", "blue", "fuchsia", - "gray", "green", "lime", "maroon", "navy", "olive", "purple", - "red", "silver", "teal", "white", "yellow" }; + final Grid grid = new Grid(4, 4); + final String[] colors = new String[] { "aqua", "black", "blue", + "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", + "purple", "red", "silver", "teal", "white", "yellow" }; int colornum = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++, colornum++) { // Create a button for each color - Button button = new Button(colors[colornum]); + final Button button = new Button(colors[colornum]); button.addClickListener(this); // Put the button in the Grid layout @@ -49,7 +53,7 @@ public class GwtColorPicker extends Composite implements ClickListener { // Create a panel with the color grid and currently selected color // indicator - HorizontalPanel panel = new HorizontalPanel(); + final HorizontalPanel panel = new HorizontalPanel(); panel.add(grid); panel.add(currentcolor); @@ -60,7 +64,7 @@ public class GwtColorPicker extends Composite implements ClickListener { // the parent of the label element. Notice that the element has no // parent // before the widget has been added to the horizontal panel. - Element panelcell = DOM.getParent(currentcolor.getElement()); + final Element panelcell = DOM.getParent(currentcolor.getElement()); DOM.setElementProperty(panelcell, "className", "colorpicker-currentcolorbox"); @@ -85,8 +89,8 @@ public class GwtColorPicker extends Composite implements ClickListener { // Obtain the DOM elements. This assumes that the element // of the HorizontalPanel is the parent of the label element. - Element nameelement = currentcolor.getElement(); - Element cell = DOM.getParent(nameelement); + final Element nameelement = currentcolor.getElement(); + final Element cell = DOM.getParent(nameelement); // Give feedback by changing the background color DOM.setStyleAttribute(cell, "background", newcolor); diff --git a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/IColorPicker.java b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/IColorPicker.java index 434c4f0530..bab75f85f5 100644 --- a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/IColorPicker.java +++ b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/IColorPicker.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.colorpicker.gwt.client.ui; import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; diff --git a/src/com/itmill/toolkit/demo/featurebrowser/ButtonExample.java b/src/com/itmill/toolkit/demo/featurebrowser/ButtonExample.java index b4406da7b4..a352fe99ff 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/ButtonExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/ButtonExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.terminal.ExternalResource; @@ -21,18 +25,18 @@ public class ButtonExample extends CustomComponent implements public ButtonExample() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); - OrderedLayout horiz = new OrderedLayout( + final OrderedLayout horiz = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); main.addComponent(horiz); - Panel basic = new Panel("Basic buttons"); + final Panel basic = new Panel("Basic buttons"); basic.setStyleName(Panel.STYLE_LIGHT); horiz.addComponent(basic); - Panel bells = new Panel("w/ bells & whistles"); + final Panel bells = new Panel("w/ bells & whistles"); bells.setStyleName(Panel.STYLE_LIGHT); horiz.addComponent(bells); @@ -77,10 +81,10 @@ public class ButtonExample extends CustomComponent implements b.setDescription("Link-style, icon+tootip, no caption"); basic.addComponent(b); - Panel links = new Panel("Links"); + final Panel links = new Panel("Links"); links.setStyleName(Panel.STYLE_LIGHT); main.addComponent(links); - Label desc = new Label( + final Label desc = new Label( "The main difference between a Link and" + " a link-styled Button is that the Link works client-" + " side, whereas the Button works server side.
This means" @@ -123,7 +127,7 @@ public class ButtonExample extends CustomComponent implements } public void buttonClick(ClickEvent event) { - Button b = event.getButton(); + final Button b = event.getButton(); getWindow().showNotification( "Clicked" + (b instanceof CheckBox ? ", value: " diff --git a/src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java b/src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java index 235fe9c466..7f6e6d38f5 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/ClientCachingExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.terminal.PaintException; @@ -28,13 +32,13 @@ public class ClientCachingExample extends CustomComponent { public ClientCachingExample() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); main.addComponent(new Label(msg)); - TabSheet ts = new TabSheet(); + final TabSheet ts = new TabSheet(); main.addComponent(ts); Layout layout = new OrderedLayout(); @@ -51,7 +55,7 @@ public class ClientCachingExample extends CustomComponent { public void paintContent(PaintTarget target) throws PaintException { try { Thread.sleep(3000); - } catch (Exception e) { + } catch (final Exception e) { // IGNORED } super.paintContent(target); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java b/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java index c83db8b2a0..b7a02f3161 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.ui.ComboBox; @@ -21,12 +25,12 @@ public class ComboBoxExample extends CustomComponent { "Fielding", "Einstein" }; public ComboBoxExample() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); // starts-with filter - ComboBox s1 = new ComboBox("Select with starts-with filter"); + final ComboBox s1 = new ComboBox("Select with starts-with filter"); s1.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH); s1.setColumns(20); for (int i = 0; i < 105; i++) { @@ -39,7 +43,7 @@ public class ComboBoxExample extends CustomComponent { main.addComponent(s1); // contains filter - ComboBox s2 = new ComboBox("Select with contains filter"); + final ComboBox s2 = new ComboBox("Select with contains filter"); s2.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); s2.setColumns(20); for (int i = 0; i < 500; i++) { @@ -52,7 +56,7 @@ public class ComboBoxExample extends CustomComponent { main.addComponent(s2); // initially empty - ComboBox s3 = new ComboBox("Initially empty; enter your own"); + final ComboBox s3 = new ComboBox("Initially empty; enter your own"); s3.setColumns(20); s3.setImmediate(true); main.addComponent(s3); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java b/src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java index 5ff1a9d79e..7391fc135e 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -33,7 +37,7 @@ public class EmbeddedBrowserExample extends ExpandLayout implements setSizeFull(); // create the address combobox - Select select = new Select(); + final Select select = new Select(); // allow input select.setNewItemsAllowed(true); // no empty selection @@ -59,7 +63,7 @@ public class EmbeddedBrowserExample extends ExpandLayout implements } public void valueChange(ValueChangeEvent event) { - String url = (String) event.getProperty().getValue(); + final String url = (String) event.getProperty().getValue(); if (url != null) { // the selected url has changed, let's go there emb.setSource(new ExternalResource(url)); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java b/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java index a15547472b..0e80eba006 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import java.util.HashMap; @@ -10,6 +14,7 @@ import com.itmill.toolkit.data.util.IndexedContainer; import com.itmill.toolkit.terminal.ExternalResource; import com.itmill.toolkit.terminal.Sizeable; import com.itmill.toolkit.terminal.ThemeResource; +import com.itmill.toolkit.ui.AbstractSelect; import com.itmill.toolkit.ui.Button; import com.itmill.toolkit.ui.Component; import com.itmill.toolkit.ui.Embedded; @@ -46,7 +51,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements private TabSheet ts; // Example "cache" - private HashMap exampleInstances = new HashMap(); + private final HashMap exampleInstances = new HashMap(); // List of examples private static final Object[][] demos = new Object[][] { @@ -99,23 +104,24 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements setTheme("example"); // Create new window for the application and give the window a visible. - Window main = new Window("IT Mill Toolkit 5"); + final Window main = new Window("IT Mill Toolkit 5"); // set as main window setMainWindow(main); - SplitPanel split = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); + final SplitPanel split = new SplitPanel( + SplitPanel.ORIENTATION_HORIZONTAL); split.setSplitPosition(200, Sizeable.UNITS_PIXELS); main.setLayout(split); - HashMap sectionIds = new HashMap(); - HierarchicalContainer container = createContainer(); - Object rootId = container.addItem(); + final HashMap sectionIds = new HashMap(); + final HierarchicalContainer container = createContainer(); + final Object rootId = container.addItem(); Item item = container.getItem(rootId); Property p = item.getItemProperty(PROPERTY_ID_NAME); p.setValue("All examples"); for (int i = 0; i < demos.length; i++) { - Object[] demo = demos[i]; - String section = (String) demo[0]; + final Object[] demo = demos[i]; + final String section = (String) demo[0]; Object sectionId; if (sectionIds.containsKey(section)) { sectionId = sectionIds.get(section); @@ -127,7 +133,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements p = item.getItemProperty(PROPERTY_ID_NAME); p.setValue(section); } - Object id = container.addItem(); + final Object id = container.addItem(); container.setParent(id, sectionId); initItem(container.getItem(id), demo); @@ -138,7 +144,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements tree.setMultiSelect(false); tree.setNullSelectionAllowed(false); tree.setContainerDataSource(container); - tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY); + tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); tree.setItemCaptionPropertyId(PROPERTY_ID_NAME); tree.addListener(this); tree.setImmediate(true); @@ -146,7 +152,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements split.addComponent(tree); - SplitPanel split2 = new SplitPanel(); + final SplitPanel split2 = new SplitPanel(); split2.setSplitPosition(200, Sizeable.UNITS_PIXELS); split.addComponent(split2); @@ -159,7 +165,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements table.setNullSelectionAllowed(false); try { table.setContainerDataSource((IndexedContainer) container.clone()); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(System.err); } // Hide some columns @@ -169,11 +175,11 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements table.setImmediate(true); split2.addComponent(table); - ExpandLayout exp = new ExpandLayout(); + final ExpandLayout exp = new ExpandLayout(); exp.setMargin(true); split2.addComponent(exp); - OrderedLayout wbLayout = new OrderedLayout( + final OrderedLayout wbLayout = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); Button b = new Button("Open in sub-window", new Button.ClickListener() { public void buttonClick(ClickEvent event) { @@ -203,13 +209,13 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements public void buttonClick(ClickEvent event) { Component component = (Component) ts.getComponentIterator() .next(); - String caption = ts.getTabCaption(component); + final String caption = ts.getTabCaption(component); Window w = getWindow(caption); if (w == null) { try { component = (Component) component.getClass() .newInstance(); - } catch (Exception e) { + } catch (final Exception e) { // Could not create return; } @@ -230,8 +236,8 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements wbLayout.addComponent(b); exp.addComponent(wbLayout); - exp.setComponentAlignment(wbLayout, ExpandLayout.ALIGNMENT_RIGHT, - ExpandLayout.ALIGNMENT_TOP); + exp.setComponentAlignment(wbLayout, OrderedLayout.ALIGNMENT_RIGHT, + OrderedLayout.ALIGNMENT_TOP); ts = new TabSheet(); ts.setSizeFull(); @@ -239,13 +245,13 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements exp.addComponent(ts); exp.expand(ts); - Label status = new Label( + final Label status = new Label( "Developer Area" + " | Documentation"); status.setContentMode(Label.CONTENT_XHTML); exp.addComponent(status); - exp.setComponentAlignment(status, ExpandLayout.ALIGNMENT_RIGHT, - ExpandLayout.ALIGNMENT_VERTICAL_CENTER); + exp.setComponentAlignment(status, OrderedLayout.ALIGNMENT_RIGHT, + OrderedLayout.ALIGNMENT_VERTICAL_CENTER); // select initial section ("All") tree.setValue(rootId); @@ -270,7 +276,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements } private HierarchicalContainer createContainer() { - HierarchicalContainer c = new HierarchicalContainer(); + final HierarchicalContainer c = new HierarchicalContainer(); c.addContainerProperty(PROPERTY_ID_CATEGORY, String.class, null); c.addContainerProperty(PROPERTY_ID_NAME, String.class, ""); c.addContainerProperty(PROPERTY_ID_DESC, String.class, ""); @@ -281,8 +287,8 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements public void valueChange(ValueChangeEvent event) { if (event.getProperty() == tree) { - Object id = tree.getValue(); - Item item = tree.getItem(id); + final Object id = tree.getValue(); + final Item item = tree.getItem(id); // String section; if (tree.isRoot(id)) { @@ -296,7 +302,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements } table.setValue(null); - IndexedContainer c = (IndexedContainer) table + final IndexedContainer c = (IndexedContainer) table .getContainerDataSource(); c.removeAllContainerFilters(); if (section != null) { @@ -315,18 +321,18 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements table.removeListener(this); tree.setValue(table.getValue()); table.addListener(this); - Item item = table.getItem(table.getValue()); - Class c = (Class) item.getItemProperty(PROPERTY_ID_CLASS) + final Item item = table.getItem(table.getValue()); + final Class c = (Class) item.getItemProperty(PROPERTY_ID_CLASS) .getValue(); - Component component = getComponent(c); + final Component component = getComponent(c); if (component != null) { - String caption = (String) item.getItemProperty( + final String caption = (String) item.getItemProperty( PROPERTY_ID_NAME).getValue(); ts.removeAllComponents(); ts.addTab(component, caption, null); } // update "viewed" state - Property p = item.getItemProperty(PROPERTY_ID_VIEWED); + final Property p = item.getItemProperty(PROPERTY_ID_VIEWED); if (p.getValue() == null) { p.setValue(new Embedded("", new ThemeResource( "icons/ok.png"))); @@ -340,9 +346,9 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements private Component getComponent(Class componentClass) { if (!exampleInstances.containsKey(componentClass)) { try { - Component c = (Component) componentClass.newInstance(); + final Component c = (Component) componentClass.newInstance(); exampleInstances.put(componentClass, c); - } catch (Exception e) { + } catch (final Exception e) { return null; } } diff --git a/src/com/itmill/toolkit/demo/featurebrowser/LabelExample.java b/src/com/itmill/toolkit/demo/featurebrowser/LabelExample.java index 41e14b8841..c465b14845 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/LabelExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/LabelExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.ui.CustomComponent; @@ -25,11 +29,11 @@ public class LabelExample extends CustomComponent { public LabelExample() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); - GridLayout g = new GridLayout(2, 4); + final GridLayout g = new GridLayout(2, 4); main.addComponent(g); // plain w/o caption diff --git a/src/com/itmill/toolkit/demo/featurebrowser/LayoutExample.java b/src/com/itmill/toolkit/demo/featurebrowser/LayoutExample.java index 14510597ca..d33710b051 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/LayoutExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/LayoutExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.ui.CustomComponent; @@ -17,11 +21,11 @@ public class LayoutExample extends CustomComponent { public LayoutExample() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); - GridLayout g = new GridLayout(2, 5); + final GridLayout g = new GridLayout(2, 5); main.addComponent(g); // panel @@ -53,7 +57,7 @@ public class LayoutExample extends CustomComponent { ol.addComponent(new Label("Component 3")); ts.addTab(ol, "Horizontal OrderedLayout", null); - GridLayout gl = new GridLayout(3, 3); + final GridLayout gl = new GridLayout(3, 3); gl.setMargin(true); gl.addComponent(new Label("Component 1.1")); gl.addComponent(new Label("Component 1.2")); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java b/src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java index f0f8e2ac54..925474f1f5 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import java.util.Date; @@ -35,7 +39,7 @@ public class NotificationExample extends CustomComponent { */ public NotificationExample() { // Main layout - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); // use theme-specific margin setCompositionRoot(main); @@ -75,7 +79,7 @@ public class NotificationExample extends CustomComponent { message.setValue("A quick one jumped over the lazy dog."); // Button to show the notification - Button b = new Button("Show notification", new ClickListener() { + final Button b = new Button("Show notification", new ClickListener() { // this is an inline ClickListener public void buttonClick(ClickEvent event) { // show the notification diff --git a/src/com/itmill/toolkit/demo/featurebrowser/RichTextExample.java b/src/com/itmill/toolkit/demo/featurebrowser/RichTextExample.java index 6450940b0b..9410c8558b 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/RichTextExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/RichTextExample.java @@ -1,6 +1,7 @@ -/** - * +/* +@ITMillApache2LicenseForJavaFiles@ */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.ui.Button; @@ -22,10 +23,10 @@ public class RichTextExample extends CustomComponent { + "See the manual " + "for more information."; - private OrderedLayout main; - private Label l; - private RichTextArea editor = new RichTextArea(); - private Button b; + private final OrderedLayout main; + private final Label l; + private final RichTextArea editor = new RichTextArea(); + private final Button b; public RichTextExample() { // main layout diff --git a/src/com/itmill/toolkit/demo/featurebrowser/SelectExample.java b/src/com/itmill/toolkit/demo/featurebrowser/SelectExample.java index 46baf23fd7..084d14f149 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/SelectExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/SelectExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -20,24 +24,24 @@ import com.itmill.toolkit.ui.TwinColSelect; public class SelectExample extends CustomComponent { // listener that shows a value change notification - private Field.ValueChangeListener listener = new Field.ValueChangeListener() { + private final Field.ValueChangeListener listener = new Field.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { getWindow().showNotification("" + event.getProperty().getValue()); } }; public SelectExample() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); - OrderedLayout horiz = new OrderedLayout( + final OrderedLayout horiz = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); main.addComponent(horiz); - Panel single = new Panel("Single selects"); + final Panel single = new Panel("Single selects"); single.setStyleName(Panel.STYLE_LIGHT); horiz.addComponent(single); - Panel multi = new Panel("Multi selects"); + final Panel multi = new Panel("Multi selects"); multi.setStyleName(Panel.STYLE_LIGHT); horiz.addComponent(multi); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/TableExample.java b/src/com/itmill/toolkit/demo/featurebrowser/TableExample.java index 5d181212ef..29c55f224d 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/TableExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/TableExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import java.util.Iterator; @@ -46,7 +50,7 @@ public class TableExample extends CustomComponent implements Action.Handler, public TableExample() { // main layout - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); @@ -64,7 +68,7 @@ public class TableExample extends CustomComponent implements Action.Handler, main.addComponent(source); // x-selected button row - OrderedLayout horiz = new OrderedLayout( + final OrderedLayout horiz = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); horiz.setMargin(false, false, true, false); main.addComponent(horiz); @@ -96,7 +100,7 @@ public class TableExample extends CustomComponent implements Action.Handler, saved.addActionHandler(this); main.addComponent(saved); - CheckBox b = new CheckBox("Modify saved creatures"); + final CheckBox b = new CheckBox("Modify saved creatures"); b.addListener(new CheckBox.ClickListener() { public void buttonClick(ClickEvent event) { saved.setEditable(((Boolean) event.getButton().getValue()) @@ -122,17 +126,17 @@ public class TableExample extends CustomComponent implements Action.Handler, private void fillTable(Table table) { initProperties(table); - String[] sp = new String[] { "Fox", "Dog", "Cat", "Moose", "Penguin", - "Cow" }; - String[] ty = new String[] { "Quick", "Lazy", "Sleepy", "Fidgety", - "Crazy", "Kewl" }; - String[] ki = new String[] { "Jumping", "Walking", "Sleeping", + final String[] sp = new String[] { "Fox", "Dog", "Cat", "Moose", + "Penguin", "Cow" }; + final String[] ty = new String[] { "Quick", "Lazy", "Sleepy", + "Fidgety", "Crazy", "Kewl" }; + final String[] ki = new String[] { "Jumping", "Walking", "Sleeping", "Skipping", "Dancing" }; for (int i = 0; i < 100; i++) { - String s = sp[(int) (Math.random() * sp.length)]; - String t = ty[(int) (Math.random() * ty.length)]; - String k = ki[(int) (Math.random() * ki.length)]; + final String s = sp[(int) (Math.random() * sp.length)]; + final String t = ty[(int) (Math.random() * ty.length)]; + final String k = ki[(int) (Math.random() * ki.length)]; table.addItem(new Object[] { s, t, k, Boolean.FALSE }, new Integer( i)); } @@ -142,7 +146,7 @@ public class TableExample extends CustomComponent implements Action.Handler, // Called for each item (row), returns valid actions for that item public Action[] getActions(Object target, Object sender) { if (sender == source) { - Item item = source.getItem(target); + final Item item = source.getItem(target); // save, delete, and hire if not already hired if (item != null && item.getItemProperty(PROPERTY_HIRED).getValue() == Boolean.FALSE) { @@ -178,7 +182,7 @@ public class TableExample extends CustomComponent implements Action.Handler, return; } // "manual" copy of the item properties we want - Item added = saved.addItem(target); + final Item added = saved.addItem(target); Property p = added.getItemProperty(PROPERTY_SPECIES); p.setValue(item.getItemProperty(PROPERTY_SPECIES).getValue()); p = added.getItemProperty(PROPERTY_TYPE); @@ -197,7 +201,7 @@ public class TableExample extends CustomComponent implements Action.Handler, } else { // sender==saved if (action == ACTION_DELETE) { - Item item = saved.getItem(target); + final Item item = saved.getItem(target); getWindow().showNotification("Deleted", "" + item); saved.removeItem(target); } @@ -205,18 +209,18 @@ public class TableExample extends CustomComponent implements Action.Handler, } public void buttonClick(ClickEvent event) { - Button b = event.getButton(); + final Button b = event.getButton(); if (b == deselect) { source.setValue(null); } else if (b == saveSelected) { // loop each selected and copy to "saved" table - Set selected = (Set) source.getValue(); + final Set selected = (Set) source.getValue(); int s = 0; - for (Iterator it = selected.iterator(); it.hasNext();) { - Object id = it.next(); + for (final Iterator it = selected.iterator(); it.hasNext();) { + final Object id = it.next(); if (!saved.containsId(id)) { - Item item = source.getItem(id); - Item added = saved.addItem(id); + final Item item = source.getItem(id); + final Item added = saved.addItem(id); // "manual" copy of the properties we want Property p = added.getItemProperty(PROPERTY_SPECIES); p.setValue(item.getItemProperty(PROPERTY_SPECIES) @@ -236,11 +240,11 @@ public class TableExample extends CustomComponent implements Action.Handler, } else if (b == hireSelected) { // loop each selected and set property HIRED to true int s = 0; - Set selected = (Set) source.getValue(); - for (Iterator it = selected.iterator(); it.hasNext();) { - Object id = it.next(); + final Set selected = (Set) source.getValue(); + for (final Iterator it = selected.iterator(); it.hasNext();) { + final Object id = it.next(); Item item = source.getItem(id); - Property p = item.getItemProperty(PROPERTY_HIRED); + final Property p = item.getItemProperty(PROPERTY_HIRED); if (p.getValue() == Boolean.FALSE) { p.setValue(Boolean.TRUE); source.requestRepaint(); @@ -258,9 +262,9 @@ public class TableExample extends CustomComponent implements Action.Handler, } else { // loop trough selected and delete int s = 0; - Set selected = (Set) source.getValue(); - for (Iterator it = selected.iterator(); it.hasNext();) { - Object id = it.next(); + final Set selected = (Set) source.getValue(); + for (final Iterator it = selected.iterator(); it.hasNext();) { + final Object id = it.next(); if (source.containsId(id)) { s++; source.removeItem(id); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/TreeExample.java b/src/com/itmill/toolkit/demo/featurebrowser/TreeExample.java index ce62c7bf23..694c839fb4 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/TreeExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/TreeExample.java @@ -1,9 +1,14 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Property; import com.itmill.toolkit.data.Property.ValueChangeEvent; import com.itmill.toolkit.event.Action; +import com.itmill.toolkit.ui.AbstractSelect; import com.itmill.toolkit.ui.CustomComponent; import com.itmill.toolkit.ui.Label; import com.itmill.toolkit.ui.OrderedLayout; @@ -32,7 +37,7 @@ public class TreeExample extends CustomComponent implements Action.Handler, TextField editor; public TreeExample() { - OrderedLayout main = new OrderedLayout( + final OrderedLayout main = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); main.setMargin(true); setCompositionRoot(main); @@ -49,10 +54,10 @@ public class TreeExample extends CustomComponent implements Action.Handler, // 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(Tree.ITEM_CAPTION_MODE_PROPERTY); + tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); tree.setItemCaptionPropertyId(CAPTION_PROPERTY); for (int i = 1; i <= 3; i++) { - Object id = addCaptionedItem("Section " + i, null); + final Object id = addCaptionedItem("Section " + i, null); tree.expandItem(id); addCaptionedItem("Team A", id); addCaptionedItem("Team B", id); @@ -87,7 +92,7 @@ public class TreeExample extends CustomComponent implements Action.Handler, tree.removeItem(target); } else { // Add - Object id = addCaptionedItem("New Item", target); + final Object id = addCaptionedItem("New Item", target); tree.expandItem(target); tree.setValue(id); editor.focus(); @@ -95,7 +100,7 @@ public class TreeExample extends CustomComponent implements Action.Handler, } public void valueChange(ValueChangeEvent event) { - Object id = tree.getValue(); // selected item id + final Object id = tree.getValue(); // selected item id if (event.getProperty() == tree) { // a Tree item was (un) selected if (id == null) { @@ -109,7 +114,7 @@ public class TreeExample extends CustomComponent implements Action.Handler, editor.removeListener(this); // enable TextField and update value editor.setEnabled(true); - Item item = tree.getItem(id); + final Item item = tree.getItem(id); editor.setValue(item.getItemProperty(CAPTION_PROPERTY) .getValue()); // listen for TextField changes @@ -119,8 +124,8 @@ public class TreeExample extends CustomComponent implements Action.Handler, } else { // TextField if (id != null) { - Item item = tree.getItem(id); - Property p = item.getItemProperty(CAPTION_PROPERTY); + final Item item = tree.getItem(id); + final Property p = item.getItemProperty(CAPTION_PROPERTY); p.setValue(editor.getValue()); tree.requestRepaint(); } @@ -139,11 +144,11 @@ public class TreeExample extends CustomComponent implements Action.Handler, */ private Object addCaptionedItem(String caption, Object parent) { // add item, let tree decide id - Object id = tree.addItem(); + final Object id = tree.addItem(); // get the created item - Item item = tree.getItem(id); + final Item item = tree.getItem(id); // set our "caption" property - Property p = item.getItemProperty(CAPTION_PROPERTY); + final Property p = item.getItemProperty(CAPTION_PROPERTY); p.setValue(caption); if (parent != null) { tree.setParent(id, parent); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/ValueInputExample.java b/src/com/itmill/toolkit/demo/featurebrowser/ValueInputExample.java index cc07d4c0d5..6bbd875917 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/ValueInputExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/ValueInputExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.featurebrowser; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -19,12 +23,12 @@ import com.itmill.toolkit.ui.Window.Notification; public class ValueInputExample extends CustomComponent { public ValueInputExample() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); // listener that shows a value change notification - Field.ValueChangeListener listener = new Field.ValueChangeListener() { + final Field.ValueChangeListener listener = new Field.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { getWindow().showNotification("Received", "
" + event.getProperty().getValue() + "
", @@ -106,13 +110,13 @@ public class ValueInputExample extends CustomComponent { slider.addListener(new Slider.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { // update caption when value changes - Slider s = (Slider) event.getProperty(); + final Slider s = (Slider) event.getProperty(); s.setCaption("Value: " + s.getValue()); } }); try { slider.setValue(20); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(System.err); } left.addComponent(slider); @@ -122,13 +126,13 @@ public class ValueInputExample extends CustomComponent { slider.addListener(new Slider.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { // update caption when value changes - Slider s = (Slider) event.getProperty(); + final Slider s = (Slider) event.getProperty(); s.setCaption("Value: " + s.getValue()); } }); try { slider.setValue(0.5); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(System.err); } left.addComponent(slider); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java b/src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java index 8ae6021db1..c13d96d2ee 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java @@ -1,6 +1,7 @@ -/** - * +/* +@ITMillApache2LicenseForJavaFiles@ */ + package com.itmill.toolkit.demo.featurebrowser; import java.net.URL; @@ -37,19 +38,19 @@ public class WindowingExample extends CustomComponent { private URL windowUrl = null; public WindowingExample() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.setMargin(true); setCompositionRoot(main); - Label l = new Label(txt); + final Label l = new Label(txt); l.setContentMode(Label.CONTENT_XHTML); main.addComponent(l); main.addComponent(new Button("Create a new subwindow", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - Window w = new Window("Subwindow"); - Label l = new Label(txt); + final Window w = new Window("Subwindow"); + final Label l = new Label(txt); l.setContentMode(Label.CONTENT_XHTML); w.addComponent(l); getApplication().getMainWindow().addWindow(w); @@ -58,9 +59,9 @@ public class WindowingExample extends CustomComponent { main.addComponent(new Button("Create a new modal window", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - Window w = new Window("Modal window"); + final Window w = new Window("Modal window"); w.setModal(true); - Label l = new Label(txt); + final Label l = new Label(txt); l.setContentMode(Label.CONTENT_XHTML); w.addComponent(l); getApplication().getMainWindow().addWindow(w); @@ -71,8 +72,8 @@ public class WindowingExample extends CustomComponent { new Button.ClickListener() { public void buttonClick(ClickEvent event) { if (windowUrl == null) { - Window w = new Window("Subwindow"); - Label l = new Label(txt); + final Window w = new Window("Subwindow"); + final Label l = new Label(txt); l.setContentMode(Label.CONTENT_XHTML); w.addComponent(l); getApplication().addWindow(w); @@ -86,10 +87,11 @@ public class WindowingExample extends CustomComponent { "Create a new application-level window, with it's own state", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - Window w = new Window("Subwindow"); + final Window w = new Window("Subwindow"); getApplication().addWindow(w); - Label l = new Label("Each opened window has its own" - + " name, and is accessed trough its own uri."); + final Label l = new Label( + "Each opened window has its own" + + " name, and is accessed trough its own uri."); l.setCaption("Window " + w.getName()); w.addComponent(l); getApplication().getMainWindow().open( diff --git a/src/com/itmill/toolkit/demo/reservation/CalendarDemo.java b/src/com/itmill/toolkit/demo/reservation/CalendarDemo.java index bbe5ef8778..4a2be6c878 100644 --- a/src/com/itmill/toolkit/demo/reservation/CalendarDemo.java +++ b/src/com/itmill/toolkit/demo/reservation/CalendarDemo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation; import java.sql.SQLException; @@ -35,7 +39,7 @@ public class CalendarDemo extends com.itmill.toolkit.Application { * Initialize Application. Demo components are added to main window. */ public void init() { - Window main = new Window("Calendar demo"); + final Window main = new Window("Calendar demo"); setMainWindow(main); main.setLayout(new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL)); @@ -54,8 +58,8 @@ public class CalendarDemo extends com.itmill.toolkit.Application { from.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { - Date fd = (Date) from.getValue(); - Date td = (Date) to.getValue(); + final Date fd = (Date) from.getValue(); + final Date td = (Date) to.getValue(); if (fd == null) { to.setValue(null); to.setEnabled(false); @@ -85,12 +89,12 @@ public class CalendarDemo extends com.itmill.toolkit.Application { */ private void initCalendars() { try { - QueryContainer qc = new QueryContainer("SELECT * FROM " + final QueryContainer qc = new QueryContainer("SELECT * FROM " + SampleCalendarDatabase.DB_TABLE_NAME, sampleDatabase .getConnection()); from.setContainerDataSource(qc); to.setContainerDataSource(qc); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); } /* diff --git a/src/com/itmill/toolkit/demo/reservation/CalendarField.java b/src/com/itmill/toolkit/demo/reservation/CalendarField.java index a746685c4f..565d78a97b 100644 --- a/src/com/itmill/toolkit/demo/reservation/CalendarField.java +++ b/src/com/itmill/toolkit/demo/reservation/CalendarField.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation; import java.util.Collection; @@ -118,19 +122,19 @@ public class CalendarField extends DateField implements Container.Viewer { // Check old propertyIds if (itemEndPropertyId != null) { - Class c = dataSource.getType(itemEndPropertyId); + final Class c = dataSource.getType(itemEndPropertyId); if (!Date.class.isAssignableFrom(c)) { itemEndPropertyId = null; } } if (itemNotimePropertyId != null) { - Class c = dataSource.getType(itemNotimePropertyId); + final Class c = dataSource.getType(itemNotimePropertyId); if (!Boolean.class.isAssignableFrom(c)) { itemNotimePropertyId = null; } } if (itemStartPropertyId != null) { - Class c = dataSource.getType(itemStartPropertyId); + final Class c = dataSource.getType(itemStartPropertyId); if (Date.class.isAssignableFrom(c)) { // All we _really_ need is one date return true; @@ -139,10 +143,10 @@ public class CalendarField extends DateField implements Container.Viewer { } } // We need at least one Date - Collection ids = dataSource.getContainerPropertyIds(); - for (Iterator it = ids.iterator(); it.hasNext();) { - Object id = it.next(); - Class c = dataSource.getType(id); + final Collection ids = dataSource.getContainerPropertyIds(); + for (final Iterator it = ids.iterator(); it.hasNext();) { + final Object id = it.next(); + final Class c = dataSource.getType(id); if (Date.class.isAssignableFrom(c)) { itemStartPropertyId = id; return true; @@ -242,14 +246,15 @@ public class CalendarField extends DateField implements Container.Viewer { // TODO send one month now, the rest via lazyloading int month = new Date().getMonth(); - Object value = getValue(); + final Object value = getValue(); if (value != null && value instanceof Date) { month = ((Date) value).getMonth(); } - for (Iterator it = dataSource.getItemIds().iterator(); it.hasNext();) { - Object itemId = it.next(); - Item item = dataSource.getItem(itemId); + for (final Iterator it = dataSource.getItemIds().iterator(); it + .hasNext();) { + final Object itemId = it.next(); + final Item item = dataSource.getItem(itemId); Property p = item.getItemProperty(itemStartPropertyId); Date start = (Date) p.getValue(); Date end = start; // assume same day @@ -259,7 +264,7 @@ public class CalendarField extends DateField implements Container.Viewer { if (end == null) { end = start; } else if (end.before(start)) { - Date tmp = start; + final Date tmp = start; start = end; end = tmp; } @@ -274,7 +279,7 @@ public class CalendarField extends DateField implements Container.Viewer { target.addAttribute("id", itemId.hashCode()); if (itemStyleNamePropertyId != null) { p = item.getItemProperty(itemStyleNamePropertyId); - String styleName = (String) p.getValue(); + final String styleName = (String) p.getValue(); target.addAttribute("styleName", styleName); } target.addAttribute("start", "" + start.getTime()); @@ -283,14 +288,14 @@ public class CalendarField extends DateField implements Container.Viewer { } if (itemTitlePropertyId != null) { p = item.getItemProperty(itemTitlePropertyId); - Object val = p.getValue(); + final Object val = p.getValue(); if (val != null) { target.addAttribute("title", val.toString()); } } if (itemDescriptionPropertyId != null) { p = item.getItemProperty(itemDescriptionPropertyId); - Object val = p.getValue(); + final Object val = p.getValue(); if (val != null) { target.addAttribute("description", val .toString()); @@ -298,7 +303,7 @@ public class CalendarField extends DateField implements Container.Viewer { } if (itemNotimePropertyId != null) { p = item.getItemProperty(itemNotimePropertyId); - Object val = p.getValue(); + final Object val = p.getValue(); if (val != null) { target.addAttribute("notime", ((Boolean) val) .booleanValue()); diff --git a/src/com/itmill/toolkit/demo/reservation/GoogleMap.java b/src/com/itmill/toolkit/demo/reservation/GoogleMap.java index 5355b9eea3..b2a20bdae5 100644 --- a/src/com/itmill/toolkit/demo/reservation/GoogleMap.java +++ b/src/com/itmill/toolkit/demo/reservation/GoogleMap.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation; import java.awt.geom.Point2D; @@ -15,8 +19,8 @@ import com.itmill.toolkit.ui.AbstractComponent; public class GoogleMap extends AbstractComponent implements Sizeable, Container.Viewer { - private String TAG_MARKERS = "markers"; - private String TAG_MARKER = "marker"; + private final String TAG_MARKERS = "markers"; + private final String TAG_MARKER = "marker"; private int width = 400; private int height = 300; private int zoomLevel = 15; @@ -43,14 +47,14 @@ public class GoogleMap extends AbstractComponent implements Sizeable, if (dataSource != null) { target.startTag(TAG_MARKERS); - Collection itemIds = dataSource.getItemIds(); - for (Iterator it = itemIds.iterator(); it.hasNext();) { - Object itemId = it.next(); - Item item = dataSource.getItem(itemId); + final Collection itemIds = dataSource.getItemIds(); + for (final Iterator it = itemIds.iterator(); it.hasNext();) { + final Object itemId = it.next(); + final Item item = dataSource.getItem(itemId); Property p = item.getItemProperty(getItemMarkerXPropertyId()); - Double x = (Double) (p != null ? p.getValue() : null); + final Double x = (Double) (p != null ? p.getValue() : null); p = item.getItemProperty(getItemMarkerYPropertyId()); - Double y = (Double) (p != null ? p.getValue() : null); + final Double y = (Double) (p != null ? p.getValue() : null); if (x == null || y == null) { continue; } @@ -58,7 +62,7 @@ public class GoogleMap extends AbstractComponent implements Sizeable, target.addAttribute("x", x.doubleValue()); target.addAttribute("y", y.doubleValue()); p = item.getItemProperty(getItemMarkerHtmlPropertyId()); - String h = (String) (p != null ? p.getValue() : null); + final String h = (String) (p != null ? p.getValue() : null); target.addAttribute("html", h); target.endTag(TAG_MARKER); } @@ -170,11 +174,11 @@ public class GoogleMap extends AbstractComponent implements Sizeable, if (dataSource == null) { initDataSource(); } - Object markerId = dataSource.addItem(); + final Object markerId = dataSource.addItem(); if (markerId == null) { return null; } - Item marker = dataSource.getItem(markerId); + final Item marker = dataSource.getItem(markerId); Property p = marker.getItemProperty(getItemMarkerXPropertyId()); p.setValue(new Double(location.x)); p = marker.getItemProperty(getItemMarkerYPropertyId()); diff --git a/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java b/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java index c95ca3857c..130768aa7f 100644 --- a/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java +++ b/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation; import java.awt.geom.Point2D; @@ -59,14 +63,14 @@ public class ReservationApplication extends Application { db.generateDemoUser(); db.generateReservations(); - Window mainWindow = new Window("Reservr"); + final Window mainWindow = new Window("Reservr"); setMainWindow(mainWindow); setTheme("reservr"); - TabSheet mainTabs = new TabSheet(); + final TabSheet mainTabs = new TabSheet(); mainWindow.addComponent(mainTabs); - OrderedLayout reservationTab = new OrderedLayout(); + final OrderedLayout reservationTab = new OrderedLayout(); mainTabs.addTab(reservationTab, "Make reservation", null); resourcePanel = new ResourceSelectorPanel("Resources"); @@ -76,13 +80,13 @@ public class ReservationApplication extends Application { this, "selectedResourcesChanged"); reservationTab.addComponent(resourcePanel); - Panel reservationPanel = new Panel("Reservation", new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL)); + final Panel reservationPanel = new Panel("Reservation", + new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL)); reservationPanel.addStyleName(Panel.STYLE_LIGHT); reservationPanel.getLayout().setMargin(true); reservationTab.addComponent(reservationPanel); - OrderedLayout infoLayout = new OrderedLayout(); + final OrderedLayout infoLayout = new OrderedLayout(); infoLayout.setMargin(false, true, false, false); reservationPanel.addComponent(infoLayout); resourceName = new Label("From the list above"); @@ -107,7 +111,7 @@ public class ReservationApplication extends Application { map.setContainerDataSource(db.getResources(null)); infoLayout.addComponent(map); - Calendar from = Calendar.getInstance(); + final Calendar from = Calendar.getInstance(); from.add(Calendar.HOUR, 1); from.set(Calendar.MINUTE, 0); from.set(Calendar.SECOND, 0); @@ -119,12 +123,12 @@ public class ReservationApplication extends Application { initCalendarFieldPropertyIds(reservedFrom); reservationPanel.addComponent(reservedFrom); - Label arrowLabel = new Label("»"); + final Label arrowLabel = new Label("»"); arrowLabel.setContentMode(Label.CONTENT_XHTML); arrowLabel.setStyleName("arrow"); reservationPanel.addComponent(arrowLabel); - Calendar to = Calendar.getInstance(); + final Calendar to = Calendar.getInstance(); to.setTime(from.getTime()); to.add(Calendar.MILLISECOND, (int) DEFAULT_GAP_MILLIS); reservedTo = new CalendarField("To"); @@ -136,7 +140,7 @@ public class ReservationApplication extends Application { reservedFrom.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { - Date fd = (Date) reservedFrom.getValue(); + final Date fd = (Date) reservedFrom.getValue(); if (fd == null) { reservedTo.setValue(null); reservedTo.setEnabled(false); @@ -147,7 +151,7 @@ public class ReservationApplication extends Application { } reservedTo.setMinimumDate(new Date(fd.getTime() + DEFAULT_GAP_MILLIS)); - Calendar to = Calendar.getInstance(); + final Calendar to = Calendar.getInstance(); to.setTime(fd); to.add(Calendar.MILLISECOND, (int) currentGapMillis); reservedTo.setValue(to.getTime()); @@ -156,11 +160,11 @@ public class ReservationApplication extends Application { }); reservedTo.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { - Date from = (Date) reservedFrom.getValue(); - Date to = (Date) reservedTo.getValue(); + final Date from = (Date) reservedFrom.getValue(); + final Date to = (Date) reservedTo.getValue(); currentGapMillis = to.getTime() - from.getTime(); if (currentGapMillis <= 0) { - Calendar t = Calendar.getInstance(); + final Calendar t = Calendar.getInstance(); t.setTime(from); t.add(Calendar.MILLISECOND, (int) DEFAULT_GAP_MILLIS); reservedTo.setValue(t.getTime()); @@ -169,7 +173,7 @@ public class ReservationApplication extends Application { } }); - OrderedLayout allLayout = new OrderedLayout( + final OrderedLayout allLayout = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); allLayout.addStyleName(Panel.STYLE_LIGHT); allLayout.setMargin(true); @@ -193,7 +197,7 @@ public class ReservationApplication extends Application { public void makeReservation() { try { - Item resource = getActiveResource(); + final Item resource = getActiveResource(); if (resource != null) { db.addReservation(resource, 0, (Date) reservedFrom.getValue(), (Date) reservedTo.getValue(), (String) description @@ -209,7 +213,7 @@ public class ReservationApplication extends Application { "Please select a resource (or category) to reserve.", Notification.TYPE_WARNING_MESSAGE); } - } catch (ResourceNotAvailableException e) { + } catch (final ResourceNotAvailableException e) { getMainWindow() .showNotification( "Not available!", @@ -220,11 +224,11 @@ public class ReservationApplication extends Application { } private Item getActiveResource() throws ResourceNotAvailableException { - List rids = resourcePanel.getSelectedResources(); + final List rids = resourcePanel.getSelectedResources(); if (rids != null && rids.size() > 0) { - for (Iterator it = rids.iterator(); it.hasNext();) { - Item resource = (Item) it.next(); - int id = ((Integer) resource.getItemProperty( + for (final Iterator it = rids.iterator(); it.hasNext();) { + final Item resource = (Item) it.next(); + final int id = ((Integer) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_ID).getValue()) .intValue(); if (db.isAvailableResource(id, (Date) reservedFrom.getValue(), @@ -239,14 +243,14 @@ public class ReservationApplication extends Application { } private void refreshReservations(boolean alsoResources) { - Container reservations = db.getReservations(resourcePanel + final Container reservations = db.getReservations(resourcePanel .getSelectedResources()); reservedFrom.setContainerDataSource(reservations); reservedTo.setContainerDataSource(reservations); if (alsoResources) { refreshSelectedResources(); } - Container allReservations = db.getReservations(null); + final Container allReservations = db.getReservations(null); allTable.setContainerDataSource(allReservations); if (allReservations != null && allReservations.size() > 0) { allTable.setVisibleColumns(new Object[] { @@ -264,7 +268,7 @@ public class ReservationApplication extends Application { Item resource = null; try { resource = getActiveResource(); - } catch (ResourceNotAvailableException e) { + } catch (final ResourceNotAvailableException e) { getMainWindow().showNotification("Not available", "Please choose another resource or time period.", Notification.TYPE_HUMANIZED_MESSAGE); @@ -287,16 +291,16 @@ public class ReservationApplication extends Application { resourceName.setCaption(name); resourceName.setValue(desc); // Put all resources on map (may be many if category was selected) - LinkedList srs = resourcePanel.getSelectedResources(); - for (Iterator it = srs.iterator(); it.hasNext();) { + final LinkedList srs = resourcePanel.getSelectedResources(); + for (final Iterator it = srs.iterator(); it.hasNext();) { resource = (Item) it.next(); name = (String) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_NAME).getValue(); desc = (String) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue(); - Double x = (Double) resource.getItemProperty( + final Double x = (Double) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_LOCATIONX).getValue(); - Double y = (Double) resource.getItemProperty( + final Double y = (Double) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_LOCATIONY).getValue(); if (x != null && y != null) { map.addMarker(name + "
" + desc, new Point2D.Double(x diff --git a/src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java b/src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java index 673d6e9190..4ae388d0e4 100644 --- a/src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java +++ b/src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation; public class ResourceNotAvailableException extends Exception { diff --git a/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java b/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java index a34bdd66ad..8d0efd881d 100644 --- a/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java +++ b/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation; import java.util.HashMap; @@ -14,8 +18,8 @@ import com.itmill.toolkit.ui.Button.ClickEvent; public class ResourceSelectorPanel extends Panel implements Button.ClickListener { - private HashMap categoryLayouts = new HashMap(); - private HashMap categoryResources = new HashMap(); + private final HashMap categoryLayouts = new HashMap(); + private final HashMap categoryResources = new HashMap(); private Container allResources; private LinkedList selectedResources = null; @@ -30,17 +34,18 @@ public class ResourceSelectorPanel extends Panel implements categoryLayouts.clear(); categoryResources.clear(); if (resources != null && resources.size() > 0) { - for (Iterator it = resources.getItemIds().iterator(); it.hasNext();) { - Item resource = resources.getItem(it.next()); - Integer id = (Integer) resource.getItemProperty( + for (final Iterator it = resources.getItemIds().iterator(); it + .hasNext();) { + final Item resource = resources.getItem(it.next()); + final Integer id = (Integer) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_ID).getValue(); - String category = (String) resource.getItemProperty( + final String category = (String) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_CATEGORY).getValue(); - String name = (String) resource.getItemProperty( + final String name = (String) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_NAME).getValue(); - String description = (String) resource.getItemProperty( + final String description = (String) resource.getItemProperty( SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue(); - Button rButton = new Button(name, this); + final Button rButton = new Button(name, this); rButton.setStyleName("link"); rButton.setDescription(description); rButton.setData(resource); @@ -54,7 +59,7 @@ public class ResourceSelectorPanel extends Panel implements categoryLayouts.put(category, resourceLayout); resourceList = new LinkedList(); categoryResources.put(category, resourceList); - Button cButton = new Button(category + " (any)", this); + final Button cButton = new Button(category + " (any)", this); cButton.setStyleName("important-link"); cButton.setData(category); resourceLayout.addComponent(cButton); @@ -68,13 +73,13 @@ public class ResourceSelectorPanel extends Panel implements // Selects one initial categore, inpractice randomly public void selectFirstCategory() { try { - Object catId = categoryResources.keySet().iterator().next(); - LinkedList res = (LinkedList) categoryResources.get(catId); - Layout l = (Layout) categoryLayouts.get(catId); - Button catB = (Button) l.getComponentIterator().next(); + final Object catId = categoryResources.keySet().iterator().next(); + final LinkedList res = (LinkedList) categoryResources.get(catId); + final Layout l = (Layout) categoryLayouts.get(catId); + final Button catB = (Button) l.getComponentIterator().next(); setSelectedResources(res); catB.setStyleName("selected-link"); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(System.err); } } @@ -89,18 +94,18 @@ public class ResourceSelectorPanel extends Panel implements } public void buttonClick(ClickEvent event) { - Object source = event.getSource(); + final Object source = event.getSource(); if (source instanceof Button) { - Object data = ((Button) source).getData(); - String name = ((Button) source).getCaption(); + final Object data = ((Button) source).getData(); + final String name = ((Button) source).getCaption(); resetStyles(); if (data instanceof Item) { - LinkedList rlist = new LinkedList(); + final LinkedList rlist = new LinkedList(); rlist.add(data); setSelectedResources(rlist); } else { - String category = (String) data; - LinkedList resources = (LinkedList) categoryResources + final String category = (String) data; + final LinkedList resources = (LinkedList) categoryResources .get(category); setSelectedResources(resources); } @@ -110,10 +115,11 @@ public class ResourceSelectorPanel extends Panel implements } private void resetStyles() { - for (Iterator it = categoryLayouts.values().iterator(); it.hasNext();) { - Layout lo = (Layout) it.next(); - for (Iterator bit = lo.getComponentIterator(); bit.hasNext();) { - Button b = (Button) bit.next(); + for (final Iterator it = categoryLayouts.values().iterator(); it + .hasNext();) { + final Layout lo = (Layout) it.next(); + for (final Iterator bit = lo.getComponentIterator(); bit.hasNext();) { + final Button b = (Button) bit.next(); if (b.getData() instanceof Item) { b.setStyleName("link"); } else { diff --git a/src/com/itmill/toolkit/demo/reservation/SampleDB.java b/src/com/itmill/toolkit/demo/reservation/SampleDB.java index 05741f63fb..0f3163c147 100644 --- a/src/com/itmill/toolkit/demo/reservation/SampleDB.java +++ b/src/com/itmill/toolkit/demo/reservation/SampleDB.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation; import java.sql.Connection; @@ -118,17 +122,17 @@ public class SampleDB { private void dropTables() { try { update("DROP TABLE " + Reservation.TABLE); - } catch (SQLException IGNORED) { + } catch (final SQLException IGNORED) { // IGNORED, assuming it was not there } try { update("DROP TABLE " + Resource.TABLE); - } catch (SQLException IGNORED) { + } catch (final SQLException IGNORED) { // IGNORED, assuming it was not there } try { update("DROP TABLE " + User.TABLE); - } catch (SQLException IGNORED) { + } catch (final SQLException IGNORED) { // IGNORED, assuming it was not there } } @@ -142,7 +146,7 @@ public class SampleDB { try { Class.forName("org.hsqldb.jdbcDriver").newInstance(); connection = DriverManager.getConnection(DB_URL); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } @@ -156,7 +160,7 @@ public class SampleDB { private void update(String expression) throws SQLException { Statement st = null; st = connection.createStatement(); - int i = st.executeUpdate(expression); + final int i = st.executeUpdate(expression); if (i == -1) { System.out.println("SampleDatabase error : " + expression); } @@ -173,7 +177,7 @@ public class SampleDB { String stmt = null; stmt = CREATE_TABLE_RESOURCE; update(stmt); - } catch (SQLException e) { + } catch (final SQLException e) { if (e.toString().indexOf("Table already exists") == -1) { throw new RuntimeException(e); } @@ -182,7 +186,7 @@ public class SampleDB { String stmt = null; stmt = CREATE_TABLE_USER; update(stmt); - } catch (SQLException e) { + } catch (final SQLException e) { if (e.toString().indexOf("Table already exists") == -1) { throw new RuntimeException(e); } @@ -191,7 +195,7 @@ public class SampleDB { String stmt = null; stmt = CREATE_TABLE_RESERVATION; update(stmt); - } catch (SQLException e) { + } catch (final SQLException e) { if (e.toString().indexOf("Table already exists") == -1) { throw new RuntimeException(e); } @@ -205,15 +209,15 @@ public class SampleDB { private String testDatabase() { String result = null; try { - Statement stmt = connection.createStatement( + final Statement stmt = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); - ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM " + final ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM " + Resource.TABLE); rs.next(); result = "rowcount for table test is " + rs.getObject(1).toString(); stmt.close(); - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } return result; @@ -225,14 +229,14 @@ public class SampleDB { public Container getCategories() { // TODO where deleted=? - String q = "SELECT DISTINCT(" + Resource.PROPERTY_ID_CATEGORY + final String q = "SELECT DISTINCT(" + Resource.PROPERTY_ID_CATEGORY + ") FROM " + Resource.TABLE + " ORDER BY " + Resource.PROPERTY_ID_CATEGORY; try { return new QueryContainer(q, connection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } @@ -251,7 +255,7 @@ public class SampleDB { return new QueryContainer(q, connection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } @@ -266,8 +270,8 @@ public class SampleDB { q += " WHERE " + Reservation.PROPERTY_ID_RESOURCE_ID + "=" + Resource.PROPERTY_ID_ID; if (resources != null && resources.size() > 0) { - StringBuffer s = new StringBuffer(); - for (Iterator it = resources.iterator(); it.hasNext();) { + final StringBuffer s = new StringBuffer(); + for (final Iterator it = resources.iterator(); it.hasNext();) { if (s.length() > 0) { s.append(","); } @@ -279,7 +283,7 @@ public class SampleDB { } q += " ORDER BY " + Reservation.PROPERTY_ID_RESERVED_FROM; try { - QueryContainer qc = new QueryContainer(q, connection, + final QueryContainer qc = new QueryContainer(q, connection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); if (qc.size() < 1) { @@ -287,7 +291,7 @@ public class SampleDB { } else { return qc; } - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } } @@ -295,13 +299,13 @@ public class SampleDB { public void addReservation(Item resource, int reservedById, Date reservedFrom, Date reservedTo, String description) { if (reservedFrom.after(reservedTo)) { - Date tmp = reservedTo; + final Date tmp = reservedTo; reservedTo = reservedFrom; reservedFrom = tmp; } - int resourceId = ((Integer) resource.getItemProperty( + final int resourceId = ((Integer) resource.getItemProperty( Resource.PROPERTY_ID_ID).getValue()).intValue(); - String q = "INSERT INTO " + Reservation.TABLE + " (" + final String q = "INSERT INTO " + Reservation.TABLE + " (" + Reservation.PROPERTY_ID_RESOURCE_ID + "," + Reservation.PROPERTY_ID_RESERVED_BY_ID + "," + Reservation.PROPERTY_ID_RESERVED_FROM + "," @@ -314,7 +318,7 @@ public class SampleDB { throw new ResourceNotAvailableException( "The resource is not available at that time."); } - PreparedStatement p = connection.prepareStatement(q); + final PreparedStatement p = connection.prepareStatement(q); p.setInt(1, resourceId); p.setInt(2, reservedById); p.setTimestamp(3, @@ -322,7 +326,7 @@ public class SampleDB { p.setTimestamp(4, new java.sql.Timestamp(reservedTo.getTime())); p.setString(5, description); p.execute(); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } @@ -332,12 +336,12 @@ public class SampleDB { Date reservedTo) { // TODO where deleted=? if (reservedFrom.after(reservedTo)) { - Date tmp = reservedTo; + final Date tmp = reservedTo; reservedTo = reservedFrom; reservedFrom = tmp; } - String checkQ = "SELECT count(*) FROM " + Reservation.TABLE + " WHERE " - + Reservation.PROPERTY_ID_RESOURCE_ID + "=? AND ((" + final String checkQ = "SELECT count(*) FROM " + Reservation.TABLE + + " WHERE " + Reservation.PROPERTY_ID_RESOURCE_ID + "=? AND ((" + Reservation.PROPERTY_ID_RESERVED_FROM + ">=? AND " + Reservation.PROPERTY_ID_RESERVED_FROM + "? AND " @@ -345,7 +349,7 @@ public class SampleDB { + Reservation.PROPERTY_ID_RESERVED_FROM + "<=? AND " + Reservation.PROPERTY_ID_RESERVED_TO + ">=?)" + ")"; try { - PreparedStatement p = connection.prepareStatement(checkQ); + final PreparedStatement p = connection.prepareStatement(checkQ); p.setInt(1, resourceId); p.setTimestamp(2, new java.sql.Timestamp(reservedFrom.getTime())); p.setTimestamp(3, new java.sql.Timestamp(reservedTo.getTime())); @@ -354,11 +358,11 @@ public class SampleDB { p.setTimestamp(6, new java.sql.Timestamp(reservedFrom.getTime())); p.setTimestamp(7, new java.sql.Timestamp(reservedTo.getTime())); p.execute(); - ResultSet rs = p.getResultSet(); + final ResultSet rs = p.getResultSet(); if (rs.next() && rs.getInt(1) > 0) { return false; } - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } return true; @@ -366,50 +370,52 @@ public class SampleDB { public Container getUsers() { // TODO where deleted=? - String q = "SELECT * FROM " + User.TABLE + " ORDER BY " + final String q = "SELECT * FROM " + User.TABLE + " ORDER BY " + User.PROPERTY_ID_FULLNAME; try { - QueryContainer qc = new QueryContainer(q, connection, + final QueryContainer qc = new QueryContainer(q, connection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); return qc; - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } } public void generateReservations() { - int days = 30; - String descriptions[] = { "Picking up guests from airport", + final int days = 30; + final String descriptions[] = { "Picking up guests from airport", "Sightseeing with the guests", "Moving new servers from A to B", "Shopping", "Customer meeting", "Guests arriving at harbour", "Moving furniture", "Taking guests to see town" }; - Container cat = getCategories(); - Collection cIds = cat.getItemIds(); - for (Iterator it = cIds.iterator(); it.hasNext();) { - Object id = it.next(); - Item ci = cat.getItem(id); - String c = (String) ci.getItemProperty( + final Container cat = getCategories(); + final Collection cIds = cat.getItemIds(); + for (final Iterator it = cIds.iterator(); it.hasNext();) { + final Object id = it.next(); + final Item ci = cat.getItem(id); + final String c = (String) ci.getItemProperty( Resource.PROPERTY_ID_CATEGORY).getValue(); - Container resources = getResources(c); - Collection rIds = resources.getItemIds(); - Calendar cal = Calendar.getInstance(); + final Container resources = getResources(c); + final Collection rIds = resources.getItemIds(); + final Calendar cal = Calendar.getInstance(); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); - int hourNow = new Date().getHours(); + final int hourNow = new Date().getHours(); // cal.add(Calendar.DAY_OF_MONTH, -days); for (int i = 0; i < days; i++) { int r = 3; - for (Iterator rit = rIds.iterator(); rit.hasNext() && r > 0; r--) { - Object rid = rit.next(); - Item resource = resources.getItem(rid); - int s = hourNow - 6 + (int) Math.round(Math.random() * 6.0); - int e = s + 1 + (int) Math.round(Math.random() * 4.0); - Date start = new Date(cal.getTimeInMillis()); + for (final Iterator rit = rIds.iterator(); rit.hasNext() + && r > 0; r--) { + final Object rid = rit.next(); + final Item resource = resources.getItem(rid); + final int s = hourNow - 6 + + (int) Math.round(Math.random() * 6.0); + final int e = s + 1 + (int) Math.round(Math.random() * 4.0); + final Date start = new Date(cal.getTimeInMillis()); start.setHours(s); - Date end = new Date(cal.getTimeInMillis()); + final Date end = new Date(cal.getTimeInMillis()); end.setHours(e); addReservation(resource, 0, start, end, descriptions[(int) Math.floor(Math.random() @@ -423,7 +429,7 @@ public class SampleDB { public void generateResources() { - Object[][] resources = { + final Object[][] resources = { // Turku { "01", "01 Ford Mondeo", "w/ company logo", "Turku", new Double(60.510857), new Double(22.275424) }, @@ -500,7 +506,7 @@ public class SampleDB { }; - String q = "INSERT INTO " + Resource.TABLE + "(" + final String q = "INSERT INTO " + Resource.TABLE + "(" + Resource.PROPERTY_ID_STYLENAME + "," + Resource.PROPERTY_ID_NAME + "," + Resource.PROPERTY_ID_DESCRIPTION + "," @@ -509,7 +515,7 @@ public class SampleDB { + Resource.PROPERTY_ID_LOCATIONY + ")" + " VALUES (?,?,?,?,?,?)"; try { - PreparedStatement stmt = connection.prepareStatement(q); + final PreparedStatement stmt = connection.prepareStatement(q); for (int i = 0; i < resources.length; i++) { int j = 0; stmt.setString(j + 1, (String) resources[i][j++]); @@ -522,22 +528,22 @@ public class SampleDB { .doubleValue()); stmt.execute(); } - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } } public void generateDemoUser() { - String q = "INSERT INTO USER (" + User.PROPERTY_ID_FULLNAME + "," + final String q = "INSERT INTO USER (" + User.PROPERTY_ID_FULLNAME + "," + User.PROPERTY_ID_EMAIL + "," + User.PROPERTY_ID_PASSWORD + ") VALUES (?,?,?)"; try { - PreparedStatement stmt = connection.prepareStatement(q); + final PreparedStatement stmt = connection.prepareStatement(q); stmt.setString(1, "Demo User"); stmt.setString(2, "demo.user@itmill.com"); stmt.setString(3, "demo"); stmt.execute(); - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } diff --git a/src/com/itmill/toolkit/demo/reservation/gwt/client/ReservationWidgetSet.java b/src/com/itmill/toolkit/demo/reservation/gwt/client/ReservationWidgetSet.java index e8333f3ea4..8171a0df23 100644 --- a/src/com/itmill/toolkit/demo/reservation/gwt/client/ReservationWidgetSet.java +++ b/src/com/itmill/toolkit/demo/reservation/gwt/client/ReservationWidgetSet.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation.gwt.client; import com.google.gwt.core.client.GWT; @@ -9,7 +13,7 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL; public class ReservationWidgetSet extends DefaultWidgetSet { public Widget createWidget(UIDL uidl) { - String className = resolveWidgetTypeName(uidl); + final String className = resolveWidgetTypeName(uidl); if ("com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap" .equals(className)) { return new IGoogleMap(); @@ -23,7 +27,7 @@ public class ReservationWidgetSet extends DefaultWidgetSet { protected String resolveWidgetTypeName(UIDL uidl) { - String tag = uidl.getTag(); + final String tag = uidl.getTag(); if ("googlemap".equals(tag)) { return "com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap"; } else if ("calendarfield".equals(tag)) { diff --git a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/ICalendarField.java b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/ICalendarField.java index 735b773849..c6619acca9 100644 --- a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/ICalendarField.java +++ b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/ICalendarField.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation.gwt.client.ui; import java.util.ArrayList; @@ -21,15 +25,15 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IDateField; public class ICalendarField extends IDateField { - private CalendarPanel calPanel; + private final CalendarPanel calPanel; private SimplePanel hourPanel; private FlexTable hourTable; - private EntrySource entrySource; + private final EntrySource entrySource; - private TableListener ftListener = new HourTableListener(); + private final TableListener ftListener = new HourTableListener(); private int realResolution = RESOLUTION_DAY; @@ -57,20 +61,21 @@ public class ICalendarField extends IDateField { realResolution = currentResolution; currentResolution = RESOLUTION_DAY; if (uidl.hasAttribute("min")) { - String mins = uidl.getStringAttribute("min"); - long min = (mins != null ? Long.parseLong(mins) : 0); - String maxs = uidl.getStringAttribute("max"); - long max = (maxs != null ? Long.parseLong(maxs) : 0); - Date minDate = (min > 0 ? new Date(min) : null); - Date maxDate = (max > 0 ? new Date(max) : null); + final String mins = uidl.getStringAttribute("min"); + final long min = (mins != null ? Long.parseLong(mins) : 0); + final String maxs = uidl.getStringAttribute("max"); + final long max = (maxs != null ? Long.parseLong(maxs) : 0); + final Date minDate = (min > 0 ? new Date(min) : null); + final Date maxDate = (max > 0 ? new Date(max) : null); calPanel.setLimits(minDate, maxDate); } entrySource.clear(); - for (Iterator cit = uidl.getChildIterator(); cit.hasNext();) { - UIDL child = (UIDL) cit.next(); + for (final Iterator cit = uidl.getChildIterator(); cit.hasNext();) { + final UIDL child = (UIDL) cit.next(); if (child.getTag().equals("items")) { - for (Iterator iit = child.getChildIterator(); iit.hasNext();) { - UIDL item = (UIDL) iit.next(); + for (final Iterator iit = child.getChildIterator(); iit + .hasNext();) { + final UIDL item = (UIDL) iit.next(); entrySource.addItem(item); } break; @@ -107,7 +112,7 @@ public class ICalendarField extends IDateField { CLASSNAME + "-row-" + style); String hstr = (i < 10 ? "0" : "") + i + ":00"; if (dts.isTwelveHourClock()) { - String ampm = (i < 12 ? "am" : "pm"); + final String ampm = (i < 12 ? "am" : "pm"); hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm; } hourTable.setHTML(i, 0, "" + hstr + ""); @@ -115,11 +120,11 @@ public class ICalendarField extends IDateField { .setStyleName(i, 0, CLASSNAME + "-time"); } - List entries = entrySource.getEntries(date, + final List entries = entrySource.getEntries(date, DateTimeService.RESOLUTION_DAY); int currentCol = 1; - for (Iterator it = entries.iterator(); it.hasNext();) { - CalendarEntry entry = (CalendarEntry) it.next(); + for (final Iterator it = entries.iterator(); it.hasNext();) { + final CalendarEntry entry = (CalendarEntry) it.next(); int start = 0; int hours = 24; if (!entry.isNotime()) { @@ -147,19 +152,19 @@ public class ICalendarField extends IDateField { hourTable.getFlexCellFormatter().setRowSpan(start, col, hours); hourTable.getFlexCellFormatter().setStyleName(start, col, CLASSNAME + "-entry"); - String sn = entry.getStyleName(); + final String sn = entry.getStyleName(); if (sn != null && !sn.equals("")) { hourTable.getFlexCellFormatter().addStyleName(start, col, CLASSNAME + "-" + entry.getStyleName()); } - Element el = hourTable.getFlexCellFormatter() - .getElement(start, col); + final Element el = hourTable.getFlexCellFormatter().getElement( + start, col); String tooltip; if (DateTimeService.isSameDay(entry.getStart(), entry.getEnd())) { tooltip = (start < 10 ? "0" : "") + start + ":00"; if (dts.isTwelveHourClock()) { - String ampm = (start < 12 ? "am" : "pm"); + final String ampm = (start < 12 ? "am" : "pm"); tooltip = (start <= 12 ? start : start - 12) + ":00 " + ampm; @@ -180,20 +185,20 @@ public class ICalendarField extends IDateField { } // int hour = new Date().getHours()+1; // scroll to current hour - int hour = this.date.getHours() + 1; // scroll to selected + final int hour = this.date.getHours() + 1; // scroll to selected // hour - int h1 = hourPanel.getOffsetHeight() / 2; - int oh = hourTable.getOffsetHeight(); - int h2 = (int) (hour / 24.0 * oh); - int scrollTop = h2 - h1; - Element el = hourPanel.getElement(); + final int h1 = hourPanel.getOffsetHeight() / 2; + final int oh = hourTable.getOffsetHeight(); + final int h2 = (int) (hour / 24.0 * oh); + final int scrollTop = h2 - h1; + final Element el = hourPanel.getElement(); setScrollTop(el, scrollTop); } private native void setScrollTop(Element el, int scrollTop) /*-{ - el.scrollTop = scrollTop; - }-*/; + el.scrollTop = scrollTop; + }-*/; private class HourTableListener implements TableListener { @@ -209,36 +214,37 @@ public class ICalendarField extends IDateField { private class EntrySource implements CalendarPanel.CalendarEntrySource { - private HashMap dates = new HashMap(); + private final HashMap dates = new HashMap(); public void addItem(UIDL item) { - String styleName = item.getStringAttribute("styleName"); - Integer id = new Integer(item.getIntAttribute("id")); - long start = Long.parseLong(item.getStringAttribute("start")); - Date startDate = new Date(start); + final String styleName = item.getStringAttribute("styleName"); + final Integer id = new Integer(item.getIntAttribute("id")); + final long start = Long.parseLong(item.getStringAttribute("start")); + final Date startDate = new Date(start); long end = -1; try { end = Long.parseLong(item.getStringAttribute("end")); - } catch (Exception IGNORED) { + } catch (final Exception IGNORED) { // IGNORED attribute not required } - Date endDate = (end > 0 && end != start ? new Date(end) : new Date( - start)); - String title = item.getStringAttribute("title"); - String desc = item.getStringAttribute("description"); - boolean notime = item.getBooleanAttribute("notime"); - CalendarEntry entry = new CalendarEntry(styleName, startDate, + final Date endDate = (end > 0 && end != start ? new Date(end) + : new Date(start)); + final String title = item.getStringAttribute("title"); + final String desc = item.getStringAttribute("description"); + final boolean notime = item.getBooleanAttribute("notime"); + final CalendarEntry entry = new CalendarEntry(styleName, startDate, endDate, title, desc, notime); // TODO should remove+readd if the same entry (id) is // added again - for (Date d = entry.getStart(); d.getYear() <= entry.getEnd() + for (final Date d = entry.getStart(); d.getYear() <= entry.getEnd() .getYear() && d.getMonth() <= entry.getEnd().getYear() && d.getDate() <= entry.getEnd().getDate(); d.setTime(d .getTime() + 86400000)) { - String key = d.getYear() + "" + d.getMonth() + "" + d.getDate(); + final String key = d.getYear() + "" + d.getMonth() + "" + + d.getDate(); ArrayList l = (ArrayList) dates.get(key); if (l == null) { l = new ArrayList(); @@ -249,14 +255,14 @@ public class ICalendarField extends IDateField { } public List getEntries(Date date, int resolution) { - List entries = (List) dates.get(date.getYear() + "" + final List entries = (List) dates.get(date.getYear() + "" + date.getMonth() + "" + date.getDate()); - ArrayList res = new ArrayList(); + final ArrayList res = new ArrayList(); if (entries == null) { return res; } - for (Iterator it = entries.iterator(); it.hasNext();) { - CalendarEntry item = (CalendarEntry) it.next(); + for (final Iterator it = entries.iterator(); it.hasNext();) { + final CalendarEntry item = (CalendarEntry) it.next(); if (DateTimeService.isInRange(date, item.getStart(), item .getEnd(), resolution)) { res.add(item); diff --git a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java index 1517f071a0..8dbdab11b0 100644 --- a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java +++ b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.reservation.gwt.client.ui; import java.util.Iterator; @@ -32,18 +36,18 @@ public class IGoogleMap extends GMap2Widget implements Paintable { public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { map.clearOverlays(); GLatLng pos = null; - for (Iterator it = uidl.getChildIterator(); it.hasNext();) { - UIDL u = (UIDL) it.next(); + for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + final UIDL u = (UIDL) it.next(); if (u.getTag().equals("markers")) { - for (Iterator m = u.getChildIterator(); m.hasNext();) { - UIDL umarker = (UIDL) m.next(); - String html = "" + umarker.getStringAttribute("html") - + ""; - double x = umarker.getDoubleAttribute("x"); - double y = umarker.getDoubleAttribute("y"); + for (final Iterator m = u.getChildIterator(); m.hasNext();) { + final UIDL umarker = (UIDL) m.next(); + final String html = "" + + umarker.getStringAttribute("html") + ""; + final double x = umarker.getDoubleAttribute("x"); + final double y = umarker.getDoubleAttribute("y"); pos = new GLatLng(x, y); - GMarker marker = new GMarker(pos); + final GMarker marker = new GMarker(pos); map.addOverlay(marker); if (html != null) { addMarkerPopup(marker, html); @@ -61,8 +65,9 @@ public class IGoogleMap extends GMap2Widget implements Paintable { map.setZoom(uidl.getIntAttribute("zoom")); } if (uidl.hasAttribute("centerX") && uidl.hasAttribute("centerY")) { - GLatLng center = new GLatLng(uidl.getDoubleAttribute("centerX"), - uidl.getDoubleAttribute("centerY")); + final GLatLng center = new GLatLng(uidl + .getDoubleAttribute("centerX"), uidl + .getDoubleAttribute("centerY")); map.setCenter(center); } else if (pos != null) { // use last marker position diff --git a/src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java b/src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java index 3147c8bed1..4797fdfc60 100644 --- a/src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java +++ b/src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.util; import java.sql.Connection; @@ -68,11 +72,11 @@ public class SampleCalendarDatabase { */ private void connect() { // use memory-Only Database - String url = "jdbc:hsqldb:mem:toolkit"; + final String url = "jdbc:hsqldb:mem:toolkit"; try { Class.forName("org.hsqldb.jdbcDriver").newInstance(); connection = DriverManager.getConnection(url, "sa", ""); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } @@ -86,7 +90,7 @@ public class SampleCalendarDatabase { public void update(String expression) throws SQLException { Statement st = null; st = connection.createStatement(); - int i = st.executeUpdate(expression); + final int i = st.executeUpdate(expression); if (i == -1) { System.out.println("SampleDatabase error : " + expression); } @@ -107,14 +111,15 @@ public class SampleCalendarDatabase { + "EVENTSTART DATETIME, EVENTEND DATETIME, NOTIME BOOLEAN )"; update(stmt); for (int j = 0; j < ENTRYCOUNT; j++) { - Timestamp start = new Timestamp(new java.util.Date().getTime()); + final Timestamp start = new Timestamp(new java.util.Date() + .getTime()); start.setDate((int) ((Math.random() - 0.4) * 200)); start.setMinutes(0); start.setHours(8 + (int) Math.random() * 12); - Timestamp end = new Timestamp(start.getTime()); + final Timestamp end = new Timestamp(start.getTime()); if (Math.random() < 0.7) { long t = end.getTime(); - long hour = 60 * 60 * 1000; + final long hour = 60 * 60 * 1000; t = t + hour + (Math.round(Math.random() * 3 * hour)); end.setTime(t); } @@ -128,7 +133,7 @@ public class SampleCalendarDatabase { + "','" + end + "'," + (Math.random() > 0.7) + ")"; update(stmt); } - } catch (SQLException e) { + } catch (final SQLException e) { if (e.toString().indexOf("Table already exists") == -1) { throw new RuntimeException(e); } @@ -142,15 +147,15 @@ public class SampleCalendarDatabase { private String testDatabase() { String result = null; try { - Statement stmt = connection.createStatement( + final Statement stmt = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); - ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM " + final ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM " + DB_TABLE_NAME); rs.next(); result = "rowcount for table test is " + rs.getObject(1).toString(); stmt.close(); - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } return result; diff --git a/src/com/itmill/toolkit/demo/util/SampleDatabase.java b/src/com/itmill/toolkit/demo/util/SampleDatabase.java index 6c6d555667..7bdebb2502 100644 --- a/src/com/itmill/toolkit/demo/util/SampleDatabase.java +++ b/src/com/itmill/toolkit/demo/util/SampleDatabase.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.util; import java.sql.Connection; @@ -82,11 +86,11 @@ public class SampleDatabase { */ private void connect() { // use memory-Only Database - String url = "jdbc:hsqldb:mem:toolkit"; + final String url = "jdbc:hsqldb:mem:toolkit"; try { Class.forName("org.hsqldb.jdbcDriver").newInstance(); connection = DriverManager.getConnection(url, "sa", ""); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } @@ -100,7 +104,7 @@ public class SampleDatabase { public void update(String expression) throws SQLException { Statement st = null; st = connection.createStatement(); - int i = st.executeUpdate(expression); + final int i = st.executeUpdate(expression); if (i == -1) { throw new SQLException("Database error : " + expression); } @@ -134,7 +138,7 @@ public class SampleDatabase { + "'" + ")"; update(stmt); } - } catch (SQLException e) { + } catch (final SQLException e) { if (e.toString().indexOf("Table already exists") == -1) { throw new RuntimeException(e); } @@ -148,14 +152,15 @@ public class SampleDatabase { private String testDatabase() { String result = null; try { - Statement stmt = connection.createStatement( + final Statement stmt = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); - ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM employee"); + final ResultSet rs = stmt + .executeQuery("SELECT COUNT(*) FROM employee"); rs.next(); result = "rowcount for table test is " + rs.getObject(1).toString(); stmt.close(); - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e); } return result; diff --git a/src/com/itmill/toolkit/demo/util/SampleDirectory.java b/src/com/itmill/toolkit/demo/util/SampleDirectory.java index 15cdf87dad..2c90f18d3f 100644 --- a/src/com/itmill/toolkit/demo/util/SampleDirectory.java +++ b/src/com/itmill/toolkit/demo/util/SampleDirectory.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.demo.util; import java.io.File; @@ -55,7 +59,7 @@ public class SampleDirectory { return file; } // Add failure notification as an Panel to main window - Panel errorPanel = new Panel("Demo application error"); + final Panel errorPanel = new Panel("Demo application error"); errorPanel.setStyle("strong"); errorPanel.setComponentError(new SystemError( "Cannot provide sample directory")); diff --git a/src/com/itmill/toolkit/event/Action.java b/src/com/itmill/toolkit/event/Action.java index f2551f2b7b..6e80e504b6 100644 --- a/src/com/itmill/toolkit/event/Action.java +++ b/src/com/itmill/toolkit/event/Action.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.event; diff --git a/src/com/itmill/toolkit/event/EventRouter.java b/src/com/itmill/toolkit/event/EventRouter.java index a71a3e1874..c6f04c51ad 100644 --- a/src/com/itmill/toolkit/event/EventRouter.java +++ b/src/com/itmill/toolkit/event/EventRouter.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.event; @@ -86,14 +62,14 @@ public class EventRouter implements MethodEventSource { public void removeListener(Class eventType, Object target) { if (listenerList != null) { - Iterator i = listenerList.iterator(); + final Iterator i = listenerList.iterator(); while (i.hasNext()) { try { - ListenerMethod lm = (ListenerMethod) i.next(); + final ListenerMethod lm = (ListenerMethod) i.next(); if (lm.matches(eventType, target)) { i.remove(); } - } catch (java.lang.ClassCastException e) { + } catch (final java.lang.ClassCastException e) { // Class cast exceptions are ignored } } @@ -108,14 +84,14 @@ public class EventRouter implements MethodEventSource { public void removeListener(Class eventType, Object target, Method method) { if (listenerList != null) { - Iterator i = listenerList.iterator(); + final Iterator i = listenerList.iterator(); while (i.hasNext()) { try { - ListenerMethod lm = (ListenerMethod) i.next(); + final ListenerMethod lm = (ListenerMethod) i.next(); if (lm.matches(eventType, target, method)) { i.remove(); } - } catch (java.lang.ClassCastException e) { + } catch (final java.lang.ClassCastException e) { // Class cast exceptions are ignored } } @@ -130,7 +106,7 @@ public class EventRouter implements MethodEventSource { public void removeListener(Class eventType, Object target, String methodName) { // Find the correct method - Method[] methods = target.getClass().getMethods(); + final Method[] methods = target.getClass().getMethods(); Method method = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(methodName)) { @@ -143,14 +119,14 @@ public class EventRouter implements MethodEventSource { // Remove the listeners if (listenerList != null) { - Iterator i = listenerList.iterator(); + final Iterator i = listenerList.iterator(); while (i.hasNext()) { try { - ListenerMethod lm = (ListenerMethod) i.next(); + final ListenerMethod lm = (ListenerMethod) i.next(); if (lm.matches(eventType, target, method)) { i.remove(); } - } catch (java.lang.ClassCastException e) { + } catch (final java.lang.ClassCastException e) { // Class cast exceptions are ignored } } @@ -178,7 +154,7 @@ public class EventRouter implements MethodEventSource { // Send the event to all listeners. The listeners themselves // will filter out unwanted events. - Iterator i = new LinkedList(listenerList).iterator(); + final Iterator i = new LinkedList(listenerList).iterator(); while (i.hasNext()) { ((ListenerMethod) i.next()).receiveEvent(event); } diff --git a/src/com/itmill/toolkit/event/ListenerMethod.java b/src/com/itmill/toolkit/event/ListenerMethod.java index 07c9866e37..0b0d51cf58 100644 --- a/src/com/itmill/toolkit/event/ListenerMethod.java +++ b/src/com/itmill/toolkit/event/ListenerMethod.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.event; @@ -64,18 +40,18 @@ public class ListenerMethod implements EventListener { * Type of the event that should trigger this listener. Also the subclasses * of this class are accepted to trigger the listener. */ - private Class eventType; + private final Class eventType; /** * The object containing the trigger method. */ - private Object object; + private final Object object; /** * The trigger method to call when an event passing the given criteria * fires. */ - private Method method; + private final Method method; /** * Optional argument set to pass to the trigger method. @@ -189,7 +165,7 @@ public class ListenerMethod implements EventListener { throws java.lang.IllegalArgumentException { // Finds the correct method - Method[] methods = object.getClass().getMethods(); + final Method[] methods = object.getClass().getMethods(); Method method = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(methodName)) { @@ -296,7 +272,7 @@ public class ListenerMethod implements EventListener { Object[] arguments) throws java.lang.IllegalArgumentException { // Find the correct method - Method[] methods = object.getClass().getMethods(); + final Method[] methods = object.getClass().getMethods(); Method method = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(methodName)) { @@ -351,7 +327,7 @@ public class ListenerMethod implements EventListener { this.method = method; eventArgumentIndex = -1; - Class[] params = method.getParameterTypes(); + final Class[] params = method.getParameterTypes(); if (params.length == 0) { arguments = new Object[0]; @@ -395,7 +371,7 @@ public class ListenerMethod implements EventListener { throws java.lang.IllegalArgumentException { // Finds the correct method - Method[] methods = object.getClass().getMethods(); + final Method[] methods = object.getClass().getMethods(); Method method = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(methodName)) { @@ -411,7 +387,7 @@ public class ListenerMethod implements EventListener { this.method = method; eventArgumentIndex = -1; - Class[] params = method.getParameterTypes(); + final Class[] params = method.getParameterTypes(); if (params.length == 0) { arguments = new Object[0]; @@ -443,7 +419,7 @@ public class ListenerMethod implements EventListener { if (eventArgumentIndex == 0 && arguments.length == 1) { method.invoke(object, new Object[] { event }); } else { - Object[] arg = new Object[arguments.length]; + final Object[] arg = new Object[arguments.length]; for (int i = 0; i < arg.length; i++) { arg[i] = arguments[i]; } @@ -454,11 +430,11 @@ public class ListenerMethod implements EventListener { method.invoke(object, arguments); } - } catch (java.lang.IllegalAccessException e) { + } catch (final java.lang.IllegalAccessException e) { // This should never happen throw new java.lang.RuntimeException( "Internal error - please report: " + e.toString()); - } catch (java.lang.reflect.InvocationTargetException e) { + } catch (final java.lang.reflect.InvocationTargetException e) { // This should never happen throw new MethodException("Invocation if method " + method + " failed.", e.getTargetException()); @@ -526,7 +502,7 @@ public class ListenerMethod implements EventListener { */ private static final long serialVersionUID = 3257005445242894135L; - private Throwable cause; + private final Throwable cause; private String message; diff --git a/src/com/itmill/toolkit/event/MethodEventSource.java b/src/com/itmill/toolkit/event/MethodEventSource.java index 8e80ea604e..9718bfcd68 100644 --- a/src/com/itmill/toolkit/event/MethodEventSource.java +++ b/src/com/itmill/toolkit/event/MethodEventSource.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.event; diff --git a/src/com/itmill/toolkit/event/ShortcutAction.java b/src/com/itmill/toolkit/event/ShortcutAction.java index da03d86764..4b4cca83b5 100644 --- a/src/com/itmill/toolkit/event/ShortcutAction.java +++ b/src/com/itmill/toolkit/event/ShortcutAction.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.event; import com.itmill.toolkit.terminal.Resource; @@ -11,9 +15,9 @@ import com.itmill.toolkit.terminal.Resource; */ public class ShortcutAction extends Action { - private int keyCode; + private final int keyCode; - private int[] modifiers; + private final int[] modifiers; public ShortcutAction(String caption, int kc, int[] m) { super(caption); diff --git a/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java b/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java index 6bc8b50b18..5641975d4a 100644 --- a/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java +++ b/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.launcher; import java.awt.FlowLayout; @@ -31,12 +35,12 @@ public class ITMillToolkitDesktopMode { public static void main(String[] args) { - Map serverArgs = ITMillToolkitWebMode.parseArguments(args); + final Map serverArgs = ITMillToolkitWebMode.parseArguments(args); boolean deployed = false; try { // Default deployment: embedded.war deployed = deployEmbeddedWarfile(serverArgs); - } catch (IOException e1) { + } catch (final IOException e1) { e1.printStackTrace(); deployed = false; } @@ -55,7 +59,8 @@ public class ITMillToolkitDesktopMode { } // Start the Winstone servlet container - String url = ITMillToolkitWebMode.runServer(serverArgs, "Desktop Mode"); + final String url = ITMillToolkitWebMode.runServer(serverArgs, + "Desktop Mode"); // Open browser into application URL if (url != null) { @@ -106,7 +111,7 @@ public class ITMillToolkitDesktopMode { final JButton cancelButton = new JButton("Cancel"); // List for close verify buttons - ActionListener buttonListener = new ActionListener() { + final ActionListener buttonListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() == okButton) { System.exit(0); @@ -127,7 +132,7 @@ public class ITMillToolkitDesktopMode { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - Rectangle bounds = frame.getBounds(); + final Rectangle bounds = frame.getBounds(); frame.setTitle("Confirm close"); contentPane.removeAll(); contentPane.add(question); @@ -140,11 +145,11 @@ public class ITMillToolkitDesktopMode { }); // Position the window nicely - java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit() - .getScreenSize(); - int w = 270; - int h = 95; - int margin = 20; + final java.awt.Dimension screenSize = java.awt.Toolkit + .getDefaultToolkit().getScreenSize(); + final int w = 270; + final int h = 95; + final int margin = 20; frame.setBounds(new Rectangle(screenSize.width - w - margin, screenSize.height - h - margin * 2, w, h)); frame.toFront(); @@ -159,23 +164,23 @@ public class ITMillToolkitDesktopMode { * @throws IOException */ protected static boolean deployEmbeddedWarfile(Map args) throws IOException { - String embeddedWarfileName = "/embedded.war"; - InputStream embeddedWarfile = ITMillToolkitDesktopMode.class + final String embeddedWarfileName = "/embedded.war"; + final InputStream embeddedWarfile = ITMillToolkitDesktopMode.class .getResourceAsStream(embeddedWarfileName); if (embeddedWarfile != null) { - File tempWarfile = File.createTempFile("embedded", ".war") + final File tempWarfile = File.createTempFile("embedded", ".war") .getAbsoluteFile(); tempWarfile.getParentFile().mkdirs(); tempWarfile.deleteOnExit(); - String embeddedWebroot = "winstoneEmbeddedWAR"; - File tempWebroot = new File(tempWarfile.getParentFile(), + final String embeddedWebroot = "winstoneEmbeddedWAR"; + final File tempWebroot = new File(tempWarfile.getParentFile(), embeddedWebroot); tempWebroot.mkdirs(); - OutputStream out = new FileOutputStream(tempWarfile, true); + final OutputStream out = new FileOutputStream(tempWarfile, true); int read = 0; - byte buffer[] = new byte[2048]; + final byte buffer[] = new byte[2048]; while ((read = embeddedWarfile.read(buffer)) != -1) { out.write(buffer, 0, read); } diff --git a/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java b/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java index 206174b3d5..02a9f9305d 100644 --- a/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java +++ b/src/com/itmill/toolkit/launcher/ITMillToolkitWebMode.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.launcher; import java.util.HashMap; @@ -29,11 +33,11 @@ public class ITMillToolkitWebMode { public static void main(String[] args) { // Pass-through of arguments for Jetty - Map serverArgs = parseArguments(args); + final Map serverArgs = parseArguments(args); // Start Jetty System.out.println("Starting Jetty servlet container."); - String url = runServer(serverArgs, "Web Mode"); + final String url = runServer(serverArgs, "Web Mode"); // Start Browser System.out.println("Starting Web Browser."); @@ -66,9 +70,9 @@ public class ITMillToolkitWebMode { assignDefault(serverArgs, "httpPort", serverPort); try { - long started = System.currentTimeMillis(); + final long started = System.currentTimeMillis(); - Server server = new Server(); + final Server server = new Server(); // String threadPoolName = // System.getProperty("jetty.threadpool.name", @@ -91,14 +95,14 @@ public class ITMillToolkitWebMode { // threadPool.setLowThreads(lowThreads); // server.setThreadPool(threadPool); - Connector connector = new SelectChannelConnector(); + final Connector connector = new SelectChannelConnector(); // FIXME httpPort hardcoded to 8888 // connector.setPort(Integer.valueOf(serverArgs.get("httpPort") // .toString())); connector.setPort(8888); server.setConnectors(new Connector[] { connector }); - WebAppContext webappcontext = new WebAppContext(); + final WebAppContext webappcontext = new WebAppContext(); webappcontext.setContextPath(""); webappcontext.setWar(serverArgs.get("webroot").toString()); // enable hot code replace @@ -109,7 +113,7 @@ public class ITMillToolkitWebMode { server.start(); // System.err.println("Started Jetty in " // + (System.currentTimeMillis() - started) + "ms."); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); return null; } @@ -139,12 +143,12 @@ public class ITMillToolkitWebMode { * @return map of arguments key value pairs. */ protected static Map parseArguments(String[] args) { - Map map = new HashMap(); + final Map map = new HashMap(); for (int i = 0; i < args.length; i++) { - int d = args[i].indexOf("="); + final int d = args[i].indexOf("="); if (d > 0 && d < args[i].length() && args[i].startsWith("--")) { - String name = args[i].substring(2, d); - String value = args[i].substring(d + 1); + final String name = args[i].substring(2, d); + final String value = args[i].substring(d + 1); map.put(name, value); } } diff --git a/src/com/itmill/toolkit/launcher/util/BrowserLauncher.java b/src/com/itmill/toolkit/launcher/util/BrowserLauncher.java index 86c48556a5..135ce79b71 100644 --- a/src/com/itmill/toolkit/launcher/util/BrowserLauncher.java +++ b/src/com/itmill/toolkit/launcher/util/BrowserLauncher.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.launcher.util; import java.io.IOException; @@ -16,10 +20,11 @@ public class BrowserLauncher { */ public static void openBrowser(String url) { - Runtime runtime = Runtime.getRuntime(); + final Runtime runtime = Runtime.getRuntime(); boolean started = false; - String os = System.getProperty("os.name", "windows").toLowerCase(); + final String os = System.getProperty("os.name", "windows") + .toLowerCase(); // Linux if (os.indexOf("linux") >= 0) { @@ -29,7 +34,7 @@ public class BrowserLauncher { try { runtime.exec("x-www-browser " + url); started = true; - } catch (IOException e) { + } catch (final IOException e) { } } @@ -38,7 +43,7 @@ public class BrowserLauncher { try { runtime.exec("firefox " + url); started = true; - } catch (IOException e) { + } catch (final IOException e) { } } @@ -47,7 +52,7 @@ public class BrowserLauncher { try { runtime.exec("mozilla " + url); started = true; - } catch (IOException e) { + } catch (final IOException e) { } } @@ -56,7 +61,7 @@ public class BrowserLauncher { try { runtime.exec("konqueror " + url); started = true; - } catch (IOException e) { + } catch (final IOException e) { } } } @@ -69,7 +74,7 @@ public class BrowserLauncher { try { runtime.exec("open " + url); started = true; - } catch (IOException e) { + } catch (final IOException e) { } } } @@ -80,7 +85,7 @@ public class BrowserLauncher { try { runtime.exec("cmd /c start " + url); started = true; - } catch (IOException e) { + } catch (final IOException e) { } } } diff --git a/src/com/itmill/toolkit/service/ApplicationContext.java b/src/com/itmill/toolkit/service/ApplicationContext.java index 7c092c484d..fea221416d 100644 --- a/src/com/itmill/toolkit/service/ApplicationContext.java +++ b/src/com/itmill/toolkit/service/ApplicationContext.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.service; diff --git a/src/com/itmill/toolkit/service/FileTypeResolver.java b/src/com/itmill/toolkit/service/FileTypeResolver.java index 7bdadc8b05..79aadf899f 100644 --- a/src/com/itmill/toolkit/service/FileTypeResolver.java +++ b/src/com/itmill/toolkit/service/FileTypeResolver.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.service; @@ -226,13 +202,14 @@ public class FileTypeResolver { static { // Initialize extension to MIME map - StringTokenizer lines = new StringTokenizer(initialExtToMIMEMap, ","); + final StringTokenizer lines = new StringTokenizer(initialExtToMIMEMap, + ","); while (lines.hasMoreTokens()) { - String line = lines.nextToken(); - StringTokenizer exts = new StringTokenizer(line); - String type = exts.nextToken(); + final String line = lines.nextToken(); + final StringTokenizer exts = new StringTokenizer(line); + final String type = exts.nextToken(); while (exts.hasMoreTokens()) { - String ext = exts.nextToken(); + final String ext = exts.nextToken(); addExtension(ext, type); } } @@ -265,10 +242,10 @@ public class FileTypeResolver { dotIndex++; if (fileName.length() > dotIndex) { - String ext = fileName.substring(dotIndex); + final String ext = fileName.substring(dotIndex); // Return type from extension map, if found - String type = (String) extToMIMEMap.get(ext); + final String type = (String) extToMIMEMap.get(ext); if (type != null) { return type; } @@ -289,8 +266,8 @@ public class FileTypeResolver { */ public static Resource getIcon(String fileName) { - String mimeType = getMIMEType(fileName); - Resource icon = (Resource) MIMEToIconMap.get(mimeType); + final String mimeType = getMIMEType(fileName); + final Resource icon = (Resource) MIMEToIconMap.get(mimeType); if (icon != null) { return icon; } @@ -312,8 +289,8 @@ public class FileTypeResolver { */ public static Resource getIcon(File file) { - String mimeType = getMIMEType(file); - Resource icon = (Resource) MIMEToIconMap.get(mimeType); + final String mimeType = getMIMEType(file); + final Resource icon = (Resource) MIMEToIconMap.get(mimeType); if (icon != null) { return icon; } diff --git a/src/com/itmill/toolkit/terminal/ApplicationResource.java b/src/com/itmill/toolkit/terminal/ApplicationResource.java index 17093f8907..94f3a21a2e 100644 --- a/src/com/itmill/toolkit/terminal/ApplicationResource.java +++ b/src/com/itmill/toolkit/terminal/ApplicationResource.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/ClassResource.java b/src/com/itmill/toolkit/terminal/ClassResource.java index afb596f5c3..cd8498bc1d 100644 --- a/src/com/itmill/toolkit/terminal/ClassResource.java +++ b/src/com/itmill/toolkit/terminal/ClassResource.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; @@ -59,17 +35,17 @@ public class ClassResource implements ApplicationResource { /** * Associated class used for indetifying the source of the resource. */ - private Class associatedClass; + private final Class associatedClass; /** * Name of the resource is relative to the associated class. */ - private String resourceName; + private final String resourceName; /** * Application used for serving the class. */ - private Application application; + private final Application application; /** * Creates a new application resource instance. The resource id is relative @@ -153,7 +129,7 @@ public class ClassResource implements ApplicationResource { * @see com.itmill.toolkit.terminal.ApplicationResource#getStream() */ public DownloadStream getStream() { - DownloadStream ds = new DownloadStream(associatedClass + final DownloadStream ds = new DownloadStream(associatedClass .getResourceAsStream(resourceName), getMIMEType(), getFilename()); ds.setBufferSize(getBufferSize()); diff --git a/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java b/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java index 8916e6291b..ba3616466c 100644 --- a/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java +++ b/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; @@ -46,7 +22,7 @@ public class CompositeErrorMessage implements ErrorMessage { /** * Array of all the errors. */ - private List errors; + private final List errors; /** * Level of the error. @@ -86,7 +62,7 @@ public class CompositeErrorMessage implements ErrorMessage { errors = new ArrayList(errorMessages.size()); level = Integer.MIN_VALUE; - for (Iterator i = errorMessages.iterator(); i.hasNext();) { + for (final Iterator i = errorMessages.iterator(); i.hasNext();) { addErrorMessage((ErrorMessage) i.next()); } @@ -116,7 +92,7 @@ public class CompositeErrorMessage implements ErrorMessage { private void addErrorMessage(ErrorMessage error) { if (error != null && !errors.contains(error)) { errors.add(error); - int l = error.getErrorLevel(); + final int l = error.getErrorLevel(); if (l > level) { level = l; } @@ -155,7 +131,7 @@ public class CompositeErrorMessage implements ErrorMessage { } // Paint all the exceptions - for (Iterator i = errors.iterator(); i.hasNext();) { + for (final Iterator i = errors.iterator(); i.hasNext();) { ((ErrorMessage) i.next()).paint(target); } @@ -187,7 +163,7 @@ public class CompositeErrorMessage implements ErrorMessage { public String toString() { String retval = "["; int pos = 0; - for (Iterator i = errors.iterator(); i.hasNext();) { + for (final Iterator i = errors.iterator(); i.hasNext();) { if (pos > 0) { retval += ","; } diff --git a/src/com/itmill/toolkit/terminal/DownloadStream.java b/src/com/itmill/toolkit/terminal/DownloadStream.java index 4ec51c848d..e8eaef8f5f 100644 --- a/src/com/itmill/toolkit/terminal/DownloadStream.java +++ b/src/com/itmill/toolkit/terminal/DownloadStream.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/ErrorMessage.java b/src/com/itmill/toolkit/terminal/ErrorMessage.java index 4153ca220a..8c3a256dab 100644 --- a/src/com/itmill/toolkit/terminal/ErrorMessage.java +++ b/src/com/itmill/toolkit/terminal/ErrorMessage.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/ExternalResource.java b/src/com/itmill/toolkit/terminal/ExternalResource.java index 005e97217b..356d3f14a1 100644 --- a/src/com/itmill/toolkit/terminal/ExternalResource.java +++ b/src/com/itmill/toolkit/terminal/ExternalResource.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/FileResource.java b/src/com/itmill/toolkit/terminal/FileResource.java index 800e63582b..eaa7061caa 100644 --- a/src/com/itmill/toolkit/terminal/FileResource.java +++ b/src/com/itmill/toolkit/terminal/FileResource.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; @@ -61,7 +37,7 @@ public class FileResource implements ApplicationResource { /** * Application. */ - private Application application; + private final Application application; /** * Default cache time for this stream resource. @@ -85,11 +61,11 @@ public class FileResource implements ApplicationResource { */ public DownloadStream getStream() { try { - DownloadStream ds = new DownloadStream(new FileInputStream( + final DownloadStream ds = new DownloadStream(new FileInputStream( sourceFile), getMIMEType(), getFilename()); ds.setCacheTime(cacheTime); return ds; - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { // No logging for non-existing files at this level. return null; } diff --git a/src/com/itmill/toolkit/terminal/KeyMapper.java b/src/com/itmill/toolkit/terminal/KeyMapper.java index 16460de64c..0617f0ba76 100644 --- a/src/com/itmill/toolkit/terminal/KeyMapper.java +++ b/src/com/itmill/toolkit/terminal/KeyMapper.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; @@ -43,9 +19,9 @@ public class KeyMapper { private int lastKey = 0; - private Hashtable objectKeyMap = new Hashtable(); + private final Hashtable objectKeyMap = new Hashtable(); - private Hashtable keyObjectMap = new Hashtable(); + private final Hashtable keyObjectMap = new Hashtable(); /** * Gets key for an object. @@ -107,7 +83,7 @@ public class KeyMapper { * the object to be removed. */ public void remove(Object removeobj) { - String key = (String) objectKeyMap.get(removeobj); + final String key = (String) objectKeyMap.get(removeobj); if (key != null) { objectKeyMap.remove(key); diff --git a/src/com/itmill/toolkit/terminal/PaintException.java b/src/com/itmill/toolkit/terminal/PaintException.java index 2830e762a5..1c0287e026 100644 --- a/src/com/itmill/toolkit/terminal/PaintException.java +++ b/src/com/itmill/toolkit/terminal/PaintException.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/PaintTarget.java b/src/com/itmill/toolkit/terminal/PaintTarget.java index e7760c9e7f..f2a29401ad 100644 --- a/src/com/itmill/toolkit/terminal/PaintTarget.java +++ b/src/com/itmill/toolkit/terminal/PaintTarget.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/Paintable.java b/src/com/itmill/toolkit/terminal/Paintable.java index 3c89923632..aad66cdaf2 100644 --- a/src/com/itmill/toolkit/terminal/Paintable.java +++ b/src/com/itmill/toolkit/terminal/Paintable.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/ParameterHandler.java b/src/com/itmill/toolkit/terminal/ParameterHandler.java index 8d8ab0ca17..fb8c86ec72 100644 --- a/src/com/itmill/toolkit/terminal/ParameterHandler.java +++ b/src/com/itmill/toolkit/terminal/ParameterHandler.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/Resource.java b/src/com/itmill/toolkit/terminal/Resource.java index 8dc86e2d86..5cf07729aa 100644 --- a/src/com/itmill/toolkit/terminal/Resource.java +++ b/src/com/itmill/toolkit/terminal/Resource.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/Scrollable.java b/src/com/itmill/toolkit/terminal/Scrollable.java index f320a4d2a8..a874d2fd1b 100644 --- a/src/com/itmill/toolkit/terminal/Scrollable.java +++ b/src/com/itmill/toolkit/terminal/Scrollable.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/Sizeable.java b/src/com/itmill/toolkit/terminal/Sizeable.java index decacf3fa4..649be802f8 100644 --- a/src/com/itmill/toolkit/terminal/Sizeable.java +++ b/src/com/itmill/toolkit/terminal/Sizeable.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2007 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/StreamResource.java b/src/com/itmill/toolkit/terminal/StreamResource.java index 523741089d..08a39f41cd 100644 --- a/src/com/itmill/toolkit/terminal/StreamResource.java +++ b/src/com/itmill/toolkit/terminal/StreamResource.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; @@ -64,7 +40,7 @@ public class StreamResource implements ApplicationResource { /** * Application. */ - private Application application; + private final Application application; /** * Default buffer size for this stream resource. @@ -170,12 +146,12 @@ public class StreamResource implements ApplicationResource { * @see com.itmill.toolkit.terminal.ApplicationResource#getStream() */ public DownloadStream getStream() { - StreamSource ss = getStreamSource(); + final StreamSource ss = getStreamSource(); if (ss == null) { return null; } - DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), - getFilename()); + final DownloadStream ds = new DownloadStream(ss.getStream(), + getMIMEType(), getFilename()); ds.setBufferSize(getBufferSize()); ds.setCacheTime(cacheTime); return ds; diff --git a/src/com/itmill/toolkit/terminal/SystemError.java b/src/com/itmill/toolkit/terminal/SystemError.java index 0fbace4337..f5f3623ef5 100644 --- a/src/com/itmill/toolkit/terminal/SystemError.java +++ b/src/com/itmill/toolkit/terminal/SystemError.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; @@ -104,7 +80,7 @@ public class SystemError extends RuntimeException implements ErrorMessage { target.addAttribute("level", "system"); // Paint the error message - String message = getLocalizedMessage(); + final String message = getLocalizedMessage(); if (message != null) { target.addSection("h2", message); } @@ -112,7 +88,7 @@ public class SystemError extends RuntimeException implements ErrorMessage { // Paint the exception if (cause != null) { target.addSection("h3", "Exception"); - StringWriter buffer = new StringWriter(); + final StringWriter buffer = new StringWriter(); cause.printStackTrace(new PrintWriter(buffer)); target.addSection("pre", buffer.toString()); } diff --git a/src/com/itmill/toolkit/terminal/Terminal.java b/src/com/itmill/toolkit/terminal/Terminal.java index a31e31c6db..573130dee4 100644 --- a/src/com/itmill/toolkit/terminal/Terminal.java +++ b/src/com/itmill/toolkit/terminal/Terminal.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/ThemeResource.java b/src/com/itmill/toolkit/terminal/ThemeResource.java index c8f80ba56a..1b9995dc7c 100644 --- a/src/com/itmill/toolkit/terminal/ThemeResource.java +++ b/src/com/itmill/toolkit/terminal/ThemeResource.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/URIHandler.java b/src/com/itmill/toolkit/terminal/URIHandler.java index 5b4bf67d58..ef1fc76e06 100644 --- a/src/com/itmill/toolkit/terminal/URIHandler.java +++ b/src/com/itmill/toolkit/terminal/URIHandler.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/UploadStream.java b/src/com/itmill/toolkit/terminal/UploadStream.java index b0a9cf85c9..b15bb1db15 100644 --- a/src/com/itmill/toolkit/terminal/UploadStream.java +++ b/src/com/itmill/toolkit/terminal/UploadStream.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/UserError.java b/src/com/itmill/toolkit/terminal/UserError.java index 6915f07378..8d13b3c155 100644 --- a/src/com/itmill/toolkit/terminal/UserError.java +++ b/src/com/itmill/toolkit/terminal/UserError.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; @@ -63,7 +39,7 @@ public class UserError implements ErrorMessage { /** * Message in content mode. */ - private String msg; + private final String msg; /** * Error level. diff --git a/src/com/itmill/toolkit/terminal/VariableOwner.java b/src/com/itmill/toolkit/terminal/VariableOwner.java index 93bdb7d780..b14c83d1ef 100644 --- a/src/com/itmill/toolkit/terminal/VariableOwner.java +++ b/src/com/itmill/toolkit/terminal/VariableOwner.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java index 54f5885b37..f7e72d1362 100755 --- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import java.util.Date; @@ -30,17 +34,17 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IView; */ public class ApplicationConnection { - private String appUri; + private final String appUri; - private HashMap resourcesMap = new HashMap(); + private final HashMap resourcesMap = new HashMap(); private static Console console; - private Vector pendingVariables = new Vector(); + private final Vector pendingVariables = new Vector(); - private HashMap idToPaintable = new HashMap(); + private final HashMap idToPaintable = new HashMap(); - private HashMap paintableToId = new HashMap(); + private final HashMap paintableToId = new HashMap(); private final WidgetSet widgetSet; @@ -49,7 +53,7 @@ public class ApplicationConnection { private Timer loadTimer; private Element loadElement; - private IView view; + private final IView view; public ApplicationConnection(WidgetSet widgetSet) { this.widgetSet = widgetSet; @@ -108,8 +112,8 @@ public class ApplicationConnection { showLoadingIndicator(); console.log("Making UIDL Request with params: " + requestData); - String uri = appUri + "/UIDL" + getPathInfo(); - RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri); + final String uri = appUri + "/UIDL" + getPathInfo(); + final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri); rb.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); try { @@ -126,7 +130,7 @@ public class ApplicationConnection { }); - } catch (RequestException e) { + } catch (final RequestException e) { // TODO Better reporting to user console.error(e.getMessage()); } @@ -156,7 +160,7 @@ public class ApplicationConnection { + "px"); // Initialize other timers - Timer delay = new Timer() { + final Timer delay = new Timer() { public void run() { DOM.setElementProperty(loadElement, "className", "i-loading-indicator-delay"); @@ -165,7 +169,7 @@ public class ApplicationConnection { // Second one kicks in at 1500ms delay.schedule(1200); - Timer wait = new Timer() { + final Timer wait = new Timer() { public void run() { DOM.setElementProperty(loadElement, "className", "i-loading-indicator-wait"); @@ -191,20 +195,21 @@ public class ApplicationConnection { private void handleReceivedJSONMessage(Response response) { hideLoadingIndicator(); - Date start = new Date(); - String jsonText = response.getText().substring(3) + "}"; + final Date start = new Date(); + final String jsonText = response.getText().substring(3) + "}"; JSONValue json; try { json = JSONParser.parse(jsonText); - } catch (com.google.gwt.json.client.JSONException e) { + } catch (final com.google.gwt.json.client.JSONException e) { console.log(e.getMessage() + " - Original JSON-text:"); console.log(jsonText); return; } // Handle redirect - JSONObject redirect = (JSONObject) ((JSONObject) json).get("redirect"); + final JSONObject redirect = (JSONObject) ((JSONObject) json) + .get("redirect"); if (redirect != null) { - JSONString url = (JSONString) redirect.get("url"); + final JSONString url = (JSONString) redirect.get("url"); if (url != null) { console.log("redirecting to " + url.stringValue()); redirect(url.stringValue()); @@ -213,37 +218,38 @@ public class ApplicationConnection { } // Store resources - JSONObject resources = (JSONObject) ((JSONObject) json) + final JSONObject resources = (JSONObject) ((JSONObject) json) .get("resources"); - for (Iterator i = resources.keySet().iterator(); i.hasNext();) { - String key = (String) i.next(); + for (final Iterator i = resources.keySet().iterator(); i.hasNext();) { + final String key = (String) i.next(); resourcesMap.put(key, ((JSONString) resources.get(key)) .stringValue()); } // Store locale data if (((JSONObject) json).containsKey("locales")) { - JSONArray l = (JSONArray) ((JSONObject) json).get("locales"); + final JSONArray l = (JSONArray) ((JSONObject) json).get("locales"); for (int i = 0; i < l.size(); i++) { LocaleService.addLocale((JSONObject) l.get(i)); } } // Process changes - JSONArray changes = (JSONArray) ((JSONObject) json).get("changes"); + final JSONArray changes = (JSONArray) ((JSONObject) json) + .get("changes"); for (int i = 0; i < changes.size(); i++) { try { - UIDL change = new UIDL((JSONArray) changes.get(i)); + final UIDL change = new UIDL((JSONArray) changes.get(i)); try { console.dirUIDL(change); - } catch (Exception e) { + } catch (final Exception e) { console.log(e.getMessage()); // TODO: dir doesn't work in any browser although it should // work (works in hosted mode) // it partially did at some part but now broken. } - UIDL uidl = change.getChildUIDL(0); - Paintable paintable = getPaintable(uidl.getId()); + final UIDL uidl = change.getChildUIDL(0); + final Paintable paintable = getPaintable(uidl.getId()); if (paintable != null) { paintable.updateFromUIDL(uidl, this); } else { @@ -256,24 +262,25 @@ public class ApplicationConnection { view.updateFromUIDL(uidl, this); } } - } catch (Throwable e) { + } catch (final Throwable e) { e.printStackTrace(); } } if (((JSONObject) json).containsKey("meta")) { - JSONObject meta = ((JSONObject) json).get("meta").isObject(); + final JSONObject meta = ((JSONObject) json).get("meta").isObject(); if (meta.containsKey("focus")) { - String focusPid = meta.get("focus").isString().stringValue(); - Paintable toBeFocused = getPaintable(focusPid); + final String focusPid = meta.get("focus").isString() + .stringValue(); + final Paintable toBeFocused = getPaintable(focusPid); if (toBeFocused instanceof HasFocus) { - HasFocus toBeFocusedWidget = (HasFocus) toBeFocused; + final HasFocus toBeFocusedWidget = (HasFocus) toBeFocused; toBeFocusedWidget.setFocus(true); } } } - long prosessingTime = (new Date().getTime()) - start.getTime(); + final long prosessingTime = (new Date().getTime()) - start.getTime(); console.log(" Processing time was " + String.valueOf(prosessingTime) + "ms for " + jsonText.length() + " characters of JSON"); console.log("Referenced paintables: " + idToPaintable.size()); @@ -301,9 +308,9 @@ public class ApplicationConnection { } public void unregisterChildPaintables(HasWidgets container) { - Iterator it = container.iterator(); + final Iterator it = container.iterator(); while (it.hasNext()) { - Widget w = (Widget) it.next(); + final Widget w = (Widget) it.next(); if (w instanceof Paintable) { unregisterPaintable((Paintable) w); } @@ -325,7 +332,7 @@ public class ApplicationConnection { private void addVariableToQueue(String paintableId, String variableName, String encodedValue, boolean immediate, char type) { - String id = paintableId + "_" + variableName + "_" + type; + final String id = paintableId + "_" + variableName + "_" + type; for (int i = 0; i < pendingVariables.size(); i += 2) { if ((pendingVariables.get(i)).equals(id)) { pendingVariables.remove(i); @@ -341,7 +348,7 @@ public class ApplicationConnection { } public void sendPendingVariableChanges() { - StringBuffer req = new StringBuffer(); + final StringBuffer req = new StringBuffer(); req.append("changes="); for (int i = 0; i < pendingVariables.size(); i++) { @@ -398,7 +405,7 @@ public class ApplicationConnection { public void updateVariable(String paintableId, String variableName, Object[] values, boolean immediate) { - StringBuffer buf = new StringBuffer(); + final StringBuffer buf = new StringBuffer(); for (int i = 0; i < values.length; i++) { if (i > 0) { buf.append(","); @@ -471,7 +478,7 @@ public class ApplicationConnection { component.setVisible(visible); // Set captions if (manageCaption) { - Container parent = getParentLayout(component); + final Container parent = getParentLayout(component); if (parent != null) { parent.updateCaption((Paintable) component, uidl); } @@ -483,9 +490,9 @@ public class ApplicationConnection { // Switch to correct implementation if needed if (!widgetSet.isCorrectImplementation(component, uidl)) { - Container parent = getParentLayout(component); + final Container parent = getParentLayout(component); if (parent != null) { - Widget w = widgetSet.createWidget(uidl); + final Widget w = widgetSet.createWidget(uidl); parent.replaceChildComponent(component, w); registerPaintable(uidl.getId(), (Paintable) w); ((Paintable) w).updateFromUIDL(uidl, this); @@ -513,7 +520,7 @@ public class ApplicationConnection { // add additional styles as css classes, prefixed with component default // stylename if (uidl.hasAttribute("style")) { - String[] styles = uidl.getStringAttribute("style").split(" "); + final String[] styles = uidl.getStringAttribute("style").split(" "); for (int i = 0; i < styles.length; i++) { component.addStyleDependentName(styles[i]); } @@ -534,7 +541,7 @@ public class ApplicationConnection { * @return Either existing or new widget corresponding to UIDL. */ public Widget getWidget(UIDL uidl) { - String id = uidl.getId(); + final String id = uidl.getId(); Widget w = (Widget) getPaintable(id); if (w != null) { return w; @@ -571,7 +578,7 @@ public class ApplicationConnection { */ public String translateToolkitUri(String toolkitUri) { if (toolkitUri.startsWith("theme://")) { - String themeUri = getThemeUri(); + final String themeUri = getThemeUri(); if (themeUri == null) { console .error("Theme not set: ThemeResource will not be found. (" diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Caption.java b/src/com/itmill/toolkit/terminal/gwt/client/Caption.java index d097ca4829..8cd81ae889 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/Caption.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/Caption.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import com.google.gwt.user.client.DOM; @@ -10,7 +14,7 @@ public class Caption extends HTML { public static final String CLASSNAME = "i-caption"; - private Paintable owner; + private final Paintable owner; private Element errorIndicatorElement; @@ -20,7 +24,7 @@ public class Caption extends HTML { private ErrorMessage errorMessage; - private ApplicationConnection client; + private final ApplicationConnection client; public Caption(Paintable component, ApplicationConnection client) { super(); @@ -35,7 +39,7 @@ public class Caption extends HTML { setStyleName(getElement(), "i-disabled", uidl.hasAttribute("disabled")); if (uidl.hasAttribute("error")) { - UIDL errorUidl = uidl.getErrors(); + final UIDL errorUidl = uidl.getErrors(); if (errorIndicatorElement == null) { errorIndicatorElement = DOM.createDiv(); @@ -89,7 +93,7 @@ public class Caption extends HTML { } public void onBrowserEvent(Event event) { - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (errorIndicatorElement != null && DOM.compare(target, errorIndicatorElement)) { switch (DOM.eventGetType(event)) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java b/src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java index 5b61a40ecd..ec5a585998 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import com.google.gwt.user.client.ui.FlowPanel; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Console.java b/src/com/itmill/toolkit/terminal/gwt/client/Console.java index 37c911032d..51cc9311f4 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/Console.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/Console.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; public interface Console { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Container.java b/src/com/itmill/toolkit/terminal/gwt/client/Container.java index 5e0fe8df31..b73ad05f03 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/Container.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/Container.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import com.google.gwt.user.client.ui.Widget; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ContainerResizedListener.java b/src/com/itmill/toolkit/terminal/gwt/client/ContainerResizedListener.java index 22d92355d1..f299c985dd 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ContainerResizedListener.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ContainerResizedListener.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; /** diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java b/src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java index 7cc4ace944..481f3ecdec 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; public class DateLocale extends @@ -22,7 +26,7 @@ public class DateLocale extends public static String getAM() { try { return LocaleService.getAmPmStrings(locale)[0]; - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println("Tried to use an unloaded locale \"" + locale + "\"."); @@ -33,7 +37,7 @@ public class DateLocale extends public static String getPM() { try { return LocaleService.getAmPmStrings(locale)[1]; - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println("Tried to use an unloaded locale \"" + locale + "\"."); @@ -44,7 +48,7 @@ public class DateLocale extends public String[] getWEEKDAY_LONG() { try { return LocaleService.getDayNames(locale); - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println("Tried to use an unloaded locale \"" + locale + "\"."); @@ -55,7 +59,7 @@ public class DateLocale extends public String[] getWEEKDAY_SHORT() { try { return LocaleService.getShortDayNames(locale); - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println("Tried to use an unloaded locale \"" + locale + "\"."); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java b/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java index 02d77730f9..1138412fcd 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import java.util.Date; @@ -56,7 +60,7 @@ public class DateTimeService { public String getMonth(int month) { try { return LocaleService.getMonthNames(currentLocale)[month]; - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } @@ -66,7 +70,7 @@ public class DateTimeService { public String getShortMonth(int month) { try { return LocaleService.getShortMonthNames(currentLocale)[month]; - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } @@ -76,7 +80,7 @@ public class DateTimeService { public String getDay(int day) { try { return LocaleService.getDayNames(currentLocale)[day]; - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } @@ -86,7 +90,7 @@ public class DateTimeService { public String getShortDay(int day) { try { return LocaleService.getShortDayNames(currentLocale)[day]; - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } @@ -96,7 +100,7 @@ public class DateTimeService { public int getFirstDayOfWeek() { try { return LocaleService.getFirstDayOfWeek(currentLocale); - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } @@ -106,7 +110,7 @@ public class DateTimeService { public boolean isTwelveHourClock() { try { return LocaleService.isTwelveHourClock(currentLocale); - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } @@ -116,7 +120,7 @@ public class DateTimeService { public String getClockDelimeter() { try { return LocaleService.getClockDelimiter(currentLocale); - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } @@ -126,23 +130,23 @@ public class DateTimeService { public String[] getAmPmStrings() { try { return LocaleService.getAmPmStrings(currentLocale); - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } - String[] temp = new String[2]; + final String[] temp = new String[2]; temp[0] = "AM"; temp[1] = "PM"; return temp; } public int getStartWeekDay(Date date) { - Date dateForFirstOfThisMonth = new Date(date.getYear(), - date.getMonth(), 1); + final Date dateForFirstOfThisMonth = new Date(date.getYear(), date + .getMonth(), 1); int firstDay; try { firstDay = LocaleService.getFirstDayOfWeek(currentLocale); - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { firstDay = 0; // TODO redirect to console System.out.println(e + ":" + e.getMessage()); @@ -157,7 +161,7 @@ public class DateTimeService { public String getDateFormat() { try { return LocaleService.getDateFormat(currentLocale); - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { // TODO redirect to console System.out.println(e + ":" + e.getMessage()); } @@ -165,7 +169,7 @@ public class DateTimeService { } public static int getNumberOfDaysInMonth(Date date) { - int month = date.getMonth(); + final int month = date.getMonth(); if (month == 1 && true == isLeapYear(date)) { return 29; } @@ -174,14 +178,14 @@ public class DateTimeService { public static boolean isLeapYear(Date date) { // Instantiate the date for 1st March of that year - Date firstMarch = new Date(date.getYear(), 2, 1); + final Date firstMarch = new Date(date.getYear(), 2, 1); // Go back 1 day - long firstMarchTime = firstMarch.getTime(); - long lastDayTimeFeb = firstMarchTime - (24 * 60 * 60 * 1000); // NUM_MILLISECS_A_DAY + final long firstMarchTime = firstMarch.getTime(); + final long lastDayTimeFeb = firstMarchTime - (24 * 60 * 60 * 1000); // NUM_MILLISECS_A_DAY // Instantiate new Date with this time - Date febLastDay = new Date(lastDayTimeFeb); + final Date febLastDay = new Date(lastDayTimeFeb); // Check for date in this new instance return (29 == febLastDay.getDate()) ? true : false; @@ -241,9 +245,9 @@ public class DateTimeService { } private static int getDayInt(Date date) { - int y = date.getYear(); - int m = date.getMonth(); - int d = date.getDate(); + final int y = date.getYear(); + final int m = date.getMonth(); + final int d = date.getDate(); return ((y + 1900) * 10000 + m * 100 + d) * 1000000000; } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java b/src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java index 4b9d2b799a..34a0452a67 100755 --- a/src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import com.google.gwt.user.client.Event; @@ -11,13 +15,13 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IWindow; public final class DebugConsole extends IWindow implements Console { - private Panel panel; + private final Panel panel; public DebugConsole(ApplicationConnection client) { super(); this.client = client; panel = new FlowPanel(); - ScrollPanel p = new ScrollPanel(); + final ScrollPanel p = new ScrollPanel(); p.add(panel); setWidget(p); setCaption("Debug window"); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java index 82ec62b813..b846a50c17 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import com.google.gwt.core.client.GWT; @@ -53,7 +57,7 @@ public class DefaultWidgetSet implements WidgetSet { public Widget createWidget(UIDL uidl) { - String className = resolveWidgetTypeName(uidl); + final String className = resolveWidgetTypeName(uidl); if ("com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox" .equals(className)) { return new ICheckBox(); @@ -174,7 +178,7 @@ public class DefaultWidgetSet implements WidgetSet { protected String resolveWidgetTypeName(UIDL uidl) { - String tag = uidl.getTag(); + final String tag = uidl.getTag(); if ("button".equals(tag)) { if ("switch".equals(uidl.getStringAttribute("type"))) { return "com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox"; @@ -199,7 +203,7 @@ public class DefaultWidgetSet implements WidgetSet { return "com.itmill.toolkit.terminal.gwt.client.ui.ITree"; } else if ("select".equals(tag)) { if (uidl.hasAttribute("type")) { - String type = uidl.getStringAttribute("type"); + final String type = uidl.getStringAttribute("type"); if (type.equals("twincol")) { return "com.itmill.toolkit.terminal.gwt.client.ui.ITwinColSelect"; } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java b/src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java index 9df6900397..a90a00807d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import java.util.Iterator; @@ -18,16 +22,16 @@ public class ErrorMessage extends FlowPanel { public void updateFromUIDL(UIDL uidl) { clear(); - for (Iterator it = uidl.getChildIterator(); it.hasNext();) { - Object child = it.next(); + for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + final Object child = it.next(); if (child instanceof String) { - String errorMessage = (String) child; + final String errorMessage = (String) child; add(new HTML(errorMessage)); } else if (child instanceof UIDL.XML) { - UIDL.XML xml = (UIDL.XML) child; + final UIDL.XML xml = (UIDL.XML) child; add(new HTML(xml.getXMLAsString())); } else { - ErrorMessage childError = new ErrorMessage(); + final ErrorMessage childError = new ErrorMessage(); add(childError); childError.updateFromUIDL((UIDL) child); } @@ -57,7 +61,7 @@ public class ErrorMessage extends FlowPanel { } public void hide() { - ToolkitOverlay errorContainer = (ToolkitOverlay) getParent(); + final ToolkitOverlay errorContainer = (ToolkitOverlay) getParent(); if (errorContainer != null) { errorContainer.hide(); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java b/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java index 2ff8e09948..39c38bdd49 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; public class LocaleNotLoadedException extends Exception { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java b/src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java index 5a266aed91..6b74b2c186 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import java.util.HashMap; @@ -23,7 +27,7 @@ public class LocaleService { private static String defaultLocale; public static void addLocale(JSONObject json) { - String key = ((JSONString) json.get("name")).stringValue(); + final String key = ((JSONString) json.get("name")).stringValue(); if (cache.containsKey(key)) { cache.remove(key); } @@ -48,9 +52,9 @@ public class LocaleService { public static String[] getMonthNames(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONArray mn = (JSONArray) l.get("mn"); - String[] temp = new String[12]; + final JSONObject l = (JSONObject) cache.get(locale); + final JSONArray mn = (JSONArray) l.get("mn"); + final String[] temp = new String[12]; temp[0] = ((JSONString) mn.get(0)).stringValue(); temp[1] = ((JSONString) mn.get(1)).stringValue(); temp[2] = ((JSONString) mn.get(2)).stringValue(); @@ -72,9 +76,9 @@ public class LocaleService { public static String[] getShortMonthNames(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONArray smn = (JSONArray) l.get("smn"); - String[] temp = new String[12]; + final JSONObject l = (JSONObject) cache.get(locale); + final JSONArray smn = (JSONArray) l.get("smn"); + final String[] temp = new String[12]; temp[0] = ((JSONString) smn.get(0)).stringValue(); temp[1] = ((JSONString) smn.get(1)).stringValue(); temp[2] = ((JSONString) smn.get(2)).stringValue(); @@ -96,9 +100,9 @@ public class LocaleService { public static String[] getDayNames(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONArray dn = (JSONArray) l.get("dn"); - String[] temp = new String[7]; + final JSONObject l = (JSONObject) cache.get(locale); + final JSONArray dn = (JSONArray) l.get("dn"); + final String[] temp = new String[7]; temp[0] = ((JSONString) dn.get(0)).stringValue(); temp[1] = ((JSONString) dn.get(1)).stringValue(); temp[2] = ((JSONString) dn.get(2)).stringValue(); @@ -115,9 +119,9 @@ public class LocaleService { public static String[] getShortDayNames(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONArray sdn = (JSONArray) l.get("sdn"); - String[] temp = new String[7]; + final JSONObject l = (JSONObject) cache.get(locale); + final JSONArray sdn = (JSONArray) l.get("sdn"); + final String[] temp = new String[7]; temp[0] = ((JSONString) sdn.get(0)).stringValue(); temp[1] = ((JSONString) sdn.get(1)).stringValue(); temp[2] = ((JSONString) sdn.get(2)).stringValue(); @@ -134,8 +138,8 @@ public class LocaleService { public static int getFirstDayOfWeek(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONNumber fdow = (JSONNumber) l.get("fdow"); + final JSONObject l = (JSONObject) cache.get(locale); + final JSONNumber fdow = (JSONNumber) l.get("fdow"); return (int) fdow.getValue(); } else { throw new LocaleNotLoadedException(locale); @@ -145,8 +149,8 @@ public class LocaleService { public static String getDateFormat(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONString df = (JSONString) l.get("df"); + final JSONObject l = (JSONObject) cache.get(locale); + final JSONString df = (JSONString) l.get("df"); return df.stringValue(); } else { throw new LocaleNotLoadedException(locale); @@ -156,8 +160,8 @@ public class LocaleService { public static boolean isTwelveHourClock(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONBoolean thc = (JSONBoolean) l.get("thc"); + final JSONObject l = (JSONObject) cache.get(locale); + final JSONBoolean thc = (JSONBoolean) l.get("thc"); return thc.booleanValue(); } else { throw new LocaleNotLoadedException(locale); @@ -167,8 +171,8 @@ public class LocaleService { public static String getClockDelimiter(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONString hmd = (JSONString) l.get("hmd"); + final JSONObject l = (JSONObject) cache.get(locale); + final JSONString hmd = (JSONString) l.get("hmd"); return hmd.stringValue(); } else { throw new LocaleNotLoadedException(locale); @@ -178,9 +182,9 @@ public class LocaleService { public static String[] getAmPmStrings(String locale) throws LocaleNotLoadedException { if (cache.containsKey(locale)) { - JSONObject l = (JSONObject) cache.get(locale); - JSONArray ampm = (JSONArray) l.get("ampm"); - String[] temp = new String[2]; + final JSONObject l = (JSONObject) cache.get(locale); + final JSONArray ampm = (JSONArray) l.get("ampm"); + final String[] temp = new String[2]; temp[0] = ((JSONString) ampm.get(0)).stringValue(); temp[1] = ((JSONString) ampm.get(1)).stringValue(); return temp; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java b/src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java index ec81a7b11f..2c158b6ab7 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; /** diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Paintable.java b/src/com/itmill/toolkit/terminal/gwt/client/Paintable.java index bfe73243dc..81c024be4c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/Paintable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/Paintable.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; public interface Paintable { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java b/src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java index c7a752e5ff..35f1b5818f 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/StyleConstants.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; public class StyleConstants { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java index 14ad0c6a31..1dffe8c3b2 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import java.util.HashSet; @@ -24,7 +28,7 @@ public class UIDL { } public String getId() { - JSONValue val = ((JSONObject) json.get(1)).get("id"); + final JSONValue val = ((JSONObject) json.get(1)).get("id"); if (val == null) { return null; } @@ -36,7 +40,7 @@ public class UIDL { } public String getStringAttribute(String name) { - JSONValue val = ((JSONObject) json.get(1)).get(name); + final JSONValue val = ((JSONObject) json.get(1)).get(name); if (val == null) { return null; } @@ -44,49 +48,49 @@ public class UIDL { } public Set getAttributeNames() { - HashSet attrs = new HashSet(((JSONObject) json.get(1)).keySet()); + final HashSet attrs = new HashSet(((JSONObject) json.get(1)).keySet()); attrs.remove("v"); return attrs; } public int getIntAttribute(String name) { - JSONValue val = ((JSONObject) json.get(1)).get(name); + final JSONValue val = ((JSONObject) json.get(1)).get(name); if (val == null) { return 0; } - double num = ((JSONNumber) val).getValue(); + final double num = ((JSONNumber) val).getValue(); return (int) num; } public long getLongAttribute(String name) { - JSONValue val = ((JSONObject) json.get(1)).get(name); + final JSONValue val = ((JSONObject) json.get(1)).get(name); if (val == null) { return 0; } - double num = ((JSONNumber) val).getValue(); + final double num = ((JSONNumber) val).getValue(); return (long) num; } public float getFloatAttribute(String name) { - JSONValue val = ((JSONObject) json.get(1)).get(name); + final JSONValue val = ((JSONObject) json.get(1)).get(name); if (val == null) { return 0; } - double num = ((JSONNumber) val).getValue(); + final double num = ((JSONNumber) val).getValue(); return (float) num; } public double getDoubleAttribute(String name) { - JSONValue val = ((JSONObject) json.get(1)).get(name); + final JSONValue val = ((JSONObject) json.get(1)).get(name); if (val == null) { return 0; } - double num = ((JSONNumber) val).getValue(); + final double num = ((JSONNumber) val).getValue(); return num; } public boolean getBooleanAttribute(String name) { - JSONValue val = ((JSONObject) json.get(1)).get(name); + final JSONValue val = ((JSONObject) json.get(1)).get(name); if (val == null) { return false; } @@ -94,8 +98,8 @@ public class UIDL { } public String[] getStringArrayAttribute(String name) { - JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name); - String[] s = new String[a.size()]; + final JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name); + final String[] s = new String[a.size()]; for (int i = 0; i < a.size(); i++) { s[i] = ((JSONString) a.get(i)).stringValue(); } @@ -103,8 +107,8 @@ public class UIDL { } public int[] getIntArrayAttribute(String name) { - JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name); - int[] s = new int[a.size()]; + final JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name); + final int[] s = new int[a.size()]; for (int i = 0; i < a.size(); i++) { s[i] = Integer.parseInt(((JSONString) a.get(i)).stringValue()); } @@ -112,8 +116,8 @@ public class UIDL { } public HashSet getStringArrayAttributeAsSet(String string) { - JSONArray a = getArrayVariable(string); - HashSet s = new HashSet(); + final JSONArray a = getArrayVariable(string); + final HashSet s = new HashSet(); for (int i = 0; i < a.size(); i++) { s.add(((JSONString) a.get(i)).stringValue()); } @@ -136,7 +140,7 @@ public class UIDL { public UIDL getChildUIDL(int i) { - JSONValue c = json.get(i + 2); + final JSONValue c = json.get(i + 2); if (c == null) { return null; } @@ -149,7 +153,7 @@ public class UIDL { public String getChildString(int i) { - JSONValue c = json.get(i + 2); + final JSONValue c = json.get(i + 2); if (c.isString() != null) { return ((JSONString) c).stringValue(); } @@ -170,7 +174,7 @@ public class UIDL { public Object next() { if (json.size() > index) { - JSONValue c = json.get(index++); + final JSONValue c = json.get(index++); if (c.isString() != null) { return c.isString().stringValue(); } else if (c.isArray() != null) { @@ -199,10 +203,10 @@ public class UIDL { public String toString() { String s = "<" + getTag(); - for (Iterator i = getAttributeNames().iterator(); i.hasNext();) { - String name = i.next().toString(); + for (final Iterator i = getAttributeNames().iterator(); i.hasNext();) { + final String name = i.next().toString(); s += " " + name + "="; - JSONValue v = ((JSONObject) json.get(1)).get(name); + final JSONValue v = ((JSONObject) json.get(1)).get(name); if (v.isString() != null) { s += v; } else { @@ -212,9 +216,9 @@ public class UIDL { s += ">\n"; - Iterator i = getChildIterator(); + final Iterator i = getChildIterator(); while (i.hasNext()) { - Object c = i.next(); + final Object c = i.next(); s += c.toString(); } @@ -225,9 +229,9 @@ public class UIDL { public String getChildrenAsXML() { String s = ""; - Iterator i = getChildIterator(); + final Iterator i = getChildIterator(); while (i.hasNext()) { - Object c = i.next(); + final Object c = i.next(); s += c.toString(); } return s; @@ -252,7 +256,7 @@ public class UIDL { removeItem(root); UIDLBrowser.this.removeTreeListener(this); addItem(dir()); - Iterator it = treeItemIterator(); + final Iterator it = treeItemIterator(); while (it.hasNext()) { ((TreeItem) it.next()).setState(true); } @@ -275,30 +279,30 @@ public class UIDL { public TreeItem dir() { String nodeName = getTag(); - for (Iterator i = getAttributeNames().iterator(); i.hasNext();) { - String name = i.next().toString(); - String value = getAttribute(name); + for (final Iterator i = getAttributeNames().iterator(); i.hasNext();) { + final String name = i.next().toString(); + final String value = getAttribute(name); nodeName += " " + name + "=" + value; } - TreeItem item = new TreeItem(nodeName); + final TreeItem item = new TreeItem(nodeName); try { TreeItem tmp = null; - for (Iterator i = getVariableHash().keySet().iterator(); i + for (final Iterator i = getVariableHash().keySet().iterator(); i .hasNext();) { - String name = i.next().toString(); + final String name = i.next().toString(); String value = ""; try { value = getStringVariable(name); - } catch (Exception e) { + } catch (final Exception e) { try { - JSONArray a = getArrayVariable(name); + final JSONArray a = getArrayVariable(name); value = a.toString(); - } catch (Exception e2) { + } catch (final Exception e2) { try { - int intVal = getIntVariable(name); + final int intVal = getIntVariable(name); value = String.valueOf(intVal); - } catch (Exception e3) { + } catch (final Exception e3) { value = "unknown"; } } @@ -311,18 +315,18 @@ public class UIDL { if (tmp != null) { item.addItem(tmp); } - } catch (Exception e) { + } catch (final Exception e) { // Ingonered, no variables } - Iterator i = getChildIterator(); + final Iterator i = getChildIterator(); while (i.hasNext()) { - Object child = i.next(); + final Object child = i.next(); try { - UIDL c = (UIDL) child; + final UIDL c = (UIDL) child; item.addItem(c.dir()); - } catch (Exception e) { + } catch (final Exception e) { item.addItem(child.toString()); } } @@ -330,7 +334,7 @@ public class UIDL { } private JSONObject getVariableHash() { - JSONObject v = (JSONObject) ((JSONObject) json.get(1)).get("v"); + final JSONObject v = (JSONObject) ((JSONObject) json.get(1)).get("v"); if (v == null) { throw new IllegalArgumentException("No variables defined in tag."); } @@ -341,13 +345,13 @@ public class UIDL { Object v = null; try { v = getVariableHash().get(name); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { } return v != null; } public String getStringVariable(String name) { - JSONString t = (JSONString) getVariableHash().get(name); + final JSONString t = (JSONString) getVariableHash().get(name); if (t == null) { throw new IllegalArgumentException("No such variable: " + name); } @@ -355,7 +359,7 @@ public class UIDL { } public int getIntVariable(String name) { - JSONNumber t = (JSONNumber) getVariableHash().get(name); + final JSONNumber t = (JSONNumber) getVariableHash().get(name); if (t == null) { throw new IllegalArgumentException("No such variable: " + name); } @@ -363,7 +367,7 @@ public class UIDL { } public long getLongVariable(String name) { - JSONNumber t = (JSONNumber) getVariableHash().get(name); + final JSONNumber t = (JSONNumber) getVariableHash().get(name); if (t == null) { throw new IllegalArgumentException("No such variable: " + name); } @@ -371,7 +375,7 @@ public class UIDL { } public float getFloatVariable(String name) { - JSONNumber t = (JSONNumber) getVariableHash().get(name); + final JSONNumber t = (JSONNumber) getVariableHash().get(name); if (t == null) { throw new IllegalArgumentException("No such variable: " + name); } @@ -379,7 +383,7 @@ public class UIDL { } public double getDoubleVariable(String name) { - JSONNumber t = (JSONNumber) getVariableHash().get(name); + final JSONNumber t = (JSONNumber) getVariableHash().get(name); if (t == null) { throw new IllegalArgumentException("No such variable: " + name); } @@ -387,7 +391,7 @@ public class UIDL { } public boolean getBooleanVariable(String name) { - JSONBoolean t = (JSONBoolean) getVariableHash().get(name); + final JSONBoolean t = (JSONBoolean) getVariableHash().get(name); if (t == null) { throw new IllegalArgumentException("No such variable: " + name); } @@ -395,7 +399,7 @@ public class UIDL { } private JSONArray getArrayVariable(String name) { - JSONArray t = (JSONArray) getVariableHash().get(name); + final JSONArray t = (JSONArray) getVariableHash().get(name); if (t == null) { throw new IllegalArgumentException("No such variable: " + name); } @@ -403,8 +407,8 @@ public class UIDL { } public String[] getStringArrayVariable(String name) { - JSONArray a = getArrayVariable(name); - String[] s = new String[a.size()]; + final JSONArray a = getArrayVariable(name); + final String[] s = new String[a.size()]; for (int i = 0; i < a.size(); i++) { s[i] = ((JSONString) a.get(i)).stringValue(); } @@ -412,8 +416,8 @@ public class UIDL { } public Set getStringArrayVariableAsSet(String name) { - JSONArray a = getArrayVariable(name); - HashSet s = new HashSet(); + final JSONArray a = getArrayVariable(name); + final HashSet s = new HashSet(); for (int i = 0; i < a.size(); i++) { s.add(((JSONString) a.get(i)).stringValue()); } @@ -421,10 +425,10 @@ public class UIDL { } public int[] getIntArrayVariable(String name) { - JSONArray a = getArrayVariable(name); - int[] s = new int[a.size()]; + final JSONArray a = getArrayVariable(name); + final int[] s = new int[a.size()]; for (int i = 0; i < a.size(); i++) { - JSONValue v = a.get(i); + final JSONValue v = a.get(i); s[i] = v.isNumber() != null ? (int) ((JSONNumber) v).getValue() : Integer.parseInt(v.toString()); } @@ -439,9 +443,9 @@ public class UIDL { } public String getXMLAsString() { - StringBuffer sb = new StringBuffer(); - for (Iterator it = x.keySet().iterator(); it.hasNext();) { - String tag = (String) it.next(); + final StringBuffer sb = new StringBuffer(); + for (final Iterator it = x.keySet().iterator(); it.hasNext();) { + final String tag = (String) it.next(); sb.append("<"); sb.append(tag); sb.append(">"); @@ -459,7 +463,7 @@ public class UIDL { } public UIDL getErrors() { - JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get("error"); + final JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get("error"); return new UIDL(a); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Util.java b/src/com/itmill/toolkit/terminal/gwt/client/Util.java index a1fad8258d..be75d449b6 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/Util.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/Util.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import java.util.Iterator; @@ -15,9 +19,9 @@ public class Util { * */ public static native void browserDebugger() /*-{ - if(window.console) - debugger; - }-*/; + if(window.console) + debugger; + }-*/; /** * Detects if current browser is IE. @@ -25,12 +29,12 @@ public class Util { * @return true if IE */ public static native boolean isIE() /*-{ - var browser=$wnd.navigator.appName; - if (browser=="Microsoft Internet Explorer") { - return true; - } - return false; - }-*/; + var browser=$wnd.navigator.appName; + if (browser=="Microsoft Internet Explorer") { + return true; + } + return false; + }-*/; /** * Detects if current browser is IE6. @@ -38,16 +42,16 @@ public class Util { * @return true if IE6 */ public static native boolean isIE6() /*-{ - var browser=$wnd.navigator.appName; - if (browser=="Microsoft Internet Explorer") { - var ua = navigator.userAgent; - var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); - if (re.exec(ua) != null) - rv = parseFloat(RegExp.$1); - if(rv == 6) return true; - } - return false; - }-*/; + var browser=$wnd.navigator.appName; + if (browser=="Microsoft Internet Explorer") { + var ua = navigator.userAgent; + var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + if(rv == 6) return true; + } + return false; + }-*/; /** * Nulls oncontextmenu function on given element. We need to manually clear @@ -57,8 +61,8 @@ public class Util { * @param el */ public native static void removeContextMenuEvent(Element el) /*-{ - el.oncontextmenu = null; - }-*/; + el.oncontextmenu = null; + }-*/; /** * Traverses recursively ancestors until ContainerResizedListener child @@ -67,13 +71,13 @@ public class Util { * @param container */ public static void runDescendentsLayout(HasWidgets container) { - Iterator childWidgets = container.iterator(); + final Iterator childWidgets = container.iterator(); while (childWidgets.hasNext()) { - Widget child = (Widget) childWidgets.next(); + final Widget child = (Widget) childWidgets.next(); if (child instanceof ContainerResizedListener) { ((ContainerResizedListener) child).iLayout(); } else if (child instanceof HasWidgets) { - HasWidgets childContainer = (HasWidgets) child; + final HasWidgets childContainer = (HasWidgets) child; runDescendentsLayout(childContainer); } } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java b/src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java index c975830252..e55da2c33d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client; import com.google.gwt.core.client.EntryPoint; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/Action.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/Action.java index 58d7d679c0..4c1cf2626d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/Action.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/Action.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.Command; @@ -24,7 +28,7 @@ public abstract class Action implements Command { public abstract void execute(); public String getHTML() { - StringBuffer sb = new StringBuffer(); + final StringBuffer sb = new StringBuffer(); sb.append("
"); if (getIconUrl() != null) { sb.append("\"icon\""); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/AlignmentInfo.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/AlignmentInfo.java index 0a2f48ab00..68024d849a 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/AlignmentInfo.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/AlignmentInfo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; public class AlignmentInfo { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java index edf0de98bd..551c458ed6 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.Date; @@ -5,7 +9,7 @@ import java.util.Date; import com.itmill.toolkit.terminal.gwt.client.DateTimeService; public class CalendarEntry { - private String styleName; + private final String styleName; private Date start; private Date end; private String title; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java index 216bf95a3a..5173831811 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.Date; @@ -21,7 +25,7 @@ import com.itmill.toolkit.terminal.gwt.client.LocaleService; public class CalendarPanel extends FlexTable implements MouseListener, ClickListener { - private IDateField datefield; + private final IDateField datefield; private IEventButton prevYear; @@ -60,9 +64,9 @@ public class CalendarPanel extends FlexTable implements MouseListener, } private void buildCalendar(boolean forceRedraw) { - boolean needsMonth = datefield.getCurrentResolution() > IDateField.RESOLUTION_YEAR; + final boolean needsMonth = datefield.getCurrentResolution() > IDateField.RESOLUTION_YEAR; boolean needsBody = datefield.getCurrentResolution() >= IDateField.RESOLUTION_DAY; - boolean needsTime = datefield.getCurrentResolution() >= IDateField.RESOLUTION_HOUR; + final boolean needsTime = datefield.getCurrentResolution() >= IDateField.RESOLUTION_HOUR; buildCalendarHeader(forceRedraw, needsMonth); clearCalendarBody(!needsBody); if (needsBody) { @@ -142,7 +146,8 @@ public class CalendarPanel extends FlexTable implements MouseListener, } // Print weekday names - int firstDay = datefield.getDateTimeService().getFirstDayOfWeek(); + final int firstDay = datefield.getDateTimeService() + .getFirstDayOfWeek(); for (int i = 0; i < 7; i++) { int day = i + firstDay; if (day > 6) { @@ -158,9 +163,9 @@ public class CalendarPanel extends FlexTable implements MouseListener, } } - String monthName = needsMonth ? datefield.getDateTimeService() + final String monthName = needsMonth ? datefield.getDateTimeService() .getMonth(datefield.getCurrentDate().getMonth()) : ""; - int year = datefield.getCurrentDate().getYear() + 1900; + final int year = datefield.getCurrentDate().getYear() + 1900; setHTML(0, 2, "" + monthName + " " + year + ""); @@ -171,32 +176,33 @@ public class CalendarPanel extends FlexTable implements MouseListener, if (date == null) { date = new Date(); } - int startWeekDay = datefield.getDateTimeService().getStartWeekDay(date); - int numDays = DateTimeService.getNumberOfDaysInMonth(date); + final int startWeekDay = datefield.getDateTimeService() + .getStartWeekDay(date); + final int numDays = DateTimeService.getNumberOfDaysInMonth(date); int dayCount = 0; - Date today = new Date(); - Date curr = new Date(date.getTime()); + final Date today = new Date(); + final Date curr = new Date(date.getTime()); for (int row = 2; row < 8; row++) { for (int col = 0; col < 7; col++) { if (!(row == 2 && col < startWeekDay)) { if (dayCount < numDays) { - int selectedDate = ++dayCount; + final int selectedDate = ++dayCount; String title = ""; if (entrySource != null) { curr.setDate(dayCount); - List entries = entrySource.getEntries(curr, + final List entries = entrySource.getEntries(curr, IDateField.RESOLUTION_DAY); if (entries != null) { - for (Iterator it = entries.iterator(); it + for (final Iterator it = entries.iterator(); it .hasNext();) { - CalendarEntry entry = (CalendarEntry) it + final CalendarEntry entry = (CalendarEntry) it .next(); title += (title.length() > 0 ? ", " : "") + entry.getStringForDate(curr); } } } - String baseclass = IDateField.CLASSNAME + final String baseclass = IDateField.CLASSNAME + "-calendarpanel-day"; String cssClass = baseclass; if (!isEnabledDate(curr)) { @@ -371,7 +377,7 @@ public class CalendarPanel extends FlexTable implements MouseListener, private class DateClickListener implements TableListener { - private CalendarPanel cal; + private final CalendarPanel cal; public DateClickListener(CalendarPanel panel) { cal = panel; @@ -383,14 +389,14 @@ public class CalendarPanel extends FlexTable implements MouseListener, return; } - String text = cal.getText(row, col); + final String text = cal.getText(row, col); if (text.equals(" ")) { return; } try { - Integer day = new Integer(text); - Date newDate = new Date(cal.datefield.getCurrentDate() + final Integer day = new Integer(text); + final Date newDate = new Date(cal.datefield.getCurrentDate() .getTime()); newDate.setDate(day.intValue()); if (!isEnabledDate(newDate)) { @@ -402,7 +408,7 @@ public class CalendarPanel extends FlexTable implements MouseListener, cal.datefield.isImmediate()); updateCalendar(); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { // Not a number, ignore and stop here return; } @@ -412,7 +418,7 @@ public class CalendarPanel extends FlexTable implements MouseListener, public void setLimits(Date min, Date max) { if (min != null) { - Date d = new Date(min.getTime()); + final Date d = new Date(min.getTime()); d.setHours(0); d.setMinutes(0); d.setSeconds(1); @@ -421,7 +427,7 @@ public class CalendarPanel extends FlexTable implements MouseListener, minDate = null; } if (max != null) { - Date d = new Date(max.getTime()); + final Date d = new Date(max.getTime()); d.setHours(24); d.setMinutes(59); d.setSeconds(59); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java index 000c6a095f..b3c14ba321 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.Window; @@ -9,7 +13,7 @@ public class ContextMenu extends ToolkitOverlay { private ActionOwner actionOwner; - private CMenuBar menu = new CMenuBar(); + private final CMenuBar menu = new CMenuBar(); private int left; @@ -47,9 +51,9 @@ public class ContextMenu extends ToolkitOverlay { this.left = left; this.top = top; menu.clearItems(); - Action[] actions = actionOwner.getActions(); + final Action[] actions = actionOwner.getActions(); for (int i = 0; i < actions.length; i++) { - Action a = actions[i]; + final Action a = actions[i]; menu.addItem(new MenuItem(a.getHTML(), true, a)); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java index 74b211bb0b..b69cb0761a 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -21,7 +25,7 @@ public class IButton extends Button implements Paintable { private Element errorIndicatorElement; - private Element captionElement = DOM.createSpan(); + private final Element captionElement = DOM.createSpan(); private ErrorMessage errorMessage; @@ -64,7 +68,7 @@ public class IButton extends Button implements Paintable { // handle error if (uidl.hasAttribute("error")) { - UIDL errorUidl = uidl.getErrors(); + final UIDL errorUidl = uidl.getErrors(); if (errorIndicatorElement == null) { errorIndicatorElement = DOM.createDiv(); DOM.setElementProperty(errorIndicatorElement, "className", @@ -110,7 +114,7 @@ public class IButton extends Button implements Paintable { } public void onBrowserEvent(Event event) { - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (errorIndicatorElement != null && DOM.compare(target, errorIndicatorElement)) { switch (DOM.eventGetType(event)) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java index 8fb87ae06b..d2edbd3a28 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -53,7 +57,7 @@ public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox implements } if (uidl.hasAttribute("error")) { - UIDL errorUidl = uidl.getErrors(); + final UIDL errorUidl = uidl.getErrors(); if (errorIndicatorElement == null) { errorIndicatorElement = DOM.createDiv(); @@ -95,7 +99,7 @@ public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox implements public void onBrowserEvent(Event event) { super.onBrowserEvent(event); - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (errorIndicatorElement != null && DOM.compare(target, errorIndicatorElement)) { switch (DOM.eventGetType(event)) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java index 73deb42e18..ba79476fe3 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.ui.SimplePanel; @@ -17,9 +21,9 @@ public class ICustomComponent extends SimplePanel implements Paintable { public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - UIDL child = uidl.getChildUIDL(0); + final UIDL child = uidl.getChildUIDL(0); if (child != null) { - Paintable p = (Paintable) client.getWidget(child); + final Paintable p = (Paintable) client.getWidget(child); if (p != getWidget()) { if (getWidget() != null) { client.unregisterPaintable((Paintable) getWidget()); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java index 62d7cb7fcf..0bd60001f7 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.HashMap; @@ -28,13 +32,13 @@ public class ICustomLayout extends ComplexPanel implements Paintable, public static final String CLASSNAME = "i-customlayout"; /** Location-name to containing element in DOM map */ - private HashMap locationToElement = new HashMap(); + private final HashMap locationToElement = new HashMap(); /** Location-name to contained widget map */ - private HashMap locationToWidget = new HashMap(); + private final HashMap locationToWidget = new HashMap(); /** Widget to captionwrapper map */ - private HashMap widgetToCaptionWrapper = new HashMap(); + private final HashMap widgetToCaptionWrapper = new HashMap(); /** Currently rendered style */ String currentTemplate; @@ -84,7 +88,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, } // Get previous widget - Widget previous = (Widget) locationToWidget.get(location); + final Widget previous = (Widget) locationToWidget.get(location); // NOP if given widget already exists in this location if (previous == widget) { return; @@ -135,16 +139,17 @@ public class ICustomLayout extends ComplexPanel implements Paintable, iLayout(); // For all contained widgets - for (Iterator i = uidl.getChildIterator(); i.hasNext();) { - UIDL uidlForChild = (UIDL) i.next(); + for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + final UIDL uidlForChild = (UIDL) i.next(); if (uidlForChild.getTag().equals("location")) { - String location = uidlForChild.getStringAttribute("name"); - Widget child = client.getWidget(uidlForChild.getChildUIDL(0)); + final String location = uidlForChild.getStringAttribute("name"); + final Widget child = client.getWidget(uidlForChild + .getChildUIDL(0)); try { setWidget(child, location); ((Paintable) child).updateFromUIDL(uidlForChild .getChildUIDL(0), client); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // If no location is found, this component is not visible } } @@ -156,7 +161,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, /** Initialize HTML-layout. */ private void initializeHTML(UIDL uidl, ApplicationConnection client) { - String newTemplate = uidl.getStringAttribute("template"); + final String newTemplate = uidl.getStringAttribute("template"); // Get the HTML-template from client String template = client @@ -219,12 +224,12 @@ public class ICustomLayout extends ComplexPanel implements Paintable, /** Collect locations from template */ private void scanForLocations(Element elem) { - String location = getLocation(elem); + final String location = getLocation(elem); if (location != null) { locationToElement.put(location, elem); DOM.setInnerHTML(elem, ""); } else { - int len = DOM.getChildCount(elem); + final int len = DOM.getChildCount(elem); for (int i = 0; i < len; i++) { scanForLocations(DOM.getChild(elem, i)); } @@ -291,7 +296,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, while (scriptStart > 0) { res += html.substring(endOfPrevScript, scriptStart); scriptStart = lc.indexOf(">", scriptStart); - int j = lc.indexOf("", scriptStart); + final int j = lc.indexOf("", scriptStart); scripts += html.substring(scriptStart + 1, j) + ";"; nextPosToCheck = endOfPrevScript = j + "".length(); scriptStart = lc.indexOf("", startOfBody) + 1; - int endOfBody = lc.indexOf("", startOfBody); + final int endOfBody = lc.indexOf("", startOfBody); if (endOfBody > startOfBody) { res = html.substring(startOfBody, endOfBody); } else { @@ -320,7 +325,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, /** Replace child components */ public void replaceChildComponent(Widget from, Widget to) { - String location = getLocation(from); + final String location = getLocation(from); if (location == null) { throw new IllegalArgumentException(); } @@ -338,7 +343,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, .get(component); if (Caption.isNeeded(uidl)) { if (wrapper == null) { - String loc = getLocation((Widget) component); + final String loc = getLocation((Widget) component); super.remove((Widget) component); wrapper = new CaptionWrapper(component, client); super.add(wrapper, (Element) locationToElement.get(loc)); @@ -347,7 +352,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, wrapper.updateCaption(uidl); } else { if (wrapper != null) { - String loc = getLocation((Widget) component); + final String loc = getLocation((Widget) component); super.remove(wrapper); super.add((Widget) wrapper.getPaintable(), (Element) locationToElement.get(loc)); @@ -358,8 +363,9 @@ public class ICustomLayout extends ComplexPanel implements Paintable, /** Get the location of an widget */ public String getLocation(Widget w) { - for (Iterator i = locationToWidget.keySet().iterator(); i.hasNext();) { - String location = (String) i.next(); + for (final Iterator i = locationToWidget.keySet().iterator(); i + .hasNext();) { + final String location = (String) i.next(); if (locationToWidget.get(location) == w) { return location; } @@ -370,11 +376,12 @@ public class ICustomLayout extends ComplexPanel implements Paintable, /** Removes given widget from the layout */ public boolean remove(Widget w) { client.unregisterPaintable((Paintable) w); - String location = getLocation(w); + final String location = getLocation(w); if (location != null) { locationToWidget.remove(location); } - CaptionWrapper cw = (CaptionWrapper) widgetToCaptionWrapper.get(w); + final CaptionWrapper cw = (CaptionWrapper) widgetToCaptionWrapper + .get(w); if (cw != null) { widgetToCaptionWrapper.remove(w); return super.remove(cw); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java index b039ab22f7..069cd821b4 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.Date; @@ -59,11 +63,11 @@ public class IDateField extends FlowPanel implements Paintable { enabled = !uidl.getBooleanAttribute("disabled"); if (uidl.hasAttribute("locale")) { - String locale = uidl.getStringAttribute("locale"); + final String locale = uidl.getStringAttribute("locale"); try { dts.setLocale(locale); currentLocale = locale; - } catch (LocaleNotLoadedException e) { + } catch (final LocaleNotLoadedException e) { currentLocale = dts.getLocale(); // TODO redirect this to console System.out.println("Tried to use an unloaded locale \"" @@ -91,18 +95,18 @@ public class IDateField extends FlowPanel implements Paintable { currentResolution = newResolution; - int year = uidl.getIntVariable("year"); - int month = (currentResolution >= RESOLUTION_MONTH) ? uidl + final int year = uidl.getIntVariable("year"); + final int month = (currentResolution >= RESOLUTION_MONTH) ? uidl .getIntVariable("month") : -1; - int day = (currentResolution >= RESOLUTION_DAY) ? uidl + final int day = (currentResolution >= RESOLUTION_DAY) ? uidl .getIntVariable("day") : -1; - int hour = (currentResolution >= RESOLUTION_HOUR) ? uidl + final int hour = (currentResolution >= RESOLUTION_HOUR) ? uidl .getIntVariable("hour") : -1; - int min = (currentResolution >= RESOLUTION_MIN) ? uidl + final int min = (currentResolution >= RESOLUTION_MIN) ? uidl .getIntVariable("min") : -1; - int sec = (currentResolution >= RESOLUTION_SEC) ? uidl + final int sec = (currentResolution >= RESOLUTION_SEC) ? uidl .getIntVariable("sec") : -1; - int msec = (currentResolution >= RESOLUTION_MSEC) ? uidl + final int msec = (currentResolution >= RESOLUTION_MSEC) ? uidl .getIntVariable("msec") : -1; // Construct new date for this datefield (only if not null) @@ -119,22 +123,22 @@ public class IDateField extends FlowPanel implements Paintable { */ private static native double getTime(int y, int m, int d, int h, int mi, int s, int ms) /*-{ - try { - var date = new Date(); - if(y && y >= 0) date.setFullYear(y); - if(m && m >= 1) date.setMonth(m-1); - if(d && d >= 0) date.setDate(d); - if(h && h >= 0) date.setHours(h); - if(mi && mi >= 0) date.setMinutes(mi); - if(s && s >= 0) date.setSeconds(s); - if(ms && ms >= 0) date.setMilliseconds(ms); - return date.getTime(); - } catch (e) { - // TODO print some error message on the console - //console.log(e); - return (new Date()).getTime(); - } - }-*/; + try { + var date = new Date(); + if(y && y >= 0) date.setFullYear(y); + if(m && m >= 1) date.setMonth(m-1); + if(d && d >= 0) date.setDate(d); + if(h && h >= 0) date.setHours(h); + if(mi && mi >= 0) date.setMinutes(mi); + if(s && s >= 0) date.setSeconds(s); + if(ms && ms >= 0) date.setMilliseconds(ms); + return date.getTime(); + } catch (e) { + // TODO print some error message on the console + //console.log(e); + return (new Date()).getTime(); + } + }-*/; public int getMilliseconds() { return (int) (date.getTime() - date.getTime() / 1000 * 1000); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java index 80d4bfde63..895b2c7858 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; @@ -5,7 +9,7 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL; public class IDateFieldCalendar extends IDateField { - private CalendarPanel date; + private final CalendarPanel date; public IDateFieldCalendar() { super(); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java index 3b4134ba20..97491aafdc 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -12,15 +16,15 @@ public class IEmbedded extends HTML implements Paintable { if (client.updateComponent(this, uidl, true)) { return; } - String w = uidl.hasAttribute("width") ? uidl + final String w = uidl.hasAttribute("width") ? uidl .getStringAttribute("width") : "100%"; - String h = uidl.hasAttribute("height") ? uidl + final String h = uidl.hasAttribute("height") ? uidl .getStringAttribute("height") : "100%"; DOM.setStyleAttribute(getElement(), "width", w); DOM.setStyleAttribute(getElement(), "height", h); if (uidl.hasAttribute("type")) { - String type = uidl.getStringAttribute("type"); + final String type = uidl.getStringAttribute("type"); if (type.equals("image")) { setHTML(""); } else if (type.equals("browser")) { @@ -31,7 +35,7 @@ public class IEmbedded extends HTML implements Paintable { "Unknown Embedded type '" + type + "'"); } } else if (uidl.hasAttribute("mimetype")) { - String mime = uidl.getStringAttribute("mimetype"); + final String mime = uidl.getStringAttribute("mimetype"); if (mime.equals("application/x-shockwave-flash")) { setHTML("= 0) { remove(index); insert(to, index); @@ -518,7 +526,7 @@ public class IExpandLayout extends ComplexPanel implements if (Caption.isNeeded(uidl)) { if (c == null) { - int index = getWidgetIndex((Widget) component); + final int index = getWidgetIndex((Widget) component); c = new Caption(component, client); insert(c, index); componentToCaption.put(component, c); @@ -571,10 +579,10 @@ public class IExpandLayout extends ComplexPanel implements hasComponentSpacing = uidl.getBooleanAttribute("spacing"); - ArrayList uidlWidgets = new ArrayList(); - for (Iterator it = uidl.getChildIterator(); it.hasNext();) { - UIDL cellUidl = (UIDL) it.next(); - Widget child = client.getWidget(cellUidl.getChildUIDL(0)); + final ArrayList uidlWidgets = new ArrayList(); + for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + final UIDL cellUidl = (UIDL) it.next(); + final Widget child = client.getWidget(cellUidl.getChildUIDL(0)); uidlWidgets.add(child); if (cellUidl.hasAttribute("expanded")) { expandedWidget = child; @@ -582,16 +590,16 @@ public class IExpandLayout extends ComplexPanel implements } } - ArrayList oldWidgets = getPaintables(); + final ArrayList oldWidgets = getPaintables(); - Iterator oldIt = oldWidgets.iterator(); - Iterator newIt = uidlWidgets.iterator(); - Iterator newUidl = uidl.getChildIterator(); + final Iterator oldIt = oldWidgets.iterator(); + final Iterator newIt = uidlWidgets.iterator(); + final Iterator newUidl = uidl.getChildIterator(); Widget oldChild = null; while (newIt.hasNext()) { - Widget child = (Widget) newIt.next(); - UIDL childUidl = ((UIDL) newUidl.next()).getChildUIDL(0); + final Widget child = (Widget) newIt.next(); + final UIDL childUidl = ((UIDL) newUidl.next()).getChildUIDL(0); if (oldChild == null && oldIt.hasNext()) { // search for next old Paintable which still exists in layout // and delete others @@ -626,7 +634,7 @@ public class IExpandLayout extends ComplexPanel implements insert(child, index); } else { // insert new child before old one - int index = getWidgetIndex(oldChild); + final int index = getWidgetIndex(oldChild); insert(child, index); } if (child != expandedWidget) { @@ -636,7 +644,7 @@ public class IExpandLayout extends ComplexPanel implements // remove possibly remaining old Paintable object which were not updated while (oldIt.hasNext()) { oldChild = (Widget) oldIt.next(); - Paintable p = (Paintable) oldChild; + final Paintable p = (Paintable) oldChild; if (!uidlWidgets.contains(p)) { removePaintable(p); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java index 48991eec3b..4a1a617f5c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.ArrayList; @@ -37,8 +41,8 @@ public class IFilterSelect extends Composite implements Paintable, public class FilterSelectSuggestion implements Suggestion, Command { - private String key; - private String caption; + private final String key; + private final String caption; private String iconUri; public FilterSelectSuggestion(UIDL uidl) { @@ -51,7 +55,7 @@ public class IFilterSelect extends Composite implements Paintable, } public String getDisplayString() { - StringBuffer sb = new StringBuffer(); + final StringBuffer sb = new StringBuffer(); if (iconUri != null) { sb.append("Prev"); DOM.sinkEvents(up, Event.ONCLICK); @@ -122,12 +126,12 @@ public class IFilterSelect extends Composite implements Paintable, public void showSuggestions(Collection currentSuggestions, int currentPage, int totalSuggestions) { menu.setSuggestions(currentSuggestions); - int x = IFilterSelect.this.getAbsoluteLeft(); + final int x = IFilterSelect.this.getAbsoluteLeft(); int y = tb.getAbsoluteTop(); y += tb.getOffsetHeight(); setPopupPosition(x, y); - int first = currentPage * PAGELENTH + 1; - int last = first + currentSuggestions.size() - 1; + final int first = currentPage * PAGELENTH + 1; + final int last = first + currentSuggestions.size() - 1; DOM.setInnerText(status, (totalSuggestions == 0 ? 0 : first) + "-" + last + "/" + totalSuggestions); setPrevButtonActive(first > 1); @@ -168,10 +172,10 @@ public class IFilterSelect extends Composite implements Paintable, } public void selectNextItem() { - MenuItem cur = menu.getSelectedItem(); - int index = 1 + menu.getItems().indexOf(cur); + final MenuItem cur = menu.getSelectedItem(); + final int index = 1 + menu.getItems().indexOf(cur); if (menu.getItems().size() > index) { - MenuItem newSelectedItem = (MenuItem) menu.getItems() + final MenuItem newSelectedItem = (MenuItem) menu.getItems() .get(index); menu.selectItem(newSelectedItem); tb.setText(newSelectedItem.getText()); @@ -185,10 +189,10 @@ public class IFilterSelect extends Composite implements Paintable, } public void selectPrevItem() { - MenuItem cur = menu.getSelectedItem(); - int index = -1 + menu.getItems().indexOf(cur); + final MenuItem cur = menu.getSelectedItem(); + final int index = -1 + menu.getItems().indexOf(cur); if (index > -1) { - MenuItem newSelectedItem = (MenuItem) menu.getItems() + final MenuItem newSelectedItem = (MenuItem) menu.getItems() .get(index); menu.selectItem(newSelectedItem); tb.setText(newSelectedItem.getText()); @@ -200,8 +204,8 @@ public class IFilterSelect extends Composite implements Paintable, filterOptions(currentPage - 1); } } else { - MenuItem newSelectedItem = (MenuItem) menu.getItems().get( - menu.getItems().size() - 1); + final MenuItem newSelectedItem = (MenuItem) menu.getItems() + .get(menu.getItems().size() - 1); menu.selectItem(newSelectedItem); tb.setText(newSelectedItem.getText()); tb.setSelectionRange(lastFilter.length(), newSelectedItem @@ -211,7 +215,7 @@ public class IFilterSelect extends Composite implements Paintable, } public void onBrowserEvent(Event event) { - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (DOM.compare(target, up) || DOM.compare(target, DOM.getChild(up, 0))) { filterOptions(currentPage - 1, lastFilter); @@ -257,7 +261,7 @@ public class IFilterSelect extends Composite implements Paintable, } offsetHeight = getOffsetHeight(); - int desiredWidth = IFilterSelect.this.getOffsetWidth(); + final int desiredWidth = IFilterSelect.this.getOffsetWidth(); int naturalMenuWidth = DOM.getElementPropertyInt(DOM .getFirstChild(menu.getElement()), "offsetWidth"); if (naturalMenuWidth < desiredWidth) { @@ -305,7 +309,7 @@ public class IFilterSelect extends Composite implements Paintable, * @return true if popup was just closed */ public boolean isJustClosed() { - long now = (new Date()).getTime(); + final long now = (new Date()).getTime(); return (lastAutoClosed > 0 && (now - lastAutoClosed) < 200); } @@ -329,17 +333,18 @@ public class IFilterSelect extends Composite implements Paintable, * to avoid height changes when quickly "scrolling" to last page */ public void fixHeightTo(int pagelenth) { - int pixels = pagelenth * (getOffsetHeight() - 2) + final int pixels = pagelenth * (getOffsetHeight() - 2) / currentSuggestions.size(); setHeight((pixels + 2) + "px"); } public void setSuggestions(Collection suggestions) { clearItems(); - Iterator it = suggestions.iterator(); + final Iterator it = suggestions.iterator(); while (it.hasNext()) { - FilterSelectSuggestion s = (FilterSelectSuggestion) it.next(); - MenuItem mi = new MenuItem(s.getDisplayString(), true, s); + final FilterSelectSuggestion s = (FilterSelectSuggestion) it + .next(); + final MenuItem mi = new MenuItem(s.getDisplayString(), true, s); this.addItem(mi); if (s == currentSuggestion) { selectItem(mi); @@ -348,16 +353,17 @@ public class IFilterSelect extends Composite implements Paintable, } public void doSelectedItemAction() { - MenuItem item = getSelectedItem(); + final MenuItem item = getSelectedItem(); if (item != null && item.getText().toLowerCase().startsWith( lastFilter.toLowerCase())) { doItemAction(item, true); } else if (allowNewItem) { - String newItemValue = tb.getText(); + final String newItemValue = tb.getText(); // check for exact match in menu if (getItems().size() == 1) { - MenuItem potentialExactMatch = (MenuItem) getItems().get(0); + final MenuItem potentialExactMatch = (MenuItem) getItems() + .get(0); if (potentialExactMatch.getText().equals(newItemValue)) { selectItem(potentialExactMatch); doSelectedItemAction(); @@ -399,7 +405,7 @@ public class IFilterSelect extends Composite implements Paintable, private int currentPage; - private Collection currentSuggestions = new ArrayList(); + private final Collection currentSuggestions = new ArrayList(); private boolean immediate; @@ -461,9 +467,10 @@ public class IFilterSelect extends Composite implements Paintable, } if (clientSideFiltering) { currentSuggestions.clear(); - for (Iterator it = allSuggestions.iterator(); it.hasNext();) { - FilterSelectSuggestion s = (FilterSelectSuggestion) it.next(); - String string = s.getDisplayString().toLowerCase(); + for (final Iterator it = allSuggestions.iterator(); it.hasNext();) { + final FilterSelectSuggestion s = (FilterSelectSuggestion) it + .next(); + final String string = s.getDisplayString().toLowerCase(); if (string.startsWith(filter.toLowerCase())) { currentSuggestions.add(s); } @@ -512,7 +519,7 @@ public class IFilterSelect extends Composite implements Paintable, allowNewItem = uidl.hasAttribute("allownewitem"); currentSuggestions.clear(); - UIDL options = uidl.getChildUIDL(0); + final UIDL options = uidl.getChildUIDL(0); totalSuggestions = uidl.getIntAttribute("totalitems"); totalMatches = uidl.getIntAttribute("totalMatches"); @@ -520,9 +527,9 @@ public class IFilterSelect extends Composite implements Paintable, if (clientSideFiltering) { allSuggestions = new ArrayList(); } - for (Iterator i = options.getChildIterator(); i.hasNext();) { - UIDL optionUidl = (UIDL) i.next(); - FilterSelectSuggestion suggestion = new FilterSelectSuggestion( + for (final Iterator i = options.getChildIterator(); i.hasNext();) { + final UIDL optionUidl = (UIDL) i.next(); + final FilterSelectSuggestion suggestion = new FilterSelectSuggestion( optionUidl); currentSuggestions.add(suggestion); if (clientSideFiltering) { @@ -547,8 +554,8 @@ public class IFilterSelect extends Composite implements Paintable, } // Calculate minumum textarea width - int minw = minWidth(captions); - Element spacer = DOM.createDiv(); + final int minw = minWidth(captions); + final Element spacer = DOM.createDiv(); DOM.setStyleAttribute(spacer, "width", minw + "px"); DOM.setStyleAttribute(spacer, "height", "0"); DOM.setStyleAttribute(spacer, "overflow", "hidden"); @@ -674,25 +681,25 @@ public class IFilterSelect extends Composite implements Paintable, * Calculate minumum width for FilterSelect textarea */ private native int minWidth(String captions) /*-{ - if(!captions || captions.length <= 0) - return 0; - captions = captions.split("|"); - var d = $wnd.document.createElement("div"); - var html = ""; - for(var i=0; i < captions.length; i++) { - html += "
" + captions[i] + "
"; - // TODO apply same CSS classname as in suggestionmenu - } - d.style.position = "absolute"; - d.style.top = "0"; - d.style.left = "0"; - d.style.visibility = "hidden"; - d.innerHTML = html; - $wnd.document.body.appendChild(d); - var w = d.offsetWidth; - $wnd.document.body.removeChild(d); - return w; - }-*/; + if(!captions || captions.length <= 0) + return 0; + captions = captions.split("|"); + var d = $wnd.document.createElement("div"); + var html = ""; + for(var i=0; i < captions.length; i++) { + html += "
" + captions[i] + "
"; + // TODO apply same CSS classname as in suggestionmenu + } + d.style.position = "absolute"; + d.style.top = "0"; + d.style.left = "0"; + d.style.visibility = "hidden"; + d.innerHTML = html; + $wnd.document.body.appendChild(d); + var w = d.offsetWidth; + $wnd.document.body.removeChild(d); + return w; + }-*/; public void onFocus(Widget sender) { // NOP diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java index df883927fb..1ae36d5cc8 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.ui.SimplePanel; @@ -27,7 +31,7 @@ public class IForm extends SimplePanel implements Paintable { return; } - UIDL layoutUidl = uidl.getChildUIDL(0); + final UIDL layoutUidl = uidl.getChildUIDL(0); if (lo == null) { lo = (Container) client.getWidget(layoutUidl); setWidget((Widget) lo); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java index 7aa87bfc1e..fd273174e3 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.HashMap; @@ -27,16 +31,16 @@ public class IFormLayout extends FlexTable implements Container { } int i = 0; - for (Iterator it = uidl.getChildIterator(); it.hasNext(); i++) { + for (final Iterator it = uidl.getChildIterator(); it.hasNext(); i++) { prepareCell(i, 1); - UIDL childUidl = (UIDL) it.next(); - Paintable p = (Paintable) client.getWidget(childUidl); + final UIDL childUidl = (UIDL) it.next(); + final Paintable p = (Paintable) client.getWidget(childUidl); Caption c = (Caption) componentToCaption.get(p); if (c == null) { c = new Caption(p, client); componentToCaption.put(p, c); } - Paintable oldComponent = (Paintable) getWidget(i, 1); + final Paintable oldComponent = (Paintable) getWidget(i, 1); if (oldComponent == null) { setWidget(i, 1, (Widget) p); } else if (oldComponent != p) { @@ -48,7 +52,7 @@ public class IFormLayout extends FlexTable implements Container { } i++; while (getRowCount() > i) { - Paintable p = (Paintable) getWidget(i, 1); + final Paintable p = (Paintable) getWidget(i, 1); client.unregisterPaintable(p); componentToCaption.remove(p); removeRow(i); @@ -63,7 +67,8 @@ public class IFormLayout extends FlexTable implements Container { int i; for (i = 0; i < getRowCount(); i++) { if (oldComponent == getWidget(i, 1)) { - Caption newCap = new Caption((Paintable) newComponent, client); + final Caption newCap = new Caption((Paintable) newComponent, + client); setWidget(i, 0, newCap); setWidget(i, 1, newComponent); client.unregisterPaintable((Paintable) oldComponent); @@ -73,7 +78,7 @@ public class IFormLayout extends FlexTable implements Container { } public void updateCaption(Paintable component, UIDL uidl) { - Caption c = (Caption) componentToCaption.get(component); + final Caption c = (Caption) componentToCaption.get(component); if (c != null) { c.updateCaption(uidl); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java index 0cac2d7f9d..074917c2f0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.ArrayList; @@ -18,7 +22,7 @@ public class IGridLayout extends FlexTable implements Paintable, Container { public static final String CLASSNAME = "i-gridlayout"; /** Widget to captionwrapper map */ - private HashMap widgetToCaptionWrapper = new HashMap(); + private final HashMap widgetToCaptionWrapper = new HashMap(); public IGridLayout() { super(); @@ -36,18 +40,18 @@ public class IGridLayout extends FlexTable implements Paintable, Container { } int row = 0, column = 0; - ArrayList oldWidgetWrappers = new ArrayList(); - for (Iterator iterator = iterator(); iterator.hasNext();) { + final ArrayList oldWidgetWrappers = new ArrayList(); + for (final Iterator iterator = iterator(); iterator.hasNext();) { oldWidgetWrappers.add(iterator.next()); } clear(); - for (Iterator i = uidl.getChildIterator(); i.hasNext();) { - UIDL r = (UIDL) i.next(); + for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + final UIDL r = (UIDL) i.next(); if ("gr".equals(r.getTag())) { column = 0; - for (Iterator j = r.getChildIterator(); j.hasNext();) { - UIDL c = (UIDL) j.next(); + for (final Iterator j = r.getChildIterator(); j.hasNext();) { + final UIDL c = (UIDL) j.next(); if ("gc".equals(c.getTag())) { prepareCell(row, column); @@ -76,9 +80,9 @@ public class IGridLayout extends FlexTable implements Paintable, Container { ((FlexCellFormatter) getCellFormatter()).setRowSpan( row, column, h); - UIDL u = c.getChildUIDL(0); + final UIDL u = c.getChildUIDL(0); if (u != null) { - Widget child = client.getWidget(u); + final Widget child = client.getWidget(u); CaptionWrapper wr; if (widgetToCaptionWrapper.containsKey(child)) { wr = (CaptionWrapper) widgetToCaptionWrapper @@ -104,8 +108,8 @@ public class IGridLayout extends FlexTable implements Paintable, Container { } // loop oldWidgetWrappers that where not re-attached and unregister them - for (Iterator it = oldWidgetWrappers.iterator(); it.hasNext();) { - CaptionWrapper w = (CaptionWrapper) it.next(); + for (final Iterator it = oldWidgetWrappers.iterator(); it.hasNext();) { + final CaptionWrapper w = (CaptionWrapper) it.next(); client.unregisterPaintable(w.getPaintable()); widgetToCaptionWrapper.remove(w.getPaintable()); } @@ -124,7 +128,7 @@ public class IGridLayout extends FlexTable implements Paintable, Container { } public void updateCaption(Paintable component, UIDL uidl) { - CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper + final CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper .get(component); wrapper.updateCaption(uidl); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalExpandLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalExpandLayout.java index f3dc055b29..80ea9b945c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalExpandLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalExpandLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; public class IHorizontalExpandLayout extends IExpandLayout { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java index 588e6f21a6..15e1eab9ef 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.ui.HTML; @@ -25,7 +29,7 @@ public class ILabel extends HTML implements Paintable { return; } - String mode = uidl.getStringAttribute("mode"); + final String mode = uidl.getStringAttribute("mode"); if (mode == null || "text".equals(mode)) { setText(uidl.getChildString(0)); } else if ("pre".equals(mode)) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java index 3cc0e61fb0..690321f55b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -36,7 +40,7 @@ public class ILink extends HTML implements Paintable, ClickListener { private Element errorIndicatorElement; - private Element captionElement = DOM.createSpan(); + private final Element captionElement = DOM.createSpan(); private ErrorMessage errorMessage; @@ -86,7 +90,7 @@ public class ILink extends HTML implements Paintable, ClickListener { // handle error if (uidl.hasAttribute("error")) { - UIDL errorUidl = uidl.getErrors(); + final UIDL errorUidl = uidl.getErrors(); if (errorIndicatorElement == null) { errorIndicatorElement = DOM.createDiv(); DOM.setElementProperty(errorIndicatorElement, "className", @@ -151,7 +155,7 @@ public class ILink extends HTML implements Paintable, ClickListener { } public void onBrowserEvent(Event event) { - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (errorIndicatorElement != null && DOM.compare(target, errorIndicatorElement)) { switch (DOM.eventGetType(event)) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IListSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IListSelect.java index 43dfb3fa21..18bd6e15a2 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IListSelect.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IListSelect.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.Iterator; @@ -35,8 +39,8 @@ public class IListSelect extends IOptionGroupBase { // can't unselect last item in singleselect mode select.addItem("", null); } - for (Iterator i = uidl.getChildIterator(); i.hasNext();) { - UIDL optionUidl = (UIDL) i.next(); + for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + final UIDL optionUidl = (UIDL) i.next(); select.addItem(optionUidl.getStringAttribute("caption"), optionUidl .getStringAttribute("key")); if (optionUidl.hasAttribute("selected")) { @@ -49,7 +53,7 @@ public class IListSelect extends IOptionGroupBase { } protected Object[] getSelectedItems() { - Vector selectedItemKeys = new Vector(); + final Vector selectedItemKeys = new Vector(); for (int i = 0; i < select.getItemCount(); i++) { if (select.isItemSelected(i)) { selectedItemKeys.add(select.getValue(i)); @@ -59,7 +63,7 @@ public class IListSelect extends IOptionGroupBase { } public void onChange(Widget sender) { - int si = select.getSelectedIndex(); + final int si = select.getSelectedIndex(); if (si == -1 && !isNullSelectionAllowed()) { select.setSelectedIndex(lastSelectedIndex); } else { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java index 95c954a4c0..d908109795 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/INativeSelect.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.Iterator; @@ -29,8 +33,8 @@ public class INativeSelect extends IOptionGroupBase { // can't unselect last item in singleselect mode select.addItem("", null); } - for (Iterator i = uidl.getChildIterator(); i.hasNext();) { - UIDL optionUidl = (UIDL) i.next(); + for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + final UIDL optionUidl = (UIDL) i.next(); select.addItem(optionUidl.getStringAttribute("caption"), optionUidl .getStringAttribute("key")); if (optionUidl.hasAttribute("selected")) { @@ -40,7 +44,7 @@ public class INativeSelect extends IOptionGroupBase { } protected Object[] getSelectedItems() { - Vector selectedItemKeys = new Vector(); + final Vector selectedItemKeys = new Vector(); for (int i = 0; i < select.getItemCount(); i++) { if (select.isItemSelected(i)) { selectedItemKeys.add(select.getValue(i)); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java index b10ff673c9..5120d913ec 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.HashMap; @@ -14,9 +18,9 @@ public class IOptionGroup extends IOptionGroupBase { public static final String CLASSNAME = "i-select-optiongroup"; - private Panel panel; + private final Panel panel; - private Map optionsToKeys; + private final Map optionsToKeys; public IOptionGroup() { super(CLASSNAME); @@ -29,8 +33,8 @@ public class IOptionGroup extends IOptionGroupBase { */ protected void buildOptions(UIDL uidl) { panel.clear(); - for (Iterator it = uidl.getChildIterator(); it.hasNext();) { - UIDL opUidl = (UIDL) it.next(); + for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + final UIDL opUidl = (UIDL) it.next(); CheckBox op; if (isMultiselect()) { op = new ICheckBox(); @@ -56,8 +60,8 @@ public class IOptionGroup extends IOptionGroupBase { public void onClick(Widget sender) { super.onClick(sender); if (sender instanceof CheckBox) { - boolean selected = ((CheckBox) sender).isChecked(); - String key = (String) optionsToKeys.get(sender); + final boolean selected = ((CheckBox) sender).isChecked(); + final String key = (String) optionsToKeys.get(sender); if (!isMultiselect()) { selectedKeys.clear(); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java index baedab7f1a..5c77ac33c4 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.Set; @@ -49,7 +53,7 @@ abstract class IOptionGroupBase extends Composite implements Paintable, /** * Panel containing the component */ - private Panel container; + private final Panel container; private ITextField newItemField; @@ -133,7 +137,7 @@ abstract class IOptionGroupBase extends Composite implements Paintable, cols = uidl.getIntAttribute("cols"); rows = uidl.getIntAttribute("rows"); - UIDL ops = uidl.getChildUIDL(0); + final UIDL ops = uidl.getChildUIDL(0); if (getColumns() > 0) { container.setWidth(getColumns() + "em"); @@ -208,7 +212,7 @@ abstract class IOptionGroupBase extends Composite implements Paintable, protected abstract Object[] getSelectedItems(); protected Object getSelectedItem() { - Object[] sel = getSelectedItems(); + final Object[] sel = getSelectedItems(); if (sel.length > 0) { return sel[0]; } else { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java index 0110f517a3..6d7edeaf74 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.ArrayList; @@ -63,7 +67,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { size = DOM.createDiv(); DOM.setInnerHTML(size, structure); margin = DOM.getFirstChild(size); - Element tBody = DOM.getFirstChild(DOM.getFirstChild(margin)); + final Element tBody = DOM.getFirstChild(DOM.getFirstChild(margin)); if (orientationMode == ORIENTATION_HORIZONTAL) { childContainer = DOM.createTR(); DOM.appendChild(tBody, childContainer); @@ -103,23 +107,23 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { // Update contained components - ArrayList uidlWidgets = new ArrayList(); - for (Iterator it = uidl.getChildIterator(); it.hasNext();) { - UIDL uidlForChild = (UIDL) it.next(); - Widget child = client.getWidget(uidlForChild); + final ArrayList uidlWidgets = new ArrayList(); + for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + final UIDL uidlForChild = (UIDL) it.next(); + final Widget child = client.getWidget(uidlForChild); uidlWidgets.add(child); } - ArrayList oldWidgets = getPaintables(); + final ArrayList oldWidgets = getPaintables(); - Iterator oldIt = oldWidgets.iterator(); - Iterator newIt = uidlWidgets.iterator(); - Iterator newUidl = uidl.getChildIterator(); + final Iterator oldIt = oldWidgets.iterator(); + final Iterator newIt = uidlWidgets.iterator(); + final Iterator newUidl = uidl.getChildIterator(); Widget oldChild = null; while (newIt.hasNext()) { - Widget child = (Widget) newIt.next(); - UIDL childUidl = (UIDL) newUidl.next(); + final Widget child = (Widget) newIt.next(); + final UIDL childUidl = (UIDL) newUidl.next(); if (oldChild == null && oldIt.hasNext()) { // search for next old Paintable which still exists in layout @@ -155,7 +159,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { this.insert(child, index); } else { // insert new child before old one - int index = getWidgetIndex(oldChild); + final int index = getWidgetIndex(oldChild); insert(child, index); } ((Paintable) child).updateFromUIDL(childUidl, client); @@ -163,7 +167,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { // remove possibly remaining old Paintable object which were not updated while (oldIt.hasNext()) { oldChild = (Widget) oldIt.next(); - Paintable p = (Paintable) oldChild; + final Paintable p = (Paintable) oldChild; if (!uidlWidgets.contains(p)) { removePaintable(p); } @@ -183,10 +187,10 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { * @return list of Paintable objects */ protected ArrayList getPaintables() { - ArrayList al = new ArrayList(); - Iterator it = iterator(); + final ArrayList al = new ArrayList(); + final Iterator it = iterator(); while (it.hasNext()) { - Widget w = (Widget) it.next(); + final Widget w = (Widget) it.next(); if (w instanceof Paintable) { al.add(w); } @@ -203,7 +207,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { * Paintable to be removed */ public boolean removePaintable(Paintable p) { - Caption c = (Caption) componentToCaption.get(p); + final Caption c = (Caption) componentToCaption.get(p); if (c != null) { componentToCaption.remove(c); remove(c); @@ -220,12 +224,12 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { */ public void replaceChildComponent(Widget from, Widget to) { client.unregisterPaintable((Paintable) from); - Caption c = (Caption) componentToCaption.get(from); + final Caption c = (Caption) componentToCaption.get(from); if (c != null) { remove(c); componentToCaption.remove(c); } - int index = getWidgetIndex(from); + final int index = getWidgetIndex(from); if (index >= 0) { remove(index); insert(to, index); @@ -234,16 +238,16 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { protected void insert(Widget w, int beforeIndex) { if (w instanceof Caption) { - Caption c = (Caption) w; + final Caption c = (Caption) w; // captions go into same container element as their // owners - Element container = DOM.getParent(((UIObject) c.getOwner()) + final Element container = DOM.getParent(((UIObject) c.getOwner()) .getElement()); - Element captionContainer = DOM.createDiv(); + final Element captionContainer = DOM.createDiv(); DOM.insertChild(container, captionContainer, 0); insert(w, captionContainer, beforeIndex, false); } else { - Element wrapper = createWidgetWrappper(); + final Element wrapper = createWidgetWrappper(); DOM.insertChild(childContainer, wrapper, beforeIndex); insert(w, getWidgetContainerFromWrapper(wrapper), beforeIndex, false); @@ -263,7 +267,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { * creates an Element which will contain child widget */ protected Element createWidgetWrappper() { - Element td = DOM.createTD(); + final Element td = DOM.createTD(); // We need this overflow:hidden, because it's the default rendering of // IE (although it can be overridden with overflow:visible). DOM.setStyleAttribute(td, "overflow", "hidden"); @@ -271,7 +275,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { case ORIENTATION_HORIZONTAL: return td; default: - Element tr = DOM.createTR(); + final Element tr = DOM.createTR(); DOM.appendChild(tr, td); return tr; } @@ -287,7 +291,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { if (Caption.isNeeded(uidl)) { if (c == null) { - int index = getWidgetIndex((Widget) component); + final int index = getWidgetIndex((Widget) component); c = new Caption(component, client); insert(c, index); componentToCaption.put(component, c); @@ -302,7 +306,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { } public void removeCaption(Widget w) { - Caption c = (Caption) componentToCaption.get(w); + final Caption c = (Caption) componentToCaption.get(w); if (c != null) { this.remove(c); componentToCaption.remove(w); @@ -310,7 +314,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { } public void add(Widget w) { - Element wrapper = createWidgetWrappper(); + final Element wrapper = createWidgetWrappper(); DOM.appendChild(childContainer, wrapper); super.add(w, orientationMode == ORIENTATION_HORIZONTAL ? wrapper : DOM .getFirstChild(wrapper)); @@ -321,8 +325,8 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { } public boolean remove(Widget w) { - Element wrapper = DOM.getParent(w.getElement()); - boolean removed = super.remove(w); + final Element wrapper = DOM.getParent(w.getElement()); + final boolean removed = super.remove(w); if (removed) { if (!(w instanceof Caption)) { DOM.removeChild(childContainer, @@ -349,8 +353,9 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { protected void handleMargins(UIDL uidl) { // Modify layout margins String marginClasses = ""; - MarginInfo margins = new MarginInfo(uidl.getIntAttribute("margins")); - Element topBottomMarginContainer = orientationMode == ORIENTATION_HORIZONTAL ? DOM + final MarginInfo margins = new MarginInfo(uidl + .getIntAttribute("margins")); + final Element topBottomMarginContainer = orientationMode == ORIENTATION_HORIZONTAL ? DOM .getParent(childContainer) : childContainer; // Top margin @@ -418,16 +423,17 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container { // Component alignments as a comma separated list. // See com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.java for // possible values. - int[] alignments = uidl.getIntArrayAttribute("alignments"); + final int[] alignments = uidl.getIntArrayAttribute("alignments"); int alignmentIndex = 0; // Insert alignment attributes - Iterator it = getPaintables().iterator(); + final Iterator it = getPaintables().iterator(); while (it.hasNext()) { // Calculate alignment info - AlignmentInfo ai = new AlignmentInfo(alignments[alignmentIndex++]); + final AlignmentInfo ai = new AlignmentInfo( + alignments[alignmentIndex++]); - Element td = DOM.getParent(((Widget) it.next()).getElement()); + final Element td = DOM.getParent(((Widget) it.next()).getElement()); if (Util.isIE()) { DOM .setElementAttribute(td, "vAlign", ai diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java index 34979948cc..340b001f20 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; public class IOrderedLayoutHorizontal extends IOrderedLayout { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java index 6f73b32830..1214c85421 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; public class IOrderedLayoutVertical extends IOrderedLayout { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java index 82db2235b4..6d5520ec06 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -21,15 +25,15 @@ public class IPanel extends SimplePanel implements Paintable, String id; - private Element captionNode = DOM.createDiv(); + private final Element captionNode = DOM.createDiv(); - private Element captionText = DOM.createSpan(); + private final Element captionText = DOM.createSpan(); private Icon icon; - private Element bottomDecoration = DOM.createDiv(); + private final Element bottomDecoration = DOM.createDiv(); - private Element contentNode = DOM.createDiv(); + private final Element contentNode = DOM.createDiv(); private Element errorIndicatorElement; @@ -74,8 +78,8 @@ public class IPanel extends SimplePanel implements Paintable, id = uidl.getId(); // Panel size. Height needs to be saved for later use - String w = uidl.hasVariable("width") ? uidl.getStringVariable("width") - : null; + final String w = uidl.hasVariable("width") ? uidl + .getStringVariable("width") : null; height = uidl.hasVariable("height") ? uidl.getStringVariable("height") : null; setWidth(w != null ? w : ""); @@ -111,11 +115,11 @@ public class IPanel extends SimplePanel implements Paintable, // Add proper stylenames for all elements. This way we can prevent // unwanted CSS selector inheritance. if (uidl.hasAttribute("style")) { - String[] styles = uidl.getStringAttribute("style").split(" "); - String captionBaseClass = CLASSNAME + final String[] styles = uidl.getStringAttribute("style").split(" "); + final String captionBaseClass = CLASSNAME + (hasCaption ? "-caption" : "-nocaption"); - String contentBaseClass = CLASSNAME + "-content"; - String decoBaseClass = CLASSNAME + "-deco"; + final String contentBaseClass = CLASSNAME + "-content"; + final String decoBaseClass = CLASSNAME + "-deco"; String captionClass = captionBaseClass; String contentClass = contentBaseClass; String decoClass = decoBaseClass; @@ -133,8 +137,8 @@ public class IPanel extends SimplePanel implements Paintable, iLayout(); // Render content - UIDL layoutUidl = uidl.getChildUIDL(0); - Widget newLayout = client.getWidget(layoutUidl); + final UIDL layoutUidl = uidl.getChildUIDL(0); + final Widget newLayout = client.getWidget(layoutUidl); if (newLayout != layout) { if (layout != null) { client.unregisterPaintable((Paintable) layout); @@ -148,7 +152,7 @@ public class IPanel extends SimplePanel implements Paintable, private void handleError(UIDL uidl) { if (uidl.hasAttribute("error")) { - UIDL errorUidl = uidl.getErrors(); + final UIDL errorUidl = uidl.getErrors(); if (errorIndicatorElement == null) { errorIndicatorElement = DOM.createDiv(); DOM.setElementProperty(errorIndicatorElement, "className", @@ -175,7 +179,7 @@ public class IPanel extends SimplePanel implements Paintable, } private void setIconUri(UIDL uidl, ApplicationConnection client) { - String iconUri = uidl.hasAttribute("icon") ? uidl + final String iconUri = uidl.hasAttribute("icon") ? uidl .getStringAttribute("icon") : null; if (iconUri == null) { if (icon != null) { @@ -193,7 +197,7 @@ public class IPanel extends SimplePanel implements Paintable, public void iLayout() { if (height != null && height != "") { - boolean hasChildren = getWidget() != null; + final boolean hasChildren = getWidget() != null; Element contentEl = null; String origPositioning = null; if (hasChildren) { @@ -209,11 +213,11 @@ public class IPanel extends SimplePanel implements Paintable, // Calculate target height super.setHeight(height); - int targetHeight = getOffsetHeight(); + final int targetHeight = getOffsetHeight(); // Calculate used height super.setHeight(""); - int usedHeight = DOM.getElementPropertyInt(bottomDecoration, + final int usedHeight = DOM.getElementPropertyInt(bottomDecoration, "offsetTop") + DOM.getElementPropertyInt(bottomDecoration, "offsetHeight") @@ -242,7 +246,7 @@ public class IPanel extends SimplePanel implements Paintable, } public void onBrowserEvent(Event event) { - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (errorIndicatorElement != null && DOM.compare(target, errorIndicatorElement)) { switch (DOM.eventGetType(event)) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java index c5576f7090..0690edff94 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java index abc1ae8199..a2113012b1 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.Window; @@ -12,11 +16,11 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL; public class IPopupCalendar extends ITextualDate implements Paintable, ClickListener, PopupListener { - private IButton calendarToggle; + private final IButton calendarToggle; - private CalendarPanel calendar; + private final CalendarPanel calendar; - private ToolkitOverlay popup; + private final ToolkitOverlay popup; private boolean open = false; public IPopupCalendar() { @@ -49,8 +53,8 @@ public class IPopupCalendar extends ITextualDate implements Paintable, // clear previous values popup.setWidth(""); popup.setHeight(""); - int w = calendar.getOffsetWidth(); - int h = calendar.getOffsetHeight(); + final int w = calendar.getOffsetWidth(); + final int h = calendar.getOffsetHeight(); int t = calendarToggle.getAbsoluteTop(); int l = calendarToggle.getAbsoluteLeft(); if (l + w > Window.getClientWidth() + Window.getScrollLeft()) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java index d77b792750..a0672e8623 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -14,7 +18,7 @@ public class IProgressIndicator extends Widget implements Paintable { Element wrapper = DOM.createDiv(); Element indicator = DOM.createDiv(); private ApplicationConnection client; - private Poller poller; + private final Poller poller; public IProgressIndicator() { setElement(wrapper); @@ -33,16 +37,17 @@ public class IProgressIndicator extends Widget implements Paintable { if (client.updateComponent(this, uidl, true)) { return; } - boolean indeterminate = uidl.getBooleanAttribute("indeterminate"); + final boolean indeterminate = uidl.getBooleanAttribute("indeterminate"); if (indeterminate) { // TODO put up some image or something } else { try { - float f = Float.parseFloat(uidl.getStringAttribute("state")); - int size = Math.round(100 * f); + final float f = Float.parseFloat(uidl + .getStringAttribute("state")); + final int size = Math.round(100 * f); DOM.setStyleAttribute(indicator, "width", size + "%"); - } catch (Exception e) { + } catch (final Exception e) { } } poller.scheduleRepeating(uidl.getIntAttribute("pollinginterval")); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java index aea371ce02..750cf34d2c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.HashMap; @@ -82,19 +86,19 @@ public class IScrollTable extends Composite implements Table, ScrollListener, private int selectMode = Table.SELECT_MODE_NONE; - private HashSet selectedRowKeys = new HashSet(); + private final HashSet selectedRowKeys = new HashSet(); private boolean initializedAndAttached = false; - private TableHead tHead = new TableHead(); + private final TableHead tHead = new TableHead(); - private ScrollPanel bodyContainer = new ScrollPanel(); + private final ScrollPanel bodyContainer = new ScrollPanel(); private int totalRows; private Set collapsedColumns; - private RowRequestHandler rowRequestHandler; + private final RowRequestHandler rowRequestHandler; private IScrollTableBody tBody; private String width; private String height; @@ -107,11 +111,11 @@ public class IScrollTable extends Composite implements Table, ScrollListener, * This map contains captions and icon urls for actions like: * "33_c" -> * "Edit" * "33_i" -> "http://dom.com/edit.png" */ - private HashMap actionMap = new HashMap(); + private final HashMap actionMap = new HashMap(); private String[] visibleColOrder; private boolean initialContentReceived = false; private Element scrollPositionElement; - private FlowPanel panel; + private final FlowPanel panel; private boolean enabled; private boolean showColHeaders; @@ -140,7 +144,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, this.client = client; paintableId = uidl.getStringAttribute("id"); immediate = uidl.getBooleanAttribute("immediate"); - int newTotalRows = uidl.getIntAttribute("totalrows"); + final int newTotalRows = uidl.getIntAttribute("totalrows"); if (newTotalRows != totalRows) { totalRows = newTotalRows; if (initializedAndAttached) { @@ -171,9 +175,10 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } if (uidl.hasVariable("selected")) { - Set selectedKeys = uidl.getStringArrayVariableAsSet("selected"); + final Set selectedKeys = uidl + .getStringArrayVariableAsSet("selected"); selectedRowKeys.clear(); - for (Iterator it = selectedKeys.iterator(); it.hasNext();) { + for (final Iterator it = selectedKeys.iterator(); it.hasNext();) { selectedRowKeys.add(it.next()); } } @@ -200,8 +205,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } UIDL rowData = null; - for (Iterator it = uidl.getChildIterator(); it.hasNext();) { - UIDL c = (UIDL) it.next(); + for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + final UIDL c = (UIDL) it.next(); if (c.getTag().equals("rows")) { rowData = c; } else if (c.getTag().equals("actions")) { @@ -230,19 +235,19 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } private void updateVisibleColumns(UIDL uidl) { - Iterator it = uidl.getChildIterator(); + final Iterator it = uidl.getChildIterator(); while (it.hasNext()) { - UIDL col = (UIDL) it.next(); + final UIDL col = (UIDL) it.next(); tHead.updateCellFromUIDL(col); } } private void updateActionMap(UIDL c) { - Iterator it = c.getChildIterator(); + final Iterator it = c.getChildIterator(); while (it.hasNext()) { - UIDL action = (UIDL) it.next(); - String key = action.getStringAttribute("key"); - String caption = action.getStringAttribute("caption"); + final UIDL action = (UIDL) it.next(); + final String key = action.getStringAttribute("key"); + final String caption = action.getStringAttribute("caption"); actionMap.put(key + "_c", caption); if (action.hasAttribute("icon")) { // TODO need some uri handling ?? @@ -280,7 +285,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } for (int i = 0; i < strings.length; i++) { - String cid = strings[i]; + final String cid = strings[i]; visibleColOrder[colIndex] = cid; tHead.enableColumn(cid, colIndex); colIndex++; @@ -312,13 +317,13 @@ public class IScrollTable extends Composite implements Table, ScrollListener, tBody.renderRows(uidl, firstRow, reqRows); - int optimalFirstRow = (int) (firstRowInViewPort - pageLength + final int optimalFirstRow = (int) (firstRowInViewPort - pageLength * CACHE_RATE); while (tBody.getFirstRendered() < optimalFirstRow) { // client.console.log("removing row from start"); tBody.unlinkRow(true); } - int optimalLastRow = (int) (firstRowInViewPort + pageLength + pageLength + final int optimalLastRow = (int) (firstRowInViewPort + pageLength + pageLength * CACHE_RATE); while (tBody.getLastRendered() > optimalLastRow) { // client.console.log("removing row from the end"); @@ -362,7 +367,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } private void setColWidth(int colIndex, int w) { - HeaderCell cell = tHead.getHeaderCell(colIndex); + final HeaderCell cell = tHead.getHeaderCell(colIndex); cell.setWidth(w); tBody.setColWidth(colIndex, w); } @@ -372,7 +377,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } private IScrollTableRow getRenderedRowByKey(String key) { - Iterator it = tBody.iterator(); + final Iterator it = tBody.iterator(); IScrollTableRow r = null; while (it.hasNext()) { r = (IScrollTableRow) it.next(); @@ -385,7 +390,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, private void reOrderColumn(String columnKey, int newIndex) { - int oldIndex = getColIndexByKey(columnKey); + final int oldIndex = getColIndexByKey(columnKey); // Change header order tHead.moveCell(oldIndex, newIndex); @@ -400,7 +405,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, * array unless on moved columnKey. On new index also put the moved key * i == index on columnOrder, j == index on newOrder */ - String oldKeyOnNewIndex = visibleColOrder[newIndex]; + final String oldKeyOnNewIndex = visibleColOrder[newIndex]; if (showRowHeaders) { newIndex--; // columnOrder don't have rowHeader } @@ -414,7 +419,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } } // finally we can build the new columnOrder for server - String[] newOrder = new String[columnOrder.length]; + final String[] newOrder = new String[columnOrder.length]; for (int i = 0, j = 0; j < newOrder.length; i++) { if (j == newIndex) { newOrder[j] = columnKey; @@ -433,7 +438,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, // also update visibleColumnOrder int i = showRowHeaders ? 1 : 0; for (int j = 0; j < newOrder.length; j++) { - String cid = newOrder[j]; + final String cid = newOrder[j]; if (!isCollapsedColumn(cid)) { visibleColOrder[i++] = cid; } @@ -453,7 +458,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, super.onDetach(); // ensure that scrollPosElement will be detached if (scrollPositionElement != null) { - Element parent = DOM.getParent(scrollPositionElement); + final Element parent = DOM.getParent(scrollPositionElement); if (parent != null) { DOM.removeChild(parent, scrollPositionElement); } @@ -481,20 +486,20 @@ public class IScrollTable extends Composite implements Table, ScrollListener, int totalExplicitColumnsWidths = 0; int total = 0; - int[] widths = new int[tHead.visibleCells.size()]; + final int[] widths = new int[tHead.visibleCells.size()]; // first loop: collect natural widths while (headCells.hasNext()) { - HeaderCell hCell = (HeaderCell) headCells.next(); + final HeaderCell hCell = (HeaderCell) headCells.next(); int w; if (hCell.getWidth() > 0) { // server has defined column width explicitly w = hCell.getWidth(); totalExplicitColumnsWidths += w; } else { - int hw = DOM.getElementPropertyInt(hCell.getElement(), + final int hw = DOM.getElementPropertyInt(hCell.getElement(), "offsetWidth"); - int cw = tBody.getColWidth(i); + final int cw = tBody.getColWidth(i); w = (hw > cw ? hw : cw) + IScrollTableBody.CELL_EXTRA_WIDTH; } widths[i] = w; @@ -539,8 +544,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, if (availW > total) { // natural size is smaller than available space - int extraSpace = availW - total; - int totalWidthR = total - totalExplicitColumnsWidths; + final int extraSpace = availW - total; + final int totalWidthR = total - totalExplicitColumnsWidths; if (totalWidthR > 0) { // now we will share this sum relatively to those without // explicit width @@ -551,7 +556,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, hCell = (HeaderCell) headCells.next(); if (hCell.getWidth() == -1) { int w = widths[i]; - int newSpace = extraSpace * w / totalWidthR; + final int newSpace = extraSpace * w / totalWidthR; w += newSpace; widths[i] = w; } @@ -566,9 +571,9 @@ public class IScrollTable extends Composite implements Table, ScrollListener, i = 0; headCells = tHead.iterator(); while (headCells.hasNext()) { - HeaderCell hCell = (HeaderCell) headCells.next(); + final HeaderCell hCell = (HeaderCell) headCells.next(); if (hCell.getWidth() == -1) { - int w = widths[i]; + final int w = widths[i]; setColWidth(i, w); } i++; @@ -655,8 +660,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, if (preLimit < 0) { preLimit = 0; } - int lastRendered = tBody.getLastRendered(); - int firstRendered = tBody.getFirstRendered(); + final int lastRendered = tBody.getLastRendered(); + final int firstRendered = tBody.getFirstRendered(); if (postLimit <= lastRendered && preLimit >= firstRendered) { client.updateVariable(paintableId, "firstvisible", @@ -822,7 +827,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, Element floatingCopyOfHeaderCell; private boolean sortable = false; - private String cid; + private final String cid; private boolean dragging; private int dragStartX; @@ -1016,7 +1021,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, createFloatingCopy(); moved = true; } - int x = DOM.eventGetClientX(event) + final int x = DOM.eventGetClientX(event) + DOM.getElementPropertyInt(tHead.hTableWrapper, "scrollLeft"); int slotX = headerX; @@ -1026,13 +1031,13 @@ public class IScrollTable extends Composite implements Table, ScrollListener, if (showRowHeaders) { start++; } - int visibleCellCount = tHead.getVisibleCellCount(); + final int visibleCellCount = tHead.getVisibleCellCount(); for (int i = start; i <= visibleCellCount; i++) { if (i > 0) { - String colKey = getColKeyByIndex(i - 1); + final String colKey = getColKeyByIndex(i - 1); slotX += getColWidth(colKey); } - int dist = Math.abs(x - slotX); + final int dist = Math.abs(x - slotX); if (closestDistance == -1 || dist < closestDistance) { closestDistance = dist; closestSlot = i; @@ -1065,7 +1070,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, break; case Event.ONMOUSEMOVE: if (isResizing) { - int deltaX = DOM.eventGetClientX(event) - dragStartX; + final int deltaX = DOM.eventGetClientX(event) - dragStartX; if (deltaX == 0) { return; } @@ -1147,7 +1152,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, Element headerTableBody = DOM.createTBody(); Element tr = DOM.createTR(); - private Element columnSelector = DOM.createDiv(); + private final Element columnSelector = DOM.createDiv(); private int focusedSlot = -1; @@ -1179,7 +1184,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } public void updateCellFromUIDL(UIDL col) { - String cid = col.getStringAttribute("cid"); + final String cid = col.getStringAttribute("cid"); HeaderCell c = getHeaderCell(cid); if (c == null) { c = new HeaderCell(cid, col.getStringAttribute("caption")); @@ -1200,14 +1205,14 @@ public class IScrollTable extends Composite implements Table, ScrollListener, c.setAlign(col.getStringAttribute("align").charAt(0)); } if (col.hasAttribute("width")) { - String width = col.getStringAttribute("width"); + final String width = col.getStringAttribute("width"); c.setWidth(Integer.parseInt(width)); } // TODO icon } public void enableColumn(String cid, int index) { - HeaderCell c = getHeaderCell(cid); + final HeaderCell c = getHeaderCell(cid); if (!c.isEnabled()) { setHeaderCell(index, c); } @@ -1275,8 +1280,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } public void moveCell(int oldIndex, int newIndex) { - HeaderCell hCell = getHeaderCell(oldIndex); - Element cell = hCell.getElement(); + final HeaderCell hCell = getHeaderCell(oldIndex); + final Element cell = hCell.getElement(); visibleCells.remove(oldIndex); DOM.removeChild(tr, cell); @@ -1300,7 +1305,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } public void removeCell(String colKey) { - HeaderCell c = getHeaderCell(colKey); + final HeaderCell c = getHeaderCell(colKey); remove(c); } @@ -1335,8 +1340,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, public void onBrowserEvent(Event event) { if (enabled) { if (DOM.compare(DOM.eventGetTarget(event), columnSelector)) { - int left = DOM.getAbsoluteLeft(columnSelector); - int top = DOM.getAbsoluteTop(columnSelector) + final int left = DOM.getAbsoluteLeft(columnSelector); + final int top = DOM.getAbsoluteTop(columnSelector) + DOM.getElementPropertyInt(columnSelector, "offsetHeight"); client.getContextMenu().showAt(this, left, top); @@ -1380,7 +1385,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, * Override default method to distinguish on/off columns */ public String getHTML() { - StringBuffer buf = new StringBuffer(); + final StringBuffer buf = new StringBuffer(); if (collapsed) { buf.append(""); } @@ -1410,16 +1415,18 @@ public class IScrollTable extends Composite implements Table, ScrollListener, for (i = 0; i < visibleColOrder.length; i++) { cols[i] = visibleColOrder[i]; } - for (Iterator it = collapsedColumns.iterator(); it.hasNext();) { + for (final Iterator it = collapsedColumns.iterator(); it + .hasNext();) { cols[i++] = it.next(); } } - Action[] actions = new Action[cols.length]; + final Action[] actions = new Action[cols.length]; for (int i = 0; i < cols.length; i++) { - String cid = (String) cols[i]; - HeaderCell c = getHeaderCell(cid); - VisibleColumnAction a = new VisibleColumnAction(c.getColKey()); + final String cid = (String) cols[i]; + final HeaderCell c = getHeaderCell(cid); + final VisibleColumnAction a = new VisibleColumnAction(c + .getColKey()); a.setCaption(c.getCaption()); if (!c.isEnabled()) { a.setCollapsed(true); @@ -1441,8 +1448,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, * Returns column alignments for visible columns */ public char[] getColumnAlignments() { - Iterator it = visibleCells.iterator(); - char[] aligns = new char[visibleCells.size()]; + final Iterator it = visibleCells.iterator(); + final char[] aligns = new char[visibleCells.size()]; int colIndex = 0; while (it.hasNext()) { aligns[colIndex++] = ((HeaderCell) it.next()).getAlign(); @@ -1468,7 +1475,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, private int rowHeight = -1; - private List renderedRows = new Vector(); + private final List renderedRows = new Vector(); private boolean initDone = false; @@ -1512,11 +1519,11 @@ public class IScrollTable extends Composite implements Table, ScrollListener, public void renderInitialRows(UIDL rowData, int firstIndex, int rows) { firstRendered = firstIndex; lastRendered = firstIndex + rows - 1; - Iterator it = rowData.getChildIterator(); + final Iterator it = rowData.getChildIterator(); aligns = tHead.getColumnAlignments(); while (it.hasNext()) { - IScrollTableRow row = new IScrollTableRow((UIDL) it.next(), - aligns); + final IScrollTableRow row = new IScrollTableRow((UIDL) it + .next(), aligns); addRow(row); } if (isAttached()) { @@ -1526,16 +1533,16 @@ public class IScrollTable extends Composite implements Table, ScrollListener, public void renderRows(UIDL rowData, int firstIndex, int rows) { aligns = tHead.getColumnAlignments(); - Iterator it = rowData.getChildIterator(); + final Iterator it = rowData.getChildIterator(); if (firstIndex == lastRendered + 1) { while (it.hasNext()) { - IScrollTableRow row = createRow((UIDL) it.next()); + final IScrollTableRow row = createRow((UIDL) it.next()); addRow(row); lastRendered++; } fixSpacers(); } else if (firstIndex + rows == firstRendered) { - IScrollTableRow[] rowArray = new IScrollTableRow[rows]; + final IScrollTableRow[] rowArray = new IScrollTableRow[rows]; int i = rows; while (it.hasNext()) { i--; @@ -1552,7 +1559,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, while (lastRendered + 1 > firstRendered) { unlinkRow(false); } - IScrollTableRow row = createRow((UIDL) it.next()); + final IScrollTableRow row = createRow((UIDL) it.next()); firstRendered = firstIndex; lastRendered = firstIndex - 1; addRow(row); @@ -1581,11 +1588,12 @@ public class IScrollTable extends Composite implements Table, ScrollListener, * @param uidl */ private IScrollTableRow createRow(UIDL uidl) { - IScrollTableRow row = new IScrollTableRow(uidl, aligns); - int cells = DOM.getChildCount(row.getElement()); + final IScrollTableRow row = new IScrollTableRow(uidl, aligns); + final int cells = DOM.getChildCount(row.getElement()); for (int i = 0; i < cells; i++) { - Element cell = DOM.getChild(row.getElement(), i); - int w = IScrollTable.this.getColWidth(getColKeyByIndex(i)); + final Element cell = DOM.getChild(row.getElement(), i); + final int w = IScrollTable.this + .getColWidth(getColKeyByIndex(i)); DOM.setStyleAttribute(DOM.getFirstChild(cell), "width", (w - CELL_CONTENT_PADDING) + "px"); DOM.setStyleAttribute(cell, "width", w + "px"); @@ -1642,7 +1650,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, index = renderedRows.size() - 1; lastRendered--; } - IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows + final IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows .get(index); client.unregisterChildPaintables(toBeRemoved); DOM.removeChild(tBody, toBeRemoved.getElement()); @@ -1698,7 +1706,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, public int getColWidth(int i) { if (initDone) { - Element e = DOM.getChild(DOM.getChild(tBody, 0), i); + final Element e = DOM.getChild(DOM.getChild(tBody, 0), i); return DOM.getElementPropertyInt(e, "offsetWidth"); } else { return 0; @@ -1706,9 +1714,10 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } public void setColWidth(int colIndex, int w) { - int rows = DOM.getChildCount(tBody); + final int rows = DOM.getChildCount(tBody); for (int i = 0; i < rows; i++) { - Element cell = DOM.getChild(DOM.getChild(tBody, i), colIndex); + final Element cell = DOM.getChild(DOM.getChild(tBody, i), + colIndex); DOM.setStyleAttribute(DOM.getFirstChild(cell), "width", (w - CELL_CONTENT_PADDING) + "px"); DOM.setStyleAttribute(cell, "width", w + "px"); @@ -1726,11 +1735,11 @@ public class IScrollTable extends Composite implements Table, ScrollListener, public void moveCol(int oldIndex, int newIndex) { // loop all rows and move given index to its new place - Iterator rows = iterator(); + final Iterator rows = iterator(); while (rows.hasNext()) { - IScrollTableRow row = (IScrollTableRow) rows.next(); + final IScrollTableRow row = (IScrollTableRow) rows.next(); - Element td = DOM.getChild(row.getElement(), oldIndex); + final Element td = DOM.getChild(row.getElement(), oldIndex); DOM.removeChild(row.getElement(), td); DOM.insertChild(row.getElement(), td, newIndex); @@ -1743,7 +1752,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, Vector childWidgets = new Vector(); private boolean selected = false; - private int rowKey; + private final int rowKey; private String[] actionKeys = null; @@ -1796,13 +1805,14 @@ public class IScrollTable extends Composite implements Table, ScrollListener, actionKeys = uidl.getStringArrayAttribute("al"); } - Iterator cells = uidl.getChildIterator(); + final Iterator cells = uidl.getChildIterator(); while (cells.hasNext()) { - Object cell = cells.next(); + final Object cell = cells.next(); if (cell instanceof String) { addCell(cell.toString(), aligns[col++]); } else { - Widget cellContent = client.getWidget((UIDL) cell); + final Widget cellContent = client + .getWidget((UIDL) cell); ((Paintable) cellContent).updateFromUIDL((UIDL) cell, client); addCell(cellContent, aligns[col++]); @@ -1815,8 +1825,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, public void addCell(String text, char align) { // String only content is optimized by not using Label widget - Element td = DOM.createTD(); - Element container = DOM.createDiv(); + final Element td = DOM.createTD(); + final Element container = DOM.createDiv(); DOM.setElementProperty(container, "className", CLASSNAME + "-cell-content"); DOM.setInnerHTML(container, text); @@ -1836,8 +1846,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } public void addCell(Widget w, char align) { - Element td = DOM.createTD(); - Element container = DOM.createDiv(); + final Element td = DOM.createTD(); + final Element container = DOM.createDiv(); DOM.setElementProperty(container, "className", CLASSNAME + "-cell-content"); // TODO make widget cells respect align. text-align:center for @@ -1864,7 +1874,8 @@ public class IScrollTable extends Composite implements Table, ScrollListener, public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONCLICK: - Element tdOrTr = DOM.getParent(DOM.eventGetTarget(event)); + final Element tdOrTr = DOM.getParent(DOM + .eventGetTarget(event)); if (DOM.compare(getElement(), tdOrTr) || DOM.compare(getElement(), DOM.getParent(tdOrTr))) { if (selectMode > Table.SELECT_MODE_NONE) { @@ -1919,11 +1930,11 @@ public class IScrollTable extends Composite implements Table, ScrollListener, if (actionKeys == null) { return new Action[] {}; } - Action[] actions = new Action[actionKeys.length]; + final Action[] actions = new Action[actionKeys.length]; for (int i = 0; i < actions.length; i++) { - String actionKey = actionKeys[i]; - TreeAction a = new TreeAction(this, String.valueOf(rowKey), - actionKey); + final String actionKey = actionKeys[i]; + final TreeAction a = new TreeAction(this, String + .valueOf(rowKey), actionKey); a.setCaption(getActionCaption(actionKey)); a.setIconUrl(getActionIcon(actionKey)); actions[i] = a; @@ -1942,9 +1953,9 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } public void deselectAll() { - Object[] keys = selectedRowKeys.toArray(); + final Object[] keys = selectedRowKeys.toArray(); for (int i = 0; i < keys.length; i++) { - IScrollTableRow row = getRenderedRowByKey((String) keys[i]); + final IScrollTableRow row = getRenderedRowByKey((String) keys[i]); if (row != null && row.isSelected()) { row.toggleSelection(); } @@ -1975,13 +1986,13 @@ public class IScrollTable extends Composite implements Table, ScrollListener, // workaround very common 100% height problem - extract borders if (height.equals("100%")) { final int borders = getBorderSpace(); - Element elem = getElement(); - Element parentElem = DOM.getParent(elem); + final Element elem = getElement(); + final Element parentElem = DOM.getParent(elem); // put table away from flow for a moment DOM.setStyleAttribute(getElement(), "position", "absolute"); // get containers natural space for table - int availPixels = DOM.getElementPropertyInt(parentElem, + final int availPixels = DOM.getElementPropertyInt(parentElem, "offsetHeight"); // put table back to flow DOM.setStyleAttribute(getElement(), "position", "static"); @@ -1998,7 +2009,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, } private int getBorderSpace() { - Element el = getElement(); + final Element el = getElement(); return DOM.getElementPropertyInt(el, "offsetHeight") - DOM.getElementPropertyInt(el, "clientHeight"); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java index 35608fdb91..f24ddf686f 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.Command; @@ -43,16 +47,16 @@ public class ISlider extends Widget implements Paintable, private boolean arrows; /* DOM element for slider's base */ - private Element base; + private final Element base; /* DOM element for slider's handle */ - private Element handle; + private final Element handle; /* DOM element for decrement arrow */ - private Element smaller; + private final Element smaller; /* DOM element for increment arrow */ - private Element bigger; + private final Element bigger; /* Temporary dragging/animation variables */ private boolean dragging = false; @@ -159,7 +163,7 @@ public class ISlider extends Widget implements Paintable, final String domProperty = vertical ? "offsetHeight" : "offsetWidth"; if (size == -1) { - Element p = DOM.getParent(getElement()); + final Element p = DOM.getParent(getElement()); if (DOM.getElementPropertyInt(p, domProperty) > 50) { if (vertical) { setHeight(); @@ -172,7 +176,7 @@ public class ISlider extends Widget implements Paintable, DOM.setStyleAttribute(base, styleAttribute, MIN_SIZE + "px"); DeferredCommand.addCommand(new Command() { public void execute() { - Element p = DOM.getParent(getElement()); + final Element p = DOM.getParent(getElement()); if (DOM.getElementPropertyInt(p, domProperty) > (MIN_SIZE + 5)) { if (vertical) { setHeight(); @@ -193,9 +197,9 @@ public class ISlider extends Widget implements Paintable, } private void buildHandle() { - String styleAttribute = vertical ? "height" : "width"; - String handleAttribute = vertical ? "marginTop" : "marginLeft"; - String domProperty = vertical ? "offsetHeight" : "offsetWidth"; + final String styleAttribute = vertical ? "height" : "width"; + final String handleAttribute = vertical ? "marginTop" : "marginLeft"; + final String domProperty = vertical ? "offsetHeight" : "offsetWidth"; DOM.setStyleAttribute(handle, handleAttribute, "0"); @@ -204,9 +208,9 @@ public class ISlider extends Widget implements Paintable, int s = (int) (Double.parseDouble(DOM.getElementProperty(base, domProperty)) / 100 * handleSize); if (handleSize == -1) { - int baseS = Integer.parseInt(DOM.getElementProperty(base, + final int baseS = Integer.parseInt(DOM.getElementProperty(base, domProperty)); - double range = (max - min) * (resolution + 1) * 3; + final double range = (max - min) * (resolution + 1) * 3; s = (int) (baseS - range); } if (s < 3) { @@ -231,14 +235,14 @@ public class ISlider extends Widget implements Paintable, // Update handle position final String styleAttribute = vertical ? "marginTop" : "marginLeft"; - String domProperty = vertical ? "offsetHeight" : "offsetWidth"; - int handleSize = Integer.parseInt(DOM.getElementProperty(handle, + final String domProperty = vertical ? "offsetHeight" : "offsetWidth"; + final int handleSize = Integer.parseInt(DOM.getElementProperty(handle, domProperty)); - int baseSize = Integer.parseInt(DOM.getElementProperty(base, + final int baseSize = Integer.parseInt(DOM.getElementProperty(base, domProperty)); - int range = baseSize - handleSize; + final int range = baseSize - handleSize; double v = value.doubleValue(); - double valueRange = max - min; + final double valueRange = max - min; double p = 0; if (valueRange > 0) { p = range * ((v - min) / valueRange); @@ -253,7 +257,7 @@ public class ISlider extends Widget implements Paintable, } final double pos = p; - int current = DOM.getIntStyleAttribute(handle, styleAttribute); + final int current = DOM.getIntStyleAttribute(handle, styleAttribute); if ((int) (Math.round(pos)) != current && animate) { if (anim != null) { @@ -261,7 +265,7 @@ public class ISlider extends Widget implements Paintable, } anim = new Timer() { private int current; - private int goal = (int) Math.round(pos); + private final int goal = (int) Math.round(pos); private int dir = 0; public void run() { @@ -277,7 +281,7 @@ public class ISlider extends Widget implements Paintable, cancel(); return; } - int increment = (goal - current) / 2; + final int increment = (goal - current) / 2; DOM.setStyleAttribute(handle, styleAttribute, (current + increment) + "px"); } @@ -311,7 +315,7 @@ public class ISlider extends Widget implements Paintable, if (disabled || readonly) { return; } - Element targ = DOM.eventGetTarget(event); + final Element targ = DOM.eventGetTarget(event); if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) { processMouseWheelEvent(event); @@ -327,7 +331,7 @@ public class ISlider extends Widget implements Paintable, } private void processMouseWheelEvent(Event event) { - int dir = DOM.eventGetMouseWheelVelocityY(event); + final int dir = DOM.eventGetMouseWheelVelocityY(event); if (dir < 0) { increaseValue(event, false); } else { @@ -426,16 +430,16 @@ public class ISlider extends Widget implements Paintable, private void setValueByEvent(Event event, boolean animate, boolean roundup) { double v = min; // Fallback to min - int coord = vertical ? DOM.eventGetClientY(event) : DOM + final int coord = vertical ? DOM.eventGetClientY(event) : DOM .eventGetClientX(event); - String domProperty = vertical ? "offsetHeight" : "offsetWidth"; + final String domProperty = vertical ? "offsetHeight" : "offsetWidth"; - double handleSize = Integer.parseInt(DOM.getElementProperty(handle, - domProperty)); - double baseSize = Integer.parseInt(DOM.getElementProperty(base, + final double handleSize = Integer.parseInt(DOM.getElementProperty( + handle, domProperty)); + final double baseSize = Integer.parseInt(DOM.getElementProperty(base, domProperty)); - double baseOffset = vertical ? DOM.getAbsoluteTop(base) - handleSize - / 2 : DOM.getAbsoluteLeft(base) + handleSize / 2; + final double baseOffset = vertical ? DOM.getAbsoluteTop(base) + - handleSize / 2 : DOM.getAbsoluteLeft(base) + handleSize / 2; if (vertical) { v = ((baseSize - (coord - baseOffset)) / (baseSize - handleSize)) @@ -467,10 +471,10 @@ public class ISlider extends Widget implements Paintable, // Calculate decoration size DOM.setStyleAttribute(base, "height", "0"); DOM.setStyleAttribute(base, "overflow", "hidden"); - int decoHeight = DOM.getElementPropertyInt(getElement(), + final int decoHeight = DOM.getElementPropertyInt(getElement(), "offsetHeight"); // Get available space size - int availableHeight = DOM.getElementPropertyInt(DOM + final int availableHeight = DOM.getElementPropertyInt(DOM .getParent(getElement()), "offsetHeight"); int h = availableHeight - decoHeight; if (h < MIN_SIZE) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java index 00eb3f932b..7a067488db 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -27,13 +31,13 @@ public class ISplitPanel extends ComplexPanel implements Paintable, private Widget secondChild; - private Element wrapper = DOM.createDiv(); + private final Element wrapper = DOM.createDiv(); - private Element firstContainer = DOM.createDiv(); + private final Element firstContainer = DOM.createDiv(); - private Element secondContainer = DOM.createDiv(); + private final Element secondContainer = DOM.createDiv(); - private Element splitter = DOM.createDiv(); + private final Element splitter = DOM.createDiv(); private boolean resizing; @@ -116,9 +120,9 @@ public class ISplitPanel extends ComplexPanel implements Paintable, setSplitPosition(uidl.getStringAttribute("position")); - Paintable newFirstChild = (Paintable) client.getWidget(uidl + final Paintable newFirstChild = (Paintable) client.getWidget(uidl .getChildUIDL(0)); - Paintable newSecondChild = (Paintable) client.getWidget(uidl + final Paintable newSecondChild = (Paintable) client.getWidget(uidl .getChildUIDL(1)); if (firstChild != newFirstChild) { if (firstChild != null) { @@ -277,7 +281,7 @@ public class ISplitPanel extends ComplexPanel implements Paintable, } public void onMouseDown(Event event) { - Element trg = DOM.eventGetTarget(event); + final Element trg = DOM.eventGetTarget(event); if (DOM.compare(trg, splitter) || DOM.compare(trg, DOM.getChild(splitter, 0))) { resizing = true; @@ -294,12 +298,12 @@ public class ISplitPanel extends ComplexPanel implements Paintable, public void onMouseMove(Event event) { switch (orientation) { case ORIENTATION_HORIZONTAL: - int x = DOM.eventGetClientX(event); + final int x = DOM.eventGetClientX(event); onHorizontalMouseMove(x); break; case ORIENTATION_VERTICAL: default: - int y = DOM.eventGetClientY(event); + final int y = DOM.eventGetClientY(event); onVerticalMouseMove(y); break; } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanelHorizontal.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanelHorizontal.java index 77f08a2564..cfc686b7c2 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanelHorizontal.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanelHorizontal.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; public class ISplitPanelHorizontal extends ISplitPanel { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanelVertical.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanelVertical.java index cdcd8d0c65..d6e72385e3 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanelVertical.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanelVertical.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; public class ISplitPanelVertical extends ISplitPanel { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java index d10b62ba43..1798f52783 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.HashMap; @@ -30,17 +34,17 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL; public class ITablePaging extends Composite implements Table, Paintable, ClickListener { - private Grid tBody = new Grid(); - private Button nextPage = new Button(">"); - private Button prevPage = new Button("<"); - private Button firstPage = new Button("<<"); - private Button lastPage = new Button(">>"); + private final Grid tBody = new Grid(); + private final Button nextPage = new Button(">"); + private final Button prevPage = new Button("<"); + private final Button firstPage = new Button("<<"); + private final Button lastPage = new Button(">>"); private int pageLength = 15; private boolean rowHeaders = false; - private Map columnOrder = new HashMap(); + private final Map columnOrder = new HashMap(); private ApplicationConnection client; private String id; @@ -49,19 +53,19 @@ public class ITablePaging extends Composite implements Table, Paintable, private int selectMode = Table.SELECT_MODE_NONE; - private Vector selectedRowKeys = new Vector(); + private final Vector selectedRowKeys = new Vector(); private int totalRows; - private HashMap columnWidths = new HashMap(); + private final HashMap columnWidths = new HashMap(); - private HashMap visibleColumns = new HashMap(); + private final HashMap visibleColumns = new HashMap(); private int rows; private int firstRow; private boolean sortAscending = true; - private HorizontalPanel pager; + private final HorizontalPanel pager; public HashMap rowKeysToTableRows = new HashMap(); @@ -69,7 +73,7 @@ public class ITablePaging extends Composite implements Table, Paintable, tBody.setStyleName("itable-tbody"); - VerticalPanel panel = new VerticalPanel(); + final VerticalPanel panel = new VerticalPanel(); pager = new HorizontalPanel(); pager.add(firstPage); @@ -108,9 +112,10 @@ public class ITablePaging extends Composite implements Table, Paintable, } if (uidl.hasAttribute("selected")) { - Set selectedKeys = uidl.getStringArrayVariableAsSet("selected"); + final Set selectedKeys = uidl + .getStringArrayVariableAsSet("selected"); selectedRowKeys.clear(); - for (Iterator it = selectedKeys.iterator(); it.hasNext();) { + for (final Iterator it = selectedKeys.iterator(); it.hasNext();) { selectedRowKeys.add(it.next()); } } @@ -126,8 +131,8 @@ public class ITablePaging extends Composite implements Table, Paintable, UIDL rowData = null; UIDL visibleColumns = null; - for (Iterator it = uidl.getChildIterator(); it.hasNext();) { - UIDL c = (UIDL) it.next(); + for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + final UIDL c = (UIDL) it.next(); if (c.getTag().equals("rows")) { rowData = c; } else if (c.getTag().equals("actions")) { @@ -145,12 +150,12 @@ public class ITablePaging extends Composite implements Table, Paintable, } private void updateHeader(UIDL c) { - Iterator it = c.getChildIterator(); + final Iterator it = c.getChildIterator(); visibleColumns.clear(); int colIndex = (rowHeaders ? 1 : 0); while (it.hasNext()) { - UIDL col = (UIDL) it.next(); - String cid = col.getStringAttribute("cid"); + final UIDL col = (UIDL) it.next(); + final String cid = col.getStringAttribute("cid"); if (!col.hasAttribute("collapsed")) { tBody.setWidget(0, colIndex, new HeaderCell(cid, col .getStringAttribute("caption"))); @@ -176,28 +181,29 @@ public class ITablePaging extends Composite implements Table, Paintable, * which contains row data */ private void updateBody(UIDL uidl) { - Iterator it = uidl.getChildIterator(); + final Iterator it = uidl.getChildIterator(); int curRowIndex = 1; while (it.hasNext()) { - UIDL rowUidl = (UIDL) it.next(); - TableRow row = new TableRow(curRowIndex, String.valueOf(rowUidl - .getIntAttribute("key")), rowUidl.hasAttribute("selected")); + final UIDL rowUidl = (UIDL) it.next(); + final TableRow row = new TableRow(curRowIndex, String + .valueOf(rowUidl.getIntAttribute("key")), rowUidl + .hasAttribute("selected")); int colIndex = 0; if (rowHeaders) { tBody.setWidget(curRowIndex, colIndex, new BodyCell(row, rowUidl.getStringAttribute("caption"))); colIndex++; } - Iterator cells = rowUidl.getChildIterator(); + final Iterator cells = rowUidl.getChildIterator(); while (cells.hasNext()) { - Object cell = cells.next(); + final Object cell = cells.next(); if (cell instanceof String) { tBody.setWidget(curRowIndex, colIndex, new BodyCell(row, (String) cell)); } else { - Widget cellContent = client.getWidget((UIDL) cell); - BodyCell bodyCell = new BodyCell(row); + final Widget cellContent = client.getWidget((UIDL) cell); + final BodyCell bodyCell = new BodyCell(row); bodyCell.setWidget(cellContent); tBody.setWidget(curRowIndex, colIndex, bodyCell); } @@ -262,7 +268,7 @@ public class ITablePaging extends Composite implements Table, Paintable, } } if (sender instanceof HeaderCell) { - HeaderCell hCell = (HeaderCell) sender; + final HeaderCell hCell = (HeaderCell) sender; client.updateVariable(id, "sortcolumn", hCell.getCid(), false); client.updateVariable(id, "sortascending", (sortAscending ? false : true), true); @@ -299,7 +305,7 @@ public class ITablePaging extends Composite implements Table, Paintable, * @author mattitahvonen */ public class BodyCell extends SimplePanel { - private TableRow row; + private final TableRow row; public BodyCell(TableRow row) { super(); @@ -336,8 +342,8 @@ public class ITablePaging extends Composite implements Table, Paintable, private class TableRow { - private String key; - private int rowIndex; + private final String key; + private final int rowIndex; private boolean selected = false; public TableRow(int rowIndex, String rowKey, boolean selected) { @@ -402,9 +408,10 @@ public class ITablePaging extends Composite implements Table, Paintable, } public void deselectAll() { - Object[] keys = selectedRowKeys.toArray(); + final Object[] keys = selectedRowKeys.toArray(); for (int i = 0; i < keys.length; i++) { - TableRow tableRow = (TableRow) rowKeysToTableRows.get(keys[i]); + final TableRow tableRow = (TableRow) rowKeysToTableRows + .get(keys[i]); if (tableRow != null) { tableRow.setSelected(false); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java index 5c775f7d45..e3a8404aa1 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.ArrayList; @@ -26,8 +30,8 @@ public class ITabsheet extends FlowPanel implements Paintable, String id; ApplicationConnection client; - private ArrayList tabKeys = new ArrayList(); - private ArrayList captions = new ArrayList(); + private final ArrayList tabKeys = new ArrayList(); + private final ArrayList captions = new ArrayList(); int activeTabIndex = 0; private final TabBar tb; private final ITabsheetPanel tp; @@ -37,17 +41,14 @@ public class ITabsheet extends FlowPanel implements Paintable, private final TabListener tl = new TabListener() { public void onTabSelected(SourcesTabEvents sender, final int tabIndex) { - if (ITabsheet.this.client != null - && ITabsheet.this.activeTabIndex != tabIndex) { + if (client != null && activeTabIndex != tabIndex) { addStyleDependentName("loading"); // run updating variables in deferred command to bypass some FF // optimization issues DeferredCommand.addCommand(new Command() { public void execute() { - ITabsheet.this.client.updateVariable(ITabsheet.this.id, - "selected", "" - + ITabsheet.this.tabKeys.get(tabIndex), - true); + client.updateVariable(id, "selected", "" + + tabKeys.get(tabIndex), true); } }); } @@ -82,9 +83,9 @@ public class ITabsheet extends FlowPanel implements Paintable, add(tb); DOM.appendChild(getElement(), contentNode); insert(tp, contentNode, 0, true); - DOM.appendChild(getElement(), this.deco); + DOM.appendChild(getElement(), deco); - this.tb.addTabListener(this.tl); + tb.addTabListener(tl); clearTabs(); @@ -95,7 +96,7 @@ public class ITabsheet extends FlowPanel implements Paintable, public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { this.client = client; - this.id = uidl.getId(); + id = uidl.getId(); if (client.updateComponent(this, uidl, false)) { return; @@ -105,10 +106,10 @@ public class ITabsheet extends FlowPanel implements Paintable, // Add proper stylenames for all elements if (uidl.hasAttribute("style")) { - String[] styles = uidl.getStringAttribute("style").split(" "); - String contentBaseClass = "CLASSNAME" + "-content"; + final String[] styles = uidl.getStringAttribute("style").split(" "); + final String contentBaseClass = "CLASSNAME" + "-content"; String contentClass = contentBaseClass; - String decoBaseClass = CLASSNAME + "-deco"; + final String decoBaseClass = CLASSNAME + "-deco"; String decoClass = decoBaseClass; for (int i = 0; i < styles.length; i++) { tb.addStyleDependentName(styles[i]); @@ -137,7 +138,7 @@ public class ITabsheet extends FlowPanel implements Paintable, } // Render content - UIDL tabs = uidl.getChildUIDL(0); + final UIDL tabs = uidl.getChildUIDL(0); boolean keepCurrentTabs = tabKeys.size() == tabs.getNumberOfChildren(); for (int i = 0; keepCurrentTabs && i < tabKeys.size(); i++) { keepCurrentTabs = tabKeys.get(i).equals( @@ -147,8 +148,8 @@ public class ITabsheet extends FlowPanel implements Paintable, } if (keepCurrentTabs) { int index = 0; - for (Iterator it = tabs.getChildIterator(); it.hasNext();) { - UIDL tab = (UIDL) it.next(); + for (final Iterator it = tabs.getChildIterator(); it.hasNext();) { + final UIDL tab = (UIDL) it.next(); if (tab.getBooleanAttribute("selected")) { activeTabIndex = index; renderContent(tab.getChildUIDL(0)); @@ -161,9 +162,9 @@ public class ITabsheet extends FlowPanel implements Paintable, clearTabs(); int index = 0; - for (Iterator it = tabs.getChildIterator(); it.hasNext();) { - UIDL tab = (UIDL) it.next(); - String key = tab.getStringAttribute("key"); + for (final Iterator it = tabs.getChildIterator(); it.hasNext();) { + final UIDL tab = (UIDL) it.next(); + final String key = tab.getStringAttribute("key"); String caption = tab.getStringAttribute("caption"); if (caption == null) { caption = " "; @@ -188,21 +189,20 @@ public class ITabsheet extends FlowPanel implements Paintable, } // Open selected tab, if there's something to show - if (tabKeys.size() > 0) + if (tabKeys.size() > 0) { tb.selectTab(activeTabIndex); + } } private void renderContent(final UIDL contentUIDL) { DeferredCommand.addCommand(new Command() { public void execute() { - Widget content = ITabsheet.this.client.getWidget(contentUIDL); - ITabsheet.this.tp.remove(ITabsheet.this.activeTabIndex); - ITabsheet.this.tp - .insert(content, ITabsheet.this.activeTabIndex); - ITabsheet.this.tp.showWidget(ITabsheet.this.activeTabIndex); - ((Paintable) content).updateFromUIDL(contentUIDL, - ITabsheet.this.client); + final Widget content = client.getWidget(contentUIDL); + tp.remove(activeTabIndex); + tp.insert(content, activeTabIndex); + tp.showWidget(activeTabIndex); + ((Paintable) content).updateFromUIDL(contentUIDL, client); ITabsheet.this.removeStyleDependentName("loading"); ITabsheet.this.iLayout(); } @@ -218,9 +218,9 @@ public class ITabsheet extends FlowPanel implements Paintable, tp.clear(); // Get rid of unnecessary 100% cell heights in TabBar (really ugly hack) - Element tr = DOM.getChild(DOM.getChild(tb.getElement(), 0), 0); - Element rest = DOM.getChild( - DOM.getChild(tr, DOM.getChildCount(tr) - 1), 0); + final Element tr = DOM.getChild(DOM.getChild(tb.getElement(), 0), 0); + final Element rest = DOM.getChild(DOM.getChild(tr, DOM + .getChildCount(tr) - 1), 0); DOM.removeElementAttribute(rest, "style"); } @@ -241,18 +241,18 @@ public class ITabsheet extends FlowPanel implements Paintable, public void iLayout() { if (height != null && height != "") { // Take content out of flow for a while - String originalPositioning = DOM.getStyleAttribute(tp.getElement(), - "position"); + final String originalPositioning = DOM.getStyleAttribute(tp + .getElement(), "position"); DOM.setStyleAttribute(tp.getElement(), "position", "absolute"); DOM.setStyleAttribute(contentNode, "overflow", "hidden"); // Calculate target height super.setHeight(height); - int targetHeight = getOffsetHeight(); + final int targetHeight = getOffsetHeight(); // Calculate used height super.setHeight(""); - int usedHeight = DOM.getElementPropertyInt(deco, "offsetTop") + final int usedHeight = DOM.getElementPropertyInt(deco, "offsetTop") + DOM.getElementPropertyInt(deco, "offsetHeight") - DOM.getElementPropertyInt(getElement(), "offsetTop"); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java index e1f8ce3b7a..8211ed6362 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -60,7 +64,7 @@ public class ITabsheetPanel extends ComplexPanel { } public boolean remove(Widget w) { - boolean removed = super.remove(w); + final boolean removed = super.remove(w); if (removed) { resetChildWidget(w); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java index 1ac103593c..deb9286915 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java index 3195954ffc..7152d32c08 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -87,25 +91,25 @@ public class ITextField extends TextBoxBase implements Paintable, } private native void setColumns(Element e, int c) /*-{ - try { - switch(e.tagName.toLowerCase()) { - case "input": - //e.size = c; - e.style.width = c+"em"; - break; - case "textarea": - //e.cols = c; - e.style.width = c+"em"; - break; - default:; - } - } catch (e) {} - }-*/; + try { + switch(e.tagName.toLowerCase()) { + case "input": + //e.size = c; + e.style.width = c+"em"; + break; + case "textarea": + //e.cols = c; + e.style.width = c+"em"; + break; + default:; + } + } catch (e) {} + }-*/; private native void setRows(Element e, int r) /*-{ - try { - if(e.tagName.toLowerCase() == "textarea") - e.rows = r; - } catch (e) {} - }-*/; + try { + if(e.tagName.toLowerCase() == "textarea") + e.rows = r; + } catch (e) {} + }-*/; } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java index e5ed1bccbe..fa72f8d6ef 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.Timer; @@ -12,7 +16,7 @@ import com.itmill.toolkit.terminal.gwt.client.util.SimpleDateFormat; public class ITextualDate extends IDateField implements Paintable, ChangeListener { - private ITextField text; + private final ITextField text; private SimpleDateFormat format; @@ -60,18 +64,19 @@ public class ITextualDate extends IDateField implements Paintable, if (h > 11 && dts.isTwelveHourClock()) { h -= 12; } - int m = currentResolution > IDateField.RESOLUTION_HOUR ? date - .getMinutes() : 0; + final int m = currentResolution > IDateField.RESOLUTION_HOUR ? date + .getMinutes() + : 0; dateText += " " + (h < 10 ? "0" + h : "" + h) + dts.getClockDelimeter() + (m < 10 ? "0" + m : "" + m); } if (currentResolution >= IDateField.RESOLUTION_SEC) { - int s = date.getSeconds(); + final int s = date.getSeconds(); dateText += dts.getClockDelimeter() + (s < 10 ? "0" + s : "" + s); } if (currentResolution == IDateField.RESOLUTION_MSEC) { - int ms = getMilliseconds(); + final int ms = getMilliseconds(); String text = "" + ms; if (ms < 10) { text = "00" + text; @@ -145,10 +150,10 @@ public class ITextualDate extends IDateField implements Paintable, try { date = format.parse(text.getText()); - } catch (Exception e) { + } catch (final Exception e) { ApplicationConnection.getConsole().log(e.getMessage()); text.addStyleName(ITextField.CLASSNAME + "-error"); - Timer t = new Timer() { + final Timer t = new Timer() { public void run() { text.removeStyleName(ITextField.CLASSNAME + "-error"); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java index 826d696fd4..ec49ee969c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.HashMap; @@ -29,13 +33,13 @@ public class ITree extends FlowPanel implements Paintable { private boolean selectable; private boolean isMultiselect; - private HashMap keyToNode = new HashMap(); + private final HashMap keyToNode = new HashMap(); /** * This map contains captions and icon urls for actions like: * "33_c" -> * "Edit" * "33_i" -> "http://dom.com/edit.png" */ - private HashMap actionMap = new HashMap(); + private final HashMap actionMap = new HashMap(); private boolean immediate; @@ -51,11 +55,11 @@ public class ITree extends FlowPanel implements Paintable { } private void updateActionMap(UIDL c) { - Iterator it = c.getChildIterator(); + final Iterator it = c.getChildIterator(); while (it.hasNext()) { - UIDL action = (UIDL) it.next(); - String key = action.getStringAttribute("key"); - String caption = action.getStringAttribute("caption"); + final UIDL action = (UIDL) it.next(); + final String key = action.getStringAttribute("key"); + final String caption = action.getStringAttribute("caption"); actionMap.put(key + "_c", caption); if (action.hasAttribute("icon")) { // TODO need some uri handling ?? @@ -97,17 +101,17 @@ public class ITree extends FlowPanel implements Paintable { isNullSelectionAllowed = uidl.getBooleanAttribute("nullselect"); clear(); - for (Iterator i = uidl.getChildIterator(); i.hasNext();) { - UIDL childUidl = (UIDL) i.next(); + for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + final UIDL childUidl = (UIDL) i.next(); if ("actions".equals(childUidl.getTag())) { updateActionMap(childUidl); continue; } - TreeNode childTree = new TreeNode(); + final TreeNode childTree = new TreeNode(); this.add(childTree); childTree.updateFromUIDL(childUidl, client); } - String selectMode = uidl.getStringAttribute("selectmode"); + final String selectMode = uidl.getStringAttribute("selectmode"); selectable = selectMode != null; isMultiselect = "multi".equals(selectMode); @@ -116,7 +120,7 @@ public class ITree extends FlowPanel implements Paintable { } private void handleUpdate(UIDL uidl) { - TreeNode rootNode = (TreeNode) keyToNode.get(uidl + final TreeNode rootNode = (TreeNode) keyToNode.get(uidl .getStringAttribute("rootKey")); if (rootNode != null) { if (!rootNode.getState()) { @@ -132,8 +136,8 @@ public class ITree extends FlowPanel implements Paintable { if (selected) { if (!isMultiselect) { while (selectedIds.size() > 0) { - String id = (String) selectedIds.iterator().next(); - TreeNode oldSelection = (TreeNode) keyToNode.get(id); + final String id = (String) selectedIds.iterator().next(); + final TreeNode oldSelection = (TreeNode) keyToNode.get(id); oldSelection.setSelected(false); selectedIds.remove(id); } @@ -186,7 +190,7 @@ public class ITree extends FlowPanel implements Paintable { if (disabled) { return; } - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (DOM.compare(getElement(), target)) { // state change toggleState(); @@ -208,7 +212,7 @@ public class ITree extends FlowPanel implements Paintable { } protected void constructDom() { - Element root = DOM.createDiv(); + final Element root = DOM.createDiv(); nodeCaptionDiv = DOM.createDiv(); DOM.setElementProperty(nodeCaptionDiv, "className", CLASSNAME + "-caption"); @@ -301,14 +305,14 @@ public class ITree extends FlowPanel implements Paintable { childNodeContainer.clear(); childNodeContainer.setVisible(true); while (i.hasNext()) { - UIDL childUidl = (UIDL) i.next(); + final UIDL childUidl = (UIDL) i.next(); // actions are in bit weird place, don't mix them with children, // but current node's actions if ("actions".equals(childUidl.getTag())) { updateActionMap(childUidl); continue; } - TreeNode childTree = new TreeNode(); + final TreeNode childTree = new TreeNode(); childNodeContainer.add(childTree); childTree.updateFromUIDL(childUidl, client); } @@ -323,10 +327,10 @@ public class ITree extends FlowPanel implements Paintable { if (actionKeys == null) { return new Action[] {}; } - Action[] actions = new Action[actionKeys.length]; + final Action[] actions = new Action[actionKeys.length]; for (int i = 0; i < actions.length; i++) { - String actionKey = actionKeys[i]; - TreeAction a = new TreeAction(this, String.valueOf(key), + final String actionKey = actionKeys[i]; + final TreeAction a = new TreeAction(this, String.valueOf(key), actionKey); a.setCaption(getActionCaption(actionKey)); a.setIconUrl(getActionIcon(actionKey)); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java index 4e354d26fa..31ec923f16 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.Iterator; @@ -18,13 +22,13 @@ public class ITwinColSelect extends IOptionGroupBase { private static final String DEFAULT_WIDTH = "10em"; - private ListBox options; + private final ListBox options; - private ListBox selections; + private final ListBox selections; - private IButton add; + private final IButton add; - private IButton remove; + private final IButton remove; public ITwinColSelect() { super(CLASSNAME); @@ -36,7 +40,7 @@ public class ITwinColSelect extends IOptionGroupBase { selections.setVisibleItemCount(VISIBLE_COUNT); options.setStyleName(CLASSNAME + "-options"); selections.setStyleName(CLASSNAME + "-selections"); - Panel buttons = new FlowPanel(); + final Panel buttons = new FlowPanel(); buttons.setStyleName(CLASSNAME + "-buttons"); add = new IButton(); add.setText(">>"); @@ -44,10 +48,10 @@ public class ITwinColSelect extends IOptionGroupBase { remove = new IButton(); remove.setText("<<"); remove.addClickListener(this); - Panel p = ((Panel) optionsContainer); + final Panel p = ((Panel) optionsContainer); p.add(options); buttons.add(add); - HTML br = new HTML(""); + final HTML br = new HTML(""); br.setStyleName(CLASSNAME + "-deco"); buttons.add(br); buttons.add(remove); @@ -56,7 +60,7 @@ public class ITwinColSelect extends IOptionGroupBase { } protected void buildOptions(UIDL uidl) { - boolean enabled = !isDisabled() && !isReadonly(); + final boolean enabled = !isDisabled() && !isReadonly(); options.setMultipleSelect(isMultiselect()); selections.setMultipleSelect(isMultiselect()); options.setEnabled(enabled); @@ -65,8 +69,8 @@ public class ITwinColSelect extends IOptionGroupBase { remove.setEnabled(enabled); options.clear(); selections.clear(); - for (Iterator i = uidl.getChildIterator(); i.hasNext();) { - UIDL optionUidl = (UIDL) i.next(); + for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + final UIDL optionUidl = (UIDL) i.next(); if (optionUidl.hasAttribute("selected")) { selections.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key")); @@ -90,7 +94,7 @@ public class ITwinColSelect extends IOptionGroupBase { } protected Object[] getSelectedItems() { - Vector selectedItemKeys = new Vector(); + final Vector selectedItemKeys = new Vector(); for (int i = 0; i < selections.getItemCount(); i++) { selectedItemKeys.add(selections.getValue(i)); } @@ -98,7 +102,7 @@ public class ITwinColSelect extends IOptionGroupBase { } private boolean[] getItemsToAdd() { - boolean[] selectedIndexes = new boolean[options.getItemCount()]; + final boolean[] selectedIndexes = new boolean[options.getItemCount()]; for (int i = 0; i < options.getItemCount(); i++) { if (options.isItemSelected(i)) { selectedIndexes[i] = true; @@ -110,7 +114,7 @@ public class ITwinColSelect extends IOptionGroupBase { } private boolean[] getItemsToRemove() { - boolean[] selectedIndexes = new boolean[selections.getItemCount()]; + final boolean[] selectedIndexes = new boolean[selections.getItemCount()]; for (int i = 0; i < selections.getItemCount(); i++) { if (selections.isItemSelected(i)) { selectedIndexes[i] = true; @@ -124,15 +128,16 @@ public class ITwinColSelect extends IOptionGroupBase { public void onClick(Widget sender) { super.onClick(sender); if (sender == add) { - boolean[] sel = getItemsToAdd(); + final boolean[] sel = getItemsToAdd(); for (int i = 0; i < sel.length; i++) { if (sel[i]) { - int optionIndex = i - (sel.length - options.getItemCount()); + final int optionIndex = i + - (sel.length - options.getItemCount()); selectedKeys.add(options.getValue(optionIndex)); // Move selection to another column - String text = options.getItemText(optionIndex); - String value = options.getValue(optionIndex); + final String text = options.getItemText(optionIndex); + final String value = options.getValue(optionIndex); selections.addItem(text, value); selections.setItemSelected(selections.getItemCount() - 1, true); @@ -143,16 +148,16 @@ public class ITwinColSelect extends IOptionGroupBase { isImmediate()); } else if (sender == remove) { - boolean[] sel = getItemsToRemove(); + final boolean[] sel = getItemsToRemove(); for (int i = 0; i < sel.length; i++) { if (sel[i]) { - int selectionIndex = i + final int selectionIndex = i - (sel.length - selections.getItemCount()); selectedKeys.remove(selections.getValue(selectionIndex)); // Move selection to another column - String text = selections.getItemText(selectionIndex); - String value = selections.getValue(selectionIndex); + final String text = selections.getItemText(selectionIndex); + final String value = selections.getValue(selectionIndex); options.addItem(text, value); options.setItemSelected(options.getItemCount() - 1, true); selections.removeItem(selectionIndex); @@ -162,13 +167,13 @@ public class ITwinColSelect extends IOptionGroupBase { isImmediate()); } else if (sender == options) { // unselect all in other list, to avoid mistakes (i.e wrong button) - int c = selections.getItemCount(); + final int c = selections.getItemCount(); for (int i = 0; i < c; i++) { selections.setItemSelected(i, false); } } else if (sender == selections) { // unselect all in other list, to avoid mistakes (i.e wrong button) - int c = options.getItemCount(); + final int c = options.getItemCount(); for (int i = 0; i < c; i++) { options.setItemSelected(i, false); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java index 73d8be8a18..e90de5cb2d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.ui.Composite; @@ -13,7 +17,7 @@ public class IUnknownComponent extends Composite implements Paintable { Tree uidlTree = new Tree(); public IUnknownComponent() { - VerticalPanel panel = new VerticalPanel(); + final VerticalPanel panel = new VerticalPanel(); panel.add(caption); panel.add(uidlTree); initWidget(panel); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java index 60fd35cc37..ef3718d4a1 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.Timer; @@ -34,7 +38,7 @@ public class IUpload extends FormPanel implements Paintable, ClickListener, /** * Button that initiates uploading */ - private Button submitButton; + private final Button submitButton; /** * When expecting big files, programmer may initiate some UI changes when diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java index 56ad40dc0d..bf7910870e 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.HashSet; @@ -63,9 +67,9 @@ public class IView extends SimplePanel implements Paintable, // Open URL:s while (childIndex < uidl.getChidlCount() && "open".equals(uidl.getChildUIDL(childIndex).getTag())) { - UIDL open = uidl.getChildUIDL(childIndex); - String url = open.getStringAttribute("src"); - String target = open.getStringAttribute("name"); + final UIDL open = uidl.getChildUIDL(childIndex); + final String url = open.getStringAttribute("src"); + final String target = open.getStringAttribute("name"); if (target == null) { goTo(url); } else { @@ -77,7 +81,7 @@ public class IView extends SimplePanel implements Paintable, // Draw this application level window UIDL childUidl = uidl.getChildUIDL(childIndex); - Paintable lo = (Paintable) client.getWidget(childUidl); + final Paintable lo = (Paintable) client.getWidget(childUidl); if (layout != null) { if (layout != lo) { @@ -94,12 +98,12 @@ public class IView extends SimplePanel implements Paintable, layout.updateFromUIDL(childUidl, client); // Update subwindows - HashSet removedSubWindows = new HashSet(subWindows); + final HashSet removedSubWindows = new HashSet(subWindows); // Open new windows while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) { if ("window".equals(childUidl.getTag())) { - Widget w = client.getWidget(childUidl); + final Widget w = client.getWidget(childUidl); if (subWindows.contains(w)) { removedSubWindows.remove(w); } else { @@ -112,8 +116,9 @@ public class IView extends SimplePanel implements Paintable, } actionHandler.updateActionMap(childUidl); } else if (childUidl.getTag().equals("notifications")) { - for (Iterator it = childUidl.getChildIterator(); it.hasNext();) { - UIDL notification = (UIDL) it.next(); + for (final Iterator it = childUidl.getChildIterator(); it + .hasNext();) { + final UIDL notification = (UIDL) it.next(); String html = ""; if (notification.hasAttribute("caption")) { html += "

" @@ -126,19 +131,20 @@ public class IView extends SimplePanel implements Paintable, + "

"; } - String style = notification.hasAttribute("style") ? notification + final String style = notification.hasAttribute("style") ? notification .getStringAttribute("style") : null; - int position = notification.getIntAttribute("position"); - int delay = notification.getIntAttribute("delay"); + final int position = notification + .getIntAttribute("position"); + final int delay = notification.getIntAttribute("delay"); new Notification(delay).show(html, position, style); } } } // Close old windows - for (Iterator rem = removedSubWindows.iterator(); rem.hasNext();) { - IWindow w = (IWindow) rem.next(); + for (final Iterator rem = removedSubWindows.iterator(); rem.hasNext();) { + final IWindow w = (IWindow) rem.next(); client.unregisterPaintable(w); subWindows.remove(w); RootPanel.get().remove(w); @@ -155,7 +161,7 @@ public class IView extends SimplePanel implements Paintable, public void onBrowserEvent(Event event) { super.onBrowserEvent(event); if (DOM.eventGetType(event) == Event.ONKEYDOWN && actionHandler != null) { - int modifiers = KeyboardListenerCollection + final int modifiers = KeyboardListenerCollection .getKeyboardModifiers(event); actionHandler.handleKeyboardEvent( (char) DOM.eventGetKeyCode(event), modifiers); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java index abf4e2d3ea..f32b3a2f3b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.Iterator; @@ -86,10 +90,10 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { ShortcutActionHandler shortcutHandler; /** Last known width read from UIDL or updated to application connection */ - private int uidlWidth = -1; + private final int uidlWidth = -1; /** Last known height read from UIDL or updated to application connection */ - private int uidlHeight = -1; + private final int uidlHeight = -1; /** Last known positionx read from UIDL or updated to application connection */ private int uidlPositionX = -1; @@ -103,7 +107,7 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { public IWindow() { super(); - int order = windowOrder.size(); + final int order = windowOrder.size(); setWindowOrder(order); windowOrder.add(this); setStyleName(CLASSNAME); @@ -160,9 +164,9 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { DOM.sinkEvents(closeBox, Event.ONCLICK); DOM.sinkEvents(contents, Event.ONCLICK); - Element wrapper = DOM.createDiv(); + final Element wrapper = DOM.createDiv(); DOM.setElementProperty(wrapper, "className", CLASSNAME + "-wrap"); - Element wrapper2 = DOM.createDiv(); + final Element wrapper2 = DOM.createDiv(); DOM.setElementProperty(wrapper2, "className", CLASSNAME + "-wrap2"); DOM.sinkEvents(wrapper, Event.ONKEYDOWN); @@ -200,22 +204,22 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { // Initialize the width from UIDL if (uidl.hasVariable("width")) { - String width = uidl.getStringVariable("width"); + final String width = uidl.getStringVariable("width"); setWidth(width); } if (uidl.hasVariable("height")) { - String height = uidl.getStringVariable("height"); + final String height = uidl.getStringVariable("height"); setHeight(height); } // Initialize the position form UIDL try { - int positionx = uidl.getIntVariable("positionx"); - int positiony = uidl.getIntVariable("positiony"); + final int positionx = uidl.getIntVariable("positionx"); + final int positiony = uidl.getIntVariable("positiony"); if (positionx >= 0 && positiony >= 0) { setPopupPosition(positionx, positiony); } - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { // Silently ignored as positionx and positiony are not required // parameters } @@ -230,22 +234,22 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { UIDL childUidl = uidl.getChildUIDL(0); if ("open".equals(childUidl.getTag())) { - String parsedUri = client.translateToolkitUri(childUidl + final String parsedUri = client.translateToolkitUri(childUidl .getStringAttribute("src")); // TODO this should be a while-loop for multiple opens if (!childUidl.hasAttribute("name")) { - Frame frame = new Frame(); + final Frame frame = new Frame(); DOM.setStyleAttribute(frame.getElement(), "width", "100%"); DOM.setStyleAttribute(frame.getElement(), "height", "100%"); DOM.setStyleAttribute(frame.getElement(), "border", "0px"); frame.setUrl(parsedUri); contentPanel.setWidget(frame); } else { - String target = childUidl.getStringAttribute("name"); + final String target = childUidl.getStringAttribute("name"); Window.open(parsedUri, target, ""); } } else { - Paintable lo = (Paintable) client.getWidget(childUidl); + final Paintable lo = (Paintable) client.getWidget(childUidl); if (layout != null) { if (layout != lo) { // remove old @@ -263,7 +267,7 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { // we may have actions and notifications if (uidl.getChidlCount() > 1) { - int cnt = uidl.getChidlCount(); + final int cnt = uidl.getChidlCount(); for (int i = 1; i < cnt; i++) { childUidl = uidl.getChildUIDL(i); if (childUidl.getTag().equals("actions")) { @@ -273,9 +277,9 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { shortcutHandler.updateActionMap(childUidl); } else if (childUidl.getTag().equals("notifications")) { // TODO needed? move -> - for (Iterator it = childUidl.getChildIterator(); it + for (final Iterator it = childUidl.getChildIterator(); it .hasNext();) { - UIDL notification = (UIDL) it.next(); + final UIDL notification = (UIDL) it.next(); String html = ""; if (notification.hasAttribute("caption")) { html += "

" @@ -290,11 +294,12 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { + "

"; } - String style = notification.hasAttribute("style") ? notification + final String style = notification.hasAttribute("style") ? notification .getStringAttribute("style") : null; - int position = notification.getIntAttribute("position"); - int delay = notification.getIntAttribute("delay"); + final int position = notification + .getIntAttribute("position"); + final int delay = notification.getIntAttribute("delay"); new Notification(delay).show(html, position, style); } } @@ -336,16 +341,16 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { } public void onBrowserEvent(Event event) { - int type = DOM.eventGetType(event); + final int type = DOM.eventGetType(event); if (type == Event.ONKEYDOWN && shortcutHandler != null) { - int modifiers = KeyboardListenerCollection + final int modifiers = KeyboardListenerCollection .getKeyboardModifiers(event); shortcutHandler.handleKeyboardEvent((char) DOM .eventGetKeyCode(event), modifiers); return; } - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (dragging || DOM.isOrHasChild(header, target)) { onHeaderEvent(event); DOM.eventCancelBubble(event, true); @@ -445,8 +450,8 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { break; case Event.ONMOUSEMOVE: if (dragging) { - int x = DOM.eventGetScreenX(event) - startX + origX; - int y = DOM.eventGetScreenY(event) - startY + origY; + final int x = DOM.eventGetScreenX(event) - startX + origX; + final int y = DOM.eventGetScreenY(event) - startY + origY; setPopupPosition(x, y); DOM.eventPreventDefault(event); } @@ -465,7 +470,7 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { return false; } else if (modal) { // return false when modal and outside window - Element target = DOM.eventGetTarget(event); + final Element target = DOM.eventGetTarget(event); if (!DOM.isOrHasChild(getElement(), target)) { return false; } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/Icon.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/Icon.java index c960057df8..bc14d553ef 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/Icon.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/Icon.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -5,7 +9,7 @@ import com.google.gwt.user.client.ui.UIObject; import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; public class Icon extends UIObject { - private ApplicationConnection client; + private final ApplicationConnection client; private String myUri; public Icon(ApplicationConnection client) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/MarginInfo.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/MarginInfo.java index 038954d4f2..60584335a0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/MarginInfo.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/MarginInfo.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; public class MarginInfo { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java index 4d524b1237..251ec8fd49 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; /* @@ -16,7 +20,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui; * the License. */ -//COPIED HERE DUE package privates in GWT +// COPIED HERE DUE package privates in GWT import java.util.ArrayList; import java.util.List; @@ -52,13 +56,14 @@ import com.google.gwt.user.client.ui.Widget; */ public class MenuBar extends Widget implements PopupListener { - private Element body; - private ArrayList items = new ArrayList(); + private final Element body; + private final ArrayList items = new ArrayList(); private MenuBar parentMenu; private PopupPanel popup; private MenuItem selectedItem; private MenuBar shownChildMenu; - private boolean vertical, autoOpen; + private final boolean vertical; + private boolean autoOpen; /** * Creates an empty horizontal menu bar. @@ -76,18 +81,18 @@ public class MenuBar extends Widget implements PopupListener { public MenuBar(boolean vertical) { super(); - Element table = DOM.createTable(); + final Element table = DOM.createTable(); body = DOM.createTBody(); DOM.appendChild(table, body); if (!vertical) { - Element tr = DOM.createTR(); + final Element tr = DOM.createTR(); DOM.appendChild(body, tr); } this.vertical = vertical; - Element outer = DOM.createDiv(); + final Element outer = DOM.createDiv(); DOM.appendChild(outer, table); setElement(outer); @@ -130,7 +135,7 @@ public class MenuBar extends Widget implements PopupListener { * @return the {@link MenuItem} object created */ public MenuItem addItem(String text, boolean asHTML, Command cmd) { - MenuItem item = new MenuItem(text, asHTML, cmd); + final MenuItem item = new MenuItem(text, asHTML, cmd); addItem(item); return item; } @@ -148,7 +153,7 @@ public class MenuBar extends Widget implements PopupListener { * @return the {@link MenuItem} object created */ public MenuItem addItem(String text, boolean asHTML, MenuBar popup) { - MenuItem item = new MenuItem(text, asHTML, popup); + final MenuItem item = new MenuItem(text, asHTML, popup); addItem(item); return item; } @@ -164,7 +169,7 @@ public class MenuBar extends Widget implements PopupListener { * @return the {@link MenuItem} object created */ public MenuItem addItem(String text, Command cmd) { - MenuItem item = new MenuItem(text, cmd); + final MenuItem item = new MenuItem(text, cmd); addItem(item); return item; } @@ -180,7 +185,7 @@ public class MenuBar extends Widget implements PopupListener { * @return the {@link MenuItem} object created */ public MenuItem addItem(String text, MenuBar popup) { - MenuItem item = new MenuItem(text, popup); + final MenuItem item = new MenuItem(text, popup); addItem(item); return item; } @@ -189,7 +194,7 @@ public class MenuBar extends Widget implements PopupListener { * Removes all menu items from this menu bar. */ public void clearItems() { - Element container = getItemContainerElement(); + final Element container = getItemContainerElement(); while (DOM.getChildCount(container) > 0) { DOM.removeChild(container, DOM.getChild(container, 0)); } @@ -209,7 +214,7 @@ public class MenuBar extends Widget implements PopupListener { public void onBrowserEvent(Event event) { super.onBrowserEvent(event); - MenuItem item = findItem(DOM.eventGetTarget(event)); + final MenuItem item = findItem(DOM.eventGetTarget(event)); switch (DOM.eventGetType(event)) { case Event.ONCLICK: { // Fire an item's command when the user clicks on it. @@ -255,12 +260,12 @@ public class MenuBar extends Widget implements PopupListener { * the item to be removed */ public void removeItem(MenuItem item) { - int idx = items.indexOf(item); + final int idx = items.indexOf(item); if (idx == -1) { return; } - Element container = getItemContainerElement(); + final Element container = getItemContainerElement(); DOM.removeChild(container, DOM.getChild(container, idx)); items.remove(idx); } @@ -355,7 +360,7 @@ public class MenuBar extends Widget implements PopupListener { closeAllParents(); // Fire the item's command. - Command cmd = item.getCommand(); + final Command cmd = item.getCommand(); if (cmd != null) { DeferredCommand.addCommand(cmd); } @@ -384,8 +389,8 @@ public class MenuBar extends Widget implements PopupListener { // If the event target is part of the parent menu, suppress // the // event altogether. - Element target = DOM.eventGetTarget(event); - Element parentMenuElement = item.getParentMenu() + final Element target = DOM.eventGetTarget(event); + final Element parentMenuElement = item.getParentMenu() .getElement(); if (DOM.isOrHasChild(parentMenuElement, target)) { return false; @@ -466,7 +471,7 @@ public class MenuBar extends Widget implements PopupListener { private MenuItem findItem(Element hItem) { for (int i = 0; i < items.size(); ++i) { - MenuItem item = (MenuItem) items.get(i); + final MenuItem item = (MenuItem) items.get(i); if (DOM.isOrHasChild(item.getElement(), hItem)) { return item; } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java index 6767864a6e..184e3bf8d6 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; /* @@ -16,7 +20,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui; * the License. */ -//COPIED HERE DUE package privates in GWT +// COPIED HERE DUE package privates in GWT import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.HasHTML; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java index 130ac370ee..447230367e 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; @@ -154,12 +158,12 @@ public class Notification extends ToolkitOverlay { } } }; - int msec = fadeMsec / (startOpacity / 5); + final int msec = fadeMsec / (startOpacity / 5); fader.scheduleRepeating(msec); } public void setPosition(int position) { - Element el = getElement(); + final Element el = getElement(); DOM.setStyleAttribute(el, "top", null); DOM.setStyleAttribute(el, "left", null); DOM.setStyleAttribute(el, "bottom", null); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ShortcutActionHandler.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ShortcutActionHandler.java index 1cc99be0f0..561f5a57c3 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ShortcutActionHandler.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ShortcutActionHandler.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.ArrayList; @@ -15,7 +19,7 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL; * @author IT Mill ltd */ public class ShortcutActionHandler { - private ArrayList actions = new ArrayList(); + private final ArrayList actions = new ArrayList(); private ApplicationConnection client; private String paintableId; @@ -42,19 +46,19 @@ public class ShortcutActionHandler { */ public void updateActionMap(UIDL c) { actions.clear(); - Iterator it = c.getChildIterator(); + final Iterator it = c.getChildIterator(); while (it.hasNext()) { - UIDL action = (UIDL) it.next(); + final UIDL action = (UIDL) it.next(); int[] modifiers = null; if (action.hasAttribute("mk")) { modifiers = action.getIntArrayAttribute("mk"); } - ShortcutKeyCombination kc = new ShortcutKeyCombination(action + final ShortcutKeyCombination kc = new ShortcutKeyCombination(action .getIntAttribute("kc"), modifiers); - String key = action.getStringAttribute("key"); - String caption = action.getStringAttribute("caption"); + final String key = action.getStringAttribute("key"); + final String caption = action.getStringAttribute("caption"); actions.add(new ShortcutAction(key, kc, caption)); } } @@ -69,11 +73,11 @@ public class ShortcutActionHandler { * modifier keys (bitmask like in {@link KeyboardListener}) */ public void handleKeyboardEvent(char keyCode, int modifiers) { - ShortcutKeyCombination kc = new ShortcutKeyCombination(keyCode, + final ShortcutKeyCombination kc = new ShortcutKeyCombination(keyCode, modifiers); - Iterator it = actions.iterator(); + final Iterator it = actions.iterator(); while (it.hasNext()) { - ShortcutAction a = (ShortcutAction) it.next(); + final ShortcutAction a = (ShortcutAction) it.next(); if (a.getShortcutCombination().equals(kc)) { client.updateVariable(paintableId, "action", a.getKey(), true); break; @@ -137,9 +141,9 @@ class ShortcutKeyCombination { class ShortcutAction { - private ShortcutKeyCombination sc; - private String caption; - private String key; + private final ShortcutKeyCombination sc; + private final String caption; + private final String key; public ShortcutAction(String key, ShortcutKeyCombination sc, String caption) { this.sc = sc; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/Table.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/Table.java index eb955137f0..40cccf00ac 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/Table.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/Table.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.ui.HasWidgets; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java index 0ff537c542..f45b58c3c0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.ui.ChangeListener; @@ -7,7 +11,7 @@ import com.google.gwt.user.client.ui.Widget; public class Time extends FlowPanel implements ChangeListener { - private IDateField datefield; + private final IDateField datefield; private ListBox hours; @@ -30,10 +34,10 @@ public class Time extends FlowPanel implements ChangeListener { } private void buildTime(boolean redraw) { - boolean thc = datefield.getDateTimeService().isTwelveHourClock(); + final boolean thc = datefield.getDateTimeService().isTwelveHourClock(); if (redraw) { clear(); - int numHours = thc ? 12 : 24; + final int numHours = thc ? 12 : 24; hours = new ListBox(); hours.setStyleName(INativeSelect.CLASSNAME); for (int i = 0; i < numHours; i++) { @@ -43,7 +47,7 @@ public class Time extends FlowPanel implements ChangeListener { if (thc) { ampm = new ListBox(); ampm.setStyleName(INativeSelect.CLASSNAME); - String[] ampmText = datefield.getDateTimeService() + final String[] ampmText = datefield.getDateTimeService() .getAmPmStrings(); ampm.addItem(ampmText[0]); ampm.addItem(ampmText[1]); @@ -81,9 +85,9 @@ public class Time extends FlowPanel implements ChangeListener { msec.addChangeListener(this); } - String delimiter = datefield.getDateTimeService() + final String delimiter = datefield.getDateTimeService() .getClockDelimeter(); - boolean ro = datefield.isReadonly(); + final boolean ro = datefield.isReadonly(); if (ro) { int h = 0; @@ -101,7 +105,7 @@ public class Time extends FlowPanel implements ChangeListener { if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) { add(new ILabel(delimiter)); if (ro) { - int m = mins.getSelectedIndex(); + final int m = mins.getSelectedIndex(); add(new ILabel(m < 10 ? "0" + m : "" + m)); } else { add(mins); @@ -110,7 +114,7 @@ public class Time extends FlowPanel implements ChangeListener { if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) { add(new ILabel(delimiter)); if (ro) { - int s = sec.getSelectedIndex(); + final int s = sec.getSelectedIndex(); add(new ILabel(s < 10 ? "0" + s : "" + s)); } else { add(sec); @@ -119,8 +123,8 @@ public class Time extends FlowPanel implements ChangeListener { if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) { add(new ILabel(".")); if (ro) { - int m = datefield.getMilliseconds(); - String ms = m < 100 ? "0" + m : "" + m; + final int m = datefield.getMilliseconds(); + final String ms = m < 100 ? "0" + m : "" + m; add(new ILabel(m < 10 ? "0" + ms : ms)); } else { add(msec); @@ -171,7 +175,7 @@ public class Time extends FlowPanel implements ChangeListener { if (datefield.isReadonly() && !redraw) { // Do complete redraw when in read-only status clear(); - String delimiter = datefield.getDateTimeService() + final String delimiter = datefield.getDateTimeService() .getClockDelimeter(); int h = datefield.getCurrentDate().getHours(); @@ -182,18 +186,18 @@ public class Time extends FlowPanel implements ChangeListener { if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) { add(new ILabel(delimiter)); - int m = mins.getSelectedIndex(); + final int m = mins.getSelectedIndex(); add(new ILabel(m < 10 ? "0" + m : "" + m)); } if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) { add(new ILabel(delimiter)); - int s = sec.getSelectedIndex(); + final int s = sec.getSelectedIndex(); add(new ILabel(s < 10 ? "0" + s : "" + s)); } if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) { add(new ILabel(".")); - int m = datefield.getMilliseconds(); - String ms = m < 100 ? "0" + m : "" + m; + final int m = datefield.getMilliseconds(); + final String ms = m < 100 ? "0" + m : "" + m; add(new ILabel(m < 10 ? "0" + ms : ms)); } if (datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) { @@ -206,7 +210,7 @@ public class Time extends FlowPanel implements ChangeListener { } } - boolean enabled = datefield.isEnabled(); + final boolean enabled = datefield.isEnabled(); hours.setEnabled(enabled); if (mins != null) { mins.setEnabled(enabled); @@ -244,25 +248,26 @@ public class Time extends FlowPanel implements ChangeListener { datefield.isImmediate()); updateTime(false); } else if (sender == mins) { - int m = mins.getSelectedIndex(); + final int m = mins.getSelectedIndex(); datefield.getCurrentDate().setMinutes(m); datefield.getClient().updateVariable(datefield.getId(), "min", m, datefield.isImmediate()); updateTime(false); } else if (sender == sec) { - int s = sec.getSelectedIndex(); + final int s = sec.getSelectedIndex(); datefield.getCurrentDate().setSeconds(s); datefield.getClient().updateVariable(datefield.getId(), "sec", s, datefield.isImmediate()); updateTime(false); } else if (sender == msec) { - int ms = msec.getSelectedIndex(); + final int ms = msec.getSelectedIndex(); datefield.setMilliseconds(ms); datefield.getClient().updateVariable(datefield.getId(), "msec", ms, datefield.isImmediate()); updateTime(false); } else if (sender == ampm) { - int h = hours.getSelectedIndex() + ampm.getSelectedIndex() * 12; + final int h = hours.getSelectedIndex() + ampm.getSelectedIndex() + * 12; datefield.getCurrentDate().setHours(h); datefield.getClient().updateVariable(datefield.getId(), "hour", h, datefield.isImmediate()); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ToolkitOverlay.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ToolkitOverlay.java index a3045b287b..a56cd245b0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ToolkitOverlay.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ToolkitOverlay.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.DOM; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java index 39cd917536..4ecc477a3e 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; /** diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeImages.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeImages.java index 1797cef581..83e0e4c57f 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeImages.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeImages.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import com.google.gwt.user.client.ui.AbstractImagePrototype; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/richtextarea/IRichTextArea.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/richtextarea/IRichTextArea.java index dd733eb6d0..5b5a1bfba3 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/richtextarea/IRichTextArea.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/richtextarea/IRichTextArea.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui.richtextarea; import com.google.gwt.user.client.ui.ChangeListener; @@ -35,7 +39,7 @@ public class IRichTextArea extends Composite implements Paintable, RichTextToolbar formatter = new RichTextToolbar(rta); public IRichTextArea() { - FlowPanel fp = new FlowPanel(); + final FlowPanel fp = new FlowPanel(); fp.add(formatter); rta.setWidth("100%"); @@ -79,7 +83,7 @@ public class IRichTextArea extends Composite implements Paintable, } public void onLostFocus(Widget sender) { - String html = rta.getHTML(); + final String html = rta.getHTML(); client.updateVariable(id, "text", html, immediate); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/richtextarea/RichTextToolbar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/richtextarea/RichTextToolbar.java index fcffa51328..4d3d11d6c9 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/richtextarea/RichTextToolbar.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/richtextarea/RichTextToolbar.java @@ -264,12 +264,14 @@ public class RichTextToolbar extends Composite { } else if (sender == justifyRight) { basic.setJustification(RichTextArea.Justification.RIGHT); } else if (sender == insertImage) { - String url = Window.prompt("Enter an image URL:", "http://"); + final String url = Window.prompt("Enter an image URL:", + "http://"); if (url != null) { extended.insertImage(url); } } else if (sender == createLink) { - String url = Window.prompt("Enter a link URL:", "http://"); + final String url = Window + .prompt("Enter a link URL:", "http://"); if (url != null) { extended.createLink(url); } @@ -319,17 +321,17 @@ public class RichTextToolbar extends Composite { RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE, RichTextArea.FontSize.XX_LARGE }; - private Images images = (Images) GWT.create(Images.class); - private Strings strings = (Strings) GWT.create(Strings.class); - private EventListener listener = new EventListener(); + private final Images images = (Images) GWT.create(Images.class); + private final Strings strings = (Strings) GWT.create(Strings.class); + private final EventListener listener = new EventListener(); - private RichTextArea richText; - private RichTextArea.BasicFormatter basic; - private RichTextArea.ExtendedFormatter extended; + private final RichTextArea richText; + private final RichTextArea.BasicFormatter basic; + private final RichTextArea.ExtendedFormatter extended; - private VerticalPanel outer = new VerticalPanel(); - private HorizontalPanel topPanel = new HorizontalPanel(); - private HorizontalPanel bottomPanel = new HorizontalPanel(); + private final VerticalPanel outer = new VerticalPanel(); + private final HorizontalPanel topPanel = new HorizontalPanel(); + private final HorizontalPanel bottomPanel = new HorizontalPanel(); private ToggleButton bold; private ToggleButton italic; private ToggleButton underline; @@ -427,7 +429,7 @@ public class RichTextToolbar extends Composite { } private ListBox createColorList(String caption) { - ListBox lb = new ListBox(); + final ListBox lb = new ListBox(); lb.addChangeListener(listener); lb.setVisibleItemCount(1); @@ -442,7 +444,7 @@ public class RichTextToolbar extends Composite { } private ListBox createFontList() { - ListBox lb = new ListBox(); + final ListBox lb = new ListBox(); lb.addChangeListener(listener); lb.setVisibleItemCount(1); @@ -458,7 +460,7 @@ public class RichTextToolbar extends Composite { } private ListBox createFontSizes() { - ListBox lb = new ListBox(); + final ListBox lb = new ListBox(); lb.addChangeListener(listener); lb.setVisibleItemCount(1); @@ -474,7 +476,7 @@ public class RichTextToolbar extends Composite { } private PushButton createPushButton(AbstractImagePrototype img, String tip) { - PushButton pb = new PushButton(img.createImage()); + final PushButton pb = new PushButton(img.createImage()); pb.addClickListener(listener); pb.setTitle(tip); return pb; @@ -482,7 +484,7 @@ public class RichTextToolbar extends Composite { private ToggleButton createToggleButton(AbstractImagePrototype img, String tip) { - ToggleButton tb = new ToggleButton(img.createImage()); + final ToggleButton tb = new ToggleButton(img.createImage()); tb.addClickListener(listener); tb.setTitle(tip); return tb; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java b/src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java index 43e40adfd0..6b8ba5022b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.util; import java.util.Arrays; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java b/src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java index 55a24cb5d0..3a1ccfc2a2 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java @@ -50,7 +50,7 @@ public class Pattern { */ public final static int CASE_INSENSITIVE = 2; - private JavaScriptObject regExp; + private final JavaScriptObject regExp; private static JavaScriptObject createExpression(String pattern, int flags) { String sFlags = ""; @@ -65,16 +65,16 @@ public class Pattern { private static native JavaScriptObject _createExpression(String pattern, String flags)/*-{ - return new RegExp(pattern, flags); - }-*/; + return new RegExp(pattern, flags); + }-*/; private native void _match(String text, List matches)/*-{ - var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp; - var result = text.match(regExp); - if (result == null) return; - for (var i=0;i 3) { response = locale.getWEEKDAY_LONG()[date.getDay()]; @@ -187,7 +187,7 @@ public class SimpleDateFormat { // else // response = Integer.toString(date.getSeconds()); } else if (DateLocale.TOKEN_AM_PM.equals(tc)) { - int hour = date.getHours(); + final int hour = date.getHours(); if (hour > 11) { response = DateLocale.getPM(); } else { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java b/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java index 9e1e316045..82fa241487 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.util; import java.util.Date; @@ -57,7 +61,7 @@ public class SimpleDateParser { { "y", "(\\d{1,2})", DateLocale.TOKEN_YEAR }, { "a", "(\\S{1,4})", DateLocale.TOKEN_AM_PM } }; - private Pattern regularExpression; + private final Pattern regularExpression; private String instructions = ""; @@ -67,7 +71,7 @@ public class SimpleDateParser { } if (format.startsWith("'")) { format = format.substring(1); - int end = format.indexOf("'"); + final int end = format.indexOf("'"); if (end == -1) { throw new IllegalArgumentException("Unmatched single quotes."); } @@ -75,8 +79,8 @@ public class SimpleDateParser { format = format.substring(end + 1); } for (int i = 0; i < TOKENS.length; i++) { - String[] row = TOKENS[i]; - String datePattern = row[DATE_PATTERN]; + final String[] row = TOKENS[i]; + final String datePattern = row[DATE_PATTERN]; if (!format.startsWith(datePattern)) { continue; } @@ -111,9 +115,10 @@ public class SimpleDateParser { if (component.equals(DateLocale.TOKEN_HOUR_12)) { int h = Integer.parseInt(text); - String token = com.itmill.toolkit.terminal.gwt.client.DateLocale + final String token = com.itmill.toolkit.terminal.gwt.client.DateLocale .getPM(); - String which = input.substring(input.length() - token.length()); // Assumes + final String which = input.substring(input.length() + - token.length()); // Assumes // both // AM // and @@ -142,15 +147,15 @@ public class SimpleDateParser { } public SimpleDateParser(String format) { - String[] args = new String[] { "", "" }; + final String[] args = new String[] { "", "" }; _parse(format, args); regularExpression = new Pattern(args[REGEX]); instructions = args[INSTRUCTION]; } public Date parse(String input) { - Date date = new Date(0, 0, 0, 0, 0, 0); - String matches[] = regularExpression.match(input); + final Date date = new Date(0, 0, 0, 0, 0, 0); + final String matches[] = regularExpression.match(input); if (matches == null) { throw new IllegalArgumentException(input + " does not match " + regularExpression.pattern()); @@ -160,7 +165,7 @@ public class SimpleDateParser { + input + " does not match " + regularExpression.pattern()); } for (int group = 0; group < instructions.length(); group++) { - String match = matches[group + 1]; + final String match = matches[group + 1]; load(date, match, "" + instructions.charAt(group), input, regularExpression); } diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java index c7d9f8357d..4a43d22d2d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal.gwt.server; @@ -102,7 +78,7 @@ public class ApplicationServlet extends HttpServlet { } else { VERSION = "@VERSION@"; } - String[] digits = VERSION.split("\\."); + final String[] digits = VERSION.split("\\."); VERSION_MAJOR = Integer.parseInt(digits[0]); VERSION_MINOR = Integer.parseInt(digits[1]); VERSION_BUILD = digits[2]; @@ -166,38 +142,39 @@ public class ApplicationServlet extends HttpServlet { super.init(servletConfig); // Get applicationRunner - String applicationRunner = servletConfig + final String applicationRunner = servletConfig .getInitParameter("applicationRunner"); if (applicationRunner != null) { - if ("true".equals(applicationRunner)) + if ("true".equals(applicationRunner)) { applicationRunnerMode = true; - else if ("false".equals(applicationRunner)) + } else if ("false".equals(applicationRunner)) { applicationRunnerMode = false; - else + } else { throw new ServletException( "If applicationRunner parameter is given for an application, it must be 'true' or 'false'"); + } } // Stores the application parameters into Properties object applicationProperties = new Properties(); - for (Enumeration e = servletConfig.getInitParameterNames(); e + for (final Enumeration e = servletConfig.getInitParameterNames(); e .hasMoreElements();) { - String name = (String) e.nextElement(); + final String name = (String) e.nextElement(); applicationProperties.setProperty(name, servletConfig .getInitParameter(name)); } // Overrides with server.xml parameters - ServletContext context = servletConfig.getServletContext(); - for (Enumeration e = context.getInitParameterNames(); e + final ServletContext context = servletConfig.getServletContext(); + for (final Enumeration e = context.getInitParameterNames(); e .hasMoreElements();) { - String name = (String) e.nextElement(); + final String name = (String) e.nextElement(); applicationProperties.setProperty(name, context .getInitParameter(name)); } // Gets the debug window parameter - String debug = getApplicationOrSystemProperty(PARAMETER_DEBUG, "") + final String debug = getApplicationOrSystemProperty(PARAMETER_DEBUG, "") .toLowerCase(); // Enables application specific debug @@ -209,20 +186,20 @@ public class ApplicationServlet extends HttpServlet { debugMode = debug; // Gets custom class loader - String classLoaderName = getApplicationOrSystemProperty("ClassLoader", - null); + final String classLoaderName = getApplicationOrSystemProperty( + "ClassLoader", null); ClassLoader classLoader; if (classLoaderName == null) { classLoader = getClass().getClassLoader(); } else { try { - Class classLoaderClass = getClass().getClassLoader().loadClass( - classLoaderName); - Constructor c = classLoaderClass + final Class classLoaderClass = getClass().getClassLoader() + .loadClass(classLoaderName); + final Constructor c = classLoaderClass .getConstructor(new Class[] { ClassLoader.class }); classLoader = (ClassLoader) c .newInstance(new Object[] { getClass().getClassLoader() }); - } catch (Exception e) { + } catch (final Exception e) { System.err.println("Could not find specified class loader: " + classLoaderName); throw new ServletException(e); @@ -234,14 +211,15 @@ public class ApplicationServlet extends HttpServlet { // as the servlet itself if (!applicationRunnerMode) { // Gets the application class name - String applicationClassName = servletConfig + final String applicationClassName = servletConfig .getInitParameter("application"); - if (applicationClassName == null) + if (applicationClassName == null) { throw new ServletException( "Application not specified in servlet parameters"); + } try { applicationClass = classLoader.loadClass(applicationClassName); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { throw new ServletException("Failed to load application class: " + applicationClassName); } @@ -278,11 +256,11 @@ public class ApplicationServlet extends HttpServlet { // Try system properties String pkgName; - Package pkg = getClass().getPackage(); + final Package pkg = getClass().getPackage(); if (pkg != null) { pkgName = pkg.getName(); } else { - String className = getClass().getName(); + final String className = getClass().getName(); pkgName = new String(className.toCharArray(), 0, className .lastIndexOf('.')); } @@ -322,7 +300,7 @@ public class ApplicationServlet extends HttpServlet { if (request.getPathInfo() != null) { if (applicationRunnerMode && (request.getPathInfo().indexOf("/", 1) != -1)) { - String resourceUrl = request.getPathInfo().substring( + final String resourceUrl = request.getPathInfo().substring( request.getPathInfo().indexOf('/', 1)); if (resourceUrl.startsWith("/ITMILL/")) { serveStaticResourcesInITMILL(resourceUrl, response); @@ -346,8 +324,8 @@ public class ApplicationServlet extends HttpServlet { } // Update browser details - WebBrowser browser = WebApplicationContext.getApplicationContext( - request.getSession()).getBrowser(); + final WebBrowser browser = WebApplicationContext + .getApplicationContext(request.getSession()).getBrowser(); browser.updateBrowserProperties(request); // TODO Add screen height and width to the GWT client @@ -367,12 +345,12 @@ public class ApplicationServlet extends HttpServlet { DownloadStream download = null; // Handles AJAX UIDL requests - String resourceId = request.getPathInfo(); + final String resourceId = request.getPathInfo(); if (resourceId != null) { if (applicationRunnerMode) { if (resourceId.indexOf("/", 1) != -1) { - String resourceUrl = resourceId.substring(resourceId - .indexOf('/', 1)); + final String resourceUrl = resourceId + .substring(resourceId.indexOf('/', 1)); if (resourceId != null && (resourceUrl.startsWith(AJAX_UIDL_URI))) { getApplicationManager(application) @@ -433,7 +411,7 @@ public class ApplicationServlet extends HttpServlet { } // Handle parameters - Map parameters = request.getParameterMap(); + final Map parameters = request.getParameterMap(); if (window != null && parameters != null) { window.handleParameters(parameters); } @@ -446,7 +424,7 @@ public class ApplicationServlet extends HttpServlet { handleDownload(download, request, response); } - } catch (Throwable e) { + } catch (final Throwable e) { // Print stacktrace e.printStackTrace(); // Re-throw other exceptions @@ -470,7 +448,7 @@ public class ApplicationServlet extends HttpServlet { */ private void serveStaticResourcesInITMILL(String filename, HttpServletResponse response) throws IOException { - ServletContext sc = getServletContext(); + final ServletContext sc = getServletContext(); InputStream is = sc.getResourceAsStream(filename); if (is == null) { // try if requested file is found from classloader @@ -478,7 +456,7 @@ public class ApplicationServlet extends HttpServlet { // strip leading "/" otherwise stream from JAR wont work filename = filename.substring(1); is = classLoader.getResourceAsStream(filename); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } if (is == null) { @@ -492,12 +470,12 @@ public class ApplicationServlet extends HttpServlet { return; } } - String mimetype = sc.getMimeType(filename); + final String mimetype = sc.getMimeType(filename); if (mimetype != null) { response.setContentType(mimetype); } - OutputStream os = response.getOutputStream(); - byte buffer[] = new byte[20000]; + final OutputStream os = response.getOutputStream(); + final byte buffer[] = new byte[20000]; int bytes; while ((bytes = is.read(buffer)) >= 0) { os.write(buffer, 0, bytes); @@ -525,9 +503,9 @@ public class ApplicationServlet extends HttpServlet { HttpServletResponse response, Window window, String themeName) throws IOException, MalformedURLException { response.setContentType("text/html"); - BufferedWriter page = new BufferedWriter(new OutputStreamWriter( + final BufferedWriter page = new BufferedWriter(new OutputStreamWriter( response.getOutputStream())); - String pathInfo = request.getPathInfo() == null ? "/" : request + final String pathInfo = request.getPathInfo() == null ? "/" : request .getPathInfo(); page .write(" MAX_BUFFER_SIZE) { bufferSize = DEFAULT_BUFFER_SIZE; } - byte[] buffer = new byte[bufferSize]; + final byte[] buffer = new byte[bufferSize]; int bytesRead = 0; try { - OutputStream out = response.getOutputStream(); + final OutputStream out = response.getOutputStream(); while ((bytesRead = data.read(buffer)) > 0) { out.write(buffer, 0, bytesRead); out.flush(); } out.close(); - } catch (IOException ignored) { + } catch (final IOException ignored) { } } @@ -758,7 +737,7 @@ public class ApplicationServlet extends HttpServlet { try { data = getServletContext().getResourceAsStream( THEME_DIRECTORY_PATH + themeName + "/" + resourceId); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); data = null; } @@ -779,9 +758,9 @@ public class ApplicationServlet extends HttpServlet { // Tomcats // Writes the data to client - byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; + final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int bytesRead = 0; - OutputStream out = response.getOutputStream(); + final OutputStream out = response.getOutputStream(); while ((bytesRead = data.read(buffer)) > 0) { out.write(buffer, 0, bytesRead); } @@ -791,7 +770,7 @@ public class ApplicationServlet extends HttpServlet { response.sendError(HttpServletResponse.SC_NOT_FOUND); } - } catch (java.io.IOException e) { + } catch (final java.io.IOException e) { System.err.println("Resource transfer failed: " + request.getRequestURI() + ". (" + e.getMessage() + ")"); } @@ -813,7 +792,7 @@ public class ApplicationServlet extends HttpServlet { URL applicationUrl; try { - URL reqURL = new URL( + final URL reqURL = new URL( (request.isSecure() ? "https://" : "http://") + request.getServerName() + ((request.isSecure() && request.getServerPort() == 443) @@ -821,8 +800,9 @@ public class ApplicationServlet extends HttpServlet { .getServerPort() == 80) ? "" : ":" + request.getServerPort()) + request.getRequestURI()); - if (applicationRunnerMode) + if (applicationRunnerMode) { return reqURL; + } String servletPath = request.getContextPath() + request.getServletPath(); if (servletPath.length() == 0 @@ -830,7 +810,7 @@ public class ApplicationServlet extends HttpServlet { servletPath = servletPath + "/"; } applicationUrl = new URL(reqURL, servletPath); - } catch (MalformedURLException e) { + } catch (final MalformedURLException e) { System.err.println("Error constructing application url " + request.getRequestURI() + " (" + e + ")"); throw e; @@ -863,27 +843,28 @@ public class ApplicationServlet extends HttpServlet { InstantiationException { // Ensures that the session is still valid - HttpSession session = request.getSession(true); + final HttpSession session = request.getSession(true); // Gets application list for the session. - Collection applications = WebApplicationContext.getApplicationContext( - session).getApplications(); + final Collection applications = WebApplicationContext + .getApplicationContext(session).getApplications(); // Search for the application (using the application URI) from the list - for (Iterator i = applications.iterator(); i.hasNext();) { - Application a = (Application) i.next(); - String aPath = a.getURL().getPath(); + for (final Iterator i = applications.iterator(); i.hasNext();) { + final Application a = (Application) i.next(); + final String aPath = a.getURL().getPath(); String servletPath = request.getContextPath() + request.getServletPath(); if (servletPath.length() < aPath.length()) { servletPath += "/"; } if (applicationRunnerMode) { - if (request.getPathInfo().indexOf('/', 1) == -1) + if (request.getPathInfo().indexOf('/', 1) == -1) { servletPath += request.getPathInfo(); - else + } else { servletPath += request.getPathInfo().substring(1, request.getPathInfo().indexOf('/', 1)); + } } if (servletPath.equals(aPath)) { @@ -899,16 +880,16 @@ public class ApplicationServlet extends HttpServlet { } } // Creates application, because a running one was not found - WebApplicationContext context = WebApplicationContext + final WebApplicationContext context = WebApplicationContext .getApplicationContext(request.getSession()); - URL applicationUrl = getApplicationUrl(request); + final URL applicationUrl = getApplicationUrl(request); if (applicationRunnerMode) { - String applicationClassName = applicationUrl.getPath().substring( - applicationUrl.getPath().lastIndexOf('/') + 1); + final String applicationClassName = applicationUrl.getPath() + .substring(applicationUrl.getPath().lastIndexOf('/') + 1); try { applicationClass = classLoader.loadClass(applicationClassName); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { throw new InstantiationException( "Failed to load application class: " + applicationClassName); @@ -917,7 +898,7 @@ public class ApplicationServlet extends HttpServlet { // Creates new application and start it try { - Application application = (Application) applicationClass + final Application application = (Application) applicationClass .newInstance(); context.addApplication(application); @@ -928,11 +909,11 @@ public class ApplicationServlet extends HttpServlet { application.start(applicationUrl, applicationProperties, context); return application; - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { System.err.println("Illegal access to application class " + applicationClass.getName()); throw e; - } catch (InstantiationException e) { + } catch (final InstantiationException e) { System.err.println("Failed to instantiate application class: " + applicationClass.getName()); throw e; @@ -960,7 +941,7 @@ public class ApplicationServlet extends HttpServlet { logoutUrl = application.getURL().toString(); } - HttpSession session = request.getSession(); + final HttpSession session = request.getSession(); if (session != null) { WebApplicationContext.getApplicationContext(session) .removeApplication(application); @@ -998,7 +979,7 @@ public class ApplicationServlet extends HttpServlet { if (path.charAt(0) == '/') { path = path.substring(1); } - int index = path.indexOf('/'); + final int index = path.indexOf('/'); if (index < 0) { windowName = path; path = ""; @@ -1050,7 +1031,7 @@ public class ApplicationServlet extends HttpServlet { */ public boolean isDebugMode(Map parameters) { if (parameters != null) { - Object[] debug = (Object[]) parameters.get("debug"); + final Object[] debug = (Object[]) parameters.get("debug"); if (debug != null && !"false".equals(debug[0].toString()) && !"false".equals(debugMode)) { return true; @@ -1171,9 +1152,9 @@ public class ApplicationServlet extends HttpServlet { return resultPath; } else { try { - URL url = servletContext.getResource(path); + final URL url = servletContext.getResource(path); resultPath = url.getFile(); - } catch (Exception e) { + } catch (final Exception e) { // ignored } } diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index 6ecdb543f2..591e3e19d0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -1,30 +1,6 @@ -/* ************************************************************************* - - IT Mill Toolkit - - Development of Browser User Interfaces Made Easy - - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* - - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html - - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com - - ********************************************************************** */ +/* +@ITMillApache2LicenseForJavaFiles@ + */ package com.itmill.toolkit.terminal.gwt.server; @@ -96,17 +72,17 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, private static int MAX_BUFFER_SIZE = 64 * 1024; - private HashSet dirtyPaintabletSet = new HashSet(); + private final HashSet dirtyPaintabletSet = new HashSet(); - private WeakHashMap paintableIdMap = new WeakHashMap(); + private final WeakHashMap paintableIdMap = new WeakHashMap(); - private WeakHashMap idPaintableMap = new WeakHashMap(); + private final WeakHashMap idPaintableMap = new WeakHashMap(); private int idSequence = 0; - private Application application; + private final Application application; - private Set removedWindows = new HashSet(); + private final Set removedWindows = new HashSet(); private JsonPaintTarget paintTarget; @@ -114,7 +90,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, private int pendingLocalesIndex; - private ApplicationServlet applicationServlet; + private final ApplicationServlet applicationServlet; public CommunicationManager(Application application, ApplicationServlet applicationServlet) { @@ -152,9 +128,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, public void handleFileUpload(HttpServletRequest request, HttpServletResponse response) throws IOException { // Create a new file upload handler - ServletFileUpload upload = new ServletFileUpload(); + final ServletFileUpload upload = new ServletFileUpload(); - UploadProgressListener pl = new UploadProgressListener(); + final UploadProgressListener pl = new UploadProgressListener(); upload.setProgressListener(pl); @@ -168,16 +144,17 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, * request. */ while (iter.hasNext()) { - FileItemStream item = iter.next(); - String name = item.getFieldName(); + final FileItemStream item = iter.next(); + final String name = item.getFieldName(); final String filename = item.getName(); final String mimeType = item.getContentType(); final InputStream stream = item.openStream(); if (item.isFormField()) { // ignored, upload requests contian only files } else { - String pid = name.split("_")[0]; - Upload uploadComponent = (Upload) idPaintableMap.get(pid); + final String pid = name.split("_")[0]; + final Upload uploadComponent = (Upload) idPaintableMap + .get(pid); if (uploadComponent == null) { throw new FileUploadException( "Upload component not found"); @@ -186,7 +163,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, // put upload component into receiving state uploadComponent.startUpload(); } - UploadStream upstream = new UploadStream() { + final UploadStream upstream = new UploadStream() { public String getContentName() { return filename; @@ -213,14 +190,14 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, uploadComponent.receiveUpload(upstream); } } - } catch (FileUploadException e) { + } catch (final FileUploadException e) { e.printStackTrace(); } // Send short response to acknowledge client that request was done response.setContentType("text/html"); - OutputStream out = response.getOutputStream(); - PrintWriter outWriter = new PrintWriter(new BufferedWriter( + final OutputStream out = response.getOutputStream(); + final PrintWriter outWriter = new PrintWriter(new BufferedWriter( new OutputStreamWriter(out, "UTF-8"))); outWriter.print("download handled"); outWriter.flush(); @@ -241,8 +218,8 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, boolean repaintAll = (request.getParameter(GET_PARAM_REPAINT_ALL) != null) || request.getSession().isNew(); - OutputStream out = response.getOutputStream(); - PrintWriter outWriter = new PrintWriter(new BufferedWriter( + final OutputStream out = response.getOutputStream(); + final PrintWriter outWriter = new PrintWriter(new BufferedWriter( new OutputStreamWriter(out, "UTF-8"))); try { @@ -266,9 +243,10 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, // If repaint is requested, clean all ids in this root window if (repaintAll) { - for (Iterator it = idPaintableMap.keySet().iterator(); it + for (final Iterator it = idPaintableMap.keySet().iterator(); it .hasNext();) { - Component c = (Component) idPaintableMap.get(it.next()); + final Component c = (Component) idPaintableMap.get(it + .next()); if (isChildOf(window, c)) { it.remove(); paintableIdMap.remove(c); @@ -310,14 +288,14 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, if (paintables != null) { // Creates "working copy" of the current state. - List currentPaintables = new ArrayList(paintables); + final List currentPaintables = new ArrayList(paintables); // Sorts the Paintable list so that parents // are always painted before children Collections.sort(currentPaintables, new Comparator() { public int compare(Object o1, Object o2) { - Component c1 = (Component) o1; - Component c2 = (Component) o2; + final Component c1 = (Component) o1; + final Component c2 = (Component) o2; if (isChildOf(c1, c2)) { return -1; } @@ -328,12 +306,13 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, } }); - for (Iterator i = currentPaintables.iterator(); i.hasNext();) { - Paintable p = (Paintable) i.next(); + for (final Iterator i = currentPaintables.iterator(); i + .hasNext();) { + final Paintable p = (Paintable) i.next(); // TODO CLEAN if (p instanceof Window) { - Window w = (Window) p; + final Window w = (Window) p; if (w.getTerminal() == null) { w.setTerminal(application.getMainWindow() .getTerminal()); @@ -352,7 +331,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, // rendered already (changes with only cached flag) paintTarget.startTag("change"); paintTarget.addAttribute("format", "uidl"); - String pid = getPaintableId(p); + final String pid = getPaintableId(p); paintTarget.addAttribute("pid", pid); // Track paints to identify empty paints @@ -372,10 +351,10 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, outWriter.print("]"); // close changes outWriter.print(", \"meta\" : {"); - boolean metaOpen = false; + final boolean metaOpen = false; // add meta instruction for client to set focus if it is set - Paintable f = (Paintable) application.consumeFocus(); + final Paintable f = (Paintable) application.consumeFocus(); if (f != null) { if (metaOpen) { outWriter.write(","); @@ -397,9 +376,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, // TODO We should only precache the layouts that are not // cached already int resourceIndex = 0; - for (Iterator i = paintTarget.getPreCachedResources() + for (final Iterator i = paintTarget.getPreCachedResources() .iterator(); i.hasNext();) { - String resource = (String) i.next(); + final String resource = (String) i.next(); InputStream is = null; try { is = applicationServlet @@ -408,24 +387,25 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, "/" + ApplicationServlet.THEME_DIRECTORY_PATH + themeName + "/" + resource); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } if (is != null) { outWriter.print((resourceIndex++ > 0 ? ", " : "") + "\"" + resource + "\" : "); - StringBuffer layout = new StringBuffer(); + final StringBuffer layout = new StringBuffer(); try { - InputStreamReader r = new InputStreamReader(is); - char[] buffer = new char[20000]; + final InputStreamReader r = new InputStreamReader( + is); + final char[] buffer = new char[20000]; int charsRead = 0; while ((charsRead = r.read(buffer)) > 0) { layout.append(buffer, 0, charsRead); } r.close(); - } catch (java.io.IOException e) { + } catch (final java.io.IOException e) { System.err.println("Resource transfer failed: " + request.getRequestURI() + ". (" + e.getMessage() + ")"); @@ -447,13 +427,13 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, out.flush(); out.close(); - } catch (Throwable e) { + } catch (final Throwable e) { e.printStackTrace(); // Writes the error report to client // FIXME breaks UIDL response, security shouldn't reveal stack trace // to client side - OutputStreamWriter w = new OutputStreamWriter(out); - PrintWriter err = new PrintWriter(w); + final OutputStreamWriter w = new OutputStreamWriter(out); + final PrintWriter err = new PrintWriter(w); err .write("Application Internal Error"); err.write("

" + e.toString() + "

\n");
@@ -469,16 +449,16 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
     private Map handleVariables(HttpServletRequest request,
             Application application2) {
 
-        Map params = new HashMap(request.getParameterMap());
-        String changes = (String) ((params.get("changes") instanceof String[]) ? ((String[]) params
+        final Map params = new HashMap(request.getParameterMap());
+        final String changes = (String) ((params.get("changes") instanceof String[]) ? ((String[]) params
                 .get("changes"))[0]
                 : params.get("changes"));
         params.remove("changes");
         if (changes != null) {
-            String[] ca = changes.split("\u0001");
+            final String[] ca = changes.split("\u0001");
             for (int i = 0; i < ca.length; i++) {
                 String[] vid = ca[i].split("_");
-                VariableOwner owner = (VariableOwner) idPaintableMap
+                final VariableOwner owner = (VariableOwner) idPaintableMap
                         .get(vid[0]);
                 if (owner != null) {
                     Map m;
@@ -547,22 +527,23 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
 
         // Store JVM default locale for later restoration
         // (we'll have to change the default locale for a while)
-        Locale jvmDefault = Locale.getDefault();
+        final Locale jvmDefault = Locale.getDefault();
 
         // Send locale informations to client
         outWriter.print(", \"locales\":[");
         for (; pendingLocalesIndex < locales.size(); pendingLocalesIndex++) {
 
-            Locale l = generateLocale((String) locales.get(pendingLocalesIndex));
+            final Locale l = generateLocale((String) locales
+                    .get(pendingLocalesIndex));
             // Locale name
             outWriter.print("{\"name\":\"" + l.toString() + "\",");
 
             /*
              * Month names (both short and full)
              */
-            DateFormatSymbols dfs = new DateFormatSymbols(l);
-            String[] short_months = dfs.getShortMonths();
-            String[] months = dfs.getMonths();
+            final DateFormatSymbols dfs = new DateFormatSymbols(l);
+            final String[] short_months = dfs.getShortMonths();
+            final String[] months = dfs.getMonths();
             outWriter.print("\"smn\":[\""
                     + // ShortMonthNames
                     short_months[0] + "\",\"" + short_months[1] + "\",\""
@@ -583,8 +564,8 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
             /*
              * Weekday names (both short and full)
              */
-            String[] short_days = dfs.getShortWeekdays();
-            String[] days = dfs.getWeekdays();
+            final String[] short_days = dfs.getShortWeekdays();
+            final String[] days = dfs.getWeekdays();
             outWriter.print("\"sdn\":[\""
                     + // ShortDayNames
                     short_days[1] + "\",\"" + short_days[2] + "\",\""
@@ -600,7 +581,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
             /*
              * First day of week (0 = sunday, 1 = monday)
              */
-            Calendar cal = new GregorianCalendar(l);
+            final Calendar cal = new GregorianCalendar(l);
             outWriter.print("\"fdow\":" + (cal.getFirstDayOfWeek() - 1) + ",");
 
             /*
@@ -609,41 +590,41 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
             // Force our locale as JVM default for a while (SimpleDateFormat
             // uses JVM default)
             Locale.setDefault(l);
-            String df = new SimpleDateFormat().toPattern();
+            final String df = new SimpleDateFormat().toPattern();
             int timeStart = df.indexOf("H");
             if (timeStart < 0) {
                 timeStart = df.indexOf("h");
             }
-            int ampm_first = df.indexOf("a");
+            final int ampm_first = df.indexOf("a");
             // E.g. in Korean locale AM/PM is before h:mm
             // TODO should take that into consideration on client-side as well,
             // now always h:mm a
             if (ampm_first > 0 && ampm_first < timeStart) {
                 timeStart = ampm_first;
             }
-            String dateformat = df.substring(0, timeStart - 1);
+            final String dateformat = df.substring(0, timeStart - 1);
 
             outWriter.print("\"df\":\"" + dateformat.trim() + "\",");
 
             /*
              * Time formatting (24 or 12 hour clock and AM/PM suffixes)
              */
-            String timeformat = df.substring(timeStart, df.length()); // Doesn't
+            final String timeformat = df.substring(timeStart, df.length()); // Doesn't
             // return
             // second
             // or
             // milliseconds
             // We use timeformat to determine 12/24-hour clock
-            boolean twelve_hour_clock = timeformat.indexOf("a") > -1;
+            final boolean twelve_hour_clock = timeformat.indexOf("a") > -1;
             // TODO there are other possibilities as well, like 'h' in french
             // (ignore them, too complicated)
-            String hour_min_delimiter = timeformat.indexOf(".") > -1 ? "."
+            final String hour_min_delimiter = timeformat.indexOf(".") > -1 ? "."
                     : ":";
             // outWriter.print("\"tf\":\"" + timeformat + "\",");
             outWriter.print("\"thc\":" + twelve_hour_clock + ",");
             outWriter.print("\"hmd\":\"" + hour_min_delimiter + "\"");
             if (twelve_hour_clock) {
-                String[] ampm = dfs.getAmPmStrings();
+                final String[] ampm = dfs.getAmPmStrings();
                 outWriter.print(",\"ampm\":[\"" + ampm[0] + "\",\"" + ampm[1]
                         + "\"]");
             }
@@ -690,7 +671,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
             if (path.charAt(0) == '/') {
                 path = path.substring(1);
             }
-            int index = path.indexOf('/');
+            final int index = path.indexOf('/');
             if (index < 0) {
                 windowName = path;
                 path = "";
@@ -729,14 +710,14 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
             HttpServletRequest request, HttpServletResponse response) {
 
         // Download from given stream
-        InputStream data = stream.getStream();
+        final InputStream data = stream.getStream();
         if (data != null) {
 
             // Sets content type
             response.setContentType(stream.getContentType());
 
             // Sets cache headers
-            long cacheTime = stream.getCacheTime();
+            final long cacheTime = stream.getCacheTime();
             if (cacheTime <= 0) {
                 response.setHeader("Cache-Control", "no-cache");
                 response.setHeader("Pragma", "no-cache");
@@ -753,10 +734,10 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
 
             // Copy download stream parameters directly
             // to HTTP headers.
-            Iterator i = stream.getParameterNames();
+            final Iterator i = stream.getParameterNames();
             if (i != null) {
                 while (i.hasNext()) {
-                    String param = (String) i.next();
+                    final String param = (String) i.next();
                     response.setHeader(param, stream.getParameter(param));
                 }
             }
@@ -765,18 +746,18 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
             if (bufferSize <= 0 || bufferSize > MAX_BUFFER_SIZE) {
                 bufferSize = DEFAULT_BUFFER_SIZE;
             }
-            byte[] buffer = new byte[bufferSize];
+            final byte[] buffer = new byte[bufferSize];
             int bytesRead = 0;
 
             try {
-                OutputStream out = response.getOutputStream();
+                final OutputStream out = response.getOutputStream();
 
                 while ((bytesRead = data.read(buffer)) > 0) {
                     out.write(buffer, 0, bytesRead);
                     out.flush();
                 }
                 out.close();
-            } catch (IOException ignored) {
+            } catch (final IOException ignored) {
             }
 
         }
@@ -807,8 +788,8 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
         // tell client that application has quit and where to point browser now
         // Set the response type
         response.setContentType("application/json; charset=UTF-8");
-        ServletOutputStream out = response.getOutputStream();
-        PrintWriter outWriter = new PrintWriter(new BufferedWriter(
+        final ServletOutputStream out = response.getOutputStream();
+        final PrintWriter outWriter = new PrintWriter(new BufferedWriter(
                 new OutputStreamWriter(out, "UTF-8")));
         outWriter.print(")/*{");
         outWriter.print("\"redirect\":{");
@@ -847,7 +828,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
      * @return
      */
     public synchronized Set getDirtyComponents(Window w) {
-        HashSet resultset = new HashSet(dirtyPaintabletSet);
+        final HashSet resultset = new HashSet(dirtyPaintabletSet);
 
         // The following algorithm removes any components that would be painted
         // as
@@ -856,10 +837,10 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
         // The result is that each component should be painted exactly once and
         // any unmodified components will be painted as "cached=true".
 
-        for (Iterator i = dirtyPaintabletSet.iterator(); i.hasNext();) {
-            Paintable p = (Paintable) i.next();
+        for (final Iterator i = dirtyPaintabletSet.iterator(); i.hasNext();) {
+            final Paintable p = (Paintable) i.next();
             if (p instanceof Component) {
-                Component component = (Component) p;
+                final Component component = (Component) p;
                 if (component.getApplication() == null) {
                     // component is detached after requestRepaint is called
                     resultset.remove(p);
@@ -886,7 +867,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
      * @see com.itmill.toolkit.terminal.Paintable.RepaintRequestListener#repaintRequested(com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent)
      */
     public void repaintRequested(RepaintRequestEvent event) {
-        Paintable p = event.getPaintable();
+        final Paintable p = event.getPaintable();
         dirtyPaintabletSet.add(p);
 
     }
@@ -963,7 +944,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
         }
 
         public Set entrySet() {
-            Set s = new HashSet();
+            final Set s = new HashSet();
             s.add(new Map.Entry() {
 
                 public Object getKey() {
@@ -993,7 +974,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
         }
 
         public Set keySet() {
-            Set s = new HashSet();
+            final Set s = new HashSet();
             s.add(name);
             return s;
         }
@@ -1015,7 +996,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
         }
 
         public Collection values() {
-            LinkedList s = new LinkedList();
+            final LinkedList s = new LinkedList();
             s.add(value);
             return s;
 
@@ -1027,9 +1008,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
      */
     public class URIHandlerErrorImpl implements URIHandler.ErrorEvent {
 
-        private URIHandler owner;
+        private final URIHandler owner;
 
-        private Throwable throwable;
+        private final Throwable throwable;
 
         /**
          * 
@@ -1068,7 +1049,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
     }
 
     private Locale generateLocale(String value) {
-        String[] temp = value.split("_");
+        final String[] temp = value.split("_");
         if (temp.length == 1) {
             return new Locale(temp[0]);
         } else if (temp.length == 2) {
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java b/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java
index 2593addef7..2888907c90 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java
@@ -1,30 +1,6 @@
-/* *************************************************************************
- 
- IT Mill Toolkit 
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
- 
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might 
- require purchasing a commercial license from IT Mill Ltd. For guidelines 
- on usage, see licensing-guidelines.html
-
- *************************************************************************
- 
- For more information, contact:
- 
- IT Mill Ltd                           phone: +358 2 4802 7180
- Ruukinkatu 2-4                        fax:   +358 2 4802 7181
- 20540, Turku                          email:  info@itmill.com
- Finland                               company www: www.itmill.com
- 
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
 
 package com.itmill.toolkit.terminal.gwt.server;
 
@@ -44,16 +20,16 @@ public class HttpUploadStream implements
     /**
      * Holds value of property variableName.
      */
-    private String streamName;
+    private final String streamName;
 
-    private String contentName;
+    private final String contentName;
 
-    private String contentType;
+    private final String contentType;
 
     /**
      * Holds value of property variableValue.
      */
-    private InputStream stream;
+    private final InputStream stream;
 
     /**
      * Creates a new instance of UploadStreamImpl.
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java b/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java
index 3c8f413e35..1de91128b6 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java
@@ -1,30 +1,6 @@
-/* *************************************************************************
- 
- IT Mill Toolkit 
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
- 
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might 
- require purchasing a commercial license from IT Mill Ltd. For guidelines 
- on usage, see licensing-guidelines.html
-
- *************************************************************************
- 
- For more information, contact:
- 
- IT Mill Ltd                           phone: +358 2 4802 7180
- Ruukinkatu 2-4                        fax:   +358 2 4802 7181
- 20540, Turku                          email:  info@itmill.com
- Finland                               company www: www.itmill.com
- 
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
 
 package com.itmill.toolkit.terminal.gwt.server;
 
@@ -63,17 +39,17 @@ public class JsonPaintTarget implements PaintTarget {
 
     private final static String UIDL_ARG_ID = "id";
 
-    private Stack mOpenTags;
+    private final Stack mOpenTags;
 
-    private Stack openJsonTags;
+    private final Stack openJsonTags;
 
     private boolean mTagArgumentListOpen;
 
-    private PrintWriter uidlBuffer;
+    private final PrintWriter uidlBuffer;
 
     private boolean closed = false;
 
-    private CommunicationManager manager;
+    private final CommunicationManager manager;
 
     private boolean trackPaints = false;
 
@@ -199,7 +175,7 @@ public class JsonPaintTarget implements PaintTarget {
         }
 
         if (openJsonTags.size() > 0) {
-            JsonTag parent = (JsonTag) openJsonTags.pop();
+            final JsonTag parent = (JsonTag) openJsonTags.pop();
 
             String lastTag = "";
 
@@ -260,11 +236,11 @@ public class JsonPaintTarget implements PaintTarget {
             return new StringBuffer("");
         }
 
-        StringBuffer result = new StringBuffer(xml.length() * 2);
+        final StringBuffer result = new StringBuffer(xml.length() * 2);
 
         for (int i = 0; i < xml.length(); i++) {
-            char c = xml.charAt(i);
-            String s = toXmlChar(c);
+            final char c = xml.charAt(i);
+            final String s = toXmlChar(c);
             if (s != null) {
                 result.append(s);
             } else {
@@ -278,9 +254,9 @@ public class JsonPaintTarget implements PaintTarget {
         if (s == null) {
             return "";
         }
-        StringBuffer sb = new StringBuffer();
+        final StringBuffer sb = new StringBuffer();
         for (int i = 0; i < s.length(); i++) {
-            char ch = s.charAt(i);
+            final char ch = s.charAt(i);
             switch (ch) {
             case '"':
                 sb.append("\\\"");
@@ -308,7 +284,7 @@ public class JsonPaintTarget implements PaintTarget {
                 break;
             default:
                 if (ch >= '\u0000' && ch <= '\u001F') {
-                    String ss = Integer.toHexString(ch);
+                    final String ss = Integer.toHexString(ch);
                     sb.append("\\u");
                     for (int k = 0; k < 4 - ss.length(); k++) {
                         sb.append('0');
@@ -392,8 +368,8 @@ public class JsonPaintTarget implements PaintTarget {
             addAttribute(name, ((ExternalResource) value).getURL());
 
         } else if (value instanceof ApplicationResource) {
-            ApplicationResource r = (ApplicationResource) value;
-            Application a = r.getApplication();
+            final ApplicationResource r = (ApplicationResource) value;
+            final Application a = r.getApplication();
             if (a == null) {
                 throw new PaintException(
                         "Application not specified for resorce "
@@ -412,7 +388,8 @@ public class JsonPaintTarget implements PaintTarget {
             addAttribute(name, uri);
 
         } else if (value instanceof ThemeResource) {
-            String uri = "theme://" + ((ThemeResource) value).getResourceId();
+            final String uri = "theme://"
+                    + ((ThemeResource) value).getResourceId();
             addAttribute(name, uri);
         } else {
             throw new PaintException("Ajax adapter does not "
@@ -523,7 +500,7 @@ public class JsonPaintTarget implements PaintTarget {
             throw new NullPointerException(
                     "Parameters must be non-null strings");
         }
-        StringBuffer buf = new StringBuffer();
+        final StringBuffer buf = new StringBuffer();
         buf.append("\"" + name + "\":[");
         for (int i = 0; i < values.length; i++) {
             if (i > 0) {
@@ -809,8 +786,8 @@ public class JsonPaintTarget implements PaintTarget {
     public boolean startTag(Paintable paintable, String tagName)
             throws PaintException {
         startTag(tagName, true);
-        boolean isPreviouslyPainted = manager.hasPaintableId(paintable);
-        String id = manager.getPaintableId(paintable);
+        final boolean isPreviouslyPainted = manager.hasPaintableId(paintable);
+        final String id = manager.getPaintableId(paintable);
         paintable.addListener(manager);
         addAttribute("id", id);
         return cacheEnabled && isPreviouslyPainted;
@@ -941,8 +918,8 @@ public class JsonPaintTarget implements PaintTarget {
         }
 
         public String getData() {
-            StringBuffer buf = new StringBuffer();
-            Iterator it = children.iterator();
+            final StringBuffer buf = new StringBuffer();
+            final Iterator it = children.iterator();
             while (it.hasNext()) {
                 buf.append(startField());
                 buf.append(it.next());
@@ -955,11 +932,11 @@ public class JsonPaintTarget implements PaintTarget {
         }
 
         private String attributesAsJsonObject() {
-            StringBuffer buf = new StringBuffer();
+            final StringBuffer buf = new StringBuffer();
             buf.append(startField());
             buf.append("{");
-            for (Iterator iter = attr.iterator(); iter.hasNext();) {
-                String element = (String) iter.next();
+            for (final Iterator iter = attr.iterator(); iter.hasNext();) {
+                final String element = (String) iter.next();
                 buf.append(element);
                 if (iter.hasNext()) {
                     buf.append(",");
@@ -978,12 +955,12 @@ public class JsonPaintTarget implements PaintTarget {
             if (variables.size() == 0) {
                 return "";
             }
-            StringBuffer buf = new StringBuffer();
+            final StringBuffer buf = new StringBuffer();
             buf.append(startField());
             buf.append("\"v\":{");
-            Iterator iter = variables.iterator();
+            final Iterator iter = variables.iterator();
             while (iter.hasNext()) {
-                Variable element = (Variable) iter.next();
+                final Variable element = (Variable) iter.next();
                 buf.append(element.getJsonPresentation());
                 if (iter.hasNext()) {
                     buf.append(",");
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java
index 73a43e0858..fe92303901 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java
@@ -1,30 +1,6 @@
-/* *************************************************************************
- 
- IT Mill Toolkit 
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
- 
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might 
- require purchasing a commercial license from IT Mill Ltd. For guidelines 
- on usage, see licensing-guidelines.html
-
- *************************************************************************
- 
- For more information, contact:
- 
- IT Mill Ltd                           phone: +358 2 4802 7180
- Ruukinkatu 2-4                        fax:   +358 2 4802 7181
- 20540, Turku                          email:  info@itmill.com
- Finland                               company www: www.itmill.com
- 
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
 
 package com.itmill.toolkit.terminal.gwt.server;
 
@@ -61,13 +37,13 @@ public class WebApplicationContext implements ApplicationContext,
 
     private List listeners;
 
-    private HttpSession session;
+    private final HttpSession session;
 
-    private WeakHashMap formActions = new WeakHashMap();
+    private final WeakHashMap formActions = new WeakHashMap();
 
-    private HashSet applications = new HashSet();
+    private final HashSet applications = new HashSet();
 
-    private WebBrowser browser = new WebBrowser();
+    private final WebBrowser browser = new WebBrowser();
 
     /**
      * Creates a new Web Application Context.
@@ -93,7 +69,7 @@ public class WebApplicationContext implements ApplicationContext,
      * @return the Action to be set into Form action attribute.
      */
     public String getWindowFormAction(Window window) {
-        String action = (String) formActions.get(window);
+        final String action = (String) formActions.get(window);
         return action == null ? "" : action;
     }
 
@@ -125,7 +101,7 @@ public class WebApplicationContext implements ApplicationContext,
      * @see com.itmill.toolkit.service.ApplicationContext#getBaseDirectory()
      */
     public File getBaseDirectory() {
-        String realPath = ApplicationServlet.getResourcePath(session
+        final String realPath = ApplicationServlet.getResourcePath(session
                 .getServletContext(), "/");
         if (realPath == null) {
             return null;
@@ -228,7 +204,7 @@ public class WebApplicationContext implements ApplicationContext,
         if (listeners == null) {
             return;
         }
-        for (Iterator i = listeners.iterator(); i.hasNext();) {
+        for (final Iterator i = listeners.iterator(); i.hasNext();) {
             ((ApplicationContext.TransactionListener) i.next())
                     .transactionStart(application, request);
         }
@@ -248,11 +224,11 @@ public class WebApplicationContext implements ApplicationContext,
         }
 
         LinkedList exceptions = null;
-        for (Iterator i = listeners.iterator(); i.hasNext();) {
+        for (final Iterator i = listeners.iterator(); i.hasNext();) {
             try {
                 ((ApplicationContext.TransactionListener) i.next())
                         .transactionEnd(application, request);
-            } catch (RuntimeException t) {
+            } catch (final RuntimeException t) {
                 if (exceptions == null) {
                     exceptions = new LinkedList();
                 }
@@ -262,14 +238,14 @@ public class WebApplicationContext implements ApplicationContext,
 
         // If any runtime exceptions occurred, throw a combined exception
         if (exceptions != null) {
-            StringBuffer msg = new StringBuffer();
-            for (Iterator i = listeners.iterator(); i.hasNext();) {
-                RuntimeException e = (RuntimeException) i.next();
+            final StringBuffer msg = new StringBuffer();
+            for (final Iterator i = listeners.iterator(); i.hasNext();) {
+                final RuntimeException e = (RuntimeException) i.next();
                 if (msg.length() == 0) {
                     msg.append("\n\n--------------------------\n\n");
                 }
                 msg.append(e.getMessage() + "\n");
-                StringWriter trace = new StringWriter();
+                final StringWriter trace = new StringWriter();
                 e.printStackTrace(new PrintWriter(trace, true));
                 msg.append(trace.toString());
             }
@@ -300,7 +276,8 @@ public class WebApplicationContext implements ApplicationContext,
         // closing
 
         while (!applications.isEmpty()) {
-            Application app = (Application) applications.iterator().next();
+            final Application app = (Application) applications.iterator()
+                    .next();
             app.close();
             removeApplication(app);
         }
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
index a5c94cbd29..027a8361de 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.terminal.gwt.server;
 
 import java.util.Locale;
@@ -54,18 +58,18 @@ public class WebBrowser implements Terminal {
         address = request.getRemoteAddr();
         secureConnection = request.isSecure();
 
-        String agent = request.getHeader("user-agent");
+        final String agent = request.getHeader("user-agent");
         if (agent != null) {
             browserApplication = agent;
         }
 
-        String sw = request.getParameter("screenWidth");
-        String sh = request.getParameter("screenHeight");
+        final String sw = request.getParameter("screenWidth");
+        final String sh = request.getParameter("screenHeight");
         if (sw != null && sh != null) {
             try {
                 screenHeight = Integer.parseInt(sh);
                 screenWidth = Integer.parseInt(sw);
-            } catch (NumberFormatException e) {
+            } catch (final NumberFormatException e) {
                 screenHeight = screenWidth = 0;
             }
         }
diff --git a/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java
index ff9dcefe5c..9a7f93c378 100644
--- a/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java
+++ b/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.terminal.web;
 
 import javax.servlet.ServletConfig;
diff --git a/src/com/itmill/toolkit/tests/BasicRandomTest.java b/src/com/itmill/toolkit/tests/BasicRandomTest.java
index 6e248f1177..fe3811657e 100644
--- a/src/com/itmill/toolkit/tests/BasicRandomTest.java
+++ b/src/com/itmill/toolkit/tests/BasicRandomTest.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.tests;
 
 import java.util.ArrayList;
@@ -57,17 +61,17 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
 
     private static int COMPONENT_MAX_GROUPED_NUMBER = 5;
 
-    private OrderedLayout mainLayout = new OrderedLayout();
+    private final OrderedLayout mainLayout = new OrderedLayout();
 
     private Layout testingLayout;
 
-    private TextField randomSeedValue = new TextField("Seed for random");
+    private final TextField randomSeedValue = new TextField("Seed for random");
 
-    private Button seedShuffle = new Button("Shuffle with seed", this,
+    private final Button seedShuffle = new Button("Shuffle with seed", this,
             "seedShuffle");
 
-    private Button randomShuffle = new Button("Seed randomly and shuffle",
-            this, "randomShuffle");
+    private final Button randomShuffle = new Button(
+            "Seed randomly and shuffle", this, "randomShuffle");
 
     private Label display = null;
 
@@ -83,7 +87,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
 
     private long eventCounter = 0;
 
-    private Label statusLabel = new Label();
+    private final Label statusLabel = new Label();
 
     // Store button object => real value map
     // needed because button captions are randomized
@@ -91,7 +95,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
 
     public void init() {
         // addWindow(new Window("ATFTest", create()));
-        Window mainWindow = new Window("Testing", create());
+        final Window mainWindow = new Window("Testing", create());
         setMainWindow(mainWindow);
 
         setUser(new Long(System.currentTimeMillis()).toString());
@@ -120,9 +124,9 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
                         + "through X buttons and ensure that Result label "
                         + "contains correct value.", Label.CONTENT_XHTML));
 
-        OrderedLayout setupLayout = new OrderedLayout(
+        final OrderedLayout setupLayout = new OrderedLayout(
                 OrderedLayout.ORIENTATION_HORIZONTAL);
-        Panel statusPanel = new Panel("Status");
+        final Panel statusPanel = new Panel("Status");
         statusPanel.setWidth(200);
         setupLayout.addComponent(statusPanel);
         statusPanel.addComponent(statusLabel);
@@ -155,7 +159,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
             // randomize using user given value
             rand = new Random(Long.parseLong((String) randomSeedValue
                     .getValue()));
-        } catch (Exception e) {
+        } catch (final Exception e) {
             randomize();
         }
         testingLayout = new GridLayout(5, 5);
@@ -176,7 +180,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
     }
 
     private void randomize() {
-        long newSeed = System.currentTimeMillis();
+        final long newSeed = System.currentTimeMillis();
         rand = new Random(newSeed);
         randomSeedValue.setValue(String.valueOf(newSeed));
     }
@@ -189,7 +193,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
         components = new ArrayList();
 
         // create label
-        Label userLabel = new Label("user");
+        final Label userLabel = new Label("user");
         userLabel.setValue(getUser());
         // userLabel.setUIID("Label_user");
         components.add(userLabel);
@@ -201,16 +205,16 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
         components.add(display);
 
         // create calculator buttonsStatus:
-        String[][] calcValues = {
+        final String[][] calcValues = {
                 { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-",
                         "*", "/", "=", "C" },
                 { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "plus",
                         "minus", "multiple", "divisor", "equals", "clear" } };
-        String[] randomizedCaptions = { "a", "b", "c", "y", "8", "3" };
+        final String[] randomizedCaptions = { "a", "b", "c", "y", "8", "3" };
         // String[] randomizedCaptions = { "X" };
         buttonValues = new HashMap();
         for (int i = 0; i > calcValues[0].length; i++) {
-            Button button = new Button("", this);
+            final Button button = new Button("", this);
             // Test requirement: ATF must not rely on caption
             // button.setCaption(randomizedCaptions[rand
             // .nextInt(randomizedCaptions.length)]);
@@ -238,8 +242,8 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
     private Component getComponent() {
         if (components.size() > 0) {
             // components found, return any
-            int i = rand.nextInt(components.size());
-            Component c = (Component) components.get(i);
+            final int i = rand.nextInt(components.size());
+            final Component c = (Component) components.get(i);
             components.remove(i);
             return c;
         } else {
@@ -251,23 +255,23 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
     private void addComponents(Layout layout) {
         while (components.size() > 0) {
             // Get random container
-            ComponentContainer container = getRandomComponentContainer(""
+            final ComponentContainer container = getRandomComponentContainer(""
                     + captionCounter++);
             layout.addComponent(container);
             // Get random amount of components for above container
-            int groupsize = rand.nextInt(COMPONENT_MAX_GROUPED_NUMBER) + 1;
+            final int groupsize = rand.nextInt(COMPONENT_MAX_GROUPED_NUMBER) + 1;
             for (int j = 0; j < groupsize; j++) {
-                Component c = getComponent();
+                final Component c = getComponent();
                 if (c != null) {
                     if (container instanceof TabSheet) {
-                        ComponentContainer tab = (ComponentContainer) ((TabSheet) container)
+                        final ComponentContainer tab = (ComponentContainer) ((TabSheet) container)
                                 .getSelectedTab();
                         tab.addComponent(c);
                     } else if (container instanceof GridLayout) {
-                        GridLayout gl = (GridLayout) container;
+                        final GridLayout gl = (GridLayout) container;
                         if (j == 0) {
-                            int x = rand.nextInt(gl.getWidth());
-                            int y = rand.nextInt(gl.getHeight());
+                            final int x = rand.nextInt(gl.getWidth());
+                            final int y = rand.nextInt(gl.getHeight());
                             gl.removeComponent(x, y);
                             gl.addComponent(c, x, y);
                         } else {
@@ -282,7 +286,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
     }
 
     public void buttonClick(Button.ClickEvent event) {
-        String value = (String) buttonValues.get(event.getButton());
+        final String value = (String) buttonValues.get(event.getButton());
         eventCounter++;
         try {
             // Number button pressed
@@ -292,7 +296,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
                     + ", value " + Double.toString(current));
             System.out.println("#" + eventCounter + ": button " + value
                     + ", value " + Double.toString(current));
-        } catch (java.lang.NumberFormatException e) {
+        } catch (final java.lang.NumberFormatException e) {
             // Operation button pressed
             if (operation.equals("+")) {
                 stored += current;
@@ -330,7 +334,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
      */
     private ComponentContainer getRandomComponentContainer(String caption) {
         ComponentContainer result = null;
-        int randint = rand.nextInt(5);
+        final int randint = rand.nextInt(5);
         switch (randint) {
         case 0:
             result = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
@@ -364,11 +368,11 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
             ((Panel) result).setCaption("Panel_" + caption);
             break;
         case 4:
-            TabSheet ts = new TabSheet();
+            final TabSheet ts = new TabSheet();
             ts.setCaption("TabSheet_" + caption);
             // randomly select one of the tabs
-            int selectedTab = rand.nextInt(3);
-            ArrayList tabs = new ArrayList();
+            final int selectedTab = rand.nextInt(3);
+            final ArrayList tabs = new ArrayList();
             for (int i = 0; i < 3; i++) {
                 String tabCaption = "tab" + i;
                 if (selectedTab == i) {
@@ -394,7 +398,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
      */
     private AbstractComponent getRandomComponent(String caption) {
         AbstractComponent result = null;
-        int randint = rand.nextInt(7); // calendar disabled
+        final int randint = rand.nextInt(7); // calendar disabled
         switch (randint) {
         case 0:
             // Label
@@ -446,8 +450,8 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
     }
 
     private AbstractComponent getExamplePicture(String caption) {
-        ClassResource cr = new ClassResource("icon_demo.png", this);
-        Embedded em = new Embedded("Embedded " + caption, cr);
+        final ClassResource cr = new ClassResource("icon_demo.png", this);
+        final Embedded em = new Embedded("Embedded " + caption, cr);
         return em;
     }
 
@@ -466,7 +470,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
      */
     public void terminalError(
             com.itmill.toolkit.terminal.Terminal.ErrorEvent event) {
-        Throwable e = event.getThrowable();
+        final Throwable e = event.getThrowable();
         System.err.println(getUser().toString() + " terminalError: "
                 + e.toString());
         e.printStackTrace();
diff --git a/src/com/itmill/toolkit/tests/PerformanceTestSubTreeCaching.java b/src/com/itmill/toolkit/tests/PerformanceTestSubTreeCaching.java
index c866243c28..5fecaece1b 100644
--- a/src/com/itmill/toolkit/tests/PerformanceTestSubTreeCaching.java
+++ b/src/com/itmill/toolkit/tests/PerformanceTestSubTreeCaching.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.tests;
 
 import java.util.Date;
@@ -10,13 +14,13 @@ import com.itmill.toolkit.ui.Table;
 
 public class PerformanceTestSubTreeCaching extends CustomComponent {
 
-    private OrderedLayout main;
+    private final OrderedLayout main;
 
-    private OrderedLayout testContainer;
+    private final OrderedLayout testContainer;
 
     private Date startTime;
 
-    private Label result;
+    private final Label result;
 
     private static final String DESCRIPTION = "Hyphothesis: Toolkit 4 has major architechtural problem when adding "
             + "small incrementall updates to a container which has either a lot or "
@@ -55,8 +59,8 @@ public class PerformanceTestSubTreeCaching extends CustomComponent {
     }
 
     public void endTest() {
-        long millis = (new Date()).getTime() - startTime.getTime();
-        Float f = new Float(millis / 1000.0);
+        final long millis = (new Date()).getTime() - startTime.getTime();
+        final Float f = new Float(millis / 1000.0);
         result.setValue("Test completed in " + f + " seconds");
     }
 
@@ -68,7 +72,7 @@ public class PerformanceTestSubTreeCaching extends CustomComponent {
     private void populateContainer(OrderedLayout container, int n) {
         for (int i = 0; i < n; i++) {
             // array_type array_element = [i];
-            Table t = TestForTablesInitialColumnWidthLogicRendering
+            final Table t = TestForTablesInitialColumnWidthLogicRendering
                     .getTestTable(5, 100);
             container.addComponent(t);
         }
diff --git a/src/com/itmill/toolkit/tests/RandomLayoutStress.java b/src/com/itmill/toolkit/tests/RandomLayoutStress.java
index 5267f658e6..02a04f9860 100644
--- a/src/com/itmill/toolkit/tests/RandomLayoutStress.java
+++ b/src/com/itmill/toolkit/tests/RandomLayoutStress.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.tests;
 
 import java.util.Random;
@@ -27,7 +31,7 @@ import com.itmill.toolkit.ui.Window;
  */
 public class RandomLayoutStress extends com.itmill.toolkit.Application {
 
-    private Random seededRandom = new Random(1);
+    private final Random seededRandom = new Random(1);
 
     // FIXME increasing these settings brings out interesting client-side issues
     // (DOM errors)
@@ -42,11 +46,12 @@ public class RandomLayoutStress extends com.itmill.toolkit.Application {
      * Initialize Application. Demo components are added to main window.
      */
     public void init() {
-        Window mainWindow = new Window("Layout demo");
+        final Window mainWindow = new Window("Layout demo");
         setMainWindow(mainWindow);
 
         // Create horizontal ordered layout
-        Panel panelA = new Panel("Panel containing horizontal ordered layout");
+        final Panel panelA = new Panel(
+                "Panel containing horizontal ordered layout");
         OrderedLayout layoutA = new OrderedLayout(
                 OrderedLayout.ORIENTATION_HORIZONTAL);
         // Add 4 random components
@@ -55,7 +60,8 @@ public class RandomLayoutStress extends com.itmill.toolkit.Application {
         panelA.addComponent(layoutA);
 
         // Create vertical ordered layout
-        Panel panelB = new Panel("Panel containing vertical ordered layout");
+        final Panel panelB = new Panel(
+                "Panel containing vertical ordered layout");
         OrderedLayout layoutB = new OrderedLayout(
                 OrderedLayout.ORIENTATION_VERTICAL);
         // Add 4 random components
@@ -64,9 +70,9 @@ public class RandomLayoutStress extends com.itmill.toolkit.Application {
         panelB.addComponent(layoutB);
 
         // Create grid layout
-        int gridSize = (int) java.lang.Math.sqrt(componentCountC);
-        Panel panelG = new Panel("Panel containing grid layout (" + gridSize
-                + " x " + gridSize + ")");
+        final int gridSize = (int) java.lang.Math.sqrt(componentCountC);
+        final Panel panelG = new Panel("Panel containing grid layout ("
+                + gridSize + " x " + gridSize + ")");
         GridLayout layoutG = new GridLayout(gridSize, gridSize);
         // Add 12 random components
         fillLayout(layoutG, componentCountC);
@@ -74,7 +80,7 @@ public class RandomLayoutStress extends com.itmill.toolkit.Application {
         panelG.addComponent(layoutG);
 
         // Create TabSheet
-        TabSheet tabsheet = new TabSheet();
+        final TabSheet tabsheet = new TabSheet();
         tabsheet
                 .setCaption("Tabsheet, above layouts are added to this component");
         layoutA = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
@@ -91,8 +97,8 @@ public class RandomLayoutStress extends com.itmill.toolkit.Application {
         tabsheet.addTab(layoutG, "Grid layout (4 x 2)", null);
 
         // Create custom layout
-        Panel panelC = new Panel("Custom layout with style exampleStyle");
-        CustomLayout layoutC = new CustomLayout("exampleStyle");
+        final Panel panelC = new Panel("Custom layout with style exampleStyle");
+        final CustomLayout layoutC = new CustomLayout("exampleStyle");
         // Add 4 random components
         fillLayout(layoutC, componentCountD);
         // Add layout to panel
@@ -108,7 +114,7 @@ public class RandomLayoutStress extends com.itmill.toolkit.Application {
 
     private AbstractComponent getRandomComponent(int caption) {
         AbstractComponent result = null;
-        int randint = seededRandom.nextInt(7);
+        final int randint = seededRandom.nextInt(7);
         switch (randint) {
         case 0:
             // Label
diff --git a/src/com/itmill/toolkit/tests/TableSelectTest.java b/src/com/itmill/toolkit/tests/TableSelectTest.java
index eb53f5cbf1..4307eb6b7f 100644
--- a/src/com/itmill/toolkit/tests/TableSelectTest.java
+++ b/src/com/itmill/toolkit/tests/TableSelectTest.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.tests;
 
 import com.itmill.toolkit.data.Property.ValueChangeEvent;
@@ -10,7 +14,7 @@ public class TableSelectTest extends CustomComponent implements
         Table.ValueChangeListener {
 
     public TableSelectTest() {
-        OrderedLayout main = new OrderedLayout();
+        final OrderedLayout main = new OrderedLayout();
         setCompositionRoot(main);
         main.addComponent(new Label("Hello World!"));
 
@@ -68,7 +72,7 @@ public class TableSelectTest extends CustomComponent implements
         try {
             t.setMultiSelect(true);
             t.setCaption("multi(SHOLD FAIL BUT DID NOT) nullsel nullselid");
-        } catch (Exception e) {
+        } catch (final Exception e) {
             System.err.println("failed ok");
         }
         t.setNullSelectionAllowed(true);
@@ -81,7 +85,7 @@ public class TableSelectTest extends CustomComponent implements
         try {
             t.setMultiSelect(true);
             t.setCaption("multi(SHOLD FAIL BUT DID NOT) NO-nullsel nullselid");
-        } catch (Exception e) {
+        } catch (final Exception e) {
             System.err.println("failed ok");
         }
         t.setNullSelectionAllowed(false);
@@ -110,7 +114,7 @@ public class TableSelectTest extends CustomComponent implements
     }
 
     public void valueChange(ValueChangeEvent event) {
-        Object val = event.getProperty().getValue();
+        final Object val = event.getProperty().getValue();
 
         System.err.println("Value: " + val);
 
diff --git a/src/com/itmill/toolkit/tests/TestBench.java b/src/com/itmill/toolkit/tests/TestBench.java
index d94548becf..48787515dc 100644
--- a/src/com/itmill/toolkit/tests/TestBench.java
+++ b/src/com/itmill/toolkit/tests/TestBench.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.tests;
 
 import java.io.File;
@@ -59,9 +63,10 @@ public class TestBench extends com.itmill.toolkit.Application implements
         for (int p = 0; p < testablePackages.length; p++) {
             testables.addItem(testablePackages[p]);
             try {
-                List testableClasses = getTestableClassesForPackage(testablePackages[p]);
-                for (Iterator it = testableClasses.iterator(); it.hasNext();) {
-                    Class t = (Class) it.next();
+                final List testableClasses = getTestableClassesForPackage(testablePackages[p]);
+                for (final Iterator it = testableClasses.iterator(); it
+                        .hasNext();) {
+                    final Class t = (Class) it.next();
                     // ignore TestBench itself
                     if (t.equals(TestBench.class)) {
                         continue;
@@ -71,33 +76,33 @@ public class TestBench extends com.itmill.toolkit.Application implements
                         itemCaptions.put(t, t.getName());
                         testables.setParent(t, testablePackages[p]);
                         continue;
-                    } catch (Exception e) {
+                    } catch (final Exception e) {
                         try {
                             testables.addItem(t);
                             itemCaptions.put(t, t.getName());
                             testables.setParent(t, testablePackages[p]);
                             continue;
-                        } catch (Exception e1) {
+                        } catch (final Exception e1) {
                             e1.printStackTrace();
                         }
                     }
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 e.printStackTrace();
             }
         }
 
         menu = new Tree("Testables", testables);
 
-        for (Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
-            Class testable = (Class) i.next();
+        for (final Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
+            final Class testable = (Class) i.next();
             // simplify captions
-            String name = testable.getName().substring(
+            final String name = testable.getName().substring(
                     testable.getName().lastIndexOf('.') + 1);
             menu.setItemCaption(testable, name);
         }
         // expand all root items
-        for (Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
+        for (final Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
             menu.expandItemsRecursively(i.next());
         }
 
@@ -122,14 +127,14 @@ public class TestBench extends com.itmill.toolkit.Application implements
 
     private Component createTestable(Class c) {
         try {
-            Application app = (Application) c.newInstance();
+            final Application app = (Application) c.newInstance();
             app.init();
             return app.getMainWindow().getLayout();
-        } catch (Exception e) {
+        } catch (final Exception e) {
             try {
-                CustomComponent cc = (CustomComponent) c.newInstance();
+                final CustomComponent cc = (CustomComponent) c.newInstance();
                 return cc;
-            } catch (Exception e1) {
+            } catch (final Exception e1) {
                 e1.printStackTrace();
                 return new Label(
                         "Cannot create application / custom component: "
@@ -143,10 +148,10 @@ public class TestBench extends com.itmill.toolkit.Application implements
         bodyLayout.removeAllComponents();
         bodyLayout.setCaption(null);
 
-        Object o = menu.getValue();
+        final Object o = menu.getValue();
         if (o != null && o instanceof Class) {
-            Class c = (Class) o;
-            String title = c.getName();
+            final Class c = (Class) o;
+            final String title = c.getName();
             bodyLayout.setCaption(title);
             bodyLayout.addComponent(createTestable(c));
         } else {
@@ -164,38 +169,39 @@ public class TestBench extends com.itmill.toolkit.Application implements
      */
     public static List getTestableClassesForPackage(String packageName)
             throws Exception {
-        ArrayList directories = new ArrayList();
+        final ArrayList directories = new ArrayList();
         try {
-            ClassLoader cld = Thread.currentThread().getContextClassLoader();
+            final ClassLoader cld = Thread.currentThread()
+                    .getContextClassLoader();
             if (cld == null) {
                 throw new ClassNotFoundException("Can't get class loader.");
             }
-            String path = packageName.replace('.', '/');
+            final String path = packageName.replace('.', '/');
             // Ask for all resources for the path
-            Enumeration resources = cld.getResources(path);
+            final Enumeration resources = cld.getResources(path);
             while (resources.hasMoreElements()) {
-                URL url = (URL) resources.nextElement();
+                final URL url = (URL) resources.nextElement();
                 directories.add(new File(url.getFile()));
             }
-        } catch (Exception x) {
+        } catch (final Exception x) {
             throw new Exception(packageName
                     + " does not appear to be a valid package.");
         }
 
-        ArrayList classes = new ArrayList();
+        final ArrayList classes = new ArrayList();
         // For every directory identified capture all the .class files
-        for (Iterator it = directories.iterator(); it.hasNext();) {
-            File directory = (File) it.next();
+        for (final Iterator it = directories.iterator(); it.hasNext();) {
+            final File directory = (File) it.next();
             if (directory.exists()) {
                 // Get the list of the files contained in the package
-                String[] files = directory.list();
+                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 = packageName + '.'
+                        final String p = packageName + '.'
                                 + files[j].substring(0, files[j].length() - 6);
-                        Class c = Class.forName(p);
+                        final Class c = Class.forName(p);
                         if (c.getSuperclass() != null) {
                             if ((c.getSuperclass()
                                     .equals(com.itmill.toolkit.Application.class))) {
diff --git a/src/com/itmill/toolkit/tests/TestCaptionWrapper.java b/src/com/itmill/toolkit/tests/TestCaptionWrapper.java
index 567d9eb877..ae8c886c59 100644
--- a/src/com/itmill/toolkit/tests/TestCaptionWrapper.java
+++ b/src/com/itmill/toolkit/tests/TestCaptionWrapper.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.tests;
 
 import com.itmill.toolkit.terminal.ClassResource;
@@ -65,15 +69,15 @@ public class TestCaptionWrapper extends CustomComponent implements Listener {
         test(main);
         populateLayout(main);
 
-        Panel panel = new Panel("Panel");
+        final Panel panel = new Panel("Panel");
         test(panel);
         populateLayout(panel.getLayout());
 
-        TabSheet tabsheet = new TabSheet();
+        final TabSheet tabsheet = new TabSheet();
         test(tabsheet);
-        OrderedLayout tab1 = new OrderedLayout();
+        final OrderedLayout tab1 = new OrderedLayout();
         tab1.addComponent(new Label("try tab2"));
-        OrderedLayout tab2 = new OrderedLayout();
+        final OrderedLayout tab2 = new OrderedLayout();
         test(tab2);
         populateLayout(tab2);
         tabsheet.addTab(tab1, "TabSheet tab1", new ClassResource("m.gif",
@@ -81,15 +85,15 @@ public class TestCaptionWrapper extends CustomComponent implements Listener {
         tabsheet.addTab(tab2, "TabSheet tab2", new ClassResource("m.gif",
                 getApplication()));
 
-        ExpandLayout expandLayout = new ExpandLayout();
+        final ExpandLayout expandLayout = new ExpandLayout();
         test(expandLayout);
         populateLayout(expandLayout);
 
-        GridLayout gridLayout = new GridLayout();
+        final GridLayout gridLayout = new GridLayout();
         test(gridLayout);
         populateLayout(gridLayout);
 
-        Window window = new Window("TEST: Window");
+        final Window window = new Window("TEST: Window");
         test(window);
         populateLayout(window.getLayout());
 
@@ -97,67 +101,69 @@ public class TestCaptionWrapper extends CustomComponent implements Listener {
 
     void populateLayout(Layout layout) {
 
-        Button button = new Button("Button " + count++);
+        final Button button = new Button("Button " + count++);
         test(layout, button);
         button.addListener(this);
 
-        DateField df = new DateField("DateField " + count++);
+        final DateField df = new DateField("DateField " + count++);
         test(layout, df);
 
-        CheckBox cb = new CheckBox("Checkbox " + count++);
+        final CheckBox cb = new CheckBox("Checkbox " + count++);
         test(layout, cb);
 
-        Embedded emb = new Embedded("Embedded " + count++);
+        final Embedded emb = new Embedded("Embedded " + count++);
         test(layout, emb);
 
-        Panel panel = new Panel("Panel " + count++);
+        final Panel panel = new Panel("Panel " + count++);
         test(layout, panel);
 
-        Label label = new Label("Label " + count++);
+        final Label label = new Label("Label " + count++);
         test(layout, label);
 
-        Link link = new Link("Link " + count++, new ExternalResource(
+        final Link link = new Link("Link " + count++, new ExternalResource(
                 "www.itmill.com"));
         test(layout, link);
 
-        NativeSelect nativeSelect = new NativeSelect("NativeSelect " + count++);
+        final NativeSelect nativeSelect = new NativeSelect("NativeSelect "
+                + count++);
         test(layout, nativeSelect);
 
-        OptionGroup optionGroup = new OptionGroup("OptionGroup " + count++);
+        final OptionGroup optionGroup = new OptionGroup("OptionGroup "
+                + count++);
         test(layout, optionGroup);
 
-        ProgressIndicator pi = new ProgressIndicator();
+        final ProgressIndicator pi = new ProgressIndicator();
         test(layout, pi);
 
-        RichTextArea rta = new RichTextArea();
+        final RichTextArea rta = new RichTextArea();
         test(layout, rta);
 
-        Select select = new Select("Select " + count++);
+        final Select select = new Select("Select " + count++);
         test(layout, select);
 
-        Slider slider = new Slider("Slider " + count++);
+        final Slider slider = new Slider("Slider " + count++);
         test(layout, slider);
 
-        Table table = new Table("Table " + count++);
+        final Table table = new Table("Table " + count++);
         test(layout, table);
 
-        TextField tf = new TextField("Textfield " + count++);
+        final TextField tf = new TextField("Textfield " + count++);
         test(layout, tf);
 
-        Tree tree = new Tree("Tree " + count++);
+        final Tree tree = new Tree("Tree " + count++);
         test(layout, tree);
 
-        TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect "
+        final TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect "
                 + count++);
         test(layout, twinColSelect);
 
-        Upload upload = new Upload("Upload (non-functional)", null);
+        final Upload upload = new Upload("Upload (non-functional)", null);
         test(layout, upload);
 
         // Custom components
         layout.addComponent(new Label("Below are few custom components",
                 Label.CONTENT_XHTML));
-        TestForUpload tfu = new TestForUpload();
+        final TestForUpload tfu = new TestForUpload();
         layout.addComponent(tfu);
 
     }
@@ -168,8 +174,8 @@ public class TestCaptionWrapper extends CustomComponent implements Listener {
      * @param c
      */
     void test(AbstractComponent c) {
-        ClassResource res = new ClassResource("m.gif", getApplication());
-        ErrorMessage errorMsg = new UserError("User error " + c);
+        final ClassResource res = new ClassResource("m.gif", getApplication());
+        final ErrorMessage errorMsg = new UserError("User error " + c);
 
         if ((c.getCaption() == null) || (c.getCaption().length() <= 0)) {
             c.setCaption("Caption " + c);
@@ -190,8 +196,8 @@ public class TestCaptionWrapper extends CustomComponent implements Listener {
     }
 
     public void componentEvent(Event event) {
-        String feedback = eventListenerString + " source=" + event.getSource()
-                + ", toString()=" + event.toString();
+        final String feedback = eventListenerString + " source="
+                + event.getSource() + ", toString()=" + event.toString();
         System.out.println("eventListenerFeedback: " + feedback);
         eventListenerFeedback.setValue(feedback);
     }
diff --git a/src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java b/src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java
index f0509be390..8183216757 100644
--- a/src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java
+++ b/src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java
@@ -1,3 +1,7 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
 package com.itmill.toolkit.tests;
 
 import java.io.File;
@@ -78,7 +82,7 @@ public class TestComponentsAndLayouts extends Application implements Listener,
     }
 
     public void createNewView() {
-        Window main = new Window("Main window");
+        final Window main = new Window("Main window");
         setMainWindow(main);
 
         // By default push all containers inside main window
@@ -112,7 +116,7 @@ public class TestComponentsAndLayouts extends Application implements Listener,
                     .addComponent(new Label(
                             "

Components inside horizontal OrderedLayout

", Label.CONTENT_XHTML)); - OrderedLayout ol = new OrderedLayout( + final OrderedLayout ol = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); populateLayout(ol); target.addComponent(ol); @@ -124,7 +128,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, .addComponent(new Label( "



Components inside vertical OrderedLayout

", Label.CONTENT_XHTML)); - OrderedLayout ol2 = new OrderedLayout( + final OrderedLayout ol2 = new OrderedLayout( OrderedLayout.ORIENTATION_VERTICAL); populateLayout(ol2); target.addComponent(ol2); @@ -136,7 +140,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, .addComponent(new Label( "

Components inside ExpandLayout (height 250px)

", Label.CONTENT_XHTML)); - ExpandLayout el = new ExpandLayout(); + final ExpandLayout el = new ExpandLayout(); el.setHeight(250); el.setHeightUnits(Sizeable.UNITS_PIXELS); populateLayout(el); @@ -148,7 +152,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, target.addComponent(new Label( "

Components inside Panel

", Label.CONTENT_XHTML)); - Panel panel = new Panel("Panel"); + final Panel panel = new Panel("Panel"); populateLayout(panel.getLayout()); target.addComponent(panel); } @@ -159,13 +163,14 @@ public class TestComponentsAndLayouts extends Application implements Listener, .addComponent(new Label( "

Components inside vertical SplitPanel (splitpanel is under 250height ExpandLayout)

", Label.CONTENT_XHTML)); - ExpandLayout sp1l = new ExpandLayout(); + final ExpandLayout sp1l = new ExpandLayout(); sp1l.setHeight(250); sp1l.setHeightUnits(Sizeable.UNITS_PIXELS); - SplitPanel sp1 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); + final SplitPanel sp1 = new SplitPanel( + SplitPanel.ORIENTATION_VERTICAL); sp1l.addComponent(sp1); - OrderedLayout sp1first = new OrderedLayout(); - OrderedLayout sp1second = new OrderedLayout(); + final OrderedLayout sp1first = new OrderedLayout(); + final OrderedLayout sp1second = new OrderedLayout(); sp1.setFirstComponent(sp1first); populateLayout(sp1first); populateLayout(sp1second); @@ -179,13 +184,14 @@ public class TestComponentsAndLayouts extends Application implements Listener, .addComponent(new Label( "

Components inside horizontal SplitPanel (splitpanel is under 250px height ExpandLayout)

", Label.CONTENT_XHTML)); - ExpandLayout sp2l = new ExpandLayout(); + final ExpandLayout sp2l = new ExpandLayout(); sp2l.setHeight(250); sp2l.setHeightUnits(Sizeable.UNITS_PIXELS); - SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); + final SplitPanel sp2 = new SplitPanel( + SplitPanel.ORIENTATION_HORIZONTAL); sp2l.addComponent(sp2); - OrderedLayout sp2first = new OrderedLayout(); - OrderedLayout sp2second = new OrderedLayout(); + final OrderedLayout sp2first = new OrderedLayout(); + final OrderedLayout sp2second = new OrderedLayout(); sp2.setFirstComponent(sp2first); populateLayout(sp2first); populateLayout(sp2second); @@ -198,10 +204,10 @@ public class TestComponentsAndLayouts extends Application implements Listener, target.addComponent(new Label( "

Components inside TabSheet

", Label.CONTENT_XHTML)); - TabSheet tabsheet = new TabSheet(); - OrderedLayout tab1 = new OrderedLayout(); + final TabSheet tabsheet = new TabSheet(); + final OrderedLayout tab1 = new OrderedLayout(); tab1.addComponent(new Label("try tab2")); - OrderedLayout tab2 = new OrderedLayout(); + final OrderedLayout tab2 = new OrderedLayout(); populateLayout(tab2); tabsheet.addTab(tab1, "TabSheet tab1", new ClassResource("m.gif", this)); @@ -219,7 +225,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, target.addComponent(new Label( "

Components inside GridLayout

", Label.CONTENT_XHTML)); - GridLayout gridLayout = new GridLayout(4, 100); + final GridLayout gridLayout = new GridLayout(4, 100); populateLayout(gridLayout); target.addComponent(gridLayout); // test(gridLayout); @@ -228,58 +234,61 @@ public class TestComponentsAndLayouts extends Application implements Listener, } void populateLayout(Layout layout) { - Button button = new Button("Button " + count++); + final Button button = new Button("Button " + count++); test(layout, button); - DateField df = new DateField("DateField " + count++); + final DateField df = new DateField("DateField " + count++); test(layout, df); - CheckBox cb = new CheckBox("Checkbox " + count++); + final CheckBox cb = new CheckBox("Checkbox " + count++); test(layout, cb); - ClassResource flashResource = new ClassResource("itmill_spin.swf", this); - Embedded emb = new Embedded("Embedded " + count++, flashResource); + final ClassResource flashResource = new ClassResource( + "itmill_spin.swf", this); + final Embedded emb = new Embedded("Embedded " + count++, flashResource); emb.setType(Embedded.TYPE_OBJECT); emb.setMimeType("application/x-shockwave-flash"); emb.setWidth(250); emb.setHeight(100); test(layout, emb); - Panel panel = new Panel("Panel " + count++); + final Panel panel = new Panel("Panel " + count++); test(layout, panel); - Label label = new Label("Label " + count++); + final Label label = new Label("Label " + count++); test(layout, label); - Link link = new Link("Link " + count++, new ExternalResource( + final Link link = new Link("Link " + count++, new ExternalResource( "www.itmill.com")); test(layout, link); - NativeSelect nativeSelect = new NativeSelect("NativeSelect " + count++); + final NativeSelect nativeSelect = new NativeSelect("NativeSelect " + + count++); nativeSelect.setContainerDataSource(getContainer()); test(layout, nativeSelect); - OptionGroup optionGroup = new OptionGroup("OptionGroup " + count++); + final OptionGroup optionGroup = new OptionGroup("OptionGroup " + + count++); optionGroup.setContainerDataSource(getSmallContainer()); optionGroup.setItemCaptionPropertyId("UNIT"); test(layout, optionGroup); - ProgressIndicator pi = new ProgressIndicator(); + final ProgressIndicator pi = new ProgressIndicator(); pi.setCaption("ProgressIndicator"); test(layout, pi); - RichTextArea rta = new RichTextArea(); + final RichTextArea rta = new RichTextArea(); test(layout, rta); - Select select = new Select("Select " + count++); + final Select select = new Select("Select " + count++); select.setContainerDataSource(getSmallContainer()); select.setItemCaptionPropertyId("UNIT"); test(layout, select); - Slider slider = new Slider("Slider " + count++); + final Slider slider = new Slider("Slider " + count++); test(layout, slider); - Table table = new Table("Table " + count++); + final Table table = new Table("Table " + count++); table.setPageLength(10); table.setSelectable(true); table.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX); @@ -293,10 +302,10 @@ public class TestComponentsAndLayouts extends Application implements Listener, table.setItemCaptionPropertyId("ID"); test(layout, table); - TabSheet tabsheet = new TabSheet(); - OrderedLayout tab1 = new OrderedLayout(); + final TabSheet tabsheet = new TabSheet(); + final OrderedLayout tab1 = new OrderedLayout(); tab1.addComponent(new Label("tab1 " + count++)); - OrderedLayout tab2 = new OrderedLayout(); + final OrderedLayout tab2 = new OrderedLayout(); tab2.addComponent(new Label("tab2 " + count++)); tabsheet.addTab(tab1, "Default (not configured) TabSheet tab1", new ClassResource("m.gif", this)); @@ -304,31 +313,31 @@ public class TestComponentsAndLayouts extends Application implements Listener, "m.gif", this)); test(layout, tabsheet); - TextField tf = new TextField("Textfield " + count++); + final TextField tf = new TextField("Textfield " + count++); test(layout, tf); // do not configure tab1 // test(tab1); test(tab2); - Tree tree = new Tree("Tree " + count++); - File sampleDir = SampleDirectory.getDirectory(this); - FilesystemContainer fsc = new FilesystemContainer(sampleDir, true); + final Tree tree = new Tree("Tree " + count++); + final File sampleDir = SampleDirectory.getDirectory(this); + final FilesystemContainer fsc = new FilesystemContainer(sampleDir, true); tree.setContainerDataSource(fsc); test(layout, tree); - TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect " + final TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect " + count++); twinColSelect.setContainerDataSource(getSmallContainer()); twinColSelect.setItemCaptionPropertyId("UNIT"); test(layout, twinColSelect); - Upload upload = new Upload("Upload (non-functional)", null); + final Upload upload = new Upload("Upload (non-functional)", null); test(layout, upload); // Custom components layout.addComponent(new Label("Below are few custom components", Label.CONTENT_XHTML)); - TestForUpload tfu = new TestForUpload(); + final TestForUpload tfu = new TestForUpload(); layout.addComponent(tfu); layout.addComponent(new Label("
----------

", Label.CONTENT_XHTML)); @@ -347,7 +356,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, try { return new QueryContainer("SELECT * FROM employee", sampleDatabase .getConnection()); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); } return null; @@ -359,7 +368,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, return new QueryContainer( "SELECT DISTINCT UNIT AS UNIT FROM employee", sampleDatabase.getConnection()); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); } return null; @@ -376,7 +385,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, // try to add listener try { c.addListener(this); - } catch (Exception e) { + } catch (final Exception e) { System.err.println("Could not add listener for component " + c + ", count was " + count); } @@ -392,8 +401,8 @@ public class TestComponentsAndLayouts extends Application implements Listener, setComponentProperties(c); // AbstractComponent specific configuration - ClassResource res = new ClassResource("m.gif", this); - ErrorMessage errorMsg = new UserError("User error " + c); + final ClassResource res = new ClassResource("m.gif", this); + final ErrorMessage errorMsg = new UserError("User error " + c); if ((c.getCaption() == null) || (c.getCaption().length() <= 0)) { c.setCaption("Caption " + c); } @@ -434,7 +443,7 @@ public class TestComponentsAndLayouts extends Application implements Listener, public void componentEvent(Event event) { eventCount++; - String feedback = "eventCount=" + eventCount + ", class=" + final String feedback = "eventCount=" + eventCount + ", class=" + event.getClass() + ", source=" + event.getSource() + ", toString()=" + event.toString(); System.out.println("eventListenerFeedback: " + feedback); diff --git a/src/com/itmill/toolkit/tests/TestDateField.java b/src/com/itmill/toolkit/tests/TestDateField.java index 44daf959fe..7ebe718923 100644 --- a/src/com/itmill/toolkit/tests/TestDateField.java +++ b/src/com/itmill/toolkit/tests/TestDateField.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.util.Locale; @@ -32,7 +36,7 @@ public class TestDateField extends CustomComponent { df = new DateField(); main.addComponent(df); - ErrorMessage errorMsg = new UserError("User error " + df); + final ErrorMessage errorMsg = new UserError("User error " + df); df.setCaption("DateField caption " + df); df.setDescription("DateField description " + df); df.setComponentError(errorMsg); @@ -42,21 +46,22 @@ public class TestDateField extends CustomComponent { df.addStyleName("thisShouldBeHarmless"); // Another test: locale - DateField df1 = new DateField(); + final DateField df1 = new DateField(); main.addComponent(df1); df1.setLocale(new Locale("en", "US")); - DateField df2 = new DateField(); + final DateField df2 = new DateField(); main.addComponent(df2); df2.setLocale(new Locale("de", "DE")); - DateField df3 = new DateField(); + final DateField df3 = new DateField(); main.addComponent(df3); df3.setLocale(new Locale("ru", "RU")); } public void attach() { - ClassResource res = new ClassResource("m.gif", super.getApplication()); + final ClassResource res = new ClassResource("m.gif", super + .getApplication()); df.setIcon(res); super.attach(); } diff --git a/src/com/itmill/toolkit/tests/TestForAlignments.java b/src/com/itmill/toolkit/tests/TestForAlignments.java index 5140478fc4..42cd5b874a 100644 --- a/src/com/itmill/toolkit/tests/TestForAlignments.java +++ b/src/com/itmill/toolkit/tests/TestForAlignments.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.ui.Button; @@ -10,18 +14,18 @@ public class TestForAlignments extends CustomComponent { public TestForAlignments() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); - Button b1 = new Button("Right"); - Button b2 = new Button("Left"); - Button b3 = new Button("Bottom"); - Button b4 = new Button("Top"); - TextField t1 = new TextField("Right aligned"); - TextField t2 = new TextField("Bottom aligned"); - DateField d1 = new DateField("Center aligned"); - DateField d2 = new DateField("Center aligned"); + final Button b1 = new Button("Right"); + final Button b2 = new Button("Left"); + final Button b3 = new Button("Bottom"); + final Button b4 = new Button("Top"); + final TextField t1 = new TextField("Right aligned"); + final TextField t2 = new TextField("Bottom aligned"); + final DateField d1 = new DateField("Center aligned"); + final DateField d2 = new DateField("Center aligned"); - OrderedLayout vert = new OrderedLayout(); + final OrderedLayout vert = new OrderedLayout(); vert.addComponent(b1); vert.addComponent(b2); vert.addComponent(t1); @@ -36,7 +40,7 @@ public class TestForAlignments extends CustomComponent { vert.setComponentAlignment(d1, OrderedLayout.ALIGNMENT_HORIZONTAL_CENTER, OrderedLayout.ALIGNMENT_TOP); - OrderedLayout hori = new OrderedLayout( + final OrderedLayout hori = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); hori.addComponent(b3); hori.addComponent(b4); diff --git a/src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java b/src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java index f41230f463..74a1e0e9ee 100644 --- a/src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java +++ b/src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.Application; @@ -27,15 +31,15 @@ public class TestForApplicationLayoutThatUsesWholeBrosersSpace extends firstLevelSplit = new SplitPanel(); - SplitPanel secondSplitPanel = new SplitPanel( + final SplitPanel secondSplitPanel = new SplitPanel( SplitPanel.ORIENTATION_HORIZONTAL); secondSplitPanel.setFirstComponent(new Label("left")); - ExpandLayout topRight = new ExpandLayout(); + final ExpandLayout topRight = new ExpandLayout(); topRight.addComponent(new Label("topright header")); - Table t = TestForTablesInitialColumnWidthLogicRendering.getTestTable(4, - 100); + final Table t = TestForTablesInitialColumnWidthLogicRendering + .getTestTable(4, 100); t.setWidth(100); t.setWidthUnits(Sizeable.UNITS_PERCENTAGE); t.setHeight(100); @@ -47,7 +51,7 @@ public class TestForApplicationLayoutThatUsesWholeBrosersSpace extends secondSplitPanel.setSecondComponent(topRight); - ExpandLayout el = new ExpandLayout(); + final ExpandLayout el = new ExpandLayout(); el.addComponent(new Label("B��")); firstLevelSplit.setFirstComponent(secondSplitPanel); diff --git a/src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java b/src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java index c4c2bb76c0..8b0f6b5ca2 100644 --- a/src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java +++ b/src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.util.Locale; @@ -18,9 +22,9 @@ import com.itmill.toolkit.ui.Button.ClickListener; public class TestForBasicApplicationLayout extends CustomComponent { - private Button click; - private Button click2; - private TabSheet tab; + private final Button click; + private final Button click2; + private final TabSheet tab; public TestForBasicApplicationLayout() { @@ -41,26 +45,27 @@ public class TestForBasicApplicationLayout extends CustomComponent { }); - SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); + final SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); sp.setSplitPosition(290, Sizeable.UNITS_PIXELS); - SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); + final SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS); - Panel p = new Panel("Accordion Panel"); + final Panel p = new Panel("Accordion Panel"); p.setSizeFull(); tab = new TabSheet(); tab.setSizeFull(); - Panel report = new Panel("Monthly Program Runs", new ExpandLayout()); - OrderedLayout controls = new OrderedLayout(); + final Panel report = new Panel("Monthly Program Runs", + new ExpandLayout()); + final OrderedLayout controls = new OrderedLayout(); controls.setMargin(true); controls.addComponent(new Label("Report tab")); controls.addComponent(click); controls.addComponent(click2); report.addComponent(controls); - DateField cal = new DateField(); + final DateField cal = new DateField(); cal.setResolution(DateField.RESOLUTION_DAY); cal.setLocale(new Locale("en", "US")); report.addComponent(cal); @@ -71,7 +76,7 @@ public class TestForBasicApplicationLayout extends CustomComponent { sp2.setFirstComponent(report); - Table table = TestForTablesInitialColumnWidthLogicRendering + final Table table = TestForTablesInitialColumnWidthLogicRendering .getTestTable(5, 200); table.setPageLength(15); table.setSelectable(true); diff --git a/src/com/itmill/toolkit/tests/TestForChildComponentRendering.java b/src/com/itmill/toolkit/tests/TestForChildComponentRendering.java index d5021a835f..15782ca12c 100644 --- a/src/com/itmill/toolkit/tests/TestForChildComponentRendering.java +++ b/src/com/itmill/toolkit/tests/TestForChildComponentRendering.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.util.ArrayList; @@ -21,7 +25,7 @@ import com.itmill.toolkit.ui.Select; */ public class TestForChildComponentRendering extends CustomComponent { - private OrderedLayout main; + private final OrderedLayout main; public TestForChildComponentRendering() { @@ -34,7 +38,7 @@ public class TestForChildComponentRendering extends CustomComponent { main.removeAllComponents(); main.addComponent(new Label("SDFGFHFHGJGFDSDSSSGFDD")); - Link l = new Link(); + final Link l = new Link(); l.setCaption("Siirry ITMILLIIN"); l.setResource(new ExternalResource("http://www.itmill.com/")); l.setTargetHeight(200); @@ -42,7 +46,7 @@ public class TestForChildComponentRendering extends CustomComponent { l.setTargetBorder(Link.TARGET_BORDER_MINIMAL); main.addComponent(l); - Select se = new Select(); + final Select se = new Select(); se.setCaption("VALITSET TÄSTÄ"); se.addItem("valinta1"); se.addItem("Valinta 2"); @@ -60,30 +64,30 @@ public class TestForChildComponentRendering extends CustomComponent { } public void randomReorder() { - Iterator it = main.getComponentIterator(); - ArrayList components = new ArrayList(); + final Iterator it = main.getComponentIterator(); + final ArrayList components = new ArrayList(); while (it.hasNext()) { components.add(it.next()); } - OrderedLayout v = main; + final OrderedLayout v = main; v.removeAllComponents(); for (int i = components.size(); i > 0; i--) { - int index = (int) (Math.random() * i); + final int index = (int) (Math.random() * i); v.addComponent((Component) components.get(index)); components.remove(index); } } public void removeRandomComponent() { - Iterator it = main.getComponentIterator(); - ArrayList components = new ArrayList(); + final Iterator it = main.getComponentIterator(); + final ArrayList components = new ArrayList(); while (it.hasNext()) { components.add(it.next()); } - int size = components.size(); - int index = (int) (Math.random() * size); + final int size = components.size(); + final int index = (int) (Math.random() * size); main.removeComponent((Component) components.get(index)); } diff --git a/src/com/itmill/toolkit/tests/TestForContainerFilterable.java b/src/com/itmill/toolkit/tests/TestForContainerFilterable.java index e567f4f34d..165abe503b 100644 --- a/src/com/itmill/toolkit/tests/TestForContainerFilterable.java +++ b/src/com/itmill/toolkit/tests/TestForContainerFilterable.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.data.util.IndexedContainer; @@ -30,13 +34,13 @@ public class TestForContainerFilterable extends CustomComponent { ic.addContainerProperty("foo", String.class, ""); ic.addContainerProperty("bar", String.class, ""); for (int i = 0; i < 1000; i++) { - Object id = ic.addItem(); + final Object id = ic.addItem(); ic.getContainerProperty(id, "foo").setValue(randomWord()); ic.getContainerProperty(id, "bar").setValue(randomWord()); } // Init filtering view - Panel filterPanel = new Panel("Filter", new OrderedLayout( + final Panel filterPanel = new Panel("Filter", new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL)); filterPanel.setWidth(100); filterPanel.setWidthUnits(Sizeable.UNITS_PERCENTAGE); @@ -84,7 +88,7 @@ public class TestForContainerFilterable extends CustomComponent { private String randomWord() { int len = (int) (Math.random() * 4); - StringBuffer buf = new StringBuffer(); + final StringBuffer buf = new StringBuffer(); while (len-- >= 0) { buf.append(parts[(int) (Math.random() * parts.length)]); } diff --git a/src/com/itmill/toolkit/tests/TestForExpandLayout.java b/src/com/itmill/toolkit/tests/TestForExpandLayout.java index 38f2445581..7ce61ed535 100644 --- a/src/com/itmill/toolkit/tests/TestForExpandLayout.java +++ b/src/com/itmill/toolkit/tests/TestForExpandLayout.java @@ -1,9 +1,15 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; +import com.itmill.toolkit.terminal.Sizeable; import com.itmill.toolkit.ui.CustomComponent; import com.itmill.toolkit.ui.DateField; import com.itmill.toolkit.ui.ExpandLayout; import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; /** * @@ -23,15 +29,15 @@ public class TestForExpandLayout extends CustomComponent { public void createNewView() { main.removeAllComponents(); for (int i = 0; i < 10; i++) { - ExpandLayout el = new ExpandLayout( - ExpandLayout.ORIENTATION_HORIZONTAL); + final ExpandLayout el = new ExpandLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); for (int j = 0; j < 10; j++) { - Label l = new Label("label" + i + ":" + j); + final Label l = new Label("label" + i + ":" + j); el.addComponent(l); } if (i > 0) { el.setHeight(1); - el.setHeightUnits(ExpandLayout.UNITS_EM); + el.setHeightUnits(Sizeable.UNITS_EM); } main.addComponent(el); } diff --git a/src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java b/src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java index 2f0c70889c..06889476f5 100644 --- a/src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java +++ b/src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.util.ArrayList; @@ -21,7 +25,7 @@ import com.itmill.toolkit.ui.Select; */ public class TestForGridLayoutChildComponentRendering extends CustomComponent { - private GridLayout main = new GridLayout(2, 3); + private final GridLayout main = new GridLayout(2, 3); public TestForGridLayoutChildComponentRendering() { @@ -33,7 +37,7 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent { main.removeAllComponents(); main.addComponent(new Label("SDFGFHFHGJGFDSDSSSGFDD")); - Link l = new Link(); + final Link l = new Link(); l.setCaption("Siirry ITMILLIIN"); l.setResource(new ExternalResource("http://www.itmill.com/")); l.setTargetHeight(200); @@ -41,7 +45,7 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent { l.setTargetBorder(Link.TARGET_BORDER_MINIMAL); main.addComponent(l); - Select se = new Select("Tästä valitaan"); + final Select se = new Select("Tästä valitaan"); se.setCaption("Whattaa select"); se.addItem("valinta1"); se.addItem("Valinta 2"); @@ -61,19 +65,19 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent { } public void randomReorder() { - Iterator it = main.getComponentIterator(); - ArrayList components = new ArrayList(); + final Iterator it = main.getComponentIterator(); + final ArrayList components = new ArrayList(); while (it.hasNext()) { components.add(it.next()); } main.removeAllComponents(); - int size = components.size(); - int colspanIndex = ((int) (Math.random() * size) / 2) * 2 + 2; + final int size = components.size(); + final int colspanIndex = ((int) (Math.random() * size) / 2) * 2 + 2; for (int i = components.size(); i > 0; i--) { - int index = (int) (Math.random() * i); + final int index = (int) (Math.random() * i); if (i == colspanIndex) { main.addComponent((Component) components.get(index), 0, (size - i) / 2, 1, (size - i) / 2); @@ -85,13 +89,13 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent { } public void removeRandomComponent() { - Iterator it = main.getComponentIterator(); - ArrayList components = new ArrayList(); + final Iterator it = main.getComponentIterator(); + final ArrayList components = new ArrayList(); while (it.hasNext()) { components.add(it.next()); } - int size = components.size(); - int index = (int) (Math.random() * size); + final int size = components.size(); + final int index = (int) (Math.random() * size); main.removeComponent((Component) components.get(index)); } diff --git a/src/com/itmill/toolkit/tests/TestForMultipleStyleNames.java b/src/com/itmill/toolkit/tests/TestForMultipleStyleNames.java index 232cefc381..5400ca828c 100644 --- a/src/com/itmill/toolkit/tests/TestForMultipleStyleNames.java +++ b/src/com/itmill/toolkit/tests/TestForMultipleStyleNames.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.util.ArrayList; @@ -63,19 +67,19 @@ public class TestForMultipleStyleNames extends CustomComponent implements public void valueChange(ValueChangeEvent event) { - String currentStyle = l.getStyle(); - String[] tmp = currentStyle.split(" "); - ArrayList curStyles = new ArrayList(); + final String currentStyle = l.getStyle(); + final String[] tmp = currentStyle.split(" "); + final ArrayList curStyles = new ArrayList(); for (int i = 0; i < tmp.length; i++) { if (tmp[i] != "") { curStyles.add(tmp[i]); } } - Collection styles = (Collection) s.getValue(); + final Collection styles = (Collection) s.getValue(); - for (Iterator iterator = styles.iterator(); iterator.hasNext();) { - String styleName = (String) iterator.next(); + for (final Iterator iterator = styles.iterator(); iterator.hasNext();) { + final String styleName = (String) iterator.next(); if (curStyles.contains(styleName)) { // already added curStyles.remove(styleName); @@ -83,8 +87,9 @@ public class TestForMultipleStyleNames extends CustomComponent implements l.addStyleName(styleName); } } - for (Iterator iterator2 = curStyles.iterator(); iterator2.hasNext();) { - String object = (String) iterator2.next(); + for (final Iterator iterator2 = curStyles.iterator(); iterator2 + .hasNext();) { + final String object = (String) iterator2.next(); l.removeStyleName(object); } } diff --git a/src/com/itmill/toolkit/tests/TestForNativeWindowing.java b/src/com/itmill/toolkit/tests/TestForNativeWindowing.java index 7fa373d8d2..5e7216101b 100644 --- a/src/com/itmill/toolkit/tests/TestForNativeWindowing.java +++ b/src/com/itmill/toolkit/tests/TestForNativeWindowing.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.net.MalformedURLException; @@ -31,7 +35,7 @@ public class TestForNativeWindowing extends Application { w.setWidth(100); w.setHeight(400); - Button closebutton = new Button("Close " + final Button closebutton = new Button("Close " + w.getCaption(), new Button.ClickListener() { public void buttonClick(ClickEvent event) { main.removeWindow(w); @@ -83,7 +87,7 @@ public class TestForNativeWindowing extends Application { .currentTimeMillis() + "/")), null); - } catch (MalformedURLException e) { + } catch (final MalformedURLException e) { } } })); @@ -94,13 +98,13 @@ public class TestForNativeWindowing extends Application { public Window getWindow(String name) { - Window w = super.getWindow(name); + final Window w = super.getWindow(name); if (w != null) { return w; } if (name != null && name.startsWith("mainwin-")) { - String postfix = name.substring("mainwin-".length()); + final String postfix = name.substring("mainwin-".length()); final Window ww = new Window("Window: " + postfix); ww.setName(name); ww.addComponent(new Label( diff --git a/src/com/itmill/toolkit/tests/TestForPreconfiguredComponents.java b/src/com/itmill/toolkit/tests/TestForPreconfiguredComponents.java index 27809adff1..47c435ad82 100644 --- a/src/com/itmill/toolkit/tests/TestForPreconfiguredComponents.java +++ b/src/com/itmill/toolkit/tests/TestForPreconfiguredComponents.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.event.Action; @@ -87,14 +91,14 @@ public class TestForPreconfiguredComponents extends CustomComponent implements .setCaption("OptionGroup + multiselect manually (configured from select)"); main.addComponent(test); - Button b = new Button("refresh view", this, "createNewView"); + final Button b = new Button("refresh view", this, "createNewView"); main.addComponent(b); } public static void fillSelect(AbstractSelect s, int items) { for (int i = 0; i < items; i++) { - String name = firstnames[(int) (Math.random() * (firstnames.length - 1))] + final String name = firstnames[(int) (Math.random() * (firstnames.length - 1))] + " " + lastnames[(int) (Math.random() * (lastnames.length - 1))]; s.addItem(name); @@ -103,7 +107,7 @@ public class TestForPreconfiguredComponents extends CustomComponent implements public Tree createTestTree() { Tree t = new Tree("Tree"); - String[] names = new String[100]; + final String[] names = new String[100]; for (int i = 0; i < names.length; i++) { names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))] + " " @@ -114,7 +118,7 @@ public class TestForPreconfiguredComponents extends CustomComponent implements t = new Tree("Organization Structure"); for (int i = 0; i < 100; i++) { t.addItem(names[i]); - String parent = names[(int) (Math.random() * (names.length - 1))]; + final String parent = names[(int) (Math.random() * (names.length - 1))]; if (t.containsId(parent)) { t.setParent(names[i], parent); } @@ -130,7 +134,7 @@ public class TestForPreconfiguredComponents extends CustomComponent implements } public Panel createTestBench(Component t) { - Panel ol = new Panel(); + final Panel ol = new Panel(); ol.setLayout(new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL)); ol.addComponent(t); diff --git a/src/com/itmill/toolkit/tests/TestForRichTextEditor.java b/src/com/itmill/toolkit/tests/TestForRichTextEditor.java index 407dbd8194..9adc4b4838 100644 --- a/src/com/itmill/toolkit/tests/TestForRichTextEditor.java +++ b/src/com/itmill/toolkit/tests/TestForRichTextEditor.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -15,7 +19,7 @@ import com.itmill.toolkit.ui.RichTextArea; public class TestForRichTextEditor extends CustomComponent implements ValueChangeListener { - private OrderedLayout main = new OrderedLayout(); + private final OrderedLayout main = new OrderedLayout(); private Label l; diff --git a/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java b/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java index 3c1b298c66..1304ef9298 100644 --- a/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java +++ b/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.util.Vector; @@ -19,7 +23,7 @@ import com.itmill.toolkit.ui.Table; public class TestForTablesInitialColumnWidthLogicRendering extends CustomComponent { - private OrderedLayout main = new OrderedLayout(); + private final OrderedLayout main = new OrderedLayout(); public TestForTablesInitialColumnWidthLogicRendering() { @@ -79,19 +83,19 @@ public class TestForTablesInitialColumnWidthLogicRendering extends t.setWidth(200); main.addComponent(t); - Button b = new Button("refresh view", this, "createNewView"); + final Button b = new Button("refresh view", this, "createNewView"); main.addComponent(b); } public static Table getTestTable(int cols, int rows) { - Table t = new Table(); + final Table t = new Table(); t.setColumnCollapsingAllowed(true); for (int i = 0; i < cols; i++) { t.addContainerProperty(testString[i], String.class, ""); } for (int i = 0; i < rows; i++) { - Vector content = new Vector(); + final Vector content = new Vector(); for (int j = 0; j < cols; j++) { content.add(rndString()); } diff --git a/src/com/itmill/toolkit/tests/TestForTrees.java b/src/com/itmill/toolkit/tests/TestForTrees.java index 331ec4065d..fd7624fce4 100644 --- a/src/com/itmill/toolkit/tests/TestForTrees.java +++ b/src/com/itmill/toolkit/tests/TestForTrees.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.event.Action; @@ -26,9 +30,9 @@ public class TestForTrees extends CustomComponent implements Handler { "Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding", "Einstein" }; - private OrderedLayout main = new OrderedLayout(); + private final OrderedLayout main = new OrderedLayout(); - private Action[] actions = new Action[] { new Action("edit"), + private final Action[] actions = new Action[] { new Action("edit"), new Action("delete") }; private Panel al; @@ -75,20 +79,20 @@ public class TestForTrees extends CustomComponent implements Handler { t.setCaption("with actions"); t.setImmediate(true); t.addActionHandler(this); - OrderedLayout ol = (OrderedLayout) createTestBench(t); + final OrderedLayout ol = (OrderedLayout) createTestBench(t); al = new Panel("action log"); ol.addComponent(al); main.addComponent(ol); contextTree = t; - Button b = new Button("refresh view", this, "createNewView"); + final Button b = new Button("refresh view", this, "createNewView"); main.addComponent(b); } public Tree createTestTree() { Tree t = new Tree("Tree"); - String[] names = new String[100]; + final String[] names = new String[100]; for (int i = 0; i < names.length; i++) { names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))] + " " @@ -99,7 +103,7 @@ public class TestForTrees extends CustomComponent implements Handler { t = new Tree("Organization Structure"); for (int i = 0; i < 100; i++) { t.addItem(names[i]); - String parent = names[(int) (Math.random() * (names.length - 1))]; + final String parent = names[(int) (Math.random() * (names.length - 1))]; if (t.containsId(parent)) { t.setParent(names[i], parent); } @@ -115,7 +119,7 @@ public class TestForTrees extends CustomComponent implements Handler { } public Component createTestBench(Tree t) { - OrderedLayout ol = new OrderedLayout(); + final OrderedLayout ol = new OrderedLayout(); ol.setOrientation(OrderedLayout.ORIENTATION_HORIZONTAL); ol.addComponent(t); diff --git a/src/com/itmill/toolkit/tests/TestForUpload.java b/src/com/itmill/toolkit/tests/TestForUpload.java index 5817a35af6..0d8cbb52a2 100644 --- a/src/com/itmill/toolkit/tests/TestForUpload.java +++ b/src/com/itmill/toolkit/tests/TestForUpload.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.io.ByteArrayInputStream; @@ -78,9 +82,9 @@ public class TestForUpload extends CustomComponent implements up.setProgressListener(this); - Button b = new Button("b", this, "readState"); + final Button b = new Button("b", this, "readState"); - Button c = new Button("b with gc", this, "gc"); + final Button c = new Button("b with gc", this, "gc"); main.addComponent(b); main.addComponent(c); @@ -112,7 +116,7 @@ public class TestForUpload extends CustomComponent implements status.setVisible(false); main.addComponent(status); - Button restart = new Button("R"); + final Button restart = new Button("R"); restart.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { @@ -124,7 +128,7 @@ public class TestForUpload extends CustomComponent implements } private void setBuffer() { - String id = (String) uploadBufferSelector.getValue(); + final String id = (String) uploadBufferSelector.getValue(); if ("memory".equals(id)) { buffer = new MemoryBuffer(); } else if ("tempfile".equals(id)) { @@ -139,7 +143,7 @@ public class TestForUpload extends CustomComponent implements } public void readState() { - StringBuffer sb = new StringBuffer(); + final StringBuffer sb = new StringBuffer(); if (up.isUploading()) { sb.append("Uploading..."); @@ -159,7 +163,7 @@ public class TestForUpload extends CustomComponent implements public void uploadFinished(FinishedEvent event) { status.removeAllComponents(); - InputStream stream = buffer.getStream(); + final InputStream stream = buffer.getStream(); if (stream == null) { status.addComponent(new Label( "Upload finished, but output buffer is null!!")); @@ -245,11 +249,11 @@ public class TestForUpload extends CustomComponent implements private FileInputStream stream; public TmpFileBuffer() { - String tempFileName = "upload_tmpfile_" + final String tempFileName = "upload_tmpfile_" + System.currentTimeMillis(); try { file = File.createTempFile(tempFileName, null); - } catch (IOException e) { + } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -262,7 +266,7 @@ public class TestForUpload extends CustomComponent implements } try { return new FileInputStream(file); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -278,7 +282,7 @@ public class TestForUpload extends CustomComponent implements mimeType = MIMEType; try { return new FileOutputStream(file); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/com/itmill/toolkit/tests/TestForWindowOpen.java b/src/com/itmill/toolkit/tests/TestForWindowOpen.java index 63a15f6aee..3db7c5c770 100644 --- a/src/com/itmill/toolkit/tests/TestForWindowOpen.java +++ b/src/com/itmill/toolkit/tests/TestForWindowOpen.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.terminal.ExternalResource; @@ -10,14 +14,14 @@ public class TestForWindowOpen extends CustomComponent { public TestForWindowOpen() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); setCompositionRoot(main); main.addComponent(new Button("Open in this window", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - ExternalResource r = new ExternalResource( + final ExternalResource r = new ExternalResource( "http://www.google.com"); getApplication().getMainWindow().open(r); @@ -29,7 +33,7 @@ public class TestForWindowOpen extends CustomComponent { new Button.ClickListener() { public void buttonClick(ClickEvent event) { - ExternalResource r = new ExternalResource( + final ExternalResource r = new ExternalResource( "http://www.google.com"); getApplication().getMainWindow().open(r, "mytarget"); @@ -41,7 +45,7 @@ public class TestForWindowOpen extends CustomComponent { new Button.ClickListener() { public void buttonClick(ClickEvent event) { - ExternalResource r = new ExternalResource( + final ExternalResource r = new ExternalResource( "http://www.google.com"); getApplication().getMainWindow() .open(r, "secondtarget"); diff --git a/src/com/itmill/toolkit/tests/TestForWindowing.java b/src/com/itmill/toolkit/tests/TestForWindowing.java index 972cdb6747..92e860450c 100644 --- a/src/com/itmill/toolkit/tests/TestForWindowing.java +++ b/src/com/itmill/toolkit/tests/TestForWindowing.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -20,60 +24,62 @@ public class TestForWindowing extends CustomComponent { public TestForWindowing() { - OrderedLayout main = new OrderedLayout(); + final OrderedLayout main = new OrderedLayout(); main.addComponent(new Label( "Click the button to create a new inline window.")); - Button create = new Button("Create a new window", new ClickListener() { + final Button create = new Button("Create a new window", + new ClickListener() { - public void buttonClick(ClickEvent event) { - Window w = new Window("Testing Window"); + public void buttonClick(ClickEvent event) { + Window w = new Window("Testing Window"); - AbstractSelect s1 = new OptionGroup(); - s1.setCaption("1. Select output format"); - s1.addItem("Excel sheet"); - s1.addItem("CSV plain text"); - s1.setValue("Excel sheet"); + AbstractSelect s1 = new OptionGroup(); + s1.setCaption("1. Select output format"); + s1.addItem("Excel sheet"); + s1.addItem("CSV plain text"); + s1.setValue("Excel sheet"); - s2 = new Select(); - s2.addItem("Separate by comma (,)"); - s2.addItem("Separate by colon (:)"); - s2.addItem("Separate by semicolon (;)"); - s2.setEnabled(false); + s2 = new Select(); + s2.addItem("Separate by comma (,)"); + s2.addItem("Separate by colon (:)"); + s2.addItem("Separate by semicolon (;)"); + s2.setEnabled(false); - s1.addListener(new ValueChangeListener() { + s1.addListener(new ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - String v = (String) event.getProperty().getValue(); - if (v.equals("CSV plain text")) { - s2.setEnabled(true); - } else { - s2.setEnabled(false); - } - } + public void valueChange(ValueChangeEvent event) { + String v = (String) event.getProperty() + .getValue(); + if (v.equals("CSV plain text")) { + s2.setEnabled(true); + } else { + s2.setEnabled(false); + } + } - }); + }); - w.addComponent(s1); - w.addComponent(s2); + w.addComponent(s1); + w.addComponent(s2); - Slider s = new Slider(); - s.setCaption("Volume"); - s.setMax(13); - s.setMin(12); - s.setResolution(2); - s.setImmediate(true); - // s.setOrientation(Slider.ORIENTATION_VERTICAL); - // s.setArrows(false); + Slider s = new Slider(); + s.setCaption("Volume"); + s.setMax(13); + s.setMin(12); + s.setResolution(2); + s.setImmediate(true); + // s.setOrientation(Slider.ORIENTATION_VERTICAL); + // s.setArrows(false); - w.addComponent(s); + w.addComponent(s); - getApplication().getMainWindow().addWindow(w); + getApplication().getMainWindow().addWindow(w); - } + } - }); + }); main.addComponent(create); diff --git a/src/com/itmill/toolkit/tests/TestIFrames.java b/src/com/itmill/toolkit/tests/TestIFrames.java index 67b0ca42b3..97dc5a05d4 100644 --- a/src/com/itmill/toolkit/tests/TestIFrames.java +++ b/src/com/itmill/toolkit/tests/TestIFrames.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.ui.CustomComponent; @@ -25,10 +29,10 @@ public class TestIFrames extends CustomComponent { } private Label createEmbedded(String URL) { - int width = 600; - int height = 250; - String iFrame = "