Cleanup performed Organized imports Format svn changeset:3162/svn branch:trunktags/6.7.0.beta1
@@ -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; | |||
} |
@@ -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) { |
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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); | |||
} |
@@ -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) { | |||
} | |||
} |
@@ -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); |
@@ -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) { |
@@ -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. |
@@ -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); | |||
} |
@@ -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) { |
@@ -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]) |
@@ -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]) |
@@ -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) { |
@@ -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; | |||
} |
@@ -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); |
@@ -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; | |||
@@ -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; |
@@ -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)); |
@@ -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); | |||
} |
@@ -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); |
@@ -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("+")) { |
@@ -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); | |||
@@ -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); |
@@ -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); | |||
/* |
@@ -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); |
@@ -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( |
@@ -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); |
@@ -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( |
@@ -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 |
@@ -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) { |
@@ -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(); | |||
} | |||
} |
@@ -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(); | |||
} | |||
@@ -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 |
@@ -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); | |||
} | |||
} |
@@ -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."); |
@@ -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); | |||
} |
@@ -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()); | |||
} |
@@ -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); |
@@ -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"); |
@@ -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"; | |||
} |
@@ -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); |
@@ -1,3 +1,7 @@ | |||
/* | |||
@ITMillApache2LicenseForJavaFiles@ | |||
*/ | |||
package com.itmill.toolkit.demo.colorpicker.gwt.client.ui; | |||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; |
@@ -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: " |
@@ -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); |
@@ -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); |
@@ -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)); |
@@ -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; | |||
} | |||
} |
@@ -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 |
@@ -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")); |
@@ -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 |
@@ -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 |
@@ -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); | |||
@@ -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); |
@@ -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); |
@@ -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); |
@@ -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( |
@@ -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(); | |||
} | |||
/* |
@@ -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()); |
@@ -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()); |
@@ -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 |
@@ -1,3 +1,7 @@ | |||
/* | |||
@ITMillApache2LicenseForJavaFiles@ | |||
*/ | |||
package com.itmill.toolkit.demo.reservation; | |||
public class ResourceNotAvailableException extends Exception { |
@@ -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 { |
@@ -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); | |||
} | |||
@@ -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)) { |
@@ -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); |
@@ -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 |
@@ -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; |
@@ -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; |
@@ -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")); |
@@ -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; | |||
@@ -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); | |||
} |
@@ -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; | |||
@@ -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; | |||
@@ -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); |
@@ -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); | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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) { | |||
} | |||
} | |||
} |
@@ -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; | |||
@@ -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; | |||
} |
@@ -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; | |||
@@ -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()); |
@@ -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 += ","; | |||
} |
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
} |
@@ -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); |
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; |