diff options
author | Jani Laakso <jani.laakso@itmill.com> | 2007-12-04 19:51:22 +0000 |
---|---|---|
committer | Jani Laakso <jani.laakso@itmill.com> | 2007-12-04 19:51:22 +0000 |
commit | 3b5793fd5540f8eee3c9a0ef49e2688c9505920c (patch) | |
tree | c60d8b56d5f2fe2772e2728f7ac639f3ff780af1 /src/com/itmill/toolkit | |
parent | 2bfeca0498c879c11f11a54a22ad87cccdaa78c2 (diff) | |
download | vaadin-framework-3b5793fd5540f8eee3c9a0ef49e2688c9505920c.tar.gz vaadin-framework-3b5793fd5540f8eee3c9a0ef49e2688c9505920c.zip |
License header parametrized
Cleanup performed
Organized imports
Format
svn changeset:3162/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit')
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; /** * <p> @@ -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("<hr />", 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 + "<b>Rows are loaded from the server as they are needed.<br />" + "Try scrolling the table to see it in action.</b><br />" + 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 <td> 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.<br/> 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( "<a href=\"http://www.itmill.com/index_developers.htm\">Developer Area</a>" + " | <a href=\"http://www.itmill.com/developers_documentation.htm\">Documentation</a>"); 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 <A href=\"http://www.itmill.com/manual/\">manual</a> "
+ "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",
"<pre>" + event.getProperty().getValue() + "</pre>",
@@ -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 + "<br/>" + 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 + "<?) OR (" + Reservation.PROPERTY_ID_RESERVED_TO + ">? 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, "<span>" + hstr + "</span>");
@@ -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 = "<span>" + umarker.getStringAttribute("html")
- + "</span>";
- 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 = "<span>"
+ + umarker.getStringAttribute("html") + "</span>";
+ 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("<div>"); if (getIconUrl() != null) { sb.append("<img src=\"" + getIconUrl() + "\" alt=\"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, "<span class=\"" + IDateField.CLASSNAME
+ "-calendarpanel-month\">" + monthName + " " + year
+ "</span>");
@@ -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("</script>", scriptStart); + final int j = lc.indexOf("</script>", scriptStart); scripts += html.substring(scriptStart + 1, j) + ";"; nextPosToCheck = endOfPrevScript = j + "</script>".length(); scriptStart = lc.indexOf("<script", nextPosToCheck); @@ -307,7 +312,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, } else { res = ""; startOfBody = lc.indexOf(">", startOfBody) + 1; - int endOfBody = lc.indexOf("</body>", startOfBody); + final int endOfBody = lc.indexOf("</body>", 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("<img src=\"" + getSrc(uidl, client) + "\"/>"); } 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("<object width=\"" + w + "\" height=\"" + h + "\"><param name=\"movie\" value=\"" diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java index 1d53cf5eb8..fd8fa7a65e 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.terminal.gwt.client.ui; import java.util.ArrayList; @@ -73,7 +77,7 @@ public class IExpandLayout extends ComplexPanel implements } public void add(Widget w) { - WidgetWrapper wrapper = createWidgetWrappper(); + final WidgetWrapper wrapper = createWidgetWrappper(); DOM.appendChild(childContainer, wrapper.getElement()); super.add(w, wrapper.getContainerElement()); } @@ -124,7 +128,7 @@ public class IExpandLayout extends ComplexPanel implements * @return */ public WidgetWrapper getWidgetWrapperFor(Widget child) { - Element containerElement = DOM.getParent(child.getElement()); + final Element containerElement = DOM.getParent(child.getElement()); if (orientationMode == ORIENTATION_HORIZONTAL) { return new HorizontalWidgetWrapper(containerElement); } else { @@ -161,7 +165,7 @@ public class IExpandLayout extends ComplexPanel implements } void setExpandedSize(int pixels) { - int spaceForMarginsAndSpacings = getOffsetHeight() + final int spaceForMarginsAndSpacings = getOffsetHeight() - DOM.getElementPropertyInt(getElement(), "clientHeight"); int fixedInnerSize = pixels - spaceForMarginsAndSpacings; if (fixedInnerSize < 0) { @@ -220,9 +224,9 @@ public class IExpandLayout extends ComplexPanel implements } else { if (td == null) { // build one cell table - Element table = DOM.createTable(); - Element tBody = DOM.createTBody(); - Element tr = DOM.createTR(); + final Element table = DOM.createTable(); + final Element tBody = DOM.createTBody(); + final Element tr = DOM.createTR(); td = DOM.createTD(); DOM.appendChild(table, tBody); DOM.appendChild(tBody, tr); @@ -234,7 +238,7 @@ public class IExpandLayout extends ComplexPanel implements DOM.setElementProperty(td, "className", CLASSNAME + "-valign"); // move possible content to cell - Element content = DOM.getFirstChild(getElement()); + final Element content = DOM.getFirstChild(getElement()); if (content != null) { DOM.removeChild(getElement(), content); DOM.appendChild(td, content); @@ -263,10 +267,10 @@ public class IExpandLayout extends ComplexPanel implements } 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); } @@ -290,15 +294,16 @@ public class IExpandLayout extends ComplexPanel implements // 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; // Set alignment attributes - Iterator it = getPaintables().iterator(); + final Iterator it = getPaintables().iterator(); boolean first = true; while (it.hasNext()) { // Calculate alignment info - AlignmentInfo ai = new AlignmentInfo(alignments[alignmentIndex++]); - WidgetWrapper wr = getWidgetWrapperFor((Widget) it.next()); + final AlignmentInfo ai = new AlignmentInfo( + alignments[alignmentIndex++]); + final WidgetWrapper wr = getWidgetWrapperFor((Widget) it.next()); wr.setAlignment(ai.getVerticalAlignment(), ai .getHorizontalAlignment()); if (first) { @@ -312,7 +317,8 @@ public class IExpandLayout extends ComplexPanel implements } protected void handleMargins(UIDL uidl) { - MarginInfo margins = new MarginInfo(uidl.getIntAttribute("margins")); + final MarginInfo margins = new MarginInfo(uidl + .getIntAttribute("margins")); setStyleName(me, CLASSNAME + "-" + StyleConstants.LAYOUT_MARGIN_TOP, margins.hasTop()); setStyleName(me, StyleConstants.LAYOUT_MARGIN_RIGHT, margins.hasRight()); @@ -338,9 +344,9 @@ public class IExpandLayout extends ComplexPanel implements return; } - int availableSpace = getAvailableSpace(); + final int availableSpace = getAvailableSpace(); - int usedSpace = getUsedSpace(); + final int usedSpace = getUsedSpace(); int spaceForExpandedWidget = availableSpace - usedSpace; @@ -349,7 +355,7 @@ public class IExpandLayout extends ComplexPanel implements spaceForExpandedWidget = EXPANDED_ELEMENTS_MIN_WIDTH; } - WidgetWrapper wr = getWidgetWrapperFor(expandedWidget); + final WidgetWrapper wr = getWidgetWrapperFor(expandedWidget); wr.setExpandedSize(spaceForExpandedWidget); // TODO save previous size and only propagate if really changed @@ -373,12 +379,12 @@ public class IExpandLayout extends ComplexPanel implements private int getUsedSpace() { int total = 0; - int widgetCount = getWidgetCount(); - Iterator it = iterator(); + final int widgetCount = getWidgetCount(); + final Iterator it = iterator(); while (it.hasNext()) { - Widget w = (Widget) it.next(); + final Widget w = (Widget) it.next(); if (w != expandedWidget) { - WidgetWrapper wr = getWidgetWrapperFor(w); + final WidgetWrapper wr = getWidgetWrapperFor(w); if (orientationMode == ORIENTATION_VERTICAL) { total += wr.getOffsetHeight(); } else { @@ -393,8 +399,8 @@ public class IExpandLayout extends ComplexPanel implements private int getSpacingSize() { if (hasComponentSpacing) { if (spacingSize < 0) { - Element temp = DOM.createDiv(); - WidgetWrapper wr = createWidgetWrappper(); + final Element temp = DOM.createDiv(); + final WidgetWrapper wr = createWidgetWrappper(); wr.setSpacingEnabled(true); DOM.appendChild(temp, wr.getElement()); DOM.setStyleAttribute(temp, "position", "absolute"); @@ -427,12 +433,14 @@ public class IExpandLayout extends ComplexPanel implements DOM.setStyleAttribute(getElement(), "overflow", "visible"); } - int marginTop = DOM.getElementPropertyInt(DOM.getFirstChild(me), - "offsetTop") + final int marginTop = DOM.getElementPropertyInt(DOM + .getFirstChild(me), "offsetTop") - DOM.getElementPropertyInt(element, "offsetTop"); - Element lastElement = DOM.getChild(me, (DOM.getChildCount(me) - 1)); - int marginBottom = DOM.getElementPropertyInt(me, "offsetHeight") + final Element lastElement = DOM.getChild(me, + (DOM.getChildCount(me) - 1)); + final int marginBottom = DOM.getElementPropertyInt(me, + "offsetHeight") + DOM.getElementPropertyInt(me, "offsetTop") - (DOM.getElementPropertyInt(lastElement, "offsetTop") + DOM .getElementPropertyInt(lastElement, "offsetHeight")); @@ -446,16 +454,16 @@ public class IExpandLayout extends ComplexPanel implements 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 { - WidgetWrapper wrapper = createWidgetWrappper(); + final WidgetWrapper wrapper = createWidgetWrappper(); DOM.insertChild(childContainer, wrapper.getElement(), beforeIndex); insert(w, wrapper.getContainerElement(), beforeIndex, false); } @@ -466,8 +474,8 @@ public class IExpandLayout extends ComplexPanel implements } public boolean remove(Widget w) { - WidgetWrapper ww = getWidgetWrapperFor(w); - boolean removed = super.remove(w); + final WidgetWrapper ww = getWidgetWrapperFor(w); + final boolean removed = super.remove(w); if (removed) { if (!(w instanceof Caption)) { DOM.removeChild(childContainer, ww.getElement()); @@ -478,7 +486,7 @@ public class IExpandLayout extends ComplexPanel implements } 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); @@ -486,7 +494,7 @@ public class IExpandLayout extends ComplexPanel implements } 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); @@ -500,12 +508,12 @@ public class IExpandLayout extends ComplexPanel implements 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); @@ -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("<img src=\""); sb.append(iconUri); @@ -88,11 +92,11 @@ public class IFilterSelect extends Composite implements Paintable, private static final String Z_INDEX = "30000"; - private SuggestionMenu menu; + private final SuggestionMenu menu; - private Element up = DOM.createDiv(); - private Element down = DOM.createDiv(); - private Element status = DOM.createDiv(); + private final Element up = DOM.createDiv(); + private final Element down = DOM.createDiv(); + private final Element status = DOM.createDiv(); private boolean isPagingEnabled = true; @@ -105,7 +109,7 @@ public class IFilterSelect extends Composite implements Paintable, setStyleName(CLASSNAME + "-suggestpopup"); DOM.setStyleAttribute(getElement(), "zIndex", Z_INDEX); - Element root = getContainerElement(); + final Element root = getContainerElement(); DOM.setInnerHTML(up, "<span>Prev</span>"); 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 += "<div>" + captions[i] + "</div>"; - // 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 += "<div>" + captions[i] + "</div>"; + // 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("<span class=\"i-off\">"); } @@ -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("<span/>");
+ final HTML br = new HTML("<span/>");
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 += "<H1>" @@ -126,19 +131,20 @@ public class IView extends SimplePanel implements Paintable, + "</p>"; } - 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 += "<H1>" @@ -290,11 +294,12 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener { + "</p>"; } - 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<result.length;i++)
- matches.@java.util.ArrayList::add(Ljava/lang/Object;)(result[i]);
- }-*/;
+ 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<result.length;i++)
+ matches.@java.util.ArrayList::add(Ljava/lang/Object;)(result[i]);
+ }-*/;
/**
* Determines wether the specified regular expression is validated by the
@@ -139,9 +139,9 @@ public class Pattern { * array is returned.
*/
public String[] match(String text) {
- List matches = new ArrayList();
+ final List matches = new ArrayList();
_match(text, matches);
- String arr[] = new String[matches.size()];
+ final String arr[] = new String[matches.size()];
for (int i = 0; i < matches.size(); i++) {
arr[i] = matches.get(i).toString();
}
@@ -155,9 +155,9 @@ public class Pattern { * @return
*/
public native boolean matches(String text)/*-{
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
- return regExp.test(text);
- }-*/;
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
+ return regExp.test(text);
+ }-*/;
/**
* Returns the regular expression for this pattern
@@ -165,16 +165,16 @@ public class Pattern { * @return
*/
public native String pattern()/*-{
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
- return regExp.source;
- }-*/;
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
+ return regExp.source;
+ }-*/;
private native void _split(String input, List results)/*-{
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
- var parts = input.split(regExp);
- for (var i=0;i<parts.length;i++)
- results.@java.util.ArrayList::add(Ljava/lang/Object;)(parts[i] );
- }-*/;
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
+ var parts = input.split(regExp);
+ for (var i=0;i<parts.length;i++)
+ results.@java.util.ArrayList::add(Ljava/lang/Object;)(parts[i] );
+ }-*/;
/**
* Split an input string by the pattern's regular expression
@@ -183,9 +183,9 @@ public class Pattern { * @return Array of strings
*/
public String[] split(String input) {
- List results = new ArrayList();
+ final List results = new ArrayList();
_split(input, results);
- String[] parts = new String[results.size()];
+ final String[] parts = new String[results.size()];
for (int i = 0; i < results.size(); i++) {
parts[i] = (String) results.get(i);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java b/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java index dfff067ec7..08a3ed2f18 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java @@ -63,7 +63,7 @@ import java.util.Date; * @version $Revision: 0.0 $ */ public class SimpleDateFormat { - private String format; + private final String format; private DateLocale locale = new DateLocale(); /** @@ -89,8 +89,8 @@ public class SimpleDateFormat { String lastTokenType = null; String currentToken = ""; for (int i = 0; i < format.length(); i++) { - String thisChar = format.substring(i, i + 1); - String currentTokenType = DateLocale.SUPPORTED_DF_TOKENS + final String thisChar = format.substring(i, i + 1); + final String currentTokenType = DateLocale.SUPPORTED_DF_TOKENS .contains(thisChar) ? thisChar : ""; if (currentTokenType.equals(lastTokenType) || i == 0) { currentToken += thisChar; @@ -126,7 +126,7 @@ public class SimpleDateFormat { */ private String handleToken(String token, Date date) { String response = token; - String tc = token.substring(0, 1); + final String tc = token.substring(0, 1); if (DateLocale.TOKEN_DAY_OF_WEEK.equals(tc)) { if (token.length() > 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("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " @@ -545,11 +523,12 @@ public class ApplicationServlet extends HttpServlet { if (applicationRunnerMode) { String servletPath = request.getContextPath() + request.getServletPath(); - 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)); + } appUrl = servletPath; } else { urlParts = getApplicationUrl(request).toString().split("\\/"); @@ -568,7 +547,7 @@ public class ApplicationServlet extends HttpServlet { widgetset = DEFAULT_WIDGETSET; } - String staticFilePath = getApplicationOrSystemProperty( + final String staticFilePath = getApplicationOrSystemProperty( PARAMETER_ITMILL_RESOURCES, appUrl); // Default theme does not use theme URI @@ -635,7 +614,7 @@ public class ApplicationServlet extends HttpServlet { DownloadStream stream = null; try { stream = application.handleURI(application.getURL(), uri); - } catch (Throwable t) { + } catch (final Throwable t) { application.terminalError(new URIHandlerErrorImpl(application, t)); } @@ -662,14 +641,14 @@ public class ApplicationServlet extends HttpServlet { 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"); @@ -686,10 +665,10 @@ public class ApplicationServlet extends HttpServlet { // 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)); } } @@ -698,18 +677,18 @@ public class ApplicationServlet extends HttpServlet { 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) { } } @@ -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("<html><body>download handled</body></html>"); 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("<html><head><title>Application Internal Error</title></head><body>"); err.write("<h1>" + e.toString() + "</h1><pre>\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("<B>Below are few custom components</B>", 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( "<hr /><h1>Components inside horizontal OrderedLayout</h3>", 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( "<br/><br/><br/><hr /><h1>Components inside vertical OrderedLayout</h3>", 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( "<hr /><h1>Components inside ExpandLayout (height 250px)</h3>", 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( "<hr /><h1>Components inside Panel</h3>", 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( "<hr /><h1>Components inside vertical SplitPanel (splitpanel is under 250height ExpandLayout)</h3>", 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( "<hr /><h1>Components inside horizontal SplitPanel (splitpanel is under 250px height ExpandLayout)</h3>", 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( "<hr /><h1>Components inside TabSheet</h3>", 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( "<hr /><h1>Components inside GridLayout</h3>", 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("<B>Below are few custom components</B>", Label.CONTENT_XHTML)); - TestForUpload tfu = new TestForUpload(); + final TestForUpload tfu = new TestForUpload(); layout.addComponent(tfu); layout.addComponent(new Label("<br/><b>----------<br/></p>", 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 = "<iframe height=\"" + height + "\" width=\"" + width - + "\" src=\"" + URL + "\" />"; + final int width = 600; + final int height = 250; + final String iFrame = "<iframe height=\"" + height + "\" width=\"" + + width + "\" src=\"" + URL + "\" />"; return new Label(iFrame, Label.CONTENT_XHTML); } diff --git a/src/com/itmill/toolkit/tests/TestSelectAndDatefieldInDeepLayouts.java b/src/com/itmill/toolkit/tests/TestSelectAndDatefieldInDeepLayouts.java index ea09e5d6ba..7dc419f96f 100644 --- a/src/com/itmill/toolkit/tests/TestSelectAndDatefieldInDeepLayouts.java +++ b/src/com/itmill/toolkit/tests/TestSelectAndDatefieldInDeepLayouts.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.util.Collection; @@ -23,7 +27,7 @@ import com.itmill.toolkit.ui.Select; public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { public TestSelectAndDatefieldInDeepLayouts() { - OrderedLayout root = (OrderedLayout) getOrderedLayout(); + final OrderedLayout root = (OrderedLayout) getOrderedLayout(); setCompositionRoot(root); root.addComponent(getSelect()); @@ -31,7 +35,7 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { root.addComponent(getSelect()); root.addComponent(getDateField()); - Panel p1 = getPanel(); + final Panel p1 = getPanel(); root.addComponent(p1); p1.addComponent(getSelect()); @@ -39,7 +43,7 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { p1.addComponent(getSelect()); p1.addComponent(getDateField()); - OrderedLayout l1 = (OrderedLayout) getOrderedLayout(); + final OrderedLayout l1 = (OrderedLayout) getOrderedLayout(); p1.addComponent(l1); l1.addComponent(getSelect()); @@ -47,7 +51,7 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { l1.addComponent(getSelect()); l1.addComponent(getDateField()); - Panel p2 = getPanel(); + final Panel p2 = getPanel(); l1.addComponent(p2); p2.addComponent(getSelect()); @@ -58,13 +62,13 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { } AbstractLayout getOrderedLayout() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); l.setCaption(getCaption("orderedlayout")); return l; } Panel getPanel() { - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption(getCaption("panel")); return panel; } @@ -78,7 +82,7 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { } private Collection getSelectOptions() { - Collection opts = new Vector(3); + final Collection opts = new Vector(3); opts.add(getCaption("opt 1")); opts.add(getCaption("opt 2")); opts.add(getCaption("opt 3")); diff --git a/src/com/itmill/toolkit/tests/TestSetVisibleAndCaching.java b/src/com/itmill/toolkit/tests/TestSetVisibleAndCaching.java index 009cd20067..4f4d2dc099 100644 --- a/src/com/itmill/toolkit/tests/TestSetVisibleAndCaching.java +++ b/src/com/itmill/toolkit/tests/TestSetVisibleAndCaching.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.ui.Button; @@ -18,7 +22,7 @@ public class TestSetVisibleAndCaching extends com.itmill.toolkit.Application { int selectedPanel = 0; public void init() { - Window mainWindow = new Window("TestSetVisibleAndCaching"); + final Window mainWindow = new Window("TestSetVisibleAndCaching"); setMainWindow(mainWindow); panelA.addComponent(new Label( diff --git a/src/com/itmill/toolkit/tests/TestSplitPanel.java b/src/com/itmill/toolkit/tests/TestSplitPanel.java index 9945fc966f..fffd1ffb5a 100644 --- a/src/com/itmill/toolkit/tests/TestSplitPanel.java +++ b/src/com/itmill/toolkit/tests/TestSplitPanel.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import com.itmill.toolkit.ui.Label; @@ -11,7 +15,7 @@ public class TestSplitPanel extends com.itmill.toolkit.Application { SplitPanel verticalSplit = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); public void init() { - Window mainWindow = new Window("Feature Browser"); + final Window mainWindow = new Window("Feature Browser"); setMainWindow(mainWindow); verticalSplit.setFirstComponent(new Label("vertical first")); diff --git a/src/com/itmill/toolkit/tests/UsingObjectsInSelect.java b/src/com/itmill/toolkit/tests/UsingObjectsInSelect.java index da29b7ee7c..76c06ad130 100644 --- a/src/com/itmill/toolkit/tests/UsingObjectsInSelect.java +++ b/src/com/itmill/toolkit/tests/UsingObjectsInSelect.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests; import java.util.LinkedList; @@ -13,20 +17,21 @@ import com.itmill.toolkit.ui.Window; public class UsingObjectsInSelect extends com.itmill.toolkit.Application implements ValueChangeListener { - private Select select = new Select(); - private Label selectedTask = new Label("Selected task", Label.CONTENT_XHTML); + private final Select select = new Select(); + private final Label selectedTask = new Label("Selected task", + Label.CONTENT_XHTML); public LinkedList exampleTasks = new LinkedList(); public static Random random = new Random(1); public void init() { - Window main = new Window("Select demo"); + final Window main = new Window("Select demo"); setMainWindow(main); - Panel panel = new Panel("Select demo"); + final Panel panel = new Panel("Select demo"); panel.addComponent(select); - Panel panel2 = new Panel("Selection"); + final Panel panel2 = new Panel("Selection"); panel2.addComponent(selectedTask); select.setCaption("Select component"); @@ -40,12 +45,12 @@ public class UsingObjectsInSelect extends com.itmill.toolkit.Application } public void createExampleTasks() { - String[] assignedTo = new String[] { "John", "Mary", "Joe", "Sarah", - "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" }; - String[] type = new String[] { "Enhancement", "Bugfix", "Testing", - "Task" }; + final String[] assignedTo = new String[] { "John", "Mary", "Joe", + "Sarah", "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" }; + final String[] type = new String[] { "Enhancement", "Bugfix", + "Testing", "Task" }; for (int j = 0; j < 100; j++) { - Task task = new Task( + final Task task = new Task( type[(int) (random.nextDouble() * (type.length - 1))], assignedTo[(int) (random.nextDouble() * (assignedTo.length - 1))], random.nextInt(100)); @@ -54,7 +59,7 @@ public class UsingObjectsInSelect extends com.itmill.toolkit.Application } public void valueChange(ValueChangeEvent event) { - Task task = (Task) select.getValue(); + final Task task = (Task) select.getValue(); selectedTask.setValue("<b>Type:</b> " + task.getType() + "<br /><b>Assigned to:</b> " + task.getAssignedTo() + "<br /><b>Estimated hours: </b>" + task.getEstimatedHours()); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/Feature.java b/src/com/itmill/toolkit/tests/featurebrowser/Feature.java index 058cff97aa..3bd9d8e44e 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/Feature.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/Feature.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.tests.featurebrowser; @@ -47,7 +23,7 @@ public abstract class Feature extends CustomComponent { private boolean propsReminder = true; - private OrderedLayout layout; + private final OrderedLayout layout; private TabSheet ts; @@ -96,7 +72,7 @@ public abstract class Feature extends CustomComponent { javadoc.setContentMode(Label.CONTENT_XHTML); // Demo - Component demo = getDemoComponent(); + final Component demo = getDemoComponent(); if (demo != null) { layout.addComponent(demo); } @@ -109,11 +85,11 @@ public abstract class Feature extends CustomComponent { ts.setHeightUnits(Sizeable.UNITS_PERCENTAGE); // Description tab - String title = getTitle(); + final String title = getTitle(); if (getDescriptionXHTML() != null) { - OrderedLayout mainLayout = new OrderedLayout( + final OrderedLayout mainLayout = new OrderedLayout( OrderedLayout.ORIENTATION_VERTICAL); - OrderedLayout layout = new OrderedLayout( + final OrderedLayout layout = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); mainLayout.addComponent(layout); if (getImage() != null) { @@ -131,7 +107,7 @@ public abstract class Feature extends CustomComponent { } description = new Label(label, Label.CONTENT_XHTML); mainLayout.addComponent(description); - mainLayout.setMargin(true); + mainLayout.setMargin(true); ts.addTab(mainLayout, "Description", null); } @@ -145,9 +121,9 @@ public abstract class Feature extends CustomComponent { } // Code Sample tab - String example = getExampleSrc(); + final String example = getExampleSrc(); if (example != null) { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); if (getTitle() != null) { l.addComponent(new Label( "<b>// " + getTitle() + " example</b>", diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureBrowser.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureBrowser.java index 2aaefecc5a..1aecfc6d45 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureBrowser.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureBrowser.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.tests.featurebrowser; @@ -57,7 +33,7 @@ public class FeatureBrowser extends CustomComponent implements private boolean initialized = false; - private Select themeSelector = new Select(); + private final Select themeSelector = new Select(); public void attach() { @@ -89,7 +65,7 @@ public class FeatureBrowser extends CustomComponent implements themeSelector.setImmediate(true); // Restart button - Button close = new Button("restart", getApplication(), "close"); + final Button close = new Button("restart", getApplication(), "close"); close.setStyle("link"); mainlayout.addComponent(close, "restart"); @@ -143,7 +119,7 @@ public class FeatureBrowser extends CustomComponent implements // new FeatureParameters()); // Pre-open all menus - for (Iterator i = features.getItemIds().iterator(); i.hasNext();) { + for (final Iterator i = features.getItemIds().iterator(); i.hasNext();) { features.expandItem(i.next()); } @@ -158,11 +134,11 @@ public class FeatureBrowser extends CustomComponent implements } public void registerFeature(String path, Feature feature) { - StringTokenizer st = new StringTokenizer(path, "/"); + final StringTokenizer st = new StringTokenizer(path, "/"); String id = ""; String parentId = null; while (st.hasMoreTokens()) { - String token = st.nextToken(); + final String token = st.nextToken(); id += "/" + token; if (!features.containsId(id)) { features.addItem(id); @@ -194,19 +170,20 @@ public class FeatureBrowser extends CustomComponent implements + ((AbstractComponent) event.getProperty()) .getTag() + ", " + event.getProperty()); } - } catch (Exception e) { + } catch (final Exception e) { // ignored, should never happen } // Change feature if (event.getProperty() == features) { - Object id = features.getValue(); + final Object id = features.getValue(); if (id != null) { if (features.areChildrenAllowed(id)) { features.expandItem(id); } - Property p = features.getContainerProperty(id, "feature"); - Feature feature = p != null ? ((Feature) p.getValue()) : null; + final Property p = features.getContainerProperty(id, "feature"); + final Feature feature = p != null ? ((Feature) p.getValue()) + : null; if (feature != null) { mainlayout.removeComponent(currentFeature); mainlayout.removeComponent(currentFeature.getTabSheet()); @@ -236,7 +213,7 @@ public class FeatureBrowser extends CustomComponent implements "buttonClick " + event.getButton().getTag() + ", " + event.getButton().getCaption() + ", " + event.getButton().getValue()); - } catch (Exception e) { + } catch (final Exception e) { // ignored, should never happen } diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureBuffering.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureBuffering.java index 2711f7fd58..be2aac0d30 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureBuffering.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureBuffering.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.tests.featurebrowser; @@ -61,12 +37,12 @@ public class FeatureBuffering extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final OrderedLayout l = new OrderedLayout(); + final Panel panel = new Panel(); panel.setCaption("Buffering"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -74,9 +50,9 @@ public class FeatureBuffering extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureButton.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureButton.java index b3038a76ef..05f35cd7d5 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureButton.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureButton.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.tests.featurebrowser; @@ -42,17 +18,17 @@ public class FeatureButton extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Button b = new Button("Caption"); + final Button b = new Button("Caption"); l.addComponent(b); // Properties propertyPanel = new PropertyPanel(b); - Select themes = (Select) propertyPanel.getField("style"); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("link").getItemProperty( themes.getItemCaptionPropertyId()).setValue("link"); - Form ap = propertyPanel + final Form ap = propertyPanel .createBeanPropertySet(new String[] { "switchMode" }); propertyPanel.addProperties("Button Properties", ap); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureContainers.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureContainers.java index 62d2a5753f..37c94d7a4c 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureContainers.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureContainers.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.tests.featurebrowser; @@ -66,13 +42,13 @@ public class FeatureContainers extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Containers"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -80,9 +56,9 @@ public class FeatureContainers extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureCustomLayout.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureCustomLayout.java index 1cac66516b..395328dbb1 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureCustomLayout.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureCustomLayout.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.tests.featurebrowser; @@ -52,13 +28,13 @@ public class FeatureCustomLayout extends Feature { + "the subcomponents with flowlayout."; protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Custom Layout"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -66,9 +42,9 @@ public class FeatureCustomLayout extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureDateField.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureDateField.java index 28530ecca8..562d47d403 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureDateField.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureDateField.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.tests.featurebrowser; @@ -41,7 +17,7 @@ public class FeatureDateField extends Feature { static private String[] localeNames; static { - Locale[] locales = Locale.getAvailableLocales(); + final Locale[] locales = Locale.getAvailableLocales(); localeNames = new String[locales.length]; for (int i = 0; i < locales.length; i++) { localeNames[i] = locales[i].getDisplayName(); @@ -54,18 +30,18 @@ public class FeatureDateField extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); l.addComponent(new Label("Your default locale is: " + getApplication().getLocale().toString().replace('_', '-'))); - DateField df = new DateField(); + final DateField df = new DateField(); df.setValue(new java.util.Date()); l.addComponent(df); // Properties propertyPanel = new PropertyPanel(df); - Form ap = propertyPanel.createBeanPropertySet(new String[] { + final Form ap = propertyPanel.createBeanPropertySet(new String[] { "resolution", "locale" }); ap.replaceWithSelect("resolution", new Object[] { new Integer(DateField.RESOLUTION_YEAR), @@ -82,7 +58,7 @@ public class FeatureDateField extends Feature { ap.getField("resolution").setValue( new Integer(DateField.RESOLUTION_DAY)); ap.getField("locale").setValue(Locale.getDefault()); - Select themes = (Select) propertyPanel.getField("style"); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("text").getItemProperty( themes.getItemCaptionPropertyId()).setValue("text"); themes.addItem("calendar").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureEmbedded.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureEmbedded.java index ba0f2eca3a..0cf915a0fe 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureEmbedded.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureEmbedded.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.tests.featurebrowser; @@ -43,11 +19,11 @@ public class FeatureEmbedded extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - ClassResource flashResource = new ClassResource("itmill_spin.swf", - getApplication()); - Embedded emb = new Embedded("Embedded Caption", flashResource); + final ClassResource flashResource = new ClassResource( + "itmill_spin.swf", getApplication()); + final Embedded emb = new Embedded("Embedded Caption", flashResource); emb.setType(Embedded.TYPE_OBJECT); emb.setMimeType("application/x-shockwave-flash"); emb.setWidth(250); @@ -56,16 +32,16 @@ public class FeatureEmbedded extends Feature { // Properties propertyPanel = new PropertyPanel(emb); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "type", - "source", "width", "height", "widthUnits", "heightUnits", - "codebase", "codetype", "archive", "mimeType", "standby", - "classId" }); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "type", "source", "width", "height", "widthUnits", + "heightUnits", "codebase", "codetype", "archive", "mimeType", + "standby", "classId" }); ap.replaceWithSelect("type", new Object[] { new Integer(Embedded.TYPE_IMAGE), new Integer(Embedded.TYPE_OBJECT) }, new Object[] { "Image", "Object" }); - Object[] units = new Object[Sizeable.UNIT_SYMBOLS.length]; - Object[] symbols = new Object[Sizeable.UNIT_SYMBOLS.length]; + final Object[] units = new Object[Sizeable.UNIT_SYMBOLS.length]; + final Object[] symbols = new Object[Sizeable.UNIT_SYMBOLS.length]; for (int i = 0; i < units.length; i++) { units[i] = new Integer(i); symbols[i] = Sizeable.UNIT_SYMBOLS[i]; diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureForm.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureForm.java index 7b18555248..94da491433 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureForm.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureForm.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.tests.featurebrowser; @@ -77,7 +53,7 @@ public class FeatureForm extends Feature implements } demo.addComponent(test); - OrderedLayout actions = new OrderedLayout( + final OrderedLayout actions = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); demo.addComponent(actions); @@ -111,7 +87,7 @@ public class FeatureForm extends Feature implements if (event.getProperty() == resetLayout) { - String value = (String) resetLayout.getValue(); + final String value = (String) resetLayout.getValue(); if (value != null) { formLayout = null; @@ -131,14 +107,14 @@ public class FeatureForm extends Feature implements if (event.getProperty() == addField) { - String value = (String) addField.getValue(); + final String value = (String) addField.getValue(); if (value != null) { if (value.equals("Text field")) { test.addField(new Object(), new TextField("Test field")); } if (value.equals("Time")) { - DateField d = new DateField("Time", new Date()); + final DateField d = new DateField("Time", new Date()); d .setDescription("This is a DateField-component with text-style"); d.setResolution(DateField.RESOLUTION_MIN); @@ -146,7 +122,7 @@ public class FeatureForm extends Feature implements test.addField(new Object(), d); } if (value.equals("Calendar")) { - DateField c = new DateField("Calendar", new Date()); + final DateField c = new DateField("Calendar", new Date()); c .setDescription("DateField-component with calendar-style and day-resolution"); c.setStyle("calendar"); @@ -154,7 +130,7 @@ public class FeatureForm extends Feature implements test.addField(new Object(), c); } if (value.equals("Option group")) { - Select s = new Select("Options"); + final Select s = new Select("Options"); s.setDescription("Select-component with optiongroup-style"); s.addItem("Linux"); s.addItem("Windows"); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureGridLayout.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureGridLayout.java index 63b8235543..e9db50b6ec 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureGridLayout.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureGridLayout.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.tests.featurebrowser; @@ -46,10 +22,10 @@ public class FeatureGridLayout extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - GridLayout gl = new GridLayout(3, 3); - DateField cal = new DateField("Test component 1", new Date()); + final GridLayout gl = new GridLayout(3, 3); + final DateField cal = new DateField("Test component 1", new Date()); cal.setStyle("calendar"); gl.addComponent(cal, 1, 0, 2, 1); for (int i = 2; i < 7; i++) { @@ -59,8 +35,8 @@ public class FeatureGridLayout extends Feature { // Properties propertyPanel = new PropertyPanel(gl); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); ap.addField("new line", new Button("New Line", gl, "newLine")); ap.addField("space", new Button("Space", gl, "space")); propertyPanel.addProperties("GridLayout Features", ap); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureItems.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureItems.java index a723b201f0..bd880969d9 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureItems.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureItems.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.tests.featurebrowser; @@ -56,13 +32,13 @@ public class FeatureItems extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Items"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -70,9 +46,9 @@ public class FeatureItems extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureLabel.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureLabel.java index 4f1febb783..fc059452ed 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureLabel.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureLabel.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.tests.featurebrowser; @@ -41,14 +17,14 @@ public class FeatureLabel extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Label lab = new Label("Label text"); + final Label lab = new Label("Label text"); l.addComponent(lab); // Properties propertyPanel = new PropertyPanel(lab); - Form ap = propertyPanel.createBeanPropertySet(new String[] { + final Form ap = propertyPanel.createBeanPropertySet(new String[] { "contentMode", "value" }); ap.replaceWithSelect("contentMode", new Object[] { new Integer(Label.CONTENT_PREFORMATTED), diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureLink.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureLink.java index 3eb2434bfc..2b91a4262b 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureLink.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureLink.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.tests.featurebrowser; @@ -42,15 +18,15 @@ public class FeatureLink extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Link lnk = new Link("Link caption", new ExternalResource( + final Link lnk = new Link("Link caption", new ExternalResource( "http://www.itmill.com")); l.addComponent(lnk); // Properties propertyPanel = new PropertyPanel(lnk); - Form ap = propertyPanel.createBeanPropertySet(new String[] { + final Form ap = propertyPanel.createBeanPropertySet(new String[] { "targetName", "targetWidth", "targetHeight", "targetBorder" }); ap.replaceWithSelect("targetBorder", new Object[] { new Integer(Link.TARGET_BORDER_DEFAULT), diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureOrderedLayout.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureOrderedLayout.java index 4792baaed9..295eedc21b 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureOrderedLayout.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureOrderedLayout.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.tests.featurebrowser; @@ -42,9 +18,9 @@ public class FeatureOrderedLayout extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - OrderedLayout ol = new OrderedLayout(); + final OrderedLayout ol = new OrderedLayout(); for (int i = 1; i < 5; i++) { ol.addComponent(new TextField("Test component " + i)); } @@ -52,13 +28,13 @@ public class FeatureOrderedLayout extends Feature { // Properties propertyPanel = new PropertyPanel(ol); - Form ap = propertyPanel + final Form ap = propertyPanel .createBeanPropertySet(new String[] { "orientation" }); ap.replaceWithSelect("orientation", new Object[] { new Integer(OrderedLayout.ORIENTATION_HORIZONTAL), new Integer(OrderedLayout.ORIENTATION_VERTICAL) }, new Object[] { "Horizontal", "Vertical" }); - Select themes = (Select) propertyPanel.getField("style"); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("form").getItemProperty( themes.getItemCaptionPropertyId()).setValue("form"); propertyPanel.addProperties("OrderedLayout Properties", ap); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeaturePanel.java b/src/com/itmill/toolkit/tests/featurebrowser/FeaturePanel.java index 74cfa90ad1..1aa4510d87 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeaturePanel.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeaturePanel.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.tests.featurebrowser; @@ -43,10 +19,10 @@ public class FeaturePanel extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); // Example panel - Panel show = new Panel("Panel caption"); + final Panel show = new Panel("Panel caption"); show .addComponent(new Label( "This is an example Label component that is added into Panel.")); @@ -54,9 +30,9 @@ public class FeaturePanel extends Feature { // Properties propertyPanel = new PropertyPanel(show); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureParameters.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureParameters.java index 30f9194d06..1107bb5148 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureParameters.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureParameters.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.tests.featurebrowser; @@ -48,11 +24,11 @@ import com.itmill.toolkit.ui.Table; public class FeatureParameters extends Feature 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 FeatureParameters() { super(); @@ -61,30 +37,30 @@ public class FeatureParameters extends Feature implements URIHandler, protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Label info = new Label("To test this feature, try to " + final Label info = new Label("To test this feature, try to " + "add some get parameters to URL. For example if you have " + "the feature browser installed in your local host, try url: "); info.setCaption("Usage info"); l.addComponent(info); try { - URL u1 = new URL(getApplication().getURL(), + final URL u1 = new URL(getApplication().getURL(), "test/uri?test=1&test=2"); - URL u2 = new URL(getApplication().getURL(), + final URL u2 = new URL(getApplication().getURL(), "foo/bar?mary=john&count=3"); l.addComponent(new Link(u1.toString(), new ExternalResource(u1))); l.addComponent(new Label("Or this: ")); l.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 p1 = new Panel("URI Handler"); + final Panel p1 = new Panel("URI Handler"); context.setCaption("Last URI handler context"); p1.addComponent(context); relative.setCaption("Last relative URI"); @@ -92,7 +68,7 @@ public class FeatureParameters extends Feature implements URIHandler, l.addComponent(p1); // Parameters - Panel p2 = new Panel("Parameter Handler"); + final Panel p2 = new Panel("Parameter Handler"); params.setCaption("Last parameters"); params.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID); params.setRowHeaderMode(Table.ROW_HEADER_MODE_ID); @@ -101,9 +77,9 @@ public class FeatureParameters extends Feature implements URIHandler, // Properties propertyPanel = new PropertyPanel(p1); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( @@ -169,9 +145,9 @@ public class FeatureParameters extends Feature implements URIHandler, */ 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/tests/featurebrowser/FeatureProperties.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureProperties.java index 8e2db9ed7d..34d8c3efa8 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureProperties.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureProperties.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.tests.featurebrowser; @@ -64,13 +40,13 @@ public class FeatureProperties extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Data Model"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -78,9 +54,9 @@ public class FeatureProperties extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureSelect.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureSelect.java index 9d292093e4..80f6d9cc9d 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureSelect.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureSelect.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.tests.featurebrowser; @@ -50,9 +26,9 @@ public class FeatureSelect extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Select s = new Select("Select employee"); + final Select s = new Select("Select employee"); for (int i = 0; i < 50; i++) { s .addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))] @@ -63,7 +39,7 @@ public class FeatureSelect extends Feature { // Properties propertyPanel = new PropertyPanel(s); - Select themes = (Select) propertyPanel.getField("style"); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("optiongroup").getItemProperty( themes.getItemCaptionPropertyId()).setValue("optiongroup"); themes.addItem("twincol").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureTabSheet.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureTabSheet.java index 53fc4c5def..056d5d5d5e 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureTabSheet.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureTabSheet.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.tests.featurebrowser; @@ -41,9 +17,9 @@ public class FeatureTabSheet extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - TabSheet ts = new TabSheet(); + final TabSheet ts = new TabSheet(); ts .addTab( new Label( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureTable.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureTable.java index 37c9c18059..3404c05c44 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureTable.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureTable.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.tests.featurebrowser; @@ -59,8 +35,8 @@ public class FeatureTable extends Feature implements Action.Handler { private boolean actionsActive = false; - private Button actionHandlerSwitch = new Button("Activate actions", this, - "toggleActions"); + private final Button actionHandlerSwitch = new Button("Activate actions", + this, "toggleActions"); public void toggleActions() { if (actionsActive) { @@ -76,7 +52,7 @@ public class FeatureTable extends Feature implements Action.Handler { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); // Sample table t = new Table("Corporate Employees"); @@ -110,7 +86,7 @@ public class FeatureTable extends Feature implements Action.Handler { // Properties propertyPanel = new PropertyPanel(t); - Form ap = propertyPanel.createBeanPropertySet(new String[] { + final Form ap = propertyPanel.createBeanPropertySet(new String[] { "pageLength", "rowHeaderMode", "selectable", "columnHeaderMode", "columnCollapsingAllowed", "columnReorderingAllowed", "width", "height" }); @@ -132,7 +108,7 @@ public class FeatureTable extends Feature implements Action.Handler { "Explicit", "Explicit defaults ID", "Hidden", "Icon only", "ID", "Index", "Item", "Property" }); - Select themes = (Select) propertyPanel.getField("style"); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("list").getItemProperty( themes.getItemCaptionPropertyId()).setValue("list"); themes.addItem("paging").getItemProperty( @@ -199,13 +175,13 @@ public class FeatureTable extends Feature implements Action.Handler { return "Table"; } - private Action ACTION1 = new Action("Action 1"); + private final Action ACTION1 = new Action("Action 1"); - private Action ACTION2 = new Action("Action 2"); + private final Action ACTION2 = new Action("Action 2"); - private Action ACTION3 = new Action("Action 3"); + private final Action ACTION3 = new Action("Action 3"); - private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; + private final Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; public Action[] getActions(Object target, Object sender) { return actions; diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureTextField.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureTextField.java index 8bdcdd34f0..e937a12577 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureTextField.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureTextField.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.tests.featurebrowser; @@ -41,17 +17,17 @@ public class FeatureTextField extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout( + final OrderedLayout l = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); // Test component - TextField tf = new TextField("Caption"); + final TextField tf = new TextField("Caption"); l.addComponent(tf); // Properties propertyPanel = new PropertyPanel(tf); - Form f = propertyPanel.createBeanPropertySet(new String[] { "columns", - "rows", "wordwrap", "writeThrough", "readThrough", + final Form f = propertyPanel.createBeanPropertySet(new String[] { + "columns", "rows", "wordwrap", "writeThrough", "readThrough", "nullRepresentation", "nullSettingAllowed", "secret" }); propertyPanel.addProperties("Text field properties", f); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureTree.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureTree.java index cbe3781194..a403b68004 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureTree.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureTree.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.tests.featurebrowser; @@ -51,8 +27,8 @@ public class FeatureTree extends Feature implements Action.Handler { private boolean actionsActive = false; - private Button actionHandlerSwitch = new Button("Activate actions", this, - "toggleActions"); + private final Button actionHandlerSwitch = new Button("Activate actions", + this, "toggleActions"); public FeatureTree() { super(); @@ -71,22 +47,22 @@ public class FeatureTree extends Feature implements Action.Handler { } public void expandAll() { - for (Iterator i = t.rootItemIds().iterator(); i.hasNext();) { + for (final Iterator i = t.rootItemIds().iterator(); i.hasNext();) { t.expandItemsRecursively(i.next()); } } public void collapseAll() { - for (Iterator i = t.rootItemIds().iterator(); i.hasNext();) { + for (final Iterator i = t.rootItemIds().iterator(); i.hasNext();) { t.collapseItemsRecursively(i.next()); } } protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - 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))] + " " @@ -97,7 +73,7 @@ public class FeatureTree extends Feature implements Action.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); } @@ -121,9 +97,9 @@ public class FeatureTree extends Feature implements Action.Handler { // Properties propertyPanel = new PropertyPanel(t); - Form ap = propertyPanel + final Form ap = propertyPanel .createBeanPropertySet(new String[] { "selectable" }); - Select themes = (Select) propertyPanel.getField("style"); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("menu").getItemProperty( themes.getItemCaptionPropertyId()).setValue("menu"); propertyPanel.addProperties("Tree Properties", ap); @@ -174,13 +150,13 @@ public class FeatureTree extends Feature implements Action.Handler { return "Tree"; } - private Action ACTION1 = new Action("Action 1"); + private final Action ACTION1 = new Action("Action 1"); - private Action ACTION2 = new Action("Action 2"); + private final Action ACTION2 = new Action("Action 2"); - private Action ACTION3 = new Action("Action 3"); + private final Action ACTION3 = new Action("Action 3"); - private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; + private final Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; public Action[] getActions(Object target, Object sender) { return actions; diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureUpload.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureUpload.java index 4c5a418c94..2b400f138e 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureUpload.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureUpload.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.tests.featurebrowser; @@ -53,9 +29,9 @@ public class FeatureUpload extends Feature implements Upload.FinishedListener { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Upload up = new Upload("Upload", buffer); + final Upload up = new Upload("Upload", buffer); up.setImmediate(true); up.addListener(this); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureUtil.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureUtil.java index cf51e7756b..6ff7e9d447 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureUtil.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureUtil.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.featurebrowser; import java.text.SimpleDateFormat; @@ -20,7 +24,7 @@ public class FeatureUtil { if (statistics) { try { return format.format(new Date()); - } catch (Exception e) { + } catch (final Exception e) { // ignored, should never happen } } diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureValidators.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureValidators.java index 49b59f5289..0f33ec5ad9 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureValidators.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureValidators.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.tests.featurebrowser; @@ -56,13 +32,13 @@ public class FeatureValidators extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Validators"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -70,9 +46,9 @@ public class FeatureValidators extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeatureWindow.java b/src/com/itmill/toolkit/tests/featurebrowser/FeatureWindow.java index 9784e6e1ce..7e357e0e00 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeatureWindow.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeatureWindow.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.tests.featurebrowser; @@ -38,9 +14,10 @@ import com.itmill.toolkit.ui.Window.CloseEvent; public class FeatureWindow extends Feature implements Window.CloseListener { - private Button addButton = new Button("Add window", this, "addWin"); + private final Button addButton = new Button("Add window", this, "addWin"); - private Button removeButton = new Button("Remove window", this, "delWin"); + private final Button removeButton = new Button("Remove window", this, + "delWin"); private Window demoWindow; @@ -52,9 +29,9 @@ public class FeatureWindow extends Feature implements Window.CloseListener { protected Component getDemoComponent() { - OrderedLayout layoutRoot = new OrderedLayout(); - OrderedLayout layoutUpper = new OrderedLayout(); - OrderedLayout layoutLower = new OrderedLayout(); + final OrderedLayout layoutRoot = new OrderedLayout(); + final OrderedLayout layoutUpper = new OrderedLayout(); + final OrderedLayout layoutLower = new OrderedLayout(); demoWindow = new Window("Feature Test Window"); demoWindow.addListener(this); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/FeaturesApplication.java b/src/com/itmill/toolkit/tests/featurebrowser/FeaturesApplication.java index c27a2c1d60..912cd2b92e 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/FeaturesApplication.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/FeaturesApplication.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.tests.featurebrowser; @@ -37,7 +13,7 @@ public class FeaturesApplication extends com.itmill.toolkit.Application { FeatureUtil.setStatistics(true); } setUser(new Long(System.currentTimeMillis()).toString()); - Window main = new Window("IT Mill Toolkit Features Tour"); + final Window main = new Window("IT Mill Toolkit Features Tour"); setMainWindow(main); main.setLayout(new FeatureBrowser()); @@ -48,7 +24,7 @@ public class FeaturesApplication extends com.itmill.toolkit.Application { */ public void terminalError( com.itmill.toolkit.terminal.Terminal.ErrorEvent event) { - Throwable e = event.getThrowable(); + final Throwable e = event.getThrowable(); FeatureUtil.debug(getUser().toString(), "terminalError: " + e.toString()); e.printStackTrace(); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/IntroBasic.java b/src/com/itmill/toolkit/tests/featurebrowser/IntroBasic.java index 4d29a768df..f2a42f63e3 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/IntroBasic.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/IntroBasic.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.tests.featurebrowser; @@ -48,13 +24,13 @@ public class IntroBasic extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Basic UI components"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -62,9 +38,9 @@ public class IntroBasic extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/IntroComponents.java b/src/com/itmill/toolkit/tests/featurebrowser/IntroComponents.java index dd9d9773f3..6a316cabc7 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/IntroComponents.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/IntroComponents.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.tests.featurebrowser; @@ -49,13 +25,13 @@ public class IntroComponents extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("UI component diagram"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -66,9 +42,9 @@ public class IntroComponents extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/IntroDataHandling.java b/src/com/itmill/toolkit/tests/featurebrowser/IntroDataHandling.java index 2f0321884f..18b7d90731 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/IntroDataHandling.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/IntroDataHandling.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.tests.featurebrowser; @@ -48,13 +24,13 @@ public class IntroDataHandling extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Data Handling"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -62,9 +38,9 @@ public class IntroDataHandling extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/IntroDataModel.java b/src/com/itmill/toolkit/tests/featurebrowser/IntroDataModel.java index 089ae73f76..346e23dab2 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/IntroDataModel.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/IntroDataModel.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.tests.featurebrowser; @@ -49,13 +25,13 @@ public class IntroDataModel extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Data Model"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -63,9 +39,9 @@ public class IntroDataModel extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/IntroItemContainers.java b/src/com/itmill/toolkit/tests/featurebrowser/IntroItemContainers.java index 3e584120b7..368d743d9b 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/IntroItemContainers.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/IntroItemContainers.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.tests.featurebrowser; @@ -48,13 +24,13 @@ public class IntroItemContainers extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Item Containers"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -62,9 +38,9 @@ public class IntroItemContainers extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/IntroLayouts.java b/src/com/itmill/toolkit/tests/featurebrowser/IntroLayouts.java index 3c57a3c3e5..2921a3c75a 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/IntroLayouts.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/IntroLayouts.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.tests.featurebrowser; @@ -50,13 +26,13 @@ public class IntroLayouts extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); + final Panel panel = new Panel(); panel.setCaption("Layouts"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); @@ -64,9 +40,9 @@ public class IntroLayouts extends Feature { // Properties propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( diff --git a/src/com/itmill/toolkit/tests/featurebrowser/IntroTerminal.java b/src/com/itmill/toolkit/tests/featurebrowser/IntroTerminal.java index f7cad07245..9e3a256c14 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/IntroTerminal.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/IntroTerminal.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.tests.featurebrowser; @@ -40,9 +16,9 @@ public class IntroTerminal extends Feature { protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); - Label lab = new Label(); + final Label lab = new Label(); lab.setStyle("featurebrowser-none"); l.addComponent(lab); diff --git a/src/com/itmill/toolkit/tests/featurebrowser/IntroWelcome.java b/src/com/itmill/toolkit/tests/featurebrowser/IntroWelcome.java index 5421f9dc57..278ba73af1 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/IntroWelcome.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/IntroWelcome.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.tests.featurebrowser; @@ -48,7 +24,7 @@ import com.itmill.toolkit.ui.Select; public class IntroWelcome extends Feature implements URIHandler, ParameterHandler { - private WebBrowser webBrowser = null; + private final WebBrowser webBrowser = null; Panel panel = new Panel(); @@ -79,7 +55,7 @@ public class IntroWelcome extends Feature implements URIHandler, + " located at the top right corner area."; // TODO Add browser agent string - private String description = WELCOME_TEXT_LOWER + private final String description = WELCOME_TEXT_LOWER + "<br /><br />IT Mill Toolkit version: " + ApplicationServlet.VERSION; @@ -89,21 +65,21 @@ public class IntroWelcome extends Feature implements URIHandler, protected Component getDemoComponent() { - OrderedLayout l = new OrderedLayout(); + final OrderedLayout l = new OrderedLayout(); panel.setCaption("Welcome to the IT Mill Toolkit feature tour!"); l.addComponent(panel); - Label label = new Label(); + final Label label = new Label(); panel.addComponent(label); label.setContentMode(Label.CONTENT_XHTML); label.setValue(WELCOME_TEXT_UPPER); propertyPanel = new PropertyPanel(panel); - Form ap = propertyPanel.createBeanPropertySet(new String[] { "width", - "height" }); - Select themes = (Select) propertyPanel.getField("style"); + final Form ap = propertyPanel.createBeanPropertySet(new String[] { + "width", "height" }); + final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("light").getItemProperty( themes.getItemCaptionPropertyId()).setValue("light"); themes.addItem("strong").getItemProperty( @@ -179,8 +155,8 @@ public class IntroWelcome extends Feature implements URIHandler, * @see com.itmill.toolkit.terminal.ParameterHandler#handleParameters(Map) */ public void handleParameters(Map parameters) { - for (Iterator i = parameters.keySet().iterator(); i.hasNext();) { - String name = (String) i.next(); + for (final Iterator i = parameters.keySet().iterator(); i.hasNext();) { + final String name = (String) i.next(); if (name.equals("systemStatus")) { String status = ""; status += "timestamp=" + new Date() + " "; diff --git a/src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.java b/src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.java index 365e34868f..29fb7ab02f 100644 --- a/src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.java +++ b/src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.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.tests.featurebrowser; @@ -65,19 +41,19 @@ public class PropertyPanel extends Panel implements Button.ClickListener, private Select addComponent; - private OrderedLayout formsLayout = new OrderedLayout(); + private final OrderedLayout formsLayout = new OrderedLayout(); - private LinkedList forms = new LinkedList(); + private final LinkedList forms = new LinkedList(); - private Button setButton = new Button("Set", this); + private final Button setButton = new Button("Set", this); - private Button discardButton = new Button("Discard changes", this); + private final Button discardButton = new Button("Discard changes", this); - private Table allProperties = new Table(); + private final Table allProperties = new Table(); - private Object objectToConfigure; + private final Object objectToConfigure; - private BeanItem config; + private final BeanItem config; protected static final int COLUMNS = 3; @@ -100,7 +76,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, config = new BeanItem(objectToConfigure); // Control buttons - OrderedLayout buttons = new OrderedLayout( + final OrderedLayout buttons = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); buttons.setMargin(false, true, true, true); buttons.addComponent(setButton); @@ -141,7 +117,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, public void addProperties(String propertySetCaption, Form properties) { // Create new panel containing the form - Panel p = new Panel(); + final Panel p = new Panel(); p.setCaption(propertySetCaption); p.setStyle("light"); p.addComponent(properties); @@ -166,8 +142,8 @@ public class PropertyPanel extends Panel implements Button.ClickListener, allProperties.removeAllItems(); // Collect demoed properties - HashSet listed = new HashSet(); - for (Iterator i = forms.iterator(); i.hasNext();) { + final HashSet listed = new HashSet(); + for (final Iterator i = forms.iterator(); i.hasNext();) { listed.addAll(((Form) i.next()).getItemPropertyIds()); } @@ -175,10 +151,10 @@ public class PropertyPanel extends Panel implements Button.ClickListener, BeanInfo info; try { info = Introspector.getBeanInfo(objectToConfigure.getClass()); - } catch (IntrospectionException e) { + } catch (final IntrospectionException e) { throw new RuntimeException(e.toString()); } - PropertyDescriptor[] pd = info.getPropertyDescriptors(); + final PropertyDescriptor[] pd = info.getPropertyDescriptors(); // Fill the table for (int i = 0; i < pd.length; i++) { @@ -193,9 +169,9 @@ public class PropertyPanel extends Panel implements Button.ClickListener, private void addBasicComponentProperties() { // Set of properties - Form set = createBeanPropertySet(new String[] { "caption", "icon", - "componentError", "description", "enabled", "visible", "style", - "readOnly", "immediate" }); + final Form set = createBeanPropertySet(new String[] { "caption", + "icon", "componentError", "description", "enabled", "visible", + "style", "readOnly", "immediate" }); // Icon set.replaceWithSelect("icon", new Object[] { null, @@ -206,7 +182,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, Throwable sampleException; try { throw new NullPointerException("sample exception"); - } catch (NullPointerException e) { + } catch (final NullPointerException e) { sampleException = e; } set @@ -228,7 +204,8 @@ public class PropertyPanel extends Panel implements Button.ClickListener, "Sample Formatted error", "Sample System Error" }); // Style - String currentStyle = ((Component) objectToConfigure).getStyleName(); + final String currentStyle = ((Component) objectToConfigure) + .getStyleName(); if (currentStyle == null) { set.replaceWithSelect("style", new Object[] { null }, new Object[] { "Default" }).setNewItemsAllowed(true); @@ -312,8 +289,8 @@ public class PropertyPanel extends Panel implements Button.ClickListener, /** Add properties for selecting */ private void addSelectProperties() { - Form set = createBeanPropertySet(new String[] { "newItemsAllowed", - "lazyLoading", "multiSelect" }); + final Form set = createBeanPropertySet(new String[] { + "newItemsAllowed", "lazyLoading", "multiSelect" }); addProperties("Select Properties", set); set.getField("multiSelect").setDescription( @@ -344,7 +321,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, private void addFieldProperties() { // TODO bug #211 states that setFocus works only for Button and // Textfield UI components - Form set = new Form(new GridLayout(COLUMNS, 1)); + final Form set = new Form(new GridLayout(COLUMNS, 1)); set.addField("focus", new Button("Focus", objectToConfigure, "focus")); set.getField("focus").setDescription( "Focus the cursor to this field. Not all " @@ -357,7 +334,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, * container */ private void addComponentContainerProperties() { - Form set = new Form(new OrderedLayout( + final Form set = new Form(new OrderedLayout( OrderedLayout.ORIENTATION_VERTICAL)); addComponent = new Select(); @@ -385,13 +362,13 @@ public class PropertyPanel extends Panel implements Button.ClickListener, "valueChange " + ((AbstractComponent) event.getProperty()) .getTag() + ", " + event.getProperty()); - } catch (Exception e) { + } catch (final Exception e) { // ignored, should never happen } // Adding components to component container if (event.getProperty() == addComponent) { - String value = (String) addComponent.getValue(); + final String value = (String) addComponent.getValue(); if (value != null) { // TextField component @@ -402,7 +379,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // DateField time style if (value.equals("Time")) { - DateField d = new DateField("Time", new Date()); + final DateField d = new DateField("Time", new Date()); d .setDescription("This is a DateField-component with text-style"); d.setResolution(DateField.RESOLUTION_MIN); @@ -413,7 +390,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // Date field calendar style if (value.equals("Calendar")) { - DateField c = new DateField("Calendar", new Date()); + final DateField c = new DateField("Calendar", new Date()); c .setDescription("DateField-component with calendar-style and day-resolution"); c.setStyle("calendar"); @@ -424,7 +401,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // Select option group style if (value.equals("Option group")) { - Select s = new Select("Options"); + final Select s = new Select("Options"); s.setDescription("Select-component with optiongroup-style"); s.addItem("Linux"); s.addItem("Windows"); @@ -439,10 +416,10 @@ public class PropertyPanel extends Panel implements Button.ClickListener, addComponent.setValue(null); } } else if (event.getProperty() == getField("lazyLoading")) { - boolean newValue = ((Boolean) event.getProperty().getValue()) + final boolean newValue = ((Boolean) event.getProperty().getValue()) .booleanValue(); - Field multiselect = getField("multiSelect"); - Field newitems = getField("newItemsAllowed"); + final Field multiselect = getField("multiSelect"); + final Field newitems = getField("newItemsAllowed"); if (newValue) { newitems.setValue(Boolean.FALSE); newitems.setVisible(false); @@ -463,7 +440,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, "buttonClick " + event.getButton().getTag() + ", " + event.getButton().getCaption() + ", " + event.getButton().getValue()); - } catch (Exception e) { + } catch (final Exception e) { // ignored, should never happen } // Commit all changed on all forms @@ -473,7 +450,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // Discard all changed on all forms if (event.getButton() == discardButton) { - for (Iterator i = forms.iterator(); i.hasNext();) { + for (final Iterator i = forms.iterator(); i.hasNext();) { ((Form) i.next()).discard(); } } @@ -485,14 +462,14 @@ public class PropertyPanel extends Panel implements Button.ClickListener, */ protected Form createBeanPropertySet(String names[]) { - Form set = new Form(new OrderedLayout( + final Form set = new Form(new OrderedLayout( OrderedLayout.ORIENTATION_VERTICAL)); for (int i = 0; i < names.length; i++) { - Property p = config.getItemProperty(names[i]); + final Property p = config.getItemProperty(names[i]); if (p != null) { set.addItemProperty(names[i], p); - Field f = set.getField(names[i]); + final Field f = set.getField(names[i]); if (f instanceof TextField) { if (Integer.class.equals(p.getType())) { ((TextField) f).setColumns(4); @@ -509,9 +486,9 @@ public class PropertyPanel extends Panel implements Button.ClickListener, /** Find a field from all forms */ public Field getField(Object propertyId) { - for (Iterator i = forms.iterator(); i.hasNext();) { - Form f = (Form) i.next(); - Field af = f.getField(propertyId); + for (final Iterator i = forms.iterator(); i.hasNext();) { + final Form f = (Form) i.next(); + final Field af = f.getField(propertyId); if (af != null) { return af; } @@ -524,7 +501,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, } protected void commit() { - for (Iterator i = forms.iterator(); i.hasNext();) { + for (final Iterator i = forms.iterator(); i.hasNext();) { ((Form) i.next()).commit(); } } diff --git a/src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java b/src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java index a91493eb79..c41bbfdc5c 100644 --- a/src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java +++ b/src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.event.Action; @@ -55,7 +59,7 @@ public class DefaultButtonExample extends CustomComponent implements Handler { * buttons. */ public Action[] getActions(Object target, Object sender) { - Action[] actions = new Action[1]; + final Action[] actions = new Action[1]; // Set the action for the requested component if (sender == ok) { diff --git a/src/com/itmill/toolkit/tests/magi/EmbeddedButton.java b/src/com/itmill/toolkit/tests/magi/EmbeddedButton.java index 0f32304331..8400ba43b6 100644 --- a/src/com/itmill/toolkit/tests/magi/EmbeddedButton.java +++ b/src/com/itmill/toolkit/tests/magi/EmbeddedButton.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.terminal.Resource; diff --git a/src/com/itmill/toolkit/tests/magi/MagiTestApplication.java b/src/com/itmill/toolkit/tests/magi/MagiTestApplication.java index 67ddb832ad..fafd7ce63c 100644 --- a/src/com/itmill/toolkit/tests/magi/MagiTestApplication.java +++ b/src/com/itmill/toolkit/tests/magi/MagiTestApplication.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import java.net.URL; @@ -63,7 +67,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { String example; String param = null; - int slashPos = relativeUri.indexOf("/"); + final int slashPos = relativeUri.indexOf("/"); if (slashPos > 0) { example = relativeUri.substring(0, slashPos); param = relativeUri.substring(slashPos + 1); @@ -73,22 +77,23 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { /* Remove existing components and windows. */ main.removeAllComponents(); - Set childwindows = main.getChildWindows(); - for (Iterator cwi = childwindows.iterator(); cwi.hasNext();) { - Window child = (Window) cwi.next(); + final Set childwindows = main.getChildWindows(); + for (final Iterator cwi = childwindows.iterator(); cwi.hasNext();) { + final Window child = (Window) cwi.next(); main.removeWindow(child); } main.setLayout(new OrderedLayout()); if (example.equals("index")) { - Object examples[] = { "defaultbutton", "label", "labelcontent", - "tree", "embedded", "textfield", "textfieldvalidation", - "datefield", "button", "select/select", "select/native", - "select/optiongroup", "select/twincol", "filterselect", - "validator", "table", "upload", "link", "gridlayout", - "orderedlayout", "formlayout", "panel", "expandlayout", - "tabsheet", "alignment", "alignment/grid", "window", - "window/opener", "window/multiple", "classresource" }; + final Object examples[] = { "defaultbutton", "label", + "labelcontent", "tree", "embedded", "textfield", + "textfieldvalidation", "datefield", "button", + "select/select", "select/native", "select/optiongroup", + "select/twincol", "filterselect", "validator", "table", + "upload", "link", "gridlayout", "orderedlayout", + "formlayout", "panel", "expandlayout", "tabsheet", + "alignment", "alignment/grid", "window", "window/opener", + "window/multiple", "classresource" }; for (int i = 0; i < examples.length; i++) { main.addComponent(new Label("<a href='/tk/testbench2/" + examples[i] + "'>" + examples[i] + "</a>", @@ -173,7 +178,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_Label(Window main, String param) { /* Some container for the Label. */ - Panel panel = new Panel("Panel Containing a Label"); + final Panel panel = new Panel("Panel Containing a Label"); main.addComponent(panel); panel.addComponent(new Label( @@ -183,7 +188,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } void example_LabelContent(Window main, String param) { - GridLayout labelgrid = new GridLayout(2, 1); + final GridLayout labelgrid = new GridLayout(2, 1); labelgrid.addStyleName("labelgrid"); labelgrid.addComponent(new Label("CONTENT_DEFAULT")); labelgrid.addComponent(new Label( @@ -212,7 +217,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { Label.CONTENT_XML)); main.addComponent(labelgrid); - ClassResource labelimage = new ClassResource("smiley.jpg", this); + final ClassResource labelimage = new ClassResource("smiley.jpg", this); main.addComponent(new Label("Here we have an image <img src=\"" + getRelativeLocation(labelimage) + "\"/> within some text.", Label.CONTENT_XHTML)); @@ -233,11 +238,11 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { new Object[] { "Neptune", "Triton", "Proteus", "Nereid", "Larissa" } }; - Tree tree = new Tree("The Planets and Major Moons"); + final Tree tree = new Tree("The Planets and Major Moons"); /* Add planets as root items in the tree. */ for (int i = 0; i < planets.length; i++) { - String planet = (String) (planets[i][0]); + final String planet = (String) (planets[i][0]); tree.addItem(planet); if (planets[i].length == 1) { @@ -246,7 +251,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } else { /* Add children (moons) under the planets. */ for (int j = 1; j < planets[i].length; j++) { - String moon = (String) planets[i][j]; + final String moon = (String) planets[i][j]; /* Add the item as a regular item. */ tree.addItem(moon); @@ -267,22 +272,22 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } void example_Select(Window main, String param) { - OrderedLayout layout = new OrderedLayout( + final OrderedLayout layout = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); layout.addStyleName("aligntop"); if (param.equals("twincol")) { - SelectExample select1 = new SelectExample(this, param, + final SelectExample select1 = new SelectExample(this, param, "Select some items", true); layout.addComponent(select1); } else if (param.equals("filter")) { - SelectExample select1 = new SelectExample(this, param, + final SelectExample select1 = new SelectExample(this, param, "Enter containing substring", false); layout.addComponent(select1); } else { - SelectExample select1 = new SelectExample(this, param, + final SelectExample select1 = new SelectExample(this, param, "Single Selection Mode", false); - SelectExample select2 = new SelectExample(this, param, + final SelectExample select2 = new SelectExample(this, param, "Multiple Selection Mode", true); layout.addComponent(select1); layout.addComponent(select2); @@ -291,7 +296,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } void example_FilterSelect(Window main, String param) { - Select select = new Select("Enter containing substring"); + final Select select = new Select("Enter containing substring"); main.addComponent(select); select @@ -310,12 +315,12 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_TextField(Window main, String param) { /* Add a single-line text field. */ - TextField subject = new TextField("Subject"); + final TextField subject = new TextField("Subject"); subject.setColumns(40); main.addComponent(subject); /* Add a multi-line text field. */ - TextField message = new TextField("Message"); + final TextField message = new TextField("Message"); message.setRows(7); message.setColumns(40); main.addComponent(message); @@ -323,7 +328,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_TextFieldValidation(Window main, String param) { // Create a text field with a label - TextField username = new TextField("Username"); + final TextField username = new TextField("Username"); main.addComponent(username); // Set visible length to 16 characters @@ -342,7 +347,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { username.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { // Get the source of the event - TextField username = (TextField) (event.getProperty()); + final TextField username = (TextField) (event.getProperty()); try { // Validate the field value. @@ -350,7 +355,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { // The value was ok, reset a possible error username.setComponentError(null); - } catch (Validator.InvalidValueException e) { + } catch (final Validator.InvalidValueException e) { // The value was not ok. Set the error. username.setComponentError(new UserError(e.getMessage())); } @@ -360,7 +365,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_DateField(Window main, String param) { /* Create a DateField with the calendar style. */ - DateField date = new DateField("Here is a calendar field"); + final DateField date = new DateField("Here is a calendar field"); date.setStyle("calendar"); /* Set the date and time to present. */ @@ -386,14 +391,15 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_Link(Window main, String param) { /* Create a link that opens the popup window. */ - Link alink = new Link(); + final Link alink = new Link(); /* Set the resource to be opened in the window. */ alink.setResource(new ExternalResource("http://www.itmill.com/")); main.addComponent(alink); - ClassResource mydocument = new ClassResource("mydocument.pdf", this); + final ClassResource mydocument = new ClassResource("mydocument.pdf", + this); main.addComponent(new Link("The document (pdf)", mydocument)); main.addComponent(new Link("link to a resource", new ExternalResource( "http://www.itmill.com/"))); @@ -416,7 +422,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { // Button checkbox = new Button ("This is a checkbox"); // main.addComponent(checkbox); - Button button = new Button("My Button"); + final Button button = new Button("My Button"); main.addComponent(button); } @@ -452,12 +458,12 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } void example_Panel(Window main, String param) { - Panel panel = new Panel("Contact Information"); - OrderedLayout form = new FormLayout(); + final Panel panel = new Panel("Contact Information"); + final OrderedLayout form = new FormLayout(); form.addComponent(new TextField("Name")); form.addComponent(new TextField("Email")); - ClassResource icon = new ClassResource("smiley.jpg", main + final ClassResource icon = new ClassResource("smiley.jpg", main .getApplication()); form.addComponent(new Embedded("Image", icon)); panel.setIcon(icon); @@ -467,7 +473,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_GridLayout(Window main, String param) { /* Create a 4 by 4 grid layout. */ - GridLayout grid = new GridLayout(4, 4); + final GridLayout grid = new GridLayout(4, 4); grid.addStyleName("example-gridlayout"); /* Fill out the first row using the cursor. */ @@ -484,7 +490,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { /* Add some components of various shapes. */ grid.addComponent(new Button("3x1 button"), 1, 1, 3, 1); grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3); - DateField date = new DateField("A 2x2 date field"); + final DateField date = new DateField("A 2x2 date field"); date.setStyle("calendar"); grid.addComponent(date, 2, 2, 3, 3); @@ -494,7 +500,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_Alignment(Window main, String param) { if (param.equals("grid")) { /* Create a 3 by 3 grid layout. */ - GridLayout layout = new GridLayout(3, 3); + final GridLayout layout = new GridLayout(3, 3); // OrderedLayout layout = new // OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); main.setLayout(layout); @@ -530,7 +536,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { * layout.addComponent(celllayout); } */ } else { - Panel panel = new Panel("A Panel with a Layout"); + final Panel panel = new Panel("A Panel with a Layout"); main.addComponent(panel); // panel.addComponent(new ) @@ -538,7 +544,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } void example_OrderedLayout(Window main, String param) { - OrderedLayout layout = new OrderedLayout( + final OrderedLayout layout = new OrderedLayout( OrderedLayout.ORIENTATION_VERTICAL); layout.addComponent(new TextField("Name")); layout.addComponent(new TextField("Street address")); @@ -547,7 +553,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } void example_FormLayout(Window main, String param) { - FormLayout layout = new FormLayout(); + final FormLayout layout = new FormLayout(); layout.addComponent(new TextField("Name")); layout.addComponent(new TextField("Street address")); layout.addComponent(new TextField("Postal code")); @@ -556,18 +562,18 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_ExpandLayout(Window main, String param) { for (int w = 0; w < 2; w++) { - ExpandLayout layout = new ExpandLayout( + final ExpandLayout layout = new ExpandLayout( OrderedLayout.ORIENTATION_VERTICAL); /* Set the expanding layout as the root layout of a child window. */ - Window window = new Window("A Child Window", layout); + final Window window = new Window("A Child Window", layout); main.addWindow(window); /* Add some component above the expanding one. */ layout.addComponent(new Label("Here be some component.")); /* Create the expanding component. */ - Table table = new Table("My Ever-Expanding Table"); + final Table table = new Table("My Ever-Expanding Table"); /* * FIXME Java 5 -> 1.4 for (int i=0; i<5; i++) * table.addContainerProperty("col "+(i+1), Integer.class, 0); for @@ -586,7 +592,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { table.setWidthUnits(Table.UNITS_PERCENTAGE); /* Add some component below the expanding one. */ - Button button2 = new Button("Ok"); + final Button button2 = new Button("Ok"); layout.addComponent(button2); layout.setComponentAlignment(button2, OrderedLayout.ALIGNMENT_RIGHT, 0); @@ -595,7 +601,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { void example_TabSheet(Window main, String param) { if (param.equals("icon")) { - TabSheet tabsheet = new TabSheet(); + final TabSheet tabsheet = new TabSheet(); tabsheet.addTab(new Label("Contents of the first tab"), "First Tab", new ClassResource("images/Mercury_small.png", @@ -617,11 +623,12 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } void example_Embedded(Window main, String param) { - Embedded image = new Embedded("", new ClassResource("smiley.jpg", this)); + final Embedded image = new Embedded("", new ClassResource("smiley.jpg", + this)); image.addStyleName("omaimage"); main.addComponent(image); - EmbeddedButton button = new EmbeddedButton(new ClassResource( + final EmbeddedButton button = new EmbeddedButton(new ClassResource( "smiley.jpg", this)); main.addComponent(button); } @@ -632,7 +639,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { main.addComponent(new WindowOpener("Window Opener", main)); } else if (param.equals("multiple")) { /* Create a new window. */ - Window mywindow = new Window("Second Window"); + final Window mywindow = new Window("Second Window"); mywindow.setName("mywindow"); mywindow.addComponent(new Label("This is a second window.")); @@ -651,12 +658,12 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } /* Create a new window. */ - Window mywindow = new Window("My Window"); + final Window mywindow = new Window("My Window"); mywindow.setName("mywindow"); /* Add some components in the window. */ mywindow.addComponent(new Label("A text label in the window.")); - Button okbutton = new Button("OK"); + final Button okbutton = new Button("OK"); mywindow.addComponent(okbutton); /* Set window size. */ @@ -673,7 +680,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application { } void example_ClassResource(Window main, String param) { - DateField df = new DateField(); + final DateField df = new DateField(); main.addComponent(df); df.setIcon(new ClassResource("smiley.jpg", main.getApplication())); main.addComponent(new Embedded("This is Embedded", new ClassResource( diff --git a/src/com/itmill/toolkit/tests/magi/MyUploader.java b/src/com/itmill/toolkit/tests/magi/MyUploader.java index ef8efa8d5f..17d2aaf078 100644 --- a/src/com/itmill/toolkit/tests/magi/MyUploader.java +++ b/src/com/itmill/toolkit/tests/magi/MyUploader.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import java.io.File; @@ -27,11 +31,11 @@ public class MyUploader extends CustomComponent implements try { /* Open the file for writing. */ fos = new FileOutputStream(file); - } catch (java.io.FileNotFoundException e) { + } catch (final java.io.FileNotFoundException e) { return null; /* - * Error while opening the file. Not reported - * here. - */ + * Error while opening the file. Not reported + * here. + */ } return fos; /* Return the output stream. */ @@ -50,7 +54,7 @@ public class MyUploader extends CustomComponent implements uploadReceiver = new MyUploadReceiver(); /* Create the Upload component. */ - Upload upload = new Upload("Upload", uploadReceiver); + final Upload upload = new Upload("Upload", uploadReceiver); /* Listen for Upload.FinishedEvent events. */ upload.addListener(this); @@ -72,8 +76,8 @@ public class MyUploader extends CustomComponent implements + " of type '" + event.getMIMEType() + "' uploaded.")); /* Display the uploaded file in the image panel. */ - FileResource imageResource = new FileResource(uploadReceiver.getFile(), - getApplication()); + final FileResource imageResource = new FileResource(uploadReceiver + .getFile(), getApplication()); imagePanel.removeAllComponents(); imagePanel.addComponent(new Embedded("", imageResource)); } diff --git a/src/com/itmill/toolkit/tests/magi/SSNField.java b/src/com/itmill/toolkit/tests/magi/SSNField.java index 9333abf369..0d52da04f8 100644 --- a/src/com/itmill/toolkit/tests/magi/SSNField.java +++ b/src/com/itmill/toolkit/tests/magi/SSNField.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import java.text.MessageFormat; @@ -25,7 +29,7 @@ public class SSNField extends CustomComponent implements public boolean isValid(Object value) { try { validate(value); - } catch (InvalidValueException e) { + } catch (final InvalidValueException e) { return false; } return true; @@ -33,13 +37,13 @@ public class SSNField extends CustomComponent implements /** Validate the given SSN. */ public void validate(Object value) throws InvalidValueException { - String ssn = (String) value; + final String ssn = (String) value; if (ssn.length() != 11) { throw new InvalidValueException("Invalid SSN length"); } - String numbers = ssn.substring(0, 6) + ssn.substring(7, 10); - int checksum = new Integer(numbers).intValue() % 31; + final String numbers = ssn.substring(0, 6) + ssn.substring(7, 10); + final int checksum = new Integer(numbers).intValue() % 31; if (!ssn.substring(10).equals( "0123456789ABCDEFHJKLMNPRSTUVWXY".substring(checksum, checksum + 1))) { @@ -58,7 +62,7 @@ public class SSNField extends CustomComponent implements myfield.setFormat(new MessageFormat("{0,number,##}")); /* Create and set the validator object for the field. */ - SSNValidator ssnvalidator = new SSNValidator(); + final SSNValidator ssnvalidator = new SSNValidator(); myfield.addValidator(ssnvalidator); /* @@ -85,7 +89,7 @@ public class SSNField extends CustomComponent implements /* The value was correct. */ myerror.setValue("Ok"); myfield.setStyle(""); - } catch (Validator.InvalidValueException e) { + } catch (final Validator.InvalidValueException e) { /* Report the error message to the user. */ myerror.setValue(e.getMessage()); diff --git a/src/com/itmill/toolkit/tests/magi/SelectExample.java b/src/com/itmill/toolkit/tests/magi/SelectExample.java index 112f1c9c77..9571b3a066 100644 --- a/src/com/itmill/toolkit/tests/magi/SelectExample.java +++ b/src/com/itmill/toolkit/tests/magi/SelectExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.Application; diff --git a/src/com/itmill/toolkit/tests/magi/TabSheetExample.java b/src/com/itmill/toolkit/tests/magi/TabSheetExample.java index 200b123db4..a19ac56d15 100644 --- a/src/com/itmill/toolkit/tests/magi/TabSheetExample.java +++ b/src/com/itmill/toolkit/tests/magi/TabSheetExample.java @@ -1,53 +1,64 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; -import com.itmill.toolkit.ui.*; + +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.CustomComponent; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.TabSheet; import com.itmill.toolkit.ui.Button.ClickEvent; import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent; -public class TabSheetExample extends CustomComponent implements Button.ClickListener, TabSheet.SelectedTabChangeListener { - TabSheet tabsheet = new TabSheet(); - Button tab1 = new Button("Push this button"); - Label tab2 = new Label("Contents of Second Tab"); - Label tab3 = new Label("Contents of Third Tab"); - - TabSheetExample () { - setCompositionRoot (tabsheet); - - /* Listen for changes in tab selection. */ - tabsheet.addListener(this); - - /* First tab contains a button, for which we listen button click events. */ - tab1.addListener(this); - tabsheet.addTab(tab1, "First Tab", null); - - /* A tab that is initially invisible. */ - tab2.setVisible(false); - tabsheet.addTab(tab2, "Second Tab", null); - - /* A tab that is initially disabled. */ - tab3.setEnabled(false); - tabsheet.addTab(tab3, "Third tab", null); - } - - public void buttonClick(ClickEvent event) { - /* Enable the invisible and disabled tabs. */ - tab2.setVisible(true); - tab3.setEnabled(true); - - /* Change selection automatically to second tab. */ - tabsheet.setSelectedTab(tab2); - } - - public void selectedTabChange(SelectedTabChangeEvent event) { - /* Cast to a TabSheet. This isn't really necessary in this example, - * as we have only one TabSheet component, but would be useful if - * there were multiple TabSheets. */ - TabSheet source = (TabSheet) event.getSource(); - if (source == tabsheet) { - /* If the first tab was selected. */ - if (source.getSelectedTab() == tab1) { - tab2.setVisible(false); - tab3.setEnabled(false); - } - } - } +public class TabSheetExample extends CustomComponent implements + Button.ClickListener, TabSheet.SelectedTabChangeListener { + TabSheet tabsheet = new TabSheet(); + Button tab1 = new Button("Push this button"); + Label tab2 = new Label("Contents of Second Tab"); + Label tab3 = new Label("Contents of Third Tab"); + + TabSheetExample() { + setCompositionRoot(tabsheet); + + /* Listen for changes in tab selection. */ + tabsheet.addListener(this); + + /* First tab contains a button, for which we listen button click events. */ + tab1.addListener(this); + tabsheet.addTab(tab1, "First Tab", null); + + /* A tab that is initially invisible. */ + tab2.setVisible(false); + tabsheet.addTab(tab2, "Second Tab", null); + + /* A tab that is initially disabled. */ + tab3.setEnabled(false); + tabsheet.addTab(tab3, "Third tab", null); + } + + public void buttonClick(ClickEvent event) { + /* Enable the invisible and disabled tabs. */ + tab2.setVisible(true); + tab3.setEnabled(true); + + /* Change selection automatically to second tab. */ + tabsheet.setSelectedTab(tab2); + } + + public void selectedTabChange(SelectedTabChangeEvent event) { + /* + * Cast to a TabSheet. This isn't really necessary in this example, as + * we have only one TabSheet component, but would be useful if there + * were multiple TabSheets. + */ + final TabSheet source = (TabSheet) event.getSource(); + if (source == tabsheet) { + /* If the first tab was selected. */ + if (source.getSelectedTab() == tab1) { + tab2.setVisible(false); + tab3.setEnabled(false); + } + } + } } diff --git a/src/com/itmill/toolkit/tests/magi/TableExample.java b/src/com/itmill/toolkit/tests/magi/TableExample.java index 989fc863cc..ab896f4446 100644 --- a/src/com/itmill/toolkit/tests/magi/TableExample.java +++ b/src/com/itmill/toolkit/tests/magi/TableExample.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.ui.CustomComponent; diff --git a/src/com/itmill/toolkit/tests/magi/TheButton.java b/src/com/itmill/toolkit/tests/magi/TheButton.java index 4f41e2ddde..877b35cf03 100644 --- a/src/com/itmill/toolkit/tests/magi/TheButton.java +++ b/src/com/itmill/toolkit/tests/magi/TheButton.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.ui.Button; diff --git a/src/com/itmill/toolkit/tests/magi/TheButtons.java b/src/com/itmill/toolkit/tests/magi/TheButtons.java index 64962b2260..627e472c63 100644 --- a/src/com/itmill/toolkit/tests/magi/TheButtons.java +++ b/src/com/itmill/toolkit/tests/magi/TheButtons.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.ui.AbstractComponentContainer; diff --git a/src/com/itmill/toolkit/tests/magi/TheButtons2.java b/src/com/itmill/toolkit/tests/magi/TheButtons2.java index b4604df873..316907f819 100644 --- a/src/com/itmill/toolkit/tests/magi/TheButtons2.java +++ b/src/com/itmill/toolkit/tests/magi/TheButtons2.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.ui.AbstractComponentContainer; diff --git a/src/com/itmill/toolkit/tests/magi/TheButtons3.java b/src/com/itmill/toolkit/tests/magi/TheButtons3.java index a5280efb7f..a3256711e8 100644 --- a/src/com/itmill/toolkit/tests/magi/TheButtons3.java +++ b/src/com/itmill/toolkit/tests/magi/TheButtons3.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.ui.AbstractComponentContainer; diff --git a/src/com/itmill/toolkit/tests/magi/WindowOpener.java b/src/com/itmill/toolkit/tests/magi/WindowOpener.java index c38dbfc9a6..ca33aa49ab 100644 --- a/src/com/itmill/toolkit/tests/magi/WindowOpener.java +++ b/src/com/itmill/toolkit/tests/magi/WindowOpener.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.magi; import com.itmill.toolkit.ui.Button; @@ -20,7 +24,7 @@ public class WindowOpener extends CustomComponent implements mainwindow = main; /* The component consists of a button that opens the window. */ - OrderedLayout layout = new OrderedLayout(); + final OrderedLayout layout = new OrderedLayout(); layout.addComponent(openbutton = new Button("Open Window", this, "openButtonClick")); layout.addComponent(explanation = new Label("Explanation")); diff --git a/src/com/itmill/toolkit/tests/testbench/TestBench.java b/src/com/itmill/toolkit/tests/testbench/TestBench.java index 35373cfabb..486a5270b7 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestBench.java +++ b/src/com/itmill/toolkit/tests/testbench/TestBench.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; import java.io.File; @@ -56,9 +60,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; @@ -68,32 +73,32 @@ 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()); } @@ -118,14 +123,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 custom component: " + e1.toString()); @@ -138,10 +143,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 { @@ -160,38 +165,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.ui.CustomComponent.class))) { diff --git a/src/com/itmill/toolkit/tests/testbench/TestForAlignments.java b/src/com/itmill/toolkit/tests/testbench/TestForAlignments.java index 858ddaa29b..3cdde28e70 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForAlignments.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForAlignments.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; 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/testbench/TestForBasicApplicationLayout.java b/src/com/itmill/toolkit/tests/testbench/TestForBasicApplicationLayout.java index 822c408be1..171a262dcc 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForBasicApplicationLayout.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForBasicApplicationLayout.java @@ -1,3 +1,7 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import java.sql.SQLException;
@@ -21,9 +25,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;
// Database provided with sample data
private SampleDatabase sampleDatabase;
@@ -47,26 +51,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);
@@ -77,14 +82,14 @@ public class TestForBasicApplicationLayout extends CustomComponent { sp2.setFirstComponent(report);
- Table table = new Table();
+ final Table table = new Table();
// populate Toolkit table component with test SQL table rows
try {
sampleDatabase = new SampleDatabase();
- 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/tests/testbench/TestForContainerFilterable.java b/src/com/itmill/toolkit/tests/testbench/TestForContainerFilterable.java index 93320ee0d8..73b93dc20c 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForContainerFilterable.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForContainerFilterable.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; import com.itmill.toolkit.data.util.IndexedContainer; @@ -30,13 +34,13 @@ public class TestForContainerFilterable extends CustomComponent { ic.addContainerProperty("first", String.class, ""); ic.addContainerProperty("second", String.class, ""); for (int i = 0; i < 1000; i++) { - Object id = ic.addItem(); + final Object id = ic.addItem(); ic.getContainerProperty(id, "first").setValue(randomWord()); ic.getContainerProperty(id, "second").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); @@ -62,12 +66,12 @@ public class TestForContainerFilterable extends CustomComponent { public void buttonClick(ClickEvent event) { ic.removeAllContainerFilters(); if (firstFilter.toString().length() > 0) { - ic.addContainerFilter("first", firstFilter.toString(), false, - false); + ic.addContainerFilter("first", firstFilter.toString(), + false, false); } if (secondFilter.toString().length() > 0) { - ic.addContainerFilter("second", secondFilter.toString(), true, - true); + ic.addContainerFilter("second", secondFilter.toString(), + true, true); } count.setValue("Rows in table: " + ic.size()); } @@ -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/testbench/TestForMultipleStyleNames.java b/src/com/itmill/toolkit/tests/testbench/TestForMultipleStyleNames.java index a4649bbb18..0bfcab513a 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForMultipleStyleNames.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForMultipleStyleNames.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; 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/testbench/TestForPreconfiguredComponents.java b/src/com/itmill/toolkit/tests/testbench/TestForPreconfiguredComponents.java index 99ca0e3089..7ab15d7360 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForPreconfiguredComponents.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForPreconfiguredComponents.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; 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/testbench/TestForRichTextEditor.java b/src/com/itmill/toolkit/tests/testbench/TestForRichTextEditor.java index ebefb888c9..d7c1ca0c93 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForRichTextEditor.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForRichTextEditor.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; 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/testbench/TestForTrees.java b/src/com/itmill/toolkit/tests/testbench/TestForTrees.java index cf89b2c27b..71884144db 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForTrees.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForTrees.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; 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/testbench/TestForUpload.java b/src/com/itmill/toolkit/tests/testbench/TestForUpload.java index 2e6c5d4e29..0a873631f3 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForUpload.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForUpload.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; 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/testbench/TestForWindowOpen.java b/src/com/itmill/toolkit/tests/testbench/TestForWindowOpen.java index b8f94e13d7..3e9b31a1c9 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForWindowOpen.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForWindowOpen.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; 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/testbench/TestForWindowing.java b/src/com/itmill/toolkit/tests/testbench/TestForWindowing.java index eec366b578..2ed29d7800 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestForWindowing.java +++ b/src/com/itmill/toolkit/tests/testbench/TestForWindowing.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; 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/testbench/TestSetVisibleAndCaching.java b/src/com/itmill/toolkit/tests/testbench/TestSetVisibleAndCaching.java index 2c6da7a26a..0a02a86f39 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestSetVisibleAndCaching.java +++ b/src/com/itmill/toolkit/tests/testbench/TestSetVisibleAndCaching.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; import com.itmill.toolkit.ui.Button; @@ -18,7 +22,7 @@ public class TestSetVisibleAndCaching extends com.itmill.toolkit.Application { int selectedPanel = 0; public void init() { - Window mainWindow = new Window("TestSetVisibleAndCaching"); + final Window mainWindow = new Window("TestSetVisibleAndCaching"); setMainWindow(mainWindow); panelA.addComponent(new Label( diff --git a/src/com/itmill/toolkit/tests/testbench/TestSplitPanel.java b/src/com/itmill/toolkit/tests/testbench/TestSplitPanel.java index a4234cdcf5..4fbee14c60 100644 --- a/src/com/itmill/toolkit/tests/testbench/TestSplitPanel.java +++ b/src/com/itmill/toolkit/tests/testbench/TestSplitPanel.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.tests.testbench; import com.itmill.toolkit.ui.Label; @@ -9,7 +13,7 @@ public class TestSplitPanel extends com.itmill.toolkit.Application { SplitPanel verticalSplit = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); public void init() { - Window mainWindow = new Window("Feature Browser"); + final Window mainWindow = new Window("Feature Browser"); setMainWindow(mainWindow); verticalSplit.setFirstComponent(new Label("vertical first")); diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 08d447640f..d62939add7 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.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.ui; @@ -188,7 +164,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource public String getStyleName() { String s = ""; if (styles != null) { - for (Iterator it = styles.iterator(); it.hasNext();) { + for (final Iterator it = styles.iterator(); it.hasNext();) { s += (String) it.next(); if (it.hasNext()) { s += " "; @@ -266,7 +242,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource if (parent != null) { return parent.getLocale(); } - Application app = getApplication(); + final Application app = getApplication(); if (app != null) { return app.getLocale(); } @@ -614,14 +590,14 @@ public abstract class AbstractComponent implements Component, MethodEventSource // Only paint content of visible components. if (isVisible()) { - String desc = getDescription(); + final String desc = getDescription(); if (desc != null && description.length() > 0) { target.addAttribute("description", getDescription()); } paintContent(target); - ErrorMessage error = getErrorMessage(); + final ErrorMessage error = getErrorMessage(); if (error != null) { error.paint(target); } @@ -684,8 +660,8 @@ public abstract class AbstractComponent implements Component, MethodEventSource // Notify the listeners if (repaintRequestListeners != null && !repaintRequestListeners.isEmpty()) { - Object[] listeners = repaintRequestListeners.toArray(); - RepaintRequestEvent event = new RepaintRequestEvent(this); + final Object[] listeners = repaintRequestListeners.toArray(); + final RepaintRequestEvent event = new RepaintRequestEvent(this); for (int i = 0; i < listeners.length; i++) { if (alreadyNotified == null) { alreadyNotified = new LinkedList(); @@ -700,7 +676,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource } // Notify the parent - Component parent = getParent(); + final Component parent = getParent(); if (parent != null) { parent.childRequestedRepaint(alreadyNotified); } @@ -758,7 +734,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource COMPONENT_EVENT_METHOD = Component.Listener.class .getDeclaredMethod("componentEvent", new Class[] { Component.Event.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen e.printStackTrace(); throw new java.lang.RuntimeException(); diff --git a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java index 9f4fcb45a1..eaf3274de1 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java +++ b/src/com/itmill/toolkit/ui/AbstractComponentContainer.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.ui; @@ -58,15 +34,15 @@ public abstract class AbstractComponentContainer extends AbstractComponent * reimplemented in extending classes for a more powerfull implementation. */ public void removeAllComponents() { - LinkedList l = new LinkedList(); + final LinkedList l = new LinkedList(); // Adds all components - for (Iterator i = getComponentIterator(); i.hasNext();) { + for (final Iterator i = getComponentIterator(); i.hasNext();) { l.add(i.next()); } // Removes all component - for (Iterator i = l.iterator(); i.hasNext();) { + for (final Iterator i = l.iterator(); i.hasNext();) { removeComponent((Component) i.next()); } } @@ -77,13 +53,13 @@ public abstract class AbstractComponentContainer extends AbstractComponent * implemented interface. */ public void moveComponentsFrom(ComponentContainer source) { - LinkedList components = new LinkedList(); - for (Iterator i = source.getComponentIterator(); i.hasNext();) { + final LinkedList components = new LinkedList(); + for (final Iterator i = source.getComponentIterator(); i.hasNext();) { components.add(i.next()); } - for (Iterator i = components.iterator(); i.hasNext();) { - Component c = (Component) i.next(); + for (final Iterator i = components.iterator(); i.hasNext();) { + final Component c = (Component) i.next(); source.removeComponent(c); addComponent(c); } @@ -98,7 +74,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent public void attach() { super.attach(); - for (Iterator i = getComponentIterator(); i.hasNext();) { + for (final Iterator i = getComponentIterator(); i.hasNext();) { ((Component) i.next()).attach(); } } @@ -112,7 +88,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent public void detach() { super.detach(); - for (Iterator i = getComponentIterator(); i.hasNext();) { + for (final Iterator i = getComponentIterator(); i.hasNext();) { ((Component) i.next()).detach(); } } @@ -131,7 +107,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent COMPONENT_DETACHED_METHOD = ComponentDetachListener.class .getDeclaredMethod("componentDetachedFromContainer", new Class[] { ComponentDetachEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException(); } diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java index 3b398a13d5..d85ab2014e 100644 --- a/src/com/itmill/toolkit/ui/AbstractField.java +++ b/src/com/itmill/toolkit/ui/AbstractField.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.ui; @@ -220,13 +196,13 @@ public abstract class AbstractField extends AbstractComponent implements Field, public void commit() throws Buffered.SourceException { if (dataSource != null && (isInvalidCommitted() || isValid()) && !dataSource.isReadOnly()) { - Object newValue = getValue(); + final Object newValue = getValue(); try { // Commits the value to datasource. dataSource.setValue(newValue); - } catch (Throwable e) { + } catch (final Throwable e) { // Sets the buffering state. currentBufferedSourceException = new Buffered.SourceException( @@ -276,7 +252,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, currentBufferedSourceException = null; requestRepaint(); } - } catch (Throwable e) { + } catch (final Throwable e) { // Sets the buffering state currentBufferedSourceException = new Buffered.SourceException( @@ -287,7 +263,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, throw currentBufferedSourceException; } - boolean wasModified = isModified(); + final boolean wasModified = isModified(); modified = false; // If the new value differs from the previous one @@ -370,7 +346,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * @see java.lang.Object#toString() */ public String toString() { - Object value = getValue(); + final Object value = getValue(); if (value == null) { return null; } @@ -392,7 +368,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, return value; } - Object newValue = dataSource.getValue(); + final Object newValue = dataSource.getValue(); if ((newValue == null && value != null) || (newValue != null && !newValue.equals(value))) { setInternalValue(newValue); @@ -438,9 +414,9 @@ public abstract class AbstractField extends AbstractComponent implements Field, // If invalid values are not allowed, the value must be checked if (!isInvalidAllowed()) { - Collection v = getValidators(); + final Collection v = getValidators(); if (v != null) { - for (Iterator i = v.iterator(); i.hasNext();) { + for (final Iterator i = v.iterator(); i.hasNext();) { ((Validator) i.next()).validate(newValue); } } @@ -461,7 +437,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, // The buffer is now unmodified modified = false; - } catch (Throwable e) { + } catch (final Throwable e) { // Sets the buffering state currentBufferedSourceException = new Buffered.SourceException( @@ -518,12 +494,12 @@ public abstract class AbstractField extends AbstractComponent implements Field, public void setPropertyDataSource(Property newDataSource) { // Saves the old value - Object oldValue = value; + final Object oldValue = value; // Discards all changes to old datasource try { discard(); - } catch (Buffered.SourceException ignored) { + } catch (final Buffered.SourceException ignored) { } // Stops listening the old data source changes @@ -542,7 +518,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, setInternalValue(dataSource.getValue()); } modified = false; - } catch (Throwable e) { + } catch (final Throwable e) { currentBufferedSourceException = new Buffered.SourceException(this, e); modified = true; @@ -555,9 +531,10 @@ public abstract class AbstractField extends AbstractComponent implements Field, // Copy the validators from the data source if (dataSource instanceof Validatable) { - Collection validators = ((Validatable) dataSource).getValidators(); + final Collection validators = ((Validatable) dataSource) + .getValidators(); if (validators != null) { - for (Iterator i = validators.iterator(); i.hasNext();) { + for (final Iterator i = validators.iterator(); i.hasNext();) { addValidator((Validator) i.next()); } } @@ -623,8 +600,8 @@ public abstract class AbstractField extends AbstractComponent implements Field, return true; } - Object value = getValue(); - for (Iterator i = validators.iterator(); i.hasNext();) { + final Object value = getValue(); + for (final Iterator i = validators.iterator(); i.hasNext();) { if (!((Validator) i.next()).isValid(value)) { return false; } @@ -648,13 +625,13 @@ public abstract class AbstractField extends AbstractComponent implements Field, // Initialize temps Validator.InvalidValueException firstError = null; LinkedList errors = null; - Object value = getValue(); + final Object value = getValue(); // Gets all the validation errors - for (Iterator i = validators.iterator(); i.hasNext();) { + for (final Iterator i = validators.iterator(); i.hasNext();) { try { ((Validator) i.next()).validate(value); - } catch (Validator.InvalidValueException e) { + } catch (final Validator.InvalidValueException e) { if (firstError == null) { firstError = e; } else { @@ -678,10 +655,10 @@ public abstract class AbstractField extends AbstractComponent implements Field, } // Creates composite validator - Validator.InvalidValueException[] exceptions = new Validator.InvalidValueException[errors + final Validator.InvalidValueException[] exceptions = new Validator.InvalidValueException[errors .size()]; int index = 0; - for (Iterator i = errors.iterator(); i.hasNext();) { + for (final Iterator i = errors.iterator(); i.hasNext();) { exceptions[index++] = (Validator.InvalidValueException) i.next(); } @@ -725,7 +702,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * @see com.itmill.toolkit.ui.AbstractComponent#getErrorMessage() */ public ErrorMessage getErrorMessage() { - ErrorMessage superError = super.getErrorMessage(); + final ErrorMessage superError = super.getErrorMessage(); return superError; /* * TODO: Check the logic of this ErrorMessage validationError = null; @@ -750,7 +727,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, VALUE_CHANGE_METHOD = Property.ValueChangeListener.class .getDeclaredMethod("valueChange", new Class[] { Property.ValueChangeEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException(); } @@ -796,7 +773,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, .getDeclaredMethod( "readOnlyStatusChange", new Class[] { Property.ReadOnlyStatusChangeEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException(); } @@ -885,7 +862,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * Asks the terminal to place the cursor to this field. */ public void focus() { - Window w = getWindow(); + final Window w = getWindow(); if (w != null) { w.setFocusedComponent(this); } else { @@ -917,7 +894,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, // Boolean field if (Boolean.class.isAssignableFrom(propertyType)) { - Button button = new Button(""); + final Button button = new Button(""); button.setSwitchMode(true); button.setImmediate(false); return button; diff --git a/src/com/itmill/toolkit/ui/AbstractLayout.java b/src/com/itmill/toolkit/ui/AbstractLayout.java index c862c0a48b..d66376052a 100644 --- a/src/com/itmill/toolkit/ui/AbstractLayout.java +++ b/src/com/itmill/toolkit/ui/AbstractLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.ui; import com.itmill.toolkit.terminal.PaintException; diff --git a/src/com/itmill/toolkit/ui/AbstractSelect.java b/src/com/itmill/toolkit/ui/AbstractSelect.java index 30d4b3c651..c10ad10fa4 100644 --- a/src/com/itmill/toolkit/ui/AbstractSelect.java +++ b/src/com/itmill/toolkit/ui/AbstractSelect.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.ui; @@ -246,9 +222,9 @@ public abstract class AbstractSelect extends AbstractField implements public AbstractSelect(String caption, Collection options) { // Creates the options container and add given options to it - Container c = new IndexedContainer(); + final Container c = new IndexedContainer(); if (options != null) { - for (Iterator i = options.iterator(); i.hasNext();) { + for (final Iterator i = options.iterator(); i.hasNext();) { c.addItem(i.next()); } } @@ -300,14 +276,14 @@ public abstract class AbstractSelect extends AbstractField implements target.startTag("options"); int keyIndex = 0; // Support for external null selection item id - Collection ids = getItemIds(); + final Collection ids = getItemIds(); if (isNullSelectionAllowed() && getNullSelectionItemId() != null && !ids.contains(getNullSelectionItemId())) { // Gets the option attribute values - Object id = getNullSelectionItemId(); - String key = itemIdMapper.key(id); - String caption = getItemCaption(id); - Resource icon = getItemIcon(id); + final Object id = getNullSelectionItemId(); + final String key = itemIdMapper.key(id); + final String caption = getItemCaption(id); + final Resource icon = getItemIcon(id); // Paints option target.startTag("so"); if (icon != null) { @@ -323,20 +299,20 @@ public abstract class AbstractSelect extends AbstractField implements target.endTag("so"); } - Iterator i = getItemIds().iterator(); + final Iterator i = getItemIds().iterator(); // Paints the available selection options from data source while (i.hasNext()) { // Gets the option attribute values - Object id = i.next(); + final Object id = i.next(); if (!isNullSelectionAllowed() && id != null && id.equals(getNullSelectionItemId())) { // Remove item if it's the null selection item but null // selection is not allowed continue; } - String key = itemIdMapper.key(id); - String caption = getItemCaption(id); - Resource icon = getItemIcon(id); // Paints the option + final String key = itemIdMapper.key(id); + final String caption = getItemCaption(id); + final Resource icon = getItemIcon(id); // Paints the option target.startTag("so"); if (icon != null) { target.addAttribute("icon", icon); @@ -373,7 +349,7 @@ public abstract class AbstractSelect extends AbstractField implements // Try to set the property value // New option entered (and it is allowed) - String newitem = (String) variables.get("newitem"); + final String newitem = (String) variables.get("newitem"); if (newitem != null && newitem.length() > 0) { // Checks for readonly @@ -389,7 +365,7 @@ public abstract class AbstractSelect extends AbstractField implements try { getContainerProperty(newitem, getItemCaptionPropertyId()).setValue(newitem); - } catch (Property.ConversionException ignored) { + } catch (final Property.ConversionException ignored) { // The conversion exception is safely ignored, the // caption is // just missing @@ -400,7 +376,7 @@ public abstract class AbstractSelect extends AbstractField implements // Selection change if (variables.containsKey("selected")) { - String[] ka = (String[]) variables.get("selected"); + final String[] ka = (String[]) variables.get("selected"); // Multiselect mode if (isMultiSelect()) { @@ -408,9 +384,9 @@ public abstract class AbstractSelect extends AbstractField implements // TODO Optimize by adding repaintNotNeeded when applicable // Converts the key-array to id-set - LinkedList s = new LinkedList(); + final LinkedList s = new LinkedList(); for (int i = 0; i < ka.length; i++) { - Object id = itemIdMapper.get(ka[i]); + final Object id = itemIdMapper.get(ka[i]); if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed @@ -431,7 +407,7 @@ public abstract class AbstractSelect extends AbstractField implements // Limits the deselection to the set of visible items // (non-visible items can not be deselected) - Collection visible = getVisibleItemIds(); + final Collection visible = getVisibleItemIds(); if (visible != null) { Set newsel = (Set) getValue(); if (newsel == null) { @@ -453,13 +429,13 @@ public abstract class AbstractSelect extends AbstractField implements if (ka.length == 0) { // Allows deselection only if the deselected item is // visible - Object current = getValue(); - Collection visible = getVisibleItemIds(); + final Object current = getValue(); + final Collection visible = getVisibleItemIds(); if (visible != null && visible.contains(current)) { setValue(null, true); } } else { - Object id = itemIdMapper.get(ka[0]); + final Object id = itemIdMapper.get(ka[0]); if (!isNullSelectionAllowed() && id == null) { requestRepaint(); } else if (id != null @@ -520,7 +496,7 @@ public abstract class AbstractSelect extends AbstractField implements * @see com.itmill.toolkit.ui.AbstractField#getValue() */ public Object getValue() { - Object retValue = super.getValue(); + final Object retValue = super.getValue(); if (isMultiSelect()) { @@ -533,7 +509,7 @@ public abstract class AbstractSelect extends AbstractField implements } else if (retValue instanceof Collection) { return new HashSet((Collection) retValue); } else { - Set s = new HashSet(); + final Set s = new HashSet(); if (items.containsId(retValue)) { s.add(retValue); } @@ -689,7 +665,7 @@ public abstract class AbstractSelect extends AbstractField implements public boolean addContainerProperty(Object propertyId, Class type, Object defaultValue) throws UnsupportedOperationException { - boolean retval = items.addContainerProperty(propertyId, type, + final boolean retval = items.addContainerProperty(propertyId, type, defaultValue); if (retval && !(items instanceof Container.PropertySetChangeNotifier)) { firePropertySetChange(); @@ -708,7 +684,7 @@ public abstract class AbstractSelect extends AbstractField implements */ public boolean removeAllItems() throws UnsupportedOperationException { - boolean retval = items.removeAllItems(); + final boolean retval = items.removeAllItems(); itemIdMapper.removeAll(); if (retval) { setValue(null); @@ -729,7 +705,7 @@ public abstract class AbstractSelect extends AbstractField implements */ public Object addItem() throws UnsupportedOperationException { - Object retval = items.addItem(); + final Object retval = items.addItem(); if (retval != null && !(items instanceof Container.ItemSetChangeNotifier)) { fireItemSetChange(); @@ -753,7 +729,7 @@ public abstract class AbstractSelect extends AbstractField implements */ public Item addItem(Object itemId) throws UnsupportedOperationException { - Item retval = items.addItem(itemId); + final Item retval = items.addItem(itemId); if (retval != null && !(items instanceof Container.ItemSetChangeNotifier)) { fireItemSetChange(); @@ -773,7 +749,7 @@ public abstract class AbstractSelect extends AbstractField implements throws UnsupportedOperationException { unselect(itemId); - boolean retval = items.removeItem(itemId); + final boolean retval = items.removeItem(itemId); itemIdMapper.remove(itemId); if (retval && !(items instanceof Container.ItemSetChangeNotifier)) { fireItemSetChange(); @@ -794,7 +770,7 @@ public abstract class AbstractSelect extends AbstractField implements public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException { - boolean retval = items.removeContainerProperty(propertyId); + final boolean retval = items.removeContainerProperty(propertyId); if (retval && !(items instanceof Container.PropertySetChangeNotifier)) { firePropertySetChange(); } @@ -821,13 +797,13 @@ public abstract class AbstractSelect extends AbstractField implements try { ((Container.ItemSetChangeNotifier) items) .removeListener(this); - } catch (ClassCastException ignored) { + } catch (final ClassCastException ignored) { // Ignored } try { ((Container.PropertySetChangeNotifier) items) .removeListener(this); - } catch (ClassCastException ignored) { + } catch (final ClassCastException ignored) { // Ignored } } @@ -842,13 +818,13 @@ public abstract class AbstractSelect extends AbstractField implements if (items != null) { try { ((Container.ItemSetChangeNotifier) items).addListener(this); - } catch (ClassCastException ignored) { + } catch (final ClassCastException ignored) { // Ignored } try { ((Container.PropertySetChangeNotifier) items) .addListener(this); - } catch (ClassCastException ignored) { + } catch (final ClassCastException ignored) { // Ignored } } @@ -894,19 +870,19 @@ public abstract class AbstractSelect extends AbstractField implements if (multiSelect != this.multiSelect) { // Selection before mode change - Object oldValue = getValue(); + final Object oldValue = getValue(); this.multiSelect = multiSelect; // Convert the value type if (multiSelect) { - Set s = new HashSet(); + final Set s = new HashSet(); if (oldValue != null) { s.add(oldValue); } setValue(s); } else { - Set s = (Set) oldValue; + final Set s = (Set) oldValue; if (s == null || s.isEmpty()) { setValue(null); } else { @@ -994,12 +970,12 @@ public abstract class AbstractSelect extends AbstractField implements try { caption = String.valueOf(((Container.Indexed) items) .indexOfId(itemId)); - } catch (ClassCastException ignored) { + } catch (final ClassCastException ignored) { } break; case ITEM_CAPTION_MODE_ITEM: - Item i = getItem(itemId); + final Item i = getItem(itemId); if (i != null) { caption = i.toString(); } @@ -1017,7 +993,7 @@ public abstract class AbstractSelect extends AbstractField implements break; case ITEM_CAPTION_MODE_PROPERTY: - Property p = getContainerProperty(itemId, + final Property p = getContainerProperty(itemId, getItemCaptionPropertyId()); if (p != null) { caption = p.toString(); @@ -1056,7 +1032,7 @@ public abstract class AbstractSelect extends AbstractField implements * @return the Icon for the item or null, if not specified. */ public Resource getItemIcon(Object itemId) { - Resource explicit = (Resource) itemIcons.get(itemId); + final Resource explicit = (Resource) itemIcons.get(itemId); if (explicit != null) { return explicit; } @@ -1065,11 +1041,12 @@ public abstract class AbstractSelect extends AbstractField implements return null; } - Property ip = getContainerProperty(itemId, getItemIconPropertyId()); + final Property ip = getContainerProperty(itemId, + getItemIconPropertyId()); if (ip == null) { return null; } - Object icon = ip.getValue(); + final Object icon = ip.getValue(); if (icon instanceof Resource) { return (Resource) icon; } @@ -1267,7 +1244,7 @@ public abstract class AbstractSelect extends AbstractField implements if (isMultiSelect()) { return ((Set) getValue()).contains(itemId); } else { - Object value = getValue(); + final Object value = getValue(); return itemId.equals(value == null ? getNullSelectionItemId() : value); } @@ -1290,7 +1267,7 @@ public abstract class AbstractSelect extends AbstractField implements public void select(Object itemId) { if (!isSelected(itemId) && items.containsId(itemId)) { if (isMultiSelect()) { - Set s = new HashSet((Set) getValue()); + final Set s = new HashSet((Set) getValue()); s.add(itemId); setValue(s); } else if (itemId.equals(getNullSelectionItemId())) { @@ -1313,7 +1290,7 @@ public abstract class AbstractSelect extends AbstractField implements public void unselect(Object itemId) { if (isSelected(itemId)) { if (isMultiSelect()) { - Set s = new HashSet((Set) getValue()); + final Set s = new HashSet((Set) getValue()); s.remove(itemId); setValue(s); } else { @@ -1403,8 +1380,8 @@ public abstract class AbstractSelect extends AbstractField implements protected void firePropertySetChange() { if (propertySetEventListeners != null && !propertySetEventListeners.isEmpty()) { - Container.PropertySetChangeEvent event = new PropertySetChangeEvent(); - Object[] listeners = propertySetEventListeners.toArray(); + final Container.PropertySetChangeEvent event = new PropertySetChangeEvent(); + final Object[] listeners = propertySetEventListeners.toArray(); for (int i = 0; i < listeners.length; i++) { ((Container.PropertySetChangeListener) listeners[i]) .containerPropertySetChange(event); @@ -1418,8 +1395,8 @@ public abstract class AbstractSelect extends AbstractField implements */ protected void fireItemSetChange() { if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) { - Container.ItemSetChangeEvent event = new ItemSetChangeEvent(); - Object[] listeners = itemSetEventListeners.toArray(); + final Container.ItemSetChangeEvent event = new ItemSetChangeEvent(); + final Object[] listeners = itemSetEventListeners.toArray(); for (int i = 0; i < listeners.length; i++) { ((Container.ItemSetChangeListener) listeners[i]) .containerItemSetChange(event); diff --git a/src/com/itmill/toolkit/ui/BaseFieldFactory.java b/src/com/itmill/toolkit/ui/BaseFieldFactory.java index e5d6af12e6..6ab3ccf114 100644 --- a/src/com/itmill/toolkit/ui/BaseFieldFactory.java +++ b/src/com/itmill/toolkit/ui/BaseFieldFactory.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.ui; @@ -74,14 +50,14 @@ public class BaseFieldFactory implements FieldFactory { // Date field if (Date.class.isAssignableFrom(type)) { - DateField df = new DateField(); + final DateField df = new DateField(); df.setResolution(DateField.RESOLUTION_DAY); return df; } // Boolean field if (Boolean.class.isAssignableFrom(type)) { - Button button = new Button(); + final Button button = new Button(); button.setSwitchMode(true); button.setImmediate(false); return button; @@ -112,7 +88,8 @@ public class BaseFieldFactory implements FieldFactory { */ public Field createField(Item item, Object propertyId, Component uiContext) { if (item != null && propertyId != null) { - Field f = createField(item.getItemProperty(propertyId), uiContext); + final Field f = createField(item.getItemProperty(propertyId), + uiContext); if (f instanceof AbstractComponent) { ((AbstractComponent) f).setCaption(propertyId.toString()); } diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java index 80def407d8..4ec0c4c9f4 100644 --- a/src/com/itmill/toolkit/ui/Button.java +++ b/src/com/itmill/toolkit/ui/Button.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.ui; @@ -158,7 +134,7 @@ public class Button extends AbstractField { boolean state; try { state = ((Boolean) getValue()).booleanValue(); - } catch (NullPointerException e) { + } catch (final NullPointerException e) { state = false; } target.addVariable(this, "state", state); @@ -175,8 +151,8 @@ public class Button extends AbstractField { public void changeVariables(Object source, Map variables) { if (variables.containsKey("state")) { // Gets the new and old button states - Boolean newValue = (Boolean) variables.get("state"); - Boolean oldValue = (Boolean) getValue(); + final Boolean newValue = (Boolean) variables.get("state"); + final Boolean oldValue = (Boolean) getValue(); if (isSwitchMode()) { @@ -256,7 +232,7 @@ public class Button extends AbstractField { try { BUTTON_CLICK_METHOD = ClickListener.class.getDeclaredMethod( "buttonClick", new Class[] { ClickEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException(); } diff --git a/src/com/itmill/toolkit/ui/CheckBox.java b/src/com/itmill/toolkit/ui/CheckBox.java index 6252a121d6..97558e4fc0 100644 --- a/src/com/itmill/toolkit/ui/CheckBox.java +++ b/src/com/itmill/toolkit/ui/CheckBox.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.ui; import com.itmill.toolkit.data.Property; diff --git a/src/com/itmill/toolkit/ui/ComboBox.java b/src/com/itmill/toolkit/ui/ComboBox.java index 55f2c317d3..3f3bd67bce 100644 --- a/src/com/itmill/toolkit/ui/ComboBox.java +++ b/src/com/itmill/toolkit/ui/ComboBox.java @@ -1,6 +1,7 @@ -/**
- *
+/*
+@ITMillApache2LicenseForJavaFiles@
*/
+
package com.itmill.toolkit.ui;
import java.util.Collection;
diff --git a/src/com/itmill/toolkit/ui/Component.java b/src/com/itmill/toolkit/ui/Component.java index fd5d78840e..a0cfe3338f 100644 --- a/src/com/itmill/toolkit/ui/Component.java +++ b/src/com/itmill/toolkit/ui/Component.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.ui; @@ -342,7 +318,7 @@ public interface Component extends Paintable, VariableOwner { */ private static final long serialVersionUID = 4051323457293857333L; - private ErrorMessage message; + private final ErrorMessage message; /** * Constructs a new event with a specified source component. diff --git a/src/com/itmill/toolkit/ui/ComponentContainer.java b/src/com/itmill/toolkit/ui/ComponentContainer.java index fae3670d05..c5b72ca100 100644 --- a/src/com/itmill/toolkit/ui/ComponentContainer.java +++ b/src/com/itmill/toolkit/ui/ComponentContainer.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.ui; @@ -166,7 +142,7 @@ public interface ComponentContainer extends Component { */ private static final long serialVersionUID = 3257285812184692019L; - private Component component; + private final Component component; /** * Creates a new attach event. @@ -214,7 +190,7 @@ public interface ComponentContainer extends Component { */ private static final long serialVersionUID = 3618140052337930290L; - private Component component; + private final Component component; /** * Creates a new detach event. diff --git a/src/com/itmill/toolkit/ui/CustomComponent.java b/src/com/itmill/toolkit/ui/CustomComponent.java index 3f63ff4806..42fadb63dd 100644 --- a/src/com/itmill/toolkit/ui/CustomComponent.java +++ b/src/com/itmill/toolkit/ui/CustomComponent.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.ui; @@ -305,8 +281,8 @@ public class CustomComponent implements Component { // Notify the listeners if (repaintRequestListeners != null && !repaintRequestListeners.isEmpty()) { - Object[] listeners = repaintRequestListeners.toArray(); - RepaintRequestEvent event = new RepaintRequestEvent(this); + final Object[] listeners = repaintRequestListeners.toArray(); + final RepaintRequestEvent event = new RepaintRequestEvent(this); for (int i = 0; i < listeners.length; i++) { if (alreadyNotified == null) { alreadyNotified = new LinkedList(); @@ -322,7 +298,7 @@ public class CustomComponent implements Component { repaintRequestListenersNotified = true; // Notify the parent - Component parent = getParent(); + final Component parent = getParent(); if (parent != null) { parent.childRequestedRepaint(alreadyNotified); } @@ -423,7 +399,7 @@ public class CustomComponent implements Component { } if (isVisible()) { - String type = getComponentType(); + final String type = getComponentType(); if (type != null) { if (!target.startTag(this, "component")) { target.addAttribute("type", type); diff --git a/src/com/itmill/toolkit/ui/CustomLayout.java b/src/com/itmill/toolkit/ui/CustomLayout.java index 283c1edf19..2b4ea0d481 100644 --- a/src/com/itmill/toolkit/ui/CustomLayout.java +++ b/src/com/itmill/toolkit/ui/CustomLayout.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.ui; @@ -66,7 +42,7 @@ public class CustomLayout extends AbstractLayout { /** * Custom layout slots containing the components. */ - private HashMap slots = new HashMap(); + private final HashMap slots = new HashMap(); private String templateName; @@ -95,7 +71,7 @@ public class CustomLayout extends AbstractLayout { * the location of the component. */ public void addComponent(Component c, String location) { - Component old = (Component) slots.get(location); + final Component old = (Component) slots.get(location); if (old != null) { removeComponent(old); } @@ -178,10 +154,10 @@ public class CustomLayout extends AbstractLayout { target.addAttribute("template", templateName); // Adds all items in all the locations - for (Iterator i = slots.keySet().iterator(); i.hasNext();) { + for (final Iterator i = slots.keySet().iterator(); i.hasNext();) { // Gets the (location,component) - String location = (String) i.next(); - Component c = (Component) slots.get(location); + final String location = (String) i.next(); + final Component c = (Component) slots.get(location); if (c != null) { // Writes the item target.startTag("location"); @@ -198,9 +174,9 @@ public class CustomLayout extends AbstractLayout { // Gets the locations String oldLocation = null; String newLocation = null; - for (Iterator i = slots.keySet().iterator(); i.hasNext();) { - String location = (String) i.next(); - Component component = (Component) slots.get(location); + for (final Iterator i = slots.keySet().iterator(); i.hasNext();) { + final String location = (String) i.next(); + final Component component = (Component) slots.get(location); if (component == oldComponent) { oldLocation = location; } diff --git a/src/com/itmill/toolkit/ui/DateField.java b/src/com/itmill/toolkit/ui/DateField.java index 55e5c58264..942d95de91 100644 --- a/src/com/itmill/toolkit/ui/DateField.java +++ b/src/com/itmill/toolkit/ui/DateField.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.ui; @@ -202,7 +178,7 @@ public class DateField extends AbstractField { super.paintContent(target); // Adds the locale as attribute - Locale l = getLocale(); + final Locale l = getLocale(); if (l != null) { target.addAttribute("locale", l.toString()); } @@ -210,8 +186,8 @@ public class DateField extends AbstractField { target.addAttribute("type", type); // Gets the calendar - Calendar calendar = getCalendar(); - Date currentDate = (Date) getValue(); + final Calendar calendar = getCalendar(); + final Date currentDate = (Date) getValue(); for (int r = resolution; r <= largestModifiable; r++) { switch (r) { @@ -273,7 +249,7 @@ public class DateField extends AbstractField { .containsKey("msec"))) { // Old and new dates - Date oldDate = (Date) getValue(); + final Date oldDate = (Date) getValue(); Date newDate = null; // Gets the new date in parts @@ -307,7 +283,7 @@ public class DateField extends AbstractField { } else { // Clone the calendar for date operation - Calendar cal = getCalendar(); + final Calendar cal = getCalendar(); // Make sure that meaningful values exists // Use the previous value if some of the variables @@ -357,7 +333,7 @@ public class DateField extends AbstractField { * implemented interface. */ public String toString() { - Date value = (Date) getValue(); + final Date value = (Date) getValue(); if (value != null) { return value.toString(); } @@ -383,10 +359,10 @@ public class DateField extends AbstractField { // Try to parse as string try { - SimpleDateFormat parser = new SimpleDateFormat(); - Date val = parser.parse(newValue.toString()); + final SimpleDateFormat parser = new SimpleDateFormat(); + final Date val = parser.parse(newValue.toString()); super.setValue(val, repaintIsNotNeeded); - } catch (ParseException e) { + } catch (final ParseException e) { throw new Property.ConversionException(e.getMessage()); } } @@ -446,10 +422,10 @@ public class DateField extends AbstractField { } // Clone the instance - Calendar newCal = (Calendar) calendar.clone(); + final Calendar newCal = (Calendar) calendar.clone(); // Assigns the current time tom calendar. - Date currentDate = (Date) getValue(); + final Date currentDate = (Date) getValue(); if (currentDate != null) { newCal.setTime(currentDate); } diff --git a/src/com/itmill/toolkit/ui/Embedded.java b/src/com/itmill/toolkit/ui/Embedded.java index 6f00c7855e..fd1127d4e4 100644 --- a/src/com/itmill/toolkit/ui/Embedded.java +++ b/src/com/itmill/toolkit/ui/Embedded.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.ui; @@ -192,9 +168,9 @@ public class Embedded extends AbstractComponent implements Sizeable { } // Params - for (Iterator i = getParameterNames(); i.hasNext();) { + for (final Iterator i = getParameterNames(); i.hasNext();) { target.startTag("embeddedparam"); - String key = (String) i.next(); + final String key = (String) i.next(); target.addAttribute("name", key); target.addAttribute("value", getParameter(key)); target.endTag("embeddedparam"); @@ -448,7 +424,7 @@ public class Embedded extends AbstractComponent implements Sizeable { public void setSource(Resource source) { if (source != null && !source.equals(this.source)) { this.source = source; - String mt = source.getMIMEType(); + final String mt = source.getMIMEType(); if ((mt.substring(0, mt.indexOf("/")).equalsIgnoreCase("image"))) { type = TYPE_IMAGE; } else { diff --git a/src/com/itmill/toolkit/ui/ExpandLayout.java b/src/com/itmill/toolkit/ui/ExpandLayout.java index 9d7d119b02..dab5ee2cf1 100644 --- a/src/com/itmill/toolkit/ui/ExpandLayout.java +++ b/src/com/itmill/toolkit/ui/ExpandLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.ui; import java.util.Iterator; @@ -73,12 +77,12 @@ public class ExpandLayout extends OrderedLayout { target.addAttribute("orientation", "horizontal"); } - String[] alignmentsArray = new String[components.size()]; + final String[] alignmentsArray = new String[components.size()]; // Adds all items in all the locations int index = 0; - for (Iterator i = getComponentIterator(); i.hasNext();) { - Component c = (Component) i.next(); + for (final Iterator i = getComponentIterator(); i.hasNext();) { + final Component c = (Component) i.next(); if (c != null) { target.startTag("cc"); if (c == expanded) { diff --git a/src/com/itmill/toolkit/ui/Field.java b/src/com/itmill/toolkit/ui/Field.java index e4248f8e9b..2da6d0ca89 100644 --- a/src/com/itmill/toolkit/ui/Field.java +++ b/src/com/itmill/toolkit/ui/Field.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.ui; diff --git a/src/com/itmill/toolkit/ui/FieldFactory.java b/src/com/itmill/toolkit/ui/FieldFactory.java index 7abbe29909..9090f267b5 100644 --- a/src/com/itmill/toolkit/ui/FieldFactory.java +++ b/src/com/itmill/toolkit/ui/FieldFactory.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.ui; diff --git a/src/com/itmill/toolkit/ui/Form.java b/src/com/itmill/toolkit/ui/Form.java index 765fcc15b0..ed69ba24e1 100644 --- a/src/com/itmill/toolkit/ui/Form.java +++ b/src/com/itmill/toolkit/ui/Form.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.ui; @@ -93,7 +69,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, /** * Ordered list of property ids in this editor. */ - private LinkedList propertyIds = new LinkedList(); + private final LinkedList propertyIds = new LinkedList(); /** * Current buffered source exception. @@ -113,7 +89,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, /** * Mapping from propertyName to corresponding field. */ - private HashMap fields = new HashMap(); + private final HashMap fields = new HashMap(); /** * Field factory for this form. @@ -189,14 +165,14 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, LinkedList problems = null; // Try to commit all - for (Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { try { - Field f = ((Field) fields.get(i.next())); + final Field f = ((Field) fields.get(i.next())); // Commit only non-readonly fields. if (!f.isReadOnly()) { f.commit(); } - } catch (Buffered.SourceException e) { + } catch (final Buffered.SourceException e) { if (problems == null) { problems = new LinkedList(); } @@ -214,12 +190,13 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } // Commit problems - Throwable[] causes = new Throwable[problems.size()]; + final Throwable[] causes = new Throwable[problems.size()]; int index = 0; - for (Iterator i = problems.iterator(); i.hasNext();) { + for (final Iterator i = problems.iterator(); i.hasNext();) { causes[index++] = (Throwable) i.next(); } - Buffered.SourceException e = new Buffered.SourceException(this, causes); + final Buffered.SourceException e = new Buffered.SourceException(this, + causes); currentBufferedSourceException = e; requestRepaint(); throw e; @@ -234,10 +211,10 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, LinkedList problems = null; // Try to discard all changes - for (Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { try { ((Field) fields.get(i.next())).discard(); - } catch (Buffered.SourceException e) { + } catch (final Buffered.SourceException e) { if (problems == null) { problems = new LinkedList(); } @@ -255,12 +232,13 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } // Discards problems occurred - Throwable[] causes = new Throwable[problems.size()]; + final Throwable[] causes = new Throwable[problems.size()]; int index = 0; - for (Iterator i = problems.iterator(); i.hasNext();) { + for (final Iterator i = problems.iterator(); i.hasNext();) { causes[index++] = (Throwable) i.next(); } - Buffered.SourceException e = new Buffered.SourceException(this, causes); + final Buffered.SourceException e = new Buffered.SourceException(this, + causes); currentBufferedSourceException = e; requestRepaint(); throw e; @@ -271,8 +249,8 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * here, we use the default one from the interface. */ public boolean isModified() { - for (Iterator i = propertyIds.iterator(); i.hasNext();) { - Field f = (Field) fields.get(i.next()); + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { + final Field f = (Field) fields.get(i.next()); if (f != null && f.isModified()) { return true; } @@ -304,7 +282,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, public void setReadThrough(boolean readThrough) { if (readThrough != this.readThrough) { this.readThrough = readThrough; - for (Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { ((Field) fields.get(i.next())).setReadThrough(readThrough); } } @@ -317,7 +295,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, public void setWriteThrough(boolean writeThrough) { if (writeThrough != this.writeThrough) { this.writeThrough = writeThrough; - for (Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { ((Field) fields.get(i.next())).setWriteThrough(writeThrough); } } @@ -341,7 +319,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } // Gets suitable field - Field field = fieldFactory.createField(property, this); + final Field field = fieldFactory.createField(property, this); if (field == null) { return false; } @@ -358,7 +336,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, + caption.substring(1, caption.length()); } field.setCaption(caption); - } catch (Throwable ignored) { + } catch (final Throwable ignored) { return false; } @@ -420,11 +398,11 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * @see com.itmill.toolkit.data.Item#getItemProperty(Object) */ public Property getItemProperty(Object id) { - Field field = (Field) fields.get(id); + final Field field = (Field) fields.get(id); if (field == null) { return null; } - Property property = field.getPropertyDataSource(); + final Property property = field.getPropertyDataSource(); if (property != null) { return property; @@ -455,7 +433,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, */ public boolean removeItemProperty(Object id) { - Field field = (Field) fields.get(id); + final Field field = (Field) fields.get(id); if (field != null) { propertyIds.remove(id); @@ -476,7 +454,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * (and only if) the return value is <code>true</code>. */ public boolean removeAllProperties() { - Object[] properties = propertyIds.toArray(); + final Object[] properties = propertyIds.toArray(); boolean success = true; for (int i = 0; i < properties.length; i++) { @@ -534,11 +512,12 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } // Adds all the properties to this form - for (Iterator i = propertyIds.iterator(); i.hasNext();) { - Object id = i.next(); - Property property = itemDatasource.getItemProperty(id); + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { + final Object id = i.next(); + final Property property = itemDatasource.getItemProperty(id); if (id != null && property != null) { - Field f = fieldFactory.createField(itemDatasource, id, this); + final Field f = fieldFactory.createField(itemDatasource, id, + this); if (f != null) { f.setPropertyDataSource(property); addField(id, f); @@ -616,12 +595,12 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } // Gets the old field - Field oldField = (Field) fields.get(propertyId); + final Field oldField = (Field) fields.get(propertyId); if (oldField == null) { throw new IllegalArgumentException("Field with given propertyid '" + propertyId.toString() + "' can not be found."); } - Object value = oldField.getValue(); + final Object value = oldField.getValue(); // Checks that the value exists and check if the select should // be forced in multiselect mode @@ -635,9 +614,9 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } if (value != null && !found) { if (value instanceof Collection) { - for (Iterator it = ((Collection) value).iterator(); it + for (final Iterator it = ((Collection) value).iterator(); it .hasNext();) { - Object val = it.next(); + final Object val = it.next(); found = false; for (int i = 0; i < values.length && !found; i++) { if (values[i] == val @@ -662,7 +641,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } // Creates the new field matching to old field parameters - Select newField = new Select(); + final Select newField = new Select(); if (isMultiselect) { newField.setMultiSelect(true); } @@ -680,7 +659,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, id = new Object(); newField.setNullSelectionItemId(id); } - Item item = newField.addItem(id); + final Item item = newField.addItem(id); if (item != null) { item.getItemProperty("desc").setValue( descriptions[i].toString()); @@ -688,7 +667,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } // Sets the property data source - Property property = oldField.getPropertyDataSource(); + final Property property = oldField.getPropertyDataSource(); oldField.setPropertyDataSource(null); newField.setPropertyDataSource(property); @@ -766,7 +745,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, */ public boolean isValid() { boolean valid = true; - for (Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { valid &= ((Field) fields.get(i.next())).isValid(); } return valid; @@ -778,7 +757,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * @see com.itmill.toolkit.data.Validatable#validate() */ public void validate() throws InvalidValueException { - for (Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { ((Field) fields.get(i.next())).validate(); } } @@ -809,7 +788,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, */ public void setReadOnly(boolean readOnly) { super.setReadOnly(readOnly); - for (Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator i = propertyIds.iterator(); i.hasNext();) { ((Field) fields.get(i.next())).setReadOnly(readOnly); } } @@ -859,7 +838,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, */ protected void setInternalValue(Object newValue) { // Stores the old value - Object oldValue = propertyValue; + final Object oldValue = propertyValue; // Sets the current Value super.setInternalValue(newValue); @@ -932,7 +911,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, */ public void setVisibleItemProperties(Collection visibleProperties) { visibleItemProperties = visibleProperties; - Object value = getValue(); + final Object value = getValue(); setFormDataSource(value, getVisibleItemProperties()); } @@ -942,7 +921,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * @see com.itmill.toolkit.ui.Component.Focusable#focus() */ public void focus() { - Field f = getFirstField(); + final Field f = getFirstField(); if (f != null) { f.focus(); } @@ -955,7 +934,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, */ public void setTabIndex(int tabIndex) { super.setTabIndex(tabIndex); - for (Iterator i = getItemPropertyIds().iterator(); i.hasNext();) { + for (final Iterator i = getItemPropertyIds().iterator(); i.hasNext();) { (getField(i.next())).setTabIndex(tabIndex); } } diff --git a/src/com/itmill/toolkit/ui/FormLayout.java b/src/com/itmill/toolkit/ui/FormLayout.java index c81ba29ab0..fe972db98b 100644 --- a/src/com/itmill/toolkit/ui/FormLayout.java +++ b/src/com/itmill/toolkit/ui/FormLayout.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.ui; public class FormLayout extends OrderedLayout { diff --git a/src/com/itmill/toolkit/ui/GridLayout.java b/src/com/itmill/toolkit/ui/GridLayout.java index 0e0d80172e..e7f5293b23 100644 --- a/src/com/itmill/toolkit/ui/GridLayout.java +++ b/src/com/itmill/toolkit/ui/GridLayout.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.ui; @@ -87,12 +63,12 @@ public class GridLayout extends AbstractLayout { * Contains all items that are placed on the grid. These are components with * grid area definition. */ - private LinkedList areas = new LinkedList(); + private final LinkedList areas = new LinkedList(); /** * Mapping from components to their respective areas. */ - private LinkedList components = new LinkedList(); + private final LinkedList components = new LinkedList(); /** * Mapping from components to alignments (horizontal + vertical). @@ -204,7 +180,7 @@ public class GridLayout extends AbstractLayout { } // Creates the area - Area area = new Area(component, column1, row1, column2, row2); + final Area area = new Area(component, column1, row1, column2, row2); // Checks the validity of the coordinates if (column2 < column1 || row2 < row1) { @@ -221,11 +197,11 @@ public class GridLayout extends AbstractLayout { // Inserts the component to right place at the list // Respect top-down, left-right ordering component.setParent(this); - Iterator i = areas.iterator(); + final Iterator i = areas.iterator(); int index = 0; boolean done = false; while (!done && i.hasNext()) { - Area existingArea = (Area) i.next(); + final Area existingArea = (Area) i.next(); if ((existingArea.row1 >= row1 && existingArea.column1 > column1) || existingArea.row1 > row1) { areas.add(index, area); @@ -253,8 +229,8 @@ public class GridLayout extends AbstractLayout { * if <code>area</code> overlaps with any existing area. */ private void checkExistingOverlaps(Area area) throws OverlapsException { - for (Iterator i = areas.iterator(); i.hasNext();) { - Area existingArea = (Area) i.next(); + for (final Iterator i = areas.iterator(); i.hasNext();) { + final Area existingArea = (Area) i.next(); if (existingArea.overlaps(area)) { // Component not added, overlaps with existing component throw new OverlapsException(existingArea); @@ -323,7 +299,7 @@ public class GridLayout extends AbstractLayout { area = new Area(component, cursorX, cursorY, cursorX, cursorY); checkExistingOverlaps(area); done = true; - } catch (OverlapsException ignored) { + } catch (final OverlapsException ignored) { space(); } } @@ -351,8 +327,8 @@ public class GridLayout extends AbstractLayout { super.removeComponent(component); Area area = null; - for (Iterator i = areas.iterator(); area == null && i.hasNext();) { - Area a = (Area) i.next(); + for (final Iterator i = areas.iterator(); area == null && i.hasNext();) { + final Area a = (Area) i.next(); if (a.getComponent() == component) { area = a; } @@ -379,8 +355,8 @@ public class GridLayout extends AbstractLayout { public void removeComponent(int column, int row) { // Finds the area - for (Iterator i = areas.iterator(); i.hasNext();) { - Area area = (Area) i.next(); + for (final Iterator i = areas.iterator(); i.hasNext();) { + final Area area = (Area) i.next(); if (area.getColumn1() == column && area.getRow1() == row) { removeComponent(area.getComponent()); return; @@ -419,13 +395,13 @@ public class GridLayout extends AbstractLayout { } // Area iterator - Iterator areaiterator = areas.iterator(); + final Iterator areaiterator = areas.iterator(); // Current item to be processed (fetch first item) Area area = areaiterator.hasNext() ? (Area) areaiterator.next() : null; // Collects rowspan related information here - HashMap cellUsed = new HashMap(); + final HashMap cellUsed = new HashMap(); // Empty cell collector int emptyCells = 0; @@ -454,8 +430,8 @@ public class GridLayout extends AbstractLayout { } // Now proceed rendering current item - int cols = (area.column2 - area.column1) + 1; - int rows = (area.row2 - area.row1) + 1; + final int cols = (area.column2 - area.column1) + 1; + final int rows = (area.row2 - area.row1) + 1; target.startTag("gc"); target.addAttribute("x", curx); @@ -500,8 +476,8 @@ public class GridLayout extends AbstractLayout { // Current column contains already an item, // check if rowspan affects at current x,y position - int rowspanDepth = ((Integer) cellUsed.get(new Integer( - curx))).intValue(); + final int rowspanDepth = ((Integer) cellUsed + .get(new Integer(curx))).intValue(); if (rowspanDepth >= cury) { @@ -582,22 +558,22 @@ public class GridLayout extends AbstractLayout { /** * The column of the upper left corner cell of the area. */ - private int column1; + private final int column1; /** * The row of the upper left corner cell of the area. */ - private int row1; + private final int row1; /** * The column of the lower right corner cell of the area. */ - private int column2; + private final int column2; /** * The row of the lower right corner cell of the area. */ - private int row2; + private final int row2; /** * Component painted on the area. @@ -765,7 +741,7 @@ public class GridLayout extends AbstractLayout { */ private static final long serialVersionUID = 3978144339870101561L; - private Area existingArea; + private final Area existingArea; /** * Constructs an <code>OverlapsException</code>. @@ -802,7 +778,7 @@ public class GridLayout extends AbstractLayout { */ private static final long serialVersionUID = 3618985589664592694L; - private Area areaOutOfBounds; + private final Area areaOutOfBounds; /** * Constructs an <code>OoutOfBoundsException</code> with the specified @@ -874,8 +850,8 @@ public class GridLayout extends AbstractLayout { // Checks for overlaps if (cols > columns) { - for (Iterator i = areas.iterator(); i.hasNext();) { - Area area = (Area) i.next(); + for (final Iterator i = areas.iterator(); i.hasNext();) { + final Area area = (Area) i.next(); if (area.column2 >= columns) { throw new OutOfBoundsException(area); } @@ -946,8 +922,8 @@ public class GridLayout extends AbstractLayout { // Checks for overlaps if (this.rows > rows) { - for (Iterator i = areas.iterator(); i.hasNext();) { - Area area = (Area) i.next(); + for (final Iterator i = areas.iterator(); i.hasNext();) { + final Area area = (Area) i.next(); if (area.row2 >= rows) { throw new OutOfBoundsException(area); } @@ -998,9 +974,9 @@ public class GridLayout extends AbstractLayout { // Gets the locations Area oldLocation = null; Area newLocation = null; - for (Iterator i = areas.iterator(); i.hasNext();) { - Area location = (Area) i.next(); - Component component = location.getComponent(); + for (final Iterator i = areas.iterator(); i.hasNext();) { + final Area location = (Area) i.next(); + final Component component = location.getComponent(); if (component == oldComponent) { oldLocation = location; } diff --git a/src/com/itmill/toolkit/ui/InlineDateField.java b/src/com/itmill/toolkit/ui/InlineDateField.java index 2219bb24a1..46db9c7fc7 100644 --- a/src/com/itmill/toolkit/ui/InlineDateField.java +++ b/src/com/itmill/toolkit/ui/InlineDateField.java @@ -1,6 +1,7 @@ -/**
- *
+/*
+@ITMillApache2LicenseForJavaFiles@
*/
+
package com.itmill.toolkit.ui;
import java.util.Date;
diff --git a/src/com/itmill/toolkit/ui/Label.java b/src/com/itmill/toolkit/ui/Label.java index 30a8ceaebc..c3f74763ec 100644 --- a/src/com/itmill/toolkit/ui/Label.java +++ b/src/com/itmill/toolkit/ui/Label.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.ui; @@ -397,7 +373,7 @@ public class Label extends AbstractComponent implements Property, VALUE_CHANGE_METHOD = Property.ValueChangeListener.class .getDeclaredMethod("valueChange", new Class[] { Property.ValueChangeEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException(); } @@ -534,10 +510,10 @@ public class Label extends AbstractComponent implements Property, */ private String stripTags(String xml) { - StringBuffer res = new StringBuffer(); + final StringBuffer res = new StringBuffer(); int processed = 0; - int xmlLen = xml.length(); + final int xmlLen = xml.length(); while (processed < xmlLen) { int next = xml.indexOf('<', processed); if (next < 0) { diff --git a/src/com/itmill/toolkit/ui/Layout.java b/src/com/itmill/toolkit/ui/Layout.java index 8e6062db81..cdc7c42730 100644 --- a/src/com/itmill/toolkit/ui/Layout.java +++ b/src/com/itmill/toolkit/ui/Layout.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.ui; diff --git a/src/com/itmill/toolkit/ui/Link.java b/src/com/itmill/toolkit/ui/Link.java index 6e12c67a31..0ba5f53564 100644 --- a/src/com/itmill/toolkit/ui/Link.java +++ b/src/com/itmill/toolkit/ui/Link.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.ui; @@ -133,7 +109,7 @@ public class Link extends AbstractComponent { } // Target window name - String name = getTargetName(); + final String name = getTargetName(); if (name != null && name.length() > 0) { target.addAttribute("name", name); } diff --git a/src/com/itmill/toolkit/ui/ListSelect.java b/src/com/itmill/toolkit/ui/ListSelect.java index 235524a649..303e321e85 100644 --- a/src/com/itmill/toolkit/ui/ListSelect.java +++ b/src/com/itmill/toolkit/ui/ListSelect.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.ui; import java.util.Collection; diff --git a/src/com/itmill/toolkit/ui/NativeSelect.java b/src/com/itmill/toolkit/ui/NativeSelect.java index 9c5859095e..d3e445dcf6 100644 --- a/src/com/itmill/toolkit/ui/NativeSelect.java +++ b/src/com/itmill/toolkit/ui/NativeSelect.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.ui; import java.util.Collection; diff --git a/src/com/itmill/toolkit/ui/OptionGroup.java b/src/com/itmill/toolkit/ui/OptionGroup.java index 0d7ff51245..e7e5b515d9 100644 --- a/src/com/itmill/toolkit/ui/OptionGroup.java +++ b/src/com/itmill/toolkit/ui/OptionGroup.java @@ -1,6 +1,7 @@ -/** - * +/* +@ITMillApache2LicenseForJavaFiles@ */ + package com.itmill.toolkit.ui; import java.util.Collection; diff --git a/src/com/itmill/toolkit/ui/OrderedLayout.java b/src/com/itmill/toolkit/ui/OrderedLayout.java index 3b05e06dd7..7bdf0611a2 100644 --- a/src/com/itmill/toolkit/ui/OrderedLayout.java +++ b/src/com/itmill/toolkit/ui/OrderedLayout.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.ui; @@ -72,7 +48,7 @@ public class OrderedLayout extends AbstractLayout { /** * Mapping from components to alignments (horizontal + vertical). */ - private Map componentToAlignment = new HashMap(); + private final Map componentToAlignment = new HashMap(); /** * Contained component should be aligned horizontally to the left. @@ -230,11 +206,11 @@ public class OrderedLayout extends AbstractLayout { target.addAttribute("spacing", spacing); } - String[] alignmentsArray = new String[components.size()]; + final String[] alignmentsArray = new String[components.size()]; // Adds all items in all the locations int index = 0; - for (Iterator i = components.iterator(); i.hasNext();) { - Component c = (Component) i.next(); + for (final Iterator i = components.iterator(); i.hasNext();) { + final Component c = (Component) i.next(); if (c != null) { // Paint child component UIDL c.paint(target); @@ -276,9 +252,9 @@ public class OrderedLayout extends AbstractLayout { // FIXME remove lines below and uncomment above // Workaround to bypass IOrderedLayouts limitations (separate classes // for different orientation + subtreecacing) - Iterator it = getComponentIterator(); + final Iterator it = getComponentIterator(); while (it.hasNext()) { - Component c = (Component) it.next(); + final Component c = (Component) it.next(); c.requestRepaint(); } } @@ -290,8 +266,8 @@ public class OrderedLayout extends AbstractLayout { int oldLocation = -1; int newLocation = -1; int location = 0; - for (Iterator i = components.iterator(); i.hasNext();) { - Component component = (Component) i.next(); + for (final Iterator i = components.iterator(); i.hasNext();) { + final Component component = (Component) i.next(); if (component == oldComponent) { oldLocation = location; @@ -347,7 +323,8 @@ public class OrderedLayout extends AbstractLayout { } public int getComponentAlignment(Component childComponent) { - Integer bitMask = (Integer) componentToAlignment.get(childComponent); + final Integer bitMask = (Integer) componentToAlignment + .get(childComponent); if (bitMask != null) { return bitMask.intValue(); } else { diff --git a/src/com/itmill/toolkit/ui/Panel.java b/src/com/itmill/toolkit/ui/Panel.java index 541effb479..a2be804cd6 100644 --- a/src/com/itmill/toolkit/ui/Panel.java +++ b/src/com/itmill/toolkit/ui/Panel.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.ui; @@ -229,14 +205,14 @@ public class Panel extends AbstractComponentContainer implements Sizeable, target.addVariable(this, "action", ""); target.startTag("actions"); - for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) { - Action[] aa = ((Action.Handler) ahi.next()).getActions(null, - this); + for (final Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) { + final Action[] aa = ((Action.Handler) ahi.next()).getActions( + null, this); if (aa != null) { for (int ai = 0; ai < aa.length; ai++) { - Action a = aa[ai]; + final Action a = aa[ai]; target.startTag("action"); - String akey = actionMapper.key(aa[ai]); + final String akey = actionMapper.key(aa[ai]); target.addAttribute("key", akey); if (a.getCaption() != null) { target.addAttribute("caption", a.getCaption()); @@ -245,11 +221,11 @@ public class Panel extends AbstractComponentContainer implements Sizeable, target.addAttribute("icon", a.getIcon()); } if (a instanceof ShortcutAction) { - ShortcutAction sa = (ShortcutAction) a; + final ShortcutAction sa = (ShortcutAction) a; target.addAttribute("kc", sa.getKeyCode()); - int[] modifiers = sa.getModifiers(); + final int[] modifiers = sa.getModifiers(); if (modifiers != null) { - String[] smodifiers = new String[modifiers.length]; + final String[] smodifiers = new String[modifiers.length]; for (int i = 0; i < modifiers.length; i++) { smodifiers[i] = String .valueOf(modifiers[i]); @@ -322,8 +298,8 @@ public class Panel extends AbstractComponentContainer implements Sizeable, super.changeVariables(source, variables); // Get new size - Integer newWidth = (Integer) variables.get("width"); - Integer newHeight = (Integer) variables.get("height"); + final Integer newWidth = (Integer) variables.get("width"); + final Integer newHeight = (Integer) variables.get("height"); if (newWidth != null && newWidth.intValue() != getWidth()) { setWidth(newWidth.intValue()); // ensure units as we are reading pixels @@ -337,8 +313,8 @@ public class Panel extends AbstractComponentContainer implements Sizeable, } // Scrolling - Integer newScrollX = (Integer) variables.get("scrollleft"); - Integer newScrollY = (Integer) variables.get("scrolldown"); + final Integer newScrollX = (Integer) variables.get("scrollleft"); + final Integer newScrollY = (Integer) variables.get("scrolldown"); if (newScrollX != null && newScrollX.intValue() != getScrollOffsetX()) { setScrollOffsetX(newScrollX.intValue()); } @@ -348,10 +324,10 @@ public class Panel extends AbstractComponentContainer implements Sizeable, // Actions if (variables.containsKey("action")) { - String key = (String) variables.get("action"); - Action action = (Action) actionMapper.get(key); + final String key = (String) variables.get("action"); + final Action action = (Action) actionMapper.get(key); if (action != null && actionHandlers != null) { - for (Iterator i = actionHandlers.iterator(); i.hasNext();) { + for (final Iterator i = actionHandlers.iterator(); i.hasNext();) { ((Action.Handler) i.next()) .handleAction(action, this, this); } diff --git a/src/com/itmill/toolkit/ui/PopupDateField.java b/src/com/itmill/toolkit/ui/PopupDateField.java index deb216e05f..b00f55ae92 100644 --- a/src/com/itmill/toolkit/ui/PopupDateField.java +++ b/src/com/itmill/toolkit/ui/PopupDateField.java @@ -1,6 +1,7 @@ -/**
- *
+/*
+@ITMillApache2LicenseForJavaFiles@
*/
+
package com.itmill.toolkit.ui;
import java.util.Date;
diff --git a/src/com/itmill/toolkit/ui/ProgressIndicator.java b/src/com/itmill/toolkit/ui/ProgressIndicator.java index 2314e833e1..8a48239da0 100644 --- a/src/com/itmill/toolkit/ui/ProgressIndicator.java +++ b/src/com/itmill/toolkit/ui/ProgressIndicator.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.ui; diff --git a/src/com/itmill/toolkit/ui/RichTextArea.java b/src/com/itmill/toolkit/ui/RichTextArea.java index 96043b5751..09dd0fd648 100644 --- a/src/com/itmill/toolkit/ui/RichTextArea.java +++ b/src/com/itmill/toolkit/ui/RichTextArea.java @@ -1,3 +1,7 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + package com.itmill.toolkit.ui; import com.itmill.toolkit.terminal.PaintException; diff --git a/src/com/itmill/toolkit/ui/Select.java b/src/com/itmill/toolkit/ui/Select.java index 34ada06365..9658940c34 100644 --- a/src/com/itmill/toolkit/ui/Select.java +++ b/src/com/itmill/toolkit/ui/Select.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.ui; @@ -188,7 +164,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { */ target.startTag("options"); - boolean paintNullSelection = needNullSelectOption + final boolean paintNullSelection = needNullSelectOption && (currentPage == 0 && (filterstring == null || filterstring.equals("") || filterstring.equals("-"))); @@ -214,16 +190,16 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { } options = options.subList(first, last); } - Iterator i = options.iterator(); + final Iterator i = options.iterator(); // Paints the available selection options from data source while (i.hasNext()) { // Gets the option attribute values - Object id = i.next(); - String key = itemIdMapper.key(id); - String caption = getItemCaption(id); - Resource icon = getItemIcon(id); + final Object id = i.next(); + final String key = itemIdMapper.key(id); + final String caption = getItemCaption(id); + final Resource icon = getItemIcon(id); // Paints the option target.startTag("so"); @@ -282,8 +258,8 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { prevfilterstring = filterstring; filteredOptions = new LinkedList(); - for (Iterator it = items.iterator(); it.hasNext();) { - Object itemId = it.next(); + for (final Iterator it = items.iterator(); it.hasNext();) { + final Object itemId = it.next(); String caption = getItemCaption(itemId); if (caption == null || caption.equals("")) { continue; @@ -330,7 +306,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { // Try to set the property value // New option entered (and it is allowed) - String newitem = (String) variables.get("newitem"); + final String newitem = (String) variables.get("newitem"); if (newitem != null && newitem.length() > 0) { // Checks for readonly @@ -346,7 +322,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { try { getContainerProperty(newitem, getItemCaptionPropertyId()).setValue(newitem); - } catch (Property.ConversionException ignored) { + } catch (final Property.ConversionException ignored) { // The conversion exception is safely ignored, the // caption is // just missing @@ -358,7 +334,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { // Selection change if (variables.containsKey("selected")) { - String[] ka = (String[]) variables.get("selected"); + final String[] ka = (String[]) variables.get("selected"); // Multiselect mode if (isMultiSelect()) { @@ -366,9 +342,9 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { // TODO Optimize by adding repaintNotNeeded whan applicaple // Converts the key-array to id-set - LinkedList s = new LinkedList(); + final LinkedList s = new LinkedList(); for (int i = 0; i < ka.length; i++) { - Object id = itemIdMapper.get(ka[i]); + final Object id = itemIdMapper.get(ka[i]); if (id != null && containsId(id)) { s.add(id); } else if (itemIdMapper.isNewIdKey(ka[i]) @@ -379,7 +355,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { // Limits the deselection to the set of visible items // (non-visible items can not be deselected) - Collection visible = getVisibleItemIds(); + final Collection visible = getVisibleItemIds(); if (visible != null) { Set newsel = (Set) getValue(); if (newsel == null) { @@ -398,13 +374,13 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering { if (ka.length == 0) { // Allows deselection only if the deselected item is visible - Object current = getValue(); - Collection visible = getVisibleItemIds(); + final Object current = getValue(); + final Collection visible = getVisibleItemIds(); if (visible != null && visible.contains(current)) { setValue(null, true); } } else { - Object id = itemIdMapper.get(ka[0]); + final Object id = itemIdMapper.get(ka[0]); if (id != null && id.equals(getNullSelectionItemId())) { setValue(null, true); } else if (itemIdMapper.isNewIdKey(ka[0])) { diff --git a/src/com/itmill/toolkit/ui/Slider.java b/src/com/itmill/toolkit/ui/Slider.java index 02191f8cfd..d0598e70fe 100644 --- a/src/com/itmill/toolkit/ui/Slider.java +++ b/src/com/itmill/toolkit/ui/Slider.java @@ -1,3 +1,7 @@ +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.ui;
import java.util.Map;
@@ -90,7 +94,7 @@ public class Slider extends AbstractField { * (client-side implementation decides the increment, usually somewhere
* between 5-10% of slide range).
*/
- private boolean arrows = false;
+ private final boolean arrows = false;
/**
* Default Slider constructor. Sets all values to defaults and the slide
@@ -175,7 +179,7 @@ public class Slider extends AbstractField { if ((new Double(getValue().toString())).doubleValue() > max) {
super.setValue(new Double(max));
}
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
super.setValue(new Double(max));
}
requestRepaint();
@@ -203,7 +207,7 @@ public class Slider extends AbstractField { if ((new Double(getValue().toString())).doubleValue() < min) {
super.setValue(new Double(min));
}
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
super.setValue(new Double(min));
}
requestRepaint();
@@ -263,7 +267,7 @@ public class Slider extends AbstractField { */
public void setValue(Double value, boolean repaintIsNotNeeded)
throws ValueOutOfBoundsException {
- double v = value.doubleValue();
+ final double v = value.doubleValue();
double newValue;
if (resolution > 0) {
// Round up to resolution
@@ -358,17 +362,17 @@ public class Slider extends AbstractField { *
* @param visible
*//*
- * public void setArrows(boolean visible) { arrows = visible;
- * requestRepaint(); }
- */
+ * public void setArrows(boolean visible) { arrows = visible;
+ * requestRepaint(); }
+ */
/*
* Does the slider have arrows?
*
* @return arrows visible
*//*
- * public boolean isArrowsVisible() { return arrows; }
- */
+ * public boolean isArrowsVisible() { return arrows; }
+ */
public String getTag() {
return "slider";
@@ -421,13 +425,13 @@ public class Slider extends AbstractField { */
public void changeVariables(Object source, Map variables) {
if (variables.containsKey("value")) {
- Object value = variables.get("value");
- Double newValue = new Double(value.toString());
+ final Object value = variables.get("value");
+ final Double newValue = new Double(value.toString());
if (newValue != null && newValue != getValue()
&& !newValue.equals(getValue())) {
try {
setValue(newValue, true);
- } catch (ValueOutOfBoundsException e) {
+ } catch (final ValueOutOfBoundsException e) {
// Convert to nearest bound
double out = e.getValue().doubleValue();
if (out < min) {
@@ -455,7 +459,7 @@ public class Slider extends AbstractField { */
private static final long serialVersionUID = -6451298598644446340L;
- private Double value;
+ private final Double value;
/**
* Constructs an <code>ValueOutOfBoundsException</code> with the
diff --git a/src/com/itmill/toolkit/ui/SplitPanel.java b/src/com/itmill/toolkit/ui/SplitPanel.java index f26d39deda..c09b337b09 100644 --- a/src/com/itmill/toolkit/ui/SplitPanel.java +++ b/src/com/itmill/toolkit/ui/SplitPanel.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.ui; @@ -218,7 +194,7 @@ public class SplitPanel extends AbstractLayout { public void paintContent(PaintTarget target) throws PaintException { super.paintContent(target); - String position = pos + UNIT_SYMBOLS[posUnit]; + final String position = pos + UNIT_SYMBOLS[posUnit]; target.addAttribute("position", position); diff --git a/src/com/itmill/toolkit/ui/TabSheet.java b/src/com/itmill/toolkit/ui/TabSheet.java index 833732224d..87ec3cfc16 100644 --- a/src/com/itmill/toolkit/ui/TabSheet.java +++ b/src/com/itmill/toolkit/ui/TabSheet.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.ui; @@ -53,24 +29,24 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable { /** * Linked list of component tabs. */ - private LinkedList tabs = new LinkedList(); + private final LinkedList tabs = new LinkedList(); /** * Tab -> caption mapping. */ - private Hashtable tabCaptions = new Hashtable(); + private final Hashtable tabCaptions = new Hashtable(); /** * Tab -> icon mapping . */ - private Hashtable tabIcons = new Hashtable(); + private final Hashtable tabIcons = new Hashtable(); /** * Selected tab. */ private Component selected = null; - private KeyMapper keyMapper = new KeyMapper(); + private final KeyMapper keyMapper = new KeyMapper(); /** * Holds the value of property tabsHIdden. @@ -197,8 +173,8 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable { * the container components are removed from. */ public void moveComponentsFrom(ComponentContainer source) { - for (Iterator i = source.getComponentIterator(); i.hasNext();) { - Component c = (Component) i.next(); + for (final Iterator i = source.getComponentIterator(); i.hasNext();) { + final Component c = (Component) i.next(); String caption = null; Resource icon = null; if (TabSheet.class.isAssignableFrom(source.getClass())) { @@ -237,17 +213,17 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable { target.startTag("tabs"); - for (Iterator i = getComponentIterator(); i.hasNext();) { - Component c = (Component) i.next(); + for (final Iterator i = getComponentIterator(); i.hasNext();) { + final Component c = (Component) i.next(); if (!c.isVisible()) { continue; } target.startTag("tab"); - Resource icon = getTabIcon(c); + final Resource icon = getTabIcon(c); if (icon != null) { target.addAttribute("icon", icon); } - String caption = getTabCaption(c); + final String caption = getTabCaption(c); if (!c.isEnabled()) { target.addAttribute("disabled", true); } @@ -381,17 +357,17 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable { public void replaceComponent(Component oldComponent, Component newComponent) { // Gets the captions - String oldCaption = getTabCaption(oldComponent); - Resource oldIcon = getTabIcon(oldComponent); - String newCaption = getTabCaption(newComponent); - Resource newIcon = getTabIcon(newComponent); + final String oldCaption = getTabCaption(oldComponent); + final Resource oldIcon = getTabIcon(oldComponent); + final String newCaption = getTabCaption(newComponent); + final Resource newIcon = getTabIcon(newComponent); // Gets the locations int oldLocation = -1; int newLocation = -1; int location = 0; - for (Iterator i = tabs.iterator(); i.hasNext();) { - Component component = (Component) i.next(); + for (final Iterator i = tabs.iterator(); i.hasNext();) { + final Component component = (Component) i.next(); if (component == oldComponent) { oldLocation = location; @@ -442,7 +418,7 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable { SELECTED_TAB_CHANGE_METHOD = SelectedTabChangeListener.class .getDeclaredMethod("selectedTabChange", new Class[] { SelectedTabChangeEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException(); } diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 15ca1e4455..4be9b840e8 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.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.ui; @@ -394,7 +370,7 @@ public class Table extends AbstractSelect implements Action.Container, // Checks that the new visible columns contains no nulls and properties // exist - Collection properties = getContainerPropertyIds(); + final Collection properties = getContainerPropertyIds(); for (int i = 0; i < visibleColumns.length; i++) { if (visibleColumns[i] == null) { throw new NullPointerException("Properties must be non-nulls"); @@ -407,15 +383,15 @@ public class Table extends AbstractSelect implements Action.Container, // If this is called befor the constructor is finished, it might be // uninitialized - LinkedList newVC = new LinkedList(); + final LinkedList newVC = new LinkedList(); for (int i = 0; i < visibleColumns.length; i++) { newVC.add(visibleColumns[i]); } // Removes alignments, icons and headers from hidden columns if (this.visibleColumns != null) { - for (Iterator i = this.visibleColumns.iterator(); i.hasNext();) { - Object col = i.next(); + for (final Iterator i = this.visibleColumns.iterator(); i.hasNext();) { + final Object col = i.next(); if (!newVC.contains(col)) { setColumnHeader(col, null); setColumnAlignment(col, null); @@ -448,9 +424,9 @@ public class Table extends AbstractSelect implements Action.Container, if (columnHeaders == null) { return null; } - String[] headers = new String[visibleColumns.size()]; + final String[] headers = new String[visibleColumns.size()]; int i = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext(); i++) { + for (final Iterator it = visibleColumns.iterator(); it.hasNext(); i++) { headers[i] = (String) columnHeaders.get(it.next()); } return headers; @@ -481,7 +457,7 @@ public class Table extends AbstractSelect implements Action.Container, this.columnHeaders.clear(); int i = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext() + for (final Iterator it = visibleColumns.iterator(); it.hasNext() && i < columnHeaders.length; i++) { this.columnHeaders.put(it.next(), columnHeaders[i]); } @@ -507,9 +483,9 @@ public class Table extends AbstractSelect implements Action.Container, if (columnIcons == null) { return null; } - Resource[] icons = new Resource[visibleColumns.size()]; + final Resource[] icons = new Resource[visibleColumns.size()]; int i = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext(); i++) { + for (final Iterator it = visibleColumns.iterator(); it.hasNext(); i++) { icons[i] = (Resource) columnIcons.get(it.next()); } @@ -540,7 +516,7 @@ public class Table extends AbstractSelect implements Action.Container, this.columnIcons.clear(); int i = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext() + for (final Iterator it = visibleColumns.iterator(); it.hasNext() && i < columnIcons.length; i++) { this.columnIcons.put(it.next(), columnIcons[i]); } @@ -571,9 +547,9 @@ public class Table extends AbstractSelect implements Action.Container, if (columnAlignments == null) { return null; } - String[] alignments = new String[visibleColumns.size()]; + final String[] alignments = new String[visibleColumns.size()]; int i = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext(); i++) { + for (final Iterator it = visibleColumns.iterator(); it.hasNext(); i++) { alignments[i++] = getColumnAlignment(it.next()); } @@ -607,7 +583,7 @@ public class Table extends AbstractSelect implements Action.Container, // Checks all alignments for (int i = 0; i < columnAlignments.length; i++) { - String a = columnAlignments[i]; + final String a = columnAlignments[i]; if (a != null && !a.equals(ALIGN_LEFT) && !a.equals(ALIGN_CENTER) && !a.equals(ALIGN_RIGHT)) { throw new IllegalArgumentException("Column " + i @@ -616,9 +592,9 @@ public class Table extends AbstractSelect implements Action.Container, } // Resets the alignments - HashMap newCA = new HashMap(); + final HashMap newCA = new HashMap(); int i = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext() + for (final Iterator it = visibleColumns.iterator(); it.hasNext() && i < columnAlignments.length; i++) { newCA.put(it.next(), columnAlignments[i]); } @@ -650,7 +626,7 @@ public class Table extends AbstractSelect implements Action.Container, * @return width of colun or -1 when value not set */ public int getColumnWidth(Object propertyId) { - Integer value = (Integer) columnWidths.get(propertyId); + final Integer value = (Integer) columnWidths.get(propertyId); if (value == null) { return -1; } @@ -699,7 +675,7 @@ public class Table extends AbstractSelect implements Action.Container, // Priorise index over id if indexes are supported if (items instanceof Container.Indexed) { - int index = getCurrentPageFirstItemIndex(); + final int index = getCurrentPageFirstItemIndex(); Object id = null; if (index >= 0 && index < size()) { id = ((Container.Indexed) items).getIdByIndex(index); @@ -730,7 +706,7 @@ public class Table extends AbstractSelect implements Action.Container, try { index = ((Container.Indexed) items) .indexOfId(currentPageFirstItemId); - } catch (ClassCastException e) { + } catch (final ClassCastException e) { // If the table item container does not have index, we have to // calculates the index by hand @@ -839,7 +815,7 @@ public class Table extends AbstractSelect implements Action.Container, * @return the specified column's alignment if it as one; null otherwise. */ public String getColumnAlignment(Object propertyId) { - String a = (String) columnAlignments.get(propertyId); + final String a = (String) columnAlignments.get(propertyId); return a == null ? ALIGN_LEFT : a; } @@ -973,7 +949,7 @@ public class Table extends AbstractSelect implements Action.Container, if (columnOrder == null || !isColumnReorderingAllowed()) { return; } - LinkedList newOrder = new LinkedList(); + final LinkedList newOrder = new LinkedList(); for (int i = 0; i < columnOrder.length; i++) { if (columnOrder[i] != null && visibleColumns.contains(columnOrder[i])) { @@ -981,8 +957,8 @@ public class Table extends AbstractSelect implements Action.Container, newOrder.add(columnOrder[i]); } } - for (Iterator it = visibleColumns.iterator(); it.hasNext();) { - Object columnId = it.next(); + for (final Iterator it = visibleColumns.iterator(); it.hasNext();) { + final Object columnId = it.next(); if (!newOrder.contains(columnId)) { newOrder.add(columnId); } @@ -1023,7 +999,7 @@ public class Table extends AbstractSelect implements Action.Container, try { currentPageFirstItemId = ((Container.Indexed) items) .getIdByIndex(newIndex); - } catch (IndexOutOfBoundsException e) { + } catch (final IndexOutOfBoundsException e) { currentPageFirstItemId = null; } currentPageFirstItemIndex = newIndex; @@ -1241,7 +1217,7 @@ public class Table extends AbstractSelect implements Action.Container, public Object addItem(Object[] cells, Object itemId) throws UnsupportedOperationException { - Object[] cols = getVisibleColumns(); + final Object[] cols = getVisibleColumns(); // Checks that a correct number of cells are given if (cells.length != cols.length) { @@ -1328,7 +1304,7 @@ public class Table extends AbstractSelect implements Action.Container, // Page start index if (variables.containsKey("firstvisible")) { - Integer value = (Integer) variables.get("firstvisible"); + final Integer value = (Integer) variables.get("firstvisible"); if (value != null) { setCurrentPageFirstItemIndex(value.intValue()); } @@ -1351,14 +1327,15 @@ public class Table extends AbstractSelect implements Action.Container, // Actions if (variables.containsKey("action")) { - StringTokenizer st = new StringTokenizer((String) variables + final StringTokenizer st = new StringTokenizer((String) variables .get("action"), ","); if (st.countTokens() == 2) { - Object itemId = itemIdMapper.get(st.nextToken()); - Action action = (Action) actionMapper.get(st.nextToken()); + final Object itemId = itemIdMapper.get(st.nextToken()); + final Action action = (Action) actionMapper.get(st.nextToken()); if (action != null && containsId(itemId) && actionHandlers != null) { - for (Iterator i = actionHandlers.iterator(); i.hasNext();) { + for (final Iterator i = actionHandlers.iterator(); i + .hasNext();) { ((Action.Handler) i.next()).handleAction(action, this, itemId); } @@ -1370,15 +1347,15 @@ public class Table extends AbstractSelect implements Action.Container, boolean doSort = false; if (!sortDisabled) { if (variables.containsKey("sortcolumn")) { - String colId = (String) variables.get("sortcolumn"); + final String colId = (String) variables.get("sortcolumn"); if (colId != null && !"".equals(colId) && !"null".equals(colId)) { - Object id = columnIdMap.get(colId); + final Object id = columnIdMap.get(colId); setSortContainerPropertyId(id); doSort = true; } } if (variables.containsKey("sortascending")) { - boolean state = ((Boolean) variables.get("sortascending")) + final boolean state = ((Boolean) variables.get("sortascending")) .booleanValue(); if (state != sortAscending) { setSortAscending(state); @@ -1395,27 +1372,30 @@ public class Table extends AbstractSelect implements Action.Container, if (isColumnCollapsingAllowed()) { if (variables.containsKey("collapsedcolumns")) { try { - Object[] ids = (Object[]) variables.get("collapsedcolumns"); - for (Iterator it = visibleColumns.iterator(); it.hasNext();) { + final Object[] ids = (Object[]) variables + .get("collapsedcolumns"); + for (final Iterator it = visibleColumns.iterator(); it + .hasNext();) { setColumnCollapsed(it.next(), false); } for (int i = 0; i < ids.length; i++) { setColumnCollapsed(columnIdMap.get(ids[i].toString()), true); } - } catch (Exception ignored) { + } catch (final Exception ignored) { } } } if (isColumnReorderingAllowed()) { if (variables.containsKey("columnorder")) { try { - Object[] ids = (Object[]) variables.get("columnorder"); + final Object[] ids = (Object[]) variables + .get("columnorder"); for (int i = 0; i < ids.length; i++) { ids[i] = columnIdMap.get(ids[i].toString()); } setColumnOrder(ids); - } catch (Exception ignored) { + } catch (final Exception ignored) { } } } @@ -1452,16 +1432,16 @@ public class Table extends AbstractSelect implements Action.Container, } // Initialize temps - Object[] colids = getVisibleColumns(); - int cols = colids.length; - int first = getCurrentPageFirstItemIndex(); + final Object[] colids = getVisibleColumns(); + final int cols = colids.length; + final int first = getCurrentPageFirstItemIndex(); int total = size(); - int pagelen = getPageLength(); - int colHeadMode = getColumnHeaderMode(); - boolean colheads = colHeadMode != COLUMN_HEADER_MODE_HIDDEN; - boolean rowheads = getRowHeaderMode() != ROW_HEADER_MODE_HIDDEN; - Object[][] cells = getVisibleCells(); - boolean iseditable = isEditable(); + final int pagelen = getPageLength(); + final int colHeadMode = getColumnHeaderMode(); + final boolean colheads = colHeadMode != COLUMN_HEADER_MODE_HIDDEN; + final boolean rowheads = getRowHeaderMode() != ROW_HEADER_MODE_HIDDEN; + final Object[][] cells = getVisibleCells(); + final boolean iseditable = isEditable(); int rows = cells[0].length; if (!isNullSelectionAllowed() && getNullSelectionItemId() != null @@ -1503,10 +1483,10 @@ public class Table extends AbstractSelect implements Action.Container, } // Visible column order - Collection sortables = getSortableContainerPropertyIds(); - ArrayList visibleColOrder = new ArrayList(); - for (Iterator it = visibleColumns.iterator(); it.hasNext();) { - Object columnId = it.next(); + final Collection sortables = getSortableContainerPropertyIds(); + final ArrayList visibleColOrder = new ArrayList(); + for (final Iterator it = visibleColumns.iterator(); it.hasNext();) { + final Object columnId = it.next(); if (!isColumnCollapsed(columnId)) { visibleColOrder.add(columnIdMap.key(columnId)); } @@ -1514,20 +1494,20 @@ public class Table extends AbstractSelect implements Action.Container, target.addAttribute("vcolorder", visibleColOrder.toArray()); // Rows - Set actionSet = new LinkedHashSet(); - boolean selectable = isSelectable(); - boolean[] iscomponent = new boolean[visibleColumns.size()]; + final Set actionSet = new LinkedHashSet(); + final boolean selectable = isSelectable(); + final boolean[] iscomponent = new boolean[visibleColumns.size()]; int iscomponentIndex = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext() + for (final Iterator it = visibleColumns.iterator(); it.hasNext() && iscomponentIndex < iscomponent.length;) { - Object columnId = it.next(); - Class colType = getType(columnId); + final Object columnId = it.next(); + final Class colType = getType(columnId); iscomponent[iscomponentIndex++] = colType != null && Component.class.isAssignableFrom(colType); } target.startTag("rows"); for (int i = 0; i < cells[0].length; i++) { - Object itemId = cells[CELL_ITEMID][i]; + final Object itemId = cells[CELL_ITEMID][i]; if (!isNullSelectionAllowed() && getNullSelectionItemId() != null && itemId == getNullSelectionItemId()) { @@ -1558,13 +1538,14 @@ public class Table extends AbstractSelect implements Action.Container, // Actions if (actionHandlers != null) { - ArrayList keys = new ArrayList(); - for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) { - Action[] aa = ((Action.Handler) ahi.next()).getActions( - itemId, this); + final ArrayList keys = new ArrayList(); + for (final Iterator ahi = actionHandlers.iterator(); ahi + .hasNext();) { + final Action[] aa = ((Action.Handler) ahi.next()) + .getActions(itemId, this); if (aa != null) { for (int ai = 0; ai < aa.length; ai++) { - String key = actionMapper.key(aa[ai]); + final String key = actionMapper.key(aa[ai]); actionSet.add(aa[ai]); keys.add(key); } @@ -1575,15 +1556,15 @@ public class Table extends AbstractSelect implements Action.Container, // cells int currentColumn = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext(); currentColumn++) { - Object columnId = it.next(); + for (final Iterator it = visibleColumns.iterator(); it.hasNext(); currentColumn++) { + final Object columnId = it.next(); if (columnId == null || isColumnCollapsed(columnId)) { continue; } if ((iscomponent[currentColumn] || iseditable) && Component.class.isInstance(cells[CELL_FIRSTCOL + currentColumn][i])) { - Component c = (Component) cells[CELL_FIRSTCOL + final Component c = (Component) cells[CELL_FIRSTCOL + currentColumn][i]; if (c == null) { target.addText(""); @@ -1630,8 +1611,8 @@ public class Table extends AbstractSelect implements Action.Container, if (!actionSet.isEmpty()) { target.addVariable(this, "action", ""); target.startTag("actions"); - for (Iterator it = actionSet.iterator(); it.hasNext();) { - Action a = (Action) it.next(); + for (final Iterator it = actionSet.iterator(); it.hasNext();) { + final Action a = (Action) it.next(); target.startTag("action"); if (a.getCaption() != null) { target.addAttribute("caption", a.getCaption()); @@ -1645,9 +1626,9 @@ public class Table extends AbstractSelect implements Action.Container, target.endTag("actions"); } if (columnReorderingAllowed) { - String[] colorder = new String[visibleColumns.size()]; + final String[] colorder = new String[visibleColumns.size()]; int i = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext() + for (final Iterator it = visibleColumns.iterator(); it.hasNext() && i < colorder.length;) { colorder[i++] = columnIdMap.key(it.next()); } @@ -1655,18 +1636,18 @@ public class Table extends AbstractSelect implements Action.Container, } // Available columns if (columnCollapsingAllowed) { - HashSet ccs = new HashSet(); - for (Iterator i = visibleColumns.iterator(); i.hasNext();) { - Object o = i.next(); + final HashSet ccs = new HashSet(); + for (final Iterator i = visibleColumns.iterator(); i.hasNext();) { + final Object o = i.next(); if (isColumnCollapsed(o)) { ccs.add(o); } } - String[] collapsedkeys = new String[ccs.size()]; + final String[] collapsedkeys = new String[ccs.size()]; int nextColumn = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext() + for (final Iterator it = visibleColumns.iterator(); it.hasNext() && nextColumn < collapsedkeys.length;) { - Object columnId = it.next(); + final Object columnId = it.next(); if (isColumnCollapsed(columnId)) { collapsedkeys[nextColumn++] = columnIdMap.key(columnId); } @@ -1675,12 +1656,12 @@ public class Table extends AbstractSelect implements Action.Container, } target.startTag("visiblecolumns"); int i = 0; - for (Iterator it = visibleColumns.iterator(); it.hasNext(); i++) { - Object columnId = it.next(); + for (final Iterator it = visibleColumns.iterator(); it.hasNext(); i++) { + final Object columnId = it.next(); if (columnId != null) { target.startTag("column"); target.addAttribute("cid", columnIdMap.key(columnId)); - String head = getColumnHeader(columnId); + final String head = getColumnHeader(columnId); target.addAttribute("caption", (head != null ? head : "")); if (isColumnCollapsed(columnId)) { target.addAttribute("collapsed", true); @@ -1732,7 +1713,7 @@ public class Table extends AbstractSelect implements Action.Container, if (listenedProperties == null) { listenedProperties = new LinkedList(); } else { - for (Iterator i = listenedProperties.iterator(); i.hasNext();) { + for (final Iterator i = listenedProperties.iterator(); i.hasNext();) { ((Property.ValueChangeNotifier) i.next()).removeListener(this); } } @@ -1741,16 +1722,16 @@ public class Table extends AbstractSelect implements Action.Container, if (visibleComponents == null) { visibleComponents = new LinkedList(); } else { - for (Iterator i = visibleComponents.iterator(); i.hasNext();) { + for (final Iterator i = visibleComponents.iterator(); i.hasNext();) { ((Component) i.next()).setParent(null); } visibleComponents.clear(); } // Collects the basic facts about the table page - Object[] colids = getVisibleColumns(); - int cols = colids.length; - int pagelen = getPageLength(); + final Object[] colids = getVisibleColumns(); + final int cols = colids.length; + final int pagelen = getPageLength(); int firstIndex = getCurrentPageFirstItemIndex(); int rows = size(); if (rows > 0 && firstIndex >= 0) { @@ -1791,8 +1772,8 @@ public class Table extends AbstractSelect implements Action.Container, } } - int headmode = getRowHeaderMode(); - boolean[] iscomponent = new boolean[cols]; + final int headmode = getRowHeaderMode(); + final boolean[] iscomponent = new boolean[cols]; for (int i = 0; i < cols; i++) { iscomponent[i] = Component.class .isAssignableFrom(getType(colids[i])); @@ -1816,7 +1797,7 @@ public class Table extends AbstractSelect implements Action.Container, if (cols > 0) { for (int j = 0; j < cols; j++) { Object value = null; - Property p = getContainerProperty(id, colids[j]); + final Property p = getContainerProperty(id, colids[j]); if (p != null) { if (p instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) p) @@ -1849,7 +1830,7 @@ public class Table extends AbstractSelect implements Action.Container, // Assures that all the rows of the cell-buffer are valid if (filledRows != cells[0].length) { - Object[][] temp = new Object[cells.length][filledRows]; + final Object[][] temp = new Object[cells.length][filledRows]; for (int i = 0; i < cells.length; i++) { for (int j = 0; j < filledRows; j++) { temp[i][j] = cells[i][j]; @@ -1886,8 +1867,8 @@ public class Table extends AbstractSelect implements Action.Container, protected Object getPropertyValue(Object rowId, Object colId, Property property) { if (isEditable() && fieldFactory != null) { - Field f = fieldFactory.createField(getContainerDataSource(), rowId, - colId, this); + final Field f = fieldFactory.createField(getContainerDataSource(), + rowId, colId, this); if (f != null) { f.setPropertyDataSource(property); return f; @@ -1984,7 +1965,7 @@ public class Table extends AbstractSelect implements Action.Container, super.attach(); if (visibleComponents != null) { - for (Iterator i = visibleComponents.iterator(); i.hasNext();) { + for (final Iterator i = visibleComponents.iterator(); i.hasNext();) { ((Component) i.next()).attach(); } } @@ -1999,7 +1980,7 @@ public class Table extends AbstractSelect implements Action.Container, super.detach(); if (visibleComponents != null) { - for (Iterator i = visibleComponents.iterator(); i.hasNext();) { + for (final Iterator i = visibleComponents.iterator(); i.hasNext();) { ((Component) i.next()).detach(); } } @@ -2022,8 +2003,9 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.itmill.toolkit.data.Container#removeItem(Object) */ public boolean removeItem(Object itemId) { - Object nextItemId = ((Container.Ordered) items).nextItemId(itemId); - boolean ret = super.removeItem(itemId); + final Object nextItemId = ((Container.Ordered) items) + .nextItemId(itemId); + final boolean ret = super.removeItem(itemId); if (ret && (itemId != null) && (itemId.equals(currentPageFirstItemId))) { currentPageFirstItemId = nextItemId; } @@ -2111,9 +2093,9 @@ public class Table extends AbstractSelect implements Action.Container, */ public Collection getVisibleItemIds() { - LinkedList visible = new LinkedList(); + final LinkedList visible = new LinkedList(); - Object[][] cells = getVisibleCells(); + final Object[][] cells = getVisibleCells(); for (int i = 0; i < cells[CELL_ITEMID].length; i++) { visible.add(cells[CELL_ITEMID][i]); } @@ -2334,9 +2316,9 @@ public class Table extends AbstractSelect implements Action.Container, */ public void sort(Object[] propertyId, boolean[] ascending) throws UnsupportedOperationException { - Container c = getContainerDataSource(); + final Container c = getContainerDataSource(); if (c instanceof Container.Sortable) { - int pageIndex = getCurrentPageFirstItemIndex(); + final int pageIndex = getCurrentPageFirstItemIndex(); ((Container.Sortable) c).sort(propertyId, ascending); setCurrentPageFirstItemIndex(pageIndex); } else if (c != null) { @@ -2366,7 +2348,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.itmill.toolkit.data.Container.Sortable#getSortableContainerPropertyIds() */ public Collection getSortableContainerPropertyIds() { - Container c = getContainerDataSource(); + final Container c = getContainerDataSource(); if (c instanceof Container.Sortable && !isSortDisabled()) { return ((Container.Sortable) c).getSortableContainerPropertyIds(); } else { diff --git a/src/com/itmill/toolkit/ui/TextField.java b/src/com/itmill/toolkit/ui/TextField.java index c90af1058e..056b75a155 100644 --- a/src/com/itmill/toolkit/ui/TextField.java +++ b/src/com/itmill/toolkit/ui/TextField.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.ui; @@ -174,8 +150,8 @@ public class TextField extends AbstractField { } // Adds the number of column and rows - int c = getColumns(); - int r = getRows(); + final int c = getColumns(); + final int r = getRows(); if (c != 0) { target.addAttribute("cols", String.valueOf(c)); } @@ -208,11 +184,11 @@ public class TextField extends AbstractField { * @see Format */ protected String getFormattedValue() { - Object value = getValue(); + final Object value = getValue(); if (format != null && value != null) { try { return format.format(value); - } catch (IllegalArgumentException ignored) { + } catch (final IllegalArgumentException ignored) { // Ignored exception } } @@ -243,7 +219,7 @@ public class TextField extends AbstractField { // Only do the setting if the string representation of the value // has been updated String newValue = (String) variables.get("text"); - String oldValue = getFormattedValue(); + final String oldValue = getFormattedValue(); if (newValue != null && (oldValue == null || isNullSettingAllowed()) && newValue.equals(getNullRepresentation())) { diff --git a/src/com/itmill/toolkit/ui/Tree.java b/src/com/itmill/toolkit/ui/Tree.java index 2042d4b312..9ef41c1567 100644 --- a/src/com/itmill/toolkit/ui/Tree.java +++ b/src/com/itmill/toolkit/ui/Tree.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.ui; @@ -73,7 +49,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, "nodeExpand", new Class[] { ExpandEvent.class }); COLLAPSE_METHOD = CollapseListener.class.getDeclaredMethod( "nodeCollapse", new Class[] { CollapseEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen e.printStackTrace(); throw new java.lang.RuntimeException( @@ -231,12 +207,12 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, boolean result = true; // Initial stack - Stack todo = new Stack(); + final Stack todo = new Stack(); todo.add(startItemId); // Expands recursively while (!todo.isEmpty()) { - Object id = todo.pop(); + final Object id = todo.pop(); if (areChildrenAllowed(id) && !expandItem(id, false)) { result = false; } @@ -284,12 +260,12 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, boolean result = true; // Initial stack - Stack todo = new Stack(); + final Stack todo = new Stack(); todo.add(startItemId); // Collapse recursively while (!todo.isEmpty()) { - Object id = todo.pop(); + final Object id = todo.pop(); if (areChildrenAllowed(id) && !collapseItem(id)) { result = false; } @@ -360,9 +336,9 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Collapses the nodes if (variables.containsKey("collapse")) { - String[] keys = (String[]) variables.get("collapse"); + final String[] keys = (String[]) variables.get("collapse"); for (int i = 0; i < keys.length; i++) { - Object id = itemIdMapper.get(keys[i]); + final Object id = itemIdMapper.get(keys[i]); if (id != null && isExpanded(id)) { expanded.remove(id); fireCollapseEvent(id); @@ -376,9 +352,9 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (variables.containsKey("requestChildTree")) { sendChildTree = true; } - String[] keys = (String[]) variables.get("expand"); + final String[] keys = (String[]) variables.get("expand"); for (int i = 0; i < keys.length; i++) { - Object id = itemIdMapper.get(keys[i]); + final Object id = itemIdMapper.get(keys[i]); if (id != null) { expandItem(id, sendChildTree); } @@ -391,14 +367,15 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Actions if (variables.containsKey("action")) { - StringTokenizer st = new StringTokenizer((String) variables + final StringTokenizer st = new StringTokenizer((String) variables .get("action"), ","); if (st.countTokens() == 2) { - Object itemId = itemIdMapper.get(st.nextToken()); - Action action = (Action) actionMapper.get(st.nextToken()); + final Object itemId = itemIdMapper.get(st.nextToken()); + final Action action = (Action) actionMapper.get(st.nextToken()); if (action != null && containsId(itemId) && actionHandlers != null) { - for (Iterator i = actionHandlers.iterator(); i.hasNext();) { + for (final Iterator i = actionHandlers.iterator(); i + .hasNext();) { ((Action.Handler) i.next()).handleAction(action, this, itemId); } @@ -448,7 +425,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } // Initialize variables - Set actionSet = new LinkedHashSet(); + final Set actionSet = new LinkedHashSet(); String[] selectedKeys; if (isMultiSelect()) { selectedKeys = new String[((Set) getValue()).size()]; @@ -456,10 +433,10 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, selectedKeys = new String[(getValue() == null ? 0 : 1)]; } int keyIndex = 0; - LinkedList expandedKeys = new LinkedList(); + final LinkedList expandedKeys = new LinkedList(); // Iterates through hierarchical tree using a stack of iterators - Stack iteratorStack = new Stack(); + final Stack iteratorStack = new Stack(); Collection ids; if (partialUpdate) { ids = getChildren(expandedItemId); @@ -474,7 +451,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, while (!iteratorStack.isEmpty()) { // Gets the iterator for current tree level - Iterator i = (Iterator) iteratorStack.peek(); + final Iterator i = (Iterator) iteratorStack.peek(); // If the level is finished, back to previous tree level if (!i.hasNext()) { @@ -490,10 +467,10 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Adds the item on current level else { - Object itemId = i.next(); + final Object itemId = i.next(); // Starts the item / node - boolean isNode = areChildrenAllowed(itemId) + final boolean isNode = areChildrenAllowed(itemId) && hasChildren(itemId); if (isNode) { target.startTag("node"); @@ -503,11 +480,11 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Adds the attributes target.addAttribute("caption", getItemCaption(itemId)); - Resource icon = getItemIcon(itemId); + final Resource icon = getItemIcon(itemId); if (icon != null) { target.addAttribute("icon", getItemIcon(itemId)); } - String key = itemIdMapper.key(itemId); + final String key = itemIdMapper.key(itemId); target.addAttribute("key", key); if (isSelected(itemId)) { target.addAttribute("selected", true); @@ -520,14 +497,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Actions if (actionHandlers != null) { - ArrayList keys = new ArrayList(); - for (Iterator ahi = actionHandlers.iterator(); ahi + final ArrayList keys = new ArrayList(); + for (final Iterator ahi = actionHandlers.iterator(); ahi .hasNext();) { - Action[] aa = ((Action.Handler) ahi.next()).getActions( - itemId, this); + final Action[] aa = ((Action.Handler) ahi.next()) + .getActions(itemId, this); if (aa != null) { for (int ai = 0; ai < aa.length; ai++) { - String akey = actionMapper.key(aa[ai]); + final String akey = actionMapper.key(aa[ai]); actionSet.add(aa[ai]); keys.add(akey); } @@ -554,8 +531,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (!actionSet.isEmpty()) { target.addVariable(this, "action", ""); target.startTag("actions"); - for (Iterator i = actionSet.iterator(); i.hasNext();) { - Action a = (Action) i.next(); + for (final Iterator i = actionSet.iterator(); i.hasNext();) { + final Action a = (Action) i.next(); target.startTag("action"); if (a.getCaption() != null) { target.addAttribute("caption", a.getCaption()); @@ -648,8 +625,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * boolean) */ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) { - boolean success = ((Container.Hierarchical) items).setChildrenAllowed( - itemId, areChildrenAllowed); + final boolean success = ((Container.Hierarchical) items) + .setChildrenAllowed(itemId, areChildrenAllowed); if (success) { fireValueChange(false); } @@ -663,8 +640,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * Object) */ public boolean setParent(Object itemId, Object newParentId) { - boolean success = ((Container.Hierarchical) items).setParent(itemId, - newParentId); + final boolean success = ((Container.Hierarchical) items).setParent( + itemId, newParentId); if (success) { requestRepaint(); } @@ -923,18 +900,18 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public Collection getVisibleItemIds() { - LinkedList visible = new LinkedList(); + final LinkedList visible = new LinkedList(); // Iterates trough hierarchical tree using a stack of iterators - Stack iteratorStack = new Stack(); - Collection ids = rootItemIds(); + final Stack iteratorStack = new Stack(); + final Collection ids = rootItemIds(); if (ids != null) { iteratorStack.push(ids.iterator()); } while (!iteratorStack.isEmpty()) { // Gets the iterator for current tree level - Iterator i = (Iterator) iteratorStack.peek(); + final Iterator i = (Iterator) iteratorStack.peek(); // If the level is finished, back to previous tree level if (!i.hasNext()) { @@ -945,7 +922,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Adds the item on current level else { - Object itemId = i.next(); + final Object itemId = i.next(); visible.add(itemId); diff --git a/src/com/itmill/toolkit/ui/TwinColSelect.java b/src/com/itmill/toolkit/ui/TwinColSelect.java index 3a77d868f4..2799bb7c0e 100644 --- a/src/com/itmill/toolkit/ui/TwinColSelect.java +++ b/src/com/itmill/toolkit/ui/TwinColSelect.java @@ -1,6 +1,7 @@ -/** - * +/* +@ITMillApache2LicenseForJavaFiles@ */ + package com.itmill.toolkit.ui; import java.util.Collection; diff --git a/src/com/itmill/toolkit/ui/Upload.java b/src/com/itmill/toolkit/ui/Upload.java index 998178d0d2..5604465b75 100644 --- a/src/com/itmill/toolkit/ui/Upload.java +++ b/src/com/itmill/toolkit/ui/Upload.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.ui; @@ -56,7 +32,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { /** * Should the field be focused on next repaint? */ - private boolean focus = false; + private final boolean focus = false; /** * The tab order number of this field. @@ -114,19 +90,19 @@ public class Upload extends AbstractComponent implements Component.Focusable { } // Gets file properties - String filename = upload.getContentName(); - String type = upload.getContentType(); + final String filename = upload.getContentName(); + final String type = upload.getContentType(); fireStarted(filename, type); // Gets the output target stream - OutputStream out = receiver.receiveUpload(filename, type); + final OutputStream out = receiver.receiveUpload(filename, type); if (out == null) { throw new RuntimeException( "Error getting outputstream from upload receiver"); } - InputStream in = upload.getStream(); + final InputStream in = upload.getStream(); if (null == in) { // No file, for instance non-existent filename in html upload @@ -135,7 +111,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { return; } - byte buffer[] = new byte[BUFFER_SIZE]; + final byte buffer[] = new byte[BUFFER_SIZE]; int bytesRead = 0; totalBytes = 0; try { @@ -155,7 +131,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { endUpload(); requestRepaint(); - } catch (IOException e) { + } catch (final IOException e) { // Download interrupted fireUploadInterrupted(filename, type, totalBytes); @@ -246,7 +222,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { UPLOAD_SUCCEEDED_METHOD = SucceededListener.class .getDeclaredMethod("uploadSucceeded", new Class[] { SucceededEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException("Internal error"); } @@ -271,17 +247,17 @@ public class Upload extends AbstractComponent implements Component.Focusable { /** * Length of the received file. */ - private long length; + private final long length; /** * MIME type of the received file. */ - private String type; + private final String type; /** * Received file name. */ - private String filename; + private final String filename; /** * @@ -413,8 +389,8 @@ public class Upload extends AbstractComponent implements Component.Focusable { * Serial generated by eclipse. */ private static final long serialVersionUID = -3984393770487403525L; - private String filename; - private String type; + private final String filename; + private final String type; /** * @@ -687,7 +663,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @see com.itmill.toolkit.ui.Component.Focusable#focus() */ public void focus() { - Window w = getWindow(); + final Window w = getWindow(); if (w != null) { w.setFocusedComponent(this); } diff --git a/src/com/itmill/toolkit/ui/Window.java b/src/com/itmill/toolkit/ui/Window.java index e104c5881d..92ed8db5ad 100644 --- a/src/com/itmill/toolkit/ui/Window.java +++ b/src/com/itmill/toolkit/ui/Window.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.ui; @@ -349,7 +325,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { handlers = uriHandlerList.toArray(); } for (int i = 0; i < handlers.length; i++) { - DownloadStream ds = ((URIHandler) handlers[i]).handleURI( + final DownloadStream ds = ((URIHandler) handlers[i]).handleURI( context, relativeUri); if (ds != null) { if (result != null) { @@ -477,11 +453,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler { throws PaintException { // Sets the window name - String name = getName(); + final String name = getName(); target.addAttribute("name", name == null ? "" : name); // Sets the window theme - String theme = getTheme(); + final String theme = getTheme(); target.addAttribute("theme", theme == null ? "" : theme); if (modal) { @@ -497,7 +473,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { // Open requested resource synchronized (openList) { if (!openList.isEmpty()) { - for (Iterator i = openList.iterator(); i.hasNext();) { + for (final Iterator i = openList.iterator(); i.hasNext();) { ((OpenResource) i.next()).paintContent(target); } openList.clear(); @@ -527,16 +503,16 @@ public class Window extends Panel implements URIHandler, ParameterHandler { } // Paint subwindows - for (Iterator i = subwindows.iterator(); i.hasNext();) { - Window w = (Window) i.next(); + for (final Iterator i = subwindows.iterator(); i.hasNext();) { + final Window w = (Window) i.next(); w.paint(target); } // Paint notifications if (notifications != null) { target.startTag("notifications"); - for (Iterator it = notifications.iterator(); it.hasNext();) { - Notification n = (Notification) it.next(); + for (final Iterator it = notifications.iterator(); it.hasNext();) { + final Notification n = (Notification) it.next(); target.startTag("notification"); if (n.getCaption() != null) { target.addAttribute("caption", n.getCaption()); @@ -636,7 +612,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { try { return new URL(application.getURL(), getName() + "/"); - } catch (MalformedURLException e) { + } catch (final MalformedURLException e) { throw new RuntimeException("Internal problem, please report"); } } @@ -858,42 +834,42 @@ public class Window extends Panel implements URIHandler, ParameterHandler { super.changeVariables(source, variables); // Gets the focused component - String focusedId = (String) variables.get("focused"); + final String focusedId = (String) variables.get("focused"); if (focusedId != null) { try { - long id = Long.parseLong(focusedId); + final long id = Long.parseLong(focusedId); focusedComponent = Window.getFocusableById(id); - } catch (NumberFormatException ignored) { + } catch (final NumberFormatException ignored) { // We ignore invalid focusable ids } } // Positioning - Integer positionx = (Integer) variables.get("positionx"); + final Integer positionx = (Integer) variables.get("positionx"); if (positionx != null) { - int x = positionx.intValue(); + final int x = positionx.intValue(); setPositionX(x < 0 ? -1 : x); } - Integer positiony = (Integer) variables.get("positiony"); + final Integer positiony = (Integer) variables.get("positiony"); if (positiony != null) { - int y = positiony.intValue(); + final int y = positiony.intValue(); setPositionY(y < 0 ? -1 : y); } // Scroll position - Integer scrolltop = (Integer) variables.get("scrolltop"); + final Integer scrolltop = (Integer) variables.get("scrolltop"); if (scrolltop != null) { - int top = scrolltop.intValue(); + final int top = scrolltop.intValue(); setScrollTop(top < 0 ? 0 : top); } - Integer scrollleft = (Integer) variables.get("scrollleft"); + final Integer scrollleft = (Integer) variables.get("scrollleft"); if (scrollleft != null) { - int left = scrollleft.intValue(); + final int left = scrollleft.intValue(); setScrollLeft(left < 0 ? 0 : left); } // Closing - Boolean close = (Boolean) variables.get("close"); + final Boolean close = (Boolean) variables.get("close"); if (close != null && close.booleanValue()) { setVisible(false); fireClose(); @@ -916,7 +892,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * the Focused component or null if none is focused. */ public void setFocusedComponent(Component.Focusable focusable) { - Application app = getApplication(); + final Application app = getApplication(); if (app != null) { app.setFocusedComponent(focusable); focusedComponent = focusable; @@ -936,8 +912,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * the focused component. */ public static long getNewFocusableId(Component.Focusable focusable) { - long newId = ++lastUsedFocusableId; - WeakReference ref = new WeakReference(focusable); + final long newId = ++lastUsedFocusableId; + final WeakReference ref = new WeakReference(focusable); focusableComponents.put(new Long(newId), ref); return newId; } @@ -950,10 +926,10 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * @return the focusable Id. */ public static Component.Focusable getFocusableById(long focusableId) { - WeakReference ref = (WeakReference) focusableComponents.get(new Long( - focusableId)); + final WeakReference ref = (WeakReference) focusableComponents + .get(new Long(focusableId)); if (ref != null) { - Object o = ref.get(); + final Object o = ref.get(); if (o != null) { return (Component.Focusable) o; } @@ -968,8 +944,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * the focusable Id to remove. */ public static void removeFocusableId(long focusableId) { - Long id = new Long(focusableId); - WeakReference ref = (WeakReference) focusableComponents.get(id); + final Long id = new Long(focusableId); + final WeakReference ref = (WeakReference) focusableComponents.get(id); ref.clear(); focusableComponents.remove(id); } @@ -1033,7 +1009,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { try { WINDOW_CLOSE_METHOD = CloseListener.class.getDeclaredMethod( "windowClose", new Class[] { CloseEvent.class }); - } catch (java.lang.NoSuchMethodException e) { + } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException(); } |