-/* *************************************************************************
-
- 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;
/**
* Mapping from window name to window instance.
*/
- private Hashtable windows = new Hashtable();
+ private final Hashtable windows = new Hashtable();
/**
* Main window of the application.
/**
* 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;
}
// Gets the window by name
- Window window = (Window) windows.get(name);
+ final Window window = (Window) windows.get(name);
return window;
}
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);
}
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);
}
* 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])
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))) {
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();
}
}
}
// Generate key
- String key = String.valueOf(++lastResourceKeyNumber);
+ final String key = String.valueOf(++lastResourceKeyNumber);
// Add the resource to mappings
resourceKeyMap.put(resource, key);
* 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);
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 {
// Resolves the prefix
String prefix = relativeUri;
- int index = relativeUri.indexOf('/');
+ final int index = relativeUri.indexOf('/');
if (index >= 0) {
prefix = relativeUri.substring(0, index);
}
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();
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;
}
}
/**
* 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.
*/
private static final long serialVersionUID = 3544669568644691769L;
- private Window window;
+ private final Window window;
/**
* Creates a event.
*/
private static final long serialVersionUID = 3977578104367822392L;
- private Window window;
+ private final Window window;
/**
* Creates a event.
// 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 {
* @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;
}
-/* *************************************************************************
-
- 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;
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 = {};
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) {
/* 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) {
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
target.addAttribute("level", "error");
// Error message
- String message = getLocalizedMessage();
+ final String message = getLocalizedMessage();
if (message != null) {
target.addText(message);
}
-/* *************************************************************************
-
- 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;
/**
* The bean which this Item is based on.
*/
- private Object bean;
+ private final Object bean;
/**
* <p>
// 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) {
}
}
// 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) {
}
}
-/* *************************************************************************
-
- 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;
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;
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);
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);
}
return ((Container.Hierarchical) container).getChildren(itemId);
}
- Collection c = (Collection) children.get(itemId);
+ final Collection c = (Collection) children.get(itemId);
if (c == null) {
return null;
}
}
// 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)
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()) {
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()) {
*/
public Object addItem() throws UnsupportedOperationException {
- Object id = container.addItem();
+ final Object id = container.addItem();
if (id != null) {
addToHierarchyWrapper(id);
}
*/
public Item addItem(Object itemId) throws UnsupportedOperationException {
- Item item = container.addItem(itemId);
+ final Item item = container.addItem(itemId);
if (item != null) {
addToHierarchyWrapper(itemId);
}
*/
public boolean removeAllItems() throws UnsupportedOperationException {
- boolean success = container.removeAllItems();
+ final boolean success = container.removeAllItems();
if (success) {
roots.clear();
public boolean removeItem(Object itemId)
throws UnsupportedOperationException {
- boolean success = container.removeItem(itemId);
+ final boolean success = container.removeItem(itemId);
if (success) {
removeFromHierarchyWrapper(itemId);
-/* *************************************************************************
-
- 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;
/**
* The wrapped container
*/
- private Container container;
+ private final Container container;
/**
* Ordering information, ie. the mapping from Item ID to the next item ID
*/
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;
}
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) {
}
// 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);
}
*/
public Object addItem() throws UnsupportedOperationException {
- Object id = container.addItem();
+ final Object id = container.addItem();
if (id != null) {
addToOrderWrapper(id);
}
* 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);
}
* 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();
public boolean removeItem(Object itemId)
throws UnsupportedOperationException {
- boolean success = container.removeItem(itemId);
+ final boolean success = container.removeItem(itemId);
if (success) {
removeFromOrderWrapper(itemId);
}
}
// 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) {
}
// 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) {
-/* *************************************************************************
-
- 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;
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) {
}
}
*/
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];
}
return Collections.unmodifiableCollection(new LinkedList());
}
- List l = Arrays.asList(f);
+ final List l = Arrays.asList(f);
Collections.sort(l);
return Collections.unmodifiableCollection(l);
return Collections.unmodifiableCollection(new LinkedList());
}
- List l = Arrays.asList(f);
+ final List l = Arrays.asList(f);
Collections.sort(l);
return Collections.unmodifiableCollection(l);
try {
val |= ((File) itemId).getCanonicalPath().startsWith(
roots[i].getCanonicalPath());
- } catch (IOException e) {
+ } catch (final IOException e) {
// Exception ignored
}
} 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 {
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]);
}
return Collections.unmodifiableCollection(new LinkedList());
}
- List l = Arrays.asList(f);
+ final List l = Arrays.asList(f);
Collections.sort(l);
return Collections.unmodifiableCollection(l);
}
/**
* The wrapped file.
*/
- private File file;
+ private final File file;
/**
* Constructs a FileItem from a existing file.
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);
}
*/
public class FileExtensionFilter implements FilenameFilter {
- private String filter;
+ private final String filter;
/**
* Constructs a new FileExtensionFilter using given extension.
-/* *************************************************************************
-
- 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;
/**
* 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
* interface.
*/
public Collection getChildren(Object itemId) {
- Collection c = (Collection) children.get(itemId);
+ final Collection c = (Collection) children.get(itemId);
if (c == null) {
return null;
}
}
// 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)
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()) {
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()) {
* @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);
}
* @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);
}
* @see com.itmill.toolkit.data.Container#removeAllItems()
*/
public boolean removeAllItems() {
- boolean success = super.removeAllItems();
+ final boolean success = super.removeAllItems();
if (success) {
roots.clear();
* @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);
}
-/* *************************************************************************
-
- 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;
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());
}
}
// 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);
}
public Object addItem() {
// Creates a new id
- Object id = new Object();
+ final Object id = new Object();
// Adds the Item into container
addItem(id);
// 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);
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);
}
return filteredItemIds.iterator().next();
}
return itemIds.get(0);
- } catch (IndexOutOfBoundsException e) {
- } catch (NoSuchElementException e) {
+ } catch (final IndexOutOfBoundsException e) {
+ } catch (final NoSuchElementException e) {
}
return null;
}
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();
return last;
}
return itemIds.get(itemIds.size() - 1);
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
}
return null;
}
if (!filteredItemIds.contains(itemId)) {
return null;
}
- Iterator i = filteredItemIds.iterator();
+ final Iterator i = filteredItemIds.iterator();
if (itemId == null) {
return null;
}
}
try {
return itemIds.get(itemIds.indexOf(itemId) + 1);
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
return null;
}
}
if (!filteredItemIds.contains(itemId)) {
return null;
}
- Iterator i = filteredItemIds.iterator();
+ final Iterator i = filteredItemIds.iterator();
if (itemId == null) {
return null;
}
}
try {
return itemIds.get(itemIds.indexOf(itemId) - 1);
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
return null;
}
}
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;
}
}
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));
}
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();
}
}
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;
}
}
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);
// 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);
// 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);
}
*/
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])
*/
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])
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);
/**
* 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
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 += " ";
|| !obj.getClass().equals(IndexedContainerItem.class)) {
return false;
}
- IndexedContainerItem li = (IndexedContainerItem) obj;
+ final IndexedContainerItem li = (IndexedContainerItem) obj;
return getHost() == li.getHost() && itemId.equals(li.itemId);
}
/**
* 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
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) {
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 "
* the Property
*/
public String toString() {
- Object value = getValue();
+ final Object value = getValue();
if (value == null) {
return null;
}
|| !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);
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]);
*/
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);
}
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;
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;
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());
}
}
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
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
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();
}
}
// 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);
}
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) {
-/* *************************************************************************
-
- 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;
/**
* 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.
*/
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);
}
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");
}
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
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;
}
// 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
}
// 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
public Object getValue() {
try {
return getMethod.invoke(instance, getArgs);
- } catch (Throwable e) {
+ } catch (final Throwable e) {
throw new MethodProperty.MethodException(e);
}
}
* @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;
}
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);
}
} 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);
}
}
* 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 {
*/
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])
-/* *************************************************************************
-
- 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;
/**
* Data type of the Property's value.
*/
- private Class type;
+ private final Class type;
/**
* Internal list of registered value change listeners.
* ObjectProperty
*/
public String toString() {
- Object value = getValue();
+ final Object value = getValue();
if (value != null) {
return value.toString();
} else {
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);
}
}
*/
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);
*/
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])
-/* *************************************************************************
-
- 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;
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 += " ";
*/
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])
*/
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
return false;
}
- PropertysetItem other = (PropertysetItem) obj;
+ final PropertysetItem other = (PropertysetItem) obj;
if (other.list != list) {
if (other.list == null) {
-/* *************************************************************************
-
- 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;
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;
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());
}
* @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));
}
try {
result.absolute(((Integer) itemId).intValue());
value = result.getObject((String) propertyId);
- } catch (Exception e) {
+ } catch (final Exception e) {
return null;
}
if (!(id instanceof Integer)) {
return false;
}
- int i = ((Integer) id).intValue();
+ final int i = ((Integer) id).intValue();
if (i < 1) {
return false;
}
if (size < 1 || !(id instanceof Integer)) {
return null;
}
- int i = ((Integer) id).intValue();
+ final int i = ((Integer) id).intValue();
if (i >= size) {
return null;
}
if (size < 1 || !(id instanceof Integer)) {
return null;
}
- int i = ((Integer) id).intValue();
+ final int i = ((Integer) id).intValue();
if (i <= 1) {
return null;
}
public void finalize() {
try {
close();
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
}
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;
}
-/* *************************************************************************
-
- 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;
/**
* List of contained validators.
*/
- private LinkedList validators = new LinkedList();
+ private final LinkedList validators = new LinkedList();
/**
* Error message.
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;
}
if (first == null) {
return;
}
- String em = getErrorMessage();
+ final String em = getErrorMessage();
if (em != null) {
throw new Validator.InvalidValueException(em);
} else {
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;
}
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;
}
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);
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
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);
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;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
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
}
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));
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.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
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);
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));
}
// (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);
}
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo;\r
\r
import com.itmill.toolkit.terminal.PaintException;\r
\r
public void init() {\r
\r
- Window main = new Window("Client-side caching example");\r
+ final Window main = new Window("Client-side caching example");\r
setMainWindow(main);\r
\r
setTheme("example");\r
\r
- TabSheet ts = new TabSheet();\r
+ final TabSheet ts = new TabSheet();\r
main.addComponent(ts);\r
\r
Layout layout = new OrderedLayout();\r
public void paintContent(PaintTarget target) throws PaintException {\r
try {\r
Thread.sleep(3000);\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
// IGNORED\r
}\r
super.paintContent(target);\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.ui.Button;
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));
// 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);
}
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("+")) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.ui.Button;
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
// 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);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.ui.OrderedLayout;
* - 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))]
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))]
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);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.ui.Label;
* - 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);
/*
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import java.util.Date;
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);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.terminal.ClassResource;
* 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);
//
// Create vertical ordered layout
//
- OrderedLayout layoutB = new OrderedLayout(
+ final OrderedLayout layoutB = new OrderedLayout(
OrderedLayout.ORIENTATION_VERTICAL);
// Add 4 panels
fillLayout(layoutB, 4);
//
// 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);
//
// 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);
}
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(
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.ui.Button;
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);
"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);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import java.net.MalformedURLException;
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);
.currentTimeMillis()
+ "/")),
null);
- } catch (MalformedURLException e) {
+ } catch (final MalformedURLException e) {
}
}
}));
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(
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import com.itmill.toolkit.data.Item;
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);
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
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import java.net.URL;
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;
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");
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);
*/
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) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import java.sql.SQLException;
+ " 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
// 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
// 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();
}
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import java.sql.SQLException;
* 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);
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();
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import java.sql.SQLException;
+ " 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
+ "<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);
// 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
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import java.io.File;
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
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);
* 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());
* 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) {
// no, childrens therefore do not exists
tree.setChildrenAllowed(path, false);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new RuntimeException(e);
}
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
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;
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);
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);
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.
// 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.");
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
//
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());
// 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);
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() {
// 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);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo;
import java.util.HashMap;
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());
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.colorpicker;
import java.util.Map;
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);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.colorpicker;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
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");
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.colorpicker.gwt.client;\r
\r
import com.google.gwt.user.client.ui.Widget;\r
public class ColorPickerWidgetSet extends DefaultWidgetSet {\r
/** Creates a widget according to its class name. */\r
public Widget createWidget(UIDL uidl) {\r
- String className = resolveWidgetTypeName(uidl);\r
+ final String className = resolveWidgetTypeName(uidl);\r
if ("com.itmill.toolkit.demo.colorpicker.gwt.client.ui.IColorPicker"\r
.equals(className)) {\r
return new IColorPicker();\r
\r
/** Resolves UIDL tag name to class name. */\r
protected String resolveWidgetTypeName(UIDL uidl) {\r
- String tag = uidl.getTag();\r
+ final String tag = uidl.getTag();\r
if ("colorpicker".equals(tag)) {\r
return "com.itmill.toolkit.demo.colorpicker.gwt.client.ui.IColorPicker";\r
}\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.colorpicker.gwt.client.ui;
import com.google.gwt.user.client.DOM;
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
// 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);
// 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");
// 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);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.colorpicker.gwt.client.ui;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import com.itmill.toolkit.terminal.ExternalResource;\r
\r
public ButtonExample() {\r
\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
main.setMargin(true);\r
setCompositionRoot(main);\r
\r
- OrderedLayout horiz = new OrderedLayout(\r
+ final OrderedLayout horiz = new OrderedLayout(\r
OrderedLayout.ORIENTATION_HORIZONTAL);\r
main.addComponent(horiz);\r
- Panel basic = new Panel("Basic buttons");\r
+ final Panel basic = new Panel("Basic buttons");\r
basic.setStyleName(Panel.STYLE_LIGHT);\r
horiz.addComponent(basic);\r
\r
- Panel bells = new Panel("w/ bells & whistles");\r
+ final Panel bells = new Panel("w/ bells & whistles");\r
bells.setStyleName(Panel.STYLE_LIGHT);\r
horiz.addComponent(bells);\r
\r
b.setDescription("Link-style, icon+tootip, no caption");\r
basic.addComponent(b);\r
\r
- Panel links = new Panel("Links");\r
+ final Panel links = new Panel("Links");\r
links.setStyleName(Panel.STYLE_LIGHT);\r
main.addComponent(links);\r
- Label desc = new Label(\r
+ final Label desc = new Label(\r
"The main difference between a Link and"\r
+ " a link-styled Button is that the Link works client-"\r
+ " side, whereas the Button works server side.<br/> This means"\r
}\r
\r
public void buttonClick(ClickEvent event) {\r
- Button b = event.getButton();\r
+ final Button b = event.getButton();\r
getWindow().showNotification(\r
"Clicked"\r
+ (b instanceof CheckBox ? ", value: "\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import com.itmill.toolkit.terminal.PaintException;\r
\r
public ClientCachingExample() {\r
\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
main.setMargin(true);\r
setCompositionRoot(main);\r
\r
main.addComponent(new Label(msg));\r
\r
- TabSheet ts = new TabSheet();\r
+ final TabSheet ts = new TabSheet();\r
main.addComponent(ts);\r
\r
Layout layout = new OrderedLayout();\r
public void paintContent(PaintTarget target) throws PaintException {\r
try {\r
Thread.sleep(3000);\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
// IGNORED\r
}\r
super.paintContent(target);\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.featurebrowser;
import com.itmill.toolkit.ui.ComboBox;
"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++) {
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++) {
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);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.featurebrowser;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
setSizeFull();
// create the address combobox
- Select select = new Select();
+ final Select select = new Select();
// allow input
select.setNewItemsAllowed(true);
// no empty selection
}
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));
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.featurebrowser;
import java.util.HashMap;
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;
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[][] {
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);
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);
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);
split.addComponent(tree);
- SplitPanel split2 = new SplitPanel();
+ final SplitPanel split2 = new SplitPanel();
split2.setSplitPosition(200, Sizeable.UNITS_PIXELS);
split.addComponent(split2);
table.setNullSelectionAllowed(false);
try {
table.setContainerDataSource((IndexedContainer) container.clone());
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace(System.err);
}
// Hide some columns
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) {
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;
}
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();
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);
}
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, "");
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)) {
}
table.setValue(null);
- IndexedContainer c = (IndexedContainer) table
+ final IndexedContainer c = (IndexedContainer) table
.getContainerDataSource();
c.removeAllContainerFilters();
if (section != null) {
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")));
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;
}
}
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import com.itmill.toolkit.ui.CustomComponent;\r
\r
public LabelExample() {\r
\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
main.setMargin(true);\r
setCompositionRoot(main);\r
\r
- GridLayout g = new GridLayout(2, 4);\r
+ final GridLayout g = new GridLayout(2, 4);\r
main.addComponent(g);\r
\r
// plain w/o caption\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import com.itmill.toolkit.ui.CustomComponent;\r
\r
public LayoutExample() {\r
\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
main.setMargin(true);\r
setCompositionRoot(main);\r
\r
- GridLayout g = new GridLayout(2, 5);\r
+ final GridLayout g = new GridLayout(2, 5);\r
main.addComponent(g);\r
\r
// panel\r
ol.addComponent(new Label("Component 3"));\r
ts.addTab(ol, "Horizontal OrderedLayout", null);\r
\r
- GridLayout gl = new GridLayout(3, 3);\r
+ final GridLayout gl = new GridLayout(3, 3);\r
gl.setMargin(true);\r
gl.addComponent(new Label("Component 1.1"));\r
gl.addComponent(new Label("Component 1.2"));\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.featurebrowser;
import java.util.Date;
*/
public NotificationExample() {
// Main layout
- OrderedLayout main = new OrderedLayout();
+ final OrderedLayout main = new OrderedLayout();
main.setMargin(true); // use theme-specific margin
setCompositionRoot(main);
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
-/**\r
- * \r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
*/\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import com.itmill.toolkit.ui.Button;\r
+ "See the <A href=\"http://www.itmill.com/manual/\">manual</a> "\r
+ "for more information.";\r
\r
- private OrderedLayout main;\r
- private Label l;\r
- private RichTextArea editor = new RichTextArea();\r
- private Button b;\r
+ private final OrderedLayout main;\r
+ private final Label l;\r
+ private final RichTextArea editor = new RichTextArea();\r
+ private final Button b;\r
\r
public RichTextExample() {\r
// main layout\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import com.itmill.toolkit.data.Property.ValueChangeEvent;\r
public class SelectExample extends CustomComponent {\r
\r
// listener that shows a value change notification\r
- private Field.ValueChangeListener listener = new Field.ValueChangeListener() {\r
+ private final Field.ValueChangeListener listener = new Field.ValueChangeListener() {\r
public void valueChange(ValueChangeEvent event) {\r
getWindow().showNotification("" + event.getProperty().getValue());\r
}\r
};\r
\r
public SelectExample() {\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
main.setMargin(true);\r
setCompositionRoot(main);\r
\r
- OrderedLayout horiz = new OrderedLayout(\r
+ final OrderedLayout horiz = new OrderedLayout(\r
OrderedLayout.ORIENTATION_HORIZONTAL);\r
main.addComponent(horiz);\r
- Panel single = new Panel("Single selects");\r
+ final Panel single = new Panel("Single selects");\r
single.setStyleName(Panel.STYLE_LIGHT);\r
horiz.addComponent(single);\r
- Panel multi = new Panel("Multi selects");\r
+ final Panel multi = new Panel("Multi selects");\r
multi.setStyleName(Panel.STYLE_LIGHT);\r
horiz.addComponent(multi);\r
\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import java.util.Iterator;\r
\r
public TableExample() {\r
// main layout\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
main.setMargin(true);\r
setCompositionRoot(main);\r
\r
main.addComponent(source);\r
\r
// x-selected button row\r
- OrderedLayout horiz = new OrderedLayout(\r
+ final OrderedLayout horiz = new OrderedLayout(\r
OrderedLayout.ORIENTATION_HORIZONTAL);\r
horiz.setMargin(false, false, true, false);\r
main.addComponent(horiz);\r
saved.addActionHandler(this);\r
main.addComponent(saved);\r
\r
- CheckBox b = new CheckBox("Modify saved creatures");\r
+ final CheckBox b = new CheckBox("Modify saved creatures");\r
b.addListener(new CheckBox.ClickListener() {\r
public void buttonClick(ClickEvent event) {\r
saved.setEditable(((Boolean) event.getButton().getValue())\r
private void fillTable(Table table) {\r
initProperties(table);\r
\r
- String[] sp = new String[] { "Fox", "Dog", "Cat", "Moose", "Penguin",\r
- "Cow" };\r
- String[] ty = new String[] { "Quick", "Lazy", "Sleepy", "Fidgety",\r
- "Crazy", "Kewl" };\r
- String[] ki = new String[] { "Jumping", "Walking", "Sleeping",\r
+ final String[] sp = new String[] { "Fox", "Dog", "Cat", "Moose",\r
+ "Penguin", "Cow" };\r
+ final String[] ty = new String[] { "Quick", "Lazy", "Sleepy",\r
+ "Fidgety", "Crazy", "Kewl" };\r
+ final String[] ki = new String[] { "Jumping", "Walking", "Sleeping",\r
"Skipping", "Dancing" };\r
\r
for (int i = 0; i < 100; i++) {\r
- String s = sp[(int) (Math.random() * sp.length)];\r
- String t = ty[(int) (Math.random() * ty.length)];\r
- String k = ki[(int) (Math.random() * ki.length)];\r
+ final String s = sp[(int) (Math.random() * sp.length)];\r
+ final String t = ty[(int) (Math.random() * ty.length)];\r
+ final String k = ki[(int) (Math.random() * ki.length)];\r
table.addItem(new Object[] { s, t, k, Boolean.FALSE }, new Integer(\r
i));\r
}\r
// Called for each item (row), returns valid actions for that item\r
public Action[] getActions(Object target, Object sender) {\r
if (sender == source) {\r
- Item item = source.getItem(target);\r
+ final Item item = source.getItem(target);\r
// save, delete, and hire if not already hired\r
if (item != null\r
&& item.getItemProperty(PROPERTY_HIRED).getValue() == Boolean.FALSE) {\r
return;\r
}\r
// "manual" copy of the item properties we want\r
- Item added = saved.addItem(target);\r
+ final Item added = saved.addItem(target);\r
Property p = added.getItemProperty(PROPERTY_SPECIES);\r
p.setValue(item.getItemProperty(PROPERTY_SPECIES).getValue());\r
p = added.getItemProperty(PROPERTY_TYPE);\r
} else {\r
// sender==saved\r
if (action == ACTION_DELETE) {\r
- Item item = saved.getItem(target);\r
+ final Item item = saved.getItem(target);\r
getWindow().showNotification("Deleted", "" + item);\r
saved.removeItem(target);\r
}\r
}\r
\r
public void buttonClick(ClickEvent event) {\r
- Button b = event.getButton();\r
+ final Button b = event.getButton();\r
if (b == deselect) {\r
source.setValue(null);\r
} else if (b == saveSelected) {\r
// loop each selected and copy to "saved" table\r
- Set selected = (Set) source.getValue();\r
+ final Set selected = (Set) source.getValue();\r
int s = 0;\r
- for (Iterator it = selected.iterator(); it.hasNext();) {\r
- Object id = it.next();\r
+ for (final Iterator it = selected.iterator(); it.hasNext();) {\r
+ final Object id = it.next();\r
if (!saved.containsId(id)) {\r
- Item item = source.getItem(id);\r
- Item added = saved.addItem(id);\r
+ final Item item = source.getItem(id);\r
+ final Item added = saved.addItem(id);\r
// "manual" copy of the properties we want\r
Property p = added.getItemProperty(PROPERTY_SPECIES);\r
p.setValue(item.getItemProperty(PROPERTY_SPECIES)\r
} else if (b == hireSelected) {\r
// loop each selected and set property HIRED to true\r
int s = 0;\r
- Set selected = (Set) source.getValue();\r
- for (Iterator it = selected.iterator(); it.hasNext();) {\r
- Object id = it.next();\r
+ final Set selected = (Set) source.getValue();\r
+ for (final Iterator it = selected.iterator(); it.hasNext();) {\r
+ final Object id = it.next();\r
Item item = source.getItem(id);\r
- Property p = item.getItemProperty(PROPERTY_HIRED);\r
+ final Property p = item.getItemProperty(PROPERTY_HIRED);\r
if (p.getValue() == Boolean.FALSE) {\r
p.setValue(Boolean.TRUE);\r
source.requestRepaint();\r
} else {\r
// loop trough selected and delete\r
int s = 0;\r
- Set selected = (Set) source.getValue();\r
- for (Iterator it = selected.iterator(); it.hasNext();) {\r
- Object id = it.next();\r
+ final Set selected = (Set) source.getValue();\r
+ for (final Iterator it = selected.iterator(); it.hasNext();) {\r
+ final Object id = it.next();\r
if (source.containsId(id)) {\r
s++;\r
source.removeItem(id);\r
+/*
+@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;
TextField editor;
public TreeExample() {
- OrderedLayout main = new OrderedLayout(
+ final OrderedLayout main = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
main.setMargin(true);
setCompositionRoot(main);
// 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);
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();
}
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) {
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
} 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();
}
*/
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);
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import com.itmill.toolkit.data.Property.ValueChangeEvent;\r
public class ValueInputExample extends CustomComponent {\r
\r
public ValueInputExample() {\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
main.setMargin(true);\r
setCompositionRoot(main);\r
\r
// listener that shows a value change notification\r
- Field.ValueChangeListener listener = new Field.ValueChangeListener() {\r
+ final Field.ValueChangeListener listener = new Field.ValueChangeListener() {\r
public void valueChange(ValueChangeEvent event) {\r
getWindow().showNotification("Received",\r
"<pre>" + event.getProperty().getValue() + "</pre>",\r
slider.addListener(new Slider.ValueChangeListener() {\r
public void valueChange(ValueChangeEvent event) {\r
// update caption when value changes\r
- Slider s = (Slider) event.getProperty();\r
+ final Slider s = (Slider) event.getProperty();\r
s.setCaption("Value: " + s.getValue());\r
}\r
});\r
try {\r
slider.setValue(20);\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
e.printStackTrace(System.err);\r
}\r
left.addComponent(slider);\r
slider.addListener(new Slider.ValueChangeListener() {\r
public void valueChange(ValueChangeEvent event) {\r
// update caption when value changes\r
- Slider s = (Slider) event.getProperty();\r
+ final Slider s = (Slider) event.getProperty();\r
s.setCaption("Value: " + s.getValue());\r
}\r
});\r
try {\r
slider.setValue(0.5);\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
e.printStackTrace(System.err);\r
}\r
left.addComponent(slider);\r
-/**\r
- * \r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
*/\r
+\r
package com.itmill.toolkit.demo.featurebrowser;\r
\r
import java.net.URL;\r
private URL windowUrl = null;\r
\r
public WindowingExample() {\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
main.setMargin(true);\r
setCompositionRoot(main);\r
\r
- Label l = new Label(txt);\r
+ final Label l = new Label(txt);\r
l.setContentMode(Label.CONTENT_XHTML);\r
main.addComponent(l);\r
\r
main.addComponent(new Button("Create a new subwindow",\r
new Button.ClickListener() {\r
public void buttonClick(ClickEvent event) {\r
- Window w = new Window("Subwindow");\r
- Label l = new Label(txt);\r
+ final Window w = new Window("Subwindow");\r
+ final Label l = new Label(txt);\r
l.setContentMode(Label.CONTENT_XHTML);\r
w.addComponent(l);\r
getApplication().getMainWindow().addWindow(w);\r
main.addComponent(new Button("Create a new modal window",\r
new Button.ClickListener() {\r
public void buttonClick(ClickEvent event) {\r
- Window w = new Window("Modal window");\r
+ final Window w = new Window("Modal window");\r
w.setModal(true);\r
- Label l = new Label(txt);\r
+ final Label l = new Label(txt);\r
l.setContentMode(Label.CONTENT_XHTML);\r
w.addComponent(l);\r
getApplication().getMainWindow().addWindow(w);\r
new Button.ClickListener() {\r
public void buttonClick(ClickEvent event) {\r
if (windowUrl == null) {\r
- Window w = new Window("Subwindow");\r
- Label l = new Label(txt);\r
+ final Window w = new Window("Subwindow");\r
+ final Label l = new Label(txt);\r
l.setContentMode(Label.CONTENT_XHTML);\r
w.addComponent(l);\r
getApplication().addWindow(w);\r
"Create a new application-level window, with it's own state",\r
new Button.ClickListener() {\r
public void buttonClick(ClickEvent event) {\r
- Window w = new Window("Subwindow");\r
+ final Window w = new Window("Subwindow");\r
getApplication().addWindow(w);\r
- Label l = new Label("Each opened window has its own"\r
- + " name, and is accessed trough its own uri.");\r
+ final Label l = new Label(\r
+ "Each opened window has its own"\r
+ + " name, and is accessed trough its own uri.");\r
l.setCaption("Window " + w.getName());\r
w.addComponent(l);\r
getApplication().getMainWindow().open(\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.reservation;
import java.sql.SQLException;
* 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));
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);
*/
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();
}
/*
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.reservation;\r
\r
import java.util.Collection;\r
\r
// Check old propertyIds\r
if (itemEndPropertyId != null) {\r
- Class c = dataSource.getType(itemEndPropertyId);\r
+ final Class c = dataSource.getType(itemEndPropertyId);\r
if (!Date.class.isAssignableFrom(c)) {\r
itemEndPropertyId = null;\r
}\r
}\r
if (itemNotimePropertyId != null) {\r
- Class c = dataSource.getType(itemNotimePropertyId);\r
+ final Class c = dataSource.getType(itemNotimePropertyId);\r
if (!Boolean.class.isAssignableFrom(c)) {\r
itemNotimePropertyId = null;\r
}\r
}\r
if (itemStartPropertyId != null) {\r
- Class c = dataSource.getType(itemStartPropertyId);\r
+ final Class c = dataSource.getType(itemStartPropertyId);\r
if (Date.class.isAssignableFrom(c)) {\r
// All we _really_ need is one date\r
return true;\r
}\r
}\r
// We need at least one Date\r
- Collection ids = dataSource.getContainerPropertyIds();\r
- for (Iterator it = ids.iterator(); it.hasNext();) {\r
- Object id = it.next();\r
- Class c = dataSource.getType(id);\r
+ final Collection ids = dataSource.getContainerPropertyIds();\r
+ for (final Iterator it = ids.iterator(); it.hasNext();) {\r
+ final Object id = it.next();\r
+ final Class c = dataSource.getType(id);\r
if (Date.class.isAssignableFrom(c)) {\r
itemStartPropertyId = id;\r
return true;\r
\r
// TODO send one month now, the rest via lazyloading\r
int month = new Date().getMonth();\r
- Object value = getValue();\r
+ final Object value = getValue();\r
if (value != null && value instanceof Date) {\r
month = ((Date) value).getMonth();\r
}\r
\r
- for (Iterator it = dataSource.getItemIds().iterator(); it.hasNext();) {\r
- Object itemId = it.next();\r
- Item item = dataSource.getItem(itemId);\r
+ for (final Iterator it = dataSource.getItemIds().iterator(); it\r
+ .hasNext();) {\r
+ final Object itemId = it.next();\r
+ final Item item = dataSource.getItem(itemId);\r
Property p = item.getItemProperty(itemStartPropertyId);\r
Date start = (Date) p.getValue();\r
Date end = start; // assume same day\r
if (end == null) {\r
end = start;\r
} else if (end.before(start)) {\r
- Date tmp = start;\r
+ final Date tmp = start;\r
start = end;\r
end = tmp;\r
}\r
target.addAttribute("id", itemId.hashCode());\r
if (itemStyleNamePropertyId != null) {\r
p = item.getItemProperty(itemStyleNamePropertyId);\r
- String styleName = (String) p.getValue();\r
+ final String styleName = (String) p.getValue();\r
target.addAttribute("styleName", styleName);\r
}\r
target.addAttribute("start", "" + start.getTime());\r
}\r
if (itemTitlePropertyId != null) {\r
p = item.getItemProperty(itemTitlePropertyId);\r
- Object val = p.getValue();\r
+ final Object val = p.getValue();\r
if (val != null) {\r
target.addAttribute("title", val.toString());\r
}\r
}\r
if (itemDescriptionPropertyId != null) {\r
p = item.getItemProperty(itemDescriptionPropertyId);\r
- Object val = p.getValue();\r
+ final Object val = p.getValue();\r
if (val != null) {\r
target.addAttribute("description", val\r
.toString());\r
}\r
if (itemNotimePropertyId != null) {\r
p = item.getItemProperty(itemNotimePropertyId);\r
- Object val = p.getValue();\r
+ final Object val = p.getValue();\r
if (val != null) {\r
target.addAttribute("notime", ((Boolean) val)\r
.booleanValue());\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.reservation;\r
\r
import java.awt.geom.Point2D;\r
\r
public class GoogleMap extends AbstractComponent implements Sizeable,\r
Container.Viewer {\r
- private String TAG_MARKERS = "markers";\r
- private String TAG_MARKER = "marker";\r
+ private final String TAG_MARKERS = "markers";\r
+ private final String TAG_MARKER = "marker";\r
private int width = 400;\r
private int height = 300;\r
private int zoomLevel = 15;\r
\r
if (dataSource != null) {\r
target.startTag(TAG_MARKERS);\r
- Collection itemIds = dataSource.getItemIds();\r
- for (Iterator it = itemIds.iterator(); it.hasNext();) {\r
- Object itemId = it.next();\r
- Item item = dataSource.getItem(itemId);\r
+ final Collection itemIds = dataSource.getItemIds();\r
+ for (final Iterator it = itemIds.iterator(); it.hasNext();) {\r
+ final Object itemId = it.next();\r
+ final Item item = dataSource.getItem(itemId);\r
Property p = item.getItemProperty(getItemMarkerXPropertyId());\r
- Double x = (Double) (p != null ? p.getValue() : null);\r
+ final Double x = (Double) (p != null ? p.getValue() : null);\r
p = item.getItemProperty(getItemMarkerYPropertyId());\r
- Double y = (Double) (p != null ? p.getValue() : null);\r
+ final Double y = (Double) (p != null ? p.getValue() : null);\r
if (x == null || y == null) {\r
continue;\r
}\r
target.addAttribute("x", x.doubleValue());\r
target.addAttribute("y", y.doubleValue());\r
p = item.getItemProperty(getItemMarkerHtmlPropertyId());\r
- String h = (String) (p != null ? p.getValue() : null);\r
+ final String h = (String) (p != null ? p.getValue() : null);\r
target.addAttribute("html", h);\r
target.endTag(TAG_MARKER);\r
}\r
if (dataSource == null) {\r
initDataSource();\r
}\r
- Object markerId = dataSource.addItem();\r
+ final Object markerId = dataSource.addItem();\r
if (markerId == null) {\r
return null;\r
}\r
- Item marker = dataSource.getItem(markerId);\r
+ final Item marker = dataSource.getItem(markerId);\r
Property p = marker.getItemProperty(getItemMarkerXPropertyId());\r
p.setValue(new Double(location.x));\r
p = marker.getItemProperty(getItemMarkerYPropertyId());\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.reservation;\r
\r
import java.awt.geom.Point2D;\r
db.generateDemoUser();\r
db.generateReservations();\r
\r
- Window mainWindow = new Window("Reservr");\r
+ final Window mainWindow = new Window("Reservr");\r
setMainWindow(mainWindow);\r
setTheme("reservr");\r
\r
- TabSheet mainTabs = new TabSheet();\r
+ final TabSheet mainTabs = new TabSheet();\r
mainWindow.addComponent(mainTabs);\r
\r
- OrderedLayout reservationTab = new OrderedLayout();\r
+ final OrderedLayout reservationTab = new OrderedLayout();\r
mainTabs.addTab(reservationTab, "Make reservation", null);\r
\r
resourcePanel = new ResourceSelectorPanel("Resources");\r
this, "selectedResourcesChanged");\r
reservationTab.addComponent(resourcePanel);\r
\r
- Panel reservationPanel = new Panel("Reservation", new OrderedLayout(\r
- OrderedLayout.ORIENTATION_HORIZONTAL));\r
+ final Panel reservationPanel = new Panel("Reservation",\r
+ new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));\r
reservationPanel.addStyleName(Panel.STYLE_LIGHT);\r
reservationPanel.getLayout().setMargin(true);\r
reservationTab.addComponent(reservationPanel);\r
\r
- OrderedLayout infoLayout = new OrderedLayout();\r
+ final OrderedLayout infoLayout = new OrderedLayout();\r
infoLayout.setMargin(false, true, false, false);\r
reservationPanel.addComponent(infoLayout);\r
resourceName = new Label("From the list above");\r
map.setContainerDataSource(db.getResources(null));\r
infoLayout.addComponent(map);\r
\r
- Calendar from = Calendar.getInstance();\r
+ final Calendar from = Calendar.getInstance();\r
from.add(Calendar.HOUR, 1);\r
from.set(Calendar.MINUTE, 0);\r
from.set(Calendar.SECOND, 0);\r
initCalendarFieldPropertyIds(reservedFrom);\r
reservationPanel.addComponent(reservedFrom);\r
\r
- Label arrowLabel = new Label("»");\r
+ final Label arrowLabel = new Label("»");\r
arrowLabel.setContentMode(Label.CONTENT_XHTML);\r
arrowLabel.setStyleName("arrow");\r
reservationPanel.addComponent(arrowLabel);\r
\r
- Calendar to = Calendar.getInstance();\r
+ final Calendar to = Calendar.getInstance();\r
to.setTime(from.getTime());\r
to.add(Calendar.MILLISECOND, (int) DEFAULT_GAP_MILLIS);\r
reservedTo = new CalendarField("To");\r
\r
reservedFrom.addListener(new ValueChangeListener() {\r
public void valueChange(ValueChangeEvent event) {\r
- Date fd = (Date) reservedFrom.getValue();\r
+ final Date fd = (Date) reservedFrom.getValue();\r
if (fd == null) {\r
reservedTo.setValue(null);\r
reservedTo.setEnabled(false);\r
}\r
reservedTo.setMinimumDate(new Date(fd.getTime()\r
+ DEFAULT_GAP_MILLIS));\r
- Calendar to = Calendar.getInstance();\r
+ final Calendar to = Calendar.getInstance();\r
to.setTime(fd);\r
to.add(Calendar.MILLISECOND, (int) currentGapMillis);\r
reservedTo.setValue(to.getTime());\r
});\r
reservedTo.addListener(new ValueChangeListener() {\r
public void valueChange(ValueChangeEvent event) {\r
- Date from = (Date) reservedFrom.getValue();\r
- Date to = (Date) reservedTo.getValue();\r
+ final Date from = (Date) reservedFrom.getValue();\r
+ final Date to = (Date) reservedTo.getValue();\r
currentGapMillis = to.getTime() - from.getTime();\r
if (currentGapMillis <= 0) {\r
- Calendar t = Calendar.getInstance();\r
+ final Calendar t = Calendar.getInstance();\r
t.setTime(from);\r
t.add(Calendar.MILLISECOND, (int) DEFAULT_GAP_MILLIS);\r
reservedTo.setValue(t.getTime());\r
}\r
});\r
\r
- OrderedLayout allLayout = new OrderedLayout(\r
+ final OrderedLayout allLayout = new OrderedLayout(\r
OrderedLayout.ORIENTATION_HORIZONTAL);\r
allLayout.addStyleName(Panel.STYLE_LIGHT);\r
allLayout.setMargin(true);\r
\r
public void makeReservation() {\r
try {\r
- Item resource = getActiveResource();\r
+ final Item resource = getActiveResource();\r
if (resource != null) {\r
db.addReservation(resource, 0, (Date) reservedFrom.getValue(),\r
(Date) reservedTo.getValue(), (String) description\r
"Please select a resource (or category) to reserve.",\r
Notification.TYPE_WARNING_MESSAGE);\r
}\r
- } catch (ResourceNotAvailableException e) {\r
+ } catch (final ResourceNotAvailableException e) {\r
getMainWindow()\r
.showNotification(\r
"Not available!",\r
}\r
\r
private Item getActiveResource() throws ResourceNotAvailableException {\r
- List rids = resourcePanel.getSelectedResources();\r
+ final List rids = resourcePanel.getSelectedResources();\r
if (rids != null && rids.size() > 0) {\r
- for (Iterator it = rids.iterator(); it.hasNext();) {\r
- Item resource = (Item) it.next();\r
- int id = ((Integer) resource.getItemProperty(\r
+ for (final Iterator it = rids.iterator(); it.hasNext();) {\r
+ final Item resource = (Item) it.next();\r
+ final int id = ((Integer) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_ID).getValue())\r
.intValue();\r
if (db.isAvailableResource(id, (Date) reservedFrom.getValue(),\r
}\r
\r
private void refreshReservations(boolean alsoResources) {\r
- Container reservations = db.getReservations(resourcePanel\r
+ final Container reservations = db.getReservations(resourcePanel\r
.getSelectedResources());\r
reservedFrom.setContainerDataSource(reservations);\r
reservedTo.setContainerDataSource(reservations);\r
if (alsoResources) {\r
refreshSelectedResources();\r
}\r
- Container allReservations = db.getReservations(null);\r
+ final Container allReservations = db.getReservations(null);\r
allTable.setContainerDataSource(allReservations);\r
if (allReservations != null && allReservations.size() > 0) {\r
allTable.setVisibleColumns(new Object[] {\r
Item resource = null;\r
try {\r
resource = getActiveResource();\r
- } catch (ResourceNotAvailableException e) {\r
+ } catch (final ResourceNotAvailableException e) {\r
getMainWindow().showNotification("Not available",\r
"Please choose another resource or time period.",\r
Notification.TYPE_HUMANIZED_MESSAGE);\r
resourceName.setCaption(name);\r
resourceName.setValue(desc);\r
// Put all resources on map (may be many if category was selected)\r
- LinkedList srs = resourcePanel.getSelectedResources();\r
- for (Iterator it = srs.iterator(); it.hasNext();) {\r
+ final LinkedList srs = resourcePanel.getSelectedResources();\r
+ for (final Iterator it = srs.iterator(); it.hasNext();) {\r
resource = (Item) it.next();\r
name = (String) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_NAME).getValue();\r
desc = (String) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();\r
- Double x = (Double) resource.getItemProperty(\r
+ final Double x = (Double) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_LOCATIONX).getValue();\r
- Double y = (Double) resource.getItemProperty(\r
+ final Double y = (Double) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_LOCATIONY).getValue();\r
if (x != null && y != null) {\r
map.addMarker(name + "<br/>" + desc, new Point2D.Double(x\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.reservation;\r
\r
public class ResourceNotAvailableException extends Exception {\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.reservation;\r
\r
import java.util.HashMap;\r
\r
public class ResourceSelectorPanel extends Panel implements\r
Button.ClickListener {\r
- private HashMap categoryLayouts = new HashMap();\r
- private HashMap categoryResources = new HashMap();\r
+ private final HashMap categoryLayouts = new HashMap();\r
+ private final HashMap categoryResources = new HashMap();\r
\r
private Container allResources;\r
private LinkedList selectedResources = null;\r
categoryLayouts.clear();\r
categoryResources.clear();\r
if (resources != null && resources.size() > 0) {\r
- for (Iterator it = resources.getItemIds().iterator(); it.hasNext();) {\r
- Item resource = resources.getItem(it.next());\r
- Integer id = (Integer) resource.getItemProperty(\r
+ for (final Iterator it = resources.getItemIds().iterator(); it\r
+ .hasNext();) {\r
+ final Item resource = resources.getItem(it.next());\r
+ final Integer id = (Integer) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_ID).getValue();\r
- String category = (String) resource.getItemProperty(\r
+ final String category = (String) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_CATEGORY).getValue();\r
- String name = (String) resource.getItemProperty(\r
+ final String name = (String) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_NAME).getValue();\r
- String description = (String) resource.getItemProperty(\r
+ final String description = (String) resource.getItemProperty(\r
SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();\r
- Button rButton = new Button(name, this);\r
+ final Button rButton = new Button(name, this);\r
rButton.setStyleName("link");\r
rButton.setDescription(description);\r
rButton.setData(resource);\r
categoryLayouts.put(category, resourceLayout);\r
resourceList = new LinkedList();\r
categoryResources.put(category, resourceList);\r
- Button cButton = new Button(category + " (any)", this);\r
+ final Button cButton = new Button(category + " (any)", this);\r
cButton.setStyleName("important-link");\r
cButton.setData(category);\r
resourceLayout.addComponent(cButton);\r
// Selects one initial categore, inpractice randomly\r
public void selectFirstCategory() {\r
try {\r
- Object catId = categoryResources.keySet().iterator().next();\r
- LinkedList res = (LinkedList) categoryResources.get(catId);\r
- Layout l = (Layout) categoryLayouts.get(catId);\r
- Button catB = (Button) l.getComponentIterator().next();\r
+ final Object catId = categoryResources.keySet().iterator().next();\r
+ final LinkedList res = (LinkedList) categoryResources.get(catId);\r
+ final Layout l = (Layout) categoryLayouts.get(catId);\r
+ final Button catB = (Button) l.getComponentIterator().next();\r
setSelectedResources(res);\r
catB.setStyleName("selected-link");\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
e.printStackTrace(System.err);\r
}\r
}\r
}\r
\r
public void buttonClick(ClickEvent event) {\r
- Object source = event.getSource();\r
+ final Object source = event.getSource();\r
if (source instanceof Button) {\r
- Object data = ((Button) source).getData();\r
- String name = ((Button) source).getCaption();\r
+ final Object data = ((Button) source).getData();\r
+ final String name = ((Button) source).getCaption();\r
resetStyles();\r
if (data instanceof Item) {\r
- LinkedList rlist = new LinkedList();\r
+ final LinkedList rlist = new LinkedList();\r
rlist.add(data);\r
setSelectedResources(rlist);\r
} else {\r
- String category = (String) data;\r
- LinkedList resources = (LinkedList) categoryResources\r
+ final String category = (String) data;\r
+ final LinkedList resources = (LinkedList) categoryResources\r
.get(category);\r
setSelectedResources(resources);\r
}\r
}\r
\r
private void resetStyles() {\r
- for (Iterator it = categoryLayouts.values().iterator(); it.hasNext();) {\r
- Layout lo = (Layout) it.next();\r
- for (Iterator bit = lo.getComponentIterator(); bit.hasNext();) {\r
- Button b = (Button) bit.next();\r
+ for (final Iterator it = categoryLayouts.values().iterator(); it\r
+ .hasNext();) {\r
+ final Layout lo = (Layout) it.next();\r
+ for (final Iterator bit = lo.getComponentIterator(); bit.hasNext();) {\r
+ final Button b = (Button) bit.next();\r
if (b.getData() instanceof Item) {\r
b.setStyleName("link");\r
} else {\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.reservation;
import java.sql.Connection;
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
}
}
try {
Class.forName("org.hsqldb.jdbcDriver").newInstance();
connection = DriverManager.getConnection(DB_URL);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new RuntimeException(e);
}
}
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);
}
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);
}
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);
}
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);
}
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;
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);
}
return new QueryContainer(q, connection,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
- } catch (SQLException e) {
+ } catch (final SQLException e) {
throw new RuntimeException(e);
}
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(",");
}
}
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) {
} else {
return qc;
}
- } catch (SQLException e) {
+ } catch (final SQLException e) {
throw new RuntimeException(e);
}
}
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 + ","
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,
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);
}
}
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 "
+ 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()));
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;
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()
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) },
};
- 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 + ","
+ 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++]);
.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);
}
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.reservation.gwt.client;\r
\r
import com.google.gwt.core.client.GWT;\r
\r
public class ReservationWidgetSet extends DefaultWidgetSet {\r
public Widget createWidget(UIDL uidl) {\r
- String className = resolveWidgetTypeName(uidl);\r
+ final String className = resolveWidgetTypeName(uidl);\r
if ("com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap"\r
.equals(className)) {\r
return new IGoogleMap();\r
\r
protected String resolveWidgetTypeName(UIDL uidl) {\r
\r
- String tag = uidl.getTag();\r
+ final String tag = uidl.getTag();\r
if ("googlemap".equals(tag)) {\r
return "com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap";\r
} else if ("calendarfield".equals(tag)) {\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.reservation.gwt.client.ui;\r
\r
import java.util.ArrayList;\r
\r
public class ICalendarField extends IDateField {\r
\r
- private CalendarPanel calPanel;\r
+ private final CalendarPanel calPanel;\r
\r
private SimplePanel hourPanel;\r
\r
private FlexTable hourTable;\r
\r
- private EntrySource entrySource;\r
+ private final EntrySource entrySource;\r
\r
- private TableListener ftListener = new HourTableListener();\r
+ private final TableListener ftListener = new HourTableListener();\r
\r
private int realResolution = RESOLUTION_DAY;\r
\r
realResolution = currentResolution;\r
currentResolution = RESOLUTION_DAY;\r
if (uidl.hasAttribute("min")) {\r
- String mins = uidl.getStringAttribute("min");\r
- long min = (mins != null ? Long.parseLong(mins) : 0);\r
- String maxs = uidl.getStringAttribute("max");\r
- long max = (maxs != null ? Long.parseLong(maxs) : 0);\r
- Date minDate = (min > 0 ? new Date(min) : null);\r
- Date maxDate = (max > 0 ? new Date(max) : null);\r
+ final String mins = uidl.getStringAttribute("min");\r
+ final long min = (mins != null ? Long.parseLong(mins) : 0);\r
+ final String maxs = uidl.getStringAttribute("max");\r
+ final long max = (maxs != null ? Long.parseLong(maxs) : 0);\r
+ final Date minDate = (min > 0 ? new Date(min) : null);\r
+ final Date maxDate = (max > 0 ? new Date(max) : null);\r
calPanel.setLimits(minDate, maxDate);\r
}\r
entrySource.clear();\r
- for (Iterator cit = uidl.getChildIterator(); cit.hasNext();) {\r
- UIDL child = (UIDL) cit.next();\r
+ for (final Iterator cit = uidl.getChildIterator(); cit.hasNext();) {\r
+ final UIDL child = (UIDL) cit.next();\r
if (child.getTag().equals("items")) {\r
- for (Iterator iit = child.getChildIterator(); iit.hasNext();) {\r
- UIDL item = (UIDL) iit.next();\r
+ for (final Iterator iit = child.getChildIterator(); iit\r
+ .hasNext();) {\r
+ final UIDL item = (UIDL) iit.next();\r
entrySource.addItem(item);\r
}\r
break;\r
CLASSNAME + "-row-" + style);\r
String hstr = (i < 10 ? "0" : "") + i + ":00";\r
if (dts.isTwelveHourClock()) {\r
- String ampm = (i < 12 ? "am" : "pm");\r
+ final String ampm = (i < 12 ? "am" : "pm");\r
hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;\r
}\r
hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");\r
.setStyleName(i, 0, CLASSNAME + "-time");\r
}\r
\r
- List entries = entrySource.getEntries(date,\r
+ final List entries = entrySource.getEntries(date,\r
DateTimeService.RESOLUTION_DAY);\r
int currentCol = 1;\r
- for (Iterator it = entries.iterator(); it.hasNext();) {\r
- CalendarEntry entry = (CalendarEntry) it.next();\r
+ for (final Iterator it = entries.iterator(); it.hasNext();) {\r
+ final CalendarEntry entry = (CalendarEntry) it.next();\r
int start = 0;\r
int hours = 24;\r
if (!entry.isNotime()) {\r
hourTable.getFlexCellFormatter().setRowSpan(start, col, hours);\r
hourTable.getFlexCellFormatter().setStyleName(start, col,\r
CLASSNAME + "-entry");\r
- String sn = entry.getStyleName();\r
+ final String sn = entry.getStyleName();\r
if (sn != null && !sn.equals("")) {\r
hourTable.getFlexCellFormatter().addStyleName(start, col,\r
CLASSNAME + "-" + entry.getStyleName());\r
}\r
- Element el = hourTable.getFlexCellFormatter()\r
- .getElement(start, col);\r
+ final Element el = hourTable.getFlexCellFormatter().getElement(\r
+ start, col);\r
\r
String tooltip;\r
if (DateTimeService.isSameDay(entry.getStart(), entry.getEnd())) {\r
tooltip = (start < 10 ? "0" : "") + start + ":00";\r
if (dts.isTwelveHourClock()) {\r
- String ampm = (start < 12 ? "am" : "pm");\r
+ final String ampm = (start < 12 ? "am" : "pm");\r
tooltip = (start <= 12 ? start : start - 12) + ":00 "\r
+ ampm;\r
\r
}\r
\r
// int hour = new Date().getHours()+1; // scroll to current hour\r
- int hour = this.date.getHours() + 1; // scroll to selected\r
+ final int hour = this.date.getHours() + 1; // scroll to selected\r
// hour\r
- int h1 = hourPanel.getOffsetHeight() / 2;\r
- int oh = hourTable.getOffsetHeight();\r
- int h2 = (int) (hour / 24.0 * oh);\r
- int scrollTop = h2 - h1;\r
- Element el = hourPanel.getElement();\r
+ final int h1 = hourPanel.getOffsetHeight() / 2;\r
+ final int oh = hourTable.getOffsetHeight();\r
+ final int h2 = (int) (hour / 24.0 * oh);\r
+ final int scrollTop = h2 - h1;\r
+ final Element el = hourPanel.getElement();\r
setScrollTop(el, scrollTop);\r
\r
}\r
\r
private native void setScrollTop(Element el, int scrollTop) /*-{\r
- el.scrollTop = scrollTop;\r
- }-*/;\r
+ el.scrollTop = scrollTop;\r
+ }-*/;\r
\r
private class HourTableListener implements TableListener {\r
\r
\r
private class EntrySource implements CalendarPanel.CalendarEntrySource {\r
\r
- private HashMap dates = new HashMap();\r
+ private final HashMap dates = new HashMap();\r
\r
public void addItem(UIDL item) {\r
- String styleName = item.getStringAttribute("styleName");\r
- Integer id = new Integer(item.getIntAttribute("id"));\r
- long start = Long.parseLong(item.getStringAttribute("start"));\r
- Date startDate = new Date(start);\r
+ final String styleName = item.getStringAttribute("styleName");\r
+ final Integer id = new Integer(item.getIntAttribute("id"));\r
+ final long start = Long.parseLong(item.getStringAttribute("start"));\r
+ final Date startDate = new Date(start);\r
long end = -1;\r
try {\r
end = Long.parseLong(item.getStringAttribute("end"));\r
- } catch (Exception IGNORED) {\r
+ } catch (final Exception IGNORED) {\r
// IGNORED attribute not required\r
}\r
- Date endDate = (end > 0 && end != start ? new Date(end) : new Date(\r
- start));\r
- String title = item.getStringAttribute("title");\r
- String desc = item.getStringAttribute("description");\r
- boolean notime = item.getBooleanAttribute("notime");\r
- CalendarEntry entry = new CalendarEntry(styleName, startDate,\r
+ final Date endDate = (end > 0 && end != start ? new Date(end)\r
+ : new Date(start));\r
+ final String title = item.getStringAttribute("title");\r
+ final String desc = item.getStringAttribute("description");\r
+ final boolean notime = item.getBooleanAttribute("notime");\r
+ final CalendarEntry entry = new CalendarEntry(styleName, startDate,\r
endDate, title, desc, notime);\r
\r
// TODO should remove+readd if the same entry (id) is\r
// added again\r
\r
- for (Date d = entry.getStart(); d.getYear() <= entry.getEnd()\r
+ for (final Date d = entry.getStart(); d.getYear() <= entry.getEnd()\r
.getYear()\r
&& d.getMonth() <= entry.getEnd().getYear()\r
&& d.getDate() <= entry.getEnd().getDate(); d.setTime(d\r
.getTime() + 86400000)) {\r
- String key = d.getYear() + "" + d.getMonth() + "" + d.getDate();\r
+ final String key = d.getYear() + "" + d.getMonth() + ""\r
+ + d.getDate();\r
ArrayList l = (ArrayList) dates.get(key);\r
if (l == null) {\r
l = new ArrayList();\r
}\r
\r
public List getEntries(Date date, int resolution) {\r
- List entries = (List) dates.get(date.getYear() + ""\r
+ final List entries = (List) dates.get(date.getYear() + ""\r
+ date.getMonth() + "" + date.getDate());\r
- ArrayList res = new ArrayList();\r
+ final ArrayList res = new ArrayList();\r
if (entries == null) {\r
return res;\r
}\r
- for (Iterator it = entries.iterator(); it.hasNext();) {\r
- CalendarEntry item = (CalendarEntry) it.next();\r
+ for (final Iterator it = entries.iterator(); it.hasNext();) {\r
+ final CalendarEntry item = (CalendarEntry) it.next();\r
if (DateTimeService.isInRange(date, item.getStart(), item\r
.getEnd(), resolution)) {\r
res.add(item);\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.demo.reservation.gwt.client.ui;\r
\r
import java.util.Iterator;\r
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
map.clearOverlays();\r
GLatLng pos = null;\r
- for (Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
- UIDL u = (UIDL) it.next();\r
+ for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
+ final UIDL u = (UIDL) it.next();\r
if (u.getTag().equals("markers")) {\r
\r
- for (Iterator m = u.getChildIterator(); m.hasNext();) {\r
- UIDL umarker = (UIDL) m.next();\r
- String html = "<span>" + umarker.getStringAttribute("html")\r
- + "</span>";\r
- double x = umarker.getDoubleAttribute("x");\r
- double y = umarker.getDoubleAttribute("y");\r
+ for (final Iterator m = u.getChildIterator(); m.hasNext();) {\r
+ final UIDL umarker = (UIDL) m.next();\r
+ final String html = "<span>"\r
+ + umarker.getStringAttribute("html") + "</span>";\r
+ final double x = umarker.getDoubleAttribute("x");\r
+ final double y = umarker.getDoubleAttribute("y");\r
pos = new GLatLng(x, y);\r
- GMarker marker = new GMarker(pos);\r
+ final GMarker marker = new GMarker(pos);\r
map.addOverlay(marker);\r
if (html != null) {\r
addMarkerPopup(marker, html);\r
map.setZoom(uidl.getIntAttribute("zoom"));\r
}\r
if (uidl.hasAttribute("centerX") && uidl.hasAttribute("centerY")) {\r
- GLatLng center = new GLatLng(uidl.getDoubleAttribute("centerX"),\r
- uidl.getDoubleAttribute("centerY"));\r
+ final GLatLng center = new GLatLng(uidl\r
+ .getDoubleAttribute("centerX"), uidl\r
+ .getDoubleAttribute("centerY"));\r
map.setCenter(center);\r
} else if (pos != null) {\r
// use last marker position\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.util;
import java.sql.Connection;
*/
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);
}
}
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);
}
+ "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);
}
+ "','" + 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);
}
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;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.util;
import java.sql.Connection;
*/
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);
}
}
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);
}
+ "'" + ")";
update(stmt);
}
- } catch (SQLException e) {
+ } catch (final SQLException e) {
if (e.toString().indexOf("Table already exists") == -1) {
throw new RuntimeException(e);
}
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;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.demo.util;
import java.io.File;
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"));
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
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
}
}
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
}
}
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)) {
// 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
}
}
// 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);
}
-/* *************************************************************************
-
- 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;
* 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.
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)) {
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)) {
this.method = method;
eventArgumentIndex = -1;
- Class[] params = method.getParameterTypes();
+ final Class[] params = method.getParameterTypes();
if (params.length == 0) {
arguments = new Object[0];
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)) {
this.method = method;
eventArgumentIndex = -1;
- Class[] params = method.getParameterTypes();
+ final Class[] params = method.getParameterTypes();
if (params.length == 0) {
arguments = new Object[0];
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];
}
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());
*/
private static final long serialVersionUID = 3257005445242894135L;
- private Throwable cause;
+ private final Throwable cause;
private String message;
-/* *************************************************************************
-
- 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;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.event;
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);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.launcher;
import java.awt.FlowLayout;
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;
}
}
// 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) {
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);
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);
});
// 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();
* @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);
}
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.launcher;\r
\r
import java.util.HashMap;\r
public static void main(String[] args) {\r
\r
// Pass-through of arguments for Jetty\r
- Map serverArgs = parseArguments(args);\r
+ final Map serverArgs = parseArguments(args);\r
\r
// Start Jetty\r
System.out.println("Starting Jetty servlet container.");\r
- String url = runServer(serverArgs, "Web Mode");\r
+ final String url = runServer(serverArgs, "Web Mode");\r
\r
// Start Browser\r
System.out.println("Starting Web Browser.");\r
assignDefault(serverArgs, "httpPort", serverPort);\r
\r
try {\r
- long started = System.currentTimeMillis();\r
+ final long started = System.currentTimeMillis();\r
\r
- Server server = new Server();\r
+ final Server server = new Server();\r
\r
// String threadPoolName =\r
// System.getProperty("jetty.threadpool.name",\r
// threadPool.setLowThreads(lowThreads);\r
// server.setThreadPool(threadPool);\r
\r
- Connector connector = new SelectChannelConnector();\r
+ final Connector connector = new SelectChannelConnector();\r
// FIXME httpPort hardcoded to 8888\r
// connector.setPort(Integer.valueOf(serverArgs.get("httpPort")\r
// .toString()));\r
connector.setPort(8888);\r
server.setConnectors(new Connector[] { connector });\r
\r
- WebAppContext webappcontext = new WebAppContext();\r
+ final WebAppContext webappcontext = new WebAppContext();\r
webappcontext.setContextPath("");\r
webappcontext.setWar(serverArgs.get("webroot").toString());\r
// enable hot code replace\r
server.start();\r
// System.err.println("Started Jetty in "\r
// + (System.currentTimeMillis() - started) + "ms.");\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
e.printStackTrace();\r
return null;\r
}\r
* @return map of arguments key value pairs.\r
*/\r
protected static Map parseArguments(String[] args) {\r
- Map map = new HashMap();\r
+ final Map map = new HashMap();\r
for (int i = 0; i < args.length; i++) {\r
- int d = args[i].indexOf("=");\r
+ final int d = args[i].indexOf("=");\r
if (d > 0 && d < args[i].length() && args[i].startsWith("--")) {\r
- String name = args[i].substring(2, d);\r
- String value = args[i].substring(d + 1);\r
+ final String name = args[i].substring(2, d);\r
+ final String value = args[i].substring(d + 1);\r
map.put(name, value);\r
}\r
}\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.launcher.util;\r
\r
import java.io.IOException;\r
*/\r
public static void openBrowser(String url) {\r
\r
- Runtime runtime = Runtime.getRuntime();\r
+ final Runtime runtime = Runtime.getRuntime();\r
boolean started = false;\r
\r
- String os = System.getProperty("os.name", "windows").toLowerCase();\r
+ final String os = System.getProperty("os.name", "windows")\r
+ .toLowerCase();\r
\r
// Linux\r
if (os.indexOf("linux") >= 0) {\r
try {\r
runtime.exec("x-www-browser " + url);\r
started = true;\r
- } catch (IOException e) {\r
+ } catch (final IOException e) {\r
}\r
}\r
\r
try {\r
runtime.exec("firefox " + url);\r
started = true;\r
- } catch (IOException e) {\r
+ } catch (final IOException e) {\r
}\r
}\r
\r
try {\r
runtime.exec("mozilla " + url);\r
started = true;\r
- } catch (IOException e) {\r
+ } catch (final IOException e) {\r
}\r
}\r
\r
try {\r
runtime.exec("konqueror " + url);\r
started = true;\r
- } catch (IOException e) {\r
+ } catch (final IOException e) {\r
}\r
}\r
}\r
try {\r
runtime.exec("open " + url);\r
started = true;\r
- } catch (IOException e) {\r
+ } catch (final IOException e) {\r
}\r
}\r
}\r
try {\r
runtime.exec("cmd /c start " + url);\r
started = true;\r
- } catch (IOException e) {\r
+ } catch (final IOException e) {\r
}\r
}\r
}\r
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
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);
}
}
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;
}
*/
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;
}
*/
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;
}
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
/**
* 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
* @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());
-/* *************************************************************************
-
- 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;
/**
* Array of all the errors.
*/
- private List errors;
+ private final List errors;
/**
* Level of the error.
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());
}
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;
}
}
// Paint all the exceptions
- for (Iterator i = errors.iterator(); i.hasNext();) {
+ for (final Iterator i = errors.iterator(); i.hasNext();) {
((ErrorMessage) i.next()).paint(target);
}
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 += ",";
}
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
/**
* Application.
*/
- private Application application;
+ private final Application application;
/**
* Default cache time for this stream resource.
*/
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;
}
-/* *************************************************************************
-
- 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;
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.
* 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);
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
/**
* Application.
*/
- private Application application;
+ private final Application application;
/**
* Default buffer size for this stream resource.
* @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;
-/* *************************************************************************
-
- 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;
target.addAttribute("level", "system");
// Paint the error message
- String message = getLocalizedMessage();
+ final String message = getLocalizedMessage();
if (message != null) {
target.addSection("h2", message);
}
// Paint the exception
if (cause != null) {
target.addSection("h3", "Exception");
- StringWriter buffer = new StringWriter();
+ final StringWriter buffer = new StringWriter();
cause.printStackTrace(new PrintWriter(buffer));
target.addSection("pre", buffer.toString());
}
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
-/* *************************************************************************
-
- 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;
/**
* Message in content mode.
*/
- private String msg;
+ private final String msg;
/**
* Error level.
-/* *************************************************************************
-
- 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;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import java.util.Date;
*/
public class ApplicationConnection {
- private String appUri;
+ private final String appUri;
- private HashMap resourcesMap = new HashMap();
+ private final HashMap resourcesMap = new HashMap();
private static Console console;
- private Vector pendingVariables = new Vector();
+ private final Vector pendingVariables = new Vector();
- private HashMap idToPaintable = new HashMap();
+ private final HashMap idToPaintable = new HashMap();
- private HashMap paintableToId = new HashMap();
+ private final HashMap paintableToId = new HashMap();
private final WidgetSet widgetSet;
private Timer loadTimer;
private Element loadElement;
- private IView view;
+ private final IView view;
public ApplicationConnection(WidgetSet widgetSet) {
this.widgetSet = widgetSet;
showLoadingIndicator();
console.log("Making UIDL Request with params: " + requestData);
- String uri = appUri + "/UIDL" + getPathInfo();
- RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri);
+ final String uri = appUri + "/UIDL" + getPathInfo();
+ final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri);
rb.setHeader("Content-Type",
"application/x-www-form-urlencoded; charset=utf-8");
try {
});
- } catch (RequestException e) {
+ } catch (final RequestException e) {
// TODO Better reporting to user
console.error(e.getMessage());
}
+ "px");
// Initialize other timers
- Timer delay = new Timer() {
+ final Timer delay = new Timer() {
public void run() {
DOM.setElementProperty(loadElement, "className",
"i-loading-indicator-delay");
// Second one kicks in at 1500ms
delay.schedule(1200);
- Timer wait = new Timer() {
+ final Timer wait = new Timer() {
public void run() {
DOM.setElementProperty(loadElement, "className",
"i-loading-indicator-wait");
private void handleReceivedJSONMessage(Response response) {
hideLoadingIndicator();
- Date start = new Date();
- String jsonText = response.getText().substring(3) + "}";
+ final Date start = new Date();
+ final String jsonText = response.getText().substring(3) + "}";
JSONValue json;
try {
json = JSONParser.parse(jsonText);
- } catch (com.google.gwt.json.client.JSONException e) {
+ } catch (final com.google.gwt.json.client.JSONException e) {
console.log(e.getMessage() + " - Original JSON-text:");
console.log(jsonText);
return;
}
// Handle redirect
- JSONObject redirect = (JSONObject) ((JSONObject) json).get("redirect");
+ final JSONObject redirect = (JSONObject) ((JSONObject) json)
+ .get("redirect");
if (redirect != null) {
- JSONString url = (JSONString) redirect.get("url");
+ final JSONString url = (JSONString) redirect.get("url");
if (url != null) {
console.log("redirecting to " + url.stringValue());
redirect(url.stringValue());
}
// Store resources
- JSONObject resources = (JSONObject) ((JSONObject) json)
+ final JSONObject resources = (JSONObject) ((JSONObject) json)
.get("resources");
- for (Iterator i = resources.keySet().iterator(); i.hasNext();) {
- String key = (String) i.next();
+ for (final Iterator i = resources.keySet().iterator(); i.hasNext();) {
+ final String key = (String) i.next();
resourcesMap.put(key, ((JSONString) resources.get(key))
.stringValue());
}
// Store locale data
if (((JSONObject) json).containsKey("locales")) {
- JSONArray l = (JSONArray) ((JSONObject) json).get("locales");
+ final JSONArray l = (JSONArray) ((JSONObject) json).get("locales");
for (int i = 0; i < l.size(); i++) {
LocaleService.addLocale((JSONObject) l.get(i));
}
}
// Process changes
- JSONArray changes = (JSONArray) ((JSONObject) json).get("changes");
+ final JSONArray changes = (JSONArray) ((JSONObject) json)
+ .get("changes");
for (int i = 0; i < changes.size(); i++) {
try {
- UIDL change = new UIDL((JSONArray) changes.get(i));
+ final UIDL change = new UIDL((JSONArray) changes.get(i));
try {
console.dirUIDL(change);
- } catch (Exception e) {
+ } catch (final Exception e) {
console.log(e.getMessage());
// TODO: dir doesn't work in any browser although it should
// work (works in hosted mode)
// it partially did at some part but now broken.
}
- UIDL uidl = change.getChildUIDL(0);
- Paintable paintable = getPaintable(uidl.getId());
+ final UIDL uidl = change.getChildUIDL(0);
+ final Paintable paintable = getPaintable(uidl.getId());
if (paintable != null) {
paintable.updateFromUIDL(uidl, this);
} else {
view.updateFromUIDL(uidl, this);
}
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
}
}
if (((JSONObject) json).containsKey("meta")) {
- JSONObject meta = ((JSONObject) json).get("meta").isObject();
+ final JSONObject meta = ((JSONObject) json).get("meta").isObject();
if (meta.containsKey("focus")) {
- String focusPid = meta.get("focus").isString().stringValue();
- Paintable toBeFocused = getPaintable(focusPid);
+ final String focusPid = meta.get("focus").isString()
+ .stringValue();
+ final Paintable toBeFocused = getPaintable(focusPid);
if (toBeFocused instanceof HasFocus) {
- HasFocus toBeFocusedWidget = (HasFocus) toBeFocused;
+ final HasFocus toBeFocusedWidget = (HasFocus) toBeFocused;
toBeFocusedWidget.setFocus(true);
}
}
}
- long prosessingTime = (new Date().getTime()) - start.getTime();
+ final long prosessingTime = (new Date().getTime()) - start.getTime();
console.log(" Processing time was " + String.valueOf(prosessingTime)
+ "ms for " + jsonText.length() + " characters of JSON");
console.log("Referenced paintables: " + idToPaintable.size());
}
public void unregisterChildPaintables(HasWidgets container) {
- Iterator it = container.iterator();
+ final Iterator it = container.iterator();
while (it.hasNext()) {
- Widget w = (Widget) it.next();
+ final Widget w = (Widget) it.next();
if (w instanceof Paintable) {
unregisterPaintable((Paintable) w);
}
private void addVariableToQueue(String paintableId, String variableName,
String encodedValue, boolean immediate, char type) {
- String id = paintableId + "_" + variableName + "_" + type;
+ final String id = paintableId + "_" + variableName + "_" + type;
for (int i = 0; i < pendingVariables.size(); i += 2) {
if ((pendingVariables.get(i)).equals(id)) {
pendingVariables.remove(i);
}
public void sendPendingVariableChanges() {
- StringBuffer req = new StringBuffer();
+ final StringBuffer req = new StringBuffer();
req.append("changes=");
for (int i = 0; i < pendingVariables.size(); i++) {
public void updateVariable(String paintableId, String variableName,
Object[] values, boolean immediate) {
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
for (int i = 0; i < values.length; i++) {
if (i > 0) {
buf.append(",");
component.setVisible(visible);
// Set captions
if (manageCaption) {
- Container parent = getParentLayout(component);
+ final Container parent = getParentLayout(component);
if (parent != null) {
parent.updateCaption((Paintable) component, uidl);
}
// Switch to correct implementation if needed
if (!widgetSet.isCorrectImplementation(component, uidl)) {
- Container parent = getParentLayout(component);
+ final Container parent = getParentLayout(component);
if (parent != null) {
- Widget w = widgetSet.createWidget(uidl);
+ final Widget w = widgetSet.createWidget(uidl);
parent.replaceChildComponent(component, w);
registerPaintable(uidl.getId(), (Paintable) w);
((Paintable) w).updateFromUIDL(uidl, this);
// add additional styles as css classes, prefixed with component default
// stylename
if (uidl.hasAttribute("style")) {
- String[] styles = uidl.getStringAttribute("style").split(" ");
+ final String[] styles = uidl.getStringAttribute("style").split(" ");
for (int i = 0; i < styles.length; i++) {
component.addStyleDependentName(styles[i]);
}
* @return Either existing or new widget corresponding to UIDL.
*/
public Widget getWidget(UIDL uidl) {
- String id = uidl.getId();
+ final String id = uidl.getId();
Widget w = (Widget) getPaintable(id);
if (w != null) {
return w;
*/
public String translateToolkitUri(String toolkitUri) {
if (toolkitUri.startsWith("theme://")) {
- String themeUri = getThemeUri();
+ final String themeUri = getThemeUri();
if (themeUri == null) {
console
.error("Theme not set: ThemeResource will not be found. ("
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import com.google.gwt.user.client.DOM;
public static final String CLASSNAME = "i-caption";
- private Paintable owner;
+ private final Paintable owner;
private Element errorIndicatorElement;
private ErrorMessage errorMessage;
- private ApplicationConnection client;
+ private final ApplicationConnection client;
public Caption(Paintable component, ApplicationConnection client) {
super();
setStyleName(getElement(), "i-disabled", uidl.hasAttribute("disabled"));
if (uidl.hasAttribute("error")) {
- UIDL errorUidl = uidl.getErrors();
+ final UIDL errorUidl = uidl.getErrors();
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
}
public void onBrowserEvent(Event event) {
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (errorIndicatorElement != null
&& DOM.compare(target, errorIndicatorElement)) {
switch (DOM.eventGetType(event)) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import com.google.gwt.user.client.ui.FlowPanel;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
public interface Console {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import com.google.gwt.user.client.ui.Widget;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
/**
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client;\r
\r
public class DateLocale extends\r
public static String getAM() {\r
try {\r
return LocaleService.getAmPmStrings(locale)[0];\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println("Tried to use an unloaded locale \"" + locale\r
+ "\".");\r
public static String getPM() {\r
try {\r
return LocaleService.getAmPmStrings(locale)[1];\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println("Tried to use an unloaded locale \"" + locale\r
+ "\".");\r
public String[] getWEEKDAY_LONG() {\r
try {\r
return LocaleService.getDayNames(locale);\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println("Tried to use an unloaded locale \"" + locale\r
+ "\".");\r
public String[] getWEEKDAY_SHORT() {\r
try {\r
return LocaleService.getShortDayNames(locale);\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println("Tried to use an unloaded locale \"" + locale\r
+ "\".");\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client;\r
\r
import java.util.Date;\r
public String getMonth(int month) {\r
try {\r
return LocaleService.getMonthNames(currentLocale)[month];\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
public String getShortMonth(int month) {\r
try {\r
return LocaleService.getShortMonthNames(currentLocale)[month];\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
public String getDay(int day) {\r
try {\r
return LocaleService.getDayNames(currentLocale)[day];\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
public String getShortDay(int day) {\r
try {\r
return LocaleService.getShortDayNames(currentLocale)[day];\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
public int getFirstDayOfWeek() {\r
try {\r
return LocaleService.getFirstDayOfWeek(currentLocale);\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
public boolean isTwelveHourClock() {\r
try {\r
return LocaleService.isTwelveHourClock(currentLocale);\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
public String getClockDelimeter() {\r
try {\r
return LocaleService.getClockDelimiter(currentLocale);\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
public String[] getAmPmStrings() {\r
try {\r
return LocaleService.getAmPmStrings(currentLocale);\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
- String[] temp = new String[2];\r
+ final String[] temp = new String[2];\r
temp[0] = "AM";\r
temp[1] = "PM";\r
return temp;\r
}\r
\r
public int getStartWeekDay(Date date) {\r
- Date dateForFirstOfThisMonth = new Date(date.getYear(),\r
- date.getMonth(), 1);\r
+ final Date dateForFirstOfThisMonth = new Date(date.getYear(), date\r
+ .getMonth(), 1);\r
int firstDay;\r
try {\r
firstDay = LocaleService.getFirstDayOfWeek(currentLocale);\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
firstDay = 0;\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
public String getDateFormat() {\r
try {\r
return LocaleService.getDateFormat(currentLocale);\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
// TODO redirect to console\r
System.out.println(e + ":" + e.getMessage());\r
}\r
}\r
\r
public static int getNumberOfDaysInMonth(Date date) {\r
- int month = date.getMonth();\r
+ final int month = date.getMonth();\r
if (month == 1 && true == isLeapYear(date)) {\r
return 29;\r
}\r
\r
public static boolean isLeapYear(Date date) {\r
// Instantiate the date for 1st March of that year\r
- Date firstMarch = new Date(date.getYear(), 2, 1);\r
+ final Date firstMarch = new Date(date.getYear(), 2, 1);\r
\r
// Go back 1 day\r
- long firstMarchTime = firstMarch.getTime();\r
- long lastDayTimeFeb = firstMarchTime - (24 * 60 * 60 * 1000); // NUM_MILLISECS_A_DAY\r
+ final long firstMarchTime = firstMarch.getTime();\r
+ final long lastDayTimeFeb = firstMarchTime - (24 * 60 * 60 * 1000); // NUM_MILLISECS_A_DAY\r
\r
// Instantiate new Date with this time\r
- Date febLastDay = new Date(lastDayTimeFeb);\r
+ final Date febLastDay = new Date(lastDayTimeFeb);\r
\r
// Check for date in this new instance\r
return (29 == febLastDay.getDate()) ? true : false;\r
}\r
\r
private static int getDayInt(Date date) {\r
- int y = date.getYear();\r
- int m = date.getMonth();\r
- int d = date.getDate();\r
+ final int y = date.getYear();\r
+ final int m = date.getMonth();\r
+ final int d = date.getDate();\r
\r
return ((y + 1900) * 10000 + m * 100 + d) * 1000000000;\r
}\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import com.google.gwt.user.client.Event;
public final class DebugConsole extends IWindow implements Console {
- private Panel panel;
+ private final Panel panel;
public DebugConsole(ApplicationConnection client) {
super();
this.client = client;
panel = new FlowPanel();
- ScrollPanel p = new ScrollPanel();
+ final ScrollPanel p = new ScrollPanel();
p.add(panel);
setWidget(p);
setCaption("Debug window");
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import com.google.gwt.core.client.GWT;
public Widget createWidget(UIDL uidl) {
- String className = resolveWidgetTypeName(uidl);
+ final String className = resolveWidgetTypeName(uidl);
if ("com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox"
.equals(className)) {
return new ICheckBox();
protected String resolveWidgetTypeName(UIDL uidl) {
- String tag = uidl.getTag();
+ final String tag = uidl.getTag();
if ("button".equals(tag)) {
if ("switch".equals(uidl.getStringAttribute("type"))) {
return "com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox";
return "com.itmill.toolkit.terminal.gwt.client.ui.ITree";
} else if ("select".equals(tag)) {
if (uidl.hasAttribute("type")) {
- String type = uidl.getStringAttribute("type");
+ final String type = uidl.getStringAttribute("type");
if (type.equals("twincol")) {
return "com.itmill.toolkit.terminal.gwt.client.ui.ITwinColSelect";
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import java.util.Iterator;
public void updateFromUIDL(UIDL uidl) {
clear();
- for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
- Object child = it.next();
+ for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {
+ final Object child = it.next();
if (child instanceof String) {
- String errorMessage = (String) child;
+ final String errorMessage = (String) child;
add(new HTML(errorMessage));
} else if (child instanceof UIDL.XML) {
- UIDL.XML xml = (UIDL.XML) child;
+ final UIDL.XML xml = (UIDL.XML) child;
add(new HTML(xml.getXMLAsString()));
} else {
- ErrorMessage childError = new ErrorMessage();
+ final ErrorMessage childError = new ErrorMessage();
add(childError);
childError.updateFromUIDL((UIDL) child);
}
}
public void hide() {
- ToolkitOverlay errorContainer = (ToolkitOverlay) getParent();
+ final ToolkitOverlay errorContainer = (ToolkitOverlay) getParent();
if (errorContainer != null) {
errorContainer.hide();
}
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client;\r
\r
public class LocaleNotLoadedException extends Exception {\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client;\r
\r
import java.util.HashMap;\r
private static String defaultLocale;\r
\r
public static void addLocale(JSONObject json) {\r
- String key = ((JSONString) json.get("name")).stringValue();\r
+ final String key = ((JSONString) json.get("name")).stringValue();\r
if (cache.containsKey(key)) {\r
cache.remove(key);\r
}\r
public static String[] getMonthNames(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONArray mn = (JSONArray) l.get("mn");\r
- String[] temp = new String[12];\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONArray mn = (JSONArray) l.get("mn");\r
+ final String[] temp = new String[12];\r
temp[0] = ((JSONString) mn.get(0)).stringValue();\r
temp[1] = ((JSONString) mn.get(1)).stringValue();\r
temp[2] = ((JSONString) mn.get(2)).stringValue();\r
public static String[] getShortMonthNames(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONArray smn = (JSONArray) l.get("smn");\r
- String[] temp = new String[12];\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONArray smn = (JSONArray) l.get("smn");\r
+ final String[] temp = new String[12];\r
temp[0] = ((JSONString) smn.get(0)).stringValue();\r
temp[1] = ((JSONString) smn.get(1)).stringValue();\r
temp[2] = ((JSONString) smn.get(2)).stringValue();\r
public static String[] getDayNames(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONArray dn = (JSONArray) l.get("dn");\r
- String[] temp = new String[7];\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONArray dn = (JSONArray) l.get("dn");\r
+ final String[] temp = new String[7];\r
temp[0] = ((JSONString) dn.get(0)).stringValue();\r
temp[1] = ((JSONString) dn.get(1)).stringValue();\r
temp[2] = ((JSONString) dn.get(2)).stringValue();\r
public static String[] getShortDayNames(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONArray sdn = (JSONArray) l.get("sdn");\r
- String[] temp = new String[7];\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONArray sdn = (JSONArray) l.get("sdn");\r
+ final String[] temp = new String[7];\r
temp[0] = ((JSONString) sdn.get(0)).stringValue();\r
temp[1] = ((JSONString) sdn.get(1)).stringValue();\r
temp[2] = ((JSONString) sdn.get(2)).stringValue();\r
public static int getFirstDayOfWeek(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONNumber fdow = (JSONNumber) l.get("fdow");\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONNumber fdow = (JSONNumber) l.get("fdow");\r
return (int) fdow.getValue();\r
} else {\r
throw new LocaleNotLoadedException(locale);\r
public static String getDateFormat(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONString df = (JSONString) l.get("df");\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONString df = (JSONString) l.get("df");\r
return df.stringValue();\r
} else {\r
throw new LocaleNotLoadedException(locale);\r
public static boolean isTwelveHourClock(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONBoolean thc = (JSONBoolean) l.get("thc");\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONBoolean thc = (JSONBoolean) l.get("thc");\r
return thc.booleanValue();\r
} else {\r
throw new LocaleNotLoadedException(locale);\r
public static String getClockDelimiter(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONString hmd = (JSONString) l.get("hmd");\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONString hmd = (JSONString) l.get("hmd");\r
return hmd.stringValue();\r
} else {\r
throw new LocaleNotLoadedException(locale);\r
public static String[] getAmPmStrings(String locale)\r
throws LocaleNotLoadedException {\r
if (cache.containsKey(locale)) {\r
- JSONObject l = (JSONObject) cache.get(locale);\r
- JSONArray ampm = (JSONArray) l.get("ampm");\r
- String[] temp = new String[2];\r
+ final JSONObject l = (JSONObject) cache.get(locale);\r
+ final JSONArray ampm = (JSONArray) l.get("ampm");\r
+ final String[] temp = new String[2];\r
temp[0] = ((JSONString) ampm.get(0)).stringValue();\r
temp[1] = ((JSONString) ampm.get(1)).stringValue();\r
return temp;\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
/**
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
public interface Paintable {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
public class StyleConstants {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import java.util.HashSet;
}
public String getId() {
- JSONValue val = ((JSONObject) json.get(1)).get("id");
+ final JSONValue val = ((JSONObject) json.get(1)).get("id");
if (val == null) {
return null;
}
}
public String getStringAttribute(String name) {
- JSONValue val = ((JSONObject) json.get(1)).get(name);
+ final JSONValue val = ((JSONObject) json.get(1)).get(name);
if (val == null) {
return null;
}
}
public Set getAttributeNames() {
- HashSet attrs = new HashSet(((JSONObject) json.get(1)).keySet());
+ final HashSet attrs = new HashSet(((JSONObject) json.get(1)).keySet());
attrs.remove("v");
return attrs;
}
public int getIntAttribute(String name) {
- JSONValue val = ((JSONObject) json.get(1)).get(name);
+ final JSONValue val = ((JSONObject) json.get(1)).get(name);
if (val == null) {
return 0;
}
- double num = ((JSONNumber) val).getValue();
+ final double num = ((JSONNumber) val).getValue();
return (int) num;
}
public long getLongAttribute(String name) {
- JSONValue val = ((JSONObject) json.get(1)).get(name);
+ final JSONValue val = ((JSONObject) json.get(1)).get(name);
if (val == null) {
return 0;
}
- double num = ((JSONNumber) val).getValue();
+ final double num = ((JSONNumber) val).getValue();
return (long) num;
}
public float getFloatAttribute(String name) {
- JSONValue val = ((JSONObject) json.get(1)).get(name);
+ final JSONValue val = ((JSONObject) json.get(1)).get(name);
if (val == null) {
return 0;
}
- double num = ((JSONNumber) val).getValue();
+ final double num = ((JSONNumber) val).getValue();
return (float) num;
}
public double getDoubleAttribute(String name) {
- JSONValue val = ((JSONObject) json.get(1)).get(name);
+ final JSONValue val = ((JSONObject) json.get(1)).get(name);
if (val == null) {
return 0;
}
- double num = ((JSONNumber) val).getValue();
+ final double num = ((JSONNumber) val).getValue();
return num;
}
public boolean getBooleanAttribute(String name) {
- JSONValue val = ((JSONObject) json.get(1)).get(name);
+ final JSONValue val = ((JSONObject) json.get(1)).get(name);
if (val == null) {
return false;
}
}
public String[] getStringArrayAttribute(String name) {
- JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name);
- String[] s = new String[a.size()];
+ final JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name);
+ final String[] s = new String[a.size()];
for (int i = 0; i < a.size(); i++) {
s[i] = ((JSONString) a.get(i)).stringValue();
}
}
public int[] getIntArrayAttribute(String name) {
- JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name);
- int[] s = new int[a.size()];
+ final JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name);
+ final int[] s = new int[a.size()];
for (int i = 0; i < a.size(); i++) {
s[i] = Integer.parseInt(((JSONString) a.get(i)).stringValue());
}
}
public HashSet getStringArrayAttributeAsSet(String string) {
- JSONArray a = getArrayVariable(string);
- HashSet s = new HashSet();
+ final JSONArray a = getArrayVariable(string);
+ final HashSet s = new HashSet();
for (int i = 0; i < a.size(); i++) {
s.add(((JSONString) a.get(i)).stringValue());
}
public UIDL getChildUIDL(int i) {
- JSONValue c = json.get(i + 2);
+ final JSONValue c = json.get(i + 2);
if (c == null) {
return null;
}
public String getChildString(int i) {
- JSONValue c = json.get(i + 2);
+ final JSONValue c = json.get(i + 2);
if (c.isString() != null) {
return ((JSONString) c).stringValue();
}
public Object next() {
if (json.size() > index) {
- JSONValue c = json.get(index++);
+ final JSONValue c = json.get(index++);
if (c.isString() != null) {
return c.isString().stringValue();
} else if (c.isArray() != null) {
public String toString() {
String s = "<" + getTag();
- for (Iterator i = getAttributeNames().iterator(); i.hasNext();) {
- String name = i.next().toString();
+ for (final Iterator i = getAttributeNames().iterator(); i.hasNext();) {
+ final String name = i.next().toString();
s += " " + name + "=";
- JSONValue v = ((JSONObject) json.get(1)).get(name);
+ final JSONValue v = ((JSONObject) json.get(1)).get(name);
if (v.isString() != null) {
s += v;
} else {
s += ">\n";
- Iterator i = getChildIterator();
+ final Iterator i = getChildIterator();
while (i.hasNext()) {
- Object c = i.next();
+ final Object c = i.next();
s += c.toString();
}
public String getChildrenAsXML() {
String s = "";
- Iterator i = getChildIterator();
+ final Iterator i = getChildIterator();
while (i.hasNext()) {
- Object c = i.next();
+ final Object c = i.next();
s += c.toString();
}
return s;
removeItem(root);
UIDLBrowser.this.removeTreeListener(this);
addItem(dir());
- Iterator it = treeItemIterator();
+ final Iterator it = treeItemIterator();
while (it.hasNext()) {
((TreeItem) it.next()).setState(true);
}
public TreeItem dir() {
String nodeName = getTag();
- for (Iterator i = getAttributeNames().iterator(); i.hasNext();) {
- String name = i.next().toString();
- String value = getAttribute(name);
+ for (final Iterator i = getAttributeNames().iterator(); i.hasNext();) {
+ final String name = i.next().toString();
+ final String value = getAttribute(name);
nodeName += " " + name + "=" + value;
}
- TreeItem item = new TreeItem(nodeName);
+ final TreeItem item = new TreeItem(nodeName);
try {
TreeItem tmp = null;
- for (Iterator i = getVariableHash().keySet().iterator(); i
+ for (final Iterator i = getVariableHash().keySet().iterator(); i
.hasNext();) {
- String name = i.next().toString();
+ final String name = i.next().toString();
String value = "";
try {
value = getStringVariable(name);
- } catch (Exception e) {
+ } catch (final Exception e) {
try {
- JSONArray a = getArrayVariable(name);
+ final JSONArray a = getArrayVariable(name);
value = a.toString();
- } catch (Exception e2) {
+ } catch (final Exception e2) {
try {
- int intVal = getIntVariable(name);
+ final int intVal = getIntVariable(name);
value = String.valueOf(intVal);
- } catch (Exception e3) {
+ } catch (final Exception e3) {
value = "unknown";
}
}
if (tmp != null) {
item.addItem(tmp);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
// Ingonered, no variables
}
- Iterator i = getChildIterator();
+ final Iterator i = getChildIterator();
while (i.hasNext()) {
- Object child = i.next();
+ final Object child = i.next();
try {
- UIDL c = (UIDL) child;
+ final UIDL c = (UIDL) child;
item.addItem(c.dir());
- } catch (Exception e) {
+ } catch (final Exception e) {
item.addItem(child.toString());
}
}
}
private JSONObject getVariableHash() {
- JSONObject v = (JSONObject) ((JSONObject) json.get(1)).get("v");
+ final JSONObject v = (JSONObject) ((JSONObject) json.get(1)).get("v");
if (v == null) {
throw new IllegalArgumentException("No variables defined in tag.");
}
Object v = null;
try {
v = getVariableHash().get(name);
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
return v != null;
}
public String getStringVariable(String name) {
- JSONString t = (JSONString) getVariableHash().get(name);
+ final JSONString t = (JSONString) getVariableHash().get(name);
if (t == null) {
throw new IllegalArgumentException("No such variable: " + name);
}
}
public int getIntVariable(String name) {
- JSONNumber t = (JSONNumber) getVariableHash().get(name);
+ final JSONNumber t = (JSONNumber) getVariableHash().get(name);
if (t == null) {
throw new IllegalArgumentException("No such variable: " + name);
}
}
public long getLongVariable(String name) {
- JSONNumber t = (JSONNumber) getVariableHash().get(name);
+ final JSONNumber t = (JSONNumber) getVariableHash().get(name);
if (t == null) {
throw new IllegalArgumentException("No such variable: " + name);
}
}
public float getFloatVariable(String name) {
- JSONNumber t = (JSONNumber) getVariableHash().get(name);
+ final JSONNumber t = (JSONNumber) getVariableHash().get(name);
if (t == null) {
throw new IllegalArgumentException("No such variable: " + name);
}
}
public double getDoubleVariable(String name) {
- JSONNumber t = (JSONNumber) getVariableHash().get(name);
+ final JSONNumber t = (JSONNumber) getVariableHash().get(name);
if (t == null) {
throw new IllegalArgumentException("No such variable: " + name);
}
}
public boolean getBooleanVariable(String name) {
- JSONBoolean t = (JSONBoolean) getVariableHash().get(name);
+ final JSONBoolean t = (JSONBoolean) getVariableHash().get(name);
if (t == null) {
throw new IllegalArgumentException("No such variable: " + name);
}
}
private JSONArray getArrayVariable(String name) {
- JSONArray t = (JSONArray) getVariableHash().get(name);
+ final JSONArray t = (JSONArray) getVariableHash().get(name);
if (t == null) {
throw new IllegalArgumentException("No such variable: " + name);
}
}
public String[] getStringArrayVariable(String name) {
- JSONArray a = getArrayVariable(name);
- String[] s = new String[a.size()];
+ final JSONArray a = getArrayVariable(name);
+ final String[] s = new String[a.size()];
for (int i = 0; i < a.size(); i++) {
s[i] = ((JSONString) a.get(i)).stringValue();
}
}
public Set getStringArrayVariableAsSet(String name) {
- JSONArray a = getArrayVariable(name);
- HashSet s = new HashSet();
+ final JSONArray a = getArrayVariable(name);
+ final HashSet s = new HashSet();
for (int i = 0; i < a.size(); i++) {
s.add(((JSONString) a.get(i)).stringValue());
}
}
public int[] getIntArrayVariable(String name) {
- JSONArray a = getArrayVariable(name);
- int[] s = new int[a.size()];
+ final JSONArray a = getArrayVariable(name);
+ final int[] s = new int[a.size()];
for (int i = 0; i < a.size(); i++) {
- JSONValue v = a.get(i);
+ final JSONValue v = a.get(i);
s[i] = v.isNumber() != null ? (int) ((JSONNumber) v).getValue()
: Integer.parseInt(v.toString());
}
}
public String getXMLAsString() {
- StringBuffer sb = new StringBuffer();
- for (Iterator it = x.keySet().iterator(); it.hasNext();) {
- String tag = (String) it.next();
+ final StringBuffer sb = new StringBuffer();
+ for (final Iterator it = x.keySet().iterator(); it.hasNext();) {
+ final String tag = (String) it.next();
sb.append("<");
sb.append(tag);
sb.append(">");
}
public UIDL getErrors() {
- JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get("error");
+ final JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get("error");
return new UIDL(a);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import java.util.Iterator;
*
*/
public static native void browserDebugger() /*-{
- if(window.console)
- debugger;
- }-*/;
+ if(window.console)
+ debugger;
+ }-*/;
/**
* Detects if current browser is IE.
* @return true if IE
*/
public static native boolean isIE() /*-{
- var browser=$wnd.navigator.appName;
- if (browser=="Microsoft Internet Explorer") {
- return true;
- }
- return false;
- }-*/;
+ var browser=$wnd.navigator.appName;
+ if (browser=="Microsoft Internet Explorer") {
+ return true;
+ }
+ return false;
+ }-*/;
/**
* Detects if current browser is IE6.
* @return true if IE6
*/
public static native boolean isIE6() /*-{
- var browser=$wnd.navigator.appName;
- if (browser=="Microsoft Internet Explorer") {
- var ua = navigator.userAgent;
- var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
- if (re.exec(ua) != null)
- rv = parseFloat(RegExp.$1);
- if(rv == 6) return true;
- }
- return false;
- }-*/;
+ var browser=$wnd.navigator.appName;
+ if (browser=="Microsoft Internet Explorer") {
+ var ua = navigator.userAgent;
+ var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+ if (re.exec(ua) != null)
+ rv = parseFloat(RegExp.$1);
+ if(rv == 6) return true;
+ }
+ return false;
+ }-*/;
/**
* Nulls oncontextmenu function on given element. We need to manually clear
* @param el
*/
public native static void removeContextMenuEvent(Element el) /*-{
- el.oncontextmenu = null;
- }-*/;
+ el.oncontextmenu = null;
+ }-*/;
/**
* Traverses recursively ancestors until ContainerResizedListener child
* @param container
*/
public static void runDescendentsLayout(HasWidgets container) {
- Iterator childWidgets = container.iterator();
+ final Iterator childWidgets = container.iterator();
while (childWidgets.hasNext()) {
- Widget child = (Widget) childWidgets.next();
+ final Widget child = (Widget) childWidgets.next();
if (child instanceof ContainerResizedListener) {
((ContainerResizedListener) child).iLayout();
} else if (child instanceof HasWidgets) {
- HasWidgets childContainer = (HasWidgets) child;
+ final HasWidgets childContainer = (HasWidgets) child;
runDescendentsLayout(childContainer);
}
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client;
import com.google.gwt.core.client.EntryPoint;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.Command;
public abstract void execute();
public String getHTML() {
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
sb.append("<div>");
if (getIconUrl() != null) {
sb.append("<img src=\"" + getIconUrl() + "\" alt=\"icon\" />");
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
public class AlignmentInfo {
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import java.util.Date;\r
import com.itmill.toolkit.terminal.gwt.client.DateTimeService;\r
\r
public class CalendarEntry {\r
- private String styleName;\r
+ private final String styleName;\r
private Date start;\r
private Date end;\r
private String title;\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import java.util.Date;\r
public class CalendarPanel extends FlexTable implements MouseListener,\r
ClickListener {\r
\r
- private IDateField datefield;\r
+ private final IDateField datefield;\r
\r
private IEventButton prevYear;\r
\r
}\r
\r
private void buildCalendar(boolean forceRedraw) {\r
- boolean needsMonth = datefield.getCurrentResolution() > IDateField.RESOLUTION_YEAR;\r
+ final boolean needsMonth = datefield.getCurrentResolution() > IDateField.RESOLUTION_YEAR;\r
boolean needsBody = datefield.getCurrentResolution() >= IDateField.RESOLUTION_DAY;\r
- boolean needsTime = datefield.getCurrentResolution() >= IDateField.RESOLUTION_HOUR;\r
+ final boolean needsTime = datefield.getCurrentResolution() >= IDateField.RESOLUTION_HOUR;\r
buildCalendarHeader(forceRedraw, needsMonth);\r
clearCalendarBody(!needsBody);\r
if (needsBody) {\r
}\r
\r
// Print weekday names\r
- int firstDay = datefield.getDateTimeService().getFirstDayOfWeek();\r
+ final int firstDay = datefield.getDateTimeService()\r
+ .getFirstDayOfWeek();\r
for (int i = 0; i < 7; i++) {\r
int day = i + firstDay;\r
if (day > 6) {\r
}\r
}\r
\r
- String monthName = needsMonth ? datefield.getDateTimeService()\r
+ final String monthName = needsMonth ? datefield.getDateTimeService()\r
.getMonth(datefield.getCurrentDate().getMonth()) : "";\r
- int year = datefield.getCurrentDate().getYear() + 1900;\r
+ final int year = datefield.getCurrentDate().getYear() + 1900;\r
setHTML(0, 2, "<span class=\"" + IDateField.CLASSNAME\r
+ "-calendarpanel-month\">" + monthName + " " + year\r
+ "</span>");\r
if (date == null) {\r
date = new Date();\r
}\r
- int startWeekDay = datefield.getDateTimeService().getStartWeekDay(date);\r
- int numDays = DateTimeService.getNumberOfDaysInMonth(date);\r
+ final int startWeekDay = datefield.getDateTimeService()\r
+ .getStartWeekDay(date);\r
+ final int numDays = DateTimeService.getNumberOfDaysInMonth(date);\r
int dayCount = 0;\r
- Date today = new Date();\r
- Date curr = new Date(date.getTime());\r
+ final Date today = new Date();\r
+ final Date curr = new Date(date.getTime());\r
for (int row = 2; row < 8; row++) {\r
for (int col = 0; col < 7; col++) {\r
if (!(row == 2 && col < startWeekDay)) {\r
if (dayCount < numDays) {\r
- int selectedDate = ++dayCount;\r
+ final int selectedDate = ++dayCount;\r
String title = "";\r
if (entrySource != null) {\r
curr.setDate(dayCount);\r
- List entries = entrySource.getEntries(curr,\r
+ final List entries = entrySource.getEntries(curr,\r
IDateField.RESOLUTION_DAY);\r
if (entries != null) {\r
- for (Iterator it = entries.iterator(); it\r
+ for (final Iterator it = entries.iterator(); it\r
.hasNext();) {\r
- CalendarEntry entry = (CalendarEntry) it\r
+ final CalendarEntry entry = (CalendarEntry) it\r
.next();\r
title += (title.length() > 0 ? ", " : "")\r
+ entry.getStringForDate(curr);\r
}\r
}\r
}\r
- String baseclass = IDateField.CLASSNAME\r
+ final String baseclass = IDateField.CLASSNAME\r
+ "-calendarpanel-day";\r
String cssClass = baseclass;\r
if (!isEnabledDate(curr)) {\r
\r
private class DateClickListener implements TableListener {\r
\r
- private CalendarPanel cal;\r
+ private final CalendarPanel cal;\r
\r
public DateClickListener(CalendarPanel panel) {\r
cal = panel;\r
return;\r
}\r
\r
- String text = cal.getText(row, col);\r
+ final String text = cal.getText(row, col);\r
if (text.equals(" ")) {\r
return;\r
}\r
\r
try {\r
- Integer day = new Integer(text);\r
- Date newDate = new Date(cal.datefield.getCurrentDate()\r
+ final Integer day = new Integer(text);\r
+ final Date newDate = new Date(cal.datefield.getCurrentDate()\r
.getTime());\r
newDate.setDate(day.intValue());\r
if (!isEnabledDate(newDate)) {\r
cal.datefield.isImmediate());\r
\r
updateCalendar();\r
- } catch (NumberFormatException e) {\r
+ } catch (final NumberFormatException e) {\r
// Not a number, ignore and stop here\r
return;\r
}\r
\r
public void setLimits(Date min, Date max) {\r
if (min != null) {\r
- Date d = new Date(min.getTime());\r
+ final Date d = new Date(min.getTime());\r
d.setHours(0);\r
d.setMinutes(0);\r
d.setSeconds(1);\r
minDate = null;\r
}\r
if (max != null) {\r
- Date d = new Date(max.getTime());\r
+ final Date d = new Date(max.getTime());\r
d.setHours(24);\r
d.setMinutes(59);\r
d.setSeconds(59);\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.Window;
private ActionOwner actionOwner;
- private CMenuBar menu = new CMenuBar();
+ private final CMenuBar menu = new CMenuBar();
private int left;
this.left = left;
this.top = top;
menu.clearItems();
- Action[] actions = actionOwner.getActions();
+ final Action[] actions = actionOwner.getActions();
for (int i = 0; i < actions.length; i++) {
- Action a = actions[i];
+ final Action a = actions[i];
menu.addItem(new MenuItem(a.getHTML(), true, a));
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
private Element errorIndicatorElement;
- private Element captionElement = DOM.createSpan();
+ private final Element captionElement = DOM.createSpan();
private ErrorMessage errorMessage;
// handle error
if (uidl.hasAttribute("error")) {
- UIDL errorUidl = uidl.getErrors();
+ final UIDL errorUidl = uidl.getErrors();
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
DOM.setElementProperty(errorIndicatorElement, "className",
}
public void onBrowserEvent(Event event) {
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (errorIndicatorElement != null
&& DOM.compare(target, errorIndicatorElement)) {
switch (DOM.eventGetType(event)) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
}
if (uidl.hasAttribute("error")) {
- UIDL errorUidl = uidl.getErrors();
+ final UIDL errorUidl = uidl.getErrors();
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (errorIndicatorElement != null
&& DOM.compare(target, errorIndicatorElement)) {
switch (DOM.eventGetType(event)) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.ui.SimplePanel;
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- UIDL child = uidl.getChildUIDL(0);
+ final UIDL child = uidl.getChildUIDL(0);
if (child != null) {
- Paintable p = (Paintable) client.getWidget(child);
+ final Paintable p = (Paintable) client.getWidget(child);
if (p != getWidget()) {
if (getWidget() != null) {
client.unregisterPaintable((Paintable) getWidget());
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.HashMap;
public static final String CLASSNAME = "i-customlayout";
/** Location-name to containing element in DOM map */
- private HashMap locationToElement = new HashMap();
+ private final HashMap locationToElement = new HashMap();
/** Location-name to contained widget map */
- private HashMap locationToWidget = new HashMap();
+ private final HashMap locationToWidget = new HashMap();
/** Widget to captionwrapper map */
- private HashMap widgetToCaptionWrapper = new HashMap();
+ private final HashMap widgetToCaptionWrapper = new HashMap();
/** Currently rendered style */
String currentTemplate;
}
// Get previous widget
- Widget previous = (Widget) locationToWidget.get(location);
+ final Widget previous = (Widget) locationToWidget.get(location);
// NOP if given widget already exists in this location
if (previous == widget) {
return;
iLayout();
// For all contained widgets
- for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
- UIDL uidlForChild = (UIDL) i.next();
+ for (final Iterator i = uidl.getChildIterator(); i.hasNext();) {
+ final UIDL uidlForChild = (UIDL) i.next();
if (uidlForChild.getTag().equals("location")) {
- String location = uidlForChild.getStringAttribute("name");
- Widget child = client.getWidget(uidlForChild.getChildUIDL(0));
+ final String location = uidlForChild.getStringAttribute("name");
+ final Widget child = client.getWidget(uidlForChild
+ .getChildUIDL(0));
try {
setWidget(child, location);
((Paintable) child).updateFromUIDL(uidlForChild
.getChildUIDL(0), client);
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// If no location is found, this component is not visible
}
}
/** Initialize HTML-layout. */
private void initializeHTML(UIDL uidl, ApplicationConnection client) {
- String newTemplate = uidl.getStringAttribute("template");
+ final String newTemplate = uidl.getStringAttribute("template");
// Get the HTML-template from client
String template = client
/** Collect locations from template */
private void scanForLocations(Element elem) {
- String location = getLocation(elem);
+ final String location = getLocation(elem);
if (location != null) {
locationToElement.put(location, elem);
DOM.setInnerHTML(elem, "");
} else {
- int len = DOM.getChildCount(elem);
+ final int len = DOM.getChildCount(elem);
for (int i = 0; i < len; i++) {
scanForLocations(DOM.getChild(elem, i));
}
while (scriptStart > 0) {
res += html.substring(endOfPrevScript, scriptStart);
scriptStart = lc.indexOf(">", scriptStart);
- int j = lc.indexOf("</script>", scriptStart);
+ final int j = lc.indexOf("</script>", scriptStart);
scripts += html.substring(scriptStart + 1, j) + ";";
nextPosToCheck = endOfPrevScript = j + "</script>".length();
scriptStart = lc.indexOf("<script", nextPosToCheck);
} else {
res = "";
startOfBody = lc.indexOf(">", startOfBody) + 1;
- int endOfBody = lc.indexOf("</body>", startOfBody);
+ final int endOfBody = lc.indexOf("</body>", startOfBody);
if (endOfBody > startOfBody) {
res = html.substring(startOfBody, endOfBody);
} else {
/** Replace child components */
public void replaceChildComponent(Widget from, Widget to) {
- String location = getLocation(from);
+ final String location = getLocation(from);
if (location == null) {
throw new IllegalArgumentException();
}
.get(component);
if (Caption.isNeeded(uidl)) {
if (wrapper == null) {
- String loc = getLocation((Widget) component);
+ final String loc = getLocation((Widget) component);
super.remove((Widget) component);
wrapper = new CaptionWrapper(component, client);
super.add(wrapper, (Element) locationToElement.get(loc));
wrapper.updateCaption(uidl);
} else {
if (wrapper != null) {
- String loc = getLocation((Widget) component);
+ final String loc = getLocation((Widget) component);
super.remove(wrapper);
super.add((Widget) wrapper.getPaintable(),
(Element) locationToElement.get(loc));
/** Get the location of an widget */
public String getLocation(Widget w) {
- for (Iterator i = locationToWidget.keySet().iterator(); i.hasNext();) {
- String location = (String) i.next();
+ for (final Iterator i = locationToWidget.keySet().iterator(); i
+ .hasNext();) {
+ final String location = (String) i.next();
if (locationToWidget.get(location) == w) {
return location;
}
/** Removes given widget from the layout */
public boolean remove(Widget w) {
client.unregisterPaintable((Paintable) w);
- String location = getLocation(w);
+ final String location = getLocation(w);
if (location != null) {
locationToWidget.remove(location);
}
- CaptionWrapper cw = (CaptionWrapper) widgetToCaptionWrapper.get(w);
+ final CaptionWrapper cw = (CaptionWrapper) widgetToCaptionWrapper
+ .get(w);
if (cw != null) {
widgetToCaptionWrapper.remove(w);
return super.remove(cw);
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import java.util.Date;\r
enabled = !uidl.getBooleanAttribute("disabled");\r
\r
if (uidl.hasAttribute("locale")) {\r
- String locale = uidl.getStringAttribute("locale");\r
+ final String locale = uidl.getStringAttribute("locale");\r
try {\r
dts.setLocale(locale);\r
currentLocale = locale;\r
- } catch (LocaleNotLoadedException e) {\r
+ } catch (final LocaleNotLoadedException e) {\r
currentLocale = dts.getLocale();\r
// TODO redirect this to console\r
System.out.println("Tried to use an unloaded locale \""\r
\r
currentResolution = newResolution;\r
\r
- int year = uidl.getIntVariable("year");\r
- int month = (currentResolution >= RESOLUTION_MONTH) ? uidl\r
+ final int year = uidl.getIntVariable("year");\r
+ final int month = (currentResolution >= RESOLUTION_MONTH) ? uidl\r
.getIntVariable("month") : -1;\r
- int day = (currentResolution >= RESOLUTION_DAY) ? uidl\r
+ final int day = (currentResolution >= RESOLUTION_DAY) ? uidl\r
.getIntVariable("day") : -1;\r
- int hour = (currentResolution >= RESOLUTION_HOUR) ? uidl\r
+ final int hour = (currentResolution >= RESOLUTION_HOUR) ? uidl\r
.getIntVariable("hour") : -1;\r
- int min = (currentResolution >= RESOLUTION_MIN) ? uidl\r
+ final int min = (currentResolution >= RESOLUTION_MIN) ? uidl\r
.getIntVariable("min") : -1;\r
- int sec = (currentResolution >= RESOLUTION_SEC) ? uidl\r
+ final int sec = (currentResolution >= RESOLUTION_SEC) ? uidl\r
.getIntVariable("sec") : -1;\r
- int msec = (currentResolution >= RESOLUTION_MSEC) ? uidl\r
+ final int msec = (currentResolution >= RESOLUTION_MSEC) ? uidl\r
.getIntVariable("msec") : -1;\r
\r
// Construct new date for this datefield (only if not null)\r
*/\r
private static native double getTime(int y, int m, int d, int h, int mi,\r
int s, int ms) /*-{\r
- try {\r
- var date = new Date();\r
- if(y && y >= 0) date.setFullYear(y);\r
- if(m && m >= 1) date.setMonth(m-1);\r
- if(d && d >= 0) date.setDate(d);\r
- if(h && h >= 0) date.setHours(h);\r
- if(mi && mi >= 0) date.setMinutes(mi);\r
- if(s && s >= 0) date.setSeconds(s);\r
- if(ms && ms >= 0) date.setMilliseconds(ms);\r
- return date.getTime();\r
- } catch (e) {\r
- // TODO print some error message on the console\r
- //console.log(e);\r
- return (new Date()).getTime();\r
- }\r
- }-*/;\r
+ try {\r
+ var date = new Date();\r
+ if(y && y >= 0) date.setFullYear(y);\r
+ if(m && m >= 1) date.setMonth(m-1);\r
+ if(d && d >= 0) date.setDate(d);\r
+ if(h && h >= 0) date.setHours(h);\r
+ if(mi && mi >= 0) date.setMinutes(mi);\r
+ if(s && s >= 0) date.setSeconds(s);\r
+ if(ms && ms >= 0) date.setMilliseconds(ms);\r
+ return date.getTime();\r
+ } catch (e) {\r
+ // TODO print some error message on the console\r
+ //console.log(e);\r
+ return (new Date()).getTime();\r
+ }\r
+ }-*/;\r
\r
public int getMilliseconds() {\r
return (int) (date.getTime() - date.getTime() / 1000 * 1000);\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
\r
public class IDateFieldCalendar extends IDateField {\r
\r
- private CalendarPanel date;\r
+ private final CalendarPanel date;\r
\r
public IDateFieldCalendar() {\r
super();\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
if (client.updateComponent(this, uidl, true)) {
return;
}
- String w = uidl.hasAttribute("width") ? uidl
+ final String w = uidl.hasAttribute("width") ? uidl
.getStringAttribute("width") : "100%";
- String h = uidl.hasAttribute("height") ? uidl
+ final String h = uidl.hasAttribute("height") ? uidl
.getStringAttribute("height") : "100%";
DOM.setStyleAttribute(getElement(), "width", w);
DOM.setStyleAttribute(getElement(), "height", h);
if (uidl.hasAttribute("type")) {
- String type = uidl.getStringAttribute("type");
+ final String type = uidl.getStringAttribute("type");
if (type.equals("image")) {
setHTML("<img src=\"" + getSrc(uidl, client) + "\"/>");
} else if (type.equals("browser")) {
"Unknown Embedded type '" + type + "'");
}
} else if (uidl.hasAttribute("mimetype")) {
- String mime = uidl.getStringAttribute("mimetype");
+ final String mime = uidl.getStringAttribute("mimetype");
if (mime.equals("application/x-shockwave-flash")) {
setHTML("<object width=\"" + w + "\" height=\"" + h
+ "\"><param name=\"movie\" value=\""
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.ArrayList;
}
public void add(Widget w) {
- WidgetWrapper wrapper = createWidgetWrappper();
+ final WidgetWrapper wrapper = createWidgetWrappper();
DOM.appendChild(childContainer, wrapper.getElement());
super.add(w, wrapper.getContainerElement());
}
* @return
*/
public WidgetWrapper getWidgetWrapperFor(Widget child) {
- Element containerElement = DOM.getParent(child.getElement());
+ final Element containerElement = DOM.getParent(child.getElement());
if (orientationMode == ORIENTATION_HORIZONTAL) {
return new HorizontalWidgetWrapper(containerElement);
} else {
}
void setExpandedSize(int pixels) {
- int spaceForMarginsAndSpacings = getOffsetHeight()
+ final int spaceForMarginsAndSpacings = getOffsetHeight()
- DOM.getElementPropertyInt(getElement(), "clientHeight");
int fixedInnerSize = pixels - spaceForMarginsAndSpacings;
if (fixedInnerSize < 0) {
} else {
if (td == null) {
// build one cell table
- Element table = DOM.createTable();
- Element tBody = DOM.createTBody();
- Element tr = DOM.createTR();
+ final Element table = DOM.createTable();
+ final Element tBody = DOM.createTBody();
+ final Element tr = DOM.createTR();
td = DOM.createTD();
DOM.appendChild(table, tBody);
DOM.appendChild(tBody, tr);
DOM.setElementProperty(td, "className", CLASSNAME
+ "-valign");
// move possible content to cell
- Element content = DOM.getFirstChild(getElement());
+ final Element content = DOM.getFirstChild(getElement());
if (content != null) {
DOM.removeChild(getElement(), content);
DOM.appendChild(td, content);
}
protected ArrayList getPaintables() {
- ArrayList al = new ArrayList();
- Iterator it = iterator();
+ final ArrayList al = new ArrayList();
+ final Iterator it = iterator();
while (it.hasNext()) {
- Widget w = (Widget) it.next();
+ final Widget w = (Widget) it.next();
if (w instanceof Paintable) {
al.add(w);
}
// Component alignments as a comma separated list.
// See com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.java for
// possible values.
- int[] alignments = uidl.getIntArrayAttribute("alignments");
+ final int[] alignments = uidl.getIntArrayAttribute("alignments");
int alignmentIndex = 0;
// Set alignment attributes
- Iterator it = getPaintables().iterator();
+ final Iterator it = getPaintables().iterator();
boolean first = true;
while (it.hasNext()) {
// Calculate alignment info
- AlignmentInfo ai = new AlignmentInfo(alignments[alignmentIndex++]);
- WidgetWrapper wr = getWidgetWrapperFor((Widget) it.next());
+ final AlignmentInfo ai = new AlignmentInfo(
+ alignments[alignmentIndex++]);
+ final WidgetWrapper wr = getWidgetWrapperFor((Widget) it.next());
wr.setAlignment(ai.getVerticalAlignment(), ai
.getHorizontalAlignment());
if (first) {
}
protected void handleMargins(UIDL uidl) {
- MarginInfo margins = new MarginInfo(uidl.getIntAttribute("margins"));
+ final MarginInfo margins = new MarginInfo(uidl
+ .getIntAttribute("margins"));
setStyleName(me, CLASSNAME + "-" + StyleConstants.LAYOUT_MARGIN_TOP,
margins.hasTop());
setStyleName(me, StyleConstants.LAYOUT_MARGIN_RIGHT, margins.hasRight());
return;
}
- int availableSpace = getAvailableSpace();
+ final int availableSpace = getAvailableSpace();
- int usedSpace = getUsedSpace();
+ final int usedSpace = getUsedSpace();
int spaceForExpandedWidget = availableSpace - usedSpace;
spaceForExpandedWidget = EXPANDED_ELEMENTS_MIN_WIDTH;
}
- WidgetWrapper wr = getWidgetWrapperFor(expandedWidget);
+ final WidgetWrapper wr = getWidgetWrapperFor(expandedWidget);
wr.setExpandedSize(spaceForExpandedWidget);
// TODO save previous size and only propagate if really changed
private int getUsedSpace() {
int total = 0;
- int widgetCount = getWidgetCount();
- Iterator it = iterator();
+ final int widgetCount = getWidgetCount();
+ final Iterator it = iterator();
while (it.hasNext()) {
- Widget w = (Widget) it.next();
+ final Widget w = (Widget) it.next();
if (w != expandedWidget) {
- WidgetWrapper wr = getWidgetWrapperFor(w);
+ final WidgetWrapper wr = getWidgetWrapperFor(w);
if (orientationMode == ORIENTATION_VERTICAL) {
total += wr.getOffsetHeight();
} else {
private int getSpacingSize() {
if (hasComponentSpacing) {
if (spacingSize < 0) {
- Element temp = DOM.createDiv();
- WidgetWrapper wr = createWidgetWrappper();
+ final Element temp = DOM.createDiv();
+ final WidgetWrapper wr = createWidgetWrappper();
wr.setSpacingEnabled(true);
DOM.appendChild(temp, wr.getElement());
DOM.setStyleAttribute(temp, "position", "absolute");
DOM.setStyleAttribute(getElement(), "overflow", "visible");
}
- int marginTop = DOM.getElementPropertyInt(DOM.getFirstChild(me),
- "offsetTop")
+ final int marginTop = DOM.getElementPropertyInt(DOM
+ .getFirstChild(me), "offsetTop")
- DOM.getElementPropertyInt(element, "offsetTop");
- Element lastElement = DOM.getChild(me, (DOM.getChildCount(me) - 1));
- int marginBottom = DOM.getElementPropertyInt(me, "offsetHeight")
+ final Element lastElement = DOM.getChild(me,
+ (DOM.getChildCount(me) - 1));
+ final int marginBottom = DOM.getElementPropertyInt(me,
+ "offsetHeight")
+ DOM.getElementPropertyInt(me, "offsetTop")
- (DOM.getElementPropertyInt(lastElement, "offsetTop") + DOM
.getElementPropertyInt(lastElement, "offsetHeight"));
protected void insert(Widget w, int beforeIndex) {
if (w instanceof Caption) {
- Caption c = (Caption) w;
+ final Caption c = (Caption) w;
// captions go into same container element as their
// owners
- Element container = DOM.getParent(((UIObject) c.getOwner())
+ final Element container = DOM.getParent(((UIObject) c.getOwner())
.getElement());
- Element captionContainer = DOM.createDiv();
+ final Element captionContainer = DOM.createDiv();
DOM.insertChild(container, captionContainer, 0);
insert(w, captionContainer, beforeIndex, false);
} else {
- WidgetWrapper wrapper = createWidgetWrappper();
+ final WidgetWrapper wrapper = createWidgetWrappper();
DOM.insertChild(childContainer, wrapper.getElement(), beforeIndex);
insert(w, wrapper.getContainerElement(), beforeIndex, false);
}
}
public boolean remove(Widget w) {
- WidgetWrapper ww = getWidgetWrapperFor(w);
- boolean removed = super.remove(w);
+ final WidgetWrapper ww = getWidgetWrapperFor(w);
+ final boolean removed = super.remove(w);
if (removed) {
if (!(w instanceof Caption)) {
DOM.removeChild(childContainer, ww.getElement());
}
public void removeCaption(Widget w) {
- Caption c = (Caption) componentToCaption.get(w);
+ final Caption c = (Caption) componentToCaption.get(w);
if (c != null) {
this.remove(c);
componentToCaption.remove(w);
}
public boolean removePaintable(Paintable p) {
- Caption c = (Caption) componentToCaption.get(p);
+ final Caption c = (Caption) componentToCaption.get(p);
if (c != null) {
componentToCaption.remove(c);
remove(c);
public void replaceChildComponent(Widget from, Widget to) {
client.unregisterPaintable((Paintable) from);
- Caption c = (Caption) componentToCaption.get(from);
+ final Caption c = (Caption) componentToCaption.get(from);
if (c != null) {
remove(c);
componentToCaption.remove(c);
}
- int index = getWidgetIndex(from);
+ final int index = getWidgetIndex(from);
if (index >= 0) {
remove(index);
insert(to, index);
if (Caption.isNeeded(uidl)) {
if (c == null) {
- int index = getWidgetIndex((Widget) component);
+ final int index = getWidgetIndex((Widget) component);
c = new Caption(component, client);
insert(c, index);
componentToCaption.put(component, c);
hasComponentSpacing = uidl.getBooleanAttribute("spacing");
- ArrayList uidlWidgets = new ArrayList();
- for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
- UIDL cellUidl = (UIDL) it.next();
- Widget child = client.getWidget(cellUidl.getChildUIDL(0));
+ final ArrayList uidlWidgets = new ArrayList();
+ for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {
+ final UIDL cellUidl = (UIDL) it.next();
+ final Widget child = client.getWidget(cellUidl.getChildUIDL(0));
uidlWidgets.add(child);
if (cellUidl.hasAttribute("expanded")) {
expandedWidget = child;
}
}
- ArrayList oldWidgets = getPaintables();
+ final ArrayList oldWidgets = getPaintables();
- Iterator oldIt = oldWidgets.iterator();
- Iterator newIt = uidlWidgets.iterator();
- Iterator newUidl = uidl.getChildIterator();
+ final Iterator oldIt = oldWidgets.iterator();
+ final Iterator newIt = uidlWidgets.iterator();
+ final Iterator newUidl = uidl.getChildIterator();
Widget oldChild = null;
while (newIt.hasNext()) {
- Widget child = (Widget) newIt.next();
- UIDL childUidl = ((UIDL) newUidl.next()).getChildUIDL(0);
+ final Widget child = (Widget) newIt.next();
+ final UIDL childUidl = ((UIDL) newUidl.next()).getChildUIDL(0);
if (oldChild == null && oldIt.hasNext()) {
// search for next old Paintable which still exists in layout
// and delete others
insert(child, index);
} else {
// insert new child before old one
- int index = getWidgetIndex(oldChild);
+ final int index = getWidgetIndex(oldChild);
insert(child, index);
}
if (child != expandedWidget) {
// remove possibly remaining old Paintable object which were not updated
while (oldIt.hasNext()) {
oldChild = (Widget) oldIt.next();
- Paintable p = (Paintable) oldChild;
+ final Paintable p = (Paintable) oldChild;
if (!uidlWidgets.contains(p)) {
removePaintable(p);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.ArrayList;
public class FilterSelectSuggestion implements Suggestion, Command {
- private String key;
- private String caption;
+ private final String key;
+ private final String caption;
private String iconUri;
public FilterSelectSuggestion(UIDL uidl) {
}
public String getDisplayString() {
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
if (iconUri != null) {
sb.append("<img src=\"");
sb.append(iconUri);
private static final String Z_INDEX = "30000";
- private SuggestionMenu menu;
+ private final SuggestionMenu menu;
- private Element up = DOM.createDiv();
- private Element down = DOM.createDiv();
- private Element status = DOM.createDiv();
+ private final Element up = DOM.createDiv();
+ private final Element down = DOM.createDiv();
+ private final Element status = DOM.createDiv();
private boolean isPagingEnabled = true;
setStyleName(CLASSNAME + "-suggestpopup");
DOM.setStyleAttribute(getElement(), "zIndex", Z_INDEX);
- Element root = getContainerElement();
+ final Element root = getContainerElement();
DOM.setInnerHTML(up, "<span>Prev</span>");
DOM.sinkEvents(up, Event.ONCLICK);
public void showSuggestions(Collection currentSuggestions,
int currentPage, int totalSuggestions) {
menu.setSuggestions(currentSuggestions);
- int x = IFilterSelect.this.getAbsoluteLeft();
+ final int x = IFilterSelect.this.getAbsoluteLeft();
int y = tb.getAbsoluteTop();
y += tb.getOffsetHeight();
setPopupPosition(x, y);
- int first = currentPage * PAGELENTH + 1;
- int last = first + currentSuggestions.size() - 1;
+ final int first = currentPage * PAGELENTH + 1;
+ final int last = first + currentSuggestions.size() - 1;
DOM.setInnerText(status, (totalSuggestions == 0 ? 0 : first) + "-"
+ last + "/" + totalSuggestions);
setPrevButtonActive(first > 1);
}
public void selectNextItem() {
- MenuItem cur = menu.getSelectedItem();
- int index = 1 + menu.getItems().indexOf(cur);
+ final MenuItem cur = menu.getSelectedItem();
+ final int index = 1 + menu.getItems().indexOf(cur);
if (menu.getItems().size() > index) {
- MenuItem newSelectedItem = (MenuItem) menu.getItems()
+ final MenuItem newSelectedItem = (MenuItem) menu.getItems()
.get(index);
menu.selectItem(newSelectedItem);
tb.setText(newSelectedItem.getText());
}
public void selectPrevItem() {
- MenuItem cur = menu.getSelectedItem();
- int index = -1 + menu.getItems().indexOf(cur);
+ final MenuItem cur = menu.getSelectedItem();
+ final int index = -1 + menu.getItems().indexOf(cur);
if (index > -1) {
- MenuItem newSelectedItem = (MenuItem) menu.getItems()
+ final MenuItem newSelectedItem = (MenuItem) menu.getItems()
.get(index);
menu.selectItem(newSelectedItem);
tb.setText(newSelectedItem.getText());
filterOptions(currentPage - 1);
}
} else {
- MenuItem newSelectedItem = (MenuItem) menu.getItems().get(
- menu.getItems().size() - 1);
+ final MenuItem newSelectedItem = (MenuItem) menu.getItems()
+ .get(menu.getItems().size() - 1);
menu.selectItem(newSelectedItem);
tb.setText(newSelectedItem.getText());
tb.setSelectionRange(lastFilter.length(), newSelectedItem
}
public void onBrowserEvent(Event event) {
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (DOM.compare(target, up)
|| DOM.compare(target, DOM.getChild(up, 0))) {
filterOptions(currentPage - 1, lastFilter);
}
offsetHeight = getOffsetHeight();
- int desiredWidth = IFilterSelect.this.getOffsetWidth();
+ final int desiredWidth = IFilterSelect.this.getOffsetWidth();
int naturalMenuWidth = DOM.getElementPropertyInt(DOM
.getFirstChild(menu.getElement()), "offsetWidth");
if (naturalMenuWidth < desiredWidth) {
* @return true if popup was just closed
*/
public boolean isJustClosed() {
- long now = (new Date()).getTime();
+ final long now = (new Date()).getTime();
return (lastAutoClosed > 0 && (now - lastAutoClosed) < 200);
}
* to avoid height changes when quickly "scrolling" to last page
*/
public void fixHeightTo(int pagelenth) {
- int pixels = pagelenth * (getOffsetHeight() - 2)
+ final int pixels = pagelenth * (getOffsetHeight() - 2)
/ currentSuggestions.size();
setHeight((pixels + 2) + "px");
}
public void setSuggestions(Collection suggestions) {
clearItems();
- Iterator it = suggestions.iterator();
+ final Iterator it = suggestions.iterator();
while (it.hasNext()) {
- FilterSelectSuggestion s = (FilterSelectSuggestion) it.next();
- MenuItem mi = new MenuItem(s.getDisplayString(), true, s);
+ final FilterSelectSuggestion s = (FilterSelectSuggestion) it
+ .next();
+ final MenuItem mi = new MenuItem(s.getDisplayString(), true, s);
this.addItem(mi);
if (s == currentSuggestion) {
selectItem(mi);
}
public void doSelectedItemAction() {
- MenuItem item = getSelectedItem();
+ final MenuItem item = getSelectedItem();
if (item != null
&& item.getText().toLowerCase().startsWith(
lastFilter.toLowerCase())) {
doItemAction(item, true);
} else if (allowNewItem) {
- String newItemValue = tb.getText();
+ final String newItemValue = tb.getText();
// check for exact match in menu
if (getItems().size() == 1) {
- MenuItem potentialExactMatch = (MenuItem) getItems().get(0);
+ final MenuItem potentialExactMatch = (MenuItem) getItems()
+ .get(0);
if (potentialExactMatch.getText().equals(newItemValue)) {
selectItem(potentialExactMatch);
doSelectedItemAction();
private int currentPage;
- private Collection currentSuggestions = new ArrayList();
+ private final Collection currentSuggestions = new ArrayList();
private boolean immediate;
}
if (clientSideFiltering) {
currentSuggestions.clear();
- for (Iterator it = allSuggestions.iterator(); it.hasNext();) {
- FilterSelectSuggestion s = (FilterSelectSuggestion) it.next();
- String string = s.getDisplayString().toLowerCase();
+ for (final Iterator it = allSuggestions.iterator(); it.hasNext();) {
+ final FilterSelectSuggestion s = (FilterSelectSuggestion) it
+ .next();
+ final String string = s.getDisplayString().toLowerCase();
if (string.startsWith(filter.toLowerCase())) {
currentSuggestions.add(s);
}
allowNewItem = uidl.hasAttribute("allownewitem");
currentSuggestions.clear();
- UIDL options = uidl.getChildUIDL(0);
+ final UIDL options = uidl.getChildUIDL(0);
totalSuggestions = uidl.getIntAttribute("totalitems");
totalMatches = uidl.getIntAttribute("totalMatches");
if (clientSideFiltering) {
allSuggestions = new ArrayList();
}
- for (Iterator i = options.getChildIterator(); i.hasNext();) {
- UIDL optionUidl = (UIDL) i.next();
- FilterSelectSuggestion suggestion = new FilterSelectSuggestion(
+ for (final Iterator i = options.getChildIterator(); i.hasNext();) {
+ final UIDL optionUidl = (UIDL) i.next();
+ final FilterSelectSuggestion suggestion = new FilterSelectSuggestion(
optionUidl);
currentSuggestions.add(suggestion);
if (clientSideFiltering) {
}
// Calculate minumum textarea width
- int minw = minWidth(captions);
- Element spacer = DOM.createDiv();
+ final int minw = minWidth(captions);
+ final Element spacer = DOM.createDiv();
DOM.setStyleAttribute(spacer, "width", minw + "px");
DOM.setStyleAttribute(spacer, "height", "0");
DOM.setStyleAttribute(spacer, "overflow", "hidden");
* Calculate minumum width for FilterSelect textarea
*/
private native int minWidth(String captions) /*-{
- if(!captions || captions.length <= 0)
- return 0;
- captions = captions.split("|");
- var d = $wnd.document.createElement("div");
- var html = "";
- for(var i=0; i < captions.length; i++) {
- html += "<div>" + captions[i] + "</div>";
- // TODO apply same CSS classname as in suggestionmenu
- }
- d.style.position = "absolute";
- d.style.top = "0";
- d.style.left = "0";
- d.style.visibility = "hidden";
- d.innerHTML = html;
- $wnd.document.body.appendChild(d);
- var w = d.offsetWidth;
- $wnd.document.body.removeChild(d);
- return w;
- }-*/;
+ if(!captions || captions.length <= 0)
+ return 0;
+ captions = captions.split("|");
+ var d = $wnd.document.createElement("div");
+ var html = "";
+ for(var i=0; i < captions.length; i++) {
+ html += "<div>" + captions[i] + "</div>";
+ // TODO apply same CSS classname as in suggestionmenu
+ }
+ d.style.position = "absolute";
+ d.style.top = "0";
+ d.style.left = "0";
+ d.style.visibility = "hidden";
+ d.innerHTML = html;
+ $wnd.document.body.appendChild(d);
+ var w = d.offsetWidth;
+ $wnd.document.body.removeChild(d);
+ return w;
+ }-*/;
public void onFocus(Widget sender) {
// NOP
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.ui.SimplePanel;\r
return;\r
}\r
\r
- UIDL layoutUidl = uidl.getChildUIDL(0);\r
+ final UIDL layoutUidl = uidl.getChildUIDL(0);\r
if (lo == null) {\r
lo = (Container) client.getWidget(layoutUidl);\r
setWidget((Widget) lo);\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.HashMap;
}
int i = 0;
- for (Iterator it = uidl.getChildIterator(); it.hasNext(); i++) {
+ for (final Iterator it = uidl.getChildIterator(); it.hasNext(); i++) {
prepareCell(i, 1);
- UIDL childUidl = (UIDL) it.next();
- Paintable p = (Paintable) client.getWidget(childUidl);
+ final UIDL childUidl = (UIDL) it.next();
+ final Paintable p = (Paintable) client.getWidget(childUidl);
Caption c = (Caption) componentToCaption.get(p);
if (c == null) {
c = new Caption(p, client);
componentToCaption.put(p, c);
}
- Paintable oldComponent = (Paintable) getWidget(i, 1);
+ final Paintable oldComponent = (Paintable) getWidget(i, 1);
if (oldComponent == null) {
setWidget(i, 1, (Widget) p);
} else if (oldComponent != p) {
}
i++;
while (getRowCount() > i) {
- Paintable p = (Paintable) getWidget(i, 1);
+ final Paintable p = (Paintable) getWidget(i, 1);
client.unregisterPaintable(p);
componentToCaption.remove(p);
removeRow(i);
int i;
for (i = 0; i < getRowCount(); i++) {
if (oldComponent == getWidget(i, 1)) {
- Caption newCap = new Caption((Paintable) newComponent, client);
+ final Caption newCap = new Caption((Paintable) newComponent,
+ client);
setWidget(i, 0, newCap);
setWidget(i, 1, newComponent);
client.unregisterPaintable((Paintable) oldComponent);
}
public void updateCaption(Paintable component, UIDL uidl) {
- Caption c = (Caption) componentToCaption.get(component);
+ final Caption c = (Caption) componentToCaption.get(component);
if (c != null) {
c.updateCaption(uidl);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.ArrayList;
public static final String CLASSNAME = "i-gridlayout";
/** Widget to captionwrapper map */
- private HashMap widgetToCaptionWrapper = new HashMap();
+ private final HashMap widgetToCaptionWrapper = new HashMap();
public IGridLayout() {
super();
}
int row = 0, column = 0;
- ArrayList oldWidgetWrappers = new ArrayList();
- for (Iterator iterator = iterator(); iterator.hasNext();) {
+ final ArrayList oldWidgetWrappers = new ArrayList();
+ for (final Iterator iterator = iterator(); iterator.hasNext();) {
oldWidgetWrappers.add(iterator.next());
}
clear();
- for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
- UIDL r = (UIDL) i.next();
+ for (final Iterator i = uidl.getChildIterator(); i.hasNext();) {
+ final UIDL r = (UIDL) i.next();
if ("gr".equals(r.getTag())) {
column = 0;
- for (Iterator j = r.getChildIterator(); j.hasNext();) {
- UIDL c = (UIDL) j.next();
+ for (final Iterator j = r.getChildIterator(); j.hasNext();) {
+ final UIDL c = (UIDL) j.next();
if ("gc".equals(c.getTag())) {
prepareCell(row, column);
((FlexCellFormatter) getCellFormatter()).setRowSpan(
row, column, h);
- UIDL u = c.getChildUIDL(0);
+ final UIDL u = c.getChildUIDL(0);
if (u != null) {
- Widget child = client.getWidget(u);
+ final Widget child = client.getWidget(u);
CaptionWrapper wr;
if (widgetToCaptionWrapper.containsKey(child)) {
wr = (CaptionWrapper) widgetToCaptionWrapper
}
// loop oldWidgetWrappers that where not re-attached and unregister them
- for (Iterator it = oldWidgetWrappers.iterator(); it.hasNext();) {
- CaptionWrapper w = (CaptionWrapper) it.next();
+ for (final Iterator it = oldWidgetWrappers.iterator(); it.hasNext();) {
+ final CaptionWrapper w = (CaptionWrapper) it.next();
client.unregisterPaintable(w.getPaintable());
widgetToCaptionWrapper.remove(w.getPaintable());
}
}
public void updateCaption(Paintable component, UIDL uidl) {
- CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper
+ final CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper
.get(component);
wrapper.updateCaption(uidl);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
public class IHorizontalExpandLayout extends IExpandLayout {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.ui.HTML;
return;
}
- String mode = uidl.getStringAttribute("mode");
+ final String mode = uidl.getStringAttribute("mode");
if (mode == null || "text".equals(mode)) {
setText(uidl.getChildString(0));
} else if ("pre".equals(mode)) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
private Element errorIndicatorElement;
- private Element captionElement = DOM.createSpan();
+ private final Element captionElement = DOM.createSpan();
private ErrorMessage errorMessage;
// handle error
if (uidl.hasAttribute("error")) {
- UIDL errorUidl = uidl.getErrors();
+ final UIDL errorUidl = uidl.getErrors();
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
DOM.setElementProperty(errorIndicatorElement, "className",
}
public void onBrowserEvent(Event event) {
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (errorIndicatorElement != null
&& DOM.compare(target, errorIndicatorElement)) {
switch (DOM.eventGetType(event)) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.Iterator;
// can't unselect last item in singleselect mode
select.addItem("", null);
}
- for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
- UIDL optionUidl = (UIDL) i.next();
+ for (final Iterator i = uidl.getChildIterator(); i.hasNext();) {
+ final UIDL optionUidl = (UIDL) i.next();
select.addItem(optionUidl.getStringAttribute("caption"), optionUidl
.getStringAttribute("key"));
if (optionUidl.hasAttribute("selected")) {
}
protected Object[] getSelectedItems() {
- Vector selectedItemKeys = new Vector();
+ final Vector selectedItemKeys = new Vector();
for (int i = 0; i < select.getItemCount(); i++) {
if (select.isItemSelected(i)) {
selectedItemKeys.add(select.getValue(i));
}
public void onChange(Widget sender) {
- int si = select.getSelectedIndex();
+ final int si = select.getSelectedIndex();
if (si == -1 && !isNullSelectionAllowed()) {
select.setSelectedIndex(lastSelectedIndex);
} else {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.Iterator;
// can't unselect last item in singleselect mode
select.addItem("", null);
}
- for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
- UIDL optionUidl = (UIDL) i.next();
+ for (final Iterator i = uidl.getChildIterator(); i.hasNext();) {
+ final UIDL optionUidl = (UIDL) i.next();
select.addItem(optionUidl.getStringAttribute("caption"), optionUidl
.getStringAttribute("key"));
if (optionUidl.hasAttribute("selected")) {
}
protected Object[] getSelectedItems() {
- Vector selectedItemKeys = new Vector();
+ final Vector selectedItemKeys = new Vector();
for (int i = 0; i < select.getItemCount(); i++) {
if (select.isItemSelected(i)) {
selectedItemKeys.add(select.getValue(i));
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import java.util.HashMap;\r
\r
public static final String CLASSNAME = "i-select-optiongroup";\r
\r
- private Panel panel;\r
+ private final Panel panel;\r
\r
- private Map optionsToKeys;\r
+ private final Map optionsToKeys;\r
\r
public IOptionGroup() {\r
super(CLASSNAME);\r
*/\r
protected void buildOptions(UIDL uidl) {\r
panel.clear();\r
- for (Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
- UIDL opUidl = (UIDL) it.next();\r
+ for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
+ final UIDL opUidl = (UIDL) it.next();\r
CheckBox op;\r
if (isMultiselect()) {\r
op = new ICheckBox();\r
public void onClick(Widget sender) {\r
super.onClick(sender);\r
if (sender instanceof CheckBox) {\r
- boolean selected = ((CheckBox) sender).isChecked();\r
- String key = (String) optionsToKeys.get(sender);\r
+ final boolean selected = ((CheckBox) sender).isChecked();\r
+ final String key = (String) optionsToKeys.get(sender);\r
if (!isMultiselect()) {\r
selectedKeys.clear();\r
}\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import java.util.Set;\r
/**\r
* Panel containing the component\r
*/\r
- private Panel container;\r
+ private final Panel container;\r
\r
private ITextField newItemField;\r
\r
cols = uidl.getIntAttribute("cols");\r
rows = uidl.getIntAttribute("rows");\r
\r
- UIDL ops = uidl.getChildUIDL(0);\r
+ final UIDL ops = uidl.getChildUIDL(0);\r
\r
if (getColumns() > 0) {\r
container.setWidth(getColumns() + "em");\r
protected abstract Object[] getSelectedItems();\r
\r
protected Object getSelectedItem() {\r
- Object[] sel = getSelectedItems();\r
+ final Object[] sel = getSelectedItems();\r
if (sel.length > 0) {\r
return sel[0];\r
} else {\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.ArrayList;
size = DOM.createDiv();
DOM.setInnerHTML(size, structure);
margin = DOM.getFirstChild(size);
- Element tBody = DOM.getFirstChild(DOM.getFirstChild(margin));
+ final Element tBody = DOM.getFirstChild(DOM.getFirstChild(margin));
if (orientationMode == ORIENTATION_HORIZONTAL) {
childContainer = DOM.createTR();
DOM.appendChild(tBody, childContainer);
// Update contained components
- ArrayList uidlWidgets = new ArrayList();
- for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
- UIDL uidlForChild = (UIDL) it.next();
- Widget child = client.getWidget(uidlForChild);
+ final ArrayList uidlWidgets = new ArrayList();
+ for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {
+ final UIDL uidlForChild = (UIDL) it.next();
+ final Widget child = client.getWidget(uidlForChild);
uidlWidgets.add(child);
}
- ArrayList oldWidgets = getPaintables();
+ final ArrayList oldWidgets = getPaintables();
- Iterator oldIt = oldWidgets.iterator();
- Iterator newIt = uidlWidgets.iterator();
- Iterator newUidl = uidl.getChildIterator();
+ final Iterator oldIt = oldWidgets.iterator();
+ final Iterator newIt = uidlWidgets.iterator();
+ final Iterator newUidl = uidl.getChildIterator();
Widget oldChild = null;
while (newIt.hasNext()) {
- Widget child = (Widget) newIt.next();
- UIDL childUidl = (UIDL) newUidl.next();
+ final Widget child = (Widget) newIt.next();
+ final UIDL childUidl = (UIDL) newUidl.next();
if (oldChild == null && oldIt.hasNext()) {
// search for next old Paintable which still exists in layout
this.insert(child, index);
} else {
// insert new child before old one
- int index = getWidgetIndex(oldChild);
+ final int index = getWidgetIndex(oldChild);
insert(child, index);
}
((Paintable) child).updateFromUIDL(childUidl, client);
// remove possibly remaining old Paintable object which were not updated
while (oldIt.hasNext()) {
oldChild = (Widget) oldIt.next();
- Paintable p = (Paintable) oldChild;
+ final Paintable p = (Paintable) oldChild;
if (!uidlWidgets.contains(p)) {
removePaintable(p);
}
* @return list of Paintable objects
*/
protected ArrayList getPaintables() {
- ArrayList al = new ArrayList();
- Iterator it = iterator();
+ final ArrayList al = new ArrayList();
+ final Iterator it = iterator();
while (it.hasNext()) {
- Widget w = (Widget) it.next();
+ final Widget w = (Widget) it.next();
if (w instanceof Paintable) {
al.add(w);
}
* Paintable to be removed
*/
public boolean removePaintable(Paintable p) {
- Caption c = (Caption) componentToCaption.get(p);
+ final Caption c = (Caption) componentToCaption.get(p);
if (c != null) {
componentToCaption.remove(c);
remove(c);
*/
public void replaceChildComponent(Widget from, Widget to) {
client.unregisterPaintable((Paintable) from);
- Caption c = (Caption) componentToCaption.get(from);
+ final Caption c = (Caption) componentToCaption.get(from);
if (c != null) {
remove(c);
componentToCaption.remove(c);
}
- int index = getWidgetIndex(from);
+ final int index = getWidgetIndex(from);
if (index >= 0) {
remove(index);
insert(to, index);
protected void insert(Widget w, int beforeIndex) {
if (w instanceof Caption) {
- Caption c = (Caption) w;
+ final Caption c = (Caption) w;
// captions go into same container element as their
// owners
- Element container = DOM.getParent(((UIObject) c.getOwner())
+ final Element container = DOM.getParent(((UIObject) c.getOwner())
.getElement());
- Element captionContainer = DOM.createDiv();
+ final Element captionContainer = DOM.createDiv();
DOM.insertChild(container, captionContainer, 0);
insert(w, captionContainer, beforeIndex, false);
} else {
- Element wrapper = createWidgetWrappper();
+ final Element wrapper = createWidgetWrappper();
DOM.insertChild(childContainer, wrapper, beforeIndex);
insert(w, getWidgetContainerFromWrapper(wrapper), beforeIndex,
false);
* creates an Element which will contain child widget
*/
protected Element createWidgetWrappper() {
- Element td = DOM.createTD();
+ final Element td = DOM.createTD();
// We need this overflow:hidden, because it's the default rendering of
// IE (although it can be overridden with overflow:visible).
DOM.setStyleAttribute(td, "overflow", "hidden");
case ORIENTATION_HORIZONTAL:
return td;
default:
- Element tr = DOM.createTR();
+ final Element tr = DOM.createTR();
DOM.appendChild(tr, td);
return tr;
}
if (Caption.isNeeded(uidl)) {
if (c == null) {
- int index = getWidgetIndex((Widget) component);
+ final int index = getWidgetIndex((Widget) component);
c = new Caption(component, client);
insert(c, index);
componentToCaption.put(component, c);
}
public void removeCaption(Widget w) {
- Caption c = (Caption) componentToCaption.get(w);
+ final Caption c = (Caption) componentToCaption.get(w);
if (c != null) {
this.remove(c);
componentToCaption.remove(w);
}
public void add(Widget w) {
- Element wrapper = createWidgetWrappper();
+ final Element wrapper = createWidgetWrappper();
DOM.appendChild(childContainer, wrapper);
super.add(w, orientationMode == ORIENTATION_HORIZONTAL ? wrapper : DOM
.getFirstChild(wrapper));
}
public boolean remove(Widget w) {
- Element wrapper = DOM.getParent(w.getElement());
- boolean removed = super.remove(w);
+ final Element wrapper = DOM.getParent(w.getElement());
+ final boolean removed = super.remove(w);
if (removed) {
if (!(w instanceof Caption)) {
DOM.removeChild(childContainer,
protected void handleMargins(UIDL uidl) {
// Modify layout margins
String marginClasses = "";
- MarginInfo margins = new MarginInfo(uidl.getIntAttribute("margins"));
- Element topBottomMarginContainer = orientationMode == ORIENTATION_HORIZONTAL ? DOM
+ final MarginInfo margins = new MarginInfo(uidl
+ .getIntAttribute("margins"));
+ final Element topBottomMarginContainer = orientationMode == ORIENTATION_HORIZONTAL ? DOM
.getParent(childContainer)
: childContainer;
// Top margin
// Component alignments as a comma separated list.
// See com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.java for
// possible values.
- int[] alignments = uidl.getIntArrayAttribute("alignments");
+ final int[] alignments = uidl.getIntArrayAttribute("alignments");
int alignmentIndex = 0;
// Insert alignment attributes
- Iterator it = getPaintables().iterator();
+ final Iterator it = getPaintables().iterator();
while (it.hasNext()) {
// Calculate alignment info
- AlignmentInfo ai = new AlignmentInfo(alignments[alignmentIndex++]);
+ final AlignmentInfo ai = new AlignmentInfo(
+ alignments[alignmentIndex++]);
- Element td = DOM.getParent(((Widget) it.next()).getElement());
+ final Element td = DOM.getParent(((Widget) it.next()).getElement());
if (Util.isIE()) {
DOM
.setElementAttribute(td, "vAlign", ai
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
public class IOrderedLayoutHorizontal extends IOrderedLayout {\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
public class IOrderedLayoutVertical extends IOrderedLayout {\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
String id;
- private Element captionNode = DOM.createDiv();
+ private final Element captionNode = DOM.createDiv();
- private Element captionText = DOM.createSpan();
+ private final Element captionText = DOM.createSpan();
private Icon icon;
- private Element bottomDecoration = DOM.createDiv();
+ private final Element bottomDecoration = DOM.createDiv();
- private Element contentNode = DOM.createDiv();
+ private final Element contentNode = DOM.createDiv();
private Element errorIndicatorElement;
id = uidl.getId();
// Panel size. Height needs to be saved for later use
- String w = uidl.hasVariable("width") ? uidl.getStringVariable("width")
- : null;
+ final String w = uidl.hasVariable("width") ? uidl
+ .getStringVariable("width") : null;
height = uidl.hasVariable("height") ? uidl.getStringVariable("height")
: null;
setWidth(w != null ? w : "");
// Add proper stylenames for all elements. This way we can prevent
// unwanted CSS selector inheritance.
if (uidl.hasAttribute("style")) {
- String[] styles = uidl.getStringAttribute("style").split(" ");
- String captionBaseClass = CLASSNAME
+ final String[] styles = uidl.getStringAttribute("style").split(" ");
+ final String captionBaseClass = CLASSNAME
+ (hasCaption ? "-caption" : "-nocaption");
- String contentBaseClass = CLASSNAME + "-content";
- String decoBaseClass = CLASSNAME + "-deco";
+ final String contentBaseClass = CLASSNAME + "-content";
+ final String decoBaseClass = CLASSNAME + "-deco";
String captionClass = captionBaseClass;
String contentClass = contentBaseClass;
String decoClass = decoBaseClass;
iLayout();
// Render content
- UIDL layoutUidl = uidl.getChildUIDL(0);
- Widget newLayout = client.getWidget(layoutUidl);
+ final UIDL layoutUidl = uidl.getChildUIDL(0);
+ final Widget newLayout = client.getWidget(layoutUidl);
if (newLayout != layout) {
if (layout != null) {
client.unregisterPaintable((Paintable) layout);
private void handleError(UIDL uidl) {
if (uidl.hasAttribute("error")) {
- UIDL errorUidl = uidl.getErrors();
+ final UIDL errorUidl = uidl.getErrors();
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
DOM.setElementProperty(errorIndicatorElement, "className",
}
private void setIconUri(UIDL uidl, ApplicationConnection client) {
- String iconUri = uidl.hasAttribute("icon") ? uidl
+ final String iconUri = uidl.hasAttribute("icon") ? uidl
.getStringAttribute("icon") : null;
if (iconUri == null) {
if (icon != null) {
public void iLayout() {
if (height != null && height != "") {
- boolean hasChildren = getWidget() != null;
+ final boolean hasChildren = getWidget() != null;
Element contentEl = null;
String origPositioning = null;
if (hasChildren) {
// Calculate target height
super.setHeight(height);
- int targetHeight = getOffsetHeight();
+ final int targetHeight = getOffsetHeight();
// Calculate used height
super.setHeight("");
- int usedHeight = DOM.getElementPropertyInt(bottomDecoration,
+ final int usedHeight = DOM.getElementPropertyInt(bottomDecoration,
"offsetTop")
+ DOM.getElementPropertyInt(bottomDecoration,
"offsetHeight")
}
public void onBrowserEvent(Event event) {
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (errorIndicatorElement != null
&& DOM.compare(target, errorIndicatorElement)) {
switch (DOM.eventGetType(event)) {
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.DOM;\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.Window;\r
public class IPopupCalendar extends ITextualDate implements Paintable,\r
ClickListener, PopupListener {\r
\r
- private IButton calendarToggle;\r
+ private final IButton calendarToggle;\r
\r
- private CalendarPanel calendar;\r
+ private final CalendarPanel calendar;\r
\r
- private ToolkitOverlay popup;\r
+ private final ToolkitOverlay popup;\r
private boolean open = false;\r
\r
public IPopupCalendar() {\r
// clear previous values\r
popup.setWidth("");\r
popup.setHeight("");\r
- int w = calendar.getOffsetWidth();\r
- int h = calendar.getOffsetHeight();\r
+ final int w = calendar.getOffsetWidth();\r
+ final int h = calendar.getOffsetHeight();\r
int t = calendarToggle.getAbsoluteTop();\r
int l = calendarToggle.getAbsoluteLeft();\r
if (l + w > Window.getClientWidth() + Window.getScrollLeft()) {\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
Element wrapper = DOM.createDiv();
Element indicator = DOM.createDiv();
private ApplicationConnection client;
- private Poller poller;
+ private final Poller poller;
public IProgressIndicator() {
setElement(wrapper);
if (client.updateComponent(this, uidl, true)) {
return;
}
- boolean indeterminate = uidl.getBooleanAttribute("indeterminate");
+ final boolean indeterminate = uidl.getBooleanAttribute("indeterminate");
if (indeterminate) {
// TODO put up some image or something
} else {
try {
- float f = Float.parseFloat(uidl.getStringAttribute("state"));
- int size = Math.round(100 * f);
+ final float f = Float.parseFloat(uidl
+ .getStringAttribute("state"));
+ final int size = Math.round(100 * f);
DOM.setStyleAttribute(indicator, "width", size + "%");
- } catch (Exception e) {
+ } catch (final Exception e) {
}
}
poller.scheduleRepeating(uidl.getIntAttribute("pollinginterval"));
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.HashMap;
private int selectMode = Table.SELECT_MODE_NONE;
- private HashSet selectedRowKeys = new HashSet();
+ private final HashSet selectedRowKeys = new HashSet();
private boolean initializedAndAttached = false;
- private TableHead tHead = new TableHead();
+ private final TableHead tHead = new TableHead();
- private ScrollPanel bodyContainer = new ScrollPanel();
+ private final ScrollPanel bodyContainer = new ScrollPanel();
private int totalRows;
private Set collapsedColumns;
- private RowRequestHandler rowRequestHandler;
+ private final RowRequestHandler rowRequestHandler;
private IScrollTableBody tBody;
private String width;
private String height;
* This map contains captions and icon urls for actions like: * "33_c" ->
* "Edit" * "33_i" -> "http://dom.com/edit.png"
*/
- private HashMap actionMap = new HashMap();
+ private final HashMap actionMap = new HashMap();
private String[] visibleColOrder;
private boolean initialContentReceived = false;
private Element scrollPositionElement;
- private FlowPanel panel;
+ private final FlowPanel panel;
private boolean enabled;
private boolean showColHeaders;
this.client = client;
paintableId = uidl.getStringAttribute("id");
immediate = uidl.getBooleanAttribute("immediate");
- int newTotalRows = uidl.getIntAttribute("totalrows");
+ final int newTotalRows = uidl.getIntAttribute("totalrows");
if (newTotalRows != totalRows) {
totalRows = newTotalRows;
if (initializedAndAttached) {
}
if (uidl.hasVariable("selected")) {
- Set selectedKeys = uidl.getStringArrayVariableAsSet("selected");
+ final Set selectedKeys = uidl
+ .getStringArrayVariableAsSet("selected");
selectedRowKeys.clear();
- for (Iterator it = selectedKeys.iterator(); it.hasNext();) {
+ for (final Iterator it = selectedKeys.iterator(); it.hasNext();) {
selectedRowKeys.add(it.next());
}
}
}
UIDL rowData = null;
- for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
- UIDL c = (UIDL) it.next();
+ for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {
+ final UIDL c = (UIDL) it.next();
if (c.getTag().equals("rows")) {
rowData = c;
} else if (c.getTag().equals("actions")) {
}
private void updateVisibleColumns(UIDL uidl) {
- Iterator it = uidl.getChildIterator();
+ final Iterator it = uidl.getChildIterator();
while (it.hasNext()) {
- UIDL col = (UIDL) it.next();
+ final UIDL col = (UIDL) it.next();
tHead.updateCellFromUIDL(col);
}
}
private void updateActionMap(UIDL c) {
- Iterator it = c.getChildIterator();
+ final Iterator it = c.getChildIterator();
while (it.hasNext()) {
- UIDL action = (UIDL) it.next();
- String key = action.getStringAttribute("key");
- String caption = action.getStringAttribute("caption");
+ final UIDL action = (UIDL) it.next();
+ final String key = action.getStringAttribute("key");
+ final String caption = action.getStringAttribute("caption");
actionMap.put(key + "_c", caption);
if (action.hasAttribute("icon")) {
// TODO need some uri handling ??
}
for (int i = 0; i < strings.length; i++) {
- String cid = strings[i];
+ final String cid = strings[i];
visibleColOrder[colIndex] = cid;
tHead.enableColumn(cid, colIndex);
colIndex++;
tBody.renderRows(uidl, firstRow, reqRows);
- int optimalFirstRow = (int) (firstRowInViewPort - pageLength
+ final int optimalFirstRow = (int) (firstRowInViewPort - pageLength
* CACHE_RATE);
while (tBody.getFirstRendered() < optimalFirstRow) {
// client.console.log("removing row from start");
tBody.unlinkRow(true);
}
- int optimalLastRow = (int) (firstRowInViewPort + pageLength + pageLength
+ final int optimalLastRow = (int) (firstRowInViewPort + pageLength + pageLength
* CACHE_RATE);
while (tBody.getLastRendered() > optimalLastRow) {
// client.console.log("removing row from the end");
}
private void setColWidth(int colIndex, int w) {
- HeaderCell cell = tHead.getHeaderCell(colIndex);
+ final HeaderCell cell = tHead.getHeaderCell(colIndex);
cell.setWidth(w);
tBody.setColWidth(colIndex, w);
}
}
private IScrollTableRow getRenderedRowByKey(String key) {
- Iterator it = tBody.iterator();
+ final Iterator it = tBody.iterator();
IScrollTableRow r = null;
while (it.hasNext()) {
r = (IScrollTableRow) it.next();
private void reOrderColumn(String columnKey, int newIndex) {
- int oldIndex = getColIndexByKey(columnKey);
+ final int oldIndex = getColIndexByKey(columnKey);
// Change header order
tHead.moveCell(oldIndex, newIndex);
* array unless on moved columnKey. On new index also put the moved key
* i == index on columnOrder, j == index on newOrder
*/
- String oldKeyOnNewIndex = visibleColOrder[newIndex];
+ final String oldKeyOnNewIndex = visibleColOrder[newIndex];
if (showRowHeaders) {
newIndex--; // columnOrder don't have rowHeader
}
}
}
// finally we can build the new columnOrder for server
- String[] newOrder = new String[columnOrder.length];
+ final String[] newOrder = new String[columnOrder.length];
for (int i = 0, j = 0; j < newOrder.length; i++) {
if (j == newIndex) {
newOrder[j] = columnKey;
// also update visibleColumnOrder
int i = showRowHeaders ? 1 : 0;
for (int j = 0; j < newOrder.length; j++) {
- String cid = newOrder[j];
+ final String cid = newOrder[j];
if (!isCollapsedColumn(cid)) {
visibleColOrder[i++] = cid;
}
super.onDetach();
// ensure that scrollPosElement will be detached
if (scrollPositionElement != null) {
- Element parent = DOM.getParent(scrollPositionElement);
+ final Element parent = DOM.getParent(scrollPositionElement);
if (parent != null) {
DOM.removeChild(parent, scrollPositionElement);
}
int totalExplicitColumnsWidths = 0;
int total = 0;
- int[] widths = new int[tHead.visibleCells.size()];
+ final int[] widths = new int[tHead.visibleCells.size()];
// first loop: collect natural widths
while (headCells.hasNext()) {
- HeaderCell hCell = (HeaderCell) headCells.next();
+ final HeaderCell hCell = (HeaderCell) headCells.next();
int w;
if (hCell.getWidth() > 0) {
// server has defined column width explicitly
w = hCell.getWidth();
totalExplicitColumnsWidths += w;
} else {
- int hw = DOM.getElementPropertyInt(hCell.getElement(),
+ final int hw = DOM.getElementPropertyInt(hCell.getElement(),
"offsetWidth");
- int cw = tBody.getColWidth(i);
+ final int cw = tBody.getColWidth(i);
w = (hw > cw ? hw : cw) + IScrollTableBody.CELL_EXTRA_WIDTH;
}
widths[i] = w;
if (availW > total) {
// natural size is smaller than available space
- int extraSpace = availW - total;
- int totalWidthR = total - totalExplicitColumnsWidths;
+ final int extraSpace = availW - total;
+ final int totalWidthR = total - totalExplicitColumnsWidths;
if (totalWidthR > 0) {
// now we will share this sum relatively to those without
// explicit width
hCell = (HeaderCell) headCells.next();
if (hCell.getWidth() == -1) {
int w = widths[i];
- int newSpace = extraSpace * w / totalWidthR;
+ final int newSpace = extraSpace * w / totalWidthR;
w += newSpace;
widths[i] = w;
}
i = 0;
headCells = tHead.iterator();
while (headCells.hasNext()) {
- HeaderCell hCell = (HeaderCell) headCells.next();
+ final HeaderCell hCell = (HeaderCell) headCells.next();
if (hCell.getWidth() == -1) {
- int w = widths[i];
+ final int w = widths[i];
setColWidth(i, w);
}
i++;
if (preLimit < 0) {
preLimit = 0;
}
- int lastRendered = tBody.getLastRendered();
- int firstRendered = tBody.getFirstRendered();
+ final int lastRendered = tBody.getLastRendered();
+ final int firstRendered = tBody.getFirstRendered();
if (postLimit <= lastRendered && preLimit >= firstRendered) {
client.updateVariable(paintableId, "firstvisible",
Element floatingCopyOfHeaderCell;
private boolean sortable = false;
- private String cid;
+ private final String cid;
private boolean dragging;
private int dragStartX;
createFloatingCopy();
moved = true;
}
- int x = DOM.eventGetClientX(event)
+ final int x = DOM.eventGetClientX(event)
+ DOM.getElementPropertyInt(tHead.hTableWrapper,
"scrollLeft");
int slotX = headerX;
if (showRowHeaders) {
start++;
}
- int visibleCellCount = tHead.getVisibleCellCount();
+ final int visibleCellCount = tHead.getVisibleCellCount();
for (int i = start; i <= visibleCellCount; i++) {
if (i > 0) {
- String colKey = getColKeyByIndex(i - 1);
+ final String colKey = getColKeyByIndex(i - 1);
slotX += getColWidth(colKey);
}
- int dist = Math.abs(x - slotX);
+ final int dist = Math.abs(x - slotX);
if (closestDistance == -1 || dist < closestDistance) {
closestDistance = dist;
closestSlot = i;
break;
case Event.ONMOUSEMOVE:
if (isResizing) {
- int deltaX = DOM.eventGetClientX(event) - dragStartX;
+ final int deltaX = DOM.eventGetClientX(event) - dragStartX;
if (deltaX == 0) {
return;
}
Element headerTableBody = DOM.createTBody();
Element tr = DOM.createTR();
- private Element columnSelector = DOM.createDiv();
+ private final Element columnSelector = DOM.createDiv();
private int focusedSlot = -1;
}
public void updateCellFromUIDL(UIDL col) {
- String cid = col.getStringAttribute("cid");
+ final String cid = col.getStringAttribute("cid");
HeaderCell c = getHeaderCell(cid);
if (c == null) {
c = new HeaderCell(cid, col.getStringAttribute("caption"));
c.setAlign(col.getStringAttribute("align").charAt(0));
}
if (col.hasAttribute("width")) {
- String width = col.getStringAttribute("width");
+ final String width = col.getStringAttribute("width");
c.setWidth(Integer.parseInt(width));
}
// TODO icon
}
public void enableColumn(String cid, int index) {
- HeaderCell c = getHeaderCell(cid);
+ final HeaderCell c = getHeaderCell(cid);
if (!c.isEnabled()) {
setHeaderCell(index, c);
}
}
public void moveCell(int oldIndex, int newIndex) {
- HeaderCell hCell = getHeaderCell(oldIndex);
- Element cell = hCell.getElement();
+ final HeaderCell hCell = getHeaderCell(oldIndex);
+ final Element cell = hCell.getElement();
visibleCells.remove(oldIndex);
DOM.removeChild(tr, cell);
}
public void removeCell(String colKey) {
- HeaderCell c = getHeaderCell(colKey);
+ final HeaderCell c = getHeaderCell(colKey);
remove(c);
}
public void onBrowserEvent(Event event) {
if (enabled) {
if (DOM.compare(DOM.eventGetTarget(event), columnSelector)) {
- int left = DOM.getAbsoluteLeft(columnSelector);
- int top = DOM.getAbsoluteTop(columnSelector)
+ final int left = DOM.getAbsoluteLeft(columnSelector);
+ final int top = DOM.getAbsoluteTop(columnSelector)
+ DOM.getElementPropertyInt(columnSelector,
"offsetHeight");
client.getContextMenu().showAt(this, left, top);
* Override default method to distinguish on/off columns
*/
public String getHTML() {
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
if (collapsed) {
buf.append("<span class=\"i-off\">");
}
for (i = 0; i < visibleColOrder.length; i++) {
cols[i] = visibleColOrder[i];
}
- for (Iterator it = collapsedColumns.iterator(); it.hasNext();) {
+ for (final Iterator it = collapsedColumns.iterator(); it
+ .hasNext();) {
cols[i++] = it.next();
}
}
- Action[] actions = new Action[cols.length];
+ final Action[] actions = new Action[cols.length];
for (int i = 0; i < cols.length; i++) {
- String cid = (String) cols[i];
- HeaderCell c = getHeaderCell(cid);
- VisibleColumnAction a = new VisibleColumnAction(c.getColKey());
+ final String cid = (String) cols[i];
+ final HeaderCell c = getHeaderCell(cid);
+ final VisibleColumnAction a = new VisibleColumnAction(c
+ .getColKey());
a.setCaption(c.getCaption());
if (!c.isEnabled()) {
a.setCollapsed(true);
* Returns column alignments for visible columns
*/
public char[] getColumnAlignments() {
- Iterator it = visibleCells.iterator();
- char[] aligns = new char[visibleCells.size()];
+ final Iterator it = visibleCells.iterator();
+ final char[] aligns = new char[visibleCells.size()];
int colIndex = 0;
while (it.hasNext()) {
aligns[colIndex++] = ((HeaderCell) it.next()).getAlign();
private int rowHeight = -1;
- private List renderedRows = new Vector();
+ private final List renderedRows = new Vector();
private boolean initDone = false;
public void renderInitialRows(UIDL rowData, int firstIndex, int rows) {
firstRendered = firstIndex;
lastRendered = firstIndex + rows - 1;
- Iterator it = rowData.getChildIterator();
+ final Iterator it = rowData.getChildIterator();
aligns = tHead.getColumnAlignments();
while (it.hasNext()) {
- IScrollTableRow row = new IScrollTableRow((UIDL) it.next(),
- aligns);
+ final IScrollTableRow row = new IScrollTableRow((UIDL) it
+ .next(), aligns);
addRow(row);
}
if (isAttached()) {
public void renderRows(UIDL rowData, int firstIndex, int rows) {
aligns = tHead.getColumnAlignments();
- Iterator it = rowData.getChildIterator();
+ final Iterator it = rowData.getChildIterator();
if (firstIndex == lastRendered + 1) {
while (it.hasNext()) {
- IScrollTableRow row = createRow((UIDL) it.next());
+ final IScrollTableRow row = createRow((UIDL) it.next());
addRow(row);
lastRendered++;
}
fixSpacers();
} else if (firstIndex + rows == firstRendered) {
- IScrollTableRow[] rowArray = new IScrollTableRow[rows];
+ final IScrollTableRow[] rowArray = new IScrollTableRow[rows];
int i = rows;
while (it.hasNext()) {
i--;
while (lastRendered + 1 > firstRendered) {
unlinkRow(false);
}
- IScrollTableRow row = createRow((UIDL) it.next());
+ final IScrollTableRow row = createRow((UIDL) it.next());
firstRendered = firstIndex;
lastRendered = firstIndex - 1;
addRow(row);
* @param uidl
*/
private IScrollTableRow createRow(UIDL uidl) {
- IScrollTableRow row = new IScrollTableRow(uidl, aligns);
- int cells = DOM.getChildCount(row.getElement());
+ final IScrollTableRow row = new IScrollTableRow(uidl, aligns);
+ final int cells = DOM.getChildCount(row.getElement());
for (int i = 0; i < cells; i++) {
- Element cell = DOM.getChild(row.getElement(), i);
- int w = IScrollTable.this.getColWidth(getColKeyByIndex(i));
+ final Element cell = DOM.getChild(row.getElement(), i);
+ final int w = IScrollTable.this
+ .getColWidth(getColKeyByIndex(i));
DOM.setStyleAttribute(DOM.getFirstChild(cell), "width",
(w - CELL_CONTENT_PADDING) + "px");
DOM.setStyleAttribute(cell, "width", w + "px");
index = renderedRows.size() - 1;
lastRendered--;
}
- IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows
+ final IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows
.get(index);
client.unregisterChildPaintables(toBeRemoved);
DOM.removeChild(tBody, toBeRemoved.getElement());
public int getColWidth(int i) {
if (initDone) {
- Element e = DOM.getChild(DOM.getChild(tBody, 0), i);
+ final Element e = DOM.getChild(DOM.getChild(tBody, 0), i);
return DOM.getElementPropertyInt(e, "offsetWidth");
} else {
return 0;
}
public void setColWidth(int colIndex, int w) {
- int rows = DOM.getChildCount(tBody);
+ final int rows = DOM.getChildCount(tBody);
for (int i = 0; i < rows; i++) {
- Element cell = DOM.getChild(DOM.getChild(tBody, i), colIndex);
+ final Element cell = DOM.getChild(DOM.getChild(tBody, i),
+ colIndex);
DOM.setStyleAttribute(DOM.getFirstChild(cell), "width",
(w - CELL_CONTENT_PADDING) + "px");
DOM.setStyleAttribute(cell, "width", w + "px");
public void moveCol(int oldIndex, int newIndex) {
// loop all rows and move given index to its new place
- Iterator rows = iterator();
+ final Iterator rows = iterator();
while (rows.hasNext()) {
- IScrollTableRow row = (IScrollTableRow) rows.next();
+ final IScrollTableRow row = (IScrollTableRow) rows.next();
- Element td = DOM.getChild(row.getElement(), oldIndex);
+ final Element td = DOM.getChild(row.getElement(), oldIndex);
DOM.removeChild(row.getElement(), td);
DOM.insertChild(row.getElement(), td, newIndex);
Vector childWidgets = new Vector();
private boolean selected = false;
- private int rowKey;
+ private final int rowKey;
private String[] actionKeys = null;
actionKeys = uidl.getStringArrayAttribute("al");
}
- Iterator cells = uidl.getChildIterator();
+ final Iterator cells = uidl.getChildIterator();
while (cells.hasNext()) {
- Object cell = cells.next();
+ final Object cell = cells.next();
if (cell instanceof String) {
addCell(cell.toString(), aligns[col++]);
} else {
- Widget cellContent = client.getWidget((UIDL) cell);
+ final Widget cellContent = client
+ .getWidget((UIDL) cell);
((Paintable) cellContent).updateFromUIDL((UIDL) cell,
client);
addCell(cellContent, aligns[col++]);
public void addCell(String text, char align) {
// String only content is optimized by not using Label widget
- Element td = DOM.createTD();
- Element container = DOM.createDiv();
+ final Element td = DOM.createTD();
+ final Element container = DOM.createDiv();
DOM.setElementProperty(container, "className", CLASSNAME
+ "-cell-content");
DOM.setInnerHTML(container, text);
}
public void addCell(Widget w, char align) {
- Element td = DOM.createTD();
- Element container = DOM.createDiv();
+ final Element td = DOM.createTD();
+ final Element container = DOM.createDiv();
DOM.setElementProperty(container, "className", CLASSNAME
+ "-cell-content");
// TODO make widget cells respect align. text-align:center for
public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONCLICK:
- Element tdOrTr = DOM.getParent(DOM.eventGetTarget(event));
+ final Element tdOrTr = DOM.getParent(DOM
+ .eventGetTarget(event));
if (DOM.compare(getElement(), tdOrTr)
|| DOM.compare(getElement(), DOM.getParent(tdOrTr))) {
if (selectMode > Table.SELECT_MODE_NONE) {
if (actionKeys == null) {
return new Action[] {};
}
- Action[] actions = new Action[actionKeys.length];
+ final Action[] actions = new Action[actionKeys.length];
for (int i = 0; i < actions.length; i++) {
- String actionKey = actionKeys[i];
- TreeAction a = new TreeAction(this, String.valueOf(rowKey),
- actionKey);
+ final String actionKey = actionKeys[i];
+ final TreeAction a = new TreeAction(this, String
+ .valueOf(rowKey), actionKey);
a.setCaption(getActionCaption(actionKey));
a.setIconUrl(getActionIcon(actionKey));
actions[i] = a;
}
public void deselectAll() {
- Object[] keys = selectedRowKeys.toArray();
+ final Object[] keys = selectedRowKeys.toArray();
for (int i = 0; i < keys.length; i++) {
- IScrollTableRow row = getRenderedRowByKey((String) keys[i]);
+ final IScrollTableRow row = getRenderedRowByKey((String) keys[i]);
if (row != null && row.isSelected()) {
row.toggleSelection();
}
// workaround very common 100% height problem - extract borders
if (height.equals("100%")) {
final int borders = getBorderSpace();
- Element elem = getElement();
- Element parentElem = DOM.getParent(elem);
+ final Element elem = getElement();
+ final Element parentElem = DOM.getParent(elem);
// put table away from flow for a moment
DOM.setStyleAttribute(getElement(), "position", "absolute");
// get containers natural space for table
- int availPixels = DOM.getElementPropertyInt(parentElem,
+ final int availPixels = DOM.getElementPropertyInt(parentElem,
"offsetHeight");
// put table back to flow
DOM.setStyleAttribute(getElement(), "position", "static");
}
private int getBorderSpace() {
- Element el = getElement();
+ final Element el = getElement();
return DOM.getElementPropertyInt(el, "offsetHeight")
- DOM.getElementPropertyInt(el, "clientHeight");
}
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.Command;\r
private boolean arrows;\r
\r
/* DOM element for slider's base */\r
- private Element base;\r
+ private final Element base;\r
\r
/* DOM element for slider's handle */\r
- private Element handle;\r
+ private final Element handle;\r
\r
/* DOM element for decrement arrow */\r
- private Element smaller;\r
+ private final Element smaller;\r
\r
/* DOM element for increment arrow */\r
- private Element bigger;\r
+ private final Element bigger;\r
\r
/* Temporary dragging/animation variables */\r
private boolean dragging = false;\r
final String domProperty = vertical ? "offsetHeight" : "offsetWidth";\r
\r
if (size == -1) {\r
- Element p = DOM.getParent(getElement());\r
+ final Element p = DOM.getParent(getElement());\r
if (DOM.getElementPropertyInt(p, domProperty) > 50) {\r
if (vertical) {\r
setHeight();\r
DOM.setStyleAttribute(base, styleAttribute, MIN_SIZE + "px");\r
DeferredCommand.addCommand(new Command() {\r
public void execute() {\r
- Element p = DOM.getParent(getElement());\r
+ final Element p = DOM.getParent(getElement());\r
if (DOM.getElementPropertyInt(p, domProperty) > (MIN_SIZE + 5)) {\r
if (vertical) {\r
setHeight();\r
}\r
\r
private void buildHandle() {\r
- String styleAttribute = vertical ? "height" : "width";\r
- String handleAttribute = vertical ? "marginTop" : "marginLeft";\r
- String domProperty = vertical ? "offsetHeight" : "offsetWidth";\r
+ final String styleAttribute = vertical ? "height" : "width";\r
+ final String handleAttribute = vertical ? "marginTop" : "marginLeft";\r
+ final String domProperty = vertical ? "offsetHeight" : "offsetWidth";\r
\r
DOM.setStyleAttribute(handle, handleAttribute, "0");\r
\r
int s = (int) (Double.parseDouble(DOM.getElementProperty(base,\r
domProperty)) / 100 * handleSize);\r
if (handleSize == -1) {\r
- int baseS = Integer.parseInt(DOM.getElementProperty(base,\r
+ final int baseS = Integer.parseInt(DOM.getElementProperty(base,\r
domProperty));\r
- double range = (max - min) * (resolution + 1) * 3;\r
+ final double range = (max - min) * (resolution + 1) * 3;\r
s = (int) (baseS - range);\r
}\r
if (s < 3) {\r
\r
// Update handle position\r
final String styleAttribute = vertical ? "marginTop" : "marginLeft";\r
- String domProperty = vertical ? "offsetHeight" : "offsetWidth";\r
- int handleSize = Integer.parseInt(DOM.getElementProperty(handle,\r
+ final String domProperty = vertical ? "offsetHeight" : "offsetWidth";\r
+ final int handleSize = Integer.parseInt(DOM.getElementProperty(handle,\r
domProperty));\r
- int baseSize = Integer.parseInt(DOM.getElementProperty(base,\r
+ final int baseSize = Integer.parseInt(DOM.getElementProperty(base,\r
domProperty));\r
- int range = baseSize - handleSize;\r
+ final int range = baseSize - handleSize;\r
double v = value.doubleValue();\r
- double valueRange = max - min;\r
+ final double valueRange = max - min;\r
double p = 0;\r
if (valueRange > 0) {\r
p = range * ((v - min) / valueRange);\r
}\r
final double pos = p;\r
\r
- int current = DOM.getIntStyleAttribute(handle, styleAttribute);\r
+ final int current = DOM.getIntStyleAttribute(handle, styleAttribute);\r
\r
if ((int) (Math.round(pos)) != current && animate) {\r
if (anim != null) {\r
}\r
anim = new Timer() {\r
private int current;\r
- private int goal = (int) Math.round(pos);\r
+ private final int goal = (int) Math.round(pos);\r
private int dir = 0;\r
\r
public void run() {\r
cancel();\r
return;\r
}\r
- int increment = (goal - current) / 2;\r
+ final int increment = (goal - current) / 2;\r
DOM.setStyleAttribute(handle, styleAttribute,\r
(current + increment) + "px");\r
}\r
if (disabled || readonly) {\r
return;\r
}\r
- Element targ = DOM.eventGetTarget(event);\r
+ final Element targ = DOM.eventGetTarget(event);\r
\r
if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) {\r
processMouseWheelEvent(event);\r
}\r
\r
private void processMouseWheelEvent(Event event) {\r
- int dir = DOM.eventGetMouseWheelVelocityY(event);\r
+ final int dir = DOM.eventGetMouseWheelVelocityY(event);\r
if (dir < 0) {\r
increaseValue(event, false);\r
} else {\r
private void setValueByEvent(Event event, boolean animate, boolean roundup) {\r
double v = min; // Fallback to min\r
\r
- int coord = vertical ? DOM.eventGetClientY(event) : DOM\r
+ final int coord = vertical ? DOM.eventGetClientY(event) : DOM\r
.eventGetClientX(event);\r
- String domProperty = vertical ? "offsetHeight" : "offsetWidth";\r
+ final String domProperty = vertical ? "offsetHeight" : "offsetWidth";\r
\r
- double handleSize = Integer.parseInt(DOM.getElementProperty(handle,\r
- domProperty));\r
- double baseSize = Integer.parseInt(DOM.getElementProperty(base,\r
+ final double handleSize = Integer.parseInt(DOM.getElementProperty(\r
+ handle, domProperty));\r
+ final double baseSize = Integer.parseInt(DOM.getElementProperty(base,\r
domProperty));\r
- double baseOffset = vertical ? DOM.getAbsoluteTop(base) - handleSize\r
- / 2 : DOM.getAbsoluteLeft(base) + handleSize / 2;\r
+ final double baseOffset = vertical ? DOM.getAbsoluteTop(base)\r
+ - handleSize / 2 : DOM.getAbsoluteLeft(base) + handleSize / 2;\r
\r
if (vertical) {\r
v = ((baseSize - (coord - baseOffset)) / (baseSize - handleSize))\r
// Calculate decoration size\r
DOM.setStyleAttribute(base, "height", "0");\r
DOM.setStyleAttribute(base, "overflow", "hidden");\r
- int decoHeight = DOM.getElementPropertyInt(getElement(),\r
+ final int decoHeight = DOM.getElementPropertyInt(getElement(),\r
"offsetHeight");\r
// Get available space size\r
- int availableHeight = DOM.getElementPropertyInt(DOM\r
+ final int availableHeight = DOM.getElementPropertyInt(DOM\r
.getParent(getElement()), "offsetHeight");\r
int h = availableHeight - decoHeight;\r
if (h < MIN_SIZE) {\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
private Widget secondChild;
- private Element wrapper = DOM.createDiv();
+ private final Element wrapper = DOM.createDiv();
- private Element firstContainer = DOM.createDiv();
+ private final Element firstContainer = DOM.createDiv();
- private Element secondContainer = DOM.createDiv();
+ private final Element secondContainer = DOM.createDiv();
- private Element splitter = DOM.createDiv();
+ private final Element splitter = DOM.createDiv();
private boolean resizing;
setSplitPosition(uidl.getStringAttribute("position"));
- Paintable newFirstChild = (Paintable) client.getWidget(uidl
+ final Paintable newFirstChild = (Paintable) client.getWidget(uidl
.getChildUIDL(0));
- Paintable newSecondChild = (Paintable) client.getWidget(uidl
+ final Paintable newSecondChild = (Paintable) client.getWidget(uidl
.getChildUIDL(1));
if (firstChild != newFirstChild) {
if (firstChild != null) {
}
public void onMouseDown(Event event) {
- Element trg = DOM.eventGetTarget(event);
+ final Element trg = DOM.eventGetTarget(event);
if (DOM.compare(trg, splitter)
|| DOM.compare(trg, DOM.getChild(splitter, 0))) {
resizing = true;
public void onMouseMove(Event event) {
switch (orientation) {
case ORIENTATION_HORIZONTAL:
- int x = DOM.eventGetClientX(event);
+ final int x = DOM.eventGetClientX(event);
onHorizontalMouseMove(x);
break;
case ORIENTATION_VERTICAL:
default:
- int y = DOM.eventGetClientY(event);
+ final int y = DOM.eventGetClientY(event);
onVerticalMouseMove(y);
break;
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
public class ISplitPanelHorizontal extends ISplitPanel {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
public class ISplitPanelVertical extends ISplitPanel {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.HashMap;
public class ITablePaging extends Composite implements Table, Paintable,
ClickListener {
- private Grid tBody = new Grid();
- private Button nextPage = new Button(">");
- private Button prevPage = new Button("<");
- private Button firstPage = new Button("<<");
- private Button lastPage = new Button(">>");
+ private final Grid tBody = new Grid();
+ private final Button nextPage = new Button(">");
+ private final Button prevPage = new Button("<");
+ private final Button firstPage = new Button("<<");
+ private final Button lastPage = new Button(">>");
private int pageLength = 15;
private boolean rowHeaders = false;
- private Map columnOrder = new HashMap();
+ private final Map columnOrder = new HashMap();
private ApplicationConnection client;
private String id;
private int selectMode = Table.SELECT_MODE_NONE;
- private Vector selectedRowKeys = new Vector();
+ private final Vector selectedRowKeys = new Vector();
private int totalRows;
- private HashMap columnWidths = new HashMap();
+ private final HashMap columnWidths = new HashMap();
- private HashMap visibleColumns = new HashMap();
+ private final HashMap visibleColumns = new HashMap();
private int rows;
private int firstRow;
private boolean sortAscending = true;
- private HorizontalPanel pager;
+ private final HorizontalPanel pager;
public HashMap rowKeysToTableRows = new HashMap();
tBody.setStyleName("itable-tbody");
- VerticalPanel panel = new VerticalPanel();
+ final VerticalPanel panel = new VerticalPanel();
pager = new HorizontalPanel();
pager.add(firstPage);
}
if (uidl.hasAttribute("selected")) {
- Set selectedKeys = uidl.getStringArrayVariableAsSet("selected");
+ final Set selectedKeys = uidl
+ .getStringArrayVariableAsSet("selected");
selectedRowKeys.clear();
- for (Iterator it = selectedKeys.iterator(); it.hasNext();) {
+ for (final Iterator it = selectedKeys.iterator(); it.hasNext();) {
selectedRowKeys.add(it.next());
}
}
UIDL rowData = null;
UIDL visibleColumns = null;
- for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
- UIDL c = (UIDL) it.next();
+ for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {
+ final UIDL c = (UIDL) it.next();
if (c.getTag().equals("rows")) {
rowData = c;
} else if (c.getTag().equals("actions")) {
}
private void updateHeader(UIDL c) {
- Iterator it = c.getChildIterator();
+ final Iterator it = c.getChildIterator();
visibleColumns.clear();
int colIndex = (rowHeaders ? 1 : 0);
while (it.hasNext()) {
- UIDL col = (UIDL) it.next();
- String cid = col.getStringAttribute("cid");
+ final UIDL col = (UIDL) it.next();
+ final String cid = col.getStringAttribute("cid");
if (!col.hasAttribute("collapsed")) {
tBody.setWidget(0, colIndex, new HeaderCell(cid, col
.getStringAttribute("caption")));
* which contains row data
*/
private void updateBody(UIDL uidl) {
- Iterator it = uidl.getChildIterator();
+ final Iterator it = uidl.getChildIterator();
int curRowIndex = 1;
while (it.hasNext()) {
- UIDL rowUidl = (UIDL) it.next();
- TableRow row = new TableRow(curRowIndex, String.valueOf(rowUidl
- .getIntAttribute("key")), rowUidl.hasAttribute("selected"));
+ final UIDL rowUidl = (UIDL) it.next();
+ final TableRow row = new TableRow(curRowIndex, String
+ .valueOf(rowUidl.getIntAttribute("key")), rowUidl
+ .hasAttribute("selected"));
int colIndex = 0;
if (rowHeaders) {
tBody.setWidget(curRowIndex, colIndex, new BodyCell(row,
rowUidl.getStringAttribute("caption")));
colIndex++;
}
- Iterator cells = rowUidl.getChildIterator();
+ final Iterator cells = rowUidl.getChildIterator();
while (cells.hasNext()) {
- Object cell = cells.next();
+ final Object cell = cells.next();
if (cell instanceof String) {
tBody.setWidget(curRowIndex, colIndex, new BodyCell(row,
(String) cell));
} else {
- Widget cellContent = client.getWidget((UIDL) cell);
- BodyCell bodyCell = new BodyCell(row);
+ final Widget cellContent = client.getWidget((UIDL) cell);
+ final BodyCell bodyCell = new BodyCell(row);
bodyCell.setWidget(cellContent);
tBody.setWidget(curRowIndex, colIndex, bodyCell);
}
}
}
if (sender instanceof HeaderCell) {
- HeaderCell hCell = (HeaderCell) sender;
+ final HeaderCell hCell = (HeaderCell) sender;
client.updateVariable(id, "sortcolumn", hCell.getCid(), false);
client.updateVariable(id, "sortascending", (sortAscending ? false
: true), true);
* @author mattitahvonen
*/
public class BodyCell extends SimplePanel {
- private TableRow row;
+ private final TableRow row;
public BodyCell(TableRow row) {
super();
private class TableRow {
- private String key;
- private int rowIndex;
+ private final String key;
+ private final int rowIndex;
private boolean selected = false;
public TableRow(int rowIndex, String rowKey, boolean selected) {
}
public void deselectAll() {
- Object[] keys = selectedRowKeys.toArray();
+ final Object[] keys = selectedRowKeys.toArray();
for (int i = 0; i < keys.length; i++) {
- TableRow tableRow = (TableRow) rowKeysToTableRows.get(keys[i]);
+ final TableRow tableRow = (TableRow) rowKeysToTableRows
+ .get(keys[i]);
if (tableRow != null) {
tableRow.setSelected(false);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.ArrayList;
String id;
ApplicationConnection client;
- private ArrayList tabKeys = new ArrayList();
- private ArrayList captions = new ArrayList();
+ private final ArrayList tabKeys = new ArrayList();
+ private final ArrayList captions = new ArrayList();
int activeTabIndex = 0;
private final TabBar tb;
private final ITabsheetPanel tp;
private final TabListener tl = new TabListener() {
public void onTabSelected(SourcesTabEvents sender, final int tabIndex) {
- if (ITabsheet.this.client != null
- && ITabsheet.this.activeTabIndex != tabIndex) {
+ if (client != null && activeTabIndex != tabIndex) {
addStyleDependentName("loading");
// run updating variables in deferred command to bypass some FF
// optimization issues
DeferredCommand.addCommand(new Command() {
public void execute() {
- ITabsheet.this.client.updateVariable(ITabsheet.this.id,
- "selected", ""
- + ITabsheet.this.tabKeys.get(tabIndex),
- true);
+ client.updateVariable(id, "selected", ""
+ + tabKeys.get(tabIndex), true);
}
});
}
add(tb);
DOM.appendChild(getElement(), contentNode);
insert(tp, contentNode, 0, true);
- DOM.appendChild(getElement(), this.deco);
+ DOM.appendChild(getElement(), deco);
- this.tb.addTabListener(this.tl);
+ tb.addTabListener(tl);
clearTabs();
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
this.client = client;
- this.id = uidl.getId();
+ id = uidl.getId();
if (client.updateComponent(this, uidl, false)) {
return;
// Add proper stylenames for all elements
if (uidl.hasAttribute("style")) {
- String[] styles = uidl.getStringAttribute("style").split(" ");
- String contentBaseClass = "CLASSNAME" + "-content";
+ final String[] styles = uidl.getStringAttribute("style").split(" ");
+ final String contentBaseClass = "CLASSNAME" + "-content";
String contentClass = contentBaseClass;
- String decoBaseClass = CLASSNAME + "-deco";
+ final String decoBaseClass = CLASSNAME + "-deco";
String decoClass = decoBaseClass;
for (int i = 0; i < styles.length; i++) {
tb.addStyleDependentName(styles[i]);
}
// Render content
- UIDL tabs = uidl.getChildUIDL(0);
+ final UIDL tabs = uidl.getChildUIDL(0);
boolean keepCurrentTabs = tabKeys.size() == tabs.getNumberOfChildren();
for (int i = 0; keepCurrentTabs && i < tabKeys.size(); i++) {
keepCurrentTabs = tabKeys.get(i).equals(
}
if (keepCurrentTabs) {
int index = 0;
- for (Iterator it = tabs.getChildIterator(); it.hasNext();) {
- UIDL tab = (UIDL) it.next();
+ for (final Iterator it = tabs.getChildIterator(); it.hasNext();) {
+ final UIDL tab = (UIDL) it.next();
if (tab.getBooleanAttribute("selected")) {
activeTabIndex = index;
renderContent(tab.getChildUIDL(0));
clearTabs();
int index = 0;
- for (Iterator it = tabs.getChildIterator(); it.hasNext();) {
- UIDL tab = (UIDL) it.next();
- String key = tab.getStringAttribute("key");
+ for (final Iterator it = tabs.getChildIterator(); it.hasNext();) {
+ final UIDL tab = (UIDL) it.next();
+ final String key = tab.getStringAttribute("key");
String caption = tab.getStringAttribute("caption");
if (caption == null) {
caption = " ";
}
// Open selected tab, if there's something to show
- if (tabKeys.size() > 0)
+ if (tabKeys.size() > 0) {
tb.selectTab(activeTabIndex);
+ }
}
private void renderContent(final UIDL contentUIDL) {
DeferredCommand.addCommand(new Command() {
public void execute() {
- Widget content = ITabsheet.this.client.getWidget(contentUIDL);
- ITabsheet.this.tp.remove(ITabsheet.this.activeTabIndex);
- ITabsheet.this.tp
- .insert(content, ITabsheet.this.activeTabIndex);
- ITabsheet.this.tp.showWidget(ITabsheet.this.activeTabIndex);
- ((Paintable) content).updateFromUIDL(contentUIDL,
- ITabsheet.this.client);
+ final Widget content = client.getWidget(contentUIDL);
+ tp.remove(activeTabIndex);
+ tp.insert(content, activeTabIndex);
+ tp.showWidget(activeTabIndex);
+ ((Paintable) content).updateFromUIDL(contentUIDL, client);
ITabsheet.this.removeStyleDependentName("loading");
ITabsheet.this.iLayout();
}
tp.clear();
// Get rid of unnecessary 100% cell heights in TabBar (really ugly hack)
- Element tr = DOM.getChild(DOM.getChild(tb.getElement(), 0), 0);
- Element rest = DOM.getChild(
- DOM.getChild(tr, DOM.getChildCount(tr) - 1), 0);
+ final Element tr = DOM.getChild(DOM.getChild(tb.getElement(), 0), 0);
+ final Element rest = DOM.getChild(DOM.getChild(tr, DOM
+ .getChildCount(tr) - 1), 0);
DOM.removeElementAttribute(rest, "style");
}
public void iLayout() {
if (height != null && height != "") {
// Take content out of flow for a while
- String originalPositioning = DOM.getStyleAttribute(tp.getElement(),
- "position");
+ final String originalPositioning = DOM.getStyleAttribute(tp
+ .getElement(), "position");
DOM.setStyleAttribute(tp.getElement(), "position", "absolute");
DOM.setStyleAttribute(contentNode, "overflow", "hidden");
// Calculate target height
super.setHeight(height);
- int targetHeight = getOffsetHeight();
+ final int targetHeight = getOffsetHeight();
// Calculate used height
super.setHeight("");
- int usedHeight = DOM.getElementPropertyInt(deco, "offsetTop")
+ final int usedHeight = DOM.getElementPropertyInt(deco, "offsetTop")
+ DOM.getElementPropertyInt(deco, "offsetHeight")
- DOM.getElementPropertyInt(getElement(), "offsetTop");
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.DOM;\r
}\r
\r
public boolean remove(Widget w) {\r
- boolean removed = super.remove(w);\r
+ final boolean removed = super.remove(w);\r
if (removed) {\r
resetChildWidget(w);\r
\r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.DOM;\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
}
private native void setColumns(Element e, int c) /*-{
- try {
- switch(e.tagName.toLowerCase()) {
- case "input":
- //e.size = c;
- e.style.width = c+"em";
- break;
- case "textarea":
- //e.cols = c;
- e.style.width = c+"em";
- break;
- default:;
- }
- } catch (e) {}
- }-*/;
+ try {
+ switch(e.tagName.toLowerCase()) {
+ case "input":
+ //e.size = c;
+ e.style.width = c+"em";
+ break;
+ case "textarea":
+ //e.cols = c;
+ e.style.width = c+"em";
+ break;
+ default:;
+ }
+ } catch (e) {}
+ }-*/;
private native void setRows(Element e, int r) /*-{
- try {
- if(e.tagName.toLowerCase() == "textarea")
- e.rows = r;
- } catch (e) {}
- }-*/;
+ try {
+ if(e.tagName.toLowerCase() == "textarea")
+ e.rows = r;
+ } catch (e) {}
+ }-*/;
}
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.Timer;\r
public class ITextualDate extends IDateField implements Paintable,\r
ChangeListener {\r
\r
- private ITextField text;\r
+ private final ITextField text;\r
\r
private SimpleDateFormat format;\r
\r
if (h > 11 && dts.isTwelveHourClock()) {\r
h -= 12;\r
}\r
- int m = currentResolution > IDateField.RESOLUTION_HOUR ? date\r
- .getMinutes() : 0;\r
+ final int m = currentResolution > IDateField.RESOLUTION_HOUR ? date\r
+ .getMinutes()\r
+ : 0;\r
dateText += " " + (h < 10 ? "0" + h : "" + h)\r
+ dts.getClockDelimeter() + (m < 10 ? "0" + m : "" + m);\r
}\r
if (currentResolution >= IDateField.RESOLUTION_SEC) {\r
- int s = date.getSeconds();\r
+ final int s = date.getSeconds();\r
dateText += dts.getClockDelimeter()\r
+ (s < 10 ? "0" + s : "" + s);\r
}\r
if (currentResolution == IDateField.RESOLUTION_MSEC) {\r
- int ms = getMilliseconds();\r
+ final int ms = getMilliseconds();\r
String text = "" + ms;\r
if (ms < 10) {\r
text = "00" + text;\r
\r
try {\r
date = format.parse(text.getText());\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
ApplicationConnection.getConsole().log(e.getMessage());\r
text.addStyleName(ITextField.CLASSNAME + "-error");\r
- Timer t = new Timer() {\r
+ final Timer t = new Timer() {\r
public void run() {\r
text.removeStyleName(ITextField.CLASSNAME\r
+ "-error");\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.HashMap;
private boolean selectable;
private boolean isMultiselect;
- private HashMap keyToNode = new HashMap();
+ private final HashMap keyToNode = new HashMap();
/**
* This map contains captions and icon urls for actions like: * "33_c" ->
* "Edit" * "33_i" -> "http://dom.com/edit.png"
*/
- private HashMap actionMap = new HashMap();
+ private final HashMap actionMap = new HashMap();
private boolean immediate;
}
private void updateActionMap(UIDL c) {
- Iterator it = c.getChildIterator();
+ final Iterator it = c.getChildIterator();
while (it.hasNext()) {
- UIDL action = (UIDL) it.next();
- String key = action.getStringAttribute("key");
- String caption = action.getStringAttribute("caption");
+ final UIDL action = (UIDL) it.next();
+ final String key = action.getStringAttribute("key");
+ final String caption = action.getStringAttribute("caption");
actionMap.put(key + "_c", caption);
if (action.hasAttribute("icon")) {
// TODO need some uri handling ??
isNullSelectionAllowed = uidl.getBooleanAttribute("nullselect");
clear();
- for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
- UIDL childUidl = (UIDL) i.next();
+ for (final Iterator i = uidl.getChildIterator(); i.hasNext();) {
+ final UIDL childUidl = (UIDL) i.next();
if ("actions".equals(childUidl.getTag())) {
updateActionMap(childUidl);
continue;
}
- TreeNode childTree = new TreeNode();
+ final TreeNode childTree = new TreeNode();
this.add(childTree);
childTree.updateFromUIDL(childUidl, client);
}
- String selectMode = uidl.getStringAttribute("selectmode");
+ final String selectMode = uidl.getStringAttribute("selectmode");
selectable = selectMode != null;
isMultiselect = "multi".equals(selectMode);
}
private void handleUpdate(UIDL uidl) {
- TreeNode rootNode = (TreeNode) keyToNode.get(uidl
+ final TreeNode rootNode = (TreeNode) keyToNode.get(uidl
.getStringAttribute("rootKey"));
if (rootNode != null) {
if (!rootNode.getState()) {
if (selected) {
if (!isMultiselect) {
while (selectedIds.size() > 0) {
- String id = (String) selectedIds.iterator().next();
- TreeNode oldSelection = (TreeNode) keyToNode.get(id);
+ final String id = (String) selectedIds.iterator().next();
+ final TreeNode oldSelection = (TreeNode) keyToNode.get(id);
oldSelection.setSelected(false);
selectedIds.remove(id);
}
if (disabled) {
return;
}
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (DOM.compare(getElement(), target)) {
// state change
toggleState();
}
protected void constructDom() {
- Element root = DOM.createDiv();
+ final Element root = DOM.createDiv();
nodeCaptionDiv = DOM.createDiv();
DOM.setElementProperty(nodeCaptionDiv, "className", CLASSNAME
+ "-caption");
childNodeContainer.clear();
childNodeContainer.setVisible(true);
while (i.hasNext()) {
- UIDL childUidl = (UIDL) i.next();
+ final UIDL childUidl = (UIDL) i.next();
// actions are in bit weird place, don't mix them with children,
// but current node's actions
if ("actions".equals(childUidl.getTag())) {
updateActionMap(childUidl);
continue;
}
- TreeNode childTree = new TreeNode();
+ final TreeNode childTree = new TreeNode();
childNodeContainer.add(childTree);
childTree.updateFromUIDL(childUidl, client);
}
if (actionKeys == null) {
return new Action[] {};
}
- Action[] actions = new Action[actionKeys.length];
+ final Action[] actions = new Action[actionKeys.length];
for (int i = 0; i < actions.length; i++) {
- String actionKey = actionKeys[i];
- TreeAction a = new TreeAction(this, String.valueOf(key),
+ final String actionKey = actionKeys[i];
+ final TreeAction a = new TreeAction(this, String.valueOf(key),
actionKey);
a.setCaption(getActionCaption(actionKey));
a.setIconUrl(getActionIcon(actionKey));
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import java.util.Iterator;\r
\r
private static final String DEFAULT_WIDTH = "10em";\r
\r
- private ListBox options;\r
+ private final ListBox options;\r
\r
- private ListBox selections;\r
+ private final ListBox selections;\r
\r
- private IButton add;\r
+ private final IButton add;\r
\r
- private IButton remove;\r
+ private final IButton remove;\r
\r
public ITwinColSelect() {\r
super(CLASSNAME);\r
selections.setVisibleItemCount(VISIBLE_COUNT);\r
options.setStyleName(CLASSNAME + "-options");\r
selections.setStyleName(CLASSNAME + "-selections");\r
- Panel buttons = new FlowPanel();\r
+ final Panel buttons = new FlowPanel();\r
buttons.setStyleName(CLASSNAME + "-buttons");\r
add = new IButton();\r
add.setText(">>");\r
remove = new IButton();\r
remove.setText("<<");\r
remove.addClickListener(this);\r
- Panel p = ((Panel) optionsContainer);\r
+ final Panel p = ((Panel) optionsContainer);\r
p.add(options);\r
buttons.add(add);\r
- HTML br = new HTML("<span/>");\r
+ final HTML br = new HTML("<span/>");\r
br.setStyleName(CLASSNAME + "-deco");\r
buttons.add(br);\r
buttons.add(remove);\r
}\r
\r
protected void buildOptions(UIDL uidl) {\r
- boolean enabled = !isDisabled() && !isReadonly();\r
+ final boolean enabled = !isDisabled() && !isReadonly();\r
options.setMultipleSelect(isMultiselect());\r
selections.setMultipleSelect(isMultiselect());\r
options.setEnabled(enabled);\r
remove.setEnabled(enabled);\r
options.clear();\r
selections.clear();\r
- for (Iterator i = uidl.getChildIterator(); i.hasNext();) {\r
- UIDL optionUidl = (UIDL) i.next();\r
+ for (final Iterator i = uidl.getChildIterator(); i.hasNext();) {\r
+ final UIDL optionUidl = (UIDL) i.next();\r
if (optionUidl.hasAttribute("selected")) {\r
selections.addItem(optionUidl.getStringAttribute("caption"),\r
optionUidl.getStringAttribute("key"));\r
}\r
\r
protected Object[] getSelectedItems() {\r
- Vector selectedItemKeys = new Vector();\r
+ final Vector selectedItemKeys = new Vector();\r
for (int i = 0; i < selections.getItemCount(); i++) {\r
selectedItemKeys.add(selections.getValue(i));\r
}\r
}\r
\r
private boolean[] getItemsToAdd() {\r
- boolean[] selectedIndexes = new boolean[options.getItemCount()];\r
+ final boolean[] selectedIndexes = new boolean[options.getItemCount()];\r
for (int i = 0; i < options.getItemCount(); i++) {\r
if (options.isItemSelected(i)) {\r
selectedIndexes[i] = true;\r
}\r
\r
private boolean[] getItemsToRemove() {\r
- boolean[] selectedIndexes = new boolean[selections.getItemCount()];\r
+ final boolean[] selectedIndexes = new boolean[selections.getItemCount()];\r
for (int i = 0; i < selections.getItemCount(); i++) {\r
if (selections.isItemSelected(i)) {\r
selectedIndexes[i] = true;\r
public void onClick(Widget sender) {\r
super.onClick(sender);\r
if (sender == add) {\r
- boolean[] sel = getItemsToAdd();\r
+ final boolean[] sel = getItemsToAdd();\r
for (int i = 0; i < sel.length; i++) {\r
if (sel[i]) {\r
- int optionIndex = i - (sel.length - options.getItemCount());\r
+ final int optionIndex = i\r
+ - (sel.length - options.getItemCount());\r
selectedKeys.add(options.getValue(optionIndex));\r
\r
// Move selection to another column\r
- String text = options.getItemText(optionIndex);\r
- String value = options.getValue(optionIndex);\r
+ final String text = options.getItemText(optionIndex);\r
+ final String value = options.getValue(optionIndex);\r
selections.addItem(text, value);\r
selections.setItemSelected(selections.getItemCount() - 1,\r
true);\r
isImmediate());\r
\r
} else if (sender == remove) {\r
- boolean[] sel = getItemsToRemove();\r
+ final boolean[] sel = getItemsToRemove();\r
for (int i = 0; i < sel.length; i++) {\r
if (sel[i]) {\r
- int selectionIndex = i\r
+ final int selectionIndex = i\r
- (sel.length - selections.getItemCount());\r
selectedKeys.remove(selections.getValue(selectionIndex));\r
\r
// Move selection to another column\r
- String text = selections.getItemText(selectionIndex);\r
- String value = selections.getValue(selectionIndex);\r
+ final String text = selections.getItemText(selectionIndex);\r
+ final String value = selections.getValue(selectionIndex);\r
options.addItem(text, value);\r
options.setItemSelected(options.getItemCount() - 1, true);\r
selections.removeItem(selectionIndex);\r
isImmediate());\r
} else if (sender == options) {\r
// unselect all in other list, to avoid mistakes (i.e wrong button)\r
- int c = selections.getItemCount();\r
+ final int c = selections.getItemCount();\r
for (int i = 0; i < c; i++) {\r
selections.setItemSelected(i, false);\r
}\r
} else if (sender == selections) {\r
// unselect all in other list, to avoid mistakes (i.e wrong button)\r
- int c = options.getItemCount();\r
+ final int c = options.getItemCount();\r
for (int i = 0; i < c; i++) {\r
options.setItemSelected(i, false);\r
}\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.ui.Composite;
Tree uidlTree = new Tree();
public IUnknownComponent() {
- VerticalPanel panel = new VerticalPanel();
+ final VerticalPanel panel = new VerticalPanel();
panel.add(caption);
panel.add(uidlTree);
initWidget(panel);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.Timer;
/**
* Button that initiates uploading
*/
- private Button submitButton;
+ private final Button submitButton;
/**
* When expecting big files, programmer may initiate some UI changes when
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.HashSet;
// Open URL:s
while (childIndex < uidl.getChidlCount()
&& "open".equals(uidl.getChildUIDL(childIndex).getTag())) {
- UIDL open = uidl.getChildUIDL(childIndex);
- String url = open.getStringAttribute("src");
- String target = open.getStringAttribute("name");
+ final UIDL open = uidl.getChildUIDL(childIndex);
+ final String url = open.getStringAttribute("src");
+ final String target = open.getStringAttribute("name");
if (target == null) {
goTo(url);
} else {
// Draw this application level window
UIDL childUidl = uidl.getChildUIDL(childIndex);
- Paintable lo = (Paintable) client.getWidget(childUidl);
+ final Paintable lo = (Paintable) client.getWidget(childUidl);
if (layout != null) {
if (layout != lo) {
layout.updateFromUIDL(childUidl, client);
// Update subwindows
- HashSet removedSubWindows = new HashSet(subWindows);
+ final HashSet removedSubWindows = new HashSet(subWindows);
// Open new windows
while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) {
if ("window".equals(childUidl.getTag())) {
- Widget w = client.getWidget(childUidl);
+ final Widget w = client.getWidget(childUidl);
if (subWindows.contains(w)) {
removedSubWindows.remove(w);
} else {
}
actionHandler.updateActionMap(childUidl);
} else if (childUidl.getTag().equals("notifications")) {
- for (Iterator it = childUidl.getChildIterator(); it.hasNext();) {
- UIDL notification = (UIDL) it.next();
+ for (final Iterator it = childUidl.getChildIterator(); it
+ .hasNext();) {
+ final UIDL notification = (UIDL) it.next();
String html = "";
if (notification.hasAttribute("caption")) {
html += "<H1>"
+ "</p>";
}
- String style = notification.hasAttribute("style") ? notification
+ final String style = notification.hasAttribute("style") ? notification
.getStringAttribute("style")
: null;
- int position = notification.getIntAttribute("position");
- int delay = notification.getIntAttribute("delay");
+ final int position = notification
+ .getIntAttribute("position");
+ final int delay = notification.getIntAttribute("delay");
new Notification(delay).show(html, position, style);
}
}
}
// Close old windows
- for (Iterator rem = removedSubWindows.iterator(); rem.hasNext();) {
- IWindow w = (IWindow) rem.next();
+ for (final Iterator rem = removedSubWindows.iterator(); rem.hasNext();) {
+ final IWindow w = (IWindow) rem.next();
client.unregisterPaintable(w);
subWindows.remove(w);
RootPanel.get().remove(w);
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (DOM.eventGetType(event) == Event.ONKEYDOWN && actionHandler != null) {
- int modifiers = KeyboardListenerCollection
+ final int modifiers = KeyboardListenerCollection
.getKeyboardModifiers(event);
actionHandler.handleKeyboardEvent(
(char) DOM.eventGetKeyCode(event), modifiers);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.Iterator;
ShortcutActionHandler shortcutHandler;
/** Last known width read from UIDL or updated to application connection */
- private int uidlWidth = -1;
+ private final int uidlWidth = -1;
/** Last known height read from UIDL or updated to application connection */
- private int uidlHeight = -1;
+ private final int uidlHeight = -1;
/** Last known positionx read from UIDL or updated to application connection */
private int uidlPositionX = -1;
public IWindow() {
super();
- int order = windowOrder.size();
+ final int order = windowOrder.size();
setWindowOrder(order);
windowOrder.add(this);
setStyleName(CLASSNAME);
DOM.sinkEvents(closeBox, Event.ONCLICK);
DOM.sinkEvents(contents, Event.ONCLICK);
- Element wrapper = DOM.createDiv();
+ final Element wrapper = DOM.createDiv();
DOM.setElementProperty(wrapper, "className", CLASSNAME + "-wrap");
- Element wrapper2 = DOM.createDiv();
+ final Element wrapper2 = DOM.createDiv();
DOM.setElementProperty(wrapper2, "className", CLASSNAME + "-wrap2");
DOM.sinkEvents(wrapper, Event.ONKEYDOWN);
// Initialize the width from UIDL
if (uidl.hasVariable("width")) {
- String width = uidl.getStringVariable("width");
+ final String width = uidl.getStringVariable("width");
setWidth(width);
}
if (uidl.hasVariable("height")) {
- String height = uidl.getStringVariable("height");
+ final String height = uidl.getStringVariable("height");
setHeight(height);
}
// Initialize the position form UIDL
try {
- int positionx = uidl.getIntVariable("positionx");
- int positiony = uidl.getIntVariable("positiony");
+ final int positionx = uidl.getIntVariable("positionx");
+ final int positiony = uidl.getIntVariable("positiony");
if (positionx >= 0 && positiony >= 0) {
setPopupPosition(positionx, positiony);
}
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
// Silently ignored as positionx and positiony are not required
// parameters
}
UIDL childUidl = uidl.getChildUIDL(0);
if ("open".equals(childUidl.getTag())) {
- String parsedUri = client.translateToolkitUri(childUidl
+ final String parsedUri = client.translateToolkitUri(childUidl
.getStringAttribute("src"));
// TODO this should be a while-loop for multiple opens
if (!childUidl.hasAttribute("name")) {
- Frame frame = new Frame();
+ final Frame frame = new Frame();
DOM.setStyleAttribute(frame.getElement(), "width", "100%");
DOM.setStyleAttribute(frame.getElement(), "height", "100%");
DOM.setStyleAttribute(frame.getElement(), "border", "0px");
frame.setUrl(parsedUri);
contentPanel.setWidget(frame);
} else {
- String target = childUidl.getStringAttribute("name");
+ final String target = childUidl.getStringAttribute("name");
Window.open(parsedUri, target, "");
}
} else {
- Paintable lo = (Paintable) client.getWidget(childUidl);
+ final Paintable lo = (Paintable) client.getWidget(childUidl);
if (layout != null) {
if (layout != lo) {
// remove old
// we may have actions and notifications
if (uidl.getChidlCount() > 1) {
- int cnt = uidl.getChidlCount();
+ final int cnt = uidl.getChidlCount();
for (int i = 1; i < cnt; i++) {
childUidl = uidl.getChildUIDL(i);
if (childUidl.getTag().equals("actions")) {
shortcutHandler.updateActionMap(childUidl);
} else if (childUidl.getTag().equals("notifications")) {
// TODO needed? move ->
- for (Iterator it = childUidl.getChildIterator(); it
+ for (final Iterator it = childUidl.getChildIterator(); it
.hasNext();) {
- UIDL notification = (UIDL) it.next();
+ final UIDL notification = (UIDL) it.next();
String html = "";
if (notification.hasAttribute("caption")) {
html += "<H1>"
+ "</p>";
}
- String style = notification.hasAttribute("style") ? notification
+ final String style = notification.hasAttribute("style") ? notification
.getStringAttribute("style")
: null;
- int position = notification.getIntAttribute("position");
- int delay = notification.getIntAttribute("delay");
+ final int position = notification
+ .getIntAttribute("position");
+ final int delay = notification.getIntAttribute("delay");
new Notification(delay).show(html, position, style);
}
}
}
public void onBrowserEvent(Event event) {
- int type = DOM.eventGetType(event);
+ final int type = DOM.eventGetType(event);
if (type == Event.ONKEYDOWN && shortcutHandler != null) {
- int modifiers = KeyboardListenerCollection
+ final int modifiers = KeyboardListenerCollection
.getKeyboardModifiers(event);
shortcutHandler.handleKeyboardEvent((char) DOM
.eventGetKeyCode(event), modifiers);
return;
}
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (dragging || DOM.isOrHasChild(header, target)) {
onHeaderEvent(event);
DOM.eventCancelBubble(event, true);
break;
case Event.ONMOUSEMOVE:
if (dragging) {
- int x = DOM.eventGetScreenX(event) - startX + origX;
- int y = DOM.eventGetScreenY(event) - startY + origY;
+ final int x = DOM.eventGetScreenX(event) - startX + origX;
+ final int y = DOM.eventGetScreenY(event) - startY + origY;
setPopupPosition(x, y);
DOM.eventPreventDefault(event);
}
return false;
} else if (modal) {
// return false when modal and outside window
- Element target = DOM.eventGetTarget(event);
+ final Element target = DOM.eventGetTarget(event);
if (!DOM.isOrHasChild(getElement(), target)) {
return false;
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
public class Icon extends UIObject {
- private ApplicationConnection client;
+ private final ApplicationConnection client;
private String myUri;
public Icon(ApplicationConnection client) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
public class MarginInfo {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
/*
* the License.
*/
-//COPIED HERE DUE package privates in GWT
+// COPIED HERE DUE package privates in GWT
import java.util.ArrayList;
import java.util.List;
*/
public class MenuBar extends Widget implements PopupListener {
- private Element body;
- private ArrayList items = new ArrayList();
+ private final Element body;
+ private final ArrayList items = new ArrayList();
private MenuBar parentMenu;
private PopupPanel popup;
private MenuItem selectedItem;
private MenuBar shownChildMenu;
- private boolean vertical, autoOpen;
+ private final boolean vertical;
+ private boolean autoOpen;
/**
* Creates an empty horizontal menu bar.
public MenuBar(boolean vertical) {
super();
- Element table = DOM.createTable();
+ final Element table = DOM.createTable();
body = DOM.createTBody();
DOM.appendChild(table, body);
if (!vertical) {
- Element tr = DOM.createTR();
+ final Element tr = DOM.createTR();
DOM.appendChild(body, tr);
}
this.vertical = vertical;
- Element outer = DOM.createDiv();
+ final Element outer = DOM.createDiv();
DOM.appendChild(outer, table);
setElement(outer);
* @return the {@link MenuItem} object created
*/
public MenuItem addItem(String text, boolean asHTML, Command cmd) {
- MenuItem item = new MenuItem(text, asHTML, cmd);
+ final MenuItem item = new MenuItem(text, asHTML, cmd);
addItem(item);
return item;
}
* @return the {@link MenuItem} object created
*/
public MenuItem addItem(String text, boolean asHTML, MenuBar popup) {
- MenuItem item = new MenuItem(text, asHTML, popup);
+ final MenuItem item = new MenuItem(text, asHTML, popup);
addItem(item);
return item;
}
* @return the {@link MenuItem} object created
*/
public MenuItem addItem(String text, Command cmd) {
- MenuItem item = new MenuItem(text, cmd);
+ final MenuItem item = new MenuItem(text, cmd);
addItem(item);
return item;
}
* @return the {@link MenuItem} object created
*/
public MenuItem addItem(String text, MenuBar popup) {
- MenuItem item = new MenuItem(text, popup);
+ final MenuItem item = new MenuItem(text, popup);
addItem(item);
return item;
}
* Removes all menu items from this menu bar.
*/
public void clearItems() {
- Element container = getItemContainerElement();
+ final Element container = getItemContainerElement();
while (DOM.getChildCount(container) > 0) {
DOM.removeChild(container, DOM.getChild(container, 0));
}
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
- MenuItem item = findItem(DOM.eventGetTarget(event));
+ final MenuItem item = findItem(DOM.eventGetTarget(event));
switch (DOM.eventGetType(event)) {
case Event.ONCLICK: {
// Fire an item's command when the user clicks on it.
* the item to be removed
*/
public void removeItem(MenuItem item) {
- int idx = items.indexOf(item);
+ final int idx = items.indexOf(item);
if (idx == -1) {
return;
}
- Element container = getItemContainerElement();
+ final Element container = getItemContainerElement();
DOM.removeChild(container, DOM.getChild(container, idx));
items.remove(idx);
}
closeAllParents();
// Fire the item's command.
- Command cmd = item.getCommand();
+ final Command cmd = item.getCommand();
if (cmd != null) {
DeferredCommand.addCommand(cmd);
}
// If the event target is part of the parent menu, suppress
// the
// event altogether.
- Element target = DOM.eventGetTarget(event);
- Element parentMenuElement = item.getParentMenu()
+ final Element target = DOM.eventGetTarget(event);
+ final Element parentMenuElement = item.getParentMenu()
.getElement();
if (DOM.isOrHasChild(parentMenuElement, target)) {
return false;
private MenuItem findItem(Element hItem) {
for (int i = 0; i < items.size(); ++i) {
- MenuItem item = (MenuItem) items.get(i);
+ final MenuItem item = (MenuItem) items.get(i);
if (DOM.isOrHasChild(item.getElement(), hItem)) {
return item;
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
/*
* the License.
*/
-//COPIED HERE DUE package privates in GWT
+// COPIED HERE DUE package privates in GWT
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HasHTML;
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.DOM;\r
}\r
}\r
};\r
- int msec = fadeMsec / (startOpacity / 5);\r
+ final int msec = fadeMsec / (startOpacity / 5);\r
fader.scheduleRepeating(msec);\r
}\r
\r
public void setPosition(int position) {\r
- Element el = getElement();\r
+ final Element el = getElement();\r
DOM.setStyleAttribute(el, "top", null);\r
DOM.setStyleAttribute(el, "left", null);\r
DOM.setStyleAttribute(el, "bottom", null);\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.ArrayList;
* @author IT Mill ltd
*/
public class ShortcutActionHandler {
- private ArrayList actions = new ArrayList();
+ private final ArrayList actions = new ArrayList();
private ApplicationConnection client;
private String paintableId;
*/
public void updateActionMap(UIDL c) {
actions.clear();
- Iterator it = c.getChildIterator();
+ final Iterator it = c.getChildIterator();
while (it.hasNext()) {
- UIDL action = (UIDL) it.next();
+ final UIDL action = (UIDL) it.next();
int[] modifiers = null;
if (action.hasAttribute("mk")) {
modifiers = action.getIntArrayAttribute("mk");
}
- ShortcutKeyCombination kc = new ShortcutKeyCombination(action
+ final ShortcutKeyCombination kc = new ShortcutKeyCombination(action
.getIntAttribute("kc"), modifiers);
- String key = action.getStringAttribute("key");
- String caption = action.getStringAttribute("caption");
+ final String key = action.getStringAttribute("key");
+ final String caption = action.getStringAttribute("caption");
actions.add(new ShortcutAction(key, kc, caption));
}
}
* modifier keys (bitmask like in {@link KeyboardListener})
*/
public void handleKeyboardEvent(char keyCode, int modifiers) {
- ShortcutKeyCombination kc = new ShortcutKeyCombination(keyCode,
+ final ShortcutKeyCombination kc = new ShortcutKeyCombination(keyCode,
modifiers);
- Iterator it = actions.iterator();
+ final Iterator it = actions.iterator();
while (it.hasNext()) {
- ShortcutAction a = (ShortcutAction) it.next();
+ final ShortcutAction a = (ShortcutAction) it.next();
if (a.getShortcutCombination().equals(kc)) {
client.updateVariable(paintableId, "action", a.getKey(), true);
break;
class ShortcutAction {
- private ShortcutKeyCombination sc;
- private String caption;
- private String key;
+ private final ShortcutKeyCombination sc;
+ private final String caption;
+ private final String key;
public ShortcutAction(String key, ShortcutKeyCombination sc, String caption) {
this.sc = sc;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.ui.HasWidgets;
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.ui.ChangeListener;\r
\r
public class Time extends FlowPanel implements ChangeListener {\r
\r
- private IDateField datefield;\r
+ private final IDateField datefield;\r
\r
private ListBox hours;\r
\r
}\r
\r
private void buildTime(boolean redraw) {\r
- boolean thc = datefield.getDateTimeService().isTwelveHourClock();\r
+ final boolean thc = datefield.getDateTimeService().isTwelveHourClock();\r
if (redraw) {\r
clear();\r
- int numHours = thc ? 12 : 24;\r
+ final int numHours = thc ? 12 : 24;\r
hours = new ListBox();\r
hours.setStyleName(INativeSelect.CLASSNAME);\r
for (int i = 0; i < numHours; i++) {\r
if (thc) {\r
ampm = new ListBox();\r
ampm.setStyleName(INativeSelect.CLASSNAME);\r
- String[] ampmText = datefield.getDateTimeService()\r
+ final String[] ampmText = datefield.getDateTimeService()\r
.getAmPmStrings();\r
ampm.addItem(ampmText[0]);\r
ampm.addItem(ampmText[1]);\r
msec.addChangeListener(this);\r
}\r
\r
- String delimiter = datefield.getDateTimeService()\r
+ final String delimiter = datefield.getDateTimeService()\r
.getClockDelimeter();\r
- boolean ro = datefield.isReadonly();\r
+ final boolean ro = datefield.isReadonly();\r
\r
if (ro) {\r
int h = 0;\r
if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {\r
add(new ILabel(delimiter));\r
if (ro) {\r
- int m = mins.getSelectedIndex();\r
+ final int m = mins.getSelectedIndex();\r
add(new ILabel(m < 10 ? "0" + m : "" + m));\r
} else {\r
add(mins);\r
if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {\r
add(new ILabel(delimiter));\r
if (ro) {\r
- int s = sec.getSelectedIndex();\r
+ final int s = sec.getSelectedIndex();\r
add(new ILabel(s < 10 ? "0" + s : "" + s));\r
} else {\r
add(sec);\r
if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {\r
add(new ILabel("."));\r
if (ro) {\r
- int m = datefield.getMilliseconds();\r
- String ms = m < 100 ? "0" + m : "" + m;\r
+ final int m = datefield.getMilliseconds();\r
+ final String ms = m < 100 ? "0" + m : "" + m;\r
add(new ILabel(m < 10 ? "0" + ms : ms));\r
} else {\r
add(msec);\r
if (datefield.isReadonly() && !redraw) {\r
// Do complete redraw when in read-only status\r
clear();\r
- String delimiter = datefield.getDateTimeService()\r
+ final String delimiter = datefield.getDateTimeService()\r
.getClockDelimeter();\r
\r
int h = datefield.getCurrentDate().getHours();\r
\r
if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {\r
add(new ILabel(delimiter));\r
- int m = mins.getSelectedIndex();\r
+ final int m = mins.getSelectedIndex();\r
add(new ILabel(m < 10 ? "0" + m : "" + m));\r
}\r
if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {\r
add(new ILabel(delimiter));\r
- int s = sec.getSelectedIndex();\r
+ final int s = sec.getSelectedIndex();\r
add(new ILabel(s < 10 ? "0" + s : "" + s));\r
}\r
if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {\r
add(new ILabel("."));\r
- int m = datefield.getMilliseconds();\r
- String ms = m < 100 ? "0" + m : "" + m;\r
+ final int m = datefield.getMilliseconds();\r
+ final String ms = m < 100 ? "0" + m : "" + m;\r
add(new ILabel(m < 10 ? "0" + ms : ms));\r
}\r
if (datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {\r
}\r
}\r
\r
- boolean enabled = datefield.isEnabled();\r
+ final boolean enabled = datefield.isEnabled();\r
hours.setEnabled(enabled);\r
if (mins != null) {\r
mins.setEnabled(enabled);\r
datefield.isImmediate());\r
updateTime(false);\r
} else if (sender == mins) {\r
- int m = mins.getSelectedIndex();\r
+ final int m = mins.getSelectedIndex();\r
datefield.getCurrentDate().setMinutes(m);\r
datefield.getClient().updateVariable(datefield.getId(), "min", m,\r
datefield.isImmediate());\r
updateTime(false);\r
} else if (sender == sec) {\r
- int s = sec.getSelectedIndex();\r
+ final int s = sec.getSelectedIndex();\r
datefield.getCurrentDate().setSeconds(s);\r
datefield.getClient().updateVariable(datefield.getId(), "sec", s,\r
datefield.isImmediate());\r
updateTime(false);\r
} else if (sender == msec) {\r
- int ms = msec.getSelectedIndex();\r
+ final int ms = msec.getSelectedIndex();\r
datefield.setMilliseconds(ms);\r
datefield.getClient().updateVariable(datefield.getId(), "msec", ms,\r
datefield.isImmediate());\r
updateTime(false);\r
} else if (sender == ampm) {\r
- int h = hours.getSelectedIndex() + ampm.getSelectedIndex() * 12;\r
+ final int h = hours.getSelectedIndex() + ampm.getSelectedIndex()\r
+ * 12;\r
datefield.getCurrentDate().setHours(h);\r
datefield.getClient().updateVariable(datefield.getId(), "hour", h,\r
datefield.isImmediate());\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui;
/**
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.client.ui.richtextarea;
import com.google.gwt.user.client.ui.ChangeListener;
RichTextToolbar formatter = new RichTextToolbar(rta);
public IRichTextArea() {
- FlowPanel fp = new FlowPanel();
+ final FlowPanel fp = new FlowPanel();
fp.add(formatter);
rta.setWidth("100%");
}
public void onLostFocus(Widget sender) {
- String html = rta.getHTML();
+ final String html = rta.getHTML();
client.updateVariable(id, "text", html, immediate);
}
} else if (sender == justifyRight) {
basic.setJustification(RichTextArea.Justification.RIGHT);
} else if (sender == insertImage) {
- String url = Window.prompt("Enter an image URL:", "http://");
+ final String url = Window.prompt("Enter an image URL:",
+ "http://");
if (url != null) {
extended.insertImage(url);
}
} else if (sender == createLink) {
- String url = Window.prompt("Enter a link URL:", "http://");
+ final String url = Window
+ .prompt("Enter a link URL:", "http://");
if (url != null) {
extended.createLink(url);
}
RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
RichTextArea.FontSize.XX_LARGE };
- private Images images = (Images) GWT.create(Images.class);
- private Strings strings = (Strings) GWT.create(Strings.class);
- private EventListener listener = new EventListener();
+ private final Images images = (Images) GWT.create(Images.class);
+ private final Strings strings = (Strings) GWT.create(Strings.class);
+ private final EventListener listener = new EventListener();
- private RichTextArea richText;
- private RichTextArea.BasicFormatter basic;
- private RichTextArea.ExtendedFormatter extended;
+ private final RichTextArea richText;
+ private final RichTextArea.BasicFormatter basic;
+ private final RichTextArea.ExtendedFormatter extended;
- private VerticalPanel outer = new VerticalPanel();
- private HorizontalPanel topPanel = new HorizontalPanel();
- private HorizontalPanel bottomPanel = new HorizontalPanel();
+ private final VerticalPanel outer = new VerticalPanel();
+ private final HorizontalPanel topPanel = new HorizontalPanel();
+ private final HorizontalPanel bottomPanel = new HorizontalPanel();
private ToggleButton bold;
private ToggleButton italic;
private ToggleButton underline;
}
private ListBox createColorList(String caption) {
- ListBox lb = new ListBox();
+ final ListBox lb = new ListBox();
lb.addChangeListener(listener);
lb.setVisibleItemCount(1);
}
private ListBox createFontList() {
- ListBox lb = new ListBox();
+ final ListBox lb = new ListBox();
lb.addChangeListener(listener);
lb.setVisibleItemCount(1);
}
private ListBox createFontSizes() {
- ListBox lb = new ListBox();
+ final ListBox lb = new ListBox();
lb.addChangeListener(listener);
lb.setVisibleItemCount(1);
}
private PushButton createPushButton(AbstractImagePrototype img, String tip) {
- PushButton pb = new PushButton(img.createImage());
+ final PushButton pb = new PushButton(img.createImage());
pb.addClickListener(listener);
pb.setTitle(tip);
return pb;
private ToggleButton createToggleButton(AbstractImagePrototype img,
String tip) {
- ToggleButton tb = new ToggleButton(img.createImage());
+ final ToggleButton tb = new ToggleButton(img.createImage());
tb.addClickListener(listener);
tb.setTitle(tip);
return tb;
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.util;\r
\r
import java.util.Arrays;\r
*/\r
public final static int CASE_INSENSITIVE = 2;\r
\r
- private JavaScriptObject regExp;\r
+ private final JavaScriptObject regExp;\r
\r
private static JavaScriptObject createExpression(String pattern, int flags) {\r
String sFlags = "";\r
\r
private static native JavaScriptObject _createExpression(String pattern,\r
String flags)/*-{\r
- return new RegExp(pattern, flags);\r
- }-*/;\r
+ return new RegExp(pattern, flags);\r
+ }-*/;\r
\r
private native void _match(String text, List matches)/*-{\r
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
- var result = text.match(regExp);\r
- if (result == null) return;\r
- for (var i=0;i<result.length;i++)\r
- matches.@java.util.ArrayList::add(Ljava/lang/Object;)(result[i]);\r
- }-*/;\r
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
+ var result = text.match(regExp);\r
+ if (result == null) return;\r
+ for (var i=0;i<result.length;i++)\r
+ matches.@java.util.ArrayList::add(Ljava/lang/Object;)(result[i]);\r
+ }-*/;\r
\r
/**\r
* Determines wether the specified regular expression is validated by the\r
* array is returned.\r
*/\r
public String[] match(String text) {\r
- List matches = new ArrayList();\r
+ final List matches = new ArrayList();\r
_match(text, matches);\r
- String arr[] = new String[matches.size()];\r
+ final String arr[] = new String[matches.size()];\r
for (int i = 0; i < matches.size(); i++) {\r
arr[i] = matches.get(i).toString();\r
}\r
* @return\r
*/\r
public native boolean matches(String text)/*-{\r
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
- return regExp.test(text);\r
- }-*/;\r
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
+ return regExp.test(text);\r
+ }-*/;\r
\r
/**\r
* Returns the regular expression for this pattern\r
* @return\r
*/\r
public native String pattern()/*-{\r
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
- return regExp.source;\r
- }-*/;\r
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
+ return regExp.source;\r
+ }-*/;\r
\r
private native void _split(String input, List results)/*-{\r
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
- var parts = input.split(regExp);\r
- for (var i=0;i<parts.length;i++)\r
- results.@java.util.ArrayList::add(Ljava/lang/Object;)(parts[i] );\r
- }-*/;\r
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
+ var parts = input.split(regExp);\r
+ for (var i=0;i<parts.length;i++)\r
+ results.@java.util.ArrayList::add(Ljava/lang/Object;)(parts[i] );\r
+ }-*/;\r
\r
/**\r
* Split an input string by the pattern's regular expression\r
* @return Array of strings\r
*/\r
public String[] split(String input) {\r
- List results = new ArrayList();\r
+ final List results = new ArrayList();\r
_split(input, results);\r
- String[] parts = new String[results.size()];\r
+ final String[] parts = new String[results.size()];\r
for (int i = 0; i < results.size(); i++) {\r
parts[i] = (String) results.get(i);\r
}\r
* @version $Revision: 0.0 $
*/
public class SimpleDateFormat {
- private String format;
+ private final String format;
private DateLocale locale = new DateLocale();
/**
String lastTokenType = null;
String currentToken = "";
for (int i = 0; i < format.length(); i++) {
- String thisChar = format.substring(i, i + 1);
- String currentTokenType = DateLocale.SUPPORTED_DF_TOKENS
+ final String thisChar = format.substring(i, i + 1);
+ final String currentTokenType = DateLocale.SUPPORTED_DF_TOKENS
.contains(thisChar) ? thisChar : "";
if (currentTokenType.equals(lastTokenType) || i == 0) {
currentToken += thisChar;
*/
private String handleToken(String token, Date date) {
String response = token;
- String tc = token.substring(0, 1);
+ final String tc = token.substring(0, 1);
if (DateLocale.TOKEN_DAY_OF_WEEK.equals(tc)) {
if (token.length() > 3) {
response = locale.getWEEKDAY_LONG()[date.getDay()];
// else
// response = Integer.toString(date.getSeconds());
} else if (DateLocale.TOKEN_AM_PM.equals(tc)) {
- int hour = date.getHours();
+ final int hour = date.getHours();
if (hour > 11) {
response = DateLocale.getPM();
} else {
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.terminal.gwt.client.util;\r
\r
import java.util.Date;\r
{ "y", "(\\d{1,2})", DateLocale.TOKEN_YEAR },\r
{ "a", "(\\S{1,4})", DateLocale.TOKEN_AM_PM } };\r
\r
- private Pattern regularExpression;\r
+ private final Pattern regularExpression;\r
\r
private String instructions = "";\r
\r
}\r
if (format.startsWith("'")) {\r
format = format.substring(1);\r
- int end = format.indexOf("'");\r
+ final int end = format.indexOf("'");\r
if (end == -1) {\r
throw new IllegalArgumentException("Unmatched single quotes.");\r
}\r
format = format.substring(end + 1);\r
}\r
for (int i = 0; i < TOKENS.length; i++) {\r
- String[] row = TOKENS[i];\r
- String datePattern = row[DATE_PATTERN];\r
+ final String[] row = TOKENS[i];\r
+ final String datePattern = row[DATE_PATTERN];\r
if (!format.startsWith(datePattern)) {\r
continue;\r
}\r
\r
if (component.equals(DateLocale.TOKEN_HOUR_12)) {\r
int h = Integer.parseInt(text);\r
- String token = com.itmill.toolkit.terminal.gwt.client.DateLocale\r
+ final String token = com.itmill.toolkit.terminal.gwt.client.DateLocale\r
.getPM();\r
- String which = input.substring(input.length() - token.length()); // Assumes\r
+ final String which = input.substring(input.length()\r
+ - token.length()); // Assumes\r
// both\r
// AM\r
// and\r
}\r
\r
public SimpleDateParser(String format) {\r
- String[] args = new String[] { "", "" };\r
+ final String[] args = new String[] { "", "" };\r
_parse(format, args);\r
regularExpression = new Pattern(args[REGEX]);\r
instructions = args[INSTRUCTION];\r
}\r
\r
public Date parse(String input) {\r
- Date date = new Date(0, 0, 0, 0, 0, 0);\r
- String matches[] = regularExpression.match(input);\r
+ final Date date = new Date(0, 0, 0, 0, 0, 0);\r
+ final String matches[] = regularExpression.match(input);\r
if (matches == null) {\r
throw new IllegalArgumentException(input + " does not match "\r
+ regularExpression.pattern());\r
+ input + " does not match " + regularExpression.pattern());\r
}\r
for (int group = 0; group < instructions.length(); group++) {\r
- String match = matches[group + 1];\r
+ final String match = matches[group + 1];\r
load(date, match, "" + instructions.charAt(group), input,\r
regularExpression);\r
}\r
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.terminal.gwt.server;
} else {
VERSION = "@VERSION@";
}
- String[] digits = VERSION.split("\\.");
+ final String[] digits = VERSION.split("\\.");
VERSION_MAJOR = Integer.parseInt(digits[0]);
VERSION_MINOR = Integer.parseInt(digits[1]);
VERSION_BUILD = digits[2];
super.init(servletConfig);
// Get applicationRunner
- String applicationRunner = servletConfig
+ final String applicationRunner = servletConfig
.getInitParameter("applicationRunner");
if (applicationRunner != null) {
- if ("true".equals(applicationRunner))
+ if ("true".equals(applicationRunner)) {
applicationRunnerMode = true;
- else if ("false".equals(applicationRunner))
+ } else if ("false".equals(applicationRunner)) {
applicationRunnerMode = false;
- else
+ } else {
throw new ServletException(
"If applicationRunner parameter is given for an application, it must be 'true' or 'false'");
+ }
}
// Stores the application parameters into Properties object
applicationProperties = new Properties();
- for (Enumeration e = servletConfig.getInitParameterNames(); e
+ for (final Enumeration e = servletConfig.getInitParameterNames(); e
.hasMoreElements();) {
- String name = (String) e.nextElement();
+ final String name = (String) e.nextElement();
applicationProperties.setProperty(name, servletConfig
.getInitParameter(name));
}
// Overrides with server.xml parameters
- ServletContext context = servletConfig.getServletContext();
- for (Enumeration e = context.getInitParameterNames(); e
+ final ServletContext context = servletConfig.getServletContext();
+ for (final Enumeration e = context.getInitParameterNames(); e
.hasMoreElements();) {
- String name = (String) e.nextElement();
+ final String name = (String) e.nextElement();
applicationProperties.setProperty(name, context
.getInitParameter(name));
}
// Gets the debug window parameter
- String debug = getApplicationOrSystemProperty(PARAMETER_DEBUG, "")
+ final String debug = getApplicationOrSystemProperty(PARAMETER_DEBUG, "")
.toLowerCase();
// Enables application specific debug
debugMode = debug;
// Gets custom class loader
- String classLoaderName = getApplicationOrSystemProperty("ClassLoader",
- null);
+ final String classLoaderName = getApplicationOrSystemProperty(
+ "ClassLoader", null);
ClassLoader classLoader;
if (classLoaderName == null) {
classLoader = getClass().getClassLoader();
} else {
try {
- Class classLoaderClass = getClass().getClassLoader().loadClass(
- classLoaderName);
- Constructor c = classLoaderClass
+ final Class classLoaderClass = getClass().getClassLoader()
+ .loadClass(classLoaderName);
+ final Constructor c = classLoaderClass
.getConstructor(new Class[] { ClassLoader.class });
classLoader = (ClassLoader) c
.newInstance(new Object[] { getClass().getClassLoader() });
- } catch (Exception e) {
+ } catch (final Exception e) {
System.err.println("Could not find specified class loader: "
+ classLoaderName);
throw new ServletException(e);
// as the servlet itself
if (!applicationRunnerMode) {
// Gets the application class name
- String applicationClassName = servletConfig
+ final String applicationClassName = servletConfig
.getInitParameter("application");
- if (applicationClassName == null)
+ if (applicationClassName == null) {
throw new ServletException(
"Application not specified in servlet parameters");
+ }
try {
applicationClass = classLoader.loadClass(applicationClassName);
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
throw new ServletException("Failed to load application class: "
+ applicationClassName);
}
// Try system properties
String pkgName;
- Package pkg = getClass().getPackage();
+ final Package pkg = getClass().getPackage();
if (pkg != null) {
pkgName = pkg.getName();
} else {
- String className = getClass().getName();
+ final String className = getClass().getName();
pkgName = new String(className.toCharArray(), 0, className
.lastIndexOf('.'));
}
if (request.getPathInfo() != null) {
if (applicationRunnerMode
&& (request.getPathInfo().indexOf("/", 1) != -1)) {
- String resourceUrl = request.getPathInfo().substring(
+ final String resourceUrl = request.getPathInfo().substring(
request.getPathInfo().indexOf('/', 1));
if (resourceUrl.startsWith("/ITMILL/")) {
serveStaticResourcesInITMILL(resourceUrl, response);
}
// Update browser details
- WebBrowser browser = WebApplicationContext.getApplicationContext(
- request.getSession()).getBrowser();
+ final WebBrowser browser = WebApplicationContext
+ .getApplicationContext(request.getSession()).getBrowser();
browser.updateBrowserProperties(request);
// TODO Add screen height and width to the GWT client
DownloadStream download = null;
// Handles AJAX UIDL requests
- String resourceId = request.getPathInfo();
+ final String resourceId = request.getPathInfo();
if (resourceId != null) {
if (applicationRunnerMode) {
if (resourceId.indexOf("/", 1) != -1) {
- String resourceUrl = resourceId.substring(resourceId
- .indexOf('/', 1));
+ final String resourceUrl = resourceId
+ .substring(resourceId.indexOf('/', 1));
if (resourceId != null
&& (resourceUrl.startsWith(AJAX_UIDL_URI))) {
getApplicationManager(application)
}
// Handle parameters
- Map parameters = request.getParameterMap();
+ final Map parameters = request.getParameterMap();
if (window != null && parameters != null) {
window.handleParameters(parameters);
}
handleDownload(download, request, response);
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
// Print stacktrace
e.printStackTrace();
// Re-throw other exceptions
*/
private void serveStaticResourcesInITMILL(String filename,
HttpServletResponse response) throws IOException {
- ServletContext sc = getServletContext();
+ final ServletContext sc = getServletContext();
InputStream is = sc.getResourceAsStream(filename);
if (is == null) {
// try if requested file is found from classloader
// strip leading "/" otherwise stream from JAR wont work
filename = filename.substring(1);
is = classLoader.getResourceAsStream(filename);
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
if (is == null) {
return;
}
}
- String mimetype = sc.getMimeType(filename);
+ final String mimetype = sc.getMimeType(filename);
if (mimetype != null) {
response.setContentType(mimetype);
}
- OutputStream os = response.getOutputStream();
- byte buffer[] = new byte[20000];
+ final OutputStream os = response.getOutputStream();
+ final byte buffer[] = new byte[20000];
int bytes;
while ((bytes = is.read(buffer)) >= 0) {
os.write(buffer, 0, bytes);
HttpServletResponse response, Window window, String themeName)
throws IOException, MalformedURLException {
response.setContentType("text/html");
- BufferedWriter page = new BufferedWriter(new OutputStreamWriter(
+ final BufferedWriter page = new BufferedWriter(new OutputStreamWriter(
response.getOutputStream()));
- String pathInfo = request.getPathInfo() == null ? "/" : request
+ final String pathInfo = request.getPathInfo() == null ? "/" : request
.getPathInfo();
page
.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
if (applicationRunnerMode) {
String servletPath = request.getContextPath()
+ request.getServletPath();
- if (request.getPathInfo().indexOf('/', 1) == -1)
+ if (request.getPathInfo().indexOf('/', 1) == -1) {
servletPath += request.getPathInfo();
- else
+ } else {
servletPath += request.getPathInfo().substring(1,
request.getPathInfo().indexOf('/', 1));
+ }
appUrl = servletPath;
} else {
urlParts = getApplicationUrl(request).toString().split("\\/");
widgetset = DEFAULT_WIDGETSET;
}
- String staticFilePath = getApplicationOrSystemProperty(
+ final String staticFilePath = getApplicationOrSystemProperty(
PARAMETER_ITMILL_RESOURCES, appUrl);
// Default theme does not use theme URI
DownloadStream stream = null;
try {
stream = application.handleURI(application.getURL(), uri);
- } catch (Throwable t) {
+ } catch (final Throwable t) {
application.terminalError(new URIHandlerErrorImpl(application, t));
}
HttpServletRequest request, HttpServletResponse response) {
// Download from given stream
- InputStream data = stream.getStream();
+ final InputStream data = stream.getStream();
if (data != null) {
// Sets content type
response.setContentType(stream.getContentType());
// Sets cache headers
- long cacheTime = stream.getCacheTime();
+ final long cacheTime = stream.getCacheTime();
if (cacheTime <= 0) {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
// Copy download stream parameters directly
// to HTTP headers.
- Iterator i = stream.getParameterNames();
+ final Iterator i = stream.getParameterNames();
if (i != null) {
while (i.hasNext()) {
- String param = (String) i.next();
+ final String param = (String) i.next();
response.setHeader(param, stream.getParameter(param));
}
}
if (bufferSize <= 0 || bufferSize > MAX_BUFFER_SIZE) {
bufferSize = DEFAULT_BUFFER_SIZE;
}
- byte[] buffer = new byte[bufferSize];
+ final byte[] buffer = new byte[bufferSize];
int bytesRead = 0;
try {
- OutputStream out = response.getOutputStream();
+ final OutputStream out = response.getOutputStream();
while ((bytesRead = data.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
out.flush();
}
out.close();
- } catch (IOException ignored) {
+ } catch (final IOException ignored) {
}
}
try {
data = getServletContext().getResourceAsStream(
THEME_DIRECTORY_PATH + themeName + "/" + resourceId);
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
data = null;
}
// Tomcats
// Writes the data to client
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+ final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int bytesRead = 0;
- OutputStream out = response.getOutputStream();
+ final OutputStream out = response.getOutputStream();
while ((bytesRead = data.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
}
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
- } catch (java.io.IOException e) {
+ } catch (final java.io.IOException e) {
System.err.println("Resource transfer failed: "
+ request.getRequestURI() + ". (" + e.getMessage() + ")");
}
URL applicationUrl;
try {
- URL reqURL = new URL(
+ final URL reqURL = new URL(
(request.isSecure() ? "https://" : "http://")
+ request.getServerName()
+ ((request.isSecure() && request.getServerPort() == 443)
.getServerPort() == 80) ? "" : ":"
+ request.getServerPort())
+ request.getRequestURI());
- if (applicationRunnerMode)
+ if (applicationRunnerMode) {
return reqURL;
+ }
String servletPath = request.getContextPath()
+ request.getServletPath();
if (servletPath.length() == 0
servletPath = servletPath + "/";
}
applicationUrl = new URL(reqURL, servletPath);
- } catch (MalformedURLException e) {
+ } catch (final MalformedURLException e) {
System.err.println("Error constructing application url "
+ request.getRequestURI() + " (" + e + ")");
throw e;
InstantiationException {
// Ensures that the session is still valid
- HttpSession session = request.getSession(true);
+ final HttpSession session = request.getSession(true);
// Gets application list for the session.
- Collection applications = WebApplicationContext.getApplicationContext(
- session).getApplications();
+ final Collection applications = WebApplicationContext
+ .getApplicationContext(session).getApplications();
// Search for the application (using the application URI) from the list
- for (Iterator i = applications.iterator(); i.hasNext();) {
- Application a = (Application) i.next();
- String aPath = a.getURL().getPath();
+ for (final Iterator i = applications.iterator(); i.hasNext();) {
+ final Application a = (Application) i.next();
+ final String aPath = a.getURL().getPath();
String servletPath = request.getContextPath()
+ request.getServletPath();
if (servletPath.length() < aPath.length()) {
servletPath += "/";
}
if (applicationRunnerMode) {
- if (request.getPathInfo().indexOf('/', 1) == -1)
+ if (request.getPathInfo().indexOf('/', 1) == -1) {
servletPath += request.getPathInfo();
- else
+ } else {
servletPath += request.getPathInfo().substring(1,
request.getPathInfo().indexOf('/', 1));
+ }
}
if (servletPath.equals(aPath)) {
}
}
// Creates application, because a running one was not found
- WebApplicationContext context = WebApplicationContext
+ final WebApplicationContext context = WebApplicationContext
.getApplicationContext(request.getSession());
- URL applicationUrl = getApplicationUrl(request);
+ final URL applicationUrl = getApplicationUrl(request);
if (applicationRunnerMode) {
- String applicationClassName = applicationUrl.getPath().substring(
- applicationUrl.getPath().lastIndexOf('/') + 1);
+ final String applicationClassName = applicationUrl.getPath()
+ .substring(applicationUrl.getPath().lastIndexOf('/') + 1);
try {
applicationClass = classLoader.loadClass(applicationClassName);
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
throw new InstantiationException(
"Failed to load application class: "
+ applicationClassName);
// Creates new application and start it
try {
- Application application = (Application) applicationClass
+ final Application application = (Application) applicationClass
.newInstance();
context.addApplication(application);
application.start(applicationUrl, applicationProperties, context);
return application;
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
System.err.println("Illegal access to application class "
+ applicationClass.getName());
throw e;
- } catch (InstantiationException e) {
+ } catch (final InstantiationException e) {
System.err.println("Failed to instantiate application class: "
+ applicationClass.getName());
throw e;
logoutUrl = application.getURL().toString();
}
- HttpSession session = request.getSession();
+ final HttpSession session = request.getSession();
if (session != null) {
WebApplicationContext.getApplicationContext(session)
.removeApplication(application);
if (path.charAt(0) == '/') {
path = path.substring(1);
}
- int index = path.indexOf('/');
+ final int index = path.indexOf('/');
if (index < 0) {
windowName = path;
path = "";
*/
public boolean isDebugMode(Map parameters) {
if (parameters != null) {
- Object[] debug = (Object[]) parameters.get("debug");
+ final Object[] debug = (Object[]) parameters.get("debug");
if (debug != null && !"false".equals(debug[0].toString())
&& !"false".equals(debugMode)) {
return true;
return resultPath;
} else {
try {
- URL url = servletContext.getResource(path);
+ final URL url = servletContext.getResource(path);
resultPath = url.getFile();
- } catch (Exception e) {
+ } catch (final Exception e) {
// ignored
}
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.terminal.gwt.server;
private static int MAX_BUFFER_SIZE = 64 * 1024;
- private HashSet dirtyPaintabletSet = new HashSet();
+ private final HashSet dirtyPaintabletSet = new HashSet();
- private WeakHashMap paintableIdMap = new WeakHashMap();
+ private final WeakHashMap paintableIdMap = new WeakHashMap();
- private WeakHashMap idPaintableMap = new WeakHashMap();
+ private final WeakHashMap idPaintableMap = new WeakHashMap();
private int idSequence = 0;
- private Application application;
+ private final Application application;
- private Set removedWindows = new HashSet();
+ private final Set removedWindows = new HashSet();
private JsonPaintTarget paintTarget;
private int pendingLocalesIndex;
- private ApplicationServlet applicationServlet;
+ private final ApplicationServlet applicationServlet;
public CommunicationManager(Application application,
ApplicationServlet applicationServlet) {
public void handleFileUpload(HttpServletRequest request,
HttpServletResponse response) throws IOException {
// Create a new file upload handler
- ServletFileUpload upload = new ServletFileUpload();
+ final ServletFileUpload upload = new ServletFileUpload();
- UploadProgressListener pl = new UploadProgressListener();
+ final UploadProgressListener pl = new UploadProgressListener();
upload.setProgressListener(pl);
* request.
*/
while (iter.hasNext()) {
- FileItemStream item = iter.next();
- String name = item.getFieldName();
+ final FileItemStream item = iter.next();
+ final String name = item.getFieldName();
final String filename = item.getName();
final String mimeType = item.getContentType();
final InputStream stream = item.openStream();
if (item.isFormField()) {
// ignored, upload requests contian only files
} else {
- String pid = name.split("_")[0];
- Upload uploadComponent = (Upload) idPaintableMap.get(pid);
+ final String pid = name.split("_")[0];
+ final Upload uploadComponent = (Upload) idPaintableMap
+ .get(pid);
if (uploadComponent == null) {
throw new FileUploadException(
"Upload component not found");
// put upload component into receiving state
uploadComponent.startUpload();
}
- UploadStream upstream = new UploadStream() {
+ final UploadStream upstream = new UploadStream() {
public String getContentName() {
return filename;
uploadComponent.receiveUpload(upstream);
}
}
- } catch (FileUploadException e) {
+ } catch (final FileUploadException e) {
e.printStackTrace();
}
// Send short response to acknowledge client that request was done
response.setContentType("text/html");
- OutputStream out = response.getOutputStream();
- PrintWriter outWriter = new PrintWriter(new BufferedWriter(
+ final OutputStream out = response.getOutputStream();
+ final PrintWriter outWriter = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(out, "UTF-8")));
outWriter.print("<html><body>download handled</body></html>");
outWriter.flush();
boolean repaintAll = (request.getParameter(GET_PARAM_REPAINT_ALL) != null)
|| request.getSession().isNew();
- OutputStream out = response.getOutputStream();
- PrintWriter outWriter = new PrintWriter(new BufferedWriter(
+ final OutputStream out = response.getOutputStream();
+ final PrintWriter outWriter = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(out, "UTF-8")));
try {
// If repaint is requested, clean all ids in this root window
if (repaintAll) {
- for (Iterator it = idPaintableMap.keySet().iterator(); it
+ for (final Iterator it = idPaintableMap.keySet().iterator(); it
.hasNext();) {
- Component c = (Component) idPaintableMap.get(it.next());
+ final Component c = (Component) idPaintableMap.get(it
+ .next());
if (isChildOf(window, c)) {
it.remove();
paintableIdMap.remove(c);
if (paintables != null) {
// Creates "working copy" of the current state.
- List currentPaintables = new ArrayList(paintables);
+ final List currentPaintables = new ArrayList(paintables);
// Sorts the Paintable list so that parents
// are always painted before children
Collections.sort(currentPaintables, new Comparator() {
public int compare(Object o1, Object o2) {
- Component c1 = (Component) o1;
- Component c2 = (Component) o2;
+ final Component c1 = (Component) o1;
+ final Component c2 = (Component) o2;
if (isChildOf(c1, c2)) {
return -1;
}
}
});
- for (Iterator i = currentPaintables.iterator(); i.hasNext();) {
- Paintable p = (Paintable) i.next();
+ for (final Iterator i = currentPaintables.iterator(); i
+ .hasNext();) {
+ final Paintable p = (Paintable) i.next();
// TODO CLEAN
if (p instanceof Window) {
- Window w = (Window) p;
+ final Window w = (Window) p;
if (w.getTerminal() == null) {
w.setTerminal(application.getMainWindow()
.getTerminal());
// rendered already (changes with only cached flag)
paintTarget.startTag("change");
paintTarget.addAttribute("format", "uidl");
- String pid = getPaintableId(p);
+ final String pid = getPaintableId(p);
paintTarget.addAttribute("pid", pid);
// Track paints to identify empty paints
outWriter.print("]"); // close changes
outWriter.print(", \"meta\" : {");
- boolean metaOpen = false;
+ final boolean metaOpen = false;
// add meta instruction for client to set focus if it is set
- Paintable f = (Paintable) application.consumeFocus();
+ final Paintable f = (Paintable) application.consumeFocus();
if (f != null) {
if (metaOpen) {
outWriter.write(",");
// TODO We should only precache the layouts that are not
// cached already
int resourceIndex = 0;
- for (Iterator i = paintTarget.getPreCachedResources()
+ for (final Iterator i = paintTarget.getPreCachedResources()
.iterator(); i.hasNext();) {
- String resource = (String) i.next();
+ final String resource = (String) i.next();
InputStream is = null;
try {
is = applicationServlet
"/"
+ ApplicationServlet.THEME_DIRECTORY_PATH
+ themeName + "/" + resource);
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
if (is != null) {
outWriter.print((resourceIndex++ > 0 ? ", " : "")
+ "\"" + resource + "\" : ");
- StringBuffer layout = new StringBuffer();
+ final StringBuffer layout = new StringBuffer();
try {
- InputStreamReader r = new InputStreamReader(is);
- char[] buffer = new char[20000];
+ final InputStreamReader r = new InputStreamReader(
+ is);
+ final char[] buffer = new char[20000];
int charsRead = 0;
while ((charsRead = r.read(buffer)) > 0) {
layout.append(buffer, 0, charsRead);
}
r.close();
- } catch (java.io.IOException e) {
+ } catch (final java.io.IOException e) {
System.err.println("Resource transfer failed: "
+ request.getRequestURI() + ". ("
+ e.getMessage() + ")");
out.flush();
out.close();
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
// Writes the error report to client
// FIXME breaks UIDL response, security shouldn't reveal stack trace
// to client side
- OutputStreamWriter w = new OutputStreamWriter(out);
- PrintWriter err = new PrintWriter(w);
+ final OutputStreamWriter w = new OutputStreamWriter(out);
+ final PrintWriter err = new PrintWriter(w);
err
.write("<html><head><title>Application Internal Error</title></head><body>");
err.write("<h1>" + e.toString() + "</h1><pre>\n");
private Map handleVariables(HttpServletRequest request,
Application application2) {
- Map params = new HashMap(request.getParameterMap());
- String changes = (String) ((params.get("changes") instanceof String[]) ? ((String[]) params
+ final Map params = new HashMap(request.getParameterMap());
+ final String changes = (String) ((params.get("changes") instanceof String[]) ? ((String[]) params
.get("changes"))[0]
: params.get("changes"));
params.remove("changes");
if (changes != null) {
- String[] ca = changes.split("\u0001");
+ final String[] ca = changes.split("\u0001");
for (int i = 0; i < ca.length; i++) {
String[] vid = ca[i].split("_");
- VariableOwner owner = (VariableOwner) idPaintableMap
+ final VariableOwner owner = (VariableOwner) idPaintableMap
.get(vid[0]);
if (owner != null) {
Map m;
// Store JVM default locale for later restoration
// (we'll have to change the default locale for a while)
- Locale jvmDefault = Locale.getDefault();
+ final Locale jvmDefault = Locale.getDefault();
// Send locale informations to client
outWriter.print(", \"locales\":[");
for (; pendingLocalesIndex < locales.size(); pendingLocalesIndex++) {
- Locale l = generateLocale((String) locales.get(pendingLocalesIndex));
+ final Locale l = generateLocale((String) locales
+ .get(pendingLocalesIndex));
// Locale name
outWriter.print("{\"name\":\"" + l.toString() + "\",");
/*
* Month names (both short and full)
*/
- DateFormatSymbols dfs = new DateFormatSymbols(l);
- String[] short_months = dfs.getShortMonths();
- String[] months = dfs.getMonths();
+ final DateFormatSymbols dfs = new DateFormatSymbols(l);
+ final String[] short_months = dfs.getShortMonths();
+ final String[] months = dfs.getMonths();
outWriter.print("\"smn\":[\""
+ // ShortMonthNames
short_months[0] + "\",\"" + short_months[1] + "\",\""
/*
* Weekday names (both short and full)
*/
- String[] short_days = dfs.getShortWeekdays();
- String[] days = dfs.getWeekdays();
+ final String[] short_days = dfs.getShortWeekdays();
+ final String[] days = dfs.getWeekdays();
outWriter.print("\"sdn\":[\""
+ // ShortDayNames
short_days[1] + "\",\"" + short_days[2] + "\",\""
/*
* First day of week (0 = sunday, 1 = monday)
*/
- Calendar cal = new GregorianCalendar(l);
+ final Calendar cal = new GregorianCalendar(l);
outWriter.print("\"fdow\":" + (cal.getFirstDayOfWeek() - 1) + ",");
/*
// Force our locale as JVM default for a while (SimpleDateFormat
// uses JVM default)
Locale.setDefault(l);
- String df = new SimpleDateFormat().toPattern();
+ final String df = new SimpleDateFormat().toPattern();
int timeStart = df.indexOf("H");
if (timeStart < 0) {
timeStart = df.indexOf("h");
}
- int ampm_first = df.indexOf("a");
+ final int ampm_first = df.indexOf("a");
// E.g. in Korean locale AM/PM is before h:mm
// TODO should take that into consideration on client-side as well,
// now always h:mm a
if (ampm_first > 0 && ampm_first < timeStart) {
timeStart = ampm_first;
}
- String dateformat = df.substring(0, timeStart - 1);
+ final String dateformat = df.substring(0, timeStart - 1);
outWriter.print("\"df\":\"" + dateformat.trim() + "\",");
/*
* Time formatting (24 or 12 hour clock and AM/PM suffixes)
*/
- String timeformat = df.substring(timeStart, df.length()); // Doesn't
+ final String timeformat = df.substring(timeStart, df.length()); // Doesn't
// return
// second
// or
// milliseconds
// We use timeformat to determine 12/24-hour clock
- boolean twelve_hour_clock = timeformat.indexOf("a") > -1;
+ final boolean twelve_hour_clock = timeformat.indexOf("a") > -1;
// TODO there are other possibilities as well, like 'h' in french
// (ignore them, too complicated)
- String hour_min_delimiter = timeformat.indexOf(".") > -1 ? "."
+ final String hour_min_delimiter = timeformat.indexOf(".") > -1 ? "."
: ":";
// outWriter.print("\"tf\":\"" + timeformat + "\",");
outWriter.print("\"thc\":" + twelve_hour_clock + ",");
outWriter.print("\"hmd\":\"" + hour_min_delimiter + "\"");
if (twelve_hour_clock) {
- String[] ampm = dfs.getAmPmStrings();
+ final String[] ampm = dfs.getAmPmStrings();
outWriter.print(",\"ampm\":[\"" + ampm[0] + "\",\"" + ampm[1]
+ "\"]");
}
if (path.charAt(0) == '/') {
path = path.substring(1);
}
- int index = path.indexOf('/');
+ final int index = path.indexOf('/');
if (index < 0) {
windowName = path;
path = "";
HttpServletRequest request, HttpServletResponse response) {
// Download from given stream
- InputStream data = stream.getStream();
+ final InputStream data = stream.getStream();
if (data != null) {
// Sets content type
response.setContentType(stream.getContentType());
// Sets cache headers
- long cacheTime = stream.getCacheTime();
+ final long cacheTime = stream.getCacheTime();
if (cacheTime <= 0) {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
// Copy download stream parameters directly
// to HTTP headers.
- Iterator i = stream.getParameterNames();
+ final Iterator i = stream.getParameterNames();
if (i != null) {
while (i.hasNext()) {
- String param = (String) i.next();
+ final String param = (String) i.next();
response.setHeader(param, stream.getParameter(param));
}
}
if (bufferSize <= 0 || bufferSize > MAX_BUFFER_SIZE) {
bufferSize = DEFAULT_BUFFER_SIZE;
}
- byte[] buffer = new byte[bufferSize];
+ final byte[] buffer = new byte[bufferSize];
int bytesRead = 0;
try {
- OutputStream out = response.getOutputStream();
+ final OutputStream out = response.getOutputStream();
while ((bytesRead = data.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
out.flush();
}
out.close();
- } catch (IOException ignored) {
+ } catch (final IOException ignored) {
}
}
// tell client that application has quit and where to point browser now
// Set the response type
response.setContentType("application/json; charset=UTF-8");
- ServletOutputStream out = response.getOutputStream();
- PrintWriter outWriter = new PrintWriter(new BufferedWriter(
+ final ServletOutputStream out = response.getOutputStream();
+ final PrintWriter outWriter = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(out, "UTF-8")));
outWriter.print(")/*{");
outWriter.print("\"redirect\":{");
* @return
*/
public synchronized Set getDirtyComponents(Window w) {
- HashSet resultset = new HashSet(dirtyPaintabletSet);
+ final HashSet resultset = new HashSet(dirtyPaintabletSet);
// The following algorithm removes any components that would be painted
// as
// The result is that each component should be painted exactly once and
// any unmodified components will be painted as "cached=true".
- for (Iterator i = dirtyPaintabletSet.iterator(); i.hasNext();) {
- Paintable p = (Paintable) i.next();
+ for (final Iterator i = dirtyPaintabletSet.iterator(); i.hasNext();) {
+ final Paintable p = (Paintable) i.next();
if (p instanceof Component) {
- Component component = (Component) p;
+ final Component component = (Component) p;
if (component.getApplication() == null) {
// component is detached after requestRepaint is called
resultset.remove(p);
* @see com.itmill.toolkit.terminal.Paintable.RepaintRequestListener#repaintRequested(com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent)
*/
public void repaintRequested(RepaintRequestEvent event) {
- Paintable p = event.getPaintable();
+ final Paintable p = event.getPaintable();
dirtyPaintabletSet.add(p);
}
}
public Set entrySet() {
- Set s = new HashSet();
+ final Set s = new HashSet();
s.add(new Map.Entry() {
public Object getKey() {
}
public Set keySet() {
- Set s = new HashSet();
+ final Set s = new HashSet();
s.add(name);
return s;
}
}
public Collection values() {
- LinkedList s = new LinkedList();
+ final LinkedList s = new LinkedList();
s.add(value);
return s;
*/
public class URIHandlerErrorImpl implements URIHandler.ErrorEvent {
- private URIHandler owner;
+ private final URIHandler owner;
- private Throwable throwable;
+ private final Throwable throwable;
/**
*
}
private Locale generateLocale(String value) {
- String[] temp = value.split("_");
+ final String[] temp = value.split("_");
if (temp.length == 1) {
return new Locale(temp[0]);
} else if (temp.length == 2) {
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.terminal.gwt.server;
/**
* Holds value of property variableName.
*/
- private String streamName;
+ private final String streamName;
- private String contentName;
+ private final String contentName;
- private String contentType;
+ private final String contentType;
/**
* Holds value of property variableValue.
*/
- private InputStream stream;
+ private final InputStream stream;
/**
* Creates a new instance of UploadStreamImpl.
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.terminal.gwt.server;
private final static String UIDL_ARG_ID = "id";
- private Stack mOpenTags;
+ private final Stack mOpenTags;
- private Stack openJsonTags;
+ private final Stack openJsonTags;
private boolean mTagArgumentListOpen;
- private PrintWriter uidlBuffer;
+ private final PrintWriter uidlBuffer;
private boolean closed = false;
- private CommunicationManager manager;
+ private final CommunicationManager manager;
private boolean trackPaints = false;
}
if (openJsonTags.size() > 0) {
- JsonTag parent = (JsonTag) openJsonTags.pop();
+ final JsonTag parent = (JsonTag) openJsonTags.pop();
String lastTag = "";
return new StringBuffer("");
}
- StringBuffer result = new StringBuffer(xml.length() * 2);
+ final StringBuffer result = new StringBuffer(xml.length() * 2);
for (int i = 0; i < xml.length(); i++) {
- char c = xml.charAt(i);
- String s = toXmlChar(c);
+ final char c = xml.charAt(i);
+ final String s = toXmlChar(c);
if (s != null) {
result.append(s);
} else {
if (s == null) {
return "";
}
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
- char ch = s.charAt(i);
+ final char ch = s.charAt(i);
switch (ch) {
case '"':
sb.append("\\\"");
break;
default:
if (ch >= '\u0000' && ch <= '\u001F') {
- String ss = Integer.toHexString(ch);
+ final String ss = Integer.toHexString(ch);
sb.append("\\u");
for (int k = 0; k < 4 - ss.length(); k++) {
sb.append('0');
addAttribute(name, ((ExternalResource) value).getURL());
} else if (value instanceof ApplicationResource) {
- ApplicationResource r = (ApplicationResource) value;
- Application a = r.getApplication();
+ final ApplicationResource r = (ApplicationResource) value;
+ final Application a = r.getApplication();
if (a == null) {
throw new PaintException(
"Application not specified for resorce "
addAttribute(name, uri);
} else if (value instanceof ThemeResource) {
- String uri = "theme://" + ((ThemeResource) value).getResourceId();
+ final String uri = "theme://"
+ + ((ThemeResource) value).getResourceId();
addAttribute(name, uri);
} else {
throw new PaintException("Ajax adapter does not "
throw new NullPointerException(
"Parameters must be non-null strings");
}
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
buf.append("\"" + name + "\":[");
for (int i = 0; i < values.length; i++) {
if (i > 0) {
public boolean startTag(Paintable paintable, String tagName)
throws PaintException {
startTag(tagName, true);
- boolean isPreviouslyPainted = manager.hasPaintableId(paintable);
- String id = manager.getPaintableId(paintable);
+ final boolean isPreviouslyPainted = manager.hasPaintableId(paintable);
+ final String id = manager.getPaintableId(paintable);
paintable.addListener(manager);
addAttribute("id", id);
return cacheEnabled && isPreviouslyPainted;
}
public String getData() {
- StringBuffer buf = new StringBuffer();
- Iterator it = children.iterator();
+ final StringBuffer buf = new StringBuffer();
+ final Iterator it = children.iterator();
while (it.hasNext()) {
buf.append(startField());
buf.append(it.next());
}
private String attributesAsJsonObject() {
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
buf.append(startField());
buf.append("{");
- for (Iterator iter = attr.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
+ for (final Iterator iter = attr.iterator(); iter.hasNext();) {
+ final String element = (String) iter.next();
buf.append(element);
if (iter.hasNext()) {
buf.append(",");
if (variables.size() == 0) {
return "";
}
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
buf.append(startField());
buf.append("\"v\":{");
- Iterator iter = variables.iterator();
+ final Iterator iter = variables.iterator();
while (iter.hasNext()) {
- Variable element = (Variable) iter.next();
+ final Variable element = (Variable) iter.next();
buf.append(element.getJsonPresentation());
if (iter.hasNext()) {
buf.append(",");
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.terminal.gwt.server;
private List listeners;
- private HttpSession session;
+ private final HttpSession session;
- private WeakHashMap formActions = new WeakHashMap();
+ private final WeakHashMap formActions = new WeakHashMap();
- private HashSet applications = new HashSet();
+ private final HashSet applications = new HashSet();
- private WebBrowser browser = new WebBrowser();
+ private final WebBrowser browser = new WebBrowser();
/**
* Creates a new Web Application Context.
* @return the Action to be set into Form action attribute.
*/
public String getWindowFormAction(Window window) {
- String action = (String) formActions.get(window);
+ final String action = (String) formActions.get(window);
return action == null ? "" : action;
}
* @see com.itmill.toolkit.service.ApplicationContext#getBaseDirectory()
*/
public File getBaseDirectory() {
- String realPath = ApplicationServlet.getResourcePath(session
+ final String realPath = ApplicationServlet.getResourcePath(session
.getServletContext(), "/");
if (realPath == null) {
return null;
if (listeners == null) {
return;
}
- for (Iterator i = listeners.iterator(); i.hasNext();) {
+ for (final Iterator i = listeners.iterator(); i.hasNext();) {
((ApplicationContext.TransactionListener) i.next())
.transactionStart(application, request);
}
}
LinkedList exceptions = null;
- for (Iterator i = listeners.iterator(); i.hasNext();) {
+ for (final Iterator i = listeners.iterator(); i.hasNext();) {
try {
((ApplicationContext.TransactionListener) i.next())
.transactionEnd(application, request);
- } catch (RuntimeException t) {
+ } catch (final RuntimeException t) {
if (exceptions == null) {
exceptions = new LinkedList();
}
// If any runtime exceptions occurred, throw a combined exception
if (exceptions != null) {
- StringBuffer msg = new StringBuffer();
- for (Iterator i = listeners.iterator(); i.hasNext();) {
- RuntimeException e = (RuntimeException) i.next();
+ final StringBuffer msg = new StringBuffer();
+ for (final Iterator i = listeners.iterator(); i.hasNext();) {
+ final RuntimeException e = (RuntimeException) i.next();
if (msg.length() == 0) {
msg.append("\n\n--------------------------\n\n");
}
msg.append(e.getMessage() + "\n");
- StringWriter trace = new StringWriter();
+ final StringWriter trace = new StringWriter();
e.printStackTrace(new PrintWriter(trace, true));
msg.append(trace.toString());
}
// closing
while (!applications.isEmpty()) {
- Application app = (Application) applications.iterator().next();
+ final Application app = (Application) applications.iterator()
+ .next();
app.close();
removeApplication(app);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.gwt.server;
import java.util.Locale;
address = request.getRemoteAddr();
secureConnection = request.isSecure();
- String agent = request.getHeader("user-agent");
+ final String agent = request.getHeader("user-agent");
if (agent != null) {
browserApplication = agent;
}
- String sw = request.getParameter("screenWidth");
- String sh = request.getParameter("screenHeight");
+ final String sw = request.getParameter("screenWidth");
+ final String sh = request.getParameter("screenHeight");
if (sw != null && sh != null) {
try {
screenHeight = Integer.parseInt(sh);
screenWidth = Integer.parseInt(sw);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
screenHeight = screenWidth = 0;
}
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.terminal.web;
import javax.servlet.ServletConfig;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.ArrayList;
private static int COMPONENT_MAX_GROUPED_NUMBER = 5;
- private OrderedLayout mainLayout = new OrderedLayout();
+ private final OrderedLayout mainLayout = new OrderedLayout();
private Layout testingLayout;
- private TextField randomSeedValue = new TextField("Seed for random");
+ private final TextField randomSeedValue = new TextField("Seed for random");
- private Button seedShuffle = new Button("Shuffle with seed", this,
+ private final Button seedShuffle = new Button("Shuffle with seed", this,
"seedShuffle");
- private Button randomShuffle = new Button("Seed randomly and shuffle",
- this, "randomShuffle");
+ private final Button randomShuffle = new Button(
+ "Seed randomly and shuffle", this, "randomShuffle");
private Label display = null;
private long eventCounter = 0;
- private Label statusLabel = new Label();
+ private final Label statusLabel = new Label();
// Store button object => real value map
// needed because button captions are randomized
public void init() {
// addWindow(new Window("ATFTest", create()));
- Window mainWindow = new Window("Testing", create());
+ final Window mainWindow = new Window("Testing", create());
setMainWindow(mainWindow);
setUser(new Long(System.currentTimeMillis()).toString());
+ "through X buttons and ensure that Result label "
+ "contains correct value.", Label.CONTENT_XHTML));
- OrderedLayout setupLayout = new OrderedLayout(
+ final OrderedLayout setupLayout = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
- Panel statusPanel = new Panel("Status");
+ final Panel statusPanel = new Panel("Status");
statusPanel.setWidth(200);
setupLayout.addComponent(statusPanel);
statusPanel.addComponent(statusLabel);
// randomize using user given value
rand = new Random(Long.parseLong((String) randomSeedValue
.getValue()));
- } catch (Exception e) {
+ } catch (final Exception e) {
randomize();
}
testingLayout = new GridLayout(5, 5);
}
private void randomize() {
- long newSeed = System.currentTimeMillis();
+ final long newSeed = System.currentTimeMillis();
rand = new Random(newSeed);
randomSeedValue.setValue(String.valueOf(newSeed));
}
components = new ArrayList();
// create label
- Label userLabel = new Label("user");
+ final Label userLabel = new Label("user");
userLabel.setValue(getUser());
// userLabel.setUIID("Label_user");
components.add(userLabel);
components.add(display);
// create calculator buttonsStatus:
- String[][] calcValues = {
+ final String[][] calcValues = {
{ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-",
"*", "/", "=", "C" },
{ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "plus",
"minus", "multiple", "divisor", "equals", "clear" } };
- String[] randomizedCaptions = { "a", "b", "c", "y", "8", "3" };
+ final String[] randomizedCaptions = { "a", "b", "c", "y", "8", "3" };
// String[] randomizedCaptions = { "X" };
buttonValues = new HashMap();
for (int i = 0; i > calcValues[0].length; i++) {
- Button button = new Button("", this);
+ final Button button = new Button("", this);
// Test requirement: ATF must not rely on caption
// button.setCaption(randomizedCaptions[rand
// .nextInt(randomizedCaptions.length)]);
private Component getComponent() {
if (components.size() > 0) {
// components found, return any
- int i = rand.nextInt(components.size());
- Component c = (Component) components.get(i);
+ final int i = rand.nextInt(components.size());
+ final Component c = (Component) components.get(i);
components.remove(i);
return c;
} else {
private void addComponents(Layout layout) {
while (components.size() > 0) {
// Get random container
- ComponentContainer container = getRandomComponentContainer(""
+ final ComponentContainer container = getRandomComponentContainer(""
+ captionCounter++);
layout.addComponent(container);
// Get random amount of components for above container
- int groupsize = rand.nextInt(COMPONENT_MAX_GROUPED_NUMBER) + 1;
+ final int groupsize = rand.nextInt(COMPONENT_MAX_GROUPED_NUMBER) + 1;
for (int j = 0; j < groupsize; j++) {
- Component c = getComponent();
+ final Component c = getComponent();
if (c != null) {
if (container instanceof TabSheet) {
- ComponentContainer tab = (ComponentContainer) ((TabSheet) container)
+ final ComponentContainer tab = (ComponentContainer) ((TabSheet) container)
.getSelectedTab();
tab.addComponent(c);
} else if (container instanceof GridLayout) {
- GridLayout gl = (GridLayout) container;
+ final GridLayout gl = (GridLayout) container;
if (j == 0) {
- int x = rand.nextInt(gl.getWidth());
- int y = rand.nextInt(gl.getHeight());
+ final int x = rand.nextInt(gl.getWidth());
+ final int y = rand.nextInt(gl.getHeight());
gl.removeComponent(x, y);
gl.addComponent(c, x, y);
} else {
}
public void buttonClick(Button.ClickEvent event) {
- String value = (String) buttonValues.get(event.getButton());
+ final String value = (String) buttonValues.get(event.getButton());
eventCounter++;
try {
// Number button pressed
+ ", value " + Double.toString(current));
System.out.println("#" + eventCounter + ": button " + value
+ ", value " + Double.toString(current));
- } catch (java.lang.NumberFormatException e) {
+ } catch (final java.lang.NumberFormatException e) {
// Operation button pressed
if (operation.equals("+")) {
stored += current;
*/
private ComponentContainer getRandomComponentContainer(String caption) {
ComponentContainer result = null;
- int randint = rand.nextInt(5);
+ final int randint = rand.nextInt(5);
switch (randint) {
case 0:
result = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
((Panel) result).setCaption("Panel_" + caption);
break;
case 4:
- TabSheet ts = new TabSheet();
+ final TabSheet ts = new TabSheet();
ts.setCaption("TabSheet_" + caption);
// randomly select one of the tabs
- int selectedTab = rand.nextInt(3);
- ArrayList tabs = new ArrayList();
+ final int selectedTab = rand.nextInt(3);
+ final ArrayList tabs = new ArrayList();
for (int i = 0; i < 3; i++) {
String tabCaption = "tab" + i;
if (selectedTab == i) {
*/
private AbstractComponent getRandomComponent(String caption) {
AbstractComponent result = null;
- int randint = rand.nextInt(7); // calendar disabled
+ final int randint = rand.nextInt(7); // calendar disabled
switch (randint) {
case 0:
// Label
}
private AbstractComponent getExamplePicture(String caption) {
- ClassResource cr = new ClassResource("icon_demo.png", this);
- Embedded em = new Embedded("Embedded " + caption, cr);
+ final ClassResource cr = new ClassResource("icon_demo.png", this);
+ final Embedded em = new Embedded("Embedded " + caption, cr);
return em;
}
*/
public void terminalError(
com.itmill.toolkit.terminal.Terminal.ErrorEvent event) {
- Throwable e = event.getThrowable();
+ final Throwable e = event.getThrowable();
System.err.println(getUser().toString() + " terminalError: "
+ e.toString());
e.printStackTrace();
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.Date;
public class PerformanceTestSubTreeCaching extends CustomComponent {
- private OrderedLayout main;
+ private final OrderedLayout main;
- private OrderedLayout testContainer;
+ private final OrderedLayout testContainer;
private Date startTime;
- private Label result;
+ private final Label result;
private static final String DESCRIPTION = "Hyphothesis: Toolkit 4 has major architechtural problem when adding "
+ "small incrementall updates to a container which has either a lot or "
}
public void endTest() {
- long millis = (new Date()).getTime() - startTime.getTime();
- Float f = new Float(millis / 1000.0);
+ final long millis = (new Date()).getTime() - startTime.getTime();
+ final Float f = new Float(millis / 1000.0);
result.setValue("Test completed in " + f + " seconds");
}
private void populateContainer(OrderedLayout container, int n) {
for (int i = 0; i < n; i++) {
// array_type array_element = [i];
- Table t = TestForTablesInitialColumnWidthLogicRendering
+ final Table t = TestForTablesInitialColumnWidthLogicRendering
.getTestTable(5, 100);
container.addComponent(t);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.Random;
*/
public class RandomLayoutStress extends com.itmill.toolkit.Application {
- private Random seededRandom = new Random(1);
+ private final Random seededRandom = new Random(1);
// FIXME increasing these settings brings out interesting client-side issues
// (DOM errors)
* Initialize Application. Demo components are added to main window.
*/
public void init() {
- Window mainWindow = new Window("Layout demo");
+ final Window mainWindow = new Window("Layout demo");
setMainWindow(mainWindow);
// Create horizontal ordered layout
- Panel panelA = new Panel("Panel containing horizontal ordered layout");
+ final Panel panelA = new Panel(
+ "Panel containing horizontal ordered layout");
OrderedLayout layoutA = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
// Add 4 random components
panelA.addComponent(layoutA);
// Create vertical ordered layout
- Panel panelB = new Panel("Panel containing vertical ordered layout");
+ final Panel panelB = new Panel(
+ "Panel containing vertical ordered layout");
OrderedLayout layoutB = new OrderedLayout(
OrderedLayout.ORIENTATION_VERTICAL);
// Add 4 random components
panelB.addComponent(layoutB);
// Create grid layout
- int gridSize = (int) java.lang.Math.sqrt(componentCountC);
- Panel panelG = new Panel("Panel containing grid layout (" + gridSize
- + " x " + gridSize + ")");
+ final int gridSize = (int) java.lang.Math.sqrt(componentCountC);
+ final Panel panelG = new Panel("Panel containing grid layout ("
+ + gridSize + " x " + gridSize + ")");
GridLayout layoutG = new GridLayout(gridSize, gridSize);
// Add 12 random components
fillLayout(layoutG, componentCountC);
panelG.addComponent(layoutG);
// Create TabSheet
- TabSheet tabsheet = new TabSheet();
+ final TabSheet tabsheet = new TabSheet();
tabsheet
.setCaption("Tabsheet, above layouts are added to this component");
layoutA = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
tabsheet.addTab(layoutG, "Grid layout (4 x 2)", null);
// Create custom layout
- Panel panelC = new Panel("Custom layout with style exampleStyle");
- CustomLayout layoutC = new CustomLayout("exampleStyle");
+ final Panel panelC = new Panel("Custom layout with style exampleStyle");
+ final CustomLayout layoutC = new CustomLayout("exampleStyle");
// Add 4 random components
fillLayout(layoutC, componentCountD);
// Add layout to panel
private AbstractComponent getRandomComponent(int caption) {
AbstractComponent result = null;
- int randint = seededRandom.nextInt(7);
+ final int randint = seededRandom.nextInt(7);
switch (randint) {
case 0:
// Label
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.tests;\r
\r
import com.itmill.toolkit.data.Property.ValueChangeEvent;\r
Table.ValueChangeListener {\r
\r
public TableSelectTest() {\r
- OrderedLayout main = new OrderedLayout();\r
+ final OrderedLayout main = new OrderedLayout();\r
setCompositionRoot(main);\r
main.addComponent(new Label("Hello World!"));\r
\r
try {\r
t.setMultiSelect(true);\r
t.setCaption("multi(SHOLD FAIL BUT DID NOT) nullsel nullselid");\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
System.err.println("failed ok");\r
}\r
t.setNullSelectionAllowed(true);\r
try {\r
t.setMultiSelect(true);\r
t.setCaption("multi(SHOLD FAIL BUT DID NOT) NO-nullsel nullselid");\r
- } catch (Exception e) {\r
+ } catch (final Exception e) {\r
System.err.println("failed ok");\r
}\r
t.setNullSelectionAllowed(false);\r
}\r
\r
public void valueChange(ValueChangeEvent event) {\r
- Object val = event.getProperty().getValue();\r
+ final Object val = event.getProperty().getValue();\r
\r
System.err.println("Value: " + val);\r
\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.io.File;
for (int p = 0; p < testablePackages.length; p++) {
testables.addItem(testablePackages[p]);
try {
- List testableClasses = getTestableClassesForPackage(testablePackages[p]);
- for (Iterator it = testableClasses.iterator(); it.hasNext();) {
- Class t = (Class) it.next();
+ final List testableClasses = getTestableClassesForPackage(testablePackages[p]);
+ for (final Iterator it = testableClasses.iterator(); it
+ .hasNext();) {
+ final Class t = (Class) it.next();
// ignore TestBench itself
if (t.equals(TestBench.class)) {
continue;
itemCaptions.put(t, t.getName());
testables.setParent(t, testablePackages[p]);
continue;
- } catch (Exception e) {
+ } catch (final Exception e) {
try {
testables.addItem(t);
itemCaptions.put(t, t.getName());
testables.setParent(t, testablePackages[p]);
continue;
- } catch (Exception e1) {
+ } catch (final Exception e1) {
e1.printStackTrace();
}
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
}
menu = new Tree("Testables", testables);
- for (Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
- Class testable = (Class) i.next();
+ for (final Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
+ final Class testable = (Class) i.next();
// simplify captions
- String name = testable.getName().substring(
+ final String name = testable.getName().substring(
testable.getName().lastIndexOf('.') + 1);
menu.setItemCaption(testable, name);
}
// expand all root items
- for (Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
+ for (final Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
menu.expandItemsRecursively(i.next());
}
private Component createTestable(Class c) {
try {
- Application app = (Application) c.newInstance();
+ final Application app = (Application) c.newInstance();
app.init();
return app.getMainWindow().getLayout();
- } catch (Exception e) {
+ } catch (final Exception e) {
try {
- CustomComponent cc = (CustomComponent) c.newInstance();
+ final CustomComponent cc = (CustomComponent) c.newInstance();
return cc;
- } catch (Exception e1) {
+ } catch (final Exception e1) {
e1.printStackTrace();
return new Label(
"Cannot create application / custom component: "
bodyLayout.removeAllComponents();
bodyLayout.setCaption(null);
- Object o = menu.getValue();
+ final Object o = menu.getValue();
if (o != null && o instanceof Class) {
- Class c = (Class) o;
- String title = c.getName();
+ final Class c = (Class) o;
+ final String title = c.getName();
bodyLayout.setCaption(title);
bodyLayout.addComponent(createTestable(c));
} else {
*/
public static List getTestableClassesForPackage(String packageName)
throws Exception {
- ArrayList directories = new ArrayList();
+ final ArrayList directories = new ArrayList();
try {
- ClassLoader cld = Thread.currentThread().getContextClassLoader();
+ final ClassLoader cld = Thread.currentThread()
+ .getContextClassLoader();
if (cld == null) {
throw new ClassNotFoundException("Can't get class loader.");
}
- String path = packageName.replace('.', '/');
+ final String path = packageName.replace('.', '/');
// Ask for all resources for the path
- Enumeration resources = cld.getResources(path);
+ final Enumeration resources = cld.getResources(path);
while (resources.hasMoreElements()) {
- URL url = (URL) resources.nextElement();
+ final URL url = (URL) resources.nextElement();
directories.add(new File(url.getFile()));
}
- } catch (Exception x) {
+ } catch (final Exception x) {
throw new Exception(packageName
+ " does not appear to be a valid package.");
}
- ArrayList classes = new ArrayList();
+ final ArrayList classes = new ArrayList();
// For every directory identified capture all the .class files
- for (Iterator it = directories.iterator(); it.hasNext();) {
- File directory = (File) it.next();
+ for (final Iterator it = directories.iterator(); it.hasNext();) {
+ final File directory = (File) it.next();
if (directory.exists()) {
// Get the list of the files contained in the package
- String[] files = directory.list();
+ final String[] files = directory.list();
for (int j = 0; j < files.length; j++) {
// we are only interested in .class files
if (files[j].endsWith(".class")) {
// removes the .class extension
- String p = packageName + '.'
+ final String p = packageName + '.'
+ files[j].substring(0, files[j].length() - 6);
- Class c = Class.forName(p);
+ final Class c = Class.forName(p);
if (c.getSuperclass() != null) {
if ((c.getSuperclass()
.equals(com.itmill.toolkit.Application.class))) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.terminal.ClassResource;
test(main);
populateLayout(main);
- Panel panel = new Panel("Panel");
+ final Panel panel = new Panel("Panel");
test(panel);
populateLayout(panel.getLayout());
- TabSheet tabsheet = new TabSheet();
+ final TabSheet tabsheet = new TabSheet();
test(tabsheet);
- OrderedLayout tab1 = new OrderedLayout();
+ final OrderedLayout tab1 = new OrderedLayout();
tab1.addComponent(new Label("try tab2"));
- OrderedLayout tab2 = new OrderedLayout();
+ final OrderedLayout tab2 = new OrderedLayout();
test(tab2);
populateLayout(tab2);
tabsheet.addTab(tab1, "TabSheet tab1", new ClassResource("m.gif",
tabsheet.addTab(tab2, "TabSheet tab2", new ClassResource("m.gif",
getApplication()));
- ExpandLayout expandLayout = new ExpandLayout();
+ final ExpandLayout expandLayout = new ExpandLayout();
test(expandLayout);
populateLayout(expandLayout);
- GridLayout gridLayout = new GridLayout();
+ final GridLayout gridLayout = new GridLayout();
test(gridLayout);
populateLayout(gridLayout);
- Window window = new Window("TEST: Window");
+ final Window window = new Window("TEST: Window");
test(window);
populateLayout(window.getLayout());
void populateLayout(Layout layout) {
- Button button = new Button("Button " + count++);
+ final Button button = new Button("Button " + count++);
test(layout, button);
button.addListener(this);
- DateField df = new DateField("DateField " + count++);
+ final DateField df = new DateField("DateField " + count++);
test(layout, df);
- CheckBox cb = new CheckBox("Checkbox " + count++);
+ final CheckBox cb = new CheckBox("Checkbox " + count++);
test(layout, cb);
- Embedded emb = new Embedded("Embedded " + count++);
+ final Embedded emb = new Embedded("Embedded " + count++);
test(layout, emb);
- Panel panel = new Panel("Panel " + count++);
+ final Panel panel = new Panel("Panel " + count++);
test(layout, panel);
- Label label = new Label("Label " + count++);
+ final Label label = new Label("Label " + count++);
test(layout, label);
- Link link = new Link("Link " + count++, new ExternalResource(
+ final Link link = new Link("Link " + count++, new ExternalResource(
"www.itmill.com"));
test(layout, link);
- NativeSelect nativeSelect = new NativeSelect("NativeSelect " + count++);
+ final NativeSelect nativeSelect = new NativeSelect("NativeSelect "
+ + count++);
test(layout, nativeSelect);
- OptionGroup optionGroup = new OptionGroup("OptionGroup " + count++);
+ final OptionGroup optionGroup = new OptionGroup("OptionGroup "
+ + count++);
test(layout, optionGroup);
- ProgressIndicator pi = new ProgressIndicator();
+ final ProgressIndicator pi = new ProgressIndicator();
test(layout, pi);
- RichTextArea rta = new RichTextArea();
+ final RichTextArea rta = new RichTextArea();
test(layout, rta);
- Select select = new Select("Select " + count++);
+ final Select select = new Select("Select " + count++);
test(layout, select);
- Slider slider = new Slider("Slider " + count++);
+ final Slider slider = new Slider("Slider " + count++);
test(layout, slider);
- Table table = new Table("Table " + count++);
+ final Table table = new Table("Table " + count++);
test(layout, table);
- TextField tf = new TextField("Textfield " + count++);
+ final TextField tf = new TextField("Textfield " + count++);
test(layout, tf);
- Tree tree = new Tree("Tree " + count++);
+ final Tree tree = new Tree("Tree " + count++);
test(layout, tree);
- TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect "
+ final TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect "
+ count++);
test(layout, twinColSelect);
- Upload upload = new Upload("Upload (non-functional)", null);
+ final Upload upload = new Upload("Upload (non-functional)", null);
test(layout, upload);
// Custom components
layout.addComponent(new Label("<B>Below are few custom components</B>",
Label.CONTENT_XHTML));
- TestForUpload tfu = new TestForUpload();
+ final TestForUpload tfu = new TestForUpload();
layout.addComponent(tfu);
}
* @param c
*/
void test(AbstractComponent c) {
- ClassResource res = new ClassResource("m.gif", getApplication());
- ErrorMessage errorMsg = new UserError("User error " + c);
+ final ClassResource res = new ClassResource("m.gif", getApplication());
+ final ErrorMessage errorMsg = new UserError("User error " + c);
if ((c.getCaption() == null) || (c.getCaption().length() <= 0)) {
c.setCaption("Caption " + c);
}
public void componentEvent(Event event) {
- String feedback = eventListenerString + " source=" + event.getSource()
- + ", toString()=" + event.toString();
+ final String feedback = eventListenerString + " source="
+ + event.getSource() + ", toString()=" + event.toString();
System.out.println("eventListenerFeedback: " + feedback);
eventListenerFeedback.setValue(feedback);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.io.File;
}
public void createNewView() {
- Window main = new Window("Main window");
+ final Window main = new Window("Main window");
setMainWindow(main);
// By default push all containers inside main window
.addComponent(new Label(
"<hr /><h1>Components inside horizontal OrderedLayout</h3>",
Label.CONTENT_XHTML));
- OrderedLayout ol = new OrderedLayout(
+ final OrderedLayout ol = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
populateLayout(ol);
target.addComponent(ol);
.addComponent(new Label(
"<br/><br/><br/><hr /><h1>Components inside vertical OrderedLayout</h3>",
Label.CONTENT_XHTML));
- OrderedLayout ol2 = new OrderedLayout(
+ final OrderedLayout ol2 = new OrderedLayout(
OrderedLayout.ORIENTATION_VERTICAL);
populateLayout(ol2);
target.addComponent(ol2);
.addComponent(new Label(
"<hr /><h1>Components inside ExpandLayout (height 250px)</h3>",
Label.CONTENT_XHTML));
- ExpandLayout el = new ExpandLayout();
+ final ExpandLayout el = new ExpandLayout();
el.setHeight(250);
el.setHeightUnits(Sizeable.UNITS_PIXELS);
populateLayout(el);
target.addComponent(new Label(
"<hr /><h1>Components inside Panel</h3>",
Label.CONTENT_XHTML));
- Panel panel = new Panel("Panel");
+ final Panel panel = new Panel("Panel");
populateLayout(panel.getLayout());
target.addComponent(panel);
}
.addComponent(new Label(
"<hr /><h1>Components inside vertical SplitPanel (splitpanel is under 250height ExpandLayout)</h3>",
Label.CONTENT_XHTML));
- ExpandLayout sp1l = new ExpandLayout();
+ final ExpandLayout sp1l = new ExpandLayout();
sp1l.setHeight(250);
sp1l.setHeightUnits(Sizeable.UNITS_PIXELS);
- SplitPanel sp1 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);
+ final SplitPanel sp1 = new SplitPanel(
+ SplitPanel.ORIENTATION_VERTICAL);
sp1l.addComponent(sp1);
- OrderedLayout sp1first = new OrderedLayout();
- OrderedLayout sp1second = new OrderedLayout();
+ final OrderedLayout sp1first = new OrderedLayout();
+ final OrderedLayout sp1second = new OrderedLayout();
sp1.setFirstComponent(sp1first);
populateLayout(sp1first);
populateLayout(sp1second);
.addComponent(new Label(
"<hr /><h1>Components inside horizontal SplitPanel (splitpanel is under 250px height ExpandLayout)</h3>",
Label.CONTENT_XHTML));
- ExpandLayout sp2l = new ExpandLayout();
+ final ExpandLayout sp2l = new ExpandLayout();
sp2l.setHeight(250);
sp2l.setHeightUnits(Sizeable.UNITS_PIXELS);
- SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
+ final SplitPanel sp2 = new SplitPanel(
+ SplitPanel.ORIENTATION_HORIZONTAL);
sp2l.addComponent(sp2);
- OrderedLayout sp2first = new OrderedLayout();
- OrderedLayout sp2second = new OrderedLayout();
+ final OrderedLayout sp2first = new OrderedLayout();
+ final OrderedLayout sp2second = new OrderedLayout();
sp2.setFirstComponent(sp2first);
populateLayout(sp2first);
populateLayout(sp2second);
target.addComponent(new Label(
"<hr /><h1>Components inside TabSheet</h3>",
Label.CONTENT_XHTML));
- TabSheet tabsheet = new TabSheet();
- OrderedLayout tab1 = new OrderedLayout();
+ final TabSheet tabsheet = new TabSheet();
+ final OrderedLayout tab1 = new OrderedLayout();
tab1.addComponent(new Label("try tab2"));
- OrderedLayout tab2 = new OrderedLayout();
+ final OrderedLayout tab2 = new OrderedLayout();
populateLayout(tab2);
tabsheet.addTab(tab1, "TabSheet tab1", new ClassResource("m.gif",
this));
target.addComponent(new Label(
"<hr /><h1>Components inside GridLayout</h3>",
Label.CONTENT_XHTML));
- GridLayout gridLayout = new GridLayout(4, 100);
+ final GridLayout gridLayout = new GridLayout(4, 100);
populateLayout(gridLayout);
target.addComponent(gridLayout);
// test(gridLayout);
}
void populateLayout(Layout layout) {
- Button button = new Button("Button " + count++);
+ final Button button = new Button("Button " + count++);
test(layout, button);
- DateField df = new DateField("DateField " + count++);
+ final DateField df = new DateField("DateField " + count++);
test(layout, df);
- CheckBox cb = new CheckBox("Checkbox " + count++);
+ final CheckBox cb = new CheckBox("Checkbox " + count++);
test(layout, cb);
- ClassResource flashResource = new ClassResource("itmill_spin.swf", this);
- Embedded emb = new Embedded("Embedded " + count++, flashResource);
+ final ClassResource flashResource = new ClassResource(
+ "itmill_spin.swf", this);
+ final Embedded emb = new Embedded("Embedded " + count++, flashResource);
emb.setType(Embedded.TYPE_OBJECT);
emb.setMimeType("application/x-shockwave-flash");
emb.setWidth(250);
emb.setHeight(100);
test(layout, emb);
- Panel panel = new Panel("Panel " + count++);
+ final Panel panel = new Panel("Panel " + count++);
test(layout, panel);
- Label label = new Label("Label " + count++);
+ final Label label = new Label("Label " + count++);
test(layout, label);
- Link link = new Link("Link " + count++, new ExternalResource(
+ final Link link = new Link("Link " + count++, new ExternalResource(
"www.itmill.com"));
test(layout, link);
- NativeSelect nativeSelect = new NativeSelect("NativeSelect " + count++);
+ final NativeSelect nativeSelect = new NativeSelect("NativeSelect "
+ + count++);
nativeSelect.setContainerDataSource(getContainer());
test(layout, nativeSelect);
- OptionGroup optionGroup = new OptionGroup("OptionGroup " + count++);
+ final OptionGroup optionGroup = new OptionGroup("OptionGroup "
+ + count++);
optionGroup.setContainerDataSource(getSmallContainer());
optionGroup.setItemCaptionPropertyId("UNIT");
test(layout, optionGroup);
- ProgressIndicator pi = new ProgressIndicator();
+ final ProgressIndicator pi = new ProgressIndicator();
pi.setCaption("ProgressIndicator");
test(layout, pi);
- RichTextArea rta = new RichTextArea();
+ final RichTextArea rta = new RichTextArea();
test(layout, rta);
- Select select = new Select("Select " + count++);
+ final Select select = new Select("Select " + count++);
select.setContainerDataSource(getSmallContainer());
select.setItemCaptionPropertyId("UNIT");
test(layout, select);
- Slider slider = new Slider("Slider " + count++);
+ final Slider slider = new Slider("Slider " + count++);
test(layout, slider);
- Table table = new Table("Table " + count++);
+ final Table table = new Table("Table " + count++);
table.setPageLength(10);
table.setSelectable(true);
table.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX);
table.setItemCaptionPropertyId("ID");
test(layout, table);
- TabSheet tabsheet = new TabSheet();
- OrderedLayout tab1 = new OrderedLayout();
+ final TabSheet tabsheet = new TabSheet();
+ final OrderedLayout tab1 = new OrderedLayout();
tab1.addComponent(new Label("tab1 " + count++));
- OrderedLayout tab2 = new OrderedLayout();
+ final OrderedLayout tab2 = new OrderedLayout();
tab2.addComponent(new Label("tab2 " + count++));
tabsheet.addTab(tab1, "Default (not configured) TabSheet tab1",
new ClassResource("m.gif", this));
"m.gif", this));
test(layout, tabsheet);
- TextField tf = new TextField("Textfield " + count++);
+ final TextField tf = new TextField("Textfield " + count++);
test(layout, tf);
// do not configure tab1
// test(tab1);
test(tab2);
- Tree tree = new Tree("Tree " + count++);
- File sampleDir = SampleDirectory.getDirectory(this);
- FilesystemContainer fsc = new FilesystemContainer(sampleDir, true);
+ final Tree tree = new Tree("Tree " + count++);
+ final File sampleDir = SampleDirectory.getDirectory(this);
+ final FilesystemContainer fsc = new FilesystemContainer(sampleDir, true);
tree.setContainerDataSource(fsc);
test(layout, tree);
- TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect "
+ final TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect "
+ count++);
twinColSelect.setContainerDataSource(getSmallContainer());
twinColSelect.setItemCaptionPropertyId("UNIT");
test(layout, twinColSelect);
- Upload upload = new Upload("Upload (non-functional)", null);
+ final Upload upload = new Upload("Upload (non-functional)", null);
test(layout, upload);
// Custom components
layout.addComponent(new Label("<B>Below are few custom components</B>",
Label.CONTENT_XHTML));
- TestForUpload tfu = new TestForUpload();
+ final TestForUpload tfu = new TestForUpload();
layout.addComponent(tfu);
layout.addComponent(new Label("<br/><b>----------<br/></p>",
Label.CONTENT_XHTML));
try {
return new QueryContainer("SELECT * FROM employee", sampleDatabase
.getConnection());
- } catch (SQLException e) {
+ } catch (final SQLException e) {
e.printStackTrace();
}
return null;
return new QueryContainer(
"SELECT DISTINCT UNIT AS UNIT FROM employee",
sampleDatabase.getConnection());
- } catch (SQLException e) {
+ } catch (final SQLException e) {
e.printStackTrace();
}
return null;
// try to add listener
try {
c.addListener(this);
- } catch (Exception e) {
+ } catch (final Exception e) {
System.err.println("Could not add listener for component " + c
+ ", count was " + count);
}
setComponentProperties(c);
// AbstractComponent specific configuration
- ClassResource res = new ClassResource("m.gif", this);
- ErrorMessage errorMsg = new UserError("User error " + c);
+ final ClassResource res = new ClassResource("m.gif", this);
+ final ErrorMessage errorMsg = new UserError("User error " + c);
if ((c.getCaption() == null) || (c.getCaption().length() <= 0)) {
c.setCaption("Caption " + c);
}
public void componentEvent(Event event) {
eventCount++;
- String feedback = "eventCount=" + eventCount + ", class="
+ final String feedback = "eventCount=" + eventCount + ", class="
+ event.getClass() + ", source=" + event.getSource()
+ ", toString()=" + event.toString();
System.out.println("eventListenerFeedback: " + feedback);
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.tests;\r
\r
import java.util.Locale;\r
df = new DateField();\r
main.addComponent(df);\r
\r
- ErrorMessage errorMsg = new UserError("User error " + df);\r
+ final ErrorMessage errorMsg = new UserError("User error " + df);\r
df.setCaption("DateField caption " + df);\r
df.setDescription("DateField description " + df);\r
df.setComponentError(errorMsg);\r
df.addStyleName("thisShouldBeHarmless");\r
\r
// Another test: locale\r
- DateField df1 = new DateField();\r
+ final DateField df1 = new DateField();\r
main.addComponent(df1);\r
df1.setLocale(new Locale("en", "US"));\r
\r
- DateField df2 = new DateField();\r
+ final DateField df2 = new DateField();\r
main.addComponent(df2);\r
df2.setLocale(new Locale("de", "DE"));\r
\r
- DateField df3 = new DateField();\r
+ final DateField df3 = new DateField();\r
main.addComponent(df3);\r
df3.setLocale(new Locale("ru", "RU"));\r
}\r
\r
public void attach() {\r
- ClassResource res = new ClassResource("m.gif", super.getApplication());\r
+ final ClassResource res = new ClassResource("m.gif", super\r
+ .getApplication());\r
df.setIcon(res);\r
super.attach();\r
}\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.ui.Button;
public TestForAlignments() {
- OrderedLayout main = new OrderedLayout();
+ final OrderedLayout main = new OrderedLayout();
- Button b1 = new Button("Right");
- Button b2 = new Button("Left");
- Button b3 = new Button("Bottom");
- Button b4 = new Button("Top");
- TextField t1 = new TextField("Right aligned");
- TextField t2 = new TextField("Bottom aligned");
- DateField d1 = new DateField("Center aligned");
- DateField d2 = new DateField("Center aligned");
+ final Button b1 = new Button("Right");
+ final Button b2 = new Button("Left");
+ final Button b3 = new Button("Bottom");
+ final Button b4 = new Button("Top");
+ final TextField t1 = new TextField("Right aligned");
+ final TextField t2 = new TextField("Bottom aligned");
+ final DateField d1 = new DateField("Center aligned");
+ final DateField d2 = new DateField("Center aligned");
- OrderedLayout vert = new OrderedLayout();
+ final OrderedLayout vert = new OrderedLayout();
vert.addComponent(b1);
vert.addComponent(b2);
vert.addComponent(t1);
vert.setComponentAlignment(d1,
OrderedLayout.ALIGNMENT_HORIZONTAL_CENTER,
OrderedLayout.ALIGNMENT_TOP);
- OrderedLayout hori = new OrderedLayout(
+ final OrderedLayout hori = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
hori.addComponent(b3);
hori.addComponent(b4);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.Application;
firstLevelSplit = new SplitPanel();
- SplitPanel secondSplitPanel = new SplitPanel(
+ final SplitPanel secondSplitPanel = new SplitPanel(
SplitPanel.ORIENTATION_HORIZONTAL);
secondSplitPanel.setFirstComponent(new Label("left"));
- ExpandLayout topRight = new ExpandLayout();
+ final ExpandLayout topRight = new ExpandLayout();
topRight.addComponent(new Label("topright header"));
- Table t = TestForTablesInitialColumnWidthLogicRendering.getTestTable(4,
- 100);
+ final Table t = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(4, 100);
t.setWidth(100);
t.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
t.setHeight(100);
secondSplitPanel.setSecondComponent(topRight);
- ExpandLayout el = new ExpandLayout();
+ final ExpandLayout el = new ExpandLayout();
el.addComponent(new Label("B��"));
firstLevelSplit.setFirstComponent(secondSplitPanel);
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.tests;\r
\r
import java.util.Locale;\r
\r
public class TestForBasicApplicationLayout extends CustomComponent {\r
\r
- private Button click;\r
- private Button click2;\r
- private TabSheet tab;\r
+ private final Button click;\r
+ private final Button click2;\r
+ private final TabSheet tab;\r
\r
public TestForBasicApplicationLayout() {\r
\r
\r
});\r
\r
- SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
+ final SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
sp.setSplitPosition(290, Sizeable.UNITS_PIXELS);\r
\r
- SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
+ final SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS);\r
\r
- Panel p = new Panel("Accordion Panel");\r
+ final Panel p = new Panel("Accordion Panel");\r
p.setSizeFull();\r
\r
tab = new TabSheet();\r
tab.setSizeFull();\r
\r
- Panel report = new Panel("Monthly Program Runs", new ExpandLayout());\r
- OrderedLayout controls = new OrderedLayout();\r
+ final Panel report = new Panel("Monthly Program Runs",\r
+ new ExpandLayout());\r
+ final OrderedLayout controls = new OrderedLayout();\r
controls.setMargin(true);\r
controls.addComponent(new Label("Report tab"));\r
controls.addComponent(click);\r
controls.addComponent(click2);\r
report.addComponent(controls);\r
- DateField cal = new DateField();\r
+ final DateField cal = new DateField();\r
cal.setResolution(DateField.RESOLUTION_DAY);\r
cal.setLocale(new Locale("en", "US"));\r
report.addComponent(cal);\r
\r
sp2.setFirstComponent(report);\r
\r
- Table table = TestForTablesInitialColumnWidthLogicRendering\r
+ final Table table = TestForTablesInitialColumnWidthLogicRendering\r
.getTestTable(5, 200);\r
table.setPageLength(15);\r
table.setSelectable(true);\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.ArrayList;
*/
public class TestForChildComponentRendering extends CustomComponent {
- private OrderedLayout main;
+ private final OrderedLayout main;
public TestForChildComponentRendering() {
main.removeAllComponents();
main.addComponent(new Label("SDFGFHFHGJGFDSDSSSGFDD"));
- Link l = new Link();
+ final Link l = new Link();
l.setCaption("Siirry ITMILLIIN");
l.setResource(new ExternalResource("http://www.itmill.com/"));
l.setTargetHeight(200);
l.setTargetBorder(Link.TARGET_BORDER_MINIMAL);
main.addComponent(l);
- Select se = new Select();
+ final Select se = new Select();
se.setCaption("VALITSET TÄSTÄ");
se.addItem("valinta1");
se.addItem("Valinta 2");
}
public void randomReorder() {
- Iterator it = main.getComponentIterator();
- ArrayList components = new ArrayList();
+ final Iterator it = main.getComponentIterator();
+ final ArrayList components = new ArrayList();
while (it.hasNext()) {
components.add(it.next());
}
- OrderedLayout v = main;
+ final OrderedLayout v = main;
v.removeAllComponents();
for (int i = components.size(); i > 0; i--) {
- int index = (int) (Math.random() * i);
+ final int index = (int) (Math.random() * i);
v.addComponent((Component) components.get(index));
components.remove(index);
}
}
public void removeRandomComponent() {
- Iterator it = main.getComponentIterator();
- ArrayList components = new ArrayList();
+ final Iterator it = main.getComponentIterator();
+ final ArrayList components = new ArrayList();
while (it.hasNext()) {
components.add(it.next());
}
- int size = components.size();
- int index = (int) (Math.random() * size);
+ final int size = components.size();
+ final int index = (int) (Math.random() * size);
main.removeComponent((Component) components.get(index));
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.data.util.IndexedContainer;
ic.addContainerProperty("foo", String.class, "");
ic.addContainerProperty("bar", String.class, "");
for (int i = 0; i < 1000; i++) {
- Object id = ic.addItem();
+ final Object id = ic.addItem();
ic.getContainerProperty(id, "foo").setValue(randomWord());
ic.getContainerProperty(id, "bar").setValue(randomWord());
}
// Init filtering view
- Panel filterPanel = new Panel("Filter", new OrderedLayout(
+ final Panel filterPanel = new Panel("Filter", new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL));
filterPanel.setWidth(100);
filterPanel.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
private String randomWord() {
int len = (int) (Math.random() * 4);
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
while (len-- >= 0) {
buf.append(parts[(int) (Math.random() * parts.length)]);
}
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.tests;\r
\r
+import com.itmill.toolkit.terminal.Sizeable;\r
import com.itmill.toolkit.ui.CustomComponent;\r
import com.itmill.toolkit.ui.DateField;\r
import com.itmill.toolkit.ui.ExpandLayout;\r
import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.OrderedLayout;\r
\r
/**\r
* \r
public void createNewView() {\r
main.removeAllComponents();\r
for (int i = 0; i < 10; i++) {\r
- ExpandLayout el = new ExpandLayout(\r
- ExpandLayout.ORIENTATION_HORIZONTAL);\r
+ final ExpandLayout el = new ExpandLayout(\r
+ OrderedLayout.ORIENTATION_HORIZONTAL);\r
for (int j = 0; j < 10; j++) {\r
- Label l = new Label("label" + i + ":" + j);\r
+ final Label l = new Label("label" + i + ":" + j);\r
el.addComponent(l);\r
}\r
if (i > 0) {\r
el.setHeight(1);\r
- el.setHeightUnits(ExpandLayout.UNITS_EM);\r
+ el.setHeightUnits(Sizeable.UNITS_EM);\r
}\r
main.addComponent(el);\r
}\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.ArrayList;
*/
public class TestForGridLayoutChildComponentRendering extends CustomComponent {
- private GridLayout main = new GridLayout(2, 3);
+ private final GridLayout main = new GridLayout(2, 3);
public TestForGridLayoutChildComponentRendering() {
main.removeAllComponents();
main.addComponent(new Label("SDFGFHFHGJGFDSDSSSGFDD"));
- Link l = new Link();
+ final Link l = new Link();
l.setCaption("Siirry ITMILLIIN");
l.setResource(new ExternalResource("http://www.itmill.com/"));
l.setTargetHeight(200);
l.setTargetBorder(Link.TARGET_BORDER_MINIMAL);
main.addComponent(l);
- Select se = new Select("Tästä valitaan");
+ final Select se = new Select("Tästä valitaan");
se.setCaption("Whattaa select");
se.addItem("valinta1");
se.addItem("Valinta 2");
}
public void randomReorder() {
- Iterator it = main.getComponentIterator();
- ArrayList components = new ArrayList();
+ final Iterator it = main.getComponentIterator();
+ final ArrayList components = new ArrayList();
while (it.hasNext()) {
components.add(it.next());
}
main.removeAllComponents();
- int size = components.size();
- int colspanIndex = ((int) (Math.random() * size) / 2) * 2 + 2;
+ final int size = components.size();
+ final int colspanIndex = ((int) (Math.random() * size) / 2) * 2 + 2;
for (int i = components.size(); i > 0; i--) {
- int index = (int) (Math.random() * i);
+ final int index = (int) (Math.random() * i);
if (i == colspanIndex) {
main.addComponent((Component) components.get(index), 0,
(size - i) / 2, 1, (size - i) / 2);
}
public void removeRandomComponent() {
- Iterator it = main.getComponentIterator();
- ArrayList components = new ArrayList();
+ final Iterator it = main.getComponentIterator();
+ final ArrayList components = new ArrayList();
while (it.hasNext()) {
components.add(it.next());
}
- int size = components.size();
- int index = (int) (Math.random() * size);
+ final int size = components.size();
+ final int index = (int) (Math.random() * size);
main.removeComponent((Component) components.get(index));
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.ArrayList;
public void valueChange(ValueChangeEvent event) {
- String currentStyle = l.getStyle();
- String[] tmp = currentStyle.split(" ");
- ArrayList curStyles = new ArrayList();
+ final String currentStyle = l.getStyle();
+ final String[] tmp = currentStyle.split(" ");
+ final ArrayList curStyles = new ArrayList();
for (int i = 0; i < tmp.length; i++) {
if (tmp[i] != "") {
curStyles.add(tmp[i]);
}
}
- Collection styles = (Collection) s.getValue();
+ final Collection styles = (Collection) s.getValue();
- for (Iterator iterator = styles.iterator(); iterator.hasNext();) {
- String styleName = (String) iterator.next();
+ for (final Iterator iterator = styles.iterator(); iterator.hasNext();) {
+ final String styleName = (String) iterator.next();
if (curStyles.contains(styleName)) {
// already added
curStyles.remove(styleName);
l.addStyleName(styleName);
}
}
- for (Iterator iterator2 = curStyles.iterator(); iterator2.hasNext();) {
- String object = (String) iterator2.next();
+ for (final Iterator iterator2 = curStyles.iterator(); iterator2
+ .hasNext();) {
+ final String object = (String) iterator2.next();
l.removeStyleName(object);
}
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.net.MalformedURLException;
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);
.currentTimeMillis()
+ "/")),
null);
- } catch (MalformedURLException e) {
+ } catch (final MalformedURLException e) {
}
}
}));
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(
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.event.Action;
.setCaption("OptionGroup + multiselect manually (configured from select)");
main.addComponent(test);
- Button b = new Button("refresh view", this, "createNewView");
+ final Button b = new Button("refresh view", this, "createNewView");
main.addComponent(b);
}
public static void fillSelect(AbstractSelect s, int items) {
for (int i = 0; i < items; i++) {
- String name = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ final String name = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ " "
+ lastnames[(int) (Math.random() * (lastnames.length - 1))];
s.addItem(name);
public Tree createTestTree() {
Tree t = new Tree("Tree");
- String[] names = new String[100];
+ final String[] names = new String[100];
for (int i = 0; i < names.length; i++) {
names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ " "
t = new Tree("Organization Structure");
for (int i = 0; i < 100; i++) {
t.addItem(names[i]);
- String parent = names[(int) (Math.random() * (names.length - 1))];
+ final String parent = names[(int) (Math.random() * (names.length - 1))];
if (t.containsId(parent)) {
t.setParent(names[i], parent);
}
}
public Panel createTestBench(Component t) {
- Panel ol = new Panel();
+ final Panel ol = new Panel();
ol.setLayout(new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));
ol.addComponent(t);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
public class TestForRichTextEditor extends CustomComponent implements
ValueChangeListener {
- private OrderedLayout main = new OrderedLayout();
+ private final OrderedLayout main = new OrderedLayout();
private Label l;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.Vector;
public class TestForTablesInitialColumnWidthLogicRendering extends
CustomComponent {
- private OrderedLayout main = new OrderedLayout();
+ private final OrderedLayout main = new OrderedLayout();
public TestForTablesInitialColumnWidthLogicRendering() {
t.setWidth(200);
main.addComponent(t);
- Button b = new Button("refresh view", this, "createNewView");
+ final Button b = new Button("refresh view", this, "createNewView");
main.addComponent(b);
}
public static Table getTestTable(int cols, int rows) {
- Table t = new Table();
+ final Table t = new Table();
t.setColumnCollapsingAllowed(true);
for (int i = 0; i < cols; i++) {
t.addContainerProperty(testString[i], String.class, "");
}
for (int i = 0; i < rows; i++) {
- Vector content = new Vector();
+ final Vector content = new Vector();
for (int j = 0; j < cols; j++) {
content.add(rndString());
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.event.Action;
"Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding",
"Einstein" };
- private OrderedLayout main = new OrderedLayout();
+ private final OrderedLayout main = new OrderedLayout();
- private Action[] actions = new Action[] { new Action("edit"),
+ private final Action[] actions = new Action[] { new Action("edit"),
new Action("delete") };
private Panel al;
t.setCaption("with actions");
t.setImmediate(true);
t.addActionHandler(this);
- OrderedLayout ol = (OrderedLayout) createTestBench(t);
+ final OrderedLayout ol = (OrderedLayout) createTestBench(t);
al = new Panel("action log");
ol.addComponent(al);
main.addComponent(ol);
contextTree = t;
- Button b = new Button("refresh view", this, "createNewView");
+ final Button b = new Button("refresh view", this, "createNewView");
main.addComponent(b);
}
public Tree createTestTree() {
Tree t = new Tree("Tree");
- String[] names = new String[100];
+ final String[] names = new String[100];
for (int i = 0; i < names.length; i++) {
names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ " "
t = new Tree("Organization Structure");
for (int i = 0; i < 100; i++) {
t.addItem(names[i]);
- String parent = names[(int) (Math.random() * (names.length - 1))];
+ final String parent = names[(int) (Math.random() * (names.length - 1))];
if (t.containsId(parent)) {
t.setParent(names[i], parent);
}
}
public Component createTestBench(Tree t) {
- OrderedLayout ol = new OrderedLayout();
+ final OrderedLayout ol = new OrderedLayout();
ol.setOrientation(OrderedLayout.ORIENTATION_HORIZONTAL);
ol.addComponent(t);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.io.ByteArrayInputStream;
up.setProgressListener(this);
- Button b = new Button("b", this, "readState");
+ final Button b = new Button("b", this, "readState");
- Button c = new Button("b with gc", this, "gc");
+ final Button c = new Button("b with gc", this, "gc");
main.addComponent(b);
main.addComponent(c);
status.setVisible(false);
main.addComponent(status);
- Button restart = new Button("R");
+ final Button restart = new Button("R");
restart.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
}
private void setBuffer() {
- String id = (String) uploadBufferSelector.getValue();
+ final String id = (String) uploadBufferSelector.getValue();
if ("memory".equals(id)) {
buffer = new MemoryBuffer();
} else if ("tempfile".equals(id)) {
}
public void readState() {
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
if (up.isUploading()) {
sb.append("Uploading...");
public void uploadFinished(FinishedEvent event) {
status.removeAllComponents();
- InputStream stream = buffer.getStream();
+ final InputStream stream = buffer.getStream();
if (stream == null) {
status.addComponent(new Label(
"Upload finished, but output buffer is null!!"));
private FileInputStream stream;
public TmpFileBuffer() {
- String tempFileName = "upload_tmpfile_"
+ final String tempFileName = "upload_tmpfile_"
+ System.currentTimeMillis();
try {
file = File.createTempFile(tempFileName, null);
- } catch (IOException e) {
+ } catch (final IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
return new FileInputStream(file);
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mimeType = MIMEType;
try {
return new FileOutputStream(file);
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.terminal.ExternalResource;
public TestForWindowOpen() {
- OrderedLayout main = new OrderedLayout();
+ final OrderedLayout main = new OrderedLayout();
setCompositionRoot(main);
main.addComponent(new Button("Open in this window",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- ExternalResource r = new ExternalResource(
+ final ExternalResource r = new ExternalResource(
"http://www.google.com");
getApplication().getMainWindow().open(r);
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- ExternalResource r = new ExternalResource(
+ final ExternalResource r = new ExternalResource(
"http://www.google.com");
getApplication().getMainWindow().open(r, "mytarget");
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- ExternalResource r = new ExternalResource(
+ final ExternalResource r = new ExternalResource(
"http://www.google.com");
getApplication().getMainWindow()
.open(r, "secondtarget");
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
public TestForWindowing() {
- OrderedLayout main = new OrderedLayout();
+ final OrderedLayout main = new OrderedLayout();
main.addComponent(new Label(
"Click the button to create a new inline window."));
- Button create = new Button("Create a new window", new ClickListener() {
+ final Button create = new Button("Create a new window",
+ new ClickListener() {
- public void buttonClick(ClickEvent event) {
- Window w = new Window("Testing Window");
+ public void buttonClick(ClickEvent event) {
+ Window w = new Window("Testing Window");
- AbstractSelect s1 = new OptionGroup();
- s1.setCaption("1. Select output format");
- s1.addItem("Excel sheet");
- s1.addItem("CSV plain text");
- s1.setValue("Excel sheet");
+ AbstractSelect s1 = new OptionGroup();
+ s1.setCaption("1. Select output format");
+ s1.addItem("Excel sheet");
+ s1.addItem("CSV plain text");
+ s1.setValue("Excel sheet");
- s2 = new Select();
- s2.addItem("Separate by comma (,)");
- s2.addItem("Separate by colon (:)");
- s2.addItem("Separate by semicolon (;)");
- s2.setEnabled(false);
+ s2 = new Select();
+ s2.addItem("Separate by comma (,)");
+ s2.addItem("Separate by colon (:)");
+ s2.addItem("Separate by semicolon (;)");
+ s2.setEnabled(false);
- s1.addListener(new ValueChangeListener() {
+ s1.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- String v = (String) event.getProperty().getValue();
- if (v.equals("CSV plain text")) {
- s2.setEnabled(true);
- } else {
- s2.setEnabled(false);
- }
- }
+ public void valueChange(ValueChangeEvent event) {
+ String v = (String) event.getProperty()
+ .getValue();
+ if (v.equals("CSV plain text")) {
+ s2.setEnabled(true);
+ } else {
+ s2.setEnabled(false);
+ }
+ }
- });
+ });
- w.addComponent(s1);
- w.addComponent(s2);
+ w.addComponent(s1);
+ w.addComponent(s2);
- Slider s = new Slider();
- s.setCaption("Volume");
- s.setMax(13);
- s.setMin(12);
- s.setResolution(2);
- s.setImmediate(true);
- // s.setOrientation(Slider.ORIENTATION_VERTICAL);
- // s.setArrows(false);
+ Slider s = new Slider();
+ s.setCaption("Volume");
+ s.setMax(13);
+ s.setMin(12);
+ s.setResolution(2);
+ s.setImmediate(true);
+ // s.setOrientation(Slider.ORIENTATION_VERTICAL);
+ // s.setArrows(false);
- w.addComponent(s);
+ w.addComponent(s);
- getApplication().getMainWindow().addWindow(w);
+ getApplication().getMainWindow().addWindow(w);
- }
+ }
- });
+ });
main.addComponent(create);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.ui.CustomComponent;
}
private Label createEmbedded(String URL) {
- int width = 600;
- int height = 250;
- String iFrame = "<iframe height=\"" + height + "\" width=\"" + width
- + "\" src=\"" + URL + "\" />";
+ final int width = 600;
+ final int height = 250;
+ final String iFrame = "<iframe height=\"" + height + "\" width=\""
+ + width + "\" src=\"" + URL + "\" />";
return new Label(iFrame, Label.CONTENT_XHTML);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.Collection;
public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent {
public TestSelectAndDatefieldInDeepLayouts() {
- OrderedLayout root = (OrderedLayout) getOrderedLayout();
+ final OrderedLayout root = (OrderedLayout) getOrderedLayout();
setCompositionRoot(root);
root.addComponent(getSelect());
root.addComponent(getSelect());
root.addComponent(getDateField());
- Panel p1 = getPanel();
+ final Panel p1 = getPanel();
root.addComponent(p1);
p1.addComponent(getSelect());
p1.addComponent(getSelect());
p1.addComponent(getDateField());
- OrderedLayout l1 = (OrderedLayout) getOrderedLayout();
+ final OrderedLayout l1 = (OrderedLayout) getOrderedLayout();
p1.addComponent(l1);
l1.addComponent(getSelect());
l1.addComponent(getSelect());
l1.addComponent(getDateField());
- Panel p2 = getPanel();
+ final Panel p2 = getPanel();
l1.addComponent(p2);
p2.addComponent(getSelect());
}
AbstractLayout getOrderedLayout() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
l.setCaption(getCaption("orderedlayout"));
return l;
}
Panel getPanel() {
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption(getCaption("panel"));
return panel;
}
}
private Collection getSelectOptions() {
- Collection opts = new Vector(3);
+ final Collection opts = new Vector(3);
opts.add(getCaption("opt 1"));
opts.add(getCaption("opt 2"));
opts.add(getCaption("opt 3"));
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.ui.Button;
int selectedPanel = 0;
public void init() {
- Window mainWindow = new Window("TestSetVisibleAndCaching");
+ final Window mainWindow = new Window("TestSetVisibleAndCaching");
setMainWindow(mainWindow);
panelA.addComponent(new Label(
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import com.itmill.toolkit.ui.Label;
SplitPanel verticalSplit = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);
public void init() {
- Window mainWindow = new Window("Feature Browser");
+ final Window mainWindow = new Window("Feature Browser");
setMainWindow(mainWindow);
verticalSplit.setFirstComponent(new Label("vertical first"));
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests;
import java.util.LinkedList;
public class UsingObjectsInSelect extends com.itmill.toolkit.Application
implements ValueChangeListener {
- private Select select = new Select();
- private Label selectedTask = new Label("Selected task", Label.CONTENT_XHTML);
+ private final Select select = new Select();
+ private final Label selectedTask = new Label("Selected task",
+ Label.CONTENT_XHTML);
public LinkedList exampleTasks = new LinkedList();
public static Random random = new Random(1);
public void init() {
- Window main = new Window("Select demo");
+ final Window main = new Window("Select demo");
setMainWindow(main);
- Panel panel = new Panel("Select demo");
+ final Panel panel = new Panel("Select demo");
panel.addComponent(select);
- Panel panel2 = new Panel("Selection");
+ final Panel panel2 = new Panel("Selection");
panel2.addComponent(selectedTask);
select.setCaption("Select component");
}
public void createExampleTasks() {
- String[] assignedTo = new String[] { "John", "Mary", "Joe", "Sarah",
- "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" };
- String[] type = new String[] { "Enhancement", "Bugfix", "Testing",
- "Task" };
+ final String[] assignedTo = new String[] { "John", "Mary", "Joe",
+ "Sarah", "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" };
+ final String[] type = new String[] { "Enhancement", "Bugfix",
+ "Testing", "Task" };
for (int j = 0; j < 100; j++) {
- Task task = new Task(
+ final Task task = new Task(
type[(int) (random.nextDouble() * (type.length - 1))],
assignedTo[(int) (random.nextDouble() * (assignedTo.length - 1))],
random.nextInt(100));
}
public void valueChange(ValueChangeEvent event) {
- Task task = (Task) select.getValue();
+ final Task task = (Task) select.getValue();
selectedTask.setValue("<b>Type:</b> " + task.getType()
+ "<br /><b>Assigned to:</b> " + task.getAssignedTo()
+ "<br /><b>Estimated hours: </b>" + task.getEstimatedHours());
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
private boolean propsReminder = true;
- private OrderedLayout layout;
+ private final OrderedLayout layout;
private TabSheet ts;
javadoc.setContentMode(Label.CONTENT_XHTML);
// Demo
- Component demo = getDemoComponent();
+ final Component demo = getDemoComponent();
if (demo != null) {
layout.addComponent(demo);
}
ts.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
// Description tab
- String title = getTitle();
+ final String title = getTitle();
if (getDescriptionXHTML() != null) {
- OrderedLayout mainLayout = new OrderedLayout(
+ final OrderedLayout mainLayout = new OrderedLayout(
OrderedLayout.ORIENTATION_VERTICAL);
- OrderedLayout layout = new OrderedLayout(
+ final OrderedLayout layout = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
mainLayout.addComponent(layout);
if (getImage() != null) {
}
description = new Label(label, Label.CONTENT_XHTML);
mainLayout.addComponent(description);
- mainLayout.setMargin(true);
+ mainLayout.setMargin(true);
ts.addTab(mainLayout, "Description", null);
}
}
// Code Sample tab
- String example = getExampleSrc();
+ final String example = getExampleSrc();
if (example != null) {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
if (getTitle() != null) {
l.addComponent(new Label(
"<b>// " + getTitle() + " example</b>",
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
private boolean initialized = false;
- private Select themeSelector = new Select();
+ private final Select themeSelector = new Select();
public void attach() {
themeSelector.setImmediate(true);
// Restart button
- Button close = new Button("restart", getApplication(), "close");
+ final Button close = new Button("restart", getApplication(), "close");
close.setStyle("link");
mainlayout.addComponent(close, "restart");
// new FeatureParameters());
// Pre-open all menus
- for (Iterator i = features.getItemIds().iterator(); i.hasNext();) {
+ for (final Iterator i = features.getItemIds().iterator(); i.hasNext();) {
features.expandItem(i.next());
}
}
public void registerFeature(String path, Feature feature) {
- StringTokenizer st = new StringTokenizer(path, "/");
+ final StringTokenizer st = new StringTokenizer(path, "/");
String id = "";
String parentId = null;
while (st.hasMoreTokens()) {
- String token = st.nextToken();
+ final String token = st.nextToken();
id += "/" + token;
if (!features.containsId(id)) {
features.addItem(id);
+ ((AbstractComponent) event.getProperty())
.getTag() + ", " + event.getProperty());
}
- } catch (Exception e) {
+ } catch (final Exception e) {
// ignored, should never happen
}
// Change feature
if (event.getProperty() == features) {
- Object id = features.getValue();
+ final Object id = features.getValue();
if (id != null) {
if (features.areChildrenAllowed(id)) {
features.expandItem(id);
}
- Property p = features.getContainerProperty(id, "feature");
- Feature feature = p != null ? ((Feature) p.getValue()) : null;
+ final Property p = features.getContainerProperty(id, "feature");
+ final Feature feature = p != null ? ((Feature) p.getValue())
+ : null;
if (feature != null) {
mainlayout.removeComponent(currentFeature);
mainlayout.removeComponent(currentFeature.getTabSheet());
"buttonClick " + event.getButton().getTag() + ", "
+ event.getButton().getCaption() + ", "
+ event.getButton().getValue());
- } catch (Exception e) {
+ } catch (final Exception e) {
// ignored, should never happen
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final OrderedLayout l = new OrderedLayout();
+ final Panel panel = new Panel();
panel.setCaption("Buffering");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Button b = new Button("Caption");
+ final Button b = new Button("Caption");
l.addComponent(b);
// Properties
propertyPanel = new PropertyPanel(b);
- Select themes = (Select) propertyPanel.getField("style");
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("link").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("link");
- Form ap = propertyPanel
+ final Form ap = propertyPanel
.createBeanPropertySet(new String[] { "switchMode" });
propertyPanel.addProperties("Button Properties", ap);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Containers");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
+ "the subcomponents with flowlayout.";
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Custom Layout");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
static private String[] localeNames;
static {
- Locale[] locales = Locale.getAvailableLocales();
+ final Locale[] locales = Locale.getAvailableLocales();
localeNames = new String[locales.length];
for (int i = 0; i < locales.length; i++) {
localeNames[i] = locales[i].getDisplayName();
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
l.addComponent(new Label("Your default locale is: "
+ getApplication().getLocale().toString().replace('_', '-')));
- DateField df = new DateField();
+ final DateField df = new DateField();
df.setValue(new java.util.Date());
l.addComponent(df);
// Properties
propertyPanel = new PropertyPanel(df);
- Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
"resolution", "locale" });
ap.replaceWithSelect("resolution", new Object[] {
new Integer(DateField.RESOLUTION_YEAR),
ap.getField("resolution").setValue(
new Integer(DateField.RESOLUTION_DAY));
ap.getField("locale").setValue(Locale.getDefault());
- Select themes = (Select) propertyPanel.getField("style");
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("text").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("text");
themes.addItem("calendar").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- ClassResource flashResource = new ClassResource("itmill_spin.swf",
- getApplication());
- Embedded emb = new Embedded("Embedded Caption", flashResource);
+ final ClassResource flashResource = new ClassResource(
+ "itmill_spin.swf", getApplication());
+ final Embedded emb = new Embedded("Embedded Caption", flashResource);
emb.setType(Embedded.TYPE_OBJECT);
emb.setMimeType("application/x-shockwave-flash");
emb.setWidth(250);
// Properties
propertyPanel = new PropertyPanel(emb);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "type",
- "source", "width", "height", "widthUnits", "heightUnits",
- "codebase", "codetype", "archive", "mimeType", "standby",
- "classId" });
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "type", "source", "width", "height", "widthUnits",
+ "heightUnits", "codebase", "codetype", "archive", "mimeType",
+ "standby", "classId" });
ap.replaceWithSelect("type", new Object[] {
new Integer(Embedded.TYPE_IMAGE),
new Integer(Embedded.TYPE_OBJECT) }, new Object[] { "Image",
"Object" });
- Object[] units = new Object[Sizeable.UNIT_SYMBOLS.length];
- Object[] symbols = new Object[Sizeable.UNIT_SYMBOLS.length];
+ final Object[] units = new Object[Sizeable.UNIT_SYMBOLS.length];
+ final Object[] symbols = new Object[Sizeable.UNIT_SYMBOLS.length];
for (int i = 0; i < units.length; i++) {
units[i] = new Integer(i);
symbols[i] = Sizeable.UNIT_SYMBOLS[i];
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
}
demo.addComponent(test);
- OrderedLayout actions = new OrderedLayout(
+ final OrderedLayout actions = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
demo.addComponent(actions);
if (event.getProperty() == resetLayout) {
- String value = (String) resetLayout.getValue();
+ final String value = (String) resetLayout.getValue();
if (value != null) {
formLayout = null;
if (event.getProperty() == addField) {
- String value = (String) addField.getValue();
+ final String value = (String) addField.getValue();
if (value != null) {
if (value.equals("Text field")) {
test.addField(new Object(), new TextField("Test field"));
}
if (value.equals("Time")) {
- DateField d = new DateField("Time", new Date());
+ final DateField d = new DateField("Time", new Date());
d
.setDescription("This is a DateField-component with text-style");
d.setResolution(DateField.RESOLUTION_MIN);
test.addField(new Object(), d);
}
if (value.equals("Calendar")) {
- DateField c = new DateField("Calendar", new Date());
+ final DateField c = new DateField("Calendar", new Date());
c
.setDescription("DateField-component with calendar-style and day-resolution");
c.setStyle("calendar");
test.addField(new Object(), c);
}
if (value.equals("Option group")) {
- Select s = new Select("Options");
+ final Select s = new Select("Options");
s.setDescription("Select-component with optiongroup-style");
s.addItem("Linux");
s.addItem("Windows");
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- GridLayout gl = new GridLayout(3, 3);
- DateField cal = new DateField("Test component 1", new Date());
+ final GridLayout gl = new GridLayout(3, 3);
+ final DateField cal = new DateField("Test component 1", new Date());
cal.setStyle("calendar");
gl.addComponent(cal, 1, 0, 2, 1);
for (int i = 2; i < 7; i++) {
// Properties
propertyPanel = new PropertyPanel(gl);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
ap.addField("new line", new Button("New Line", gl, "newLine"));
ap.addField("space", new Button("Space", gl, "space"));
propertyPanel.addProperties("GridLayout Features", ap);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Items");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Label lab = new Label("Label text");
+ final Label lab = new Label("Label text");
l.addComponent(lab);
// Properties
propertyPanel = new PropertyPanel(lab);
- Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
"contentMode", "value" });
ap.replaceWithSelect("contentMode", new Object[] {
new Integer(Label.CONTENT_PREFORMATTED),
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Link lnk = new Link("Link caption", new ExternalResource(
+ final Link lnk = new Link("Link caption", new ExternalResource(
"http://www.itmill.com"));
l.addComponent(lnk);
// Properties
propertyPanel = new PropertyPanel(lnk);
- Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
"targetName", "targetWidth", "targetHeight", "targetBorder" });
ap.replaceWithSelect("targetBorder", new Object[] {
new Integer(Link.TARGET_BORDER_DEFAULT),
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- OrderedLayout ol = new OrderedLayout();
+ final OrderedLayout ol = new OrderedLayout();
for (int i = 1; i < 5; i++) {
ol.addComponent(new TextField("Test component " + i));
}
// Properties
propertyPanel = new PropertyPanel(ol);
- Form ap = propertyPanel
+ final Form ap = propertyPanel
.createBeanPropertySet(new String[] { "orientation" });
ap.replaceWithSelect("orientation", new Object[] {
new Integer(OrderedLayout.ORIENTATION_HORIZONTAL),
new Integer(OrderedLayout.ORIENTATION_VERTICAL) },
new Object[] { "Horizontal", "Vertical" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("form").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("form");
propertyPanel.addProperties("OrderedLayout Properties", ap);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
// Example panel
- Panel show = new Panel("Panel caption");
+ final Panel show = new Panel("Panel caption");
show
.addComponent(new Label(
"This is an example Label component that is added into Panel."));
// Properties
propertyPanel = new PropertyPanel(show);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
public class FeatureParameters extends Feature implements URIHandler,
ParameterHandler {
- private Label context = new Label();
+ private final Label context = new Label();
- private Label relative = new Label();
+ private final Label relative = new Label();
- private Table params = new Table();
+ private final Table params = new Table();
public FeatureParameters() {
super();
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Label info = new Label("To test this feature, try to "
+ final Label info = new Label("To test this feature, try to "
+ "add some get parameters to URL. For example if you have "
+ "the feature browser installed in your local host, try url: ");
info.setCaption("Usage info");
l.addComponent(info);
try {
- URL u1 = new URL(getApplication().getURL(),
+ final URL u1 = new URL(getApplication().getURL(),
"test/uri?test=1&test=2");
- URL u2 = new URL(getApplication().getURL(),
+ final URL u2 = new URL(getApplication().getURL(),
"foo/bar?mary=john&count=3");
l.addComponent(new Link(u1.toString(), new ExternalResource(u1)));
l.addComponent(new Label("Or this: "));
l.addComponent(new Link(u2.toString(), new ExternalResource(u2)));
- } catch (Exception e) {
+ } catch (final Exception e) {
System.out.println("Couldn't get hostname for this machine: "
+ e.toString());
e.printStackTrace();
}
// URI
- Panel p1 = new Panel("URI Handler");
+ final Panel p1 = new Panel("URI Handler");
context.setCaption("Last URI handler context");
p1.addComponent(context);
relative.setCaption("Last relative URI");
l.addComponent(p1);
// Parameters
- Panel p2 = new Panel("Parameter Handler");
+ final Panel p2 = new Panel("Parameter Handler");
params.setCaption("Last parameters");
params.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID);
params.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
// Properties
propertyPanel = new PropertyPanel(p1);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
*/
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) {
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Data Model");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Select s = new Select("Select employee");
+ final Select s = new Select("Select employee");
for (int i = 0; i < 50; i++) {
s
.addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))]
// Properties
propertyPanel = new PropertyPanel(s);
- Select themes = (Select) propertyPanel.getField("style");
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("optiongroup").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("optiongroup");
themes.addItem("twincol").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- TabSheet ts = new TabSheet();
+ final TabSheet ts = new TabSheet();
ts
.addTab(
new Label(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
private boolean actionsActive = false;
- private Button actionHandlerSwitch = new Button("Activate actions", this,
- "toggleActions");
+ private final Button actionHandlerSwitch = new Button("Activate actions",
+ this, "toggleActions");
public void toggleActions() {
if (actionsActive) {
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
// Sample table
t = new Table("Corporate Employees");
// Properties
propertyPanel = new PropertyPanel(t);
- Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
"pageLength", "rowHeaderMode", "selectable",
"columnHeaderMode", "columnCollapsingAllowed",
"columnReorderingAllowed", "width", "height" });
"Explicit", "Explicit defaults ID", "Hidden", "Icon only",
"ID", "Index", "Item", "Property" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("list").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("list");
themes.addItem("paging").getItemProperty(
return "Table";
}
- private Action ACTION1 = new Action("Action 1");
+ private final Action ACTION1 = new Action("Action 1");
- private Action ACTION2 = new Action("Action 2");
+ private final Action ACTION2 = new Action("Action 2");
- private Action ACTION3 = new Action("Action 3");
+ private final Action ACTION3 = new Action("Action 3");
- private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 };
+ private final Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 };
public Action[] getActions(Object target, Object sender) {
return actions;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout(
+ final OrderedLayout l = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
// Test component
- TextField tf = new TextField("Caption");
+ final TextField tf = new TextField("Caption");
l.addComponent(tf);
// Properties
propertyPanel = new PropertyPanel(tf);
- Form f = propertyPanel.createBeanPropertySet(new String[] { "columns",
- "rows", "wordwrap", "writeThrough", "readThrough",
+ final Form f = propertyPanel.createBeanPropertySet(new String[] {
+ "columns", "rows", "wordwrap", "writeThrough", "readThrough",
"nullRepresentation", "nullSettingAllowed", "secret" });
propertyPanel.addProperties("Text field properties", f);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
private boolean actionsActive = false;
- private Button actionHandlerSwitch = new Button("Activate actions", this,
- "toggleActions");
+ private final Button actionHandlerSwitch = new Button("Activate actions",
+ this, "toggleActions");
public FeatureTree() {
super();
}
public void expandAll() {
- for (Iterator i = t.rootItemIds().iterator(); i.hasNext();) {
+ for (final Iterator i = t.rootItemIds().iterator(); i.hasNext();) {
t.expandItemsRecursively(i.next());
}
}
public void collapseAll() {
- for (Iterator i = t.rootItemIds().iterator(); i.hasNext();) {
+ for (final Iterator i = t.rootItemIds().iterator(); i.hasNext();) {
t.collapseItemsRecursively(i.next());
}
}
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- String[] names = new String[100];
+ final String[] names = new String[100];
for (int i = 0; i < names.length; i++) {
names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ " "
t = new Tree("Organization Structure");
for (int i = 0; i < 100; i++) {
t.addItem(names[i]);
- String parent = names[(int) (Math.random() * (names.length - 1))];
+ final String parent = names[(int) (Math.random() * (names.length - 1))];
if (t.containsId(parent)) {
t.setParent(names[i], parent);
}
// Properties
propertyPanel = new PropertyPanel(t);
- Form ap = propertyPanel
+ final Form ap = propertyPanel
.createBeanPropertySet(new String[] { "selectable" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("menu").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("menu");
propertyPanel.addProperties("Tree Properties", ap);
return "Tree";
}
- private Action ACTION1 = new Action("Action 1");
+ private final Action ACTION1 = new Action("Action 1");
- private Action ACTION2 = new Action("Action 2");
+ private final Action ACTION2 = new Action("Action 2");
- private Action ACTION3 = new Action("Action 3");
+ private final Action ACTION3 = new Action("Action 3");
- private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 };
+ private final Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 };
public Action[] getActions(Object target, Object sender) {
return actions;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Upload up = new Upload("Upload", buffer);
+ final Upload up = new Upload("Upload", buffer);
up.setImmediate(true);
up.addListener(this);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.featurebrowser;
import java.text.SimpleDateFormat;
if (statistics) {
try {
return format.format(new Date());
- } catch (Exception e) {
+ } catch (final Exception e) {
// ignored, should never happen
}
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Validators");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
public class FeatureWindow extends Feature implements Window.CloseListener {
- private Button addButton = new Button("Add window", this, "addWin");
+ private final Button addButton = new Button("Add window", this, "addWin");
- private Button removeButton = new Button("Remove window", this, "delWin");
+ private final Button removeButton = new Button("Remove window", this,
+ "delWin");
private Window demoWindow;
protected Component getDemoComponent() {
- OrderedLayout layoutRoot = new OrderedLayout();
- OrderedLayout layoutUpper = new OrderedLayout();
- OrderedLayout layoutLower = new OrderedLayout();
+ final OrderedLayout layoutRoot = new OrderedLayout();
+ final OrderedLayout layoutUpper = new OrderedLayout();
+ final OrderedLayout layoutLower = new OrderedLayout();
demoWindow = new Window("Feature Test Window");
demoWindow.addListener(this);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
FeatureUtil.setStatistics(true);
}
setUser(new Long(System.currentTimeMillis()).toString());
- Window main = new Window("IT Mill Toolkit Features Tour");
+ final Window main = new Window("IT Mill Toolkit Features Tour");
setMainWindow(main);
main.setLayout(new FeatureBrowser());
*/
public void terminalError(
com.itmill.toolkit.terminal.Terminal.ErrorEvent event) {
- Throwable e = event.getThrowable();
+ final Throwable e = event.getThrowable();
FeatureUtil.debug(getUser().toString(), "terminalError: "
+ e.toString());
e.printStackTrace();
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Basic UI components");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("UI component diagram");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Data Handling");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Data Model");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Item Containers");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
+ final Panel panel = new Panel();
panel.setCaption("Layouts");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
// Properties
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
- Label lab = new Label();
+ final Label lab = new Label();
lab.setStyle("featurebrowser-none");
l.addComponent(lab);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
public class IntroWelcome extends Feature implements URIHandler,
ParameterHandler {
- private WebBrowser webBrowser = null;
+ private final WebBrowser webBrowser = null;
Panel panel = new Panel();
+ " located at the top right corner area.";
// TODO Add browser agent string
- private String description = WELCOME_TEXT_LOWER
+ private final String description = WELCOME_TEXT_LOWER
+ "<br /><br />IT Mill Toolkit version: "
+ ApplicationServlet.VERSION;
protected Component getDemoComponent() {
- OrderedLayout l = new OrderedLayout();
+ final OrderedLayout l = new OrderedLayout();
panel.setCaption("Welcome to the IT Mill Toolkit feature tour!");
l.addComponent(panel);
- Label label = new Label();
+ final Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
label.setValue(WELCOME_TEXT_UPPER);
propertyPanel = new PropertyPanel(panel);
- Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
- "height" });
- Select themes = (Select) propertyPanel.getField("style");
+ final Form ap = propertyPanel.createBeanPropertySet(new String[] {
+ "width", "height" });
+ final Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
* @see com.itmill.toolkit.terminal.ParameterHandler#handleParameters(Map)
*/
public void handleParameters(Map parameters) {
- for (Iterator i = parameters.keySet().iterator(); i.hasNext();) {
- String name = (String) i.next();
+ for (final Iterator i = parameters.keySet().iterator(); i.hasNext();) {
+ final String name = (String) i.next();
if (name.equals("systemStatus")) {
String status = "";
status += "timestamp=" + new Date() + " ";
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.tests.featurebrowser;
private Select addComponent;
- private OrderedLayout formsLayout = new OrderedLayout();
+ private final OrderedLayout formsLayout = new OrderedLayout();
- private LinkedList forms = new LinkedList();
+ private final LinkedList forms = new LinkedList();
- private Button setButton = new Button("Set", this);
+ private final Button setButton = new Button("Set", this);
- private Button discardButton = new Button("Discard changes", this);
+ private final Button discardButton = new Button("Discard changes", this);
- private Table allProperties = new Table();
+ private final Table allProperties = new Table();
- private Object objectToConfigure;
+ private final Object objectToConfigure;
- private BeanItem config;
+ private final BeanItem config;
protected static final int COLUMNS = 3;
config = new BeanItem(objectToConfigure);
// Control buttons
- OrderedLayout buttons = new OrderedLayout(
+ final OrderedLayout buttons = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
buttons.setMargin(false, true, true, true);
buttons.addComponent(setButton);
public void addProperties(String propertySetCaption, Form properties) {
// Create new panel containing the form
- Panel p = new Panel();
+ final Panel p = new Panel();
p.setCaption(propertySetCaption);
p.setStyle("light");
p.addComponent(properties);
allProperties.removeAllItems();
// Collect demoed properties
- HashSet listed = new HashSet();
- for (Iterator i = forms.iterator(); i.hasNext();) {
+ final HashSet listed = new HashSet();
+ for (final Iterator i = forms.iterator(); i.hasNext();) {
listed.addAll(((Form) i.next()).getItemPropertyIds());
}
BeanInfo info;
try {
info = Introspector.getBeanInfo(objectToConfigure.getClass());
- } catch (IntrospectionException e) {
+ } catch (final IntrospectionException e) {
throw new RuntimeException(e.toString());
}
- PropertyDescriptor[] pd = info.getPropertyDescriptors();
+ final PropertyDescriptor[] pd = info.getPropertyDescriptors();
// Fill the table
for (int i = 0; i < pd.length; i++) {
private void addBasicComponentProperties() {
// Set of properties
- Form set = createBeanPropertySet(new String[] { "caption", "icon",
- "componentError", "description", "enabled", "visible", "style",
- "readOnly", "immediate" });
+ final Form set = createBeanPropertySet(new String[] { "caption",
+ "icon", "componentError", "description", "enabled", "visible",
+ "style", "readOnly", "immediate" });
// Icon
set.replaceWithSelect("icon", new Object[] { null,
Throwable sampleException;
try {
throw new NullPointerException("sample exception");
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
sampleException = e;
}
set
"Sample Formatted error", "Sample System Error" });
// Style
- String currentStyle = ((Component) objectToConfigure).getStyleName();
+ final String currentStyle = ((Component) objectToConfigure)
+ .getStyleName();
if (currentStyle == null) {
set.replaceWithSelect("style", new Object[] { null },
new Object[] { "Default" }).setNewItemsAllowed(true);
/** Add properties for selecting */
private void addSelectProperties() {
- Form set = createBeanPropertySet(new String[] { "newItemsAllowed",
- "lazyLoading", "multiSelect" });
+ final Form set = createBeanPropertySet(new String[] {
+ "newItemsAllowed", "lazyLoading", "multiSelect" });
addProperties("Select Properties", set);
set.getField("multiSelect").setDescription(
private void addFieldProperties() {
// TODO bug #211 states that setFocus works only for Button and
// Textfield UI components
- Form set = new Form(new GridLayout(COLUMNS, 1));
+ final Form set = new Form(new GridLayout(COLUMNS, 1));
set.addField("focus", new Button("Focus", objectToConfigure, "focus"));
set.getField("focus").setDescription(
"Focus the cursor to this field. Not all "
* container
*/
private void addComponentContainerProperties() {
- Form set = new Form(new OrderedLayout(
+ final Form set = new Form(new OrderedLayout(
OrderedLayout.ORIENTATION_VERTICAL));
addComponent = new Select();
"valueChange "
+ ((AbstractComponent) event.getProperty())
.getTag() + ", " + event.getProperty());
- } catch (Exception e) {
+ } catch (final Exception e) {
// ignored, should never happen
}
// Adding components to component container
if (event.getProperty() == addComponent) {
- String value = (String) addComponent.getValue();
+ final String value = (String) addComponent.getValue();
if (value != null) {
// TextField component
// DateField time style
if (value.equals("Time")) {
- DateField d = new DateField("Time", new Date());
+ final DateField d = new DateField("Time", new Date());
d
.setDescription("This is a DateField-component with text-style");
d.setResolution(DateField.RESOLUTION_MIN);
// Date field calendar style
if (value.equals("Calendar")) {
- DateField c = new DateField("Calendar", new Date());
+ final DateField c = new DateField("Calendar", new Date());
c
.setDescription("DateField-component with calendar-style and day-resolution");
c.setStyle("calendar");
// Select option group style
if (value.equals("Option group")) {
- Select s = new Select("Options");
+ final Select s = new Select("Options");
s.setDescription("Select-component with optiongroup-style");
s.addItem("Linux");
s.addItem("Windows");
addComponent.setValue(null);
}
} else if (event.getProperty() == getField("lazyLoading")) {
- boolean newValue = ((Boolean) event.getProperty().getValue())
+ final boolean newValue = ((Boolean) event.getProperty().getValue())
.booleanValue();
- Field multiselect = getField("multiSelect");
- Field newitems = getField("newItemsAllowed");
+ final Field multiselect = getField("multiSelect");
+ final Field newitems = getField("newItemsAllowed");
if (newValue) {
newitems.setValue(Boolean.FALSE);
newitems.setVisible(false);
"buttonClick " + event.getButton().getTag() + ", "
+ event.getButton().getCaption() + ", "
+ event.getButton().getValue());
- } catch (Exception e) {
+ } catch (final Exception e) {
// ignored, should never happen
}
// Commit all changed on all forms
// Discard all changed on all forms
if (event.getButton() == discardButton) {
- for (Iterator i = forms.iterator(); i.hasNext();) {
+ for (final Iterator i = forms.iterator(); i.hasNext();) {
((Form) i.next()).discard();
}
}
*/
protected Form createBeanPropertySet(String names[]) {
- Form set = new Form(new OrderedLayout(
+ final Form set = new Form(new OrderedLayout(
OrderedLayout.ORIENTATION_VERTICAL));
for (int i = 0; i < names.length; i++) {
- Property p = config.getItemProperty(names[i]);
+ final Property p = config.getItemProperty(names[i]);
if (p != null) {
set.addItemProperty(names[i], p);
- Field f = set.getField(names[i]);
+ final Field f = set.getField(names[i]);
if (f instanceof TextField) {
if (Integer.class.equals(p.getType())) {
((TextField) f).setColumns(4);
/** Find a field from all forms */
public Field getField(Object propertyId) {
- for (Iterator i = forms.iterator(); i.hasNext();) {
- Form f = (Form) i.next();
- Field af = f.getField(propertyId);
+ for (final Iterator i = forms.iterator(); i.hasNext();) {
+ final Form f = (Form) i.next();
+ final Field af = f.getField(propertyId);
if (af != null) {
return af;
}
}
protected void commit() {
- for (Iterator i = forms.iterator(); i.hasNext();) {
+ for (final Iterator i = forms.iterator(); i.hasNext();) {
((Form) i.next()).commit();
}
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.event.Action;
* buttons.
*/
public Action[] getActions(Object target, Object sender) {
- Action[] actions = new Action[1];
+ final Action[] actions = new Action[1];
// Set the action for the requested component
if (sender == ok) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.terminal.Resource;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import java.net.URL;
String example;
String param = null;
- int slashPos = relativeUri.indexOf("/");
+ final int slashPos = relativeUri.indexOf("/");
if (slashPos > 0) {
example = relativeUri.substring(0, slashPos);
param = relativeUri.substring(slashPos + 1);
/* Remove existing components and windows. */
main.removeAllComponents();
- Set childwindows = main.getChildWindows();
- for (Iterator cwi = childwindows.iterator(); cwi.hasNext();) {
- Window child = (Window) cwi.next();
+ final Set childwindows = main.getChildWindows();
+ for (final Iterator cwi = childwindows.iterator(); cwi.hasNext();) {
+ final Window child = (Window) cwi.next();
main.removeWindow(child);
}
main.setLayout(new OrderedLayout());
if (example.equals("index")) {
- Object examples[] = { "defaultbutton", "label", "labelcontent",
- "tree", "embedded", "textfield", "textfieldvalidation",
- "datefield", "button", "select/select", "select/native",
- "select/optiongroup", "select/twincol", "filterselect",
- "validator", "table", "upload", "link", "gridlayout",
- "orderedlayout", "formlayout", "panel", "expandlayout",
- "tabsheet", "alignment", "alignment/grid", "window",
- "window/opener", "window/multiple", "classresource" };
+ final Object examples[] = { "defaultbutton", "label",
+ "labelcontent", "tree", "embedded", "textfield",
+ "textfieldvalidation", "datefield", "button",
+ "select/select", "select/native", "select/optiongroup",
+ "select/twincol", "filterselect", "validator", "table",
+ "upload", "link", "gridlayout", "orderedlayout",
+ "formlayout", "panel", "expandlayout", "tabsheet",
+ "alignment", "alignment/grid", "window", "window/opener",
+ "window/multiple", "classresource" };
for (int i = 0; i < examples.length; i++) {
main.addComponent(new Label("<a href='/tk/testbench2/"
+ examples[i] + "'>" + examples[i] + "</a>",
void example_Label(Window main, String param) {
/* Some container for the Label. */
- Panel panel = new Panel("Panel Containing a Label");
+ final Panel panel = new Panel("Panel Containing a Label");
main.addComponent(panel);
panel.addComponent(new Label(
}
void example_LabelContent(Window main, String param) {
- GridLayout labelgrid = new GridLayout(2, 1);
+ final GridLayout labelgrid = new GridLayout(2, 1);
labelgrid.addStyleName("labelgrid");
labelgrid.addComponent(new Label("CONTENT_DEFAULT"));
labelgrid.addComponent(new Label(
Label.CONTENT_XML));
main.addComponent(labelgrid);
- ClassResource labelimage = new ClassResource("smiley.jpg", this);
+ final ClassResource labelimage = new ClassResource("smiley.jpg", this);
main.addComponent(new Label("Here we have an image <img src=\""
+ getRelativeLocation(labelimage) + "\"/> within some text.",
Label.CONTENT_XHTML));
new Object[] { "Neptune", "Triton", "Proteus", "Nereid",
"Larissa" } };
- Tree tree = new Tree("The Planets and Major Moons");
+ final Tree tree = new Tree("The Planets and Major Moons");
/* Add planets as root items in the tree. */
for (int i = 0; i < planets.length; i++) {
- String planet = (String) (planets[i][0]);
+ final String planet = (String) (planets[i][0]);
tree.addItem(planet);
if (planets[i].length == 1) {
} else {
/* Add children (moons) under the planets. */
for (int j = 1; j < planets[i].length; j++) {
- String moon = (String) planets[i][j];
+ final String moon = (String) planets[i][j];
/* Add the item as a regular item. */
tree.addItem(moon);
}
void example_Select(Window main, String param) {
- OrderedLayout layout = new OrderedLayout(
+ final OrderedLayout layout = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
layout.addStyleName("aligntop");
if (param.equals("twincol")) {
- SelectExample select1 = new SelectExample(this, param,
+ final SelectExample select1 = new SelectExample(this, param,
"Select some items", true);
layout.addComponent(select1);
} else if (param.equals("filter")) {
- SelectExample select1 = new SelectExample(this, param,
+ final SelectExample select1 = new SelectExample(this, param,
"Enter containing substring", false);
layout.addComponent(select1);
} else {
- SelectExample select1 = new SelectExample(this, param,
+ final SelectExample select1 = new SelectExample(this, param,
"Single Selection Mode", false);
- SelectExample select2 = new SelectExample(this, param,
+ final SelectExample select2 = new SelectExample(this, param,
"Multiple Selection Mode", true);
layout.addComponent(select1);
layout.addComponent(select2);
}
void example_FilterSelect(Window main, String param) {
- Select select = new Select("Enter containing substring");
+ final Select select = new Select("Enter containing substring");
main.addComponent(select);
select
void example_TextField(Window main, String param) {
/* Add a single-line text field. */
- TextField subject = new TextField("Subject");
+ final TextField subject = new TextField("Subject");
subject.setColumns(40);
main.addComponent(subject);
/* Add a multi-line text field. */
- TextField message = new TextField("Message");
+ final TextField message = new TextField("Message");
message.setRows(7);
message.setColumns(40);
main.addComponent(message);
void example_TextFieldValidation(Window main, String param) {
// Create a text field with a label
- TextField username = new TextField("Username");
+ final TextField username = new TextField("Username");
main.addComponent(username);
// Set visible length to 16 characters
username.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
// Get the source of the event
- TextField username = (TextField) (event.getProperty());
+ final TextField username = (TextField) (event.getProperty());
try {
// Validate the field value.
// The value was ok, reset a possible error
username.setComponentError(null);
- } catch (Validator.InvalidValueException e) {
+ } catch (final Validator.InvalidValueException e) {
// The value was not ok. Set the error.
username.setComponentError(new UserError(e.getMessage()));
}
void example_DateField(Window main, String param) {
/* Create a DateField with the calendar style. */
- DateField date = new DateField("Here is a calendar field");
+ final DateField date = new DateField("Here is a calendar field");
date.setStyle("calendar");
/* Set the date and time to present. */
void example_Link(Window main, String param) {
/* Create a link that opens the popup window. */
- Link alink = new Link();
+ final Link alink = new Link();
/* Set the resource to be opened in the window. */
alink.setResource(new ExternalResource("http://www.itmill.com/"));
main.addComponent(alink);
- ClassResource mydocument = new ClassResource("mydocument.pdf", this);
+ final ClassResource mydocument = new ClassResource("mydocument.pdf",
+ this);
main.addComponent(new Link("The document (pdf)", mydocument));
main.addComponent(new Link("link to a resource", new ExternalResource(
"http://www.itmill.com/")));
// Button checkbox = new Button ("This is a checkbox");
// main.addComponent(checkbox);
- Button button = new Button("My Button");
+ final Button button = new Button("My Button");
main.addComponent(button);
}
}
void example_Panel(Window main, String param) {
- Panel panel = new Panel("Contact Information");
- OrderedLayout form = new FormLayout();
+ final Panel panel = new Panel("Contact Information");
+ final OrderedLayout form = new FormLayout();
form.addComponent(new TextField("Name"));
form.addComponent(new TextField("Email"));
- ClassResource icon = new ClassResource("smiley.jpg", main
+ final ClassResource icon = new ClassResource("smiley.jpg", main
.getApplication());
form.addComponent(new Embedded("Image", icon));
panel.setIcon(icon);
void example_GridLayout(Window main, String param) {
/* Create a 4 by 4 grid layout. */
- GridLayout grid = new GridLayout(4, 4);
+ final GridLayout grid = new GridLayout(4, 4);
grid.addStyleName("example-gridlayout");
/* Fill out the first row using the cursor. */
/* Add some components of various shapes. */
grid.addComponent(new Button("3x1 button"), 1, 1, 3, 1);
grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3);
- DateField date = new DateField("A 2x2 date field");
+ final DateField date = new DateField("A 2x2 date field");
date.setStyle("calendar");
grid.addComponent(date, 2, 2, 3, 3);
void example_Alignment(Window main, String param) {
if (param.equals("grid")) {
/* Create a 3 by 3 grid layout. */
- GridLayout layout = new GridLayout(3, 3);
+ final GridLayout layout = new GridLayout(3, 3);
// OrderedLayout layout = new
// OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL);
main.setLayout(layout);
* layout.addComponent(celllayout); }
*/
} else {
- Panel panel = new Panel("A Panel with a Layout");
+ final Panel panel = new Panel("A Panel with a Layout");
main.addComponent(panel);
// panel.addComponent(new )
}
void example_OrderedLayout(Window main, String param) {
- OrderedLayout layout = new OrderedLayout(
+ final OrderedLayout layout = new OrderedLayout(
OrderedLayout.ORIENTATION_VERTICAL);
layout.addComponent(new TextField("Name"));
layout.addComponent(new TextField("Street address"));
}
void example_FormLayout(Window main, String param) {
- FormLayout layout = new FormLayout();
+ final FormLayout layout = new FormLayout();
layout.addComponent(new TextField("Name"));
layout.addComponent(new TextField("Street address"));
layout.addComponent(new TextField("Postal code"));
void example_ExpandLayout(Window main, String param) {
for (int w = 0; w < 2; w++) {
- ExpandLayout layout = new ExpandLayout(
+ final ExpandLayout layout = new ExpandLayout(
OrderedLayout.ORIENTATION_VERTICAL);
/* Set the expanding layout as the root layout of a child window. */
- Window window = new Window("A Child Window", layout);
+ final Window window = new Window("A Child Window", layout);
main.addWindow(window);
/* Add some component above the expanding one. */
layout.addComponent(new Label("Here be some component."));
/* Create the expanding component. */
- Table table = new Table("My Ever-Expanding Table");
+ final Table table = new Table("My Ever-Expanding Table");
/*
* FIXME Java 5 -> 1.4 for (int i=0; i<5; i++)
* table.addContainerProperty("col "+(i+1), Integer.class, 0); for
table.setWidthUnits(Table.UNITS_PERCENTAGE);
/* Add some component below the expanding one. */
- Button button2 = new Button("Ok");
+ final Button button2 = new Button("Ok");
layout.addComponent(button2);
layout.setComponentAlignment(button2,
OrderedLayout.ALIGNMENT_RIGHT, 0);
void example_TabSheet(Window main, String param) {
if (param.equals("icon")) {
- TabSheet tabsheet = new TabSheet();
+ final TabSheet tabsheet = new TabSheet();
tabsheet.addTab(new Label("Contents of the first tab"),
"First Tab", new ClassResource("images/Mercury_small.png",
}
void example_Embedded(Window main, String param) {
- Embedded image = new Embedded("", new ClassResource("smiley.jpg", this));
+ final Embedded image = new Embedded("", new ClassResource("smiley.jpg",
+ this));
image.addStyleName("omaimage");
main.addComponent(image);
- EmbeddedButton button = new EmbeddedButton(new ClassResource(
+ final EmbeddedButton button = new EmbeddedButton(new ClassResource(
"smiley.jpg", this));
main.addComponent(button);
}
main.addComponent(new WindowOpener("Window Opener", main));
} else if (param.equals("multiple")) {
/* Create a new window. */
- Window mywindow = new Window("Second Window");
+ final Window mywindow = new Window("Second Window");
mywindow.setName("mywindow");
mywindow.addComponent(new Label("This is a second window."));
}
/* Create a new window. */
- Window mywindow = new Window("My Window");
+ final Window mywindow = new Window("My Window");
mywindow.setName("mywindow");
/* Add some components in the window. */
mywindow.addComponent(new Label("A text label in the window."));
- Button okbutton = new Button("OK");
+ final Button okbutton = new Button("OK");
mywindow.addComponent(okbutton);
/* Set window size. */
}
void example_ClassResource(Window main, String param) {
- DateField df = new DateField();
+ final DateField df = new DateField();
main.addComponent(df);
df.setIcon(new ClassResource("smiley.jpg", main.getApplication()));
main.addComponent(new Embedded("This is Embedded", new ClassResource(
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import java.io.File;
try {
/* Open the file for writing. */
fos = new FileOutputStream(file);
- } catch (java.io.FileNotFoundException e) {
+ } catch (final java.io.FileNotFoundException e) {
return null; /*
- * Error while opening the file. Not reported
- * here.
- */
+ * Error while opening the file. Not reported
+ * here.
+ */
}
return fos; /* Return the output stream. */
uploadReceiver = new MyUploadReceiver();
/* Create the Upload component. */
- Upload upload = new Upload("Upload", uploadReceiver);
+ final Upload upload = new Upload("Upload", uploadReceiver);
/* Listen for Upload.FinishedEvent events. */
upload.addListener(this);
+ " of type '" + event.getMIMEType() + "' uploaded."));
/* Display the uploaded file in the image panel. */
- FileResource imageResource = new FileResource(uploadReceiver.getFile(),
- getApplication());
+ final FileResource imageResource = new FileResource(uploadReceiver
+ .getFile(), getApplication());
imagePanel.removeAllComponents();
imagePanel.addComponent(new Embedded("", imageResource));
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import java.text.MessageFormat;
public boolean isValid(Object value) {
try {
validate(value);
- } catch (InvalidValueException e) {
+ } catch (final InvalidValueException e) {
return false;
}
return true;
/** Validate the given SSN. */
public void validate(Object value) throws InvalidValueException {
- String ssn = (String) value;
+ final String ssn = (String) value;
if (ssn.length() != 11) {
throw new InvalidValueException("Invalid SSN length");
}
- String numbers = ssn.substring(0, 6) + ssn.substring(7, 10);
- int checksum = new Integer(numbers).intValue() % 31;
+ final String numbers = ssn.substring(0, 6) + ssn.substring(7, 10);
+ final int checksum = new Integer(numbers).intValue() % 31;
if (!ssn.substring(10).equals(
"0123456789ABCDEFHJKLMNPRSTUVWXY".substring(checksum,
checksum + 1))) {
myfield.setFormat(new MessageFormat("{0,number,##}"));
/* Create and set the validator object for the field. */
- SSNValidator ssnvalidator = new SSNValidator();
+ final SSNValidator ssnvalidator = new SSNValidator();
myfield.addValidator(ssnvalidator);
/*
/* The value was correct. */
myerror.setValue("Ok");
myfield.setStyle("");
- } catch (Validator.InvalidValueException e) {
+ } catch (final Validator.InvalidValueException e) {
/* Report the error message to the user. */
myerror.setValue(e.getMessage());
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.Application;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
-import com.itmill.toolkit.ui.*;
+
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.TabSheet;
import com.itmill.toolkit.ui.Button.ClickEvent;
import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent;
-public class TabSheetExample extends CustomComponent implements Button.ClickListener, TabSheet.SelectedTabChangeListener {
- TabSheet tabsheet = new TabSheet();
- Button tab1 = new Button("Push this button");
- Label tab2 = new Label("Contents of Second Tab");
- Label tab3 = new Label("Contents of Third Tab");
-
- TabSheetExample () {
- setCompositionRoot (tabsheet);
-
- /* Listen for changes in tab selection. */
- tabsheet.addListener(this);
-
- /* First tab contains a button, for which we listen button click events. */
- tab1.addListener(this);
- tabsheet.addTab(tab1, "First Tab", null);
-
- /* A tab that is initially invisible. */
- tab2.setVisible(false);
- tabsheet.addTab(tab2, "Second Tab", null);
-
- /* A tab that is initially disabled. */
- tab3.setEnabled(false);
- tabsheet.addTab(tab3, "Third tab", null);
- }
-
- public void buttonClick(ClickEvent event) {
- /* Enable the invisible and disabled tabs. */
- tab2.setVisible(true);
- tab3.setEnabled(true);
-
- /* Change selection automatically to second tab. */
- tabsheet.setSelectedTab(tab2);
- }
-
- public void selectedTabChange(SelectedTabChangeEvent event) {
- /* Cast to a TabSheet. This isn't really necessary in this example,
- * as we have only one TabSheet component, but would be useful if
- * there were multiple TabSheets. */
- TabSheet source = (TabSheet) event.getSource();
- if (source == tabsheet) {
- /* If the first tab was selected. */
- if (source.getSelectedTab() == tab1) {
- tab2.setVisible(false);
- tab3.setEnabled(false);
- }
- }
- }
+public class TabSheetExample extends CustomComponent implements
+ Button.ClickListener, TabSheet.SelectedTabChangeListener {
+ TabSheet tabsheet = new TabSheet();
+ Button tab1 = new Button("Push this button");
+ Label tab2 = new Label("Contents of Second Tab");
+ Label tab3 = new Label("Contents of Third Tab");
+
+ TabSheetExample() {
+ setCompositionRoot(tabsheet);
+
+ /* Listen for changes in tab selection. */
+ tabsheet.addListener(this);
+
+ /* First tab contains a button, for which we listen button click events. */
+ tab1.addListener(this);
+ tabsheet.addTab(tab1, "First Tab", null);
+
+ /* A tab that is initially invisible. */
+ tab2.setVisible(false);
+ tabsheet.addTab(tab2, "Second Tab", null);
+
+ /* A tab that is initially disabled. */
+ tab3.setEnabled(false);
+ tabsheet.addTab(tab3, "Third tab", null);
+ }
+
+ public void buttonClick(ClickEvent event) {
+ /* Enable the invisible and disabled tabs. */
+ tab2.setVisible(true);
+ tab3.setEnabled(true);
+
+ /* Change selection automatically to second tab. */
+ tabsheet.setSelectedTab(tab2);
+ }
+
+ public void selectedTabChange(SelectedTabChangeEvent event) {
+ /*
+ * Cast to a TabSheet. This isn't really necessary in this example, as
+ * we have only one TabSheet component, but would be useful if there
+ * were multiple TabSheets.
+ */
+ final TabSheet source = (TabSheet) event.getSource();
+ if (source == tabsheet) {
+ /* If the first tab was selected. */
+ if (source.getSelectedTab() == tab1) {
+ tab2.setVisible(false);
+ tab3.setEnabled(false);
+ }
+ }
+ }
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.ui.CustomComponent;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.ui.Button;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.ui.AbstractComponentContainer;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.ui.AbstractComponentContainer;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.ui.AbstractComponentContainer;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.magi;
import com.itmill.toolkit.ui.Button;
mainwindow = main;
/* The component consists of a button that opens the window. */
- OrderedLayout layout = new OrderedLayout();
+ final OrderedLayout layout = new OrderedLayout();
layout.addComponent(openbutton = new Button("Open Window", this,
"openButtonClick"));
layout.addComponent(explanation = new Label("Explanation"));
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import java.io.File;
for (int p = 0; p < testablePackages.length; p++) {
testables.addItem(testablePackages[p]);
try {
- List testableClasses = getTestableClassesForPackage(testablePackages[p]);
- for (Iterator it = testableClasses.iterator(); it.hasNext();) {
- Class t = (Class) it.next();
+ final List testableClasses = getTestableClassesForPackage(testablePackages[p]);
+ for (final Iterator it = testableClasses.iterator(); it
+ .hasNext();) {
+ final Class t = (Class) it.next();
// ignore TestBench itself
if (t.equals(TestBench.class)) {
continue;
itemCaptions.put(t, t.getName());
testables.setParent(t, testablePackages[p]);
continue;
- } catch (Exception e) {
+ } catch (final Exception e) {
try {
testables.addItem(t);
itemCaptions.put(t, t.getName());
testables.setParent(t, testablePackages[p]);
continue;
- } catch (Exception e1) {
+ } catch (final Exception e1) {
e1.printStackTrace();
}
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
}
menu = new Tree("Testables", testables);
- for (Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
- Class testable = (Class) i.next();
+ for (final Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
+ final Class testable = (Class) i.next();
// simplify captions
- String name = testable.getName().substring(
+ final String name = testable.getName().substring(
testable.getName().lastIndexOf('.') + 1);
menu.setItemCaption(testable, name);
}
// expand all root items
- for (Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
+ for (final Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
menu.expandItemsRecursively(i.next());
}
private Component createTestable(Class c) {
try {
- Application app = (Application) c.newInstance();
+ final Application app = (Application) c.newInstance();
app.init();
return app.getMainWindow().getLayout();
- } catch (Exception e) {
+ } catch (final Exception e) {
try {
- CustomComponent cc = (CustomComponent) c.newInstance();
+ final CustomComponent cc = (CustomComponent) c.newInstance();
return cc;
- } catch (Exception e1) {
+ } catch (final Exception e1) {
e1.printStackTrace();
return new Label("Cannot create custom component: "
+ e1.toString());
bodyLayout.removeAllComponents();
bodyLayout.setCaption(null);
- Object o = menu.getValue();
+ final Object o = menu.getValue();
if (o != null && o instanceof Class) {
- Class c = (Class) o;
- String title = c.getName();
+ final Class c = (Class) o;
+ final String title = c.getName();
bodyLayout.setCaption(title);
bodyLayout.addComponent(createTestable(c));
} else {
*/
public static List getTestableClassesForPackage(String packageName)
throws Exception {
- ArrayList directories = new ArrayList();
+ final ArrayList directories = new ArrayList();
try {
- ClassLoader cld = Thread.currentThread().getContextClassLoader();
+ final ClassLoader cld = Thread.currentThread()
+ .getContextClassLoader();
if (cld == null) {
throw new ClassNotFoundException("Can't get class loader.");
}
- String path = packageName.replace('.', '/');
+ final String path = packageName.replace('.', '/');
// Ask for all resources for the path
- Enumeration resources = cld.getResources(path);
+ final Enumeration resources = cld.getResources(path);
while (resources.hasMoreElements()) {
- URL url = (URL) resources.nextElement();
+ final URL url = (URL) resources.nextElement();
directories.add(new File(url.getFile()));
}
- } catch (Exception x) {
+ } catch (final Exception x) {
throw new Exception(packageName
+ " does not appear to be a valid package.");
}
- ArrayList classes = new ArrayList();
+ final ArrayList classes = new ArrayList();
// For every directory identified capture all the .class files
- for (Iterator it = directories.iterator(); it.hasNext();) {
- File directory = (File) it.next();
+ for (final Iterator it = directories.iterator(); it.hasNext();) {
+ final File directory = (File) it.next();
if (directory.exists()) {
// Get the list of the files contained in the package
- String[] files = directory.list();
+ final String[] files = directory.list();
for (int j = 0; j < files.length; j++) {
// we are only interested in .class files
if (files[j].endsWith(".class")) {
// removes the .class extension
- String p = packageName + '.'
+ final String p = packageName + '.'
+ files[j].substring(0, files[j].length() - 6);
- Class c = Class.forName(p);
+ final Class c = Class.forName(p);
if (c.getSuperclass() != null) {
if ((c.getSuperclass()
.equals(com.itmill.toolkit.ui.CustomComponent.class))) {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.ui.Button;
public TestForAlignments() {
- OrderedLayout main = new OrderedLayout();
+ final OrderedLayout main = new OrderedLayout();
- Button b1 = new Button("Right");
- Button b2 = new Button("Left");
- Button b3 = new Button("Bottom");
- Button b4 = new Button("Top");
- TextField t1 = new TextField("Right aligned");
- TextField t2 = new TextField("Bottom aligned");
- DateField d1 = new DateField("Center aligned");
- DateField d2 = new DateField("Center aligned");
+ final Button b1 = new Button("Right");
+ final Button b2 = new Button("Left");
+ final Button b3 = new Button("Bottom");
+ final Button b4 = new Button("Top");
+ final TextField t1 = new TextField("Right aligned");
+ final TextField t2 = new TextField("Bottom aligned");
+ final DateField d1 = new DateField("Center aligned");
+ final DateField d2 = new DateField("Center aligned");
- OrderedLayout vert = new OrderedLayout();
+ final OrderedLayout vert = new OrderedLayout();
vert.addComponent(b1);
vert.addComponent(b2);
vert.addComponent(t1);
vert.setComponentAlignment(d1,
OrderedLayout.ALIGNMENT_HORIZONTAL_CENTER,
OrderedLayout.ALIGNMENT_TOP);
- OrderedLayout hori = new OrderedLayout(
+ final OrderedLayout hori = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
hori.addComponent(b3);
hori.addComponent(b4);
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.tests.testbench;\r
\r
import java.sql.SQLException;\r
\r
public class TestForBasicApplicationLayout extends CustomComponent {\r
\r
- private Button click;\r
- private Button click2;\r
- private TabSheet tab;\r
+ private final Button click;\r
+ private final Button click2;\r
+ private final TabSheet tab;\r
\r
// Database provided with sample data\r
private SampleDatabase sampleDatabase;\r
\r
});\r
\r
- SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
+ final SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
sp.setSplitPosition(290, Sizeable.UNITS_PIXELS);\r
\r
- SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
+ final SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS);\r
\r
- Panel p = new Panel("Accordion Panel");\r
+ final Panel p = new Panel("Accordion Panel");\r
p.setSizeFull();\r
\r
tab = new TabSheet();\r
tab.setSizeFull();\r
\r
- Panel report = new Panel("Monthly Program Runs", new ExpandLayout());\r
- OrderedLayout controls = new OrderedLayout();\r
+ final Panel report = new Panel("Monthly Program Runs",\r
+ new ExpandLayout());\r
+ final OrderedLayout controls = new OrderedLayout();\r
controls.setMargin(true);\r
controls.addComponent(new Label("Report tab"));\r
controls.addComponent(click);\r
controls.addComponent(click2);\r
report.addComponent(controls);\r
- DateField cal = new DateField();\r
+ final DateField cal = new DateField();\r
cal.setResolution(DateField.RESOLUTION_DAY);\r
cal.setLocale(new Locale("en", "US"));\r
report.addComponent(cal);\r
\r
sp2.setFirstComponent(report);\r
\r
- Table table = new Table();\r
+ final Table table = new Table();\r
// populate Toolkit table component with test SQL table rows\r
try {\r
sampleDatabase = new SampleDatabase();\r
- QueryContainer qc = new QueryContainer("SELECT * FROM employee",\r
- sampleDatabase.getConnection());\r
+ final QueryContainer qc = new QueryContainer(\r
+ "SELECT * FROM employee", sampleDatabase.getConnection());\r
table.setContainerDataSource(qc);\r
- } catch (SQLException e) {\r
+ } catch (final SQLException e) {\r
e.printStackTrace();\r
}\r
// define which columns should be visible on Table component\r
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.data.util.IndexedContainer;
ic.addContainerProperty("first", String.class, "");
ic.addContainerProperty("second", String.class, "");
for (int i = 0; i < 1000; i++) {
- Object id = ic.addItem();
+ final Object id = ic.addItem();
ic.getContainerProperty(id, "first").setValue(randomWord());
ic.getContainerProperty(id, "second").setValue(randomWord());
}
// Init filtering view
- Panel filterPanel = new Panel("Filter", new OrderedLayout(
+ final Panel filterPanel = new Panel("Filter", new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL));
filterPanel.setWidth(100);
filterPanel.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
public void buttonClick(ClickEvent event) {
ic.removeAllContainerFilters();
if (firstFilter.toString().length() > 0) {
- ic.addContainerFilter("first", firstFilter.toString(), false,
- false);
+ ic.addContainerFilter("first", firstFilter.toString(),
+ false, false);
}
if (secondFilter.toString().length() > 0) {
- ic.addContainerFilter("second", secondFilter.toString(), true,
- true);
+ ic.addContainerFilter("second", secondFilter.toString(),
+ true, true);
}
count.setValue("Rows in table: " + ic.size());
}
private String randomWord() {
int len = (int) (Math.random() * 4);
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
while (len-- >= 0) {
buf.append(parts[(int) (Math.random() * parts.length)]);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import java.util.ArrayList;
public void valueChange(ValueChangeEvent event) {
- String currentStyle = l.getStyle();
- String[] tmp = currentStyle.split(" ");
- ArrayList curStyles = new ArrayList();
+ final String currentStyle = l.getStyle();
+ final String[] tmp = currentStyle.split(" ");
+ final ArrayList curStyles = new ArrayList();
for (int i = 0; i < tmp.length; i++) {
if (tmp[i] != "") {
curStyles.add(tmp[i]);
}
}
- Collection styles = (Collection) s.getValue();
+ final Collection styles = (Collection) s.getValue();
- for (Iterator iterator = styles.iterator(); iterator.hasNext();) {
- String styleName = (String) iterator.next();
+ for (final Iterator iterator = styles.iterator(); iterator.hasNext();) {
+ final String styleName = (String) iterator.next();
if (curStyles.contains(styleName)) {
// already added
curStyles.remove(styleName);
l.addStyleName(styleName);
}
}
- for (Iterator iterator2 = curStyles.iterator(); iterator2.hasNext();) {
- String object = (String) iterator2.next();
+ for (final Iterator iterator2 = curStyles.iterator(); iterator2
+ .hasNext();) {
+ final String object = (String) iterator2.next();
l.removeStyleName(object);
}
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.event.Action;
.setCaption("OptionGroup + multiselect manually (configured from select)");
main.addComponent(test);
- Button b = new Button("refresh view", this, "createNewView");
+ final Button b = new Button("refresh view", this, "createNewView");
main.addComponent(b);
}
public static void fillSelect(AbstractSelect s, int items) {
for (int i = 0; i < items; i++) {
- String name = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ final String name = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ " "
+ lastnames[(int) (Math.random() * (lastnames.length - 1))];
s.addItem(name);
public Tree createTestTree() {
Tree t = new Tree("Tree");
- String[] names = new String[100];
+ final String[] names = new String[100];
for (int i = 0; i < names.length; i++) {
names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ " "
t = new Tree("Organization Structure");
for (int i = 0; i < 100; i++) {
t.addItem(names[i]);
- String parent = names[(int) (Math.random() * (names.length - 1))];
+ final String parent = names[(int) (Math.random() * (names.length - 1))];
if (t.containsId(parent)) {
t.setParent(names[i], parent);
}
}
public Panel createTestBench(Component t) {
- Panel ol = new Panel();
+ final Panel ol = new Panel();
ol.setLayout(new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));
ol.addComponent(t);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
public class TestForRichTextEditor extends CustomComponent implements
ValueChangeListener {
- private OrderedLayout main = new OrderedLayout();
+ private final OrderedLayout main = new OrderedLayout();
private Label l;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.event.Action;
"Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding",
"Einstein" };
- private OrderedLayout main = new OrderedLayout();
+ private final OrderedLayout main = new OrderedLayout();
- private Action[] actions = new Action[] { new Action("edit"),
+ private final Action[] actions = new Action[] { new Action("edit"),
new Action("delete") };
private Panel al;
t.setCaption("with actions");
t.setImmediate(true);
t.addActionHandler(this);
- OrderedLayout ol = (OrderedLayout) createTestBench(t);
+ final OrderedLayout ol = (OrderedLayout) createTestBench(t);
al = new Panel("action log");
ol.addComponent(al);
main.addComponent(ol);
contextTree = t;
- Button b = new Button("refresh view", this, "createNewView");
+ final Button b = new Button("refresh view", this, "createNewView");
main.addComponent(b);
}
public Tree createTestTree() {
Tree t = new Tree("Tree");
- String[] names = new String[100];
+ final String[] names = new String[100];
for (int i = 0; i < names.length; i++) {
names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))]
+ " "
t = new Tree("Organization Structure");
for (int i = 0; i < 100; i++) {
t.addItem(names[i]);
- String parent = names[(int) (Math.random() * (names.length - 1))];
+ final String parent = names[(int) (Math.random() * (names.length - 1))];
if (t.containsId(parent)) {
t.setParent(names[i], parent);
}
}
public Component createTestBench(Tree t) {
- OrderedLayout ol = new OrderedLayout();
+ final OrderedLayout ol = new OrderedLayout();
ol.setOrientation(OrderedLayout.ORIENTATION_HORIZONTAL);
ol.addComponent(t);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import java.io.ByteArrayInputStream;
up.setProgressListener(this);
- Button b = new Button("b", this, "readState");
+ final Button b = new Button("b", this, "readState");
- Button c = new Button("b with gc", this, "gc");
+ final Button c = new Button("b with gc", this, "gc");
main.addComponent(b);
main.addComponent(c);
status.setVisible(false);
main.addComponent(status);
- Button restart = new Button("R");
+ final Button restart = new Button("R");
restart.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
}
private void setBuffer() {
- String id = (String) uploadBufferSelector.getValue();
+ final String id = (String) uploadBufferSelector.getValue();
if ("memory".equals(id)) {
buffer = new MemoryBuffer();
} else if ("tempfile".equals(id)) {
}
public void readState() {
- StringBuffer sb = new StringBuffer();
+ final StringBuffer sb = new StringBuffer();
if (up.isUploading()) {
sb.append("Uploading...");
public void uploadFinished(FinishedEvent event) {
status.removeAllComponents();
- InputStream stream = buffer.getStream();
+ final InputStream stream = buffer.getStream();
if (stream == null) {
status.addComponent(new Label(
"Upload finished, but output buffer is null!!"));
private FileInputStream stream;
public TmpFileBuffer() {
- String tempFileName = "upload_tmpfile_"
+ final String tempFileName = "upload_tmpfile_"
+ System.currentTimeMillis();
try {
file = File.createTempFile(tempFileName, null);
- } catch (IOException e) {
+ } catch (final IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
return new FileInputStream(file);
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mimeType = MIMEType;
try {
return new FileOutputStream(file);
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.terminal.ExternalResource;
public TestForWindowOpen() {
- OrderedLayout main = new OrderedLayout();
+ final OrderedLayout main = new OrderedLayout();
setCompositionRoot(main);
main.addComponent(new Button("Open in this window",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- ExternalResource r = new ExternalResource(
+ final ExternalResource r = new ExternalResource(
"http://www.google.com");
getApplication().getMainWindow().open(r);
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- ExternalResource r = new ExternalResource(
+ final ExternalResource r = new ExternalResource(
"http://www.google.com");
getApplication().getMainWindow().open(r, "mytarget");
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- ExternalResource r = new ExternalResource(
+ final ExternalResource r = new ExternalResource(
"http://www.google.com");
getApplication().getMainWindow()
.open(r, "secondtarget");
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
public TestForWindowing() {
- OrderedLayout main = new OrderedLayout();
+ final OrderedLayout main = new OrderedLayout();
main.addComponent(new Label(
"Click the button to create a new inline window."));
- Button create = new Button("Create a new window", new ClickListener() {
+ final Button create = new Button("Create a new window",
+ new ClickListener() {
- public void buttonClick(ClickEvent event) {
- Window w = new Window("Testing Window");
+ public void buttonClick(ClickEvent event) {
+ Window w = new Window("Testing Window");
- AbstractSelect s1 = new OptionGroup();
- s1.setCaption("1. Select output format");
- s1.addItem("Excel sheet");
- s1.addItem("CSV plain text");
- s1.setValue("Excel sheet");
+ AbstractSelect s1 = new OptionGroup();
+ s1.setCaption("1. Select output format");
+ s1.addItem("Excel sheet");
+ s1.addItem("CSV plain text");
+ s1.setValue("Excel sheet");
- s2 = new Select();
- s2.addItem("Separate by comma (,)");
- s2.addItem("Separate by colon (:)");
- s2.addItem("Separate by semicolon (;)");
- s2.setEnabled(false);
+ s2 = new Select();
+ s2.addItem("Separate by comma (,)");
+ s2.addItem("Separate by colon (:)");
+ s2.addItem("Separate by semicolon (;)");
+ s2.setEnabled(false);
- s1.addListener(new ValueChangeListener() {
+ s1.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- String v = (String) event.getProperty().getValue();
- if (v.equals("CSV plain text")) {
- s2.setEnabled(true);
- } else {
- s2.setEnabled(false);
- }
- }
+ public void valueChange(ValueChangeEvent event) {
+ String v = (String) event.getProperty()
+ .getValue();
+ if (v.equals("CSV plain text")) {
+ s2.setEnabled(true);
+ } else {
+ s2.setEnabled(false);
+ }
+ }
- });
+ });
- w.addComponent(s1);
- w.addComponent(s2);
+ w.addComponent(s1);
+ w.addComponent(s2);
- Slider s = new Slider();
- s.setCaption("Volume");
- s.setMax(13);
- s.setMin(12);
- s.setResolution(2);
- s.setImmediate(true);
- // s.setOrientation(Slider.ORIENTATION_VERTICAL);
- // s.setArrows(false);
+ Slider s = new Slider();
+ s.setCaption("Volume");
+ s.setMax(13);
+ s.setMin(12);
+ s.setResolution(2);
+ s.setImmediate(true);
+ // s.setOrientation(Slider.ORIENTATION_VERTICAL);
+ // s.setArrows(false);
- w.addComponent(s);
+ w.addComponent(s);
- getApplication().getMainWindow().addWindow(w);
+ getApplication().getMainWindow().addWindow(w);
- }
+ }
- });
+ });
main.addComponent(create);
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.ui.Button;
int selectedPanel = 0;
public void init() {
- Window mainWindow = new Window("TestSetVisibleAndCaching");
+ final Window mainWindow = new Window("TestSetVisibleAndCaching");
setMainWindow(mainWindow);
panelA.addComponent(new Label(
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.tests.testbench;
import com.itmill.toolkit.ui.Label;
SplitPanel verticalSplit = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);
public void init() {
- Window mainWindow = new Window("Feature Browser");
+ final Window mainWindow = new Window("Feature Browser");
setMainWindow(mainWindow);
verticalSplit.setFirstComponent(new Label("vertical first"));
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
public String getStyleName() {
String s = "";
if (styles != null) {
- for (Iterator it = styles.iterator(); it.hasNext();) {
+ for (final Iterator it = styles.iterator(); it.hasNext();) {
s += (String) it.next();
if (it.hasNext()) {
s += " ";
if (parent != null) {
return parent.getLocale();
}
- Application app = getApplication();
+ final Application app = getApplication();
if (app != null) {
return app.getLocale();
}
// Only paint content of visible components.
if (isVisible()) {
- String desc = getDescription();
+ final String desc = getDescription();
if (desc != null && description.length() > 0) {
target.addAttribute("description", getDescription());
}
paintContent(target);
- ErrorMessage error = getErrorMessage();
+ final ErrorMessage error = getErrorMessage();
if (error != null) {
error.paint(target);
}
// Notify the listeners
if (repaintRequestListeners != null
&& !repaintRequestListeners.isEmpty()) {
- Object[] listeners = repaintRequestListeners.toArray();
- RepaintRequestEvent event = new RepaintRequestEvent(this);
+ final Object[] listeners = repaintRequestListeners.toArray();
+ final RepaintRequestEvent event = new RepaintRequestEvent(this);
for (int i = 0; i < listeners.length; i++) {
if (alreadyNotified == null) {
alreadyNotified = new LinkedList();
}
// Notify the parent
- Component parent = getParent();
+ final Component parent = getParent();
if (parent != null) {
parent.childRequestedRepaint(alreadyNotified);
}
COMPONENT_EVENT_METHOD = Component.Listener.class
.getDeclaredMethod("componentEvent",
new Class[] { Component.Event.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
e.printStackTrace();
throw new java.lang.RuntimeException();
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
* reimplemented in extending classes for a more powerfull implementation.
*/
public void removeAllComponents() {
- LinkedList l = new LinkedList();
+ final LinkedList l = new LinkedList();
// Adds all components
- for (Iterator i = getComponentIterator(); i.hasNext();) {
+ for (final Iterator i = getComponentIterator(); i.hasNext();) {
l.add(i.next());
}
// Removes all component
- for (Iterator i = l.iterator(); i.hasNext();) {
+ for (final Iterator i = l.iterator(); i.hasNext();) {
removeComponent((Component) i.next());
}
}
* implemented interface.
*/
public void moveComponentsFrom(ComponentContainer source) {
- LinkedList components = new LinkedList();
- for (Iterator i = source.getComponentIterator(); i.hasNext();) {
+ final LinkedList components = new LinkedList();
+ for (final Iterator i = source.getComponentIterator(); i.hasNext();) {
components.add(i.next());
}
- for (Iterator i = components.iterator(); i.hasNext();) {
- Component c = (Component) i.next();
+ for (final Iterator i = components.iterator(); i.hasNext();) {
+ final Component c = (Component) i.next();
source.removeComponent(c);
addComponent(c);
}
public void attach() {
super.attach();
- for (Iterator i = getComponentIterator(); i.hasNext();) {
+ for (final Iterator i = getComponentIterator(); i.hasNext();) {
((Component) i.next()).attach();
}
}
public void detach() {
super.detach();
- for (Iterator i = getComponentIterator(); i.hasNext();) {
+ for (final Iterator i = getComponentIterator(); i.hasNext();) {
((Component) i.next()).detach();
}
}
COMPONENT_DETACHED_METHOD = ComponentDetachListener.class
.getDeclaredMethod("componentDetachedFromContainer",
new Class[] { ComponentDetachEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
public void commit() throws Buffered.SourceException {
if (dataSource != null && (isInvalidCommitted() || isValid())
&& !dataSource.isReadOnly()) {
- Object newValue = getValue();
+ final Object newValue = getValue();
try {
// Commits the value to datasource.
dataSource.setValue(newValue);
- } catch (Throwable e) {
+ } catch (final Throwable e) {
// Sets the buffering state.
currentBufferedSourceException = new Buffered.SourceException(
currentBufferedSourceException = null;
requestRepaint();
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
// Sets the buffering state
currentBufferedSourceException = new Buffered.SourceException(
throw currentBufferedSourceException;
}
- boolean wasModified = isModified();
+ final boolean wasModified = isModified();
modified = false;
// If the new value differs from the previous one
* @see java.lang.Object#toString()
*/
public String toString() {
- Object value = getValue();
+ final Object value = getValue();
if (value == null) {
return null;
}
return value;
}
- Object newValue = dataSource.getValue();
+ final Object newValue = dataSource.getValue();
if ((newValue == null && value != null)
|| (newValue != null && !newValue.equals(value))) {
setInternalValue(newValue);
// If invalid values are not allowed, the value must be checked
if (!isInvalidAllowed()) {
- Collection v = getValidators();
+ final Collection v = getValidators();
if (v != null) {
- for (Iterator i = v.iterator(); i.hasNext();) {
+ for (final Iterator i = v.iterator(); i.hasNext();) {
((Validator) i.next()).validate(newValue);
}
}
// The buffer is now unmodified
modified = false;
- } catch (Throwable e) {
+ } catch (final Throwable e) {
// Sets the buffering state
currentBufferedSourceException = new Buffered.SourceException(
public void setPropertyDataSource(Property newDataSource) {
// Saves the old value
- Object oldValue = value;
+ final Object oldValue = value;
// Discards all changes to old datasource
try {
discard();
- } catch (Buffered.SourceException ignored) {
+ } catch (final Buffered.SourceException ignored) {
}
// Stops listening the old data source changes
setInternalValue(dataSource.getValue());
}
modified = false;
- } catch (Throwable e) {
+ } catch (final Throwable e) {
currentBufferedSourceException = new Buffered.SourceException(this,
e);
modified = true;
// Copy the validators from the data source
if (dataSource instanceof Validatable) {
- Collection validators = ((Validatable) dataSource).getValidators();
+ final Collection validators = ((Validatable) dataSource)
+ .getValidators();
if (validators != null) {
- for (Iterator i = validators.iterator(); i.hasNext();) {
+ for (final Iterator i = validators.iterator(); i.hasNext();) {
addValidator((Validator) i.next());
}
}
return true;
}
- Object value = getValue();
- for (Iterator i = validators.iterator(); i.hasNext();) {
+ final Object value = getValue();
+ for (final Iterator i = validators.iterator(); i.hasNext();) {
if (!((Validator) i.next()).isValid(value)) {
return false;
}
// Initialize temps
Validator.InvalidValueException firstError = null;
LinkedList errors = null;
- Object value = getValue();
+ final Object value = getValue();
// Gets all the validation errors
- for (Iterator i = validators.iterator(); i.hasNext();) {
+ for (final Iterator i = validators.iterator(); i.hasNext();) {
try {
((Validator) i.next()).validate(value);
- } catch (Validator.InvalidValueException e) {
+ } catch (final Validator.InvalidValueException e) {
if (firstError == null) {
firstError = e;
} else {
}
// Creates composite validator
- Validator.InvalidValueException[] exceptions = new Validator.InvalidValueException[errors
+ final Validator.InvalidValueException[] exceptions = new Validator.InvalidValueException[errors
.size()];
int index = 0;
- for (Iterator i = errors.iterator(); i.hasNext();) {
+ for (final Iterator i = errors.iterator(); i.hasNext();) {
exceptions[index++] = (Validator.InvalidValueException) i.next();
}
* @see com.itmill.toolkit.ui.AbstractComponent#getErrorMessage()
*/
public ErrorMessage getErrorMessage() {
- ErrorMessage superError = super.getErrorMessage();
+ final ErrorMessage superError = super.getErrorMessage();
return superError;
/*
* TODO: Check the logic of this ErrorMessage validationError = null;
VALUE_CHANGE_METHOD = Property.ValueChangeListener.class
.getDeclaredMethod("valueChange",
new Class[] { Property.ValueChangeEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
.getDeclaredMethod(
"readOnlyStatusChange",
new Class[] { Property.ReadOnlyStatusChangeEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
* Asks the terminal to place the cursor to this field.
*/
public void focus() {
- Window w = getWindow();
+ final Window w = getWindow();
if (w != null) {
w.setFocusedComponent(this);
} else {
// Boolean field
if (Boolean.class.isAssignableFrom(propertyType)) {
- Button button = new Button("");
+ final Button button = new Button("");
button.setSwitchMode(true);
button.setImmediate(false);
return button;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.ui;
import com.itmill.toolkit.terminal.PaintException;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
public AbstractSelect(String caption, Collection options) {
// Creates the options container and add given options to it
- Container c = new IndexedContainer();
+ final Container c = new IndexedContainer();
if (options != null) {
- for (Iterator i = options.iterator(); i.hasNext();) {
+ for (final Iterator i = options.iterator(); i.hasNext();) {
c.addItem(i.next());
}
}
target.startTag("options");
int keyIndex = 0;
// Support for external null selection item id
- Collection ids = getItemIds();
+ final Collection ids = getItemIds();
if (isNullSelectionAllowed() && getNullSelectionItemId() != null
&& !ids.contains(getNullSelectionItemId())) {
// Gets the option attribute values
- Object id = getNullSelectionItemId();
- String key = itemIdMapper.key(id);
- String caption = getItemCaption(id);
- Resource icon = getItemIcon(id);
+ final Object id = getNullSelectionItemId();
+ final String key = itemIdMapper.key(id);
+ final String caption = getItemCaption(id);
+ final Resource icon = getItemIcon(id);
// Paints option
target.startTag("so");
if (icon != null) {
target.endTag("so");
}
- Iterator i = getItemIds().iterator();
+ final Iterator i = getItemIds().iterator();
// Paints the available selection options from data source
while (i.hasNext()) {
// Gets the option attribute values
- Object id = i.next();
+ final Object id = i.next();
if (!isNullSelectionAllowed() && id != null
&& id.equals(getNullSelectionItemId())) {
// Remove item if it's the null selection item but null
// selection is not allowed
continue;
}
- String key = itemIdMapper.key(id);
- String caption = getItemCaption(id);
- Resource icon = getItemIcon(id); // Paints the option
+ final String key = itemIdMapper.key(id);
+ final String caption = getItemCaption(id);
+ final Resource icon = getItemIcon(id); // Paints the option
target.startTag("so");
if (icon != null) {
target.addAttribute("icon", icon);
// Try to set the property value
// New option entered (and it is allowed)
- String newitem = (String) variables.get("newitem");
+ final String newitem = (String) variables.get("newitem");
if (newitem != null && newitem.length() > 0) {
// Checks for readonly
try {
getContainerProperty(newitem,
getItemCaptionPropertyId()).setValue(newitem);
- } catch (Property.ConversionException ignored) {
+ } catch (final Property.ConversionException ignored) {
// The conversion exception is safely ignored, the
// caption is
// just missing
// Selection change
if (variables.containsKey("selected")) {
- String[] ka = (String[]) variables.get("selected");
+ final String[] ka = (String[]) variables.get("selected");
// Multiselect mode
if (isMultiSelect()) {
// TODO Optimize by adding repaintNotNeeded when applicable
// Converts the key-array to id-set
- LinkedList s = new LinkedList();
+ final LinkedList s = new LinkedList();
for (int i = 0; i < ka.length; i++) {
- Object id = itemIdMapper.get(ka[i]);
+ final Object id = itemIdMapper.get(ka[i]);
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
// Limits the deselection to the set of visible items
// (non-visible items can not be deselected)
- Collection visible = getVisibleItemIds();
+ final Collection visible = getVisibleItemIds();
if (visible != null) {
Set newsel = (Set) getValue();
if (newsel == null) {
if (ka.length == 0) {
// Allows deselection only if the deselected item is
// visible
- Object current = getValue();
- Collection visible = getVisibleItemIds();
+ final Object current = getValue();
+ final Collection visible = getVisibleItemIds();
if (visible != null && visible.contains(current)) {
setValue(null, true);
}
} else {
- Object id = itemIdMapper.get(ka[0]);
+ final Object id = itemIdMapper.get(ka[0]);
if (!isNullSelectionAllowed() && id == null) {
requestRepaint();
} else if (id != null
* @see com.itmill.toolkit.ui.AbstractField#getValue()
*/
public Object getValue() {
- Object retValue = super.getValue();
+ final Object retValue = super.getValue();
if (isMultiSelect()) {
} else if (retValue instanceof Collection) {
return new HashSet((Collection) retValue);
} else {
- Set s = new HashSet();
+ final Set s = new HashSet();
if (items.containsId(retValue)) {
s.add(retValue);
}
public boolean addContainerProperty(Object propertyId, Class type,
Object defaultValue) throws UnsupportedOperationException {
- boolean retval = items.addContainerProperty(propertyId, type,
+ final boolean retval = items.addContainerProperty(propertyId, type,
defaultValue);
if (retval && !(items instanceof Container.PropertySetChangeNotifier)) {
firePropertySetChange();
*/
public boolean removeAllItems() throws UnsupportedOperationException {
- boolean retval = items.removeAllItems();
+ final boolean retval = items.removeAllItems();
itemIdMapper.removeAll();
if (retval) {
setValue(null);
*/
public Object addItem() throws UnsupportedOperationException {
- Object retval = items.addItem();
+ final Object retval = items.addItem();
if (retval != null
&& !(items instanceof Container.ItemSetChangeNotifier)) {
fireItemSetChange();
*/
public Item addItem(Object itemId) throws UnsupportedOperationException {
- Item retval = items.addItem(itemId);
+ final Item retval = items.addItem(itemId);
if (retval != null
&& !(items instanceof Container.ItemSetChangeNotifier)) {
fireItemSetChange();
throws UnsupportedOperationException {
unselect(itemId);
- boolean retval = items.removeItem(itemId);
+ final boolean retval = items.removeItem(itemId);
itemIdMapper.remove(itemId);
if (retval && !(items instanceof Container.ItemSetChangeNotifier)) {
fireItemSetChange();
public boolean removeContainerProperty(Object propertyId)
throws UnsupportedOperationException {
- boolean retval = items.removeContainerProperty(propertyId);
+ final boolean retval = items.removeContainerProperty(propertyId);
if (retval && !(items instanceof Container.PropertySetChangeNotifier)) {
firePropertySetChange();
}
try {
((Container.ItemSetChangeNotifier) items)
.removeListener(this);
- } catch (ClassCastException ignored) {
+ } catch (final ClassCastException ignored) {
// Ignored
}
try {
((Container.PropertySetChangeNotifier) items)
.removeListener(this);
- } catch (ClassCastException ignored) {
+ } catch (final ClassCastException ignored) {
// Ignored
}
}
if (items != null) {
try {
((Container.ItemSetChangeNotifier) items).addListener(this);
- } catch (ClassCastException ignored) {
+ } catch (final ClassCastException ignored) {
// Ignored
}
try {
((Container.PropertySetChangeNotifier) items)
.addListener(this);
- } catch (ClassCastException ignored) {
+ } catch (final ClassCastException ignored) {
// Ignored
}
}
if (multiSelect != this.multiSelect) {
// Selection before mode change
- Object oldValue = getValue();
+ final Object oldValue = getValue();
this.multiSelect = multiSelect;
// Convert the value type
if (multiSelect) {
- Set s = new HashSet();
+ final Set s = new HashSet();
if (oldValue != null) {
s.add(oldValue);
}
setValue(s);
} else {
- Set s = (Set) oldValue;
+ final Set s = (Set) oldValue;
if (s == null || s.isEmpty()) {
setValue(null);
} else {
try {
caption = String.valueOf(((Container.Indexed) items)
.indexOfId(itemId));
- } catch (ClassCastException ignored) {
+ } catch (final ClassCastException ignored) {
}
break;
case ITEM_CAPTION_MODE_ITEM:
- Item i = getItem(itemId);
+ final Item i = getItem(itemId);
if (i != null) {
caption = i.toString();
}
break;
case ITEM_CAPTION_MODE_PROPERTY:
- Property p = getContainerProperty(itemId,
+ final Property p = getContainerProperty(itemId,
getItemCaptionPropertyId());
if (p != null) {
caption = p.toString();
* @return the Icon for the item or null, if not specified.
*/
public Resource getItemIcon(Object itemId) {
- Resource explicit = (Resource) itemIcons.get(itemId);
+ final Resource explicit = (Resource) itemIcons.get(itemId);
if (explicit != null) {
return explicit;
}
return null;
}
- Property ip = getContainerProperty(itemId, getItemIconPropertyId());
+ final Property ip = getContainerProperty(itemId,
+ getItemIconPropertyId());
if (ip == null) {
return null;
}
- Object icon = ip.getValue();
+ final Object icon = ip.getValue();
if (icon instanceof Resource) {
return (Resource) icon;
}
if (isMultiSelect()) {
return ((Set) getValue()).contains(itemId);
} else {
- Object value = getValue();
+ final Object value = getValue();
return itemId.equals(value == null ? getNullSelectionItemId()
: value);
}
public void select(Object itemId) {
if (!isSelected(itemId) && items.containsId(itemId)) {
if (isMultiSelect()) {
- Set s = new HashSet((Set) getValue());
+ final Set s = new HashSet((Set) getValue());
s.add(itemId);
setValue(s);
} else if (itemId.equals(getNullSelectionItemId())) {
public void unselect(Object itemId) {
if (isSelected(itemId)) {
if (isMultiSelect()) {
- Set s = new HashSet((Set) getValue());
+ final Set s = new HashSet((Set) getValue());
s.remove(itemId);
setValue(s);
} else {
protected void firePropertySetChange() {
if (propertySetEventListeners != null
&& !propertySetEventListeners.isEmpty()) {
- Container.PropertySetChangeEvent event = new PropertySetChangeEvent();
- Object[] listeners = propertySetEventListeners.toArray();
+ final Container.PropertySetChangeEvent event = new PropertySetChangeEvent();
+ final Object[] listeners = propertySetEventListeners.toArray();
for (int i = 0; i < listeners.length; i++) {
((Container.PropertySetChangeListener) listeners[i])
.containerPropertySetChange(event);
*/
protected void fireItemSetChange() {
if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) {
- Container.ItemSetChangeEvent event = new ItemSetChangeEvent();
- Object[] listeners = itemSetEventListeners.toArray();
+ final Container.ItemSetChangeEvent event = new ItemSetChangeEvent();
+ final Object[] listeners = itemSetEventListeners.toArray();
for (int i = 0; i < listeners.length; i++) {
((Container.ItemSetChangeListener) listeners[i])
.containerItemSetChange(event);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
// Date field
if (Date.class.isAssignableFrom(type)) {
- DateField df = new DateField();
+ final DateField df = new DateField();
df.setResolution(DateField.RESOLUTION_DAY);
return df;
}
// Boolean field
if (Boolean.class.isAssignableFrom(type)) {
- Button button = new Button();
+ final Button button = new Button();
button.setSwitchMode(true);
button.setImmediate(false);
return button;
*/
public Field createField(Item item, Object propertyId, Component uiContext) {
if (item != null && propertyId != null) {
- Field f = createField(item.getItemProperty(propertyId), uiContext);
+ final Field f = createField(item.getItemProperty(propertyId),
+ uiContext);
if (f instanceof AbstractComponent) {
((AbstractComponent) f).setCaption(propertyId.toString());
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
boolean state;
try {
state = ((Boolean) getValue()).booleanValue();
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
state = false;
}
target.addVariable(this, "state", state);
public void changeVariables(Object source, Map variables) {
if (variables.containsKey("state")) {
// Gets the new and old button states
- Boolean newValue = (Boolean) variables.get("state");
- Boolean oldValue = (Boolean) getValue();
+ final Boolean newValue = (Boolean) variables.get("state");
+ final Boolean oldValue = (Boolean) getValue();
if (isSwitchMode()) {
try {
BUTTON_CLICK_METHOD = ClickListener.class.getDeclaredMethod(
"buttonClick", new Class[] { ClickEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.ui;
import com.itmill.toolkit.data.Property;
-/**\r
- * \r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
*/\r
+\r
package com.itmill.toolkit.ui;\r
\r
import java.util.Collection;\r
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
*/
private static final long serialVersionUID = 4051323457293857333L;
- private ErrorMessage message;
+ private final ErrorMessage message;
/**
* Constructs a new event with a specified source component.
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
*/
private static final long serialVersionUID = 3257285812184692019L;
- private Component component;
+ private final Component component;
/**
* Creates a new attach event.
*/
private static final long serialVersionUID = 3618140052337930290L;
- private Component component;
+ private final Component component;
/**
* Creates a new detach event.
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
// Notify the listeners
if (repaintRequestListeners != null
&& !repaintRequestListeners.isEmpty()) {
- Object[] listeners = repaintRequestListeners.toArray();
- RepaintRequestEvent event = new RepaintRequestEvent(this);
+ final Object[] listeners = repaintRequestListeners.toArray();
+ final RepaintRequestEvent event = new RepaintRequestEvent(this);
for (int i = 0; i < listeners.length; i++) {
if (alreadyNotified == null) {
alreadyNotified = new LinkedList();
repaintRequestListenersNotified = true;
// Notify the parent
- Component parent = getParent();
+ final Component parent = getParent();
if (parent != null) {
parent.childRequestedRepaint(alreadyNotified);
}
}
if (isVisible()) {
- String type = getComponentType();
+ final String type = getComponentType();
if (type != null) {
if (!target.startTag(this, "component")) {
target.addAttribute("type", type);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
/**
* Custom layout slots containing the components.
*/
- private HashMap slots = new HashMap();
+ private final HashMap slots = new HashMap();
private String templateName;
* the location of the component.
*/
public void addComponent(Component c, String location) {
- Component old = (Component) slots.get(location);
+ final Component old = (Component) slots.get(location);
if (old != null) {
removeComponent(old);
}
target.addAttribute("template", templateName);
// Adds all items in all the locations
- for (Iterator i = slots.keySet().iterator(); i.hasNext();) {
+ for (final Iterator i = slots.keySet().iterator(); i.hasNext();) {
// Gets the (location,component)
- String location = (String) i.next();
- Component c = (Component) slots.get(location);
+ final String location = (String) i.next();
+ final Component c = (Component) slots.get(location);
if (c != null) {
// Writes the item
target.startTag("location");
// Gets the locations
String oldLocation = null;
String newLocation = null;
- for (Iterator i = slots.keySet().iterator(); i.hasNext();) {
- String location = (String) i.next();
- Component component = (Component) slots.get(location);
+ for (final Iterator i = slots.keySet().iterator(); i.hasNext();) {
+ final String location = (String) i.next();
+ final Component component = (Component) slots.get(location);
if (component == oldComponent) {
oldLocation = location;
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
super.paintContent(target);
// Adds the locale as attribute
- Locale l = getLocale();
+ final Locale l = getLocale();
if (l != null) {
target.addAttribute("locale", l.toString());
}
target.addAttribute("type", type);
// Gets the calendar
- Calendar calendar = getCalendar();
- Date currentDate = (Date) getValue();
+ final Calendar calendar = getCalendar();
+ final Date currentDate = (Date) getValue();
for (int r = resolution; r <= largestModifiable; r++) {
switch (r) {
.containsKey("msec"))) {
// Old and new dates
- Date oldDate = (Date) getValue();
+ final Date oldDate = (Date) getValue();
Date newDate = null;
// Gets the new date in parts
} else {
// Clone the calendar for date operation
- Calendar cal = getCalendar();
+ final Calendar cal = getCalendar();
// Make sure that meaningful values exists
// Use the previous value if some of the variables
* implemented interface.
*/
public String toString() {
- Date value = (Date) getValue();
+ final Date value = (Date) getValue();
if (value != null) {
return value.toString();
}
// Try to parse as string
try {
- SimpleDateFormat parser = new SimpleDateFormat();
- Date val = parser.parse(newValue.toString());
+ final SimpleDateFormat parser = new SimpleDateFormat();
+ final Date val = parser.parse(newValue.toString());
super.setValue(val, repaintIsNotNeeded);
- } catch (ParseException e) {
+ } catch (final ParseException e) {
throw new Property.ConversionException(e.getMessage());
}
}
}
// Clone the instance
- Calendar newCal = (Calendar) calendar.clone();
+ final Calendar newCal = (Calendar) calendar.clone();
// Assigns the current time tom calendar.
- Date currentDate = (Date) getValue();
+ final Date currentDate = (Date) getValue();
if (currentDate != null) {
newCal.setTime(currentDate);
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
}
// Params
- for (Iterator i = getParameterNames(); i.hasNext();) {
+ for (final Iterator i = getParameterNames(); i.hasNext();) {
target.startTag("embeddedparam");
- String key = (String) i.next();
+ final String key = (String) i.next();
target.addAttribute("name", key);
target.addAttribute("value", getParameter(key));
target.endTag("embeddedparam");
public void setSource(Resource source) {
if (source != null && !source.equals(this.source)) {
this.source = source;
- String mt = source.getMIMEType();
+ final String mt = source.getMIMEType();
if ((mt.substring(0, mt.indexOf("/")).equalsIgnoreCase("image"))) {
type = TYPE_IMAGE;
} else {
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.ui;
import java.util.Iterator;
target.addAttribute("orientation", "horizontal");
}
- String[] alignmentsArray = new String[components.size()];
+ final String[] alignmentsArray = new String[components.size()];
// Adds all items in all the locations
int index = 0;
- for (Iterator i = getComponentIterator(); i.hasNext();) {
- Component c = (Component) i.next();
+ for (final Iterator i = getComponentIterator(); i.hasNext();) {
+ final Component c = (Component) i.next();
if (c != null) {
target.startTag("cc");
if (c == expanded) {
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
/**
* Ordered list of property ids in this editor.
*/
- private LinkedList propertyIds = new LinkedList();
+ private final LinkedList propertyIds = new LinkedList();
/**
* Current buffered source exception.
/**
* Mapping from propertyName to corresponding field.
*/
- private HashMap fields = new HashMap();
+ private final HashMap fields = new HashMap();
/**
* Field factory for this form.
LinkedList problems = null;
// Try to commit all
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
try {
- Field f = ((Field) fields.get(i.next()));
+ final Field f = ((Field) fields.get(i.next()));
// Commit only non-readonly fields.
if (!f.isReadOnly()) {
f.commit();
}
- } catch (Buffered.SourceException e) {
+ } catch (final Buffered.SourceException e) {
if (problems == null) {
problems = new LinkedList();
}
}
// Commit problems
- Throwable[] causes = new Throwable[problems.size()];
+ final Throwable[] causes = new Throwable[problems.size()];
int index = 0;
- for (Iterator i = problems.iterator(); i.hasNext();) {
+ for (final Iterator i = problems.iterator(); i.hasNext();) {
causes[index++] = (Throwable) i.next();
}
- Buffered.SourceException e = new Buffered.SourceException(this, causes);
+ final Buffered.SourceException e = new Buffered.SourceException(this,
+ causes);
currentBufferedSourceException = e;
requestRepaint();
throw e;
LinkedList problems = null;
// Try to discard all changes
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
try {
((Field) fields.get(i.next())).discard();
- } catch (Buffered.SourceException e) {
+ } catch (final Buffered.SourceException e) {
if (problems == null) {
problems = new LinkedList();
}
}
// Discards problems occurred
- Throwable[] causes = new Throwable[problems.size()];
+ final Throwable[] causes = new Throwable[problems.size()];
int index = 0;
- for (Iterator i = problems.iterator(); i.hasNext();) {
+ for (final Iterator i = problems.iterator(); i.hasNext();) {
causes[index++] = (Throwable) i.next();
}
- Buffered.SourceException e = new Buffered.SourceException(this, causes);
+ final Buffered.SourceException e = new Buffered.SourceException(this,
+ causes);
currentBufferedSourceException = e;
requestRepaint();
throw e;
* here, we use the default one from the interface.
*/
public boolean isModified() {
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
- Field f = (Field) fields.get(i.next());
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
+ final Field f = (Field) fields.get(i.next());
if (f != null && f.isModified()) {
return true;
}
public void setReadThrough(boolean readThrough) {
if (readThrough != this.readThrough) {
this.readThrough = readThrough;
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
((Field) fields.get(i.next())).setReadThrough(readThrough);
}
}
public void setWriteThrough(boolean writeThrough) {
if (writeThrough != this.writeThrough) {
this.writeThrough = writeThrough;
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
((Field) fields.get(i.next())).setWriteThrough(writeThrough);
}
}
}
// Gets suitable field
- Field field = fieldFactory.createField(property, this);
+ final Field field = fieldFactory.createField(property, this);
if (field == null) {
return false;
}
+ caption.substring(1, caption.length());
}
field.setCaption(caption);
- } catch (Throwable ignored) {
+ } catch (final Throwable ignored) {
return false;
}
* @see com.itmill.toolkit.data.Item#getItemProperty(Object)
*/
public Property getItemProperty(Object id) {
- Field field = (Field) fields.get(id);
+ final Field field = (Field) fields.get(id);
if (field == null) {
return null;
}
- Property property = field.getPropertyDataSource();
+ final Property property = field.getPropertyDataSource();
if (property != null) {
return property;
*/
public boolean removeItemProperty(Object id) {
- Field field = (Field) fields.get(id);
+ final Field field = (Field) fields.get(id);
if (field != null) {
propertyIds.remove(id);
* (and only if) the return value is <code>true</code>.
*/
public boolean removeAllProperties() {
- Object[] properties = propertyIds.toArray();
+ final Object[] properties = propertyIds.toArray();
boolean success = true;
for (int i = 0; i < properties.length; i++) {
}
// Adds all the properties to this form
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
- Object id = i.next();
- Property property = itemDatasource.getItemProperty(id);
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
+ final Object id = i.next();
+ final Property property = itemDatasource.getItemProperty(id);
if (id != null && property != null) {
- Field f = fieldFactory.createField(itemDatasource, id, this);
+ final Field f = fieldFactory.createField(itemDatasource, id,
+ this);
if (f != null) {
f.setPropertyDataSource(property);
addField(id, f);
}
// Gets the old field
- Field oldField = (Field) fields.get(propertyId);
+ final Field oldField = (Field) fields.get(propertyId);
if (oldField == null) {
throw new IllegalArgumentException("Field with given propertyid '"
+ propertyId.toString() + "' can not be found.");
}
- Object value = oldField.getValue();
+ final Object value = oldField.getValue();
// Checks that the value exists and check if the select should
// be forced in multiselect mode
}
if (value != null && !found) {
if (value instanceof Collection) {
- for (Iterator it = ((Collection) value).iterator(); it
+ for (final Iterator it = ((Collection) value).iterator(); it
.hasNext();) {
- Object val = it.next();
+ final Object val = it.next();
found = false;
for (int i = 0; i < values.length && !found; i++) {
if (values[i] == val
}
// Creates the new field matching to old field parameters
- Select newField = new Select();
+ final Select newField = new Select();
if (isMultiselect) {
newField.setMultiSelect(true);
}
id = new Object();
newField.setNullSelectionItemId(id);
}
- Item item = newField.addItem(id);
+ final Item item = newField.addItem(id);
if (item != null) {
item.getItemProperty("desc").setValue(
descriptions[i].toString());
}
// Sets the property data source
- Property property = oldField.getPropertyDataSource();
+ final Property property = oldField.getPropertyDataSource();
oldField.setPropertyDataSource(null);
newField.setPropertyDataSource(property);
*/
public boolean isValid() {
boolean valid = true;
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
valid &= ((Field) fields.get(i.next())).isValid();
}
return valid;
* @see com.itmill.toolkit.data.Validatable#validate()
*/
public void validate() throws InvalidValueException {
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
((Field) fields.get(i.next())).validate();
}
}
*/
public void setReadOnly(boolean readOnly) {
super.setReadOnly(readOnly);
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
+ for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
((Field) fields.get(i.next())).setReadOnly(readOnly);
}
}
*/
protected void setInternalValue(Object newValue) {
// Stores the old value
- Object oldValue = propertyValue;
+ final Object oldValue = propertyValue;
// Sets the current Value
super.setInternalValue(newValue);
*/
public void setVisibleItemProperties(Collection visibleProperties) {
visibleItemProperties = visibleProperties;
- Object value = getValue();
+ final Object value = getValue();
setFormDataSource(value, getVisibleItemProperties());
}
* @see com.itmill.toolkit.ui.Component.Focusable#focus()
*/
public void focus() {
- Field f = getFirstField();
+ final Field f = getFirstField();
if (f != null) {
f.focus();
}
*/
public void setTabIndex(int tabIndex) {
super.setTabIndex(tabIndex);
- for (Iterator i = getItemPropertyIds().iterator(); i.hasNext();) {
+ for (final Iterator i = getItemPropertyIds().iterator(); i.hasNext();) {
(getField(i.next())).setTabIndex(tabIndex);
}
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.ui;
public class FormLayout extends OrderedLayout {
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2007 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
* Contains all items that are placed on the grid. These are components with
* grid area definition.
*/
- private LinkedList areas = new LinkedList();
+ private final LinkedList areas = new LinkedList();
/**
* Mapping from components to their respective areas.
*/
- private LinkedList components = new LinkedList();
+ private final LinkedList components = new LinkedList();
/**
* Mapping from components to alignments (horizontal + vertical).
}
// Creates the area
- Area area = new Area(component, column1, row1, column2, row2);
+ final Area area = new Area(component, column1, row1, column2, row2);
// Checks the validity of the coordinates
if (column2 < column1 || row2 < row1) {
// Inserts the component to right place at the list
// Respect top-down, left-right ordering
component.setParent(this);
- Iterator i = areas.iterator();
+ final Iterator i = areas.iterator();
int index = 0;
boolean done = false;
while (!done && i.hasNext()) {
- Area existingArea = (Area) i.next();
+ final Area existingArea = (Area) i.next();
if ((existingArea.row1 >= row1 && existingArea.column1 > column1)
|| existingArea.row1 > row1) {
areas.add(index, area);
* if <code>area</code> overlaps with any existing area.
*/
private void checkExistingOverlaps(Area area) throws OverlapsException {
- for (Iterator i = areas.iterator(); i.hasNext();) {
- Area existingArea = (Area) i.next();
+ for (final Iterator i = areas.iterator(); i.hasNext();) {
+ final Area existingArea = (Area) i.next();
if (existingArea.overlaps(area)) {
// Component not added, overlaps with existing component
throw new OverlapsException(existingArea);
area = new Area(component, cursorX, cursorY, cursorX, cursorY);
checkExistingOverlaps(area);
done = true;
- } catch (OverlapsException ignored) {
+ } catch (final OverlapsException ignored) {
space();
}
}
super.removeComponent(component);
Area area = null;
- for (Iterator i = areas.iterator(); area == null && i.hasNext();) {
- Area a = (Area) i.next();
+ for (final Iterator i = areas.iterator(); area == null && i.hasNext();) {
+ final Area a = (Area) i.next();
if (a.getComponent() == component) {
area = a;
}
public void removeComponent(int column, int row) {
// Finds the area
- for (Iterator i = areas.iterator(); i.hasNext();) {
- Area area = (Area) i.next();
+ for (final Iterator i = areas.iterator(); i.hasNext();) {
+ final Area area = (Area) i.next();
if (area.getColumn1() == column && area.getRow1() == row) {
removeComponent(area.getComponent());
return;
}
// Area iterator
- Iterator areaiterator = areas.iterator();
+ final Iterator areaiterator = areas.iterator();
// Current item to be processed (fetch first item)
Area area = areaiterator.hasNext() ? (Area) areaiterator.next() : null;
// Collects rowspan related information here
- HashMap cellUsed = new HashMap();
+ final HashMap cellUsed = new HashMap();
// Empty cell collector
int emptyCells = 0;
}
// Now proceed rendering current item
- int cols = (area.column2 - area.column1) + 1;
- int rows = (area.row2 - area.row1) + 1;
+ final int cols = (area.column2 - area.column1) + 1;
+ final int rows = (area.row2 - area.row1) + 1;
target.startTag("gc");
target.addAttribute("x", curx);
// Current column contains already an item,
// check if rowspan affects at current x,y position
- int rowspanDepth = ((Integer) cellUsed.get(new Integer(
- curx))).intValue();
+ final int rowspanDepth = ((Integer) cellUsed
+ .get(new Integer(curx))).intValue();
if (rowspanDepth >= cury) {
/**
* The column of the upper left corner cell of the area.
*/
- private int column1;
+ private final int column1;
/**
* The row of the upper left corner cell of the area.
*/
- private int row1;
+ private final int row1;
/**
* The column of the lower right corner cell of the area.
*/
- private int column2;
+ private final int column2;
/**
* The row of the lower right corner cell of the area.
*/
- private int row2;
+ private final int row2;
/**
* Component painted on the area.
*/
private static final long serialVersionUID = 3978144339870101561L;
- private Area existingArea;
+ private final Area existingArea;
/**
* Constructs an <code>OverlapsException</code>.
*/
private static final long serialVersionUID = 3618985589664592694L;
- private Area areaOutOfBounds;
+ private final Area areaOutOfBounds;
/**
* Constructs an <code>OoutOfBoundsException</code> with the specified
// Checks for overlaps
if (cols > columns) {
- for (Iterator i = areas.iterator(); i.hasNext();) {
- Area area = (Area) i.next();
+ for (final Iterator i = areas.iterator(); i.hasNext();) {
+ final Area area = (Area) i.next();
if (area.column2 >= columns) {
throw new OutOfBoundsException(area);
}
// Checks for overlaps
if (this.rows > rows) {
- for (Iterator i = areas.iterator(); i.hasNext();) {
- Area area = (Area) i.next();
+ for (final Iterator i = areas.iterator(); i.hasNext();) {
+ final Area area = (Area) i.next();
if (area.row2 >= rows) {
throw new OutOfBoundsException(area);
}
// Gets the locations
Area oldLocation = null;
Area newLocation = null;
- for (Iterator i = areas.iterator(); i.hasNext();) {
- Area location = (Area) i.next();
- Component component = location.getComponent();
+ for (final Iterator i = areas.iterator(); i.hasNext();) {
+ final Area location = (Area) i.next();
+ final Component component = location.getComponent();
if (component == oldComponent) {
oldLocation = location;
}
-/**\r
- * \r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
*/\r
+\r
package com.itmill.toolkit.ui;\r
\r
import java.util.Date;\r
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
VALUE_CHANGE_METHOD = Property.ValueChangeListener.class
.getDeclaredMethod("valueChange",
new Class[] { Property.ValueChangeEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
*/
private String stripTags(String xml) {
- StringBuffer res = new StringBuffer();
+ final StringBuffer res = new StringBuffer();
int processed = 0;
- int xmlLen = xml.length();
+ final int xmlLen = xml.length();
while (processed < xmlLen) {
int next = xml.indexOf('<', processed);
if (next < 0) {
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
}
// Target window name
- String name = getTargetName();
+ final String name = getTargetName();
if (name != null && name.length() > 0) {
target.addAttribute("name", name);
}
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.ui;
import java.util.Collection;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.ui;
import java.util.Collection;
-/**
- *
+/*
+@ITMillApache2LicenseForJavaFiles@
*/
+
package com.itmill.toolkit.ui;
import java.util.Collection;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
/**
* Mapping from components to alignments (horizontal + vertical).
*/
- private Map componentToAlignment = new HashMap();
+ private final Map componentToAlignment = new HashMap();
/**
* Contained component should be aligned horizontally to the left.
target.addAttribute("spacing", spacing);
}
- String[] alignmentsArray = new String[components.size()];
+ final String[] alignmentsArray = new String[components.size()];
// Adds all items in all the locations
int index = 0;
- for (Iterator i = components.iterator(); i.hasNext();) {
- Component c = (Component) i.next();
+ for (final Iterator i = components.iterator(); i.hasNext();) {
+ final Component c = (Component) i.next();
if (c != null) {
// Paint child component UIDL
c.paint(target);
// FIXME remove lines below and uncomment above
// Workaround to bypass IOrderedLayouts limitations (separate classes
// for different orientation + subtreecacing)
- Iterator it = getComponentIterator();
+ final Iterator it = getComponentIterator();
while (it.hasNext()) {
- Component c = (Component) it.next();
+ final Component c = (Component) it.next();
c.requestRepaint();
}
}
int oldLocation = -1;
int newLocation = -1;
int location = 0;
- for (Iterator i = components.iterator(); i.hasNext();) {
- Component component = (Component) i.next();
+ for (final Iterator i = components.iterator(); i.hasNext();) {
+ final Component component = (Component) i.next();
if (component == oldComponent) {
oldLocation = location;
}
public int getComponentAlignment(Component childComponent) {
- Integer bitMask = (Integer) componentToAlignment.get(childComponent);
+ final Integer bitMask = (Integer) componentToAlignment
+ .get(childComponent);
if (bitMask != null) {
return bitMask.intValue();
} else {
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
target.addVariable(this, "action", "");
target.startTag("actions");
- for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) {
- Action[] aa = ((Action.Handler) ahi.next()).getActions(null,
- this);
+ for (final Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) {
+ final Action[] aa = ((Action.Handler) ahi.next()).getActions(
+ null, this);
if (aa != null) {
for (int ai = 0; ai < aa.length; ai++) {
- Action a = aa[ai];
+ final Action a = aa[ai];
target.startTag("action");
- String akey = actionMapper.key(aa[ai]);
+ final String akey = actionMapper.key(aa[ai]);
target.addAttribute("key", akey);
if (a.getCaption() != null) {
target.addAttribute("caption", a.getCaption());
target.addAttribute("icon", a.getIcon());
}
if (a instanceof ShortcutAction) {
- ShortcutAction sa = (ShortcutAction) a;
+ final ShortcutAction sa = (ShortcutAction) a;
target.addAttribute("kc", sa.getKeyCode());
- int[] modifiers = sa.getModifiers();
+ final int[] modifiers = sa.getModifiers();
if (modifiers != null) {
- String[] smodifiers = new String[modifiers.length];
+ final String[] smodifiers = new String[modifiers.length];
for (int i = 0; i < modifiers.length; i++) {
smodifiers[i] = String
.valueOf(modifiers[i]);
super.changeVariables(source, variables);
// Get new size
- Integer newWidth = (Integer) variables.get("width");
- Integer newHeight = (Integer) variables.get("height");
+ final Integer newWidth = (Integer) variables.get("width");
+ final Integer newHeight = (Integer) variables.get("height");
if (newWidth != null && newWidth.intValue() != getWidth()) {
setWidth(newWidth.intValue());
// ensure units as we are reading pixels
}
// Scrolling
- Integer newScrollX = (Integer) variables.get("scrollleft");
- Integer newScrollY = (Integer) variables.get("scrolldown");
+ final Integer newScrollX = (Integer) variables.get("scrollleft");
+ final Integer newScrollY = (Integer) variables.get("scrolldown");
if (newScrollX != null && newScrollX.intValue() != getScrollOffsetX()) {
setScrollOffsetX(newScrollX.intValue());
}
// Actions
if (variables.containsKey("action")) {
- String key = (String) variables.get("action");
- Action action = (Action) actionMapper.get(key);
+ final String key = (String) variables.get("action");
+ final Action action = (Action) actionMapper.get(key);
if (action != null && actionHandlers != null) {
- for (Iterator i = actionHandlers.iterator(); i.hasNext();) {
+ for (final Iterator i = actionHandlers.iterator(); i.hasNext();) {
((Action.Handler) i.next())
.handleAction(action, this, this);
}
-/**\r
- * \r
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
*/\r
+\r
package com.itmill.toolkit.ui;\r
\r
import java.util.Date;\r
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
package com.itmill.toolkit.ui;
import com.itmill.toolkit.terminal.PaintException;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
*/
target.startTag("options");
- boolean paintNullSelection = needNullSelectOption
+ final boolean paintNullSelection = needNullSelectOption
&& (currentPage == 0 && (filterstring == null
|| filterstring.equals("") || filterstring.equals("-")));
}
options = options.subList(first, last);
}
- Iterator i = options.iterator();
+ final Iterator i = options.iterator();
// Paints the available selection options from data source
while (i.hasNext()) {
// Gets the option attribute values
- Object id = i.next();
- String key = itemIdMapper.key(id);
- String caption = getItemCaption(id);
- Resource icon = getItemIcon(id);
+ final Object id = i.next();
+ final String key = itemIdMapper.key(id);
+ final String caption = getItemCaption(id);
+ final Resource icon = getItemIcon(id);
// Paints the option
target.startTag("so");
prevfilterstring = filterstring;
filteredOptions = new LinkedList();
- for (Iterator it = items.iterator(); it.hasNext();) {
- Object itemId = it.next();
+ for (final Iterator it = items.iterator(); it.hasNext();) {
+ final Object itemId = it.next();
String caption = getItemCaption(itemId);
if (caption == null || caption.equals("")) {
continue;
// Try to set the property value
// New option entered (and it is allowed)
- String newitem = (String) variables.get("newitem");
+ final String newitem = (String) variables.get("newitem");
if (newitem != null && newitem.length() > 0) {
// Checks for readonly
try {
getContainerProperty(newitem,
getItemCaptionPropertyId()).setValue(newitem);
- } catch (Property.ConversionException ignored) {
+ } catch (final Property.ConversionException ignored) {
// The conversion exception is safely ignored, the
// caption is
// just missing
// Selection change
if (variables.containsKey("selected")) {
- String[] ka = (String[]) variables.get("selected");
+ final String[] ka = (String[]) variables.get("selected");
// Multiselect mode
if (isMultiSelect()) {
// TODO Optimize by adding repaintNotNeeded whan applicaple
// Converts the key-array to id-set
- LinkedList s = new LinkedList();
+ final LinkedList s = new LinkedList();
for (int i = 0; i < ka.length; i++) {
- Object id = itemIdMapper.get(ka[i]);
+ final Object id = itemIdMapper.get(ka[i]);
if (id != null && containsId(id)) {
s.add(id);
} else if (itemIdMapper.isNewIdKey(ka[i])
// Limits the deselection to the set of visible items
// (non-visible items can not be deselected)
- Collection visible = getVisibleItemIds();
+ final Collection visible = getVisibleItemIds();
if (visible != null) {
Set newsel = (Set) getValue();
if (newsel == null) {
if (ka.length == 0) {
// Allows deselection only if the deselected item is visible
- Object current = getValue();
- Collection visible = getVisibleItemIds();
+ final Object current = getValue();
+ final Collection visible = getVisibleItemIds();
if (visible != null && visible.contains(current)) {
setValue(null, true);
}
} else {
- Object id = itemIdMapper.get(ka[0]);
+ final Object id = itemIdMapper.get(ka[0]);
if (id != null && id.equals(getNullSelectionItemId())) {
setValue(null, true);
} else if (itemIdMapper.isNewIdKey(ka[0])) {
+/* \r
+@ITMillApache2LicenseForJavaFiles@\r
+ */\r
+\r
package com.itmill.toolkit.ui;\r
\r
import java.util.Map;\r
* (client-side implementation decides the increment, usually somewhere\r
* between 5-10% of slide range).\r
*/\r
- private boolean arrows = false;\r
+ private final boolean arrows = false;\r
\r
/**\r
* Default Slider constructor. Sets all values to defaults and the slide\r
if ((new Double(getValue().toString())).doubleValue() > max) {\r
super.setValue(new Double(max));\r
}\r
- } catch (ClassCastException e) {\r
+ } catch (final ClassCastException e) {\r
super.setValue(new Double(max));\r
}\r
requestRepaint();\r
if ((new Double(getValue().toString())).doubleValue() < min) {\r
super.setValue(new Double(min));\r
}\r
- } catch (ClassCastException e) {\r
+ } catch (final ClassCastException e) {\r
super.setValue(new Double(min));\r
}\r
requestRepaint();\r
*/\r
public void setValue(Double value, boolean repaintIsNotNeeded)\r
throws ValueOutOfBoundsException {\r
- double v = value.doubleValue();\r
+ final double v = value.doubleValue();\r
double newValue;\r
if (resolution > 0) {\r
// Round up to resolution\r
* \r
* @param visible\r
*//*\r
- * public void setArrows(boolean visible) { arrows = visible;\r
- * requestRepaint(); }\r
- */\r
+ * public void setArrows(boolean visible) { arrows = visible;\r
+ * requestRepaint(); }\r
+ */\r
\r
/*\r
* Does the slider have arrows?\r
* \r
* @return arrows visible\r
*//*\r
- * public boolean isArrowsVisible() { return arrows; }\r
- */\r
+ * public boolean isArrowsVisible() { return arrows; }\r
+ */\r
\r
public String getTag() {\r
return "slider";\r
*/\r
public void changeVariables(Object source, Map variables) {\r
if (variables.containsKey("value")) {\r
- Object value = variables.get("value");\r
- Double newValue = new Double(value.toString());\r
+ final Object value = variables.get("value");\r
+ final Double newValue = new Double(value.toString());\r
if (newValue != null && newValue != getValue()\r
&& !newValue.equals(getValue())) {\r
try {\r
setValue(newValue, true);\r
- } catch (ValueOutOfBoundsException e) {\r
+ } catch (final ValueOutOfBoundsException e) {\r
// Convert to nearest bound\r
double out = e.getValue().doubleValue();\r
if (out < min) {\r
*/\r
private static final long serialVersionUID = -6451298598644446340L;\r
\r
- private Double value;\r
+ private final Double value;\r
\r
/**\r
* Constructs an <code>ValueOutOfBoundsException</code> with the\r
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
- String position = pos + UNIT_SYMBOLS[posUnit];
+ final String position = pos + UNIT_SYMBOLS[posUnit];
target.addAttribute("position", position);
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
/**
* Linked list of component tabs.
*/
- private LinkedList tabs = new LinkedList();
+ private final LinkedList tabs = new LinkedList();
/**
* Tab -> caption mapping.
*/
- private Hashtable tabCaptions = new Hashtable();
+ private final Hashtable tabCaptions = new Hashtable();
/**
* Tab -> icon mapping .
*/
- private Hashtable tabIcons = new Hashtable();
+ private final Hashtable tabIcons = new Hashtable();
/**
* Selected tab.
*/
private Component selected = null;
- private KeyMapper keyMapper = new KeyMapper();
+ private final KeyMapper keyMapper = new KeyMapper();
/**
* Holds the value of property tabsHIdden.
* the container components are removed from.
*/
public void moveComponentsFrom(ComponentContainer source) {
- for (Iterator i = source.getComponentIterator(); i.hasNext();) {
- Component c = (Component) i.next();
+ for (final Iterator i = source.getComponentIterator(); i.hasNext();) {
+ final Component c = (Component) i.next();
String caption = null;
Resource icon = null;
if (TabSheet.class.isAssignableFrom(source.getClass())) {
target.startTag("tabs");
- for (Iterator i = getComponentIterator(); i.hasNext();) {
- Component c = (Component) i.next();
+ for (final Iterator i = getComponentIterator(); i.hasNext();) {
+ final Component c = (Component) i.next();
if (!c.isVisible()) {
continue;
}
target.startTag("tab");
- Resource icon = getTabIcon(c);
+ final Resource icon = getTabIcon(c);
if (icon != null) {
target.addAttribute("icon", icon);
}
- String caption = getTabCaption(c);
+ final String caption = getTabCaption(c);
if (!c.isEnabled()) {
target.addAttribute("disabled", true);
}
public void replaceComponent(Component oldComponent, Component newComponent) {
// Gets the captions
- String oldCaption = getTabCaption(oldComponent);
- Resource oldIcon = getTabIcon(oldComponent);
- String newCaption = getTabCaption(newComponent);
- Resource newIcon = getTabIcon(newComponent);
+ final String oldCaption = getTabCaption(oldComponent);
+ final Resource oldIcon = getTabIcon(oldComponent);
+ final String newCaption = getTabCaption(newComponent);
+ final Resource newIcon = getTabIcon(newComponent);
// Gets the locations
int oldLocation = -1;
int newLocation = -1;
int location = 0;
- for (Iterator i = tabs.iterator(); i.hasNext();) {
- Component component = (Component) i.next();
+ for (final Iterator i = tabs.iterator(); i.hasNext();) {
+ final Component component = (Component) i.next();
if (component == oldComponent) {
oldLocation = location;
SELECTED_TAB_CHANGE_METHOD = SelectedTabChangeListener.class
.getDeclaredMethod("selectedTabChange",
new Class[] { SelectedTabChangeEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
// Checks that the new visible columns contains no nulls and properties
// exist
- Collection properties = getContainerPropertyIds();
+ final Collection properties = getContainerPropertyIds();
for (int i = 0; i < visibleColumns.length; i++) {
if (visibleColumns[i] == null) {
throw new NullPointerException("Properties must be non-nulls");
// If this is called befor the constructor is finished, it might be
// uninitialized
- LinkedList newVC = new LinkedList();
+ final LinkedList newVC = new LinkedList();
for (int i = 0; i < visibleColumns.length; i++) {
newVC.add(visibleColumns[i]);
}
// Removes alignments, icons and headers from hidden columns
if (this.visibleColumns != null) {
- for (Iterator i = this.visibleColumns.iterator(); i.hasNext();) {
- Object col = i.next();
+ for (final Iterator i = this.visibleColumns.iterator(); i.hasNext();) {
+ final Object col = i.next();
if (!newVC.contains(col)) {
setColumnHeader(col, null);
setColumnAlignment(col, null);
if (columnHeaders == null) {
return null;
}
- String[] headers = new String[visibleColumns.size()];
+ final String[] headers = new String[visibleColumns.size()];
int i = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext(); i++) {
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext(); i++) {
headers[i] = (String) columnHeaders.get(it.next());
}
return headers;
this.columnHeaders.clear();
int i = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext()
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext()
&& i < columnHeaders.length; i++) {
this.columnHeaders.put(it.next(), columnHeaders[i]);
}
if (columnIcons == null) {
return null;
}
- Resource[] icons = new Resource[visibleColumns.size()];
+ final Resource[] icons = new Resource[visibleColumns.size()];
int i = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext(); i++) {
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext(); i++) {
icons[i] = (Resource) columnIcons.get(it.next());
}
this.columnIcons.clear();
int i = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext()
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext()
&& i < columnIcons.length; i++) {
this.columnIcons.put(it.next(), columnIcons[i]);
}
if (columnAlignments == null) {
return null;
}
- String[] alignments = new String[visibleColumns.size()];
+ final String[] alignments = new String[visibleColumns.size()];
int i = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext(); i++) {
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext(); i++) {
alignments[i++] = getColumnAlignment(it.next());
}
// Checks all alignments
for (int i = 0; i < columnAlignments.length; i++) {
- String a = columnAlignments[i];
+ final String a = columnAlignments[i];
if (a != null && !a.equals(ALIGN_LEFT) && !a.equals(ALIGN_CENTER)
&& !a.equals(ALIGN_RIGHT)) {
throw new IllegalArgumentException("Column " + i
}
// Resets the alignments
- HashMap newCA = new HashMap();
+ final HashMap newCA = new HashMap();
int i = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext()
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext()
&& i < columnAlignments.length; i++) {
newCA.put(it.next(), columnAlignments[i]);
}
* @return width of colun or -1 when value not set
*/
public int getColumnWidth(Object propertyId) {
- Integer value = (Integer) columnWidths.get(propertyId);
+ final Integer value = (Integer) columnWidths.get(propertyId);
if (value == null) {
return -1;
}
// Priorise index over id if indexes are supported
if (items instanceof Container.Indexed) {
- int index = getCurrentPageFirstItemIndex();
+ final int index = getCurrentPageFirstItemIndex();
Object id = null;
if (index >= 0 && index < size()) {
id = ((Container.Indexed) items).getIdByIndex(index);
try {
index = ((Container.Indexed) items)
.indexOfId(currentPageFirstItemId);
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
// If the table item container does not have index, we have to
// calculates the index by hand
* @return the specified column's alignment if it as one; null otherwise.
*/
public String getColumnAlignment(Object propertyId) {
- String a = (String) columnAlignments.get(propertyId);
+ final String a = (String) columnAlignments.get(propertyId);
return a == null ? ALIGN_LEFT : a;
}
if (columnOrder == null || !isColumnReorderingAllowed()) {
return;
}
- LinkedList newOrder = new LinkedList();
+ final LinkedList newOrder = new LinkedList();
for (int i = 0; i < columnOrder.length; i++) {
if (columnOrder[i] != null
&& visibleColumns.contains(columnOrder[i])) {
newOrder.add(columnOrder[i]);
}
}
- for (Iterator it = visibleColumns.iterator(); it.hasNext();) {
- Object columnId = it.next();
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext();) {
+ final Object columnId = it.next();
if (!newOrder.contains(columnId)) {
newOrder.add(columnId);
}
try {
currentPageFirstItemId = ((Container.Indexed) items)
.getIdByIndex(newIndex);
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
currentPageFirstItemId = null;
}
currentPageFirstItemIndex = newIndex;
public Object addItem(Object[] cells, Object itemId)
throws UnsupportedOperationException {
- Object[] cols = getVisibleColumns();
+ final Object[] cols = getVisibleColumns();
// Checks that a correct number of cells are given
if (cells.length != cols.length) {
// Page start index
if (variables.containsKey("firstvisible")) {
- Integer value = (Integer) variables.get("firstvisible");
+ final Integer value = (Integer) variables.get("firstvisible");
if (value != null) {
setCurrentPageFirstItemIndex(value.intValue());
}
// Actions
if (variables.containsKey("action")) {
- StringTokenizer st = new StringTokenizer((String) variables
+ final StringTokenizer st = new StringTokenizer((String) variables
.get("action"), ",");
if (st.countTokens() == 2) {
- Object itemId = itemIdMapper.get(st.nextToken());
- Action action = (Action) actionMapper.get(st.nextToken());
+ final Object itemId = itemIdMapper.get(st.nextToken());
+ final Action action = (Action) actionMapper.get(st.nextToken());
if (action != null && containsId(itemId)
&& actionHandlers != null) {
- for (Iterator i = actionHandlers.iterator(); i.hasNext();) {
+ for (final Iterator i = actionHandlers.iterator(); i
+ .hasNext();) {
((Action.Handler) i.next()).handleAction(action, this,
itemId);
}
boolean doSort = false;
if (!sortDisabled) {
if (variables.containsKey("sortcolumn")) {
- String colId = (String) variables.get("sortcolumn");
+ final String colId = (String) variables.get("sortcolumn");
if (colId != null && !"".equals(colId) && !"null".equals(colId)) {
- Object id = columnIdMap.get(colId);
+ final Object id = columnIdMap.get(colId);
setSortContainerPropertyId(id);
doSort = true;
}
}
if (variables.containsKey("sortascending")) {
- boolean state = ((Boolean) variables.get("sortascending"))
+ final boolean state = ((Boolean) variables.get("sortascending"))
.booleanValue();
if (state != sortAscending) {
setSortAscending(state);
if (isColumnCollapsingAllowed()) {
if (variables.containsKey("collapsedcolumns")) {
try {
- Object[] ids = (Object[]) variables.get("collapsedcolumns");
- for (Iterator it = visibleColumns.iterator(); it.hasNext();) {
+ final Object[] ids = (Object[]) variables
+ .get("collapsedcolumns");
+ for (final Iterator it = visibleColumns.iterator(); it
+ .hasNext();) {
setColumnCollapsed(it.next(), false);
}
for (int i = 0; i < ids.length; i++) {
setColumnCollapsed(columnIdMap.get(ids[i].toString()),
true);
}
- } catch (Exception ignored) {
+ } catch (final Exception ignored) {
}
}
}
if (isColumnReorderingAllowed()) {
if (variables.containsKey("columnorder")) {
try {
- Object[] ids = (Object[]) variables.get("columnorder");
+ final Object[] ids = (Object[]) variables
+ .get("columnorder");
for (int i = 0; i < ids.length; i++) {
ids[i] = columnIdMap.get(ids[i].toString());
}
setColumnOrder(ids);
- } catch (Exception ignored) {
+ } catch (final Exception ignored) {
}
}
}
}
// Initialize temps
- Object[] colids = getVisibleColumns();
- int cols = colids.length;
- int first = getCurrentPageFirstItemIndex();
+ final Object[] colids = getVisibleColumns();
+ final int cols = colids.length;
+ final int first = getCurrentPageFirstItemIndex();
int total = size();
- int pagelen = getPageLength();
- int colHeadMode = getColumnHeaderMode();
- boolean colheads = colHeadMode != COLUMN_HEADER_MODE_HIDDEN;
- boolean rowheads = getRowHeaderMode() != ROW_HEADER_MODE_HIDDEN;
- Object[][] cells = getVisibleCells();
- boolean iseditable = isEditable();
+ final int pagelen = getPageLength();
+ final int colHeadMode = getColumnHeaderMode();
+ final boolean colheads = colHeadMode != COLUMN_HEADER_MODE_HIDDEN;
+ final boolean rowheads = getRowHeaderMode() != ROW_HEADER_MODE_HIDDEN;
+ final Object[][] cells = getVisibleCells();
+ final boolean iseditable = isEditable();
int rows = cells[0].length;
if (!isNullSelectionAllowed() && getNullSelectionItemId() != null
}
// Visible column order
- Collection sortables = getSortableContainerPropertyIds();
- ArrayList visibleColOrder = new ArrayList();
- for (Iterator it = visibleColumns.iterator(); it.hasNext();) {
- Object columnId = it.next();
+ final Collection sortables = getSortableContainerPropertyIds();
+ final ArrayList visibleColOrder = new ArrayList();
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext();) {
+ final Object columnId = it.next();
if (!isColumnCollapsed(columnId)) {
visibleColOrder.add(columnIdMap.key(columnId));
}
target.addAttribute("vcolorder", visibleColOrder.toArray());
// Rows
- Set actionSet = new LinkedHashSet();
- boolean selectable = isSelectable();
- boolean[] iscomponent = new boolean[visibleColumns.size()];
+ final Set actionSet = new LinkedHashSet();
+ final boolean selectable = isSelectable();
+ final boolean[] iscomponent = new boolean[visibleColumns.size()];
int iscomponentIndex = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext()
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext()
&& iscomponentIndex < iscomponent.length;) {
- Object columnId = it.next();
- Class colType = getType(columnId);
+ final Object columnId = it.next();
+ final Class colType = getType(columnId);
iscomponent[iscomponentIndex++] = colType != null
&& Component.class.isAssignableFrom(colType);
}
target.startTag("rows");
for (int i = 0; i < cells[0].length; i++) {
- Object itemId = cells[CELL_ITEMID][i];
+ final Object itemId = cells[CELL_ITEMID][i];
if (!isNullSelectionAllowed() && getNullSelectionItemId() != null
&& itemId == getNullSelectionItemId()) {
// Actions
if (actionHandlers != null) {
- ArrayList keys = new ArrayList();
- for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) {
- Action[] aa = ((Action.Handler) ahi.next()).getActions(
- itemId, this);
+ final ArrayList keys = new ArrayList();
+ for (final Iterator ahi = actionHandlers.iterator(); ahi
+ .hasNext();) {
+ final Action[] aa = ((Action.Handler) ahi.next())
+ .getActions(itemId, this);
if (aa != null) {
for (int ai = 0; ai < aa.length; ai++) {
- String key = actionMapper.key(aa[ai]);
+ final String key = actionMapper.key(aa[ai]);
actionSet.add(aa[ai]);
keys.add(key);
}
// cells
int currentColumn = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext(); currentColumn++) {
- Object columnId = it.next();
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext(); currentColumn++) {
+ final Object columnId = it.next();
if (columnId == null || isColumnCollapsed(columnId)) {
continue;
}
if ((iscomponent[currentColumn] || iseditable)
&& Component.class.isInstance(cells[CELL_FIRSTCOL
+ currentColumn][i])) {
- Component c = (Component) cells[CELL_FIRSTCOL
+ final Component c = (Component) cells[CELL_FIRSTCOL
+ currentColumn][i];
if (c == null) {
target.addText("");
if (!actionSet.isEmpty()) {
target.addVariable(this, "action", "");
target.startTag("actions");
- for (Iterator it = actionSet.iterator(); it.hasNext();) {
- Action a = (Action) it.next();
+ for (final Iterator it = actionSet.iterator(); it.hasNext();) {
+ final Action a = (Action) it.next();
target.startTag("action");
if (a.getCaption() != null) {
target.addAttribute("caption", a.getCaption());
target.endTag("actions");
}
if (columnReorderingAllowed) {
- String[] colorder = new String[visibleColumns.size()];
+ final String[] colorder = new String[visibleColumns.size()];
int i = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext()
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext()
&& i < colorder.length;) {
colorder[i++] = columnIdMap.key(it.next());
}
}
// Available columns
if (columnCollapsingAllowed) {
- HashSet ccs = new HashSet();
- for (Iterator i = visibleColumns.iterator(); i.hasNext();) {
- Object o = i.next();
+ final HashSet ccs = new HashSet();
+ for (final Iterator i = visibleColumns.iterator(); i.hasNext();) {
+ final Object o = i.next();
if (isColumnCollapsed(o)) {
ccs.add(o);
}
}
- String[] collapsedkeys = new String[ccs.size()];
+ final String[] collapsedkeys = new String[ccs.size()];
int nextColumn = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext()
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext()
&& nextColumn < collapsedkeys.length;) {
- Object columnId = it.next();
+ final Object columnId = it.next();
if (isColumnCollapsed(columnId)) {
collapsedkeys[nextColumn++] = columnIdMap.key(columnId);
}
}
target.startTag("visiblecolumns");
int i = 0;
- for (Iterator it = visibleColumns.iterator(); it.hasNext(); i++) {
- Object columnId = it.next();
+ for (final Iterator it = visibleColumns.iterator(); it.hasNext(); i++) {
+ final Object columnId = it.next();
if (columnId != null) {
target.startTag("column");
target.addAttribute("cid", columnIdMap.key(columnId));
- String head = getColumnHeader(columnId);
+ final String head = getColumnHeader(columnId);
target.addAttribute("caption", (head != null ? head : ""));
if (isColumnCollapsed(columnId)) {
target.addAttribute("collapsed", true);
if (listenedProperties == null) {
listenedProperties = new LinkedList();
} else {
- for (Iterator i = listenedProperties.iterator(); i.hasNext();) {
+ for (final Iterator i = listenedProperties.iterator(); i.hasNext();) {
((Property.ValueChangeNotifier) i.next()).removeListener(this);
}
}
if (visibleComponents == null) {
visibleComponents = new LinkedList();
} else {
- for (Iterator i = visibleComponents.iterator(); i.hasNext();) {
+ for (final Iterator i = visibleComponents.iterator(); i.hasNext();) {
((Component) i.next()).setParent(null);
}
visibleComponents.clear();
}
// Collects the basic facts about the table page
- Object[] colids = getVisibleColumns();
- int cols = colids.length;
- int pagelen = getPageLength();
+ final Object[] colids = getVisibleColumns();
+ final int cols = colids.length;
+ final int pagelen = getPageLength();
int firstIndex = getCurrentPageFirstItemIndex();
int rows = size();
if (rows > 0 && firstIndex >= 0) {
}
}
- int headmode = getRowHeaderMode();
- boolean[] iscomponent = new boolean[cols];
+ final int headmode = getRowHeaderMode();
+ final boolean[] iscomponent = new boolean[cols];
for (int i = 0; i < cols; i++) {
iscomponent[i] = Component.class
.isAssignableFrom(getType(colids[i]));
if (cols > 0) {
for (int j = 0; j < cols; j++) {
Object value = null;
- Property p = getContainerProperty(id, colids[j]);
+ final Property p = getContainerProperty(id, colids[j]);
if (p != null) {
if (p instanceof Property.ValueChangeNotifier) {
((Property.ValueChangeNotifier) p)
// Assures that all the rows of the cell-buffer are valid
if (filledRows != cells[0].length) {
- Object[][] temp = new Object[cells.length][filledRows];
+ final Object[][] temp = new Object[cells.length][filledRows];
for (int i = 0; i < cells.length; i++) {
for (int j = 0; j < filledRows; j++) {
temp[i][j] = cells[i][j];
protected Object getPropertyValue(Object rowId, Object colId,
Property property) {
if (isEditable() && fieldFactory != null) {
- Field f = fieldFactory.createField(getContainerDataSource(), rowId,
- colId, this);
+ final Field f = fieldFactory.createField(getContainerDataSource(),
+ rowId, colId, this);
if (f != null) {
f.setPropertyDataSource(property);
return f;
super.attach();
if (visibleComponents != null) {
- for (Iterator i = visibleComponents.iterator(); i.hasNext();) {
+ for (final Iterator i = visibleComponents.iterator(); i.hasNext();) {
((Component) i.next()).attach();
}
}
super.detach();
if (visibleComponents != null) {
- for (Iterator i = visibleComponents.iterator(); i.hasNext();) {
+ for (final Iterator i = visibleComponents.iterator(); i.hasNext();) {
((Component) i.next()).detach();
}
}
* @see com.itmill.toolkit.data.Container#removeItem(Object)
*/
public boolean removeItem(Object itemId) {
- Object nextItemId = ((Container.Ordered) items).nextItemId(itemId);
- boolean ret = super.removeItem(itemId);
+ final Object nextItemId = ((Container.Ordered) items)
+ .nextItemId(itemId);
+ final boolean ret = super.removeItem(itemId);
if (ret && (itemId != null) && (itemId.equals(currentPageFirstItemId))) {
currentPageFirstItemId = nextItemId;
}
*/
public Collection getVisibleItemIds() {
- LinkedList visible = new LinkedList();
+ final LinkedList visible = new LinkedList();
- Object[][] cells = getVisibleCells();
+ final Object[][] cells = getVisibleCells();
for (int i = 0; i < cells[CELL_ITEMID].length; i++) {
visible.add(cells[CELL_ITEMID][i]);
}
*/
public void sort(Object[] propertyId, boolean[] ascending)
throws UnsupportedOperationException {
- Container c = getContainerDataSource();
+ final Container c = getContainerDataSource();
if (c instanceof Container.Sortable) {
- int pageIndex = getCurrentPageFirstItemIndex();
+ final int pageIndex = getCurrentPageFirstItemIndex();
((Container.Sortable) c).sort(propertyId, ascending);
setCurrentPageFirstItemIndex(pageIndex);
} else if (c != null) {
* @see com.itmill.toolkit.data.Container.Sortable#getSortableContainerPropertyIds()
*/
public Collection getSortableContainerPropertyIds() {
- Container c = getContainerDataSource();
+ final Container c = getContainerDataSource();
if (c instanceof Container.Sortable && !isSortDisabled()) {
return ((Container.Sortable) c).getSortableContainerPropertyIds();
} else {
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
}
// Adds the number of column and rows
- int c = getColumns();
- int r = getRows();
+ final int c = getColumns();
+ final int r = getRows();
if (c != 0) {
target.addAttribute("cols", String.valueOf(c));
}
* @see Format
*/
protected String getFormattedValue() {
- Object value = getValue();
+ final Object value = getValue();
if (format != null && value != null) {
try {
return format.format(value);
- } catch (IllegalArgumentException ignored) {
+ } catch (final IllegalArgumentException ignored) {
// Ignored exception
}
}
// Only do the setting if the string representation of the value
// has been updated
String newValue = (String) variables.get("text");
- String oldValue = getFormattedValue();
+ final String oldValue = getFormattedValue();
if (newValue != null
&& (oldValue == null || isNullSettingAllowed())
&& newValue.equals(getNullRepresentation())) {
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
"nodeExpand", new Class[] { ExpandEvent.class });
COLLAPSE_METHOD = CollapseListener.class.getDeclaredMethod(
"nodeCollapse", new Class[] { CollapseEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
e.printStackTrace();
throw new java.lang.RuntimeException(
boolean result = true;
// Initial stack
- Stack todo = new Stack();
+ final Stack todo = new Stack();
todo.add(startItemId);
// Expands recursively
while (!todo.isEmpty()) {
- Object id = todo.pop();
+ final Object id = todo.pop();
if (areChildrenAllowed(id) && !expandItem(id, false)) {
result = false;
}
boolean result = true;
// Initial stack
- Stack todo = new Stack();
+ final Stack todo = new Stack();
todo.add(startItemId);
// Collapse recursively
while (!todo.isEmpty()) {
- Object id = todo.pop();
+ final Object id = todo.pop();
if (areChildrenAllowed(id) && !collapseItem(id)) {
result = false;
}
// Collapses the nodes
if (variables.containsKey("collapse")) {
- String[] keys = (String[]) variables.get("collapse");
+ final String[] keys = (String[]) variables.get("collapse");
for (int i = 0; i < keys.length; i++) {
- Object id = itemIdMapper.get(keys[i]);
+ final Object id = itemIdMapper.get(keys[i]);
if (id != null && isExpanded(id)) {
expanded.remove(id);
fireCollapseEvent(id);
if (variables.containsKey("requestChildTree")) {
sendChildTree = true;
}
- String[] keys = (String[]) variables.get("expand");
+ final String[] keys = (String[]) variables.get("expand");
for (int i = 0; i < keys.length; i++) {
- Object id = itemIdMapper.get(keys[i]);
+ final Object id = itemIdMapper.get(keys[i]);
if (id != null) {
expandItem(id, sendChildTree);
}
// Actions
if (variables.containsKey("action")) {
- StringTokenizer st = new StringTokenizer((String) variables
+ final StringTokenizer st = new StringTokenizer((String) variables
.get("action"), ",");
if (st.countTokens() == 2) {
- Object itemId = itemIdMapper.get(st.nextToken());
- Action action = (Action) actionMapper.get(st.nextToken());
+ final Object itemId = itemIdMapper.get(st.nextToken());
+ final Action action = (Action) actionMapper.get(st.nextToken());
if (action != null && containsId(itemId)
&& actionHandlers != null) {
- for (Iterator i = actionHandlers.iterator(); i.hasNext();) {
+ for (final Iterator i = actionHandlers.iterator(); i
+ .hasNext();) {
((Action.Handler) i.next()).handleAction(action, this,
itemId);
}
}
// Initialize variables
- Set actionSet = new LinkedHashSet();
+ final Set actionSet = new LinkedHashSet();
String[] selectedKeys;
if (isMultiSelect()) {
selectedKeys = new String[((Set) getValue()).size()];
selectedKeys = new String[(getValue() == null ? 0 : 1)];
}
int keyIndex = 0;
- LinkedList expandedKeys = new LinkedList();
+ final LinkedList expandedKeys = new LinkedList();
// Iterates through hierarchical tree using a stack of iterators
- Stack iteratorStack = new Stack();
+ final Stack iteratorStack = new Stack();
Collection ids;
if (partialUpdate) {
ids = getChildren(expandedItemId);
while (!iteratorStack.isEmpty()) {
// Gets the iterator for current tree level
- Iterator i = (Iterator) iteratorStack.peek();
+ final Iterator i = (Iterator) iteratorStack.peek();
// If the level is finished, back to previous tree level
if (!i.hasNext()) {
// Adds the item on current level
else {
- Object itemId = i.next();
+ final Object itemId = i.next();
// Starts the item / node
- boolean isNode = areChildrenAllowed(itemId)
+ final boolean isNode = areChildrenAllowed(itemId)
&& hasChildren(itemId);
if (isNode) {
target.startTag("node");
// Adds the attributes
target.addAttribute("caption", getItemCaption(itemId));
- Resource icon = getItemIcon(itemId);
+ final Resource icon = getItemIcon(itemId);
if (icon != null) {
target.addAttribute("icon", getItemIcon(itemId));
}
- String key = itemIdMapper.key(itemId);
+ final String key = itemIdMapper.key(itemId);
target.addAttribute("key", key);
if (isSelected(itemId)) {
target.addAttribute("selected", true);
// Actions
if (actionHandlers != null) {
- ArrayList keys = new ArrayList();
- for (Iterator ahi = actionHandlers.iterator(); ahi
+ final ArrayList keys = new ArrayList();
+ for (final Iterator ahi = actionHandlers.iterator(); ahi
.hasNext();) {
- Action[] aa = ((Action.Handler) ahi.next()).getActions(
- itemId, this);
+ final Action[] aa = ((Action.Handler) ahi.next())
+ .getActions(itemId, this);
if (aa != null) {
for (int ai = 0; ai < aa.length; ai++) {
- String akey = actionMapper.key(aa[ai]);
+ final String akey = actionMapper.key(aa[ai]);
actionSet.add(aa[ai]);
keys.add(akey);
}
if (!actionSet.isEmpty()) {
target.addVariable(this, "action", "");
target.startTag("actions");
- for (Iterator i = actionSet.iterator(); i.hasNext();) {
- Action a = (Action) i.next();
+ for (final Iterator i = actionSet.iterator(); i.hasNext();) {
+ final Action a = (Action) i.next();
target.startTag("action");
if (a.getCaption() != null) {
target.addAttribute("caption", a.getCaption());
* boolean)
*/
public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) {
- boolean success = ((Container.Hierarchical) items).setChildrenAllowed(
- itemId, areChildrenAllowed);
+ final boolean success = ((Container.Hierarchical) items)
+ .setChildrenAllowed(itemId, areChildrenAllowed);
if (success) {
fireValueChange(false);
}
* Object)
*/
public boolean setParent(Object itemId, Object newParentId) {
- boolean success = ((Container.Hierarchical) items).setParent(itemId,
- newParentId);
+ final boolean success = ((Container.Hierarchical) items).setParent(
+ itemId, newParentId);
if (success) {
requestRepaint();
}
*/
public Collection getVisibleItemIds() {
- LinkedList visible = new LinkedList();
+ final LinkedList visible = new LinkedList();
// Iterates trough hierarchical tree using a stack of iterators
- Stack iteratorStack = new Stack();
- Collection ids = rootItemIds();
+ final Stack iteratorStack = new Stack();
+ final Collection ids = rootItemIds();
if (ids != null) {
iteratorStack.push(ids.iterator());
}
while (!iteratorStack.isEmpty()) {
// Gets the iterator for current tree level
- Iterator i = (Iterator) iteratorStack.peek();
+ final Iterator i = (Iterator) iteratorStack.peek();
// If the level is finished, back to previous tree level
if (!i.hasNext()) {
// Adds the item on current level
else {
- Object itemId = i.next();
+ final Object itemId = i.next();
visible.add(itemId);
-/**
- *
+/*
+@ITMillApache2LicenseForJavaFiles@
*/
+
package com.itmill.toolkit.ui;
import java.util.Collection;
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
/**
* Should the field be focused on next repaint?
*/
- private boolean focus = false;
+ private final boolean focus = false;
/**
* The tab order number of this field.
}
// Gets file properties
- String filename = upload.getContentName();
- String type = upload.getContentType();
+ final String filename = upload.getContentName();
+ final String type = upload.getContentType();
fireStarted(filename, type);
// Gets the output target stream
- OutputStream out = receiver.receiveUpload(filename, type);
+ final OutputStream out = receiver.receiveUpload(filename, type);
if (out == null) {
throw new RuntimeException(
"Error getting outputstream from upload receiver");
}
- InputStream in = upload.getStream();
+ final InputStream in = upload.getStream();
if (null == in) {
// No file, for instance non-existent filename in html upload
return;
}
- byte buffer[] = new byte[BUFFER_SIZE];
+ final byte buffer[] = new byte[BUFFER_SIZE];
int bytesRead = 0;
totalBytes = 0;
try {
endUpload();
requestRepaint();
- } catch (IOException e) {
+ } catch (final IOException e) {
// Download interrupted
fireUploadInterrupted(filename, type, totalBytes);
UPLOAD_SUCCEEDED_METHOD = SucceededListener.class
.getDeclaredMethod("uploadSucceeded",
new Class[] { SucceededEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException("Internal error");
}
/**
* Length of the received file.
*/
- private long length;
+ private final long length;
/**
* MIME type of the received file.
*/
- private String type;
+ private final String type;
/**
* Received file name.
*/
- private String filename;
+ private final String filename;
/**
*
* Serial generated by eclipse.
*/
private static final long serialVersionUID = -3984393770487403525L;
- private String filename;
- private String type;
+ private final String filename;
+ private final String type;
/**
*
* @see com.itmill.toolkit.ui.Component.Focusable#focus()
*/
public void focus() {
- Window w = getWindow();
+ final Window w = getWindow();
if (w != null) {
w.setFocusedComponent(this);
}
-/* *************************************************************************
-
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
package com.itmill.toolkit.ui;
handlers = uriHandlerList.toArray();
}
for (int i = 0; i < handlers.length; i++) {
- DownloadStream ds = ((URIHandler) handlers[i]).handleURI(
+ final DownloadStream ds = ((URIHandler) handlers[i]).handleURI(
context, relativeUri);
if (ds != null) {
if (result != null) {
throws PaintException {
// Sets the window name
- String name = getName();
+ final String name = getName();
target.addAttribute("name", name == null ? "" : name);
// Sets the window theme
- String theme = getTheme();
+ final String theme = getTheme();
target.addAttribute("theme", theme == null ? "" : theme);
if (modal) {
// Open requested resource
synchronized (openList) {
if (!openList.isEmpty()) {
- for (Iterator i = openList.iterator(); i.hasNext();) {
+ for (final Iterator i = openList.iterator(); i.hasNext();) {
((OpenResource) i.next()).paintContent(target);
}
openList.clear();
}
// Paint subwindows
- for (Iterator i = subwindows.iterator(); i.hasNext();) {
- Window w = (Window) i.next();
+ for (final Iterator i = subwindows.iterator(); i.hasNext();) {
+ final Window w = (Window) i.next();
w.paint(target);
}
// Paint notifications
if (notifications != null) {
target.startTag("notifications");
- for (Iterator it = notifications.iterator(); it.hasNext();) {
- Notification n = (Notification) it.next();
+ for (final Iterator it = notifications.iterator(); it.hasNext();) {
+ final Notification n = (Notification) it.next();
target.startTag("notification");
if (n.getCaption() != null) {
target.addAttribute("caption", n.getCaption());
try {
return new URL(application.getURL(), getName() + "/");
- } catch (MalformedURLException e) {
+ } catch (final MalformedURLException e) {
throw new RuntimeException("Internal problem, please report");
}
}
super.changeVariables(source, variables);
// Gets the focused component
- String focusedId = (String) variables.get("focused");
+ final String focusedId = (String) variables.get("focused");
if (focusedId != null) {
try {
- long id = Long.parseLong(focusedId);
+ final long id = Long.parseLong(focusedId);
focusedComponent = Window.getFocusableById(id);
- } catch (NumberFormatException ignored) {
+ } catch (final NumberFormatException ignored) {
// We ignore invalid focusable ids
}
}
// Positioning
- Integer positionx = (Integer) variables.get("positionx");
+ final Integer positionx = (Integer) variables.get("positionx");
if (positionx != null) {
- int x = positionx.intValue();
+ final int x = positionx.intValue();
setPositionX(x < 0 ? -1 : x);
}
- Integer positiony = (Integer) variables.get("positiony");
+ final Integer positiony = (Integer) variables.get("positiony");
if (positiony != null) {
- int y = positiony.intValue();
+ final int y = positiony.intValue();
setPositionY(y < 0 ? -1 : y);
}
// Scroll position
- Integer scrolltop = (Integer) variables.get("scrolltop");
+ final Integer scrolltop = (Integer) variables.get("scrolltop");
if (scrolltop != null) {
- int top = scrolltop.intValue();
+ final int top = scrolltop.intValue();
setScrollTop(top < 0 ? 0 : top);
}
- Integer scrollleft = (Integer) variables.get("scrollleft");
+ final Integer scrollleft = (Integer) variables.get("scrollleft");
if (scrollleft != null) {
- int left = scrollleft.intValue();
+ final int left = scrollleft.intValue();
setScrollLeft(left < 0 ? 0 : left);
}
// Closing
- Boolean close = (Boolean) variables.get("close");
+ final Boolean close = (Boolean) variables.get("close");
if (close != null && close.booleanValue()) {
setVisible(false);
fireClose();
* the Focused component or null if none is focused.
*/
public void setFocusedComponent(Component.Focusable focusable) {
- Application app = getApplication();
+ final Application app = getApplication();
if (app != null) {
app.setFocusedComponent(focusable);
focusedComponent = focusable;
* the focused component.
*/
public static long getNewFocusableId(Component.Focusable focusable) {
- long newId = ++lastUsedFocusableId;
- WeakReference ref = new WeakReference(focusable);
+ final long newId = ++lastUsedFocusableId;
+ final WeakReference ref = new WeakReference(focusable);
focusableComponents.put(new Long(newId), ref);
return newId;
}
* @return the focusable Id.
*/
public static Component.Focusable getFocusableById(long focusableId) {
- WeakReference ref = (WeakReference) focusableComponents.get(new Long(
- focusableId));
+ final WeakReference ref = (WeakReference) focusableComponents
+ .get(new Long(focusableId));
if (ref != null) {
- Object o = ref.get();
+ final Object o = ref.get();
if (o != null) {
return (Component.Focusable) o;
}
* the focusable Id to remove.
*/
public static void removeFocusableId(long focusableId) {
- Long id = new Long(focusableId);
- WeakReference ref = (WeakReference) focusableComponents.get(id);
+ final Long id = new Long(focusableId);
+ final WeakReference ref = (WeakReference) focusableComponents.get(id);
ref.clear();
focusableComponents.remove(id);
}
try {
WINDOW_CLOSE_METHOD = CloseListener.class.getDeclaredMethod(
"windowClose", new Class[] { CloseEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
+ } catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}