aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Laakso <jani.laakso@itmill.com>2007-04-18 05:32:44 +0000
committerJani Laakso <jani.laakso@itmill.com>2007-04-18 05:32:44 +0000
commit121ae54f709f887c95592b95bdc09977642b8c3b (patch)
tree389925b20e51a24428ae8bb625c651c3d9de6ca8
parent76d0a503c56656bafc68d732d245dd2dafe1b55d (diff)
downloadvaadin-framework-121ae54f709f887c95592b95bdc09977642b8c3b.tar.gz
vaadin-framework-121ae54f709f887c95592b95bdc09977642b8c3b.zip
Unified code style (indentation) based on default settings using Eclipse 3.2.
svn changeset:1256/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/Application.java335
-rw-r--r--src/com/itmill/toolkit/data/Buffered.java250
-rw-r--r--src/com/itmill/toolkit/data/BufferedValidatable.java63
-rw-r--r--src/com/itmill/toolkit/data/Container.java1380
-rw-r--r--src/com/itmill/toolkit/data/Item.java167
-rw-r--r--src/com/itmill/toolkit/data/Property.java778
-rw-r--r--src/com/itmill/toolkit/data/Validatable.java198
-rw-r--r--src/com/itmill/toolkit/data/Validator.java158
-rw-r--r--src/com/itmill/toolkit/data/util/BeanItem.java96
-rw-r--r--src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java398
-rw-r--r--src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java365
-rw-r--r--src/com/itmill/toolkit/data/util/FilesystemContainer.java511
-rw-r--r--src/com/itmill/toolkit/data/util/HierarchicalContainer.java194
-rw-r--r--src/com/itmill/toolkit/data/util/IndexedContainer.java2810
-rw-r--r--src/com/itmill/toolkit/data/util/MethodProperty.java575
-rw-r--r--src/com/itmill/toolkit/data/util/ObjectProperty.java683
-rw-r--r--src/com/itmill/toolkit/data/util/PropertysetItem.java538
-rw-r--r--src/com/itmill/toolkit/data/validator/CompositeValidator.java290
-rw-r--r--src/com/itmill/toolkit/data/validator/NullValidator.java120
-rw-r--r--src/com/itmill/toolkit/data/validator/StringLengthValidator.java135
-rw-r--r--src/com/itmill/toolkit/demo/Calc.java85
-rw-r--r--src/com/itmill/toolkit/demo/HelloWorld.java53
-rw-r--r--src/com/itmill/toolkit/demo/KeyboardShortcut.java22
-rw-r--r--src/com/itmill/toolkit/demo/QueryContainerDemo.java13
-rw-r--r--src/com/itmill/toolkit/demo/TableDemo.java15
-rw-r--r--src/com/itmill/toolkit/event/Action.java175
-rw-r--r--src/com/itmill/toolkit/event/EventRouter.java299
-rw-r--r--src/com/itmill/toolkit/event/ListenerMethod.java465
-rw-r--r--src/com/itmill/toolkit/event/MethodEventSource.java196
-rw-r--r--src/com/itmill/toolkit/event/ShortcutAction.java20
-rw-r--r--src/com/itmill/toolkit/service/ApplicationContext.java123
-rw-r--r--src/com/itmill/toolkit/service/FileTypeResolver.java188
-rw-r--r--src/com/itmill/toolkit/service/License.java78
-rw-r--r--src/com/itmill/toolkit/terminal/ApplicationResource.java96
-rw-r--r--src/com/itmill/toolkit/terminal/ClassResource.java148
-rw-r--r--src/com/itmill/toolkit/terminal/CompositeErrorMessage.java105
-rw-r--r--src/com/itmill/toolkit/terminal/DownloadStream.java174
-rw-r--r--src/com/itmill/toolkit/terminal/ErrorMessage.java85
-rw-r--r--src/com/itmill/toolkit/terminal/ExternalResource.java84
-rw-r--r--src/com/itmill/toolkit/terminal/FileResource.java136
-rw-r--r--src/com/itmill/toolkit/terminal/KeyMapper.java186
-rw-r--r--src/com/itmill/toolkit/terminal/PaintException.java95
-rw-r--r--src/com/itmill/toolkit/terminal/PaintTarget.java353
-rw-r--r--src/com/itmill/toolkit/terminal/Paintable.java186
-rw-r--r--src/com/itmill/toolkit/terminal/ParameterHandler.java95
-rw-r--r--src/com/itmill/toolkit/terminal/Resource.java54
-rw-r--r--src/com/itmill/toolkit/terminal/Scrollable.java118
-rw-r--r--src/com/itmill/toolkit/terminal/Sizeable.java153
-rw-r--r--src/com/itmill/toolkit/terminal/StreamResource.java162
-rw-r--r--src/com/itmill/toolkit/terminal/SystemError.java98
-rw-r--r--src/com/itmill/toolkit/terminal/Terminal.java109
-rw-r--r--src/com/itmill/toolkit/terminal/ThemeResource.java105
-rw-r--r--src/com/itmill/toolkit/terminal/URIHandler.java83
-rw-r--r--src/com/itmill/toolkit/terminal/UploadStream.java104
-rw-r--r--src/com/itmill/toolkit/terminal/UserError.java116
-rw-r--r--src/com/itmill/toolkit/terminal/VariableOwner.java195
-rw-r--r--src/com/itmill/toolkit/terminal/web/AjaxApplicationManager.java1255
-rw-r--r--src/com/itmill/toolkit/terminal/web/AjaxHttpUploadStream.java100
-rw-r--r--src/com/itmill/toolkit/terminal/web/AjaxPaintTarget.java1328
-rw-r--r--src/com/itmill/toolkit/terminal/web/AjaxVariableMap.java477
-rw-r--r--src/com/itmill/toolkit/terminal/web/ApplicationServlet.java300
-rw-r--r--src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java30
-rw-r--r--src/com/itmill/toolkit/terminal/web/DebugWindow.java297
-rw-r--r--src/com/itmill/toolkit/terminal/web/DirectoryThemeSource.java145
-rw-r--r--src/com/itmill/toolkit/terminal/web/HttpUploadStream.java100
-rw-r--r--src/com/itmill/toolkit/terminal/web/HttpVariableMap.java473
-rw-r--r--src/com/itmill/toolkit/terminal/web/JarThemeSource.java62
-rw-r--r--src/com/itmill/toolkit/terminal/web/Log.java183
-rw-r--r--src/com/itmill/toolkit/terminal/web/MultipartRequest.java1451
-rw-r--r--src/com/itmill/toolkit/terminal/web/ServletMultipartRequest.java200
-rw-r--r--src/com/itmill/toolkit/terminal/web/ServletThemeSource.java72
-rw-r--r--src/com/itmill/toolkit/terminal/web/Theme.java232
-rw-r--r--src/com/itmill/toolkit/terminal/web/ThemeFunctionLibrary.java84
-rw-r--r--src/com/itmill/toolkit/terminal/web/ThemeSource.java164
-rw-r--r--src/com/itmill/toolkit/terminal/web/UIDLTransformer.java534
-rw-r--r--src/com/itmill/toolkit/terminal/web/UIDLTransformerException.java69
-rw-r--r--src/com/itmill/toolkit/terminal/web/UIDLTransformerFactory.java273
-rw-r--r--src/com/itmill/toolkit/terminal/web/UIDLTransformerType.java88
-rw-r--r--src/com/itmill/toolkit/terminal/web/WebApplicationContext.java54
-rw-r--r--src/com/itmill/toolkit/terminal/web/WebBrowser.java586
-rw-r--r--src/com/itmill/toolkit/terminal/web/WebBrowserProbe.java23
-rw-r--r--src/com/itmill/toolkit/terminal/web/WebPaintTarget.java583
-rw-r--r--src/com/itmill/toolkit/terminal/web/XSLReader.java276
-rw-r--r--src/com/itmill/toolkit/ui/AbstractComponent.java669
-rw-r--r--src/com/itmill/toolkit/ui/AbstractComponentContainer.java189
-rw-r--r--src/com/itmill/toolkit/ui/AbstractField.java1806
-rw-r--r--src/com/itmill/toolkit/ui/BaseFieldFactory.java104
-rw-r--r--src/com/itmill/toolkit/ui/Button.java282
-rw-r--r--src/com/itmill/toolkit/ui/Component.java355
-rw-r--r--src/com/itmill/toolkit/ui/ComponentContainer.java333
-rw-r--r--src/com/itmill/toolkit/ui/CustomComponent.java244
-rw-r--r--src/com/itmill/toolkit/ui/CustomLayout.java173
-rw-r--r--src/com/itmill/toolkit/ui/DateField.java774
-rw-r--r--src/com/itmill/toolkit/ui/Embedded.java282
-rw-r--r--src/com/itmill/toolkit/ui/Field.java113
-rw-r--r--src/com/itmill/toolkit/ui/FieldFactory.java106
-rw-r--r--src/com/itmill/toolkit/ui/Form.java426
-rw-r--r--src/com/itmill/toolkit/ui/FrameWindow.java425
-rw-r--r--src/com/itmill/toolkit/ui/GridLayout.java496
-rw-r--r--src/com/itmill/toolkit/ui/Label.java453
-rw-r--r--src/com/itmill/toolkit/ui/Layout.java53
-rw-r--r--src/com/itmill/toolkit/ui/Link.java206
-rw-r--r--src/com/itmill/toolkit/ui/OrderedLayout.java169
-rw-r--r--src/com/itmill/toolkit/ui/Panel.java257
-rw-r--r--src/com/itmill/toolkit/ui/ProgressIndicator.java173
-rw-r--r--src/com/itmill/toolkit/ui/Select.java202
-rw-r--r--src/com/itmill/toolkit/ui/TabSheet.java278
-rw-r--r--src/com/itmill/toolkit/ui/Table.java4545
-rw-r--r--src/com/itmill/toolkit/ui/TextField.java328
-rw-r--r--src/com/itmill/toolkit/ui/Tree.java491
-rw-r--r--src/com/itmill/toolkit/ui/Upload.java371
-rw-r--r--src/com/itmill/toolkit/ui/Window.java236
-rw-r--r--src/com/itmill/toolkit/ui/select/ContainsFilter.java10
-rw-r--r--src/com/itmill/toolkit/ui/select/StartsWithFilter.java9
114 files changed, 20400 insertions, 18413 deletions
diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java
index 27b2a2c703..4b08b4579d 100644
--- a/src/com/itmill/toolkit/Application.java
+++ b/src/com/itmill/toolkit/Application.java
@@ -63,11 +63,11 @@ import java.net.URL;
* As mentioned, all IT Mill Toolkit applications must inherit this class.
* However, this is almost all of what one needs to do to create a fully
* functional application. The only thing a class inheriting the
- * <code>Application</code> needs to do is implement the <code>init</code> method
- * where it creates the windows it needs to perform its function. Note that all
- * applications must have at least one window: the main window. The first
- * unnamed window constructed by an application automatically becomes the main
- * window which behaves just like other windows with one exception: when
+ * <code>Application</code> needs to do is implement the <code>init</code>
+ * method where it creates the windows it needs to perform its function. Note
+ * that all applications must have at least one window: the main window. The
+ * first unnamed window constructed by an application automatically becomes the
+ * main window which behaves just like other windows with one exception: when
* accessing windows using URLs the main window corresponds to the application
* URL whereas other windows correspond to a URL gotten by catenating the
* window's name to the application URL.
@@ -106,78 +106,78 @@ import java.net.URL;
*/
public abstract class Application implements URIHandler, Terminal.ErrorListener {
- /**
- * Random window name generator.
+ /**
+ * Random window name generator.
*/
private static Random nameGenerator = new Random();
- /**
- * Application context the application is running in.
+ /**
+ * Application context the application is running in.
*/
private ApplicationContext context;
- /**
- * The current user or <code>null</code> if no user has logged in.
+ /**
+ * The current user or <code>null</code> if no user has logged in.
*/
private Object user;
- /**
- * Mapping from window name to window instance.
+ /**
+ * Mapping from window name to window instance.
*/
private Hashtable windows = new Hashtable();
- /**
- * Main window of the application.
+ /**
+ * Main window of the application.
*/
private Window mainWindow = null;
- /**
- * The application's URL.
+ /**
+ * The application's URL.
*/
private URL applicationUrl;
- /**
- * Name of the theme currently used by the application.
+ /**
+ * Name of the theme currently used by the application.
*/
private String theme = null;
- /**
- * Application status.
+ /**
+ * Application status.
*/
private boolean applicationIsRunning = false;
- /**
- * Application properties.
+ /**
+ * Application properties.
*/
private Properties properties;
- /**
- * Default locale of the application.
+ /**
+ * Default locale of the application.
*/
private Locale locale;
- /**
- * List of listeners listening user changes.
+ /**
+ * List of listeners listening user changes.
*/
private LinkedList userChangeListeners = null;
- /**
- * Window attach listeners.
+ /**
+ * Window attach listeners.
*/
private LinkedList windowAttachListeners = null;
- /**
- * Window detach listeners.
+ /**
+ * Window detach listeners.
*/
private LinkedList windowDetachListeners = null;
- /**
- * License for running this application.
+ /**
+ * License for running this application.
*/
private License license = null;
- /**
- * Application resource mapping: key <-> resource.
+ /**
+ * Application resource mapping: key <-> resource.
*/
private Hashtable resourceKeyMap = new Hashtable();
@@ -195,8 +195,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* <p>
- * Gets a window by name. Returns <code>null</code> if the application is not
- * running or it does not contain a window corresponding to the name.
+ * Gets a window by name. Returns <code>null</code> if the application is
+ * not running or it does not contain a window corresponding to the name.
* </p>
*
* @param name
@@ -214,7 +214,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
return window;
}
-
+
/**
* Adds a new window to the application.
*
@@ -288,7 +288,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
/**
- * Removes the specified window from the application.
+ * Removes the specified window from the application.
*
* @param window
* the window to be removed.
@@ -329,13 +329,14 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* <p>
- * Sets the user of the application instance. An application instance may have
- * a user associated to it. This can be set in login procedure or application initialization.
+ * Sets the user of the application instance. An application instance may
+ * have a user associated to it. This can be set in login procedure or
+ * application initialization.
* </p>
* <p>
- * A component performing the user login procedure can assign the user property
- * of the application and make the user object available to other components
- * of the application.
+ * A component performing the user login procedure can assign the user
+ * property of the application and make the user object available to other
+ * components of the application.
* </p>
*
* @param user
@@ -367,17 +368,17 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
/**
- * Ends the Application. In effect this will cause the application
- * stop returning any windows when asked.
+ * Ends the Application. In effect this will cause the application stop
+ * returning any windows when asked.
*/
public void close() {
applicationIsRunning = false;
}
/**
- * Starts the application on the given URL.After this call the
- * application corresponds to the given URL and it will return
- * windows when asked for them.
+ * Starts the application on the given URL.After this call the application
+ * corresponds to the given URL and it will return windows when asked for
+ * them.
*
* @param applicationUrl
* the URL the application should respond to.
@@ -417,18 +418,19 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* <p>
- * Main initializer of the application. The <code>init</code> method is called by the
- * framework when the application is started, and it should perform whatever
- * initialization operations the application needs, such as creating windows
- * and adding components to them.
+ * Main initializer of the application. The <code>init</code> method is
+ * called by the framework when the application is started, and it should
+ * perform whatever initialization operations the application needs, such as
+ * creating windows and adding components to them.
* </p>
*/
public abstract void init();
/**
- * Gets the application's theme. The application's theme is the default theme
- * used by all the windows in it that do not explicitly specify a theme.
- * If the application theme is not explicitly set, the <code>null</code> is returned.
+ * Gets the application's theme. The application's theme is the default
+ * theme used by all the windows in it that do not explicitly specify a
+ * theme. If the application theme is not explicitly set, the
+ * <code>null</code> is returned.
*
* @return the name of the application's theme.
*/
@@ -437,11 +439,12 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
/**
- * Sets the application's theme.
+ * Sets the application's theme.
* <p>
- * Note that this theme can be overridden by the windows. <code>null</code>
+ * Note that this theme can be overridden by the windows. <code>null</code>
* implies the default terminal theme.
* </p>
+ *
* @param theme
* the new theme for this application.
*/
@@ -479,10 +482,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* <p>
- * Sets the mainWindow. If the main window is not explicitly set, the main window
- * defaults to first created window. Setting window as a main window of this
- * application also adds the window to this application.
+ * Sets the mainWindow. If the main window is not explicitly set, the main
+ * window defaults to first created window. Setting window as a main window
+ * of this application also adds the window to this application.
* </p>
+ *
* @param mainWindow
* the mainWindow to set.
*/
@@ -516,10 +520,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
/**
- * Adds new resource to the application. The resource can be accessed
- * by the user of the application.
+ * Adds new resource to the application. The resource can be accessed by the
+ * user of the application.
+ *
* @param resource
- * the resource to add.
+ * the resource to add.
*/
public void addResource(ApplicationResource resource) {
@@ -535,10 +540,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
keyResourceMap.put(key, resource);
}
- /**
- * Removes the resource from the application.
+ /**
+ * Removes the resource from the application.
+ *
* @param resource
- * the resource to remove.
+ * the resource to remove.
*/
public void removeResource(ApplicationResource resource) {
Object key = resourceKeyMap.get(resource);
@@ -549,10 +555,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
/**
- * Gets the relative uri of the resource.
- * @param resource
- * the resource to get relative location.
- * @return the relative uri of the resource.
+ * Gets the relative uri of the resource.
+ *
+ * @param resource
+ * the resource to get relative location.
+ * @return the relative uri of the resource.
*/
public String getRelativeLocation(ApplicationResource resource) {
@@ -574,7 +581,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
* @see com.itmill.toolkit.terminal.URIHandler#handleURI(URL, String)
*/
public DownloadStream handleURI(URL context, String relativeUri) {
-
+
// If the relative uri is null, we are ready
if (relativeUri == null)
return null;
@@ -626,9 +633,10 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
return null;
}
- /**
- * Gets the default locale for this application.
- * @return the locale of this application.
+ /**
+ * Gets the default locale for this application.
+ *
+ * @return the locale of this application.
*/
public Locale getLocale() {
if (this.locale != null)
@@ -638,15 +646,19 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Sets the default locale for this application.
- * @param locale the Locale object.
- *
+ *
+ * @param locale
+ * the Locale object.
+ *
*/
public void setLocale(Locale locale) {
this.locale = locale;
}
/**
- * <p>An event that characterizes a change in the current selection.</p>
+ * <p>
+ * An event that characterizes a change in the current selection.
+ * </p>
* Application user change event sent when the setUser is called to change
* the current user of the application.
*
@@ -661,21 +673,25 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
*/
private static final long serialVersionUID = 3544951069307188281L;
- /**
- * New user of the application.
+ /**
+ * New user of the application.
*/
private Object newUser;
- /**
- * Previous user of the application.
+ /**
+ * Previous user of the application.
*/
private Object prevUser;
- /**
+ /**
* Contructor for user change event.
- * @param source the application source.
- * @param newUser the new User.
- * @param prevUser the previous User.
+ *
+ * @param source
+ * the application source.
+ * @param newUser
+ * the new User.
+ * @param prevUser
+ * the previous User.
*/
public UserChangeEvent(Application source, Object newUser,
Object prevUser) {
@@ -684,8 +700,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
this.prevUser = prevUser;
}
- /**
+ /**
* Gets the new user of the application.
+ *
* @return the new User.
*/
public Object getNewUser() {
@@ -694,8 +711,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Gets the previous user of the application.
- * @return the previous Toolkit user, if user has not changed
- * ever on application it returns <code>null</code>
+ *
+ * @return the previous Toolkit user, if user has not changed ever on
+ * application it returns <code>null</code>
*/
public Object getPreviousUser() {
return prevUser;
@@ -703,6 +721,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Gets the application where the user change occurred.
+ *
* @return the Application.
*/
public Application getApplication() {
@@ -711,7 +730,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
/**
- * The <code>UserChangeListener</code> interface for listening application user changes.
+ * The <code>UserChangeListener</code> interface for listening application
+ * user changes.
*
* @version
* @VERSION@
@@ -720,18 +740,21 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
public interface UserChangeListener extends EventListener {
/**
- * The <code>applicationUserChanged</code> method Invoked when the application user has changed.
- * @param event
- * the change event.
+ * The <code>applicationUserChanged</code> method Invoked when the
+ * application user has changed.
+ *
+ * @param event
+ * the change event.
*/
public void applicationUserChanged(Application.UserChangeEvent event);
}
/**
* Adds the user change listener.
+ *
* @param listener
- * the user change listener to add.
- */
+ * the user change listener to add.
+ */
public void addListener(UserChangeListener listener) {
if (userChangeListeners == null)
userChangeListeners = new LinkedList();
@@ -740,8 +763,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Removes the user change listener.
+ *
* @param listener
- * the user change listener to remove.
+ * the user change listener to remove.
*/
public void removeListener(UserChangeListener listener) {
if (userChangeListeners == null)
@@ -751,8 +775,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
userChangeListeners = null;
}
- /**
- * Window detach event.
+ /**
+ * Window detach event.
*/
public class WindowDetachEvent extends EventObject {
@@ -776,14 +800,16 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Gets the detached window.
+ *
* @return the detached window.
*/
public Window getWindow() {
return window;
}
- /**
- * Gets the application from which the window was detached.
+ /**
+ * Gets the application from which the window was detached.
+ *
* @return the Application.
*/
public Application getApplication() {
@@ -791,8 +817,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
}
- /**
- * Window attach event.
+ /**
+ * Window attach event.
*/
public class WindowAttachEvent extends EventObject {
@@ -814,8 +840,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
this.window = window;
}
- /**
+ /**
* Gets the attached window.
+ *
* @return the attached window.
*/
public Window getWindow() {
@@ -824,6 +851,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Gets the application to which the window was attached.
+ *
* @return the Application.
*/
public Application getApplication() {
@@ -831,36 +859,39 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
}
- /**
- * Window attach listener interface.
+ /**
+ * Window attach listener interface.
*/
public interface WindowAttachListener {
- /**
+ /**
* Window attached
- * @param event
- * the window attach event.
+ *
+ * @param event
+ * the window attach event.
*/
public void windowAttached(WindowAttachEvent event);
}
- /**
- * Window detach listener interface.
+ /**
+ * Window detach listener interface.
*/
public interface WindowDetachListener {
- /**
+ /**
* Window detached.
- * @param event
- * the window detach event.
+ *
+ * @param event
+ * the window detach event.
*/
public void windowDetached(WindowDetachEvent event);
}
/**
* Adds the window attach listener.
- * @param listener
- * the window attach listener to add.
+ *
+ * @param listener
+ * the window attach listener to add.
*/
public void addListener(WindowAttachListener listener) {
if (windowAttachListeners == null)
@@ -870,8 +901,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Adds the window detach listener.
- * @param listener
- * the window detach listener to add.
+ *
+ * @param listener
+ * the window detach listener to add.
*/
public void addListener(WindowDetachListener listener) {
if (windowDetachListeners == null)
@@ -881,8 +913,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Removes the window attach listener.
+ *
* @param listener
- * the window attach listener to remove.
+ * the window attach listener to remove.
*/
public void removeListener(WindowAttachListener listener) {
if (windowAttachListeners != null) {
@@ -892,10 +925,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
}
- /**
+ /**
* Removes the window detach listener.
- * @param listener
- * the window detach listener to remove.
+ *
+ * @param listener
+ * the window detach listener to remove.
*/
public void removeListener(WindowDetachListener listener) {
if (windowDetachListeners != null) {
@@ -906,13 +940,14 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
/**
- * Returns the URL user is redirected to on application close.If the URL
- * is <code>null</code>, the application is closed normally as defined by
+ * Returns the URL user is redirected to on application close.If the URL is
+ * <code>null</code>, the application is closed normally as defined by
* the application running environment.
* <p>
- * Desctop application just closes the application window and web-application redirects
- * the browser to application main URL.
+ * Desctop application just closes the application window and
+ * web-application redirects the browser to application main URL.
* </p>
+ *
* @return the URL.
*/
public String getLogoutURL() {
@@ -920,10 +955,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
}
/**
- * Sets the URL user is redirected to on application close. If the URL is <code>null</code>,
- * the application is closed normally as defined by the application running environment:
- * Desctop application just closes the application window and web-application redirects
- * the browser to application main URL.
+ * Sets the URL user is redirected to on application close. If the URL is
+ * <code>null</code>, the application is closed normally as defined by
+ * the application running environment: Desctop application just closes the
+ * application window and web-application redirects the browser to
+ * application main URL.
*
* @param logoutURL
* the logoutURL to set.
@@ -932,18 +968,20 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
this.logoutURL = logoutURL;
}
- /**
+ /**
* <p>
- * Invoked by the terminal on any exception that occurs in application and is thrown by
- * the <code>setVariable</code> to the terminal. The default implementation sets
- * the exceptions as <code>ComponentErrors</code> to the component that initiated the exception.
+ * Invoked by the terminal on any exception that occurs in application and
+ * is thrown by the <code>setVariable</code> to the terminal. The default
+ * implementation sets the exceptions as <code>ComponentErrors</code> to
+ * the component that initiated the exception.
* </p>
- * <p>
- * You can safely override this method in your application in order to direct the errors
- * to some other destination (for example log).
+ * <p>
+ * You can safely override this method in your application in order to
+ * direct the errors to some other destination (for example log).
* </p>
- * @param event
- * the change event.
+ *
+ * @param event
+ * the change event.
* @see com.itmill.toolkit.terminal.Terminal.ErrorListener#terminalError(com.itmill.toolkit.terminal.Terminal.ErrorEvent)
*/
public void terminalError(Terminal.ErrorEvent event) {
@@ -975,6 +1013,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
* The application context is the environment where the application is
* running in.
* </p>
+ *
* @return the application context.
*/
public ApplicationContext getContext() {
@@ -984,10 +1023,12 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Gets the license this application is running on.
* <p>
- * The license is initialized by the <code>ApplicationServlet</code> class before application
- * is started. The license-file can not be found in <code>WEB-INF/itmill-toolkit-license.xml</code>,
- * you can set its source in application <code>init</code> method.
+ * The license is initialized by the <code>ApplicationServlet</code> class
+ * before application is started. The license-file can not be found in
+ * <code>WEB-INF/itmill-toolkit-license.xml</code>, you can set its
+ * source in application <code>init</code> method.
* </p>
+ *
* @return the License this application is currently using.
*/
public License getToolkitLicense() {
@@ -997,12 +1038,13 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
/**
* Sets the license this application is currently using.
* <p>
- * The license is initialized by the <code>ApplicationServlet</code> before application
- * is started. Changing the license after application <code>init</code> method has no effect.
+ * The license is initialized by the <code>ApplicationServlet</code>
+ * before application is started. Changing the license after application
+ * <code>init</code> method has no effect.
* </p>
- *
+ *
* @param license
- * the New license for this application.
+ * the New license for this application.
*/
public void setToolkitLicense(License license) {
this.license = license;
@@ -1011,6 +1053,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
public void setFocusedComponent(Focusable focusable) {
this.pendingFocus = focusable;
}
+
/**
* Gets and nulls focused component in this window
*
@@ -1018,7 +1061,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
*/
public Component.Focusable consumeFocus() {
Component.Focusable f = this.pendingFocus;
- this.pendingFocus= null;
+ this.pendingFocus = null;
return f;
}
diff --git a/src/com/itmill/toolkit/data/Buffered.java b/src/com/itmill/toolkit/data/Buffered.java
index d16d6bd0fd..ae0b4ee08d 100644
--- a/src/com/itmill/toolkit/data/Buffered.java
+++ b/src/com/itmill/toolkit/data/Buffered.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data;
@@ -33,184 +33,194 @@ import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.SystemError;
-/**
- * <p>Defines the interface to commit and discard changes to an object,
- * supporting read-through and write-through modes.
+/**
+ * <p>
+ * Defines the interface to commit and discard changes to an object, supporting
+ * read-through and write-through modes.
* </p>
*
- * <p><i>Read-through mode</i> means that the value read from the buffered
- * object is constantly up to date with the data source.
- * <i>Write-through</i> mode means that all changes to the object are
- * immediately updated to the data source.
+ * <p>
+ * <i>Read-through mode</i> means that the value read from the buffered object
+ * is constantly up to date with the data source. <i>Write-through</i> mode
+ * means that all changes to the object are immediately updated to the data
+ * source.
* </p>
*
- * <p>Since these modes are independent, their combinations may result in
- * some behaviour that may sound surprising.
+ * <p>
+ * Since these modes are independent, their combinations may result in some
+ * behaviour that may sound surprising.
* </p>
*
* <p>
- * For example, if a <code>Buffered</code> object is in read-through mode
- * but not in write-through mode, the result is an object whose value is updated
- * directly from the data source only if it's not locally modified. If the
- * value is locally modified, retrieving the value from the object would
- * result in a value that is different than the one stored in the data
- * source, even though the object is in read-through mode.
+ * For example, if a <code>Buffered</code> object is in read-through mode but
+ * not in write-through mode, the result is an object whose value is updated
+ * directly from the data source only if it's not locally modified. If the value
+ * is locally modified, retrieving the value from the object would result in a
+ * value that is different than the one stored in the data source, even though
+ * the object is in read-through mode.
* </p>
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Buffered {
- /**
- * Updates all changes since the previous commit to the data source.
- * The value stored in the object will always be updated into the data
- * source when <code>commit</code> is called.
+ /**
+ * Updates all changes since the previous commit to the data source. The
+ * value stored in the object will always be updated into the data source
+ * when <code>commit</code> is called.
*
- * @throws SourceException if the operation fails because of an
- * exception is thrown by the data source. The cause is included in the
- * exception.
+ * @throws SourceException
+ * if the operation fails because of an exception is thrown by
+ * the data source. The cause is included in the exception.
*/
public void commit() throws SourceException;
- /**
- * Discards all changes since last commit. The object updates its value
- * from the data source.
+ /**
+ * Discards all changes since last commit. The object updates its value from
+ * the data source.
*
- * @throws SourceException if the operation fails because of an
- * exception is thrown by the data source. The cause is included in the
- * exception.
+ * @throws SourceException
+ * if the operation fails because of an exception is thrown by
+ * the data source. The cause is included in the exception.
*/
public void discard() throws SourceException;
- /**
+ /**
* Tests if the object is in write-through mode. If the object is in
* write-through mode, all modifications to it will result in
* <code>commit</code> being called after the modification.
*
* @return <code>true</code> if the object is in write-through mode,
- * <code>false</code> if it's not.
+ * <code>false</code> if it's not.
*/
public boolean isWriteThrough();
- /**
+ /**
* Sets the object's write-through mode to the specified status. When
- * switching the write-through mode on, the <code>commit</code>
- * operation will be performed.
+ * switching the write-through mode on, the <code>commit</code> operation
+ * will be performed.
*
- * @param writeThrough Boolean value to indicate if the object should be
- * in write-through mode after the call.
+ * @param writeThrough
+ * Boolean value to indicate if the object should be in
+ * write-through mode after the call.
* @throws SourceException
- * If the operation fails because of an exception
- * is thrown by the data source.
+ * If the operation fails because of an exception is thrown by
+ * the data source.
*
*/
public void setWriteThrough(boolean writeThrough) throws SourceException;
- /**
+ /**
* Tests if the object is in read-through mode. If the object is in
- * read-through mode, retrieving its value will result in the value
- * being first updated from the data source to the object.
- * <p>
+ * read-through mode, retrieving its value will result in the value being
+ * first updated from the data source to the object.
+ * <p>
* The only exception to this rule is that when the object is not in
- * write-through mode and it's buffer contains a modified value, the
- * value retrieved from the object will be the locally modified value
- * in the buffer which may differ from the value in the data source.
+ * write-through mode and it's buffer contains a modified value, the value
+ * retrieved from the object will be the locally modified value in the
+ * buffer which may differ from the value in the data source.
* </p>
+ *
* @return <code>true</code> if the object is in read-through mode,
- * <code>false</code> if it's not.
+ * <code>false</code> if it's not.
*/
public boolean isReadThrough();
- /**
+ /**
* Sets the object's read-through mode to the specified status. When
- * switching read-through mode on, the object's value is updated from
- * the data source.
+ * switching read-through mode on, the object's value is updated from the
+ * data source.
*
- * @param readThrough Boolean value to indicate if the object should be
- * in read-through mode after the call.
+ * @param readThrough
+ * Boolean value to indicate if the object should be in
+ * read-through mode after the call.
*
- * @throws SourceException If the operation fails because of an
- * exception is thrown by the data source. The cause is included in the
- * exception.
+ * @throws SourceException
+ * If the operation fails because of an exception is thrown by
+ * the data source. The cause is included in the exception.
*/
public void setReadThrough(boolean readThrough) throws SourceException;
- /**
- * Tests if the value stored in the object has been modified since it
- * was last updated from the data source.
+ /**
+ * Tests if the value stored in the object has been modified since it was
+ * last updated from the data source.
*
- * @return <code>true</code> if the value in the object has been
- * modified since the last data source update, <code>false</code> if
- * not.
+ * @return <code>true</code> if the value in the object has been modified
+ * since the last data source update, <code>false</code> if not.
*/
public boolean isModified();
/**
- * An exception that signals that one or more exceptions occurred
- * while a buffered object tried to access its data source
- * or if there is a problem in processing a data source.
+ * An exception that signals that one or more exceptions occurred while a
+ * buffered object tried to access its data source or if there is a problem
+ * in processing a data source.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
- public class SourceException
- extends RuntimeException
- implements ErrorMessage {
+ public class SourceException extends RuntimeException implements
+ ErrorMessage {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3256720671781630518L;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3256720671781630518L;
- /** Source class implementing the buffered interface */
+ /** Source class implementing the buffered interface */
private Buffered source;
/** Original cause of the source exception */
- private Throwable[] causes = {
- };
+ private Throwable[] causes = {};
- /**
+ /**
* Creates a source exception that does not include a cause.
*
- * @param source the source object implementing the Buffered interface.
+ * @param source
+ * the source object implementing the Buffered interface.
*/
public SourceException(Buffered source) {
this.source = source;
}
- /**
+ /**
* Creates a source exception from a cause exception.
*
- * @param source the source object implementing the Buffered
- * interface.
- * @param cause the original cause for this exception.
+ * @param source
+ * the source object implementing the Buffered interface.
+ * @param cause
+ * the original cause for this exception.
*/
public SourceException(Buffered source, Throwable cause) {
this.source = source;
causes = new Throwable[] { cause };
}
- /**
+ /**
* Creates a source exception from multiple causes.
*
- * @param source the source object implementing the Buffered
- * interface.
- * @param causes the original causes for this exception.
+ * @param source
+ * the source object implementing the Buffered interface.
+ * @param causes
+ * the original causes for this exception.
*/
public SourceException(Buffered source, Throwable[] causes) {
this.source = source;
this.causes = causes;
}
- /**
+ /**
* Gets the cause of the exception.
*
* @return The cause for the exception.
- * @throws MoreThanOneCauseException if there is more than one cause
- * for the exception. This is possible if the commit operation
- * triggers more than one error at the same time.
+ * @throws MoreThanOneCauseException
+ * if there is more than one cause for the exception. This
+ * is possible if the commit operation triggers more than
+ * one error at the same time.
*/
public final Throwable getCause() {
if (causes.length == 0)
@@ -218,8 +228,8 @@ public interface Buffered {
return causes[0];
}
- /**
- * Gets all the causes for this exception.
+ /**
+ * Gets all the causes for this exception.
*
* @return throwables that caused this exception
*/
@@ -227,7 +237,7 @@ public interface Buffered {
return causes;
}
- /**
+ /**
* Gets a source of the exception.
*
* @return the Buffered object which generated this exception.
@@ -236,15 +246,15 @@ public interface Buffered {
return source;
}
- /**
- * Gets the error level of this buffered source exception. The
- * level of the exception is maximum error level of all the contained
- * causes.
- * <p>
- * The causes that do not specify error level default to
+ /**
+ * Gets the error level of this buffered source exception. The level of
+ * the exception is maximum error level of all the contained causes.
+ * <p>
+ * The causes that do not specify error level default to
* <code>ERROR</code> level. Also source exception without any causes
* are of level <code>ERROR</code>.
* </p>
+ *
* @see com.itmill.toolkit.terminal.ErrorMessage#getErrorLevel()
*/
public int getErrorLevel() {
@@ -252,9 +262,8 @@ public interface Buffered {
int level = Integer.MIN_VALUE;
for (int i = 0; i < causes.length; i++) {
- int causeLevel =
- (causes[i] instanceof ErrorMessage)
- ? ((ErrorMessage) causes[i]).getErrorLevel()
+ int causeLevel = (causes[i] instanceof ErrorMessage) ? ((ErrorMessage) causes[i])
+ .getErrorLevel()
: ErrorMessage.ERROR;
if (causeLevel > level)
level = causeLevel;
@@ -281,7 +290,7 @@ public interface Buffered {
// Paint all the exceptions
for (int i = 0; i < causes.length; i++) {
if (causes[i] instanceof ErrorMessage)
- ((ErrorMessage) causes[i]).paint(target);
+ ((ErrorMessage) causes[i]).paint(target);
else
new SystemError(causes[i]).paint(target);
}
@@ -290,7 +299,6 @@ public interface Buffered {
}
-
/* Documented in super interface */
public void addListener(RepaintRequestListener listener) {
}
diff --git a/src/com/itmill/toolkit/data/BufferedValidatable.java b/src/com/itmill/toolkit/data/BufferedValidatable.java
index de3a6edac5..d7983a0d68 100644
--- a/src/com/itmill/toolkit/data/BufferedValidatable.java
+++ b/src/com/itmill/toolkit/data/BufferedValidatable.java
@@ -1,55 +1,56 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data;
-
-/** <p>
+/**
+ * <p>
* This interface defines the combination of <code>Validatable</code> and
* <code>Buffered</code> interfaces. The combination of the interfaces defines
* if the invalid data is committed to datasource.
* </p>
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface BufferedValidatable extends Buffered, Validatable {
- /**
- * Tests if the invalid data is committed to datasource.
- * The default is <code>false</code>.
+ /**
+ * Tests if the invalid data is committed to datasource. The default is
+ * <code>false</code>.
*/
public boolean isInvalidCommitted();
-
- /**
- * Sets if the invalid data should be committed to datasource.
- * The default is <code>false</code>.
- */
+
+ /**
+ * Sets if the invalid data should be committed to datasource. The default
+ * is <code>false</code>.
+ */
public void setInvalidCommitted(boolean isCommitted);
}
diff --git a/src/com/itmill/toolkit/data/Container.java b/src/com/itmill/toolkit/data/Container.java
index 6dd819719b..6116a55815 100644
--- a/src/com/itmill/toolkit/data/Container.java
+++ b/src/com/itmill/toolkit/data/Container.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data;
@@ -69,675 +69,679 @@ import java.util.Collection;
* </p>
*
* @author IT Mill Ltd
- * @version @VERSION@ @since 3.0
+ * @version
+ * @VERSION@
+ * @since 3.0
*/
public interface Container {
- public final static Object NULL_ITEM_ID = new Object();
-
- /**
- * Gets the Item with the given Item ID from the Container. If the Container
- * does not contain the requested Item, <code>null</code> is returned.
- *
- * @param itemId
- * ID of the Item to retrieve
- * @return the Item with the given ID or <code>null</code> if the Item is
- * not found in the Container
- */
- public Item getItem(Object itemId);
-
- /**
- * Gets the ID's of all Properties stored in the Container. The ID's are
- * returned as a unmodifiable collection.
- *
- * @return unmodifiable collection of Property IDs
- */
- public Collection getContainerPropertyIds();
-
- /**
- * Gets the ID's of all Items stored in the Container. The ID's are returned
- * as a unmodifiable collection.
- *
- * @return unmodifiable collection of Item IDs
- */
- public Collection getItemIds();
-
- /**
- * Gets the Property identified by the given itemId and propertyId from the
- * Container. If the Container does not contain the Property,
- * <code>null</code> is returned.
- *
- * @param itemId
- * ID of the Item which contains the Property
- * @param propertyId
- * ID of the Property to retrieve
- * @return Property with the given ID or <code>null</code>
- */
- public Property getContainerProperty(Object itemId, Object propertyId);
-
- /**
- * Gets the data type of all Properties identified by the given Property ID.
- *
- * @param propertyId
- * ID identifying the Properties
- * @return data type of the Properties
- */
- public Class getType(Object propertyId);
-
- /**
- * Gets the number of Items in the Container.
- *
- * @return number of Items in the Container
- */
- public int size();
-
- /**
- * Tests if the Container contains the specified Item
- *
- * @param itemId
- * ID the of Item to be tested
- * @return boolean indicating if the Container holds the specified Item
- */
- public boolean containsId(Object itemId);
-
- /**
- * Creates a new Item with the given ID into the Container. The new
- * <p>
- * Item is returned, and it is ready to have its Properties modified.
- * Returns <code>null</code> if the operation fails or the Container
- * already contains a Item with the given ID.
- * </p>
- *
- * <p>
- * This functionality is optional.
- * </p>
- *
- * @param itemId
- * ID of the Item to be created
- * @return Created new Item, or <code>null</code> in case of a failure
- */
- public Item addItem(Object itemId) throws UnsupportedOperationException;
-
- /**
- * Creates a new Item into the Container, and assign it an automatic ID.
- *
- * <p>
- * The new ID is returned, or <code>null</code> if the operation fails.
- * After a successful call you can use the
- * {@link #getItem(Object ItemId) <code>getItem</code>}method to fetch the
- * Item.
- * </p>
- *
- * <p>
- * This functionality is optional.
- * </p>
- *
- * @return ID of the newly created Item, or <code>null</code> in case of a
- * failure
- */
- public Object addItem() throws UnsupportedOperationException;
-
- /**
- * Removes the Item identified by <code>ItemId</code> from the Container.
- * This functionality is optional.
- *
- * @param itemId
- * ID of the Item to remove
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean removeItem(Object itemId)
- throws UnsupportedOperationException;
-
- /**
- * Adds a new Property to all Items in the Container. The Property ID, data
- * type and default value of the new Property are given as parameters.
- *
- * This functionality is optional.
- *
- * @param propertyId
- * ID of the Property
- * @param type
- * Data type of the new Property
- * @param defaultValue
- * The value all created Properties are initialized to
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean addContainerProperty(Object propertyId, Class type,
- Object defaultValue) throws UnsupportedOperationException;
-
- /**
- * Removes a Property specified by the given Property ID from the Container.
- * Note that the Property will be removed from all Items in the Container.
- *
- * This functionality is optional.
- *
- * @param propertyId
- * ID of the Property to remove
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException;
-
- /**
- * Removes all Items from the Container.
- *
- * <p>
- * Note that Property ID and type information is preserved. This
- * functionality is optional.
- * </p>
- *
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean removeAllItems() throws UnsupportedOperationException;
-
- /**
- * Interface for Container classes whose Items can be traversed in order.
- */
- public interface Ordered extends Container {
-
- /**
- * Gets the ID of the Item following the Item that corresponds to
- * <code>itemId</code>. If the given Item is the last or not found in
- * the Container, <code>null</code> is returned.
- *
- * @param itemId
- * ID of an Item in the Container
- * @return ID of the next Item or <code>null</code>
- */
- public Object nextItemId(Object itemId);
-
- /**
- * Gets the ID of the Item preceding the Item that corresponds to
- * <code>itemId</code>. If the given Item is the first or not found
- * in the Container, <code>null</code> is returned.
- *
- * @param itemId
- * ID of an Item in the Container
- * @return ID of the previous Item or <code>null</code>
- */
- public Object prevItemId(Object itemId);
-
- /**
- * Gets the ID of the first Item in the Container.
- *
- * @return ID of the first Item in the Container
- */
- public Object firstItemId();
-
- /**
- * Gets the ID of the last Item in the Container..
- *
- * @return ID of the last Item in the Container
- */
- public Object lastItemId();
-
- /**
- * Tests if the Item corresponding to the given Item ID is the first
- * Item in the Container.
- *
- * @param itemId
- * ID of an Item in the Container
- * @return <code>true</code> if the Item is first in the Container,
- * <code>false</code> if not
- */
- public boolean isFirstId(Object itemId);
-
- /**
- * Tests if the Item corresponding to the given Item ID is the last Item
- * in the Container.
- *
- * @return <code>true</code> if the Item is last in the Container,
- * <code>false</code> if not
- */
- public boolean isLastId(Object itemId);
-
- /**
- * Adds new item after the given item.
- * <p>
- * Adding an item after null item adds the item as first item of the
- * ordered container.
- * </p>
- *
- * @param previousItemId
- * Id of the previous item in ordered container.
- * @return Returns item id the the created new item or null if the
- * operation fails.
- */
- public Object addItemAfter(Object previousItemId)
- throws UnsupportedOperationException;
-
- /**
- * Adds new item after the given item.
- * <p>
- * Adding an item after null item adds the item as first item of the
- * ordered container.
- * </p>
- *
- * @param previousItemId
- * Id of the previous item in ordered container.
- * @param newItemId
- * Id of the new item to be added.
- * @return Returns new item or null if the operation fails.
- */
- public Item addItemAfter(Object previousItemId, Object newItemId)
- throws UnsupportedOperationException;
-
- }
-
- /** Interface for Container classes whose Items can be sorted. */
- public interface Sortable extends Ordered {
-
- /**
- * Sort method.
- *
- * Sorts the container items.
- *
- * @param propertyId
- * Array of container property IDs, which values are used to
- * sort the items in container as primary, secondary, ...
- * sorting criterion. All of the item IDs must be in the
- * collection returned by <code>getSortableContainerPropertyIds</code>
- * @param ascending
- * Array of sorting order flags corresponding to each property ID
- * used in sorting. If this array is shorter than propertyId array,
- * ascending order is assumed for items where the order is not
- * specified.
- * Use <code>true</code> to sort in ascending order,
- * <code>false</code> to use descending order.
- */
- void sort(Object[] propertyId, boolean[] ascending);
-
- /**
- * Gets the container property IDs, which can be used to sort the item.
- *
- * @return The sortable field ids.
- */
- Collection getSortableContainerPropertyIds();
-
- }
-
- /** Interface for Container classes whose Items can be indexed. */
- public interface Indexed extends Ordered {
-
- /**
- * Gets the index of the Item corresponding to the itemId.
- * The following is <code>true</code> for the returned index: 0 <= index < size().
- *
- * @param itemId
- * ID of an Item in the Container
- * @return index of the Item, or -1 if the Container does not include
- * the Item
- */
- public int indexOfId(Object itemId);
-
- /**
- * Gets the ID of an Item by an index number.
- *
- * @param index
- * Index of the requested id in the Container
- * @return ID of the Item in the given index
- */
- public Object getIdByIndex(int index);
-
- /**
- * Adds new item at given index.
- * <p>
- * The indexes of the item currently in the given position and all the
- * following items are incremented.
- * </p>
- *
- * @param index
- * Index to add the new item.
- * @return Returns item id the the created new item or null if the
- * operation fails.
- */
- public Object addItemAt(int index) throws UnsupportedOperationException;
-
- /**
- * Adds new item at given index.
- * <p>
- * The indexes of the item currently in the given position and all the
- * following items are incremented.
- * </p>
- *
- * @param index
- * Index to add the new item.
- * @param newItemId
- * Id of the new item to be added.
- * @return Returns new item or null if the operation fails.
- */
- public Item addItemAt(int index, Object newItemId)
- throws UnsupportedOperationException;
-
- }
-
- /**
- * <p>
- * Interface for <code>Container</code> classes whose Items can be
- * arranged hierarchically. This means that the Items in the container
- * belong in a tree-like structure, with the following quirks:
- * </p>
- *
- * <ul>
- * <li>The Item structure may have more than one root elements
- * <li>The Items in the hierarchy can be declared explicitly to be able or
- * unable to have children.
- * </ul>
- */
- public interface Hierarchical extends Container {
-
- /**
- * Gets the IDs of all Items that are children of the specified Item.
- * The returned collection is unmodifiable.
- *
- * @param itemId
- * ID of the Item whose children the caller is interested in
- * @return An unmodifiable {@link java.util.Collection collection}
- * containing the IDs of all other Items that are children in
- * the container hierarchy
- */
- public Collection getChildren(Object itemId);
-
- /**
- * Gets the ID of the parent Item of the specified Item.
- *
- * @param itemId
- * ID of the Item whose parent the caller wishes to find out.
- * @return the ID of the parent Item. Will be <code>null</code> if the
- * specified Item is a root element.
- */
- public Object getParent(Object itemId);
-
- /**
- * Gets the IDs of all Items in the container that don't have a parent.
- * Such items are called <code>root</code> Items. The returned
- * collection is unmodifiable.
- *
- * @return An unmodifiable {@link java.util.Collection collection}
- * containing IDs of all root elements of the container
- */
- public Collection rootItemIds();
-
- /**
- * <p>
- * Sets the parent of an Item. The new parent item must exist and be
- * able to have children. (
- * <code>canHaveChildren(newParentId) == true</code>). It is also
- * possible to detach a node from the hierarchy (and thus make it root)
- * by setting the parent <code>null</code>.
- * </p>
- *
- * <p>
- * This operation is optional.
- * </p>
- *
- * @param itemId
- * ID of the item to be set as the child of the Item
- * identified with <code>newParentId</code>
- * @param newParentId
- * ID of the Item that's to be the new parent of the Item
- * identified with <code>itemId</code>
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean setParent(Object itemId, Object newParentId)
- throws UnsupportedOperationException;
-
- /**
- * Tests if the Item with given ID can have any children. If the
- * Container also implements the <code>Managed</code> interface, the
- * items created with <code>newItem</code> can have children by
- * default.
- *
- * @param itemId
- * ID of the Item in the container whose child capability is
- * to be tested
- * @return <code>true</code> if the specified Item exists in the
- * Container and it can have children, <code>false</code> if
- * it's not found from the container or it can't have children.
- */
- public boolean areChildrenAllowed(Object itemId);
-
- /**
- * <p>
- * Sets the given Item's capability to have children. If the Item
- * identified with <code>itemId</code> already has children and
- * <code>areChildrenAllowed</code> is false this method fails and
- * <code>false</code> is returned.
- * </p>
- * <p>
- * The children must be first explicitly removed with
- * {@link #setParent(Object itemId, Object newParentId)}or
- * {@link com.itmill.toolkit.data.Container#removeItem(Object itemId)}.
- * </p>
- *
- * <p>
- * This operation is optional. If it is not implemented, the method
- * always returns <code>false</code>.
- * </p>
- *
- * @param itemId
- * ID of the Item in the container whose child capability is
- * to be set
- * @param areChildrenAllowed
- * boolean value specifying if the Item can have children or
- * not
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean setChildrenAllowed(Object itemId,
- boolean areChildrenAllowed)
- throws UnsupportedOperationException;
-
- /**
- * Tests if the Item specified with <code>itemId</code> is a root
- * Item. The hierarchical container can have more than one root and must
- * have at least one unless it is empty. The
- * {@link #getParent(Object itemId)}method always returns
- * <code>null</code> for root Items.
- *
- * @param itemId
- * ID of the Item whose root status is to be tested
- * @return <code>true</code> if the specified Item is a root,
- * <code>false</code> if not
- */
- public boolean isRoot(Object itemId);
-
- /**
- * <p>
- * Tests if the Item specified with <code>itemId</code> has any child
- * Items, that is, is it a leaf Item. The
- * {@link #getChildren(Object itemId)}method always returns
- * <code>null</code> for leaf Items.
- * </p>
- *
- * <p>
- * Note that being a leaf does not imply whether or not an Item is
- * allowed to have children.
- * </p>.
- *
- * @param itemId
- * ID of the Item whose leaf status is to be tested
- * @return <code>true</code> if the specified Item is a leaf,
- * <code>false</code> if not
- */
- public boolean hasChildren(Object itemId);
- }
-
- /**
- * Interface implemented by viewer classes capable of using a Container as a
- * data source.
- */
- public interface Viewer {
-
- /**
- * Sets the Container that serves as the data source of the viewer.
- *
- * @param newDataSource
- * The new data source Item
- */
- public void setContainerDataSource(Container newDataSource);
-
- /**
- * Gets the Container serving as the data source of the viewer.
- *
- * @return data source Container
- */
- public Container getContainerDataSource();
-
- }
-
- /**
- * <p>
- * Interface implemented by the editor classes supporting editing the
- * Container. Implementing this interface means that the Container serving
- * as the data source of the editor can be modified through it.
- * </p>
- * <p>
- * Note that not implementing the <code>Container.Editor</code> interface does not
- * restrict the class from editing the Container contents internally.
- * </p>
- */
- public interface Editor extends Container.Viewer {
-
- }
-
- /* Contents change event ******************************************* */
-
- /**
- * An <code>Event</code> object specifying the Container whose Item set
- * has changed. Note that these events are triggered only through succesful
- * calls to the <code>newItem</code> and <code>removeAllItems</code>
- * methods in the Container.Managed interface.
- */
- public interface ItemSetChangeEvent {
-
- /**
- * Gets the Property where the event occurred.
- *
- * @return source of the event
- */
- public Container getContainer();
- }
-
- /** Container Item set change listener interface. */
- public interface ItemSetChangeListener {
-
- /**
- * Lets the listener know a Containers Item set has changed.
- *
- * @param event
- * change event text
- */
- public void containerItemSetChange(Container.ItemSetChangeEvent event);
- }
-
- /**
- * The interface for adding and removing <code>ItemSetChangeEvent</code>
- * listeners. By implementing this interface a class explicitly announces
- * that it will generate a <code>ItemSetChangeEvent</code> when its
- * contents are modified.
- * <p>
- * Note: The general Java convention is not to explicitly declare that a
- * class generates events, but to directly define the
- * <code>addListener</code> and <code>removeListener</code> methods.
- * That way the caller of these methods has no real way of finding out if
- * the class really will send the events, or if it just defines the methods
- * to be able to implement an interface.
- * </p>
- */
- public interface ItemSetChangeNotifier {
-
- /**
- * Adds an Item set change listener for the object.
- *
- * @param listener
- * listener to be added
- */
- public void addListener(Container.ItemSetChangeListener listener);
-
- /**
- * Removes the Item set change listener from the object.
- *
- * @param listener
- * listener to be removed
- */
- public void removeListener(Container.ItemSetChangeListener listener);
- }
-
- /* Property set change event ******************************************** */
-
- /**
- * An <code>Event</code> object specifying the Container whose Property
- * set has changed.
- *<p>
- * Note: These events are triggered only through succesful calls to
- * the <code>addProperty</code> and
- * <code>removeProperty</code> methods in the Container.Managed interface.
- * </p>
- */
- public interface PropertySetChangeEvent {
-
- /**
- * Retrieves the Container whose contents have been modified.
- *
- * @return Source Container of the event.
- */
- public Container getContainer();
- }
-
- /**
- * The listener interface for receiving <code>PropertySetChangeEvent</code>
- * objects.
- */
- public interface PropertySetChangeListener {
-
- /**
- * Notifies this listener that the Containers contents has changed.
- *
- * @param event
- * Change event.
- */
- public void containerPropertySetChange(
- Container.PropertySetChangeEvent event);
- }
-
- /**
- * <p>
- * The interface for adding and removing <code>PropertySetChangeEvent</code>
- * listeners. By implementing this interface a class explicitly announces
- * that it will generate a <code>PropertySetChangeEvent</code> when its
- * contents are modified.
- * </p>
- * <p>
- * Note that the general Java convention is not to explicitly declare that a
- * class generates events, but to directly define the
- * <code>addListener</code> and <code>removeListener</code> methods.
- * That way the caller of these methods has no real way of finding out if
- * the class really will send the events, or if it just defines the methods
- * to be able to implement an interface.
- * </p>
- */
- public interface PropertySetChangeNotifier {
-
- /**
- * Registers a new Property set change listener for this Container.
- *
- * @param listener
- * The new Listener to be registered
- */
- public void addListener(Container.PropertySetChangeListener listener);
-
- /**
- * Removes a previously registered Property set change listener.
- *
- * @param listener
- * Listener to be removed
- */
- public void removeListener(Container.PropertySetChangeListener listener);
- }
+ public final static Object NULL_ITEM_ID = new Object();
+
+ /**
+ * Gets the Item with the given Item ID from the Container. If the Container
+ * does not contain the requested Item, <code>null</code> is returned.
+ *
+ * @param itemId
+ * ID of the Item to retrieve
+ * @return the Item with the given ID or <code>null</code> if the Item is
+ * not found in the Container
+ */
+ public Item getItem(Object itemId);
+
+ /**
+ * Gets the ID's of all Properties stored in the Container. The ID's are
+ * returned as a unmodifiable collection.
+ *
+ * @return unmodifiable collection of Property IDs
+ */
+ public Collection getContainerPropertyIds();
+
+ /**
+ * Gets the ID's of all Items stored in the Container. The ID's are returned
+ * as a unmodifiable collection.
+ *
+ * @return unmodifiable collection of Item IDs
+ */
+ public Collection getItemIds();
+
+ /**
+ * Gets the Property identified by the given itemId and propertyId from the
+ * Container. If the Container does not contain the Property,
+ * <code>null</code> is returned.
+ *
+ * @param itemId
+ * ID of the Item which contains the Property
+ * @param propertyId
+ * ID of the Property to retrieve
+ * @return Property with the given ID or <code>null</code>
+ */
+ public Property getContainerProperty(Object itemId, Object propertyId);
+
+ /**
+ * Gets the data type of all Properties identified by the given Property ID.
+ *
+ * @param propertyId
+ * ID identifying the Properties
+ * @return data type of the Properties
+ */
+ public Class getType(Object propertyId);
+
+ /**
+ * Gets the number of Items in the Container.
+ *
+ * @return number of Items in the Container
+ */
+ public int size();
+
+ /**
+ * Tests if the Container contains the specified Item
+ *
+ * @param itemId
+ * ID the of Item to be tested
+ * @return boolean indicating if the Container holds the specified Item
+ */
+ public boolean containsId(Object itemId);
+
+ /**
+ * Creates a new Item with the given ID into the Container. The new
+ * <p>
+ * Item is returned, and it is ready to have its Properties modified.
+ * Returns <code>null</code> if the operation fails or the Container
+ * already contains a Item with the given ID.
+ * </p>
+ *
+ * <p>
+ * This functionality is optional.
+ * </p>
+ *
+ * @param itemId
+ * ID of the Item to be created
+ * @return Created new Item, or <code>null</code> in case of a failure
+ */
+ public Item addItem(Object itemId) throws UnsupportedOperationException;
+
+ /**
+ * Creates a new Item into the Container, and assign it an automatic ID.
+ *
+ * <p>
+ * The new ID is returned, or <code>null</code> if the operation fails.
+ * After a successful call you can use the
+ * {@link #getItem(Object ItemId) <code>getItem</code>}method to fetch the
+ * Item.
+ * </p>
+ *
+ * <p>
+ * This functionality is optional.
+ * </p>
+ *
+ * @return ID of the newly created Item, or <code>null</code> in case of a
+ * failure
+ */
+ public Object addItem() throws UnsupportedOperationException;
+
+ /**
+ * Removes the Item identified by <code>ItemId</code> from the Container.
+ * This functionality is optional.
+ *
+ * @param itemId
+ * ID of the Item to remove
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean removeItem(Object itemId)
+ throws UnsupportedOperationException;
+
+ /**
+ * Adds a new Property to all Items in the Container. The Property ID, data
+ * type and default value of the new Property are given as parameters.
+ *
+ * This functionality is optional.
+ *
+ * @param propertyId
+ * ID of the Property
+ * @param type
+ * Data type of the new Property
+ * @param defaultValue
+ * The value all created Properties are initialized to
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean addContainerProperty(Object propertyId, Class type,
+ Object defaultValue) throws UnsupportedOperationException;
+
+ /**
+ * Removes a Property specified by the given Property ID from the Container.
+ * Note that the Property will be removed from all Items in the Container.
+ *
+ * This functionality is optional.
+ *
+ * @param propertyId
+ * ID of the Property to remove
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException;
+
+ /**
+ * Removes all Items from the Container.
+ *
+ * <p>
+ * Note that Property ID and type information is preserved. This
+ * functionality is optional.
+ * </p>
+ *
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean removeAllItems() throws UnsupportedOperationException;
+
+ /**
+ * Interface for Container classes whose Items can be traversed in order.
+ */
+ public interface Ordered extends Container {
+
+ /**
+ * Gets the ID of the Item following the Item that corresponds to
+ * <code>itemId</code>. If the given Item is the last or not found in
+ * the Container, <code>null</code> is returned.
+ *
+ * @param itemId
+ * ID of an Item in the Container
+ * @return ID of the next Item or <code>null</code>
+ */
+ public Object nextItemId(Object itemId);
+
+ /**
+ * Gets the ID of the Item preceding the Item that corresponds to
+ * <code>itemId</code>. If the given Item is the first or not found
+ * in the Container, <code>null</code> is returned.
+ *
+ * @param itemId
+ * ID of an Item in the Container
+ * @return ID of the previous Item or <code>null</code>
+ */
+ public Object prevItemId(Object itemId);
+
+ /**
+ * Gets the ID of the first Item in the Container.
+ *
+ * @return ID of the first Item in the Container
+ */
+ public Object firstItemId();
+
+ /**
+ * Gets the ID of the last Item in the Container..
+ *
+ * @return ID of the last Item in the Container
+ */
+ public Object lastItemId();
+
+ /**
+ * Tests if the Item corresponding to the given Item ID is the first
+ * Item in the Container.
+ *
+ * @param itemId
+ * ID of an Item in the Container
+ * @return <code>true</code> if the Item is first in the Container,
+ * <code>false</code> if not
+ */
+ public boolean isFirstId(Object itemId);
+
+ /**
+ * Tests if the Item corresponding to the given Item ID is the last Item
+ * in the Container.
+ *
+ * @return <code>true</code> if the Item is last in the Container,
+ * <code>false</code> if not
+ */
+ public boolean isLastId(Object itemId);
+
+ /**
+ * Adds new item after the given item.
+ * <p>
+ * Adding an item after null item adds the item as first item of the
+ * ordered container.
+ * </p>
+ *
+ * @param previousItemId
+ * Id of the previous item in ordered container.
+ * @return Returns item id the the created new item or null if the
+ * operation fails.
+ */
+ public Object addItemAfter(Object previousItemId)
+ throws UnsupportedOperationException;
+
+ /**
+ * Adds new item after the given item.
+ * <p>
+ * Adding an item after null item adds the item as first item of the
+ * ordered container.
+ * </p>
+ *
+ * @param previousItemId
+ * Id of the previous item in ordered container.
+ * @param newItemId
+ * Id of the new item to be added.
+ * @return Returns new item or null if the operation fails.
+ */
+ public Item addItemAfter(Object previousItemId, Object newItemId)
+ throws UnsupportedOperationException;
+
+ }
+
+ /** Interface for Container classes whose Items can be sorted. */
+ public interface Sortable extends Ordered {
+
+ /**
+ * Sort method.
+ *
+ * Sorts the container items.
+ *
+ * @param propertyId
+ * Array of container property IDs, which values are used to
+ * sort the items in container as primary, secondary, ...
+ * sorting criterion. All of the item IDs must be in the
+ * collection returned by
+ * <code>getSortableContainerPropertyIds</code>
+ * @param ascending
+ * Array of sorting order flags corresponding to each
+ * property ID used in sorting. If this array is shorter than
+ * propertyId array, ascending order is assumed for items
+ * where the order is not specified. Use <code>true</code>
+ * to sort in ascending order, <code>false</code> to use
+ * descending order.
+ */
+ void sort(Object[] propertyId, boolean[] ascending);
+
+ /**
+ * Gets the container property IDs, which can be used to sort the item.
+ *
+ * @return The sortable field ids.
+ */
+ Collection getSortableContainerPropertyIds();
+
+ }
+
+ /** Interface for Container classes whose Items can be indexed. */
+ public interface Indexed extends Ordered {
+
+ /**
+ * Gets the index of the Item corresponding to the itemId. The following
+ * is <code>true</code> for the returned index: 0 <= index < size().
+ *
+ * @param itemId
+ * ID of an Item in the Container
+ * @return index of the Item, or -1 if the Container does not include
+ * the Item
+ */
+ public int indexOfId(Object itemId);
+
+ /**
+ * Gets the ID of an Item by an index number.
+ *
+ * @param index
+ * Index of the requested id in the Container
+ * @return ID of the Item in the given index
+ */
+ public Object getIdByIndex(int index);
+
+ /**
+ * Adds new item at given index.
+ * <p>
+ * The indexes of the item currently in the given position and all the
+ * following items are incremented.
+ * </p>
+ *
+ * @param index
+ * Index to add the new item.
+ * @return Returns item id the the created new item or null if the
+ * operation fails.
+ */
+ public Object addItemAt(int index) throws UnsupportedOperationException;
+
+ /**
+ * Adds new item at given index.
+ * <p>
+ * The indexes of the item currently in the given position and all the
+ * following items are incremented.
+ * </p>
+ *
+ * @param index
+ * Index to add the new item.
+ * @param newItemId
+ * Id of the new item to be added.
+ * @return Returns new item or null if the operation fails.
+ */
+ public Item addItemAt(int index, Object newItemId)
+ throws UnsupportedOperationException;
+
+ }
+
+ /**
+ * <p>
+ * Interface for <code>Container</code> classes whose Items can be
+ * arranged hierarchically. This means that the Items in the container
+ * belong in a tree-like structure, with the following quirks:
+ * </p>
+ *
+ * <ul>
+ * <li>The Item structure may have more than one root elements
+ * <li>The Items in the hierarchy can be declared explicitly to be able or
+ * unable to have children.
+ * </ul>
+ */
+ public interface Hierarchical extends Container {
+
+ /**
+ * Gets the IDs of all Items that are children of the specified Item.
+ * The returned collection is unmodifiable.
+ *
+ * @param itemId
+ * ID of the Item whose children the caller is interested in
+ * @return An unmodifiable {@link java.util.Collection collection}
+ * containing the IDs of all other Items that are children in
+ * the container hierarchy
+ */
+ public Collection getChildren(Object itemId);
+
+ /**
+ * Gets the ID of the parent Item of the specified Item.
+ *
+ * @param itemId
+ * ID of the Item whose parent the caller wishes to find out.
+ * @return the ID of the parent Item. Will be <code>null</code> if the
+ * specified Item is a root element.
+ */
+ public Object getParent(Object itemId);
+
+ /**
+ * Gets the IDs of all Items in the container that don't have a parent.
+ * Such items are called <code>root</code> Items. The returned
+ * collection is unmodifiable.
+ *
+ * @return An unmodifiable {@link java.util.Collection collection}
+ * containing IDs of all root elements of the container
+ */
+ public Collection rootItemIds();
+
+ /**
+ * <p>
+ * Sets the parent of an Item. The new parent item must exist and be
+ * able to have children. (
+ * <code>canHaveChildren(newParentId) == true</code>). It is also
+ * possible to detach a node from the hierarchy (and thus make it root)
+ * by setting the parent <code>null</code>.
+ * </p>
+ *
+ * <p>
+ * This operation is optional.
+ * </p>
+ *
+ * @param itemId
+ * ID of the item to be set as the child of the Item
+ * identified with <code>newParentId</code>
+ * @param newParentId
+ * ID of the Item that's to be the new parent of the Item
+ * identified with <code>itemId</code>
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean setParent(Object itemId, Object newParentId)
+ throws UnsupportedOperationException;
+
+ /**
+ * Tests if the Item with given ID can have any children. If the
+ * Container also implements the <code>Managed</code> interface, the
+ * items created with <code>newItem</code> can have children by
+ * default.
+ *
+ * @param itemId
+ * ID of the Item in the container whose child capability is
+ * to be tested
+ * @return <code>true</code> if the specified Item exists in the
+ * Container and it can have children, <code>false</code> if
+ * it's not found from the container or it can't have children.
+ */
+ public boolean areChildrenAllowed(Object itemId);
+
+ /**
+ * <p>
+ * Sets the given Item's capability to have children. If the Item
+ * identified with <code>itemId</code> already has children and
+ * <code>areChildrenAllowed</code> is false this method fails and
+ * <code>false</code> is returned.
+ * </p>
+ * <p>
+ * The children must be first explicitly removed with
+ * {@link #setParent(Object itemId, Object newParentId)}or
+ * {@link com.itmill.toolkit.data.Container#removeItem(Object itemId)}.
+ * </p>
+ *
+ * <p>
+ * This operation is optional. If it is not implemented, the method
+ * always returns <code>false</code>.
+ * </p>
+ *
+ * @param itemId
+ * ID of the Item in the container whose child capability is
+ * to be set
+ * @param areChildrenAllowed
+ * boolean value specifying if the Item can have children or
+ * not
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean setChildrenAllowed(Object itemId,
+ boolean areChildrenAllowed)
+ throws UnsupportedOperationException;
+
+ /**
+ * Tests if the Item specified with <code>itemId</code> is a root
+ * Item. The hierarchical container can have more than one root and must
+ * have at least one unless it is empty. The
+ * {@link #getParent(Object itemId)}method always returns
+ * <code>null</code> for root Items.
+ *
+ * @param itemId
+ * ID of the Item whose root status is to be tested
+ * @return <code>true</code> if the specified Item is a root,
+ * <code>false</code> if not
+ */
+ public boolean isRoot(Object itemId);
+
+ /**
+ * <p>
+ * Tests if the Item specified with <code>itemId</code> has any child
+ * Items, that is, is it a leaf Item. The
+ * {@link #getChildren(Object itemId)}method always returns
+ * <code>null</code> for leaf Items.
+ * </p>
+ *
+ * <p>
+ * Note that being a leaf does not imply whether or not an Item is
+ * allowed to have children.
+ * </p>.
+ *
+ * @param itemId
+ * ID of the Item whose leaf status is to be tested
+ * @return <code>true</code> if the specified Item is a leaf,
+ * <code>false</code> if not
+ */
+ public boolean hasChildren(Object itemId);
+ }
+
+ /**
+ * Interface implemented by viewer classes capable of using a Container as a
+ * data source.
+ */
+ public interface Viewer {
+
+ /**
+ * Sets the Container that serves as the data source of the viewer.
+ *
+ * @param newDataSource
+ * The new data source Item
+ */
+ public void setContainerDataSource(Container newDataSource);
+
+ /**
+ * Gets the Container serving as the data source of the viewer.
+ *
+ * @return data source Container
+ */
+ public Container getContainerDataSource();
+
+ }
+
+ /**
+ * <p>
+ * Interface implemented by the editor classes supporting editing the
+ * Container. Implementing this interface means that the Container serving
+ * as the data source of the editor can be modified through it.
+ * </p>
+ * <p>
+ * Note that not implementing the <code>Container.Editor</code> interface
+ * does not restrict the class from editing the Container contents
+ * internally.
+ * </p>
+ */
+ public interface Editor extends Container.Viewer {
+
+ }
+
+ /* Contents change event ******************************************* */
+
+ /**
+ * An <code>Event</code> object specifying the Container whose Item set
+ * has changed. Note that these events are triggered only through succesful
+ * calls to the <code>newItem</code> and <code>removeAllItems</code>
+ * methods in the Container.Managed interface.
+ */
+ public interface ItemSetChangeEvent {
+
+ /**
+ * Gets the Property where the event occurred.
+ *
+ * @return source of the event
+ */
+ public Container getContainer();
+ }
+
+ /** Container Item set change listener interface. */
+ public interface ItemSetChangeListener {
+
+ /**
+ * Lets the listener know a Containers Item set has changed.
+ *
+ * @param event
+ * change event text
+ */
+ public void containerItemSetChange(Container.ItemSetChangeEvent event);
+ }
+
+ /**
+ * The interface for adding and removing <code>ItemSetChangeEvent</code>
+ * listeners. By implementing this interface a class explicitly announces
+ * that it will generate a <code>ItemSetChangeEvent</code> when its
+ * contents are modified.
+ * <p>
+ * Note: The general Java convention is not to explicitly declare that a
+ * class generates events, but to directly define the
+ * <code>addListener</code> and <code>removeListener</code> methods.
+ * That way the caller of these methods has no real way of finding out if
+ * the class really will send the events, or if it just defines the methods
+ * to be able to implement an interface.
+ * </p>
+ */
+ public interface ItemSetChangeNotifier {
+
+ /**
+ * Adds an Item set change listener for the object.
+ *
+ * @param listener
+ * listener to be added
+ */
+ public void addListener(Container.ItemSetChangeListener listener);
+
+ /**
+ * Removes the Item set change listener from the object.
+ *
+ * @param listener
+ * listener to be removed
+ */
+ public void removeListener(Container.ItemSetChangeListener listener);
+ }
+
+ /* Property set change event ******************************************** */
+
+ /**
+ * An <code>Event</code> object specifying the Container whose Property
+ * set has changed.
+ * <p>
+ * Note: These events are triggered only through succesful calls to the
+ * <code>addProperty</code> and <code>removeProperty</code> methods in
+ * the Container.Managed interface.
+ * </p>
+ */
+ public interface PropertySetChangeEvent {
+
+ /**
+ * Retrieves the Container whose contents have been modified.
+ *
+ * @return Source Container of the event.
+ */
+ public Container getContainer();
+ }
+
+ /**
+ * The listener interface for receiving <code>PropertySetChangeEvent</code>
+ * objects.
+ */
+ public interface PropertySetChangeListener {
+
+ /**
+ * Notifies this listener that the Containers contents has changed.
+ *
+ * @param event
+ * Change event.
+ */
+ public void containerPropertySetChange(
+ Container.PropertySetChangeEvent event);
+ }
+
+ /**
+ * <p>
+ * The interface for adding and removing <code>PropertySetChangeEvent</code>
+ * listeners. By implementing this interface a class explicitly announces
+ * that it will generate a <code>PropertySetChangeEvent</code> when its
+ * contents are modified.
+ * </p>
+ * <p>
+ * Note that the general Java convention is not to explicitly declare that a
+ * class generates events, but to directly define the
+ * <code>addListener</code> and <code>removeListener</code> methods.
+ * That way the caller of these methods has no real way of finding out if
+ * the class really will send the events, or if it just defines the methods
+ * to be able to implement an interface.
+ * </p>
+ */
+ public interface PropertySetChangeNotifier {
+
+ /**
+ * Registers a new Property set change listener for this Container.
+ *
+ * @param listener
+ * The new Listener to be registered
+ */
+ public void addListener(Container.PropertySetChangeListener listener);
+
+ /**
+ * Removes a previously registered Property set change listener.
+ *
+ * @param listener
+ * Listener to be removed
+ */
+ public void removeListener(Container.PropertySetChangeListener listener);
+ }
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/data/Item.java b/src/com/itmill/toolkit/data/Item.java
index d59e94edf4..8e3437993e 100644
--- a/src/com/itmill/toolkit/data/Item.java
+++ b/src/com/itmill/toolkit/data/Item.java
@@ -1,54 +1,56 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data;
import java.util.Collection;
-/**
+/**
* <p>
- * Provides a mechanism for handling a set of Properties, each associated
- * to a locally unique identifier. The interface is split into subinterfaces
- * to enable a class to implement only the functionalities it needs.
+ * Provides a mechanism for handling a set of Properties, each associated to a
+ * locally unique identifier. The interface is split into subinterfaces to
+ * enable a class to implement only the functionalities it needs.
* </p>
*
- * @author IT Mill Ltd
- * @version @VERSION@
+ * @author IT Mill Ltd
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Item {
- /**
- * Gets the Property corresponding to the given Property ID stored in
- * the Item. If the Item does not contain the Property,
- * <code>null</code> is returned.
+ /**
+ * Gets the Property corresponding to the given Property ID stored in the
+ * Item. If the Item does not contain the Property, <code>null</code> is
+ * returned.
*
- * @param id identifier of the Property to get
+ * @param id
+ * identifier of the Property to get
* @return the Property with the given ID or <code>null</code>
*/
public Property getItemProperty(Object id);
@@ -56,50 +58,58 @@ public interface Item {
/**
* Gets the collection of IDs of all Properties stored in the Item.
*
- * @return unmodifiable collection containing IDs of the Properties
- * stored the Item
+ * @return unmodifiable collection containing IDs of the Properties stored
+ * the Item
*/
public Collection getItemPropertyIds();
- /**
+ /**
* Tries to add a new Property into the Item.
*
- * <p>This functionality is optional.</p>
+ * <p>
+ * This functionality is optional.
+ * </p>
*
- * @param id ID of the new Property
- * @param property the Property to be added and associated with the id
+ * @param id
+ * ID of the new Property
+ * @param property
+ * the Property to be added and associated with the id
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- * @throws UnsupportedOperationException if the operation is not supported.
+ * <code>false</code> if not
+ * @throws UnsupportedOperationException
+ * if the operation is not supported.
*/
public boolean addItemProperty(Object id, Property property)
- throws UnsupportedOperationException;
+ throws UnsupportedOperationException;
/**
- * Removes the Property identified by ID from the Item.
- *
+ * Removes the Property identified by ID from the Item.
+ *
* <p>
* This functionality is optional.
* </p>
- *
- * @param id ID of the Property to be removed
+ *
+ * @param id
+ * ID of the Property to be removed
* @return <code>true</code> if the operation succeeded
- * @throws UnsupportedOperationException if the operation is not supported.
- * <code>false</code> if not
+ * @throws UnsupportedOperationException
+ * if the operation is not supported. <code>false</code> if
+ * not
*/
public boolean removeItemProperty(Object id)
- throws UnsupportedOperationException;
+ throws UnsupportedOperationException;
- /**
- * Interface implemented by viewer classes capable of using an Item as
- * a data source.
+ /**
+ * Interface implemented by viewer classes capable of using an Item as a
+ * data source.
*/
public interface Viewer {
/**
* Sets the Item that serves as the data source of the viewer.
*
- * @param newDataSource The new data source Item
+ * @param newDataSource
+ * The new data source Item
*/
public void setItemDataSource(Item newDataSource);
@@ -112,10 +122,10 @@ public interface Item {
}
/**
- * Interface implemented by the <code>Editor</code> classes capable of editing the
- * Item. Implementing this interface means that the Item serving as the
- * data source of the editor can be modified through it.
- * <p>
+ * Interface implemented by the <code>Editor</code> classes capable of
+ * editing the Item. Implementing this interface means that the Item serving
+ * as the data source of the editor can be modified through it.
+ * <p>
* Note : Not implementing the <code>Item.Editor</code> interface does not
* restrict the class from editing the contents of an internally.
* </p>
@@ -127,8 +137,8 @@ public interface Item {
/* Property set change event ******************************************** */
/**
- * An <code>Event</code> object specifying the Item whose contents
- * has been changed through the <code>Property</code> interface.
+ * An <code>Event</code> object specifying the Item whose contents has
+ * been changed through the <code>Property</code> interface.
* <p>
* Note: The values stored in the Properties may change without triggering
* this event.
@@ -136,7 +146,7 @@ public interface Item {
*/
public interface PropertySetChangeEvent {
- /**
+ /**
* Retrieves the Item whose contents has been modified.
*
* @return source Item of the event
@@ -144,47 +154,50 @@ public interface Item {
public Item getItem();
}
- /**
- * The listener interface for receiving
- * <code>PropertySetChangeEvent</code> objects.
+ /**
+ * The listener interface for receiving <code>PropertySetChangeEvent</code>
+ * objects.
*/
public interface PropertySetChangeListener {
/**
- * Notifies this listener that the Item's property set has changed.
+ * Notifies this listener that the Item's property set has changed.
*
- * @param event Property set change event object
+ * @param event
+ * Property set change event object
*/
public void itemPropertySetChange(Item.PropertySetChangeEvent event);
}
- /**
- * The interface for adding and removing <code>PropertySetChangeEvent</code>
- * listeners. By implementing this interface a class explicitly announces that
- * it will generate a <code>PropertySetChangeEvent</code> when its Property
- * set is modified.
+ /**
+ * The interface for adding and removing <code>PropertySetChangeEvent</code>
+ * listeners. By implementing this interface a class explicitly announces
+ * that it will generate a <code>PropertySetChangeEvent</code> when its
+ * Property set is modified.
* <p>
- * Note : The general Java convention is not to explicitly declare
- * that a class generates events, but to directly define the
+ * Note : The general Java convention is not to explicitly declare that a
+ * class generates events, but to directly define the
* <code>addListener</code> and <code>removeListener</code> methods.
- * That way the caller of these methods has no real way of finding out
- * if the class really will send the events, or if it just defines the
- * methods to be able to implement an interface.
+ * That way the caller of these methods has no real way of finding out if
+ * the class really will send the events, or if it just defines the methods
+ * to be able to implement an interface.
* </p>
*/
public interface PropertySetChangeNotifier {
/**
- * Registers a new property set change listener for this Item.
+ * Registers a new property set change listener for this Item.
*
- * @param listener The new Listener to be registered.
+ * @param listener
+ * The new Listener to be registered.
*/
public void addListener(Item.PropertySetChangeListener listener);
/**
- * Removes a previously registered property set change listener.
+ * Removes a previously registered property set change listener.
*
- * @param listener Listener to be removed.
+ * @param listener
+ * Listener to be removed.
*/
public void removeListener(Item.PropertySetChangeListener listener);
}
diff --git a/src/com/itmill/toolkit/data/Property.java b/src/com/itmill/toolkit/data/Property.java
index 2f2f27638d..5999e5cd9e 100644
--- a/src/com/itmill/toolkit/data/Property.java
+++ b/src/com/itmill/toolkit/data/Property.java
@@ -1,395 +1,431 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data;
-/**
+/**
* <p>
- * The <code>Property</code> is a simple data object that contains one typed value. This
- * interface contains methods to inspect and modify the stored value and its
- * type, and the object's read-only state.
+ * The <code>Property</code> is a simple data object that contains one typed
+ * value. This interface contains methods to inspect and modify the stored value
+ * and its type, and the object's read-only state.
* </p>
*
* <p>
- * The <code>Property</code> also defines the events <code>ReadOnlyStatusChangeEvent</code> and
- * <code>ValueChangeEvent</code>, and the associated <code>listener</code> and <code>notifier</code> interfaces.
+ * The <code>Property</code> also defines the events
+ * <code>ReadOnlyStatusChangeEvent</code> and <code>ValueChangeEvent</code>,
+ * and the associated <code>listener</code> and <code>notifier</code>
+ * interfaces.
* </p>
*
- *<p>
- * The <code>Property.Viewer</code> interface should be used to attach the Property to
- * an external data source. This way the value in the data source can be
- * inspected using the <code>Property</code> interface.
+ * <p>
+ * The <code>Property.Viewer</code> interface should be used to attach the
+ * Property to an external data source. This way the value in the data source
+ * can be inspected using the <code>Property</code> interface.
* </p>
*
* <p>
- * The <code>Property.editor</code> interface should be implemented if the value needs to
- * be changed through the implementing class.
+ * The <code>Property.editor</code> interface should be implemented if the
+ * value needs to be changed through the implementing class.
* </p>
- * @author IT Mill Ltd
- * @version @VERSION@
+ *
+ * @author IT Mill Ltd
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Property {
-
- /**
- * Gets the value stored in the Property.
- *
- * @return the value stored in the Property
- */
- public Object getValue();
-
- /**
- * Sets the value of the Property.
- * <p>
- * Implementing this functionality is optional. If the functionality
- * is missing, one should declare the Property to be in read-only mode
- * and throw <code>Property.ReadOnlyException</code> in this function.
- * </p>
- * Note : It is not required, but highly recommended to support setting
- * the value also as a <code>String</code> in addition to the native
- * type of the Property (as given by the <code>getType</code> method).
- * If the <code>String</code> conversion fails or is unsupported, the
- * method should throw <code>Property.ConversionException</code>. The
- * string conversion should at least understand the format returned by
- * the <code>toString</code> method of the Property.
- *
- * @param newValue New value of the Property. This should be assignable
- * to the type returned by getType, but also String type
- * should be supported
- *
- * @throws Property.ReadOnlyException if the object is in read-only
- * mode
- * @throws Property.ConversionException if newValue can't
- * be converted into the Property's native type directly or through
- * String
- */
- public void setValue(Object newValue)
- throws Property.ReadOnlyException, Property.ConversionException;
-
- /**
- * Returns the value of the Property in human readable textual format.
- * The return value should be assignable to the <code>setValue</code>
- * method if the Property is not in read-only mode.
- *
- * @return <code>String</code> representation of the value stored in the
- * Property
- */
- public String toString();
-
- /**
- * Returns the type of the Property. The methods <code>getValue</code>
- * and <code>setValue</code> must be compatible with this type: one
- * must be able to safely cast the value returned from
- * <code>getValue</code> to the given type and pass any variable
- * assignable to this type as an argument to <code>setValue</code>.
- *
- * @return type of the Property
- */
- public Class getType();
-
- /**
- * Tests if the Property is in read-only mode. In read-only mode calls
- * to the method <code>setValue</code> will throw
- * <code>ReadOnlyException</code> and will not modify the value of the
- * Property.
- *
- * @return <code>true</code> if the Property is in read-only mode,
- * <code>false</code> if it's not
- */
- public boolean isReadOnly();
-
- /**
- * Sets the Property's read-only mode to the specified status.
- *
- * This functionality is optional, but all properties must implement
- * the <code>isReadOnly</code> mode query correctly.
- *
- * @param newStatus new read-only status of the Property
- */
- public void setReadOnly(boolean newStatus);
-
- /**
- * <code>Exception</code> object that signals that a requested
- * Property modification failed because it's in read-only mode.
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
- public class ReadOnlyException extends RuntimeException {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3257571702287119410L;
-
- /**
- * Constructs a new <code>ReadOnlyException</code> without a detail
- * message.
- */
- public ReadOnlyException() {
- }
-
- /**
- * Constructs a new <code>ReadOnlyException</code> with the
- * specified detail message.
- *
- * @param msg the detail message
- */
- public ReadOnlyException(String msg) {
- super(msg);
- }
- }
-
- /**
- * An exception that signals that the value passed to the
- * <code>setValue</code> method couldn't be converted to the native
- * type of the Property.
- * @author IT Mill Ltd
- * @version @VERSION@
- * @since 3.0
- */
- public class ConversionException extends RuntimeException {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3257571706666366008L;
-
- /**
- * Constructs a new <code>ConversionException</code> without a
- * detail message.
- */
- public ConversionException() {
- }
-
- /**
- * Constructs a new <code>ConversionException</code> with the
- * specified detail message.
- *
- * @param msg the detail message
- */
- public ConversionException(String msg) {
- super(msg);
- }
-
- /**
- * Constructs a new <code>ConversionException</code> from another
- * exception.
- *
- * @param cause The cause of the the conversion failure
- */
- public ConversionException(Throwable cause) {
- super(cause.toString());
- }
- }
-
- /**
- * Interface implemented by the viewer classes capable of using a
- * Property as a data source.
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
- public interface Viewer {
-
- /**
- * Sets the Property that serves as the data source of the viewer.
- *
- * @param newDataSource the new data source Property
- */
- public void setPropertyDataSource(Property newDataSource);
-
- /**
- * Gets the Property serving as the data source of the viewer.
- *
- * @return the Property serving as the viewers data source
- */
- public Property getPropertyDataSource();
- }
-
- /**
- * Interface implemented by the editor classes capable of editing the
- * Property.
- * <p>
- * Implementing this interface means that the Property serving
- * as the data source of the editor can be modified through the editor.
- * It does not restrict the editor from editing the Property internally,
- * though if the Property is in a read-only mode, attempts to modify it
- * will result in the <code>ReadOnlyException</code> being thrown.
- * </p>
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
- public interface Editor extends Property.Viewer {
-
- }
-
- /* Value change event ******************************************* */
-
- /**
- * An <code>Event</code> object specifying the Property whose value
- * has been changed.
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
- public interface ValueChangeEvent {
-
- /**
- * Retrieves the Property that has been modified.
- *
- * @return source Property of the event
- */
- public Property getProperty();
- }
-
- /**
- * The <code>listener</code> interface for receiving <code>ValueChangeEvent</code> objects.
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- **/
- public interface ValueChangeListener {
-
- /**
- * Notifies this listener that the Property's value has changed.
- *
- * @param event value change event object
- */
- public void valueChange(Property.ValueChangeEvent event);
- }
-
- /**
- * The interface for adding and removing <code>ValueChangeEvent</code>
- * listeners. If a Property wishes to allow other objects to receive
- * <code>ValueChangeEvent</code> generated by it, it must implement
- * this interface.
- * <p>
- * Note : The general Java convention is not to explicitly declare
- * that a class generates events, but to directly define the
- * <code>addListener</code> and <code>removeListener</code> methods.
- * That way the caller of these methods has no real way of finding out
- * if the class really will send the events, or if it just defines the
- * methods to be able to implement an interface.
- * </p>
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
- public interface ValueChangeNotifier {
-
- /**
- * Registers a new value change listener for this Property.
- *
- * @param listener the new Listener to be registered
- */
- public void addListener(Property.ValueChangeListener listener);
-
- /**
- * Removes a previously registered value change listener.
- *
- * @param listener listener to be removed
- */
- public void removeListener(Property.ValueChangeListener listener);
- }
-
- /* ReadOnly Status change event ***************************************** */
-
- /**
- * An <code>Event</code> object specifying the Property whose read-only
- * status has been changed.
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
- public interface ReadOnlyStatusChangeEvent {
-
- /**
- * Property whose read-only state has changed.
- *
- * @return source Property of the event.
- */
- public Property getProperty();
- }
-
- /**
- * The listener interface for receiving <code>ReadOnlyStatusChangeEvent</code>
- * objects.
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- * */
- public interface ReadOnlyStatusChangeListener {
-
- /**
- * Notifies this listener that a Property's read-only status has
- * changed.
- *
- * @param event Read-only status change event object
- */
- public void readOnlyStatusChange(
- Property.ReadOnlyStatusChangeEvent event);
- }
-
- /**
- * The interface for adding and removing <code>ReadOnlyStatusChangeEvent</code>
- * listeners. If a Property wishes to allow other objects to receive
- * <code>ReadOnlyStatusChangeEvent</code> generated by it, it must
- * implement this interface.
- * <p>
- * Note : The general Java convention is not to explicitly declare
- * that a class generates events, but to directly define the
- * <code>addListener</code> and <code>removeListener</code> methods.
- * That way the caller of these methods has no real way of finding out
- * if the class really will send the events, or if it just defines the
- * methods to be able to implement an interface.
- * </p>
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
- public interface ReadOnlyStatusChangeNotifier {
-
- /**
- * Registers a new read-only status change listener for this
- * Property.
- *
- * @param listener the new Listener to be registered
- */
- public void addListener(Property.ReadOnlyStatusChangeListener listener);
-
- /**
- * Removes a previously registered read-only status change listener.
- *
- * @param listener listener to be removed
- */
- public void removeListener(
- Property.ReadOnlyStatusChangeListener listener);
- }
+
+ /**
+ * Gets the value stored in the Property.
+ *
+ * @return the value stored in the Property
+ */
+ public Object getValue();
+
+ /**
+ * Sets the value of the Property.
+ * <p>
+ * Implementing this functionality is optional. If the functionality is
+ * missing, one should declare the Property to be in read-only mode and
+ * throw <code>Property.ReadOnlyException</code> in this function.
+ * </p>
+ * Note : It is not required, but highly recommended to support setting the
+ * value also as a <code>String</code> in addition to the native type of
+ * the Property (as given by the <code>getType</code> method). If the
+ * <code>String</code> conversion fails or is unsupported, the method
+ * should throw <code>Property.ConversionException</code>. The string
+ * conversion should at least understand the format returned by the
+ * <code>toString</code> method of the Property.
+ *
+ * @param newValue
+ * New value of the Property. This should be assignable to the
+ * type returned by getType, but also String type should be
+ * supported
+ *
+ * @throws Property.ReadOnlyException
+ * if the object is in read-only mode
+ * @throws Property.ConversionException
+ * if newValue can't be converted into the Property's native
+ * type directly or through String
+ */
+ public void setValue(Object newValue) throws Property.ReadOnlyException,
+ Property.ConversionException;
+
+ /**
+ * Returns the value of the Property in human readable textual format. The
+ * return value should be assignable to the <code>setValue</code> method
+ * if the Property is not in read-only mode.
+ *
+ * @return <code>String</code> representation of the value stored in the
+ * Property
+ */
+ public String toString();
+
+ /**
+ * Returns the type of the Property. The methods <code>getValue</code> and
+ * <code>setValue</code> must be compatible with this type: one must be
+ * able to safely cast the value returned from <code>getValue</code> to
+ * the given type and pass any variable assignable to this type as an
+ * argument to <code>setValue</code>.
+ *
+ * @return type of the Property
+ */
+ public Class getType();
+
+ /**
+ * Tests if the Property is in read-only mode. In read-only mode calls to
+ * the method <code>setValue</code> will throw
+ * <code>ReadOnlyException</code> and will not modify the value of the
+ * Property.
+ *
+ * @return <code>true</code> if the Property is in read-only mode,
+ * <code>false</code> if it's not
+ */
+ public boolean isReadOnly();
+
+ /**
+ * Sets the Property's read-only mode to the specified status.
+ *
+ * This functionality is optional, but all properties must implement the
+ * <code>isReadOnly</code> mode query correctly.
+ *
+ * @param newStatus
+ * new read-only status of the Property
+ */
+ public void setReadOnly(boolean newStatus);
+
+ /**
+ * <code>Exception</code> object that signals that a requested Property
+ * modification failed because it's in read-only mode.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public class ReadOnlyException extends RuntimeException {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3257571702287119410L;
+
+ /**
+ * Constructs a new <code>ReadOnlyException</code> without a detail
+ * message.
+ */
+ public ReadOnlyException() {
+ }
+
+ /**
+ * Constructs a new <code>ReadOnlyException</code> with the specified
+ * detail message.
+ *
+ * @param msg
+ * the detail message
+ */
+ public ReadOnlyException(String msg) {
+ super(msg);
+ }
+ }
+
+ /**
+ * An exception that signals that the value passed to the
+ * <code>setValue</code> method couldn't be converted to the native type
+ * of the Property.
+ *
+ * @author IT Mill Ltd
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public class ConversionException extends RuntimeException {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3257571706666366008L;
+
+ /**
+ * Constructs a new <code>ConversionException</code> without a detail
+ * message.
+ */
+ public ConversionException() {
+ }
+
+ /**
+ * Constructs a new <code>ConversionException</code> with the
+ * specified detail message.
+ *
+ * @param msg
+ * the detail message
+ */
+ public ConversionException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>ConversionException</code> from another
+ * exception.
+ *
+ * @param cause
+ * The cause of the the conversion failure
+ */
+ public ConversionException(Throwable cause) {
+ super(cause.toString());
+ }
+ }
+
+ /**
+ * Interface implemented by the viewer classes capable of using a Property
+ * as a data source.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public interface Viewer {
+
+ /**
+ * Sets the Property that serves as the data source of the viewer.
+ *
+ * @param newDataSource
+ * the new data source Property
+ */
+ public void setPropertyDataSource(Property newDataSource);
+
+ /**
+ * Gets the Property serving as the data source of the viewer.
+ *
+ * @return the Property serving as the viewers data source
+ */
+ public Property getPropertyDataSource();
+ }
+
+ /**
+ * Interface implemented by the editor classes capable of editing the
+ * Property.
+ * <p>
+ * Implementing this interface means that the Property serving as the data
+ * source of the editor can be modified through the editor. It does not
+ * restrict the editor from editing the Property internally, though if the
+ * Property is in a read-only mode, attempts to modify it will result in the
+ * <code>ReadOnlyException</code> being thrown.
+ * </p>
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public interface Editor extends Property.Viewer {
+
+ }
+
+ /* Value change event ******************************************* */
+
+ /**
+ * An <code>Event</code> object specifying the Property whose value has
+ * been changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public interface ValueChangeEvent {
+
+ /**
+ * Retrieves the Property that has been modified.
+ *
+ * @return source Property of the event
+ */
+ public Property getProperty();
+ }
+
+ /**
+ * The <code>listener</code> interface for receiving
+ * <code>ValueChangeEvent</code> objects.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public interface ValueChangeListener {
+
+ /**
+ * Notifies this listener that the Property's value has changed.
+ *
+ * @param event
+ * value change event object
+ */
+ public void valueChange(Property.ValueChangeEvent event);
+ }
+
+ /**
+ * The interface for adding and removing <code>ValueChangeEvent</code>
+ * listeners. If a Property wishes to allow other objects to receive
+ * <code>ValueChangeEvent</code> generated by it, it must implement this
+ * interface.
+ * <p>
+ * Note : The general Java convention is not to explicitly declare that a
+ * class generates events, but to directly define the
+ * <code>addListener</code> and <code>removeListener</code> methods.
+ * That way the caller of these methods has no real way of finding out if
+ * the class really will send the events, or if it just defines the methods
+ * to be able to implement an interface.
+ * </p>
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public interface ValueChangeNotifier {
+
+ /**
+ * Registers a new value change listener for this Property.
+ *
+ * @param listener
+ * the new Listener to be registered
+ */
+ public void addListener(Property.ValueChangeListener listener);
+
+ /**
+ * Removes a previously registered value change listener.
+ *
+ * @param listener
+ * listener to be removed
+ */
+ public void removeListener(Property.ValueChangeListener listener);
+ }
+
+ /* ReadOnly Status change event ***************************************** */
+
+ /**
+ * An <code>Event</code> object specifying the Property whose read-only
+ * status has been changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public interface ReadOnlyStatusChangeEvent {
+
+ /**
+ * Property whose read-only state has changed.
+ *
+ * @return source Property of the event.
+ */
+ public Property getProperty();
+ }
+
+ /**
+ * The listener interface for receiving
+ * <code>ReadOnlyStatusChangeEvent</code> objects.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public interface ReadOnlyStatusChangeListener {
+
+ /**
+ * Notifies this listener that a Property's read-only status has
+ * changed.
+ *
+ * @param event
+ * Read-only status change event object
+ */
+ public void readOnlyStatusChange(
+ Property.ReadOnlyStatusChangeEvent event);
+ }
+
+ /**
+ * The interface for adding and removing
+ * <code>ReadOnlyStatusChangeEvent</code> listeners. If a Property wishes
+ * to allow other objects to receive <code>ReadOnlyStatusChangeEvent</code>
+ * generated by it, it must implement this interface.
+ * <p>
+ * Note : The general Java convention is not to explicitly declare that a
+ * class generates events, but to directly define the
+ * <code>addListener</code> and <code>removeListener</code> methods.
+ * That way the caller of these methods has no real way of finding out if
+ * the class really will send the events, or if it just defines the methods
+ * to be able to implement an interface.
+ * </p>
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public interface ReadOnlyStatusChangeNotifier {
+
+ /**
+ * Registers a new read-only status change listener for this Property.
+ *
+ * @param listener
+ * the new Listener to be registered
+ */
+ public void addListener(Property.ReadOnlyStatusChangeListener listener);
+
+ /**
+ * Removes a previously registered read-only status change listener.
+ *
+ * @param listener
+ * listener to be removed
+ */
+ public void removeListener(
+ Property.ReadOnlyStatusChangeListener listener);
+ }
}
diff --git a/src/com/itmill/toolkit/data/Validatable.java b/src/com/itmill/toolkit/data/Validatable.java
index b60ee46b54..4cce9bc983 100644
--- a/src/com/itmill/toolkit/data/Validatable.java
+++ b/src/com/itmill/toolkit/data/Validatable.java
@@ -1,131 +1,133 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data;
import java.util.Collection;
-/**
+/**
* <p>
- * Interface for validatable objects. Defines methods to verify if the
- * object's value is valid or not, and to add, remove and list registered
- * validators of the object.
+ * Interface for validatable objects. Defines methods to verify if the object's
+ * value is valid or not, and to add, remove and list registered validators of
+ * the object.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
* @see com.itmill.toolkit.data.Validator
- */
+ */
public interface Validatable {
-
- /**
- * <p>
- * Adds a new validator for this object. The validator's
- * {@link Validator#validate(Object)} method is activated every time the
- * object's value needs to be verified, that is, when the
- * {@link #isValid()} method is called. This usually happens when the
- * object's value changes.
- * </p>
- *
- * @param validator the new validator
- */
- void addValidator(Validator validator);
-
- /**
- * <p>
- * Removes a previously registered validator from the object. The specified
- * validator is removed from the object and its <code>validate</code> method
- * is no longer called in {@link #isValid()}.
- * </p>
- *
- * @param validator the validator to remove
- */
- void removeValidator(Validator validator);
-
- /**
- * <p>
- * Lists all validators currently registered for the object. If no
- * validators are registered, returns <code>null</code>.
- * </p>
- *
- * @return collection of validators or <code>null</code>
- */
- public Collection getValidators();
-
- /**
- * <p>
- * Tests the current value of the object against all registered
- * validators. The registered validators are iterated and for each the
- * {@link Validator#validate(Object)} method is called. If any validator
- * throws the {@link Validator.InvalidValueException} this method
- * returns <code>false</code>.
- * </p>
- *
- * @return <code>true</code> if the registered validators concur that
- * the value is valid, <code>false</code> otherwise
- */
- public boolean isValid();
-
- /**
- * <p>
- * Checks the validity of the validatable. If the validatable is valid
- * this method should do nothing, and if it's not valid, it should throw
- * <code>Validator.InvalidValueException</code>
- * </p>
- *
- * @throws Validator.InvalidValueException if the value is not valid
- */
- public void validate()
- throws Validator.InvalidValueException;
-
- /**
+
+ /**
* <p>
- * Checks the validabtable object accept invalid values.The default value
- * is <code>true</code>.
+ * Adds a new validator for this object. The validator's
+ * {@link Validator#validate(Object)} method is activated every time the
+ * object's value needs to be verified, that is, when the {@link #isValid()}
+ * method is called. This usually happens when the object's value changes.
* </p>
*
+ * @param validator
+ * the new validator
*/
- public boolean isInvalidAllowed();
+ void addValidator(Validator validator);
/**
* <p>
- * Should the validabtable object accept invalid values. Supporting
- * this configuration possibility is optional. By default invalid values are
+ * Removes a previously registered validator from the object. The specified
+ * validator is removed from the object and its <code>validate</code>
+ * method is no longer called in {@link #isValid()}.
+ * </p>
+ *
+ * @param validator
+ * the validator to remove
+ */
+ void removeValidator(Validator validator);
+
+ /**
+ * <p>
+ * Lists all validators currently registered for the object. If no
+ * validators are registered, returns <code>null</code>.
+ * </p>
+ *
+ * @return collection of validators or <code>null</code>
+ */
+ public Collection getValidators();
+
+ /**
+ * <p>
+ * Tests the current value of the object against all registered validators.
+ * The registered validators are iterated and for each the
+ * {@link Validator#validate(Object)} method is called. If any validator
+ * throws the {@link Validator.InvalidValueException} this method returns
+ * <code>false</code>.
+ * </p>
+ *
+ * @return <code>true</code> if the registered validators concur that the
+ * value is valid, <code>false</code> otherwise
+ */
+ public boolean isValid();
+
+ /**
+ * <p>
+ * Checks the validity of the validatable. If the validatable is valid this
+ * method should do nothing, and if it's not valid, it should throw
+ * <code>Validator.InvalidValueException</code>
+ * </p>
+ *
+ * @throws Validator.InvalidValueException
+ * if the value is not valid
+ */
+ public void validate() throws Validator.InvalidValueException;
+
+ /**
+ * <p>
+ * Checks the validabtable object accept invalid values.The default value is
+ * <code>true</code>.
+ * </p>
+ *
+ */
+ public boolean isInvalidAllowed();
+
+ /**
+ * <p>
+ * Should the validabtable object accept invalid values. Supporting this
+ * configuration possibility is optional. By default invalid values are
* allowed.
* </p>
*
* @param invalidValueAllowed
*
* @throws UnsupportedOperationException
- * if the setInvalidAllowed is not supported.
+ * if the setInvalidAllowed is not supported.
*/
- public void setInvalidAllowed(boolean invalidValueAllowed)
- throws UnsupportedOperationException;
-
+ public void setInvalidAllowed(boolean invalidValueAllowed)
+ throws UnsupportedOperationException;
+
}
diff --git a/src/com/itmill/toolkit/data/Validator.java b/src/com/itmill/toolkit/data/Validator.java
index 9ae86006a7..c4397eb95a 100644
--- a/src/com/itmill/toolkit/data/Validator.java
+++ b/src/com/itmill/toolkit/data/Validator.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data;
@@ -32,106 +32,118 @@ import com.itmill.toolkit.terminal.ErrorMessage;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-/**
- * Object validator interface. Implementors of this class can be added to
- * any {@link com.itmill.toolkit.data.Validatable} object to verify
- * its value. The <code>Validatable#isValid(Object)</code> iterates all
- * registered <code>Validator</code>s, calling their {@link #validate(Object)}
- * methods. <code>validate(Object)</code> should throw the
- * {@link Validator.InvalidValueException} if the given value is not valid
- * by its standards.
- *
+/**
+ * Object validator interface. Implementors of this class can be added to any
+ * {@link com.itmill.toolkit.data.Validatable} object to verify its value. The
+ * <code>Validatable#isValid(Object)</code> iterates all registered
+ * <code>Validator</code>s, calling their {@link #validate(Object)} methods.
+ * <code>validate(Object)</code> should throw the
+ * {@link Validator.InvalidValueException} if the given value is not valid by
+ * its standards.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Validator {
- /**
- * Checks the given value against this validator. If the value is valid
- * this method should do nothing, and if it's not valid, it should throw
+ /**
+ * Checks the given value against this validator. If the value is valid this
+ * method should do nothing, and if it's not valid, it should throw
* <code>Validator.InvalidValueException</code>
*
- * @param value the value to check
- * @throws Validator.InvalidValueException if the value is not valid
+ * @param value
+ * the value to check
+ * @throws Validator.InvalidValueException
+ * if the value is not valid
*/
public void validate(Object value) throws Validator.InvalidValueException;
- /**
+ /**
* Tests if the given value is valid.
- * @param value the value to check
+ *
+ * @param value
+ * the value to check
* @return <code>true</code> for valid value, otherwise <code>false</code>.
*/
public boolean isValid(Object value);
- /**
+ /**
* Adds the proposing functionality to a {@link Validator}. A
* <code>Suggestive</code> validator can propose a valid value for the
* object it is attached to validate. This way the {@link Validatable}
- * object may avoid situations where it contains a value that could
- * lead to a error.
+ * object may avoid situations where it contains a value that could lead to
+ * a error.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Suggestive extends Validator {
- /**
- * Suggests another value that can be used instead of the
- * proposedValue if it is invalid. If it is valid
- * in the opinion of this validator, however, it is returned as is.
+ /**
+ * Suggests another value that can be used instead of the proposedValue
+ * if it is invalid. If it is valid in the opinion of this validator,
+ * however, it is returned as is.
*
- * @param proposedValue Originally proposed value that could be
- * invalid.
+ * @param proposedValue
+ * Originally proposed value that could be invalid.
* @return Suggested value that's not invalid against this validator
*/
public Object suggestValidValue(Object proposedValue);
}
- /**
- * Invalid value exception can be thrown by {@link Validator} when a
- * given value is not valid.
+ /**
+ * Invalid value exception can be thrown by {@link Validator} when a given
+ * value is not valid.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
- public class InvalidValueException
- extends RuntimeException
- implements ErrorMessage {
+ public class InvalidValueException extends RuntimeException implements
+ ErrorMessage {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3689073941163422257L;
- /** Array of validation errors that are causing the problem. */
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3689073941163422257L;
+
+ /** Array of validation errors that are causing the problem. */
private InvalidValueException[] causes = null;
- /**
+ /**
* Constructs a new <code>InvalidValueException</code> with the
* specified detail message.
*
- * @param message The detail message of the problem.
+ * @param message
+ * The detail message of the problem.
*/
public InvalidValueException(String message) {
- this(message, new InvalidValueException[] {
- });
+ this(message, new InvalidValueException[] {});
}
- /**
- * Constructs a new <code>InvalidValueException</code> with a set
- * of causing validation exceptions. The error message contains
- * first the given message and then a list of validation errors
- * in the given validatables.
+ /**
+ * Constructs a new <code>InvalidValueException</code> with a set of
+ * causing validation exceptions. The error message contains first the
+ * given message and then a list of validation errors in the given
+ * validatables.
*
- * @param message The detail message of the problem.
- * @param causes Array of validatables whos invalidities are possiblity causing the invalidity.
+ * @param message
+ * The detail message of the problem.
+ * @param causes
+ * Array of validatables whos invalidities are possiblity
+ * causing the invalidity.
*/
- public InvalidValueException(
- String message,
- InvalidValueException[] causes) {
+ public InvalidValueException(String message,
+ InvalidValueException[] causes) {
super(message);
if (causes == null)
- throw new NullPointerException("Possible causes array must not be null");
+ throw new NullPointerException(
+ "Possible causes array must not be null");
this.causes = causes;
}
diff --git a/src/com/itmill/toolkit/data/util/BeanItem.java b/src/com/itmill/toolkit/data/util/BeanItem.java
index 4ab7026c10..de5f291394 100644
--- a/src/com/itmill/toolkit/data/util/BeanItem.java
+++ b/src/com/itmill/toolkit/data/util/BeanItem.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -37,34 +37,36 @@ import java.util.Iterator;
import com.itmill.toolkit.data.Property;
-/**
+/**
* A wrapper class for adding the Item interface to any Java Bean.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class BeanItem extends PropertysetItem {
/**
- * The bean which this Item is based on.
+ * The bean which this Item is based on.
*/
private Object bean;
- /**
+ /**
* <p>
- * Creates a new instance of <code>BeanItem</code> and adds all properties of a
- * Java Bean to it. The properties are identified by their respective
+ * Creates a new instance of <code>BeanItem</code> and adds all properties
+ * of a Java Bean to it. The properties are identified by their respective
* bean names.
* </p>
*
* <p>
- * Note : This version only supports introspectable bean
- * properties and their getter and setter methods. Stand-alone <code>is</code> and
+ * Note : This version only supports introspectable bean properties and
+ * their getter and setter methods. Stand-alone <code>is</code> and
* <code>are</code> methods are not supported.
* </p>
*
- * @param bean the Java Bean to copy properties from.
+ * @param bean
+ * the Java Bean to copy properties from.
*
*/
public BeanItem(Object bean) {
@@ -84,33 +86,34 @@ public class BeanItem extends PropertysetItem {
Class type = pd[i].getPropertyType();
String name = pd[i].getName();
- Property p =
- new MethodProperty(type, bean, getMethod, setMethod);
+ Property p = new MethodProperty(type, bean, getMethod,
+ setMethod);
addItemProperty(name, p);
}
} catch (java.beans.IntrospectionException ignored) {
}
}
- /**
+ /**
* <p>
- * Creates a new instance of <code>BeanItem</code> and adds all listed properties of a
- * Java Bean to it - in specified order. The properties are identified by their
- * respective bean names.
+ * Creates a new instance of <code>BeanItem</code> and adds all listed
+ * properties of a Java Bean to it - in specified order. The properties are
+ * identified by their respective bean names.
* </p>
*
* <p>
- * Note : This version only supports introspectable bean properties and their getter
- * and setter methods. Stand-alone <code>is</code> and <code>are</code> methods
- * are not supported.
+ * Note : This version only supports introspectable bean properties and
+ * their getter and setter methods. Stand-alone <code>is</code> and
+ * <code>are</code> methods are not supported.
* </p>
*
- * @param bean the Java Bean to copy properties from.
+ * @param bean
+ * the Java Bean to copy properties from.
* @param propertyIds
- * id of the property.
+ * id of the property.
*/
public BeanItem(Object bean, Collection propertyIds) {
-
+
this.bean = bean;
// Try to introspect, if it fails, we just have an empty Item
@@ -129,11 +132,7 @@ public class BeanItem extends PropertysetItem {
Method setMethod = pd[i].getWriteMethod();
Class type = pd[i].getPropertyType();
- Property p =
- new MethodProperty(
- type,
- bean,
- getMethod,
+ Property p = new MethodProperty(type, bean, getMethod,
setMethod);
addItemProperty(name, p);
}
@@ -145,8 +144,9 @@ public class BeanItem extends PropertysetItem {
}
- /**
- * Gets the underlying JavaBean object.
+ /**
+ * Gets the underlying JavaBean object.
+ *
* @return the bean object.
*/
public Object getBean() {
diff --git a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java
index b275fb7a22..6939a1be70 100644
--- a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java
+++ b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -39,28 +39,25 @@ import com.itmill.toolkit.data.Container;
import com.itmill.toolkit.data.Item;
import com.itmill.toolkit.data.Property;
-/**
+/**
* <p>
- * A wrapper class for adding external hierarchy to containers not
- * implementing the {@link com.itmill.toolkit.data.Container.Hierarchical}
- * interface.
+ * A wrapper class for adding external hierarchy to containers not implementing
+ * the {@link com.itmill.toolkit.data.Container.Hierarchical} interface.
* </p>
*
* <p>
- * If the wrapped container is changed directly (that is, not through
- * the wrapper), the hierarchy information must be updated with the
+ * If the wrapped container is changed directly (that is, not through the
+ * wrapper), the hierarchy information must be updated with the
* {@link #updateHierarchicalWrapper()} method.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class ContainerHierarchicalWrapper
- implements
- Container.Hierarchical,
- Container.ItemSetChangeNotifier,
- Container.PropertySetChangeNotifier {
+public class ContainerHierarchicalWrapper implements Container.Hierarchical,
+ Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier {
/** The wrapped container */
private Container container;
@@ -80,13 +77,13 @@ public class ContainerHierarchicalWrapper
/** Is the wrapped container hierarchical by itself ? */
private boolean hierarchical;
- /**
- * Constructs a new hierarchical wrapper for an existing Container.
- * Works even if the to-be-wrapped container already implements the
+ /**
+ * Constructs a new hierarchical wrapper for an existing Container. Works
+ * even if the to-be-wrapped container already implements the
* <code>Container.Hierarchical</code> interface.
*
- * @param toBeWrapped the container that needs to be accessed
- * hierarchically
+ * @param toBeWrapped
+ * the container that needs to be accessed hierarchically
* @see #updateHierarchicalWrapper()
*/
public ContainerHierarchicalWrapper(Container toBeWrapped) {
@@ -109,21 +106,19 @@ public class ContainerHierarchicalWrapper
updateHierarchicalWrapper();
}
- /**
- * Updates the wrapper's internal hierarchy data to include all Items
- * in the underlying container. If the contents of the wrapped container
- * change without the wrapper's knowledge, this method needs to be
- * called to update the hierarchy information of the Items.
+ /**
+ * Updates the wrapper's internal hierarchy data to include all Items in the
+ * underlying container. If the contents of the wrapped container change
+ * without the wrapper's knowledge, this method needs to be called to update
+ * the hierarchy information of the Items.
*/
public void updateHierarchicalWrapper() {
if (!hierarchical) {
// Recreate hierarchy and datasrtuctures if missing
- if (noChildrenAllowed == null
- || parent == null
- || children == null
- || roots == null) {
+ if (noChildrenAllowed == null || parent == null || children == null
+ || roots == null) {
noChildrenAllowed = new HashSet();
parent = new Hashtable();
children = new Hashtable();
@@ -162,11 +157,12 @@ public class ContainerHierarchicalWrapper
/**
* Removes the specified Item from the wrapper's internal hierarchy
* structure.
- * <p>
- * Note : The Item is not removed from the underlying
- * Container.
+ * <p>
+ * Note : The Item is not removed from the underlying Container.
* </p>
- * @param itemId the ID of the item to remove from the hierarchy.
+ *
+ * @param itemId
+ * the ID of the item to remove from the hierarchy.
*/
private void removeFromHierarchyWrapper(Object itemId) {
@@ -183,33 +179,35 @@ public class ContainerHierarchicalWrapper
noChildrenAllowed.remove(itemId);
}
- /**
- * Adds the specified Item specified to the internal hierarchy
- * structure. The new item is added as a root Item. The underlying
- * container is not modified.
+ /**
+ * Adds the specified Item specified to the internal hierarchy structure.
+ * The new item is added as a root Item. The underlying container is not
+ * modified.
*
- * @param itemId the ID of the item to add to the hierarchy.
+ * @param itemId
+ * the ID of the item to add to the hierarchy.
*/
private void addToHierarchyWrapper(Object itemId) {
roots.add(itemId);
}
- /* Can the specified Item have any children?
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Can the specified Item have any children? Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public boolean areChildrenAllowed(Object itemId) {
// If the wrapped container implements the method directly, use it
if (hierarchical)
- return ((Container.Hierarchical) container).areChildrenAllowed(
- itemId);
+ return ((Container.Hierarchical) container)
+ .areChildrenAllowed(itemId);
return !noChildrenAllowed.contains(itemId);
}
- /* Gets the IDs of the children of the specified Item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the IDs of the children of the specified Item. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection getChildren(Object itemId) {
@@ -223,9 +221,10 @@ public class ContainerHierarchicalWrapper
return Collections.unmodifiableCollection(c);
}
- /* Gets the ID of the parent of the specified Item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the ID of the parent of the specified Item. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Object getParent(Object itemId) {
@@ -236,9 +235,10 @@ public class ContainerHierarchicalWrapper
return parent.get(itemId);
}
- /* Is the Item corresponding to the given ID a leaf node?
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Is the Item corresponding to the given ID a leaf node? Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean hasChildren(Object itemId) {
@@ -249,9 +249,10 @@ public class ContainerHierarchicalWrapper
return children.get(itemId) != null;
}
- /* Is the Item corresponding to the given ID a root node?
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Is the Item corresponding to the given ID a root node? Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean isRoot(Object itemId) {
@@ -262,9 +263,10 @@ public class ContainerHierarchicalWrapper
return parent.get(itemId) == null;
}
- /* Gets the IDs of the root elements in the container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the IDs of the root elements in the container. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection rootItemIds() {
@@ -275,30 +277,31 @@ public class ContainerHierarchicalWrapper
return Collections.unmodifiableCollection(roots);
}
- /**
+ /**
* <p>
- * Sets the given Item's capability to have children. If the Item
- * identified with the itemId already has children and the
- * areChildrenAllowed is false this method fails and
- * <code>false</code> is returned; the children must be first explicitly
- * removed with {@link #setParent(Object itemId, Object newParentId)} or
+ * Sets the given Item's capability to have children. If the Item identified
+ * with the itemId already has children and the areChildrenAllowed is false
+ * this method fails and <code>false</code> is returned; the children must
+ * be first explicitly removed with
+ * {@link #setParent(Object itemId, Object newParentId)} or
* {@link com.itmill.toolkit.data.Container#removeItem(Object itemId)}.
* </p>
*
- * @param itemId the ID of the Item in the container whose child
- * capability is to be set.
- * @param childrenAllowed the boolean value specifying if the Item
- * can have children or not.
+ * @param itemId
+ * the ID of the Item in the container whose child capability is
+ * to be set.
+ * @param childrenAllowed
+ * the boolean value specifying if the Item can have children or
+ * not.
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
*/
public boolean setChildrenAllowed(Object itemId, boolean childrenAllowed) {
// If the wrapped container implements the method directly, use it
if (hierarchical)
return ((Container.Hierarchical) container).setChildrenAllowed(
- itemId,
- childrenAllowed);
+ itemId, childrenAllowed);
// Check that the item is in the container
if (!containsId(itemId))
@@ -313,29 +316,29 @@ public class ContainerHierarchicalWrapper
return true;
}
- /**
+ /**
* <p>
- * Sets the parent of an Item. The new parent item must exist and be
- * able to have children.
- * (<code>canHaveChildren(newParentId) == true</code>). It is also
- * possible to detach a node from the hierarchy (and thus make it root)
- * by setting the parent <code>null</code>.
+ * Sets the parent of an Item. The new parent item must exist and be able to
+ * have children. (<code>canHaveChildren(newParentId) == true</code>).
+ * It is also possible to detach a node from the hierarchy (and thus make it
+ * root) by setting the parent <code>null</code>.
* </p>
*
- * @param itemId the ID of the item to be set as the child of the Item
- * identified with newParentId.
- * @param newParentId the ID of the Item that's to be the new parent
- * of the Item identified with itemId.
+ * @param itemId
+ * the ID of the item to be set as the child of the Item
+ * identified with newParentId.
+ * @param newParentId
+ * the ID of the Item that's to be the new parent of the Item
+ * identified with itemId.
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
*/
public boolean setParent(Object itemId, Object newParentId) {
// If the wrapped container implements the method directly, use it
if (hierarchical)
- return ((Container.Hierarchical) container).setParent(
- itemId,
- newParentId);
+ return ((Container.Hierarchical) container).setParent(itemId,
+ newParentId);
// Check that the item is in the container
if (!containsId(itemId))
@@ -344,12 +347,12 @@ public class ContainerHierarchicalWrapper
// Get the old parent
Object oldParentId = parent.get(itemId);
- // Check if no change is necessary
+ // Check if no change is necessary
if ((newParentId == null && oldParentId == null)
- || newParentId.equals(oldParentId))
+ || newParentId.equals(oldParentId))
return true;
- // Making root
+ // Making root
if (newParentId == null) {
// Remove from old parents children list
@@ -371,8 +374,7 @@ public class ContainerHierarchicalWrapper
// Check that the new parent exists in container and can have
// children
- if (!containsId(newParentId)
- || noChildrenAllowed.contains(newParentId))
+ if (!containsId(newParentId) || noChildrenAllowed.contains(newParentId))
return false;
// Check that setting parent doesn't result to a loop
@@ -406,14 +408,14 @@ public class ContainerHierarchicalWrapper
return true;
}
- /**
- * Creates a new Item into the Container, assigns it an
- * automatic ID, and adds it to the hierarchy.
+ /**
+ * Creates a new Item into the Container, assigns it an automatic ID, and
+ * adds it to the hierarchy.
*
- * @return the autogenerated ID of the new Item or <code>null</code>
- * if the operation failed
+ * @return the autogenerated ID of the new Item or <code>null</code> if
+ * the operation failed
* @throws UnsupportedOperationException
- * if the addItem is not supported.
+ * if the addItem is not supported.
*/
public Object addItem() throws UnsupportedOperationException {
@@ -423,14 +425,15 @@ public class ContainerHierarchicalWrapper
return id;
}
- /**
+ /**
* Adds a new Item by its ID to the underlying container and to the
* hierarchy.
+ *
* @param itemId
- * the ID of the Item to be created.
+ * the ID of the Item to be created.
* @return the added Item or <code>null</code> if the operation failed.
* @throws UnsupportedOperationException
- * if the addItem is not supported.
+ * if the addItem is not supported.
*/
public Item addItem(Object itemId) throws UnsupportedOperationException {
@@ -440,14 +443,13 @@ public class ContainerHierarchicalWrapper
return item;
}
- /**
- * Removes all items from the underlying container and from the
- * hierarcy.
+ /**
+ * Removes all items from the underlying container and from the hierarcy.
*
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
* @throws UnsupportedOperationException
- * if the removeAllItems is not supported.
+ * if the removeAllItems is not supported.
*/
public boolean removeAllItems() throws UnsupportedOperationException {
@@ -462,18 +464,19 @@ public class ContainerHierarchicalWrapper
return success;
}
- /**
- * Removes an Item specified by the itemId from the underlying
- * container and from the hierarcy.
+ /**
+ * Removes an Item specified by the itemId from the underlying container and
+ * from the hierarcy.
+ *
* @param itemId
- * the ID of the Item to be removed.
+ * the ID of the Item to be removed.
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
* @throws UnsupportedOperationException
- * if the removeItem is not supported.
+ * if the removeItem is not supported.
*/
public boolean removeItem(Object itemId)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
boolean success = container.removeItem(itemId);
@@ -483,139 +486,146 @@ public class ContainerHierarchicalWrapper
return success;
}
- /**
+ /**
* Adds a new Property to all Items in the Container.
- *
- * @param propertyId the ID of the new Property.
- * @param type the Data type of the new Property.
- * @param defaultValue the value all created Properties are
- * initialized to.
+ *
+ * @param propertyId
+ * the ID of the new Property.
+ * @param type
+ * the Data type of the new Property.
+ * @param defaultValue
+ * the value all created Properties are initialized to.
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
* @throws UnsupportedOperationException
- * if the addContainerProperty is not supported.
+ * if the addContainerProperty is not supported.
*/
- public boolean addContainerProperty(
- Object propertyId,
- Class type,
- Object defaultValue)
- throws UnsupportedOperationException {
+ public boolean addContainerProperty(Object propertyId, Class type,
+ Object defaultValue) throws UnsupportedOperationException {
return container.addContainerProperty(propertyId, type, defaultValue);
}
- /**
- * Removes the specified Property from the underlying container and
- * from the hierarchy.
- * <p>
- * Note : The Property will be removed from all
- * Items in the Container.
- *</p>
- * @param propertyId the ID of the Property to remove.
+ /**
+ * Removes the specified Property from the underlying container and from the
+ * hierarchy.
+ * <p>
+ * Note : The Property will be removed from all Items in the Container.
+ * </p>
+ *
+ * @param propertyId
+ * the ID of the Property to remove.
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
* @throws UnsupportedOperationException
- * if the removeContainerProperty is not supported.
+ * if the removeContainerProperty is not supported.
*/
public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
return container.removeContainerProperty(propertyId);
}
- /* Does the container contain the specified Item?
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Does the container contain the specified Item? Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean containsId(Object itemId) {
return container.containsId(itemId);
}
- /* Gets the specified Item from the container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the specified Item from the container. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public Item getItem(Object itemId) {
return container.getItem(itemId);
}
- /* Gets the ID's of all Items stored in the Container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the ID's of all Items stored in the Container Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection getItemIds() {
return container.getItemIds();
}
- /* Gets the Property identified by the given itemId and propertyId from
- * the Container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the Property identified by the given itemId and propertyId from the
+ * Container Don't add a JavaDoc comment here, we use the default
+ * documentation from implemented interface.
*/
public Property getContainerProperty(Object itemId, Object propertyId) {
return container.getContainerProperty(itemId, propertyId);
}
- /* Gets the ID's of all Properties stored in the Container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the ID's of all Properties stored in the Container Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection getContainerPropertyIds() {
return container.getContainerPropertyIds();
}
- /* Gets the data type of all Properties identified by the given Property
- * ID.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the data type of all Properties identified by the given Property ID.
+ * Don't add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public Class getType(Object propertyId) {
return container.getType(propertyId);
}
- /* Gets the number of Items in the Container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the number of Items in the Container. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public int size() {
return container.size();
}
- /* Registers a new Item set change listener for this Container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Registers a new Item set change listener for this Container. Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public void addListener(Container.ItemSetChangeListener listener) {
if (container instanceof Container.ItemSetChangeNotifier)
((Container.ItemSetChangeNotifier) container).addListener(listener);
}
- /* Removes a Item set change listener from the object.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Removes a Item set change listener from the object. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public void removeListener(Container.ItemSetChangeListener listener) {
if (container instanceof Container.ItemSetChangeNotifier)
- ((Container.ItemSetChangeNotifier) container).removeListener(
- listener);
+ ((Container.ItemSetChangeNotifier) container)
+ .removeListener(listener);
}
- /* Registers a new Property set change listener for this Container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Registers a new Property set change listener for this Container. Don't
+ * add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public void addListener(Container.PropertySetChangeListener listener) {
if (container instanceof Container.PropertySetChangeNotifier)
- ((Container.PropertySetChangeNotifier) container).addListener(
- listener);
+ ((Container.PropertySetChangeNotifier) container)
+ .addListener(listener);
}
- /* Removes a Property set change listener from the object.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Removes a Property set change listener from the object. Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public void removeListener(Container.PropertySetChangeListener listener) {
if (container instanceof Container.PropertySetChangeNotifier)
- ((Container.PropertySetChangeNotifier) container).removeListener(
- listener);
+ ((Container.PropertySetChangeNotifier) container)
+ .removeListener(listener);
}
}
diff --git a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java
index da54d2b2c8..02f0813db4 100644
--- a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java
+++ b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -37,69 +37,65 @@ import com.itmill.toolkit.data.Container;
import com.itmill.toolkit.data.Item;
import com.itmill.toolkit.data.Property;
-/**
+/**
* <p>
- * A wrapper class for adding external ordering to containers not
- * implementing the {@link com.itmill.toolkit.data.Container.Ordered}
- * interface.
+ * A wrapper class for adding external ordering to containers not implementing
+ * the {@link com.itmill.toolkit.data.Container.Ordered} interface.
* </p>
*
* <p>
- * If the wrapped container is changed directly (that is, not through
- * the wrapper), the ordering must be updated with the
- * {@link #updateOrderWrapper()} method.
+ * If the wrapped container is changed directly (that is, not through the
+ * wrapper), the ordering must be updated with the {@link #updateOrderWrapper()}
+ * method.
* </p>
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class ContainerOrderedWrapper
- implements
- Container.Ordered,
- Container.ItemSetChangeNotifier,
- Container.PropertySetChangeNotifier {
+public class ContainerOrderedWrapper implements Container.Ordered,
+ Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier {
/**
- * The wrapped container
+ * The wrapped container
*/
private Container container;
- /**
- * Ordering information, ie. the mapping from Item ID to the next
- * item ID
+ /**
+ * Ordering information, ie. the mapping from Item ID to the next item ID
*/
private Hashtable next;
- /**
- * Reverse ordering information for convenience and performance
- * reasons.
+ /**
+ * Reverse ordering information for convenience and performance reasons.
*/
private Hashtable prev;
- /**
- * ID of the first Item in the container.
+ /**
+ * ID of the first Item in the container.
*/
private Object first;
/**
- * ID of the last Item in the container.
+ * ID of the last Item in the container.
*/
private Object last;
- /**
- * Is the wrapped container ordered by itself, ie. does it implement
- * the Container.Ordered interface by itself? If it does, this class
- * will use the methods of the underlying container directly.
+ /**
+ * Is the wrapped container ordered by itself, ie. does it implement the
+ * Container.Ordered interface by itself? If it does, this class will use
+ * the methods of the underlying container directly.
*/
private boolean ordered = false;
- /**
- * Constructs a new ordered wrapper for an existing Container. Works
- * even if the to-be-wrapped container already implements the
- * Container.Ordered interface.
+ /**
+ * Constructs a new ordered wrapper for an existing Container. Works even if
+ * the to-be-wrapped container already implements the Container.Ordered
+ * interface.
*
- * @param toBeWrapped the container whose contents need to be ordered.
+ * @param toBeWrapped
+ * the container whose contents need to be ordered.
*/
public ContainerOrderedWrapper(Container toBeWrapped) {
@@ -114,13 +110,15 @@ public class ContainerOrderedWrapper
updateOrderWrapper();
}
- /**
+ /**
* Removes the specified Item from the wrapper's internal hierarchy
- * structure.
+ * structure.
* <p>
* Note : The Item is not removed from the underlying Container.
* </p>
- * @param id the ID of the Item to be removed from the ordering.
+ *
+ * @param id
+ * the ID of the Item to be removed from the ordering.
*/
private void removeFromOrderWrapper(Object id) {
if (id != null) {
@@ -139,11 +137,12 @@ public class ContainerOrderedWrapper
}
}
- /**
+ /**
* Registers the specified Item to the last position in the wrapper's
* internal ordering. The underlying container is not modified.
*
- * @param id the ID of the Item to be added to the ordering.
+ * @param id
+ * the ID of the Item to be added to the ordering.
*/
private void addToOrderWrapper(Object id) {
@@ -157,13 +156,15 @@ public class ContainerOrderedWrapper
}
}
- /**
+ /**
* Registers the specified Item after the specified itemId in the wrapper's
- * internal ordering. The underlying container is not modified.
- * Given item id must be in the container, or must be null.
+ * internal ordering. The underlying container is not modified. Given item
+ * id must be in the container, or must be null.
*
- * @param id the ID of the Item to be added to the ordering.
- * @param previousItemId the Id of the previous item.
+ * @param id
+ * the ID of the Item to be added to the ordering.
+ * @param previousItemId
+ * the Id of the previous item.
*/
private void addToOrderWrapper(Object id, Object previousItemId) {
@@ -183,13 +184,13 @@ public class ContainerOrderedWrapper
}
}
- /**
- * Updates the wrapper's internal ordering information to include all
- * Items in the underlying container.
+ /**
+ * Updates the wrapper's internal ordering information to include all Items
+ * in the underlying container.
* <p>
- * Note : If the contents of the wrapped container change without the
- * wrapper's knowledge, this method needs to be called to update
- * the ordering information of the Items.
+ * Note : If the contents of the wrapped container change without the
+ * wrapper's knowledge, this method needs to be called to update the
+ * ordering information of the Items.
* </p>
*/
public void updateOrderWrapper() {
@@ -199,10 +200,7 @@ public class ContainerOrderedWrapper
Collection ids = container.getItemIds();
// Recreates ordering if some parts of it are missing
- if (next == null
- || first == null
- || last == null
- || prev != null) {
+ if (next == null || first == null || last == null || prev != null) {
first = null;
last = null;
next = new Hashtable();
@@ -226,9 +224,10 @@ public class ContainerOrderedWrapper
}
}
- /* Gets the first item stored in the ordered container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the first item stored in the ordered container Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Object firstItemId() {
if (ordered)
@@ -236,9 +235,10 @@ public class ContainerOrderedWrapper
return first;
}
- /* Tests if the given item is the first item in the container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the given item is the first item in the container Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean isFirstId(Object itemId) {
if (ordered)
@@ -246,9 +246,10 @@ public class ContainerOrderedWrapper
return first != null && first.equals(itemId);
}
- /* Tests if the given item is the last item in the container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the given item is the last item in the container Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean isLastId(Object itemId) {
if (ordered)
@@ -256,9 +257,10 @@ public class ContainerOrderedWrapper
return last != null && last.equals(itemId);
}
- /* Gets the last item stored in the ordered container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the last item stored in the ordered container Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Object lastItemId() {
if (ordered)
@@ -266,9 +268,10 @@ public class ContainerOrderedWrapper
return last;
}
- /* Gets the item that is next from the specified item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the item that is next from the specified item. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Object nextItemId(Object itemId) {
if (ordered)
@@ -276,9 +279,10 @@ public class ContainerOrderedWrapper
return next.get(itemId);
}
- /* Gets the item that is previous from the specified item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the item that is previous from the specified item. Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public Object prevItemId(Object itemId) {
if (ordered)
@@ -286,33 +290,32 @@ public class ContainerOrderedWrapper
return prev.get(itemId);
}
- /**
+ /**
* Registers a new Property to all Items in the Container.
- *
- * @param propertyId the ID of the new Property.
- * @param type the Data type of the new Property.
- * @param defaultValue the value all created Properties are
- * initialized to.
+ *
+ * @param propertyId
+ * the ID of the new Property.
+ * @param type
+ * the Data type of the new Property.
+ * @param defaultValue
+ * the value all created Properties are initialized to.
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
*/
- public boolean addContainerProperty(
- Object propertyId,
- Class type,
- Object defaultValue)
- throws UnsupportedOperationException {
+ public boolean addContainerProperty(Object propertyId, Class type,
+ Object defaultValue) throws UnsupportedOperationException {
return container.addContainerProperty(propertyId, type, defaultValue);
}
- /**
- * Creates a new Item into the Container, assigns it an
- * automatic ID, and adds it to the ordering.
+ /**
+ * Creates a new Item into the Container, assigns it an automatic ID, and
+ * adds it to the ordering.
*
- * @return the autogenerated ID of the new Item or <code>null</code>
- * if the operation failed
+ * @return the autogenerated ID of the new Item or <code>null</code> if
+ * the operation failed
* @throws UnsupportedOperationException
- * if the addItem is not supported.
+ * if the addItem is not supported.
*/
public Object addItem() throws UnsupportedOperationException {
@@ -322,14 +325,15 @@ public class ContainerOrderedWrapper
return id;
}
- /**
+ /**
* Registers a new Item by its ID to the underlying container and to the
* ordering.
+ *
* @param itemId
- * the ID of the Item to be created.
+ * the ID of the Item to be created.
* @return the added Item or <code>null</code> if the operation failed
* @throws UnsupportedOperationException
- * if the addItem is not supported.
+ * if the addItem is not supported.
*/
public Item addItem(Object itemId) throws UnsupportedOperationException {
Item item = container.addItem(itemId);
@@ -338,14 +342,13 @@ public class ContainerOrderedWrapper
return item;
}
- /**
- * Removes all items from the underlying container and from the
- * ordering.
+ /**
+ * Removes all items from the underlying container and from the ordering.
*
* @return <code>true</code> if the operation succeeded, otherwise
- * <code>false</code>
+ * <code>false</code>
* @throws UnsupportedOperationException
- * if the removeAllItems is not supported.
+ * if the removeAllItems is not supported.
*/
public boolean removeAllItems() throws UnsupportedOperationException {
boolean success = container.removeAllItems();
@@ -357,18 +360,19 @@ public class ContainerOrderedWrapper
return success;
}
- /**
- * Removes an Item specified by the itemId from the underlying
- * container and from the ordering.
+ /**
+ * Removes an Item specified by the itemId from the underlying container and
+ * from the ordering.
+ *
* @param itemId
- * the ID of the Item to be removed.
+ * the ID of the Item to be removed.
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
* @throws UnsupportedOperationException
- * if the removeItem is not supported.
+ * if the removeItem is not supported.
*/
public boolean removeItem(Object itemId)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
boolean success = container.removeItem(itemId);
if (success)
@@ -376,124 +380,135 @@ public class ContainerOrderedWrapper
return success;
}
- /**
- * Removes the specified Property from the underlying container and
- * from the ordering.
- * <p>
+ /**
+ * Removes the specified Property from the underlying container and from the
+ * ordering.
+ * <p>
* Note : The Property will be removed from all the Items in the Container.
* </p>
- * @param propertyId the ID of the Property to remove.
+ *
+ * @param propertyId
+ * the ID of the Property to remove.
* @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * <code>false</code> if not
* @throws UnsupportedOperationException
- * if the removeContainerProperty is not supported.
+ * if the removeContainerProperty is not supported.
*/
public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
return container.removeContainerProperty(propertyId);
}
- /* Does the container contain the specified Item?
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Does the container contain the specified Item? Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean containsId(Object itemId) {
return container.containsId(itemId);
}
- /* Gets the specified Item from the container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the specified Item from the container. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public Item getItem(Object itemId) {
return container.getItem(itemId);
}
- /* Gets the ID's of all Items stored in the Container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the ID's of all Items stored in the Container Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection getItemIds() {
return container.getItemIds();
}
- /* Gets the Property identified by the given itemId and propertyId from
- * the Container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the Property identified by the given itemId and propertyId from the
+ * Container Don't add a JavaDoc comment here, we use the default
+ * documentation from implemented interface.
*/
public Property getContainerProperty(Object itemId, Object propertyId) {
return container.getContainerProperty(itemId, propertyId);
}
- /* Gets the ID's of all Properties stored in the Container
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the ID's of all Properties stored in the Container Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection getContainerPropertyIds() {
return container.getContainerPropertyIds();
}
- /* Gets the data type of all Properties identified by the given Property
- * ID.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the data type of all Properties identified by the given Property ID.
+ * Don't add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public Class getType(Object propertyId) {
return container.getType(propertyId);
}
- /* Gets the number of Items in the Container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the number of Items in the Container. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public int size() {
return container.size();
}
- /* Registers a new Item set change listener for this Container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Registers a new Item set change listener for this Container. Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public void addListener(Container.ItemSetChangeListener listener) {
if (container instanceof Container.ItemSetChangeNotifier)
((Container.ItemSetChangeNotifier) container).addListener(listener);
}
- /* Removes a Item set change listener from the object.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Removes a Item set change listener from the object. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public void removeListener(Container.ItemSetChangeListener listener) {
if (container instanceof Container.ItemSetChangeNotifier)
- ((Container.ItemSetChangeNotifier) container).removeListener(
- listener);
+ ((Container.ItemSetChangeNotifier) container)
+ .removeListener(listener);
}
- /* Registers a new Property set change listener for this Container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Registers a new Property set change listener for this Container. Don't
+ * add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public void addListener(Container.PropertySetChangeListener listener) {
if (container instanceof Container.PropertySetChangeNotifier)
- ((Container.PropertySetChangeNotifier) container).addListener(
- listener);
+ ((Container.PropertySetChangeNotifier) container)
+ .addListener(listener);
}
- /* Removes a Property set change listener from the object.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Removes a Property set change listener from the object. Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public void removeListener(Container.PropertySetChangeListener listener) {
if (container instanceof Container.PropertySetChangeNotifier)
- ((Container.PropertySetChangeNotifier) container).removeListener(
- listener);
+ ((Container.PropertySetChangeNotifier) container)
+ .removeListener(listener);
}
+
/**
- * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object, Object)
+ * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object,
+ * Object)
*/
public Item addItemAfter(Object previousItemId, Object newItemId)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
// If the previous item is not in the container, fail
if (previousItemId != null && !containsId(previousItemId))
@@ -513,7 +528,7 @@ public class ContainerOrderedWrapper
* @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object)
*/
public Object addItemAfter(Object previousItemId)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
// If the previous item is not in the container, fail
if (previousItemId != null && !containsId(previousItemId))
diff --git a/src/com/itmill/toolkit/data/util/FilesystemContainer.java b/src/com/itmill/toolkit/data/util/FilesystemContainer.java
index af71437906..f502b0fee8 100644
--- a/src/com/itmill/toolkit/data/util/FilesystemContainer.java
+++ b/src/com/itmill/toolkit/data/util/FilesystemContainer.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -51,23 +51,24 @@ import com.itmill.toolkit.terminal.Resource;
* A hierarchical container wrapper for a filesystem.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class FilesystemContainer implements Container.Hierarchical {
- /**
- * String identifier of a file's "name" property.
+ /**
+ * String identifier of a file's "name" property.
*/
public static String PROPERTY_NAME = "Name";
/**
- * String identifier of a file's "size" property.
+ * String identifier of a file's "size" property.
*/
public static String PROPERTY_SIZE = "Size";
- /**
- * String identifier of a file's "icon" property.
+ /**
+ * String identifier of a file's "icon" property.
*/
public static String PROPERTY_ICON = "Icon";
@@ -77,14 +78,16 @@ public class FilesystemContainer implements Container.Hierarchical {
public static String PROPERTY_LASTMODIFIED = "Last Modified";
/**
- * List of the string identifiers for the available properties.
+ * List of the string identifiers for the available properties.
*/
public static Collection FILE_PROPERTIES;
private static Method FILEITEM_LASTMODIFIED;
private static Method FILEITEM_NAME;
+
private static Method FILEITEM_ICON;
+
private static Method FILEITEM_SIZE;
static {
@@ -96,30 +99,29 @@ public class FilesystemContainer implements Container.Hierarchical {
FILE_PROPERTIES.add(PROPERTY_LASTMODIFIED);
FILE_PROPERTIES = Collections.unmodifiableCollection(FILE_PROPERTIES);
try {
- FILEITEM_LASTMODIFIED =
- FileItem.class.getMethod("lastModified", new Class[] {
- });
- FILEITEM_NAME = FileItem.class.getMethod("getName", new Class[] {
- });
- FILEITEM_ICON = FileItem.class.getMethod("getIcon", new Class[] {
- });
- FILEITEM_SIZE = FileItem.class.getMethod("getSize", new Class[] {
- });
+ FILEITEM_LASTMODIFIED = FileItem.class.getMethod("lastModified",
+ new Class[] {});
+ 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) {
}
}
- private File[] roots = new File[] {
- };
+ private File[] roots = new File[] {};
+
private FilenameFilter filter = null;
+
private boolean recursive = true;
- /**
+ /**
* Constructs a new <code>FileSystemContainer</code> with the specified
* file as the root of the filesystem. The files are included recursively.
*
- * @param root the root file for the new file-system container. Null values are ignored.
+ * @param root
+ * the root file for the new file-system container. Null values
+ * are ignored.
*/
public FilesystemContainer(File root) {
if (root != null) {
@@ -127,56 +129,63 @@ public class FilesystemContainer implements Container.Hierarchical {
}
}
- /**
+ /**
* Constructs a new <code>FileSystemContainer</code> with the specified
* file as the root of the filesystem. The files are included recursively.
*
- * @param root the root file for the new file-system container.
- * @param recursive should the container recursively contain subdirectories.
+ * @param root
+ * the root file for the new file-system container.
+ * @param recursive
+ * should the container recursively contain subdirectories.
*/
public FilesystemContainer(File root, boolean recursive) {
this(root);
this.setRecursive(recursive);
}
- /**
+ /**
* Constructs a new <code>FileSystemContainer</code> with the specified
* file as the root of the filesystem.
*
- * @param root the root file for the new file-system container.
- * @param extension the Filename extension (w/o separator) to limit the files in container.
- * @param recursive should the container recursively contain subdirectories.
- */
- public FilesystemContainer(
- File root,
- String extension,
- boolean recursive) {
+ * @param root
+ * the root file for the new file-system container.
+ * @param extension
+ * the Filename extension (w/o separator) to limit the files in
+ * container.
+ * @param recursive
+ * should the container recursively contain subdirectories.
+ */
+ public FilesystemContainer(File root, String extension, boolean recursive) {
this(root);
this.setFilter(extension);
this.setRecursive(recursive);
}
- /**
+ /**
* Constructs a new <code>FileSystemContainer</code> with the specified
* root and recursivity status.
*
- * @param root the root file for the new file-system container.
- * @param filter the Filename filter to limit the files in container.
- * @param recursive should the container recursively contain subdirectories.
- */
- public FilesystemContainer(
- File root,
- FilenameFilter filter,
- boolean recursive) {
+ * @param root
+ * the root file for the new file-system container.
+ * @param filter
+ * the Filename filter to limit the files in container.
+ * @param recursive
+ * should the container recursively contain subdirectories.
+ */
+ public FilesystemContainer(File root, FilenameFilter filter,
+ boolean recursive) {
this(root);
this.setFilter(filter);
this.setRecursive(recursive);
}
- /**
- * Adds new root file directory.
- * Adds a file to be included as root file directory in the <code>FilesystemContainer</code>.
- * @param root the File to be added as root directory. Null values are ignored.
+ /**
+ * Adds new root file directory. Adds a file to be included as root file
+ * directory in the <code>FilesystemContainer</code>.
+ *
+ * @param root
+ * the File to be added as root directory. Null values are
+ * ignored.
*/
public void addRoot(File root) {
if (root != null) {
@@ -189,27 +198,28 @@ public class FilesystemContainer implements Container.Hierarchical {
}
}
- /**
- * Tests if the specified Item in the container may have children.
- * Since a <code>FileSystemContainer</code> contains files and
- * directories, this method returns <code>true</code> for directory
- * Items only.
- * @param itemId the id of the item.
+ /**
+ * Tests if the specified Item in the container may have children. Since a
+ * <code>FileSystemContainer</code> contains files and directories, this
+ * method returns <code>true</code> for directory Items only.
+ *
+ * @param itemId
+ * the id of the item.
* @return <code>true</code> if the specified Item is a directory,
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
public boolean areChildrenAllowed(Object itemId) {
- return itemId instanceof File
- && ((File) itemId).canRead()
- && ((File) itemId).isDirectory();
+ return itemId instanceof File && ((File) itemId).canRead()
+ && ((File) itemId).isDirectory();
}
- /* Gets the ID's of all Items who are children of the specified Item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the ID's of all Items who are children of the specified Item. Don't
+ * add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public Collection getChildren(Object itemId) {
-
+
if (!(itemId instanceof File))
return Collections.unmodifiableCollection(new LinkedList());
File[] f;
@@ -227,9 +237,9 @@ public class FilesystemContainer implements Container.Hierarchical {
return Collections.unmodifiableCollection(l);
}
- /* Gets the parent item of the specified Item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the parent item of the specified Item. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public Object getParent(Object itemId) {
@@ -238,9 +248,9 @@ public class FilesystemContainer implements Container.Hierarchical {
return ((File) itemId).getParentFile();
}
- /* Tests if the specified Item has any children.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the specified Item has any children. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public boolean hasChildren(Object itemId) {
@@ -254,9 +264,10 @@ public class FilesystemContainer implements Container.Hierarchical {
return (l != null) && (l.length > 0);
}
- /* Tests if the specified Item is the root of the filesystem.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the specified Item is the root of the filesystem. Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean isRoot(Object itemId) {
@@ -269,9 +280,10 @@ public class FilesystemContainer implements Container.Hierarchical {
return false;
}
- /* Gets the ID's of all root Items in the container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the ID's of all root Items in the container. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection rootItemIds() {
@@ -296,46 +308,51 @@ public class FilesystemContainer implements Container.Hierarchical {
return Collections.unmodifiableCollection(l);
}
- /**
- * Returns <code>false</code> when conversion from files to directories is not
- * supported.
- * @param itemId
- * the ID of the item.
- * @param areChildrenAllowed
- * the boolean value specifying if the Item can have children or not.
- * @return <code>true</code> if the operaton is successful otherwise
- * <code>false</code>.
+ /**
+ * Returns <code>false</code> when conversion from files to directories is
+ * not supported.
+ *
+ * @param itemId
+ * the ID of the item.
+ * @param areChildrenAllowed
+ * the boolean value specifying if the Item can have children or
+ * not.
+ * @return <code>true</code> if the operaton is successful otherwise
+ * <code>false</code>.
* @throws UnsupportedOperationException
- * if the setChildrenAllowed is not supported.
+ * if the setChildrenAllowed is not supported.
*/
- public boolean setChildrenAllowed(
- Object itemId,
- boolean areChildrenAllowed)
- throws UnsupportedOperationException {
+ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed)
+ throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Conversion file to/from directory is not supported");
+ throw new UnsupportedOperationException(
+ "Conversion file to/from directory is not supported");
}
- /**
- * Returns <code>false</code> when moving files around in the filesystem is not
- * supported.
- * @param itemId the ID of the item.
- * @param newParentId the ID of the Item that's to be the new parent
- * of the Item identified with itemId.
+ /**
+ * Returns <code>false</code> when moving files around in the filesystem
+ * is not supported.
+ *
+ * @param itemId
+ * the ID of the item.
+ * @param newParentId
+ * the ID of the Item that's to be the new parent of the Item
+ * identified with itemId.
* @return <code>true</code> if the operation is successful otherwise
- * <code>false</code>.
+ * <code>false</code>.
* @throws UnsupportedOperationException
- * if the setParent is not supported.
+ * if the setParent is not supported.
*/
public boolean setParent(Object itemId, Object newParentId)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
throw new UnsupportedOperationException("File moving is not supported");
}
- /* Tests if the filesystem contains the specified Item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the filesystem contains the specified Item. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean containsId(Object itemId) {
@@ -346,25 +363,22 @@ public class FilesystemContainer implements Container.Hierarchical {
// Try to match all roots
for (int i = 0; i < roots.length; i++) {
try {
- val
- |= ((File) itemId).getCanonicalPath().startsWith(
+ val |= ((File) itemId).getCanonicalPath().startsWith(
roots[i].getCanonicalPath());
} catch (IOException e) {
- // Exception ignored
+ // Exception ignored
}
}
if (val && this.filter != null)
- val
- &= this.filter.accept(
- ((File) itemId).getParentFile(),
+ val &= this.filter.accept(((File) itemId).getParentFile(),
((File) itemId).getName());
return val;
}
- /* Gets the specified Item from the filesystem.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the specified Item from the filesystem. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public Item getItem(Object itemId) {
@@ -373,12 +387,14 @@ public class FilesystemContainer implements Container.Hierarchical {
return new FileItem((File) itemId);
}
- /**
- * Internal recursive method to add the files under the specified
- * directory to the collection.
+ /**
+ * Internal recursive method to add the files under the specified directory
+ * to the collection.
*
- * @param col the collection where the found items are added
- * @param f the root file where to start adding files
+ * @param col
+ * the collection where the found items are added
+ * @param f
+ * the root file where to start adding files
*/
private void addItemIds(Collection col, File f) {
File[] l;
@@ -389,8 +405,8 @@ public class FilesystemContainer implements Container.Hierarchical {
List ll = Arrays.asList(l);
Collections.sort(ll);
- for (Iterator i = ll.iterator();i.hasNext();) {
- File lf = (File)i.next();
+ for (Iterator i = ll.iterator(); i.hasNext();) {
+ File lf = (File) i.next();
if (lf.isDirectory())
addItemIds(col, lf);
else
@@ -398,14 +414,12 @@ public class FilesystemContainer implements Container.Hierarchical {
}
}
- /* Gets the IDs of Items in the filesystem.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the IDs of Items in the filesystem. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public Collection getItemIds() {
-
-
if (recursive) {
Collection col = new ArrayList();
for (int i = 0; i < roots.length; i++) {
@@ -425,22 +439,23 @@ public class FilesystemContainer implements Container.Hierarchical {
if (f == null)
return Collections.unmodifiableCollection(new LinkedList());
-
+
List l = Arrays.asList(f);
Collections.sort(l);
return Collections.unmodifiableCollection(l);
}
-
+
}
- /**
- * Gets the specified property of the specified file Item. The
- * available file properties are "Name", "Size" and "Last Modified".
- * If propertyId is not one of those, <code>null</code> is
- * returned.
+ /**
+ * Gets the specified property of the specified file Item. The available
+ * file properties are "Name", "Size" and "Last Modified". If propertyId is
+ * not one of those, <code>null</code> is returned.
*
- * @param itemId the ID of the file whose property is requested.
- * @param propertyId the property's ID.
+ * @param itemId
+ * the ID of the file whose property is requested.
+ * @param propertyId
+ * the property's ID.
* @return the requested property's value, or <code>null</code>
*/
public Property getContainerProperty(Object itemId, Object propertyId) {
@@ -449,53 +464,40 @@ public class FilesystemContainer implements Container.Hierarchical {
return null;
if (propertyId.equals(PROPERTY_NAME))
- return new MethodProperty(
- getType(propertyId),
- new FileItem((File) itemId),
- FILEITEM_NAME,
- null);
+ return new MethodProperty(getType(propertyId), new FileItem(
+ (File) itemId), FILEITEM_NAME, null);
if (propertyId.equals(PROPERTY_ICON))
- return new MethodProperty(
- getType(propertyId),
- new FileItem((File) itemId),
- FILEITEM_ICON,
- null);
+ return new MethodProperty(getType(propertyId), new FileItem(
+ (File) itemId), FILEITEM_ICON, null);
if (propertyId.equals(PROPERTY_SIZE))
- return new MethodProperty(
- getType(propertyId),
- new FileItem((File) itemId),
- FILEITEM_SIZE,
- null);
+ return new MethodProperty(getType(propertyId), new FileItem(
+ (File) itemId), FILEITEM_SIZE, null);
if (propertyId.equals(PROPERTY_LASTMODIFIED))
- return new MethodProperty(
- getType(propertyId),
- new FileItem((File) itemId),
- FILEITEM_LASTMODIFIED,
- null);
+ return new MethodProperty(getType(propertyId), new FileItem(
+ (File) itemId), FILEITEM_LASTMODIFIED, null);
return null;
}
- /**
+ /**
* Gets the collection of available file properties.
*
- * @return Unmodifiable collection containing all available file
- * properties.
+ * @return Unmodifiable collection containing all available file properties.
*/
public Collection getContainerPropertyIds() {
return FILE_PROPERTIES;
}
- /**
- * Gets the specified property's data type. "Name" is a
- * <code>String</code>, "Size" is a <code>Long</code>, "Last Modified"
- * is a <code>Date</code>. If propertyId is not one of
- * those, <code>null</code> is returned.
+ /**
+ * Gets the specified property's data type. "Name" is a <code>String</code>,
+ * "Size" is a <code>Long</code>, "Last Modified" is a <code>Date</code>.
+ * If propertyId is not one of those, <code>null</code> is returned.
*
- * @param propertyId the ID of the property whose type is requested.
+ * @param propertyId
+ * the ID of the property whose type is requested.
* @return data type of the requested property, or <code>null</code>
*/
public Class getType(Object propertyId) {
@@ -511,11 +513,12 @@ public class FilesystemContainer implements Container.Hierarchical {
return null;
}
- /**
- * Internal method to recursively calculate the number of files under
- * a root directory.
+ /**
+ * Internal method to recursively calculate the number of files under a root
+ * directory.
*
- * @param f the root to start counting from.
+ * @param f
+ * the root to start counting from.
*/
private int getFileCounts(File f) {
File[] l;
@@ -534,7 +537,7 @@ public class FilesystemContainer implements Container.Hierarchical {
return ret;
}
- /**
+ /**
* Gets the number of Items in the container. In effect, this is the
* combined amount of files and directories.
*
@@ -565,48 +568,51 @@ public class FilesystemContainer implements Container.Hierarchical {
}
}
- /**
+ /**
* A Item wrapper for files in a filesystem.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class FileItem implements Item {
- /**
- * The wrapped file.
+ /**
+ * The wrapped file.
*/
private File file;
- /**
- * Constructs a FileItem from a existing file.
+ /**
+ * Constructs a FileItem from a existing file.
*/
private FileItem(File file) {
this.file = file;
}
- /* Gets the specified property of this file.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the specified property of this file. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public Property getItemProperty(Object id) {
return FilesystemContainer.this.getContainerProperty(file, id);
}
- /* Gets the IDs of all properties available for this item
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the IDs of all properties available for this item Don't add a
+ * JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public Collection getItemPropertyIds() {
return FilesystemContainer.this.getContainerPropertyIds();
}
/**
- * Calculates a integer hash-code for the Property that's unique
- * inside the Item containing the Property. Two different Properties
- * inside the same Item contained in the same list always have
- * different hash-codes, though Properties in different Items may
- * have identical hash-codes.
+ * Calculates a integer hash-code for the Property that's unique inside
+ * the Item containing the Property. Two different Properties inside the
+ * same Item contained in the same list always have different
+ * hash-codes, though Properties in different Items may have identical
+ * hash-codes.
*
* @return A locally unique hash-code as integer
*/
@@ -615,12 +621,13 @@ public class FilesystemContainer implements Container.Hierarchical {
}
/**
- * Tests if the given object is the same as the this object.
- * Two Properties got from an Item with the same ID are equal.
+ * Tests if the given object is the same as the this object. Two
+ * Properties got from an Item with the same ID are equal.
*
- * @param obj an object to compare with this object.
- * @return <code>true</code> if the given object is the same as
- * this object, <code>false</code> if not
+ * @param obj
+ * an object to compare with this object.
+ * @return <code>true</code> if the given object is the same as this
+ * object, <code>false</code> if not
*/
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof FileItem))
@@ -628,35 +635,44 @@ public class FilesystemContainer implements Container.Hierarchical {
FileItem fi = (FileItem) obj;
return fi.getHost() == getHost() && fi.file.equals(file);
}
+
/**
* Gets the host of this file.
*/
private FilesystemContainer getHost() {
return FilesystemContainer.this;
}
+
/**
* Gets the last modified date of this file.
+ *
* @return Date
*/
public Date lastModified() {
return new Date(this.file.lastModified());
}
+
/**
* Gets the name of this file.
+ *
* @return file name of this file.
*/
public String getName() {
return this.file.getName();
}
+
/**
* Gets the icon of this file.
+ *
* @return the icon of this file.
*/
public Resource getIcon() {
return FileTypeResolver.getIcon(this.file);
}
+
/**
* Gets the size of this file.
+ *
* @return size
*/
public long getSize() {
@@ -674,48 +690,56 @@ public class FilesystemContainer implements Container.Hierarchical {
return file.getName();
}
- /**
+ /**
* Filesystem container does not support adding new properties.
+ *
* @see com.itmill.toolkit.data.Item#addItemProperty(Object, Property)
*/
public boolean addItemProperty(Object id, Property property)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException(
- "Filesystem container "
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Filesystem container "
+ "does not support adding new properties");
}
/**
* Filesystem container does not support removing properties.
+ *
* @see com.itmill.toolkit.data.Item#removeItemProperty(Object)
*/
public boolean removeItemProperty(Object id)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Filesystem container does not support property removal");
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "Filesystem container does not support property removal");
}
}
- /**
- * Generic file extension filter for displaying only files having certain extension.
+ /**
+ * Generic file extension filter for displaying only files having certain
+ * extension.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class FileExtensionFilter implements FilenameFilter {
private String filter;
- /**
+ /**
* Constructs a new FileExtensionFilter using given extension.
- * @param fileExtension the File extension without the separator (dot).
+ *
+ * @param fileExtension
+ * the File extension without the separator (dot).
*/
public FileExtensionFilter(String fileExtension) {
this.filter = "." + fileExtension;
}
- /**
+ /**
* Allows only files with the extension and directories.
+ *
* @see java.io.FilenameFilter#accept(File, String)
*/
public boolean accept(File dir, String name) {
@@ -725,8 +749,10 @@ public class FilesystemContainer implements Container.Hierarchical {
}
}
+
/**
* Returns the file filter used to limit the files in this container.
+ *
* @return Used filter instance or null if no filter is assigned.
*/
public FilenameFilter getFilter() {
@@ -735,7 +761,9 @@ public class FilesystemContainer implements Container.Hierarchical {
/**
* Sets the file filter used to limit the files in this container.
- * @param filter The filter to set. <code>null</code> disables filtering.
+ *
+ * @param filter
+ * The filter to set. <code>null</code> disables filtering.
*/
public void setFilter(FilenameFilter filter) {
this.filter = filter;
@@ -743,7 +771,10 @@ public class FilesystemContainer implements Container.Hierarchical {
/**
* Sets the file filter used to limit the files in this container.
- * @param extension the Filename extension (w/o separator) to limit the files in container.
+ *
+ * @param extension
+ * the Filename extension (w/o separator) to limit the files in
+ * container.
*/
public void setFilter(String extension) {
this.filter = new FileExtensionFilter(extension);
@@ -751,69 +782,77 @@ public class FilesystemContainer implements Container.Hierarchical {
/**
* Is this container recursive filesystem.
- * @return <code>true</code> if container is recursive, <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if container is recursive, <code>false</code>
+ * otherwise.
*/
public boolean isRecursive() {
return recursive;
}
/**
- * Sets the container recursive property.
- * Set this to false to limit the files directly under the root file.
+ * Sets the container recursive property. Set this to false to limit the
+ * files directly under the root file.
* <p>
* Note : This is meaningful only if the root really is a directory.
* </p>
- * @param recursive the New value for recursive property.
+ *
+ * @param recursive
+ * the New value for recursive property.
*/
public void setRecursive(boolean recursive) {
this.recursive = recursive;
}
/**
- * @see com.itmill.toolkit.data.Container#addContainerProperty(Object, Class, Object)
+ * @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
+ * Class, Object)
*/
- public boolean addContainerProperty(
- Object propertyId,
- Class type,
- Object defaultValue)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("File system container does not support this operation");
+ public boolean addContainerProperty(Object propertyId, Class type,
+ Object defaultValue) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
}
/**
* @see com.itmill.toolkit.data.Container#addItem()
*/
public Object addItem() throws UnsupportedOperationException {
- throw new UnsupportedOperationException("File system container does not support this operation");
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
}
/**
* @see com.itmill.toolkit.data.Container#addItem(Object)
*/
public Item addItem(Object itemId) throws UnsupportedOperationException {
- throw new UnsupportedOperationException("File system container does not support this operation");
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
}
/**
* @see com.itmill.toolkit.data.Container#removeAllItems()
*/
public boolean removeAllItems() throws UnsupportedOperationException {
- throw new UnsupportedOperationException("File system container does not support this operation");
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
}
/**
* @see com.itmill.toolkit.data.Container#removeItem(Object)
*/
public boolean removeItem(Object itemId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("File system container does not support this operation");
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
}
/**
* @see com.itmill.toolkit.data.Container#removeContainerProperty(Object)
*/
public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("File system container does not support this operation");
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
}
}
diff --git a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java
index 1c7a773d6d..b9de5d26de 100644
--- a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java
+++ b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -37,49 +37,50 @@ import java.util.HashSet;
import com.itmill.toolkit.data.Container;
import com.itmill.toolkit.data.Item;
-/**
+/**
* A specialized Container whose contents can be accessed like it was a
* tree-like structure.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class HierarchicalContainer
- extends IndexedContainer
- implements Container.Hierarchical {
+public class HierarchicalContainer extends IndexedContainer implements
+ Container.Hierarchical {
/**
* Set of IDs of those contained Items that can't have children.
*/
private HashSet noChildrenAllowed = new HashSet();
- /**
+ /**
* Mapping from Item ID to parent Item.
*/
private Hashtable parent = new Hashtable();
- /**
- * Mapping from Item ID to a list of child IDs.
+ /**
+ * Mapping from Item ID to a list of child IDs.
*/
private Hashtable children = new Hashtable();
- /**
+ /**
* List that contains all root elements of the container.
*/
private LinkedList roots = new LinkedList();
- /* Can the specified Item have any children?
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Can the specified Item have any children? Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public boolean areChildrenAllowed(Object itemId) {
return !noChildrenAllowed.contains(itemId);
}
- /* Gets the IDs of the children of the specified Item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the IDs of the children of the specified Item. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection getChildren(Object itemId) {
Collection c = (Collection) children.get(itemId);
@@ -88,55 +89,61 @@ public class HierarchicalContainer
return Collections.unmodifiableCollection(c);
}
- /* Gets the ID of the parent of the specified Item.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the ID of the parent of the specified Item. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Object getParent(Object itemId) {
return parent.get(itemId);
}
- /* Is the Item corresponding to the given ID a leaf node?
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Is the Item corresponding to the given ID a leaf node? Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean hasChildren(Object itemId) {
return children.get(itemId) != null;
}
- /* Is the Item corresponding to the given ID a root node?
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Is the Item corresponding to the given ID a root node? Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean isRoot(Object itemId) {
return parent.get(itemId) == null;
}
- /* Gets the IDs of the root elements in the container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the IDs of the root elements in the container. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public Collection rootItemIds() {
return Collections.unmodifiableCollection(roots);
}
- /**
- * <p>
- * Sets the given Item's capability to have children. If the Item
- * identified with the itemId already has children and the
- * areChildrenAllowed is false this method fails and
- * <code>false</code> is returned; the children must be first explicitly
- * removed with {@link #setParent(Object itemId, Object newParentId)} or
- * {@link com.itmill.toolkit.data.Container#removeItem(Object itemId)}.
- * </p>
- *
- * @param itemId the ID of the Item in the container whose child
- * capability is to be set.
- * @param childrenAllowed the boolean value specifying if the Item
- * can have children or not.
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
+ /**
+ * <p>
+ * Sets the given Item's capability to have children. If the Item identified
+ * with the itemId already has children and the areChildrenAllowed is false
+ * this method fails and <code>false</code> is returned; the children must
+ * be first explicitly removed with
+ * {@link #setParent(Object itemId, Object newParentId)} or
+ * {@link com.itmill.toolkit.data.Container#removeItem(Object itemId)}.
+ * </p>
+ *
+ * @param itemId
+ * the ID of the Item in the container whose child capability is
+ * to be set.
+ * @param childrenAllowed
+ * the boolean value specifying if the Item can have children or
+ * not.
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
public boolean setChildrenAllowed(Object itemId, boolean childrenAllowed) {
// Checks that the item is in the container
@@ -152,21 +159,22 @@ public class HierarchicalContainer
return true;
}
- /**
+ /**
* <p>
- * Sets the parent of an Item. The new parent item must exist and be
- * able to have children.
- * (<code>canHaveChildren(newParentId) == true</code>). It is also
- * possible to detach a node from the hierarchy (and thus make it root)
- * by setting the parent <code>null</code>.
+ * Sets the parent of an Item. The new parent item must exist and be able to
+ * have children. (<code>canHaveChildren(newParentId) == true</code>).
+ * It is also possible to detach a node from the hierarchy (and thus make it
+ * root) by setting the parent <code>null</code>.
* </p>
*
- * @param itemId the ID of the item to be set as the child of the Item
- * identified with newParentId.
- * @param newParentId the ID of the Item that's to be the new parent
- * of the Item identified with itemId.
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
+ * @param itemId
+ * the ID of the item to be set as the child of the Item
+ * identified with newParentId.
+ * @param newParentId
+ * the ID of the Item that's to be the new parent of the Item
+ * identified with itemId.
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
*/
public boolean setParent(Object itemId, Object newParentId) {
@@ -177,12 +185,12 @@ public class HierarchicalContainer
// Gets the old parent
Object oldParentId = parent.get(itemId);
- // Checks if no change is necessary
+ // Checks if no change is necessary
if ((newParentId == null && oldParentId == null)
- || newParentId.equals(oldParentId))
+ || newParentId.equals(oldParentId))
return true;
- // Making root
+ // Making root
if (newParentId == null) {
// Removes from old parents children list
@@ -204,14 +212,15 @@ public class HierarchicalContainer
// Checks that the new parent exists in container and can have
// children
- if (!containsId(newParentId)
- || noChildrenAllowed.contains(newParentId))
+ if (!containsId(newParentId) || noChildrenAllowed.contains(newParentId))
return false;
// Checks that setting parent doesn't result to a loop
Object o = newParentId;
- while (o != null && !o.equals(itemId)) o = parent.get(o);
- if (o != null) return false;
+ while (o != null && !o.equals(itemId))
+ o = parent.get(o);
+ if (o != null)
+ return false;
// Updates parent
parent.put(itemId, newParentId);
@@ -236,6 +245,7 @@ public class HierarchicalContainer
return true;
}
+
/**
* @see com.itmill.toolkit.data.Container#addItem()
*/
@@ -244,7 +254,7 @@ public class HierarchicalContainer
if (id != null && !roots.contains(id))
roots.add(id);
return id;
-
+
}
/**
@@ -252,8 +262,8 @@ public class HierarchicalContainer
*/
public Item addItem(Object itemId) {
Item item = super.addItem(itemId);
- if (item != null)
- roots.add(itemId);
+ if (item != null)
+ roots.add(itemId);
return item;
}
@@ -277,19 +287,21 @@ public class HierarchicalContainer
*/
public boolean removeItem(Object itemId) {
boolean success = super.removeItem(itemId);
-
+
if (success) {
- if (isRoot(itemId)) roots.remove(itemId);
+ if (isRoot(itemId))
+ roots.remove(itemId);
children.remove(itemId);
Object p = parent.get(itemId);
if (p != null) {
LinkedList c = (LinkedList) children.get(p);
- if (c != null) c.remove(itemId);
+ if (c != null)
+ c.remove(itemId);
}
parent.remove(itemId);
noChildrenAllowed.remove(itemId);
}
-
+
return success;
}
diff --git a/src/com/itmill/toolkit/data/util/IndexedContainer.java b/src/com/itmill/toolkit/data/util/IndexedContainer.java
index 589557a385..883d08bc37 100644
--- a/src/com/itmill/toolkit/data/util/IndexedContainer.java
+++ b/src/com/itmill/toolkit/data/util/IndexedContainer.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -38,10 +38,10 @@ import com.itmill.toolkit.data.Property;
/**
* Indexed container implementation.
* <p>
- * A list implementation of the <code>com.itmill.toolkit.data.Container</code> interface. A
- * list is a ordered collection wherein the user has a precise control over
- * where in the list each new Item is inserted. The user may access the Items by
- * their integer index (position in the list) or by their Item ID.
+ * A list implementation of the <code>com.itmill.toolkit.data.Container</code>
+ * interface. A list is a ordered collection wherein the user has a precise
+ * control over where in the list each new Item is inserted. The user may access
+ * the Items by their integer index (position in the list) or by their Item ID.
* </p>
*
* @see com.itmill.toolkit.data.Container
@@ -53,1387 +53,1397 @@ import com.itmill.toolkit.data.Property;
*/
public class IndexedContainer implements Container, Container.Indexed,
- Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier,
- Property.ValueChangeNotifier, Container.Sortable, Comparator, Cloneable {
-
- /* Internal structure *************************************************** */
-
- /**
- * Linked list of ordered Item IDs.
- */
- private ArrayList itemIds = new ArrayList();
-
- /**
- * Linked list of ordered Property IDs.
- */
- private ArrayList propertyIds = new ArrayList();
-
- /**
- * Property ID to type mapping.
- */
- private Hashtable types = new Hashtable();
-
- /**
- * Hash of Items, where each Item is implemented as a mapping from Property
- * ID to Property value.
- */
- private Hashtable items = new Hashtable();
-
- /**
- * Set of properties that are read-only.
- */
- private HashSet readOnlyProperties = new HashSet();
-
- /**
- * List of all Property value change event listeners listening all the
- * properties.
- */
- private LinkedList propertyValueChangeListeners = null;
-
- /**
- * Data structure containing all listeners interested in changes to single
- * Properties. The data structure is a hashtable mapping Property IDs to a
- * hashtable that maps Item IDs to a linked list of listeners listening
- * Property identified by given Property ID and Item ID.
- */
- private Hashtable singlePropertyValueChangeListeners = null;
-
- /**
- * List of all Property set change event listeners.
- */
- private LinkedList propertySetChangeListeners = null;
-
- /**
- * List of all container Item set change event listeners.
- */
- private LinkedList itemSetChangeListeners = null;
-
- /**
- * Temporary store for sorting property ids.
- */
- private Object[] sortPropertyId;
-
- /**
- * Temporary store for sorting direction.
- */
- private boolean[] sortDirection;
-
- /* Container constructors *********************************************** */
-
- public IndexedContainer() {
- }
-
- public IndexedContainer(Collection itemIds) {
- if (items != null) {
- for (Iterator i = itemIds.iterator(); i.hasNext();) {
- this.addItem(i.next());
- }
- }
- }
-
- /* Container methods **************************************************** */
-
- /**
- * Gets the Item with the given Item ID from the list. If the list does not
- * contain the requested Item, <code>null</code> is returned.
- *
- * @param itemId
- * the ID of the Item to retrieve.
- * @return the Item with the given ID or <code>null</code> if the Item is
- * not found in the list
- */
- public Item getItem(Object itemId) {
- if (items.containsKey(itemId))
- return new IndexedContainerItem(itemId);
- return null;
- }
-
- /**
- * Gets the ID's of all Items stored in the list. The ID's are returned as a
- * unmodifiable collection.
- *
- * @return unmodifiable collection of Item IDs
- */
- public Collection getItemIds() {
- return Collections.unmodifiableCollection(itemIds);
- }
-
- /**
- * Gets the ID's of all Properties stored in the list. The ID's are returned
- * as a unmodifiable collection.
- *
- * @return unmodifiable collection of Property IDs
- */
- public Collection getContainerPropertyIds() {
- return Collections.unmodifiableCollection(propertyIds);
- }
-
- /**
- * Gets the type of a Property stored in the list.
- *
- * @param id
- * the ID of the Property.
- * @return Type of the requested Property
- */
- public Class getType(Object propertyId) {
- return (Class) types.get(propertyId);
- }
-
- /**
- * Gets the Property identified by the given Item ID and Property ID from
- * the lsit. If the list does not contain the Property, <code>null</code>
- * is returned.
- *
- * @param itemId
- * the ID of the Item which contains the requested Property.
- * @param propertyId
- * the ID of the Property to retrieve.
- * @return Property with the given ID or <code>null</code>
- *
- * @see com.itmill.toolkit.data.Container#getContainerProperty(Object,
- * Object)
- */
- public Property getContainerProperty(Object itemId, Object propertyId) {
- if (!items.containsKey(itemId))
- return null;
- return new IndexedContainerProperty(itemId, propertyId);
- }
-
- /**
- * Gets the number of Items in the list.
- *
- * @return number of Items in the list
- */
- public int size() {
- return itemIds.size();
- }
-
- /**
- * Tests if the list contains the specified Item
- *
- * @param itemId
- * the ID the of Item to be tested for.
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean containsId(Object itemId) {
- return items.containsKey(itemId);
- }
-
- /**
- * Adds a new Property to all Items in the list. The Property ID, data type
- * and default value of the new Property are given as parameters.
- *
- * @param propertyId
- * the ID of the new Property.
- * @param type
- * the Data type of the new Property.
- * @param defaultValue
- * the value all created Properties are initialized to.
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean addContainerProperty(Object propertyId, Class type,
- Object defaultValue) {
-
- // Fails, if nulls are given
- if (propertyId == null || type == null)
- return false;
-
- // Fails if the Property is already present
- if (propertyIds.contains(propertyId))
- return false;
-
- // Adds the Property to Property list and types
- propertyIds.add(propertyId);
- types.put(propertyId, type);
-
- // If default value is given, set it
- if (defaultValue != null)
- for (Iterator i = itemIds.iterator(); i.hasNext();)
- getItem(i.next()).getItemProperty(propertyId).setValue(
- defaultValue);
-
- // Sends a change event
- fireContainerPropertySetChange();
-
- return true;
- }
-
- /**
- * Removes all Items from the list.
- * <p>
- * Note : The Property ID and type information is preserved.
- * </p>
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean removeAllItems() {
-
- // Removes all Items
- itemIds.clear();
- items.clear();
-
- // Sends a change event
- fireContentsChange();
-
- return true;
- }
-
- /**
- * Creates a new Item into the list, and assign it an automatic ID. The new
- * ID is returned, or <code>null</code> if the operation fails. After a
- * successful call you can use the
- * {@link #getItem(Object ItemId) <code>getItem</code>}method to fetch the
- * Item.
- *
- * @return ID of the newly created Item, or <code>null</code> in case of a
- * failure
- */
- public Object addItem() {
-
- // Creates a new id
- Object id = new Object();
-
- // Adds the Item into container
- addItem(id);
-
- return id;
- }
-
- /**
- * Creates a new Item with the given ID into the list. The new Item is
- * returned, and it is ready to have its Properties modified. Returns
- * <code>null</code> if the operation fails or the Container already
- * contains a Item with the given ID.
- *
- * @param itemId
- * the ID of the Item to be created.
- * @return Created new Item, or <code>null</code> in case of a failure
- */
- public Item addItem(Object itemId) {
-
- // Makes sure that the Item has not been created yet
- if (items.containsKey(itemId))
- return null;
-
- // Adds the Item to container
- itemIds.add(itemId);
- items.put(itemId, new Hashtable());
-
- // Sends the event
- fireContentsChange();
-
- return getItem(itemId);
- }
-
- /**
- * Removes the Item corresponding to the given Item ID from the list.
- *
- * @param itemId
- * the ID of the Item to remove.
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean removeItem(Object itemId) {
-
- if (items.remove(itemId) == null)
- return false;
- itemIds.remove(itemId);
-
- fireContentsChange();
-
- return true;
- }
-
- /**
- * Removes a Property specified by the given Property ID from the list. Note
- * that the Property will be removed from all Items in the list.
- *
- * @param propertyId
- * the ID of the Property to remove.
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean removeContainerProperty(Object propertyId) {
-
- // Fails if the Property is not present
- if (!propertyIds.contains(propertyId))
- return false;
-
- // Removes the Property to Property list and types
- propertyIds.remove(propertyId);
- types.remove(propertyId);
-
- // If remove the Property from all Items
- for (Iterator i = itemIds.iterator(); i.hasNext();)
- ((Hashtable) items.get(i.next())).remove(propertyId);
-
- // Sends a change event
- fireContainerPropertySetChange();
-
- return true;
- }
-
- /* Container.Ordered methods ******************************************** */
-
- /**
- * Gets the ID of the first Item in the list.
- *
- * @return ID of the first Item in the list
- */
- public Object firstItemId() {
- try {
- return itemIds.get(0);
- } catch (IndexOutOfBoundsException e) {
- }
- return null;
- }
-
- /**
- * Gets the ID of the last Item in the list.
- *
- * @return ID of the last Item in the list
- */
- public Object lastItemId() {
- try {
- return itemIds.get(itemIds.size() - 1);
- } catch (IndexOutOfBoundsException e) {
- }
- return null;
- }
-
- /**
- * Gets the ID of the Item following the Item that corresponds to
- * the itemId. If the given Item is the last or not found in the
- * list, <code>null</code> is returned.
- *
- * @param itemId
- * the ID of an Item in the list.
- * @return ID of the next Item or <code>null</code>
- */
- public Object nextItemId(Object itemId) {
- try {
- return itemIds.get(itemIds.indexOf(itemId) + 1);
- } catch (IndexOutOfBoundsException e) {
- return null;
- }
- }
-
- /**
- * Gets the ID of the Item preceding the Item that corresponds to
- * the itemId. If the given Item is the first or not found in
- * the list, <code>null</code> is returned.
- *
- * @param itemId
- * the ID of an Item in the list.
- * @return ID of the previous Item or <code>null</code>
- */
- public Object prevItemId(Object itemId) {
- try {
- return itemIds.get(itemIds.indexOf(itemId) - 1);
- } catch (IndexOutOfBoundsException e) {
- return null;
- }
- }
-
- /**
- * Tests if the Item corresponding to the given Item ID is the first Item in
- * the list.
- *
- * @param itemId
- * the ID of an Item in the list.
- * @return <code>true</code> if the Item is first in the list,
- * <code>false</code> if not
- */
- public boolean isFirstId(Object itemId) {
- return (size() >= 1 && itemIds.get(0).equals(itemId));
- }
-
- /**
- * Tests if the Item corresponding to the given Item ID is the last Item in
- * the list.
- *
- * @param itemId
- * the ID of an Item in the list.
- * @return <code>true</code> if the Item is last in the list,
- * <code>false</code> if not
- */
- public boolean isLastId(Object itemId) {
- int s = size();
- return (s >= 1 && itemIds.get(s - 1).equals(itemId));
- }
-
- /**
- * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object,
- * Object)
- */
- public Item addItemAfter(Object previousItemId, Object newItemId) {
-
- // Get the index of the addition
- int index = 0;
- if (previousItemId != null) {
- index = 1 + indexOfId(previousItemId);
- if (index <= 0 || index > size())
- return null;
- }
-
- return addItemAt(index, newItemId);
- }
-
- /**
- * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object)
- */
- public Object addItemAfter(Object previousItemId) {
-
- // Get the index of the addition
- int index = 0;
- if (previousItemId != null) {
- index = 1 + indexOfId(previousItemId);
- if (index <= 0 || index > size())
- return null;
- }
-
- return addItemAt(index);
- }
-
- /**
- * Gets ID with the index. The following is true for the index: 0 <= index <
- * size().
- *
- * @return ID in the given index.
- * @param index
- * Index of the requested ID in the container.
- */
- public Object getIdByIndex(int index) {
- return itemIds.get(index);
- }
-
- /**
- * Gets the index of an id. The following is true for the index: 0 <= index <
- * size().
- *
- * @return Index of the Item or -1 if the Item is not in the container.
- * @param itemId
- * ID of an Item in the collection
- */
- public int indexOfId(Object itemId) {
- return itemIds.indexOf(itemId);
- }
-
- /**
- * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int, Object)
- */
- public Item addItemAt(int index, Object newItemId) {
-
- // Make sure that the Item has not been created yet
- if (items.containsKey(newItemId))
- return null;
-
- // Adds the Item to container
- itemIds.add(index, newItemId);
- items.put(newItemId, new Hashtable());
-
- // Sends the event
- fireContentsChange();
-
- return getItem(newItemId);
- }
-
- /**
- * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int)
- */
- public Object addItemAt(int index) {
-
- // Creates a new id
- Object id = new Object();
-
- // Adds the Item into container
- addItemAt(index, id);
-
- return id;
- }
-
- /* Event notifiers ****************************************************** */
-
- /**
- * An <code>event</code> object specifying the list whose Property set has
- * changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
- private class PropertySetChangeEvent extends EventObject implements
- Container.PropertySetChangeEvent {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3257002172528079926L;
-
- private PropertySetChangeEvent(IndexedContainer source) {
- super(source);
- }
-
- /**
- * Gets the list whose Property set has changed.
- *
- * @return source object of the event as a Container
- */
- public Container getContainer() {
- return (Container) getSource();
- }
- }
-
- /**
- * An <code>event</code> object specifying the list whose Item set has
- * changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
- private class ItemSetChangeEvent extends EventObject implements
- Container.ItemSetChangeEvent {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3832616279386372147L;
-
- private ItemSetChangeEvent(IndexedContainer source) {
- super(source);
- }
-
- /**
- * Gets the list whose Item set has changed.
- *
- * @return source object of the event as a Container
- */
- public Container getContainer() {
- return (Container) getSource();
- }
-
- }
-
- /**
- * An <code>event</code> object specifying the Propery in a list whose
- * value has changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
- private class PropertyValueChangeEvent extends EventObject implements
- Property.ValueChangeEvent {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3833749884498359857L;
-
- private PropertyValueChangeEvent(Property source) {
- super(source);
- }
-
- /**
- * Gets the Property whose value has changed.
- *
- * @return source object of the event as a Property
- */
- public Property getProperty() {
- return (Property) getSource();
- }
-
- }
-
- /**
- * Registers a new Property set change listener for this list.
- *
- * @param listener
- * the new Listener to be registered.
- */
- public void addListener(Container.PropertySetChangeListener listener) {
- if (propertySetChangeListeners == null)
- propertySetChangeListeners = new LinkedList();
- propertySetChangeListeners.add(listener);
- }
-
- /**
- * Removes a previously registered Property set change listener.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Container.PropertySetChangeListener listener) {
- if (propertySetChangeListeners != null)
- propertySetChangeListeners.remove(listener);
- }
-
- /**
- * Adds a Item set change listener for the list.
- *
- * @param listener
- * the listener to be added.
- */
- public void addListener(Container.ItemSetChangeListener listener) {
- if (itemSetChangeListeners == null)
- itemSetChangeListeners = new LinkedList();
- itemSetChangeListeners.add(listener);
- }
-
- /**
- * Removes a Item set change listener from the object.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Container.ItemSetChangeListener listener) {
- if (itemSetChangeListeners != null)
- itemSetChangeListeners.remove(listener);
- }
-
- /**
- * Registers a new value change listener for this object.
- *
- * @param listener
- * the new Listener to be registered
- */
- public void addListener(Property.ValueChangeListener listener) {
- if (propertyValueChangeListeners == null)
- propertyValueChangeListeners = new LinkedList();
- propertyValueChangeListeners.add(listener);
- }
-
- /**
- * Removes a previously registered value change listener.
- *
- * @param listener
- * the listener to be removed.
- */
- public void removeListener(Property.ValueChangeListener listener) {
- if (propertyValueChangeListeners != null)
- propertyValueChangeListeners.remove(listener);
- }
-
- /**
- * Sends a Property value change event to all interested listeners.
- * @param source the IndexedContainerProperty object.
- */
- private void firePropertyValueChange(IndexedContainerProperty source) {
-
- // Sends event to listeners listening all value changes
- if (propertyValueChangeListeners != null) {
- Object[] l = propertyValueChangeListeners.toArray();
- 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
- .get(source.propertyId);
- if (propertySetToListenerListMap != null) {
- LinkedList listenerList = (LinkedList) propertySetToListenerListMap
- .get(source.itemId);
- if (listenerList != null) {
- Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent(
- source);
- for (Iterator i = listenerList.iterator(); i.hasNext();)
- ((Property.ValueChangeListener) i.next())
- .valueChange(event);
- }
- }
- }
-
- }
-
- /**
- * Sends a Property set change event to all interested listeners.
- */
- private void fireContainerPropertySetChange() {
- if (propertySetChangeListeners != null) {
- Object[] l = propertySetChangeListeners.toArray();
- Container.PropertySetChangeEvent event = new IndexedContainer.PropertySetChangeEvent(
- this);
- for (int i = 0; i < l.length; i++)
- ((Container.PropertySetChangeListener) l[i])
- .containerPropertySetChange(event);
- }
- }
-
- /**
- * Sends Item set change event to all registered interested listeners.
- */
- private void fireContentsChange() {
- if (itemSetChangeListeners != null) {
- Object[] l = itemSetChangeListeners.toArray();
- Container.ItemSetChangeEvent event = new IndexedContainer.ItemSetChangeEvent(
- this);
- for (int i = 0; i < l.length; i++)
- ((Container.ItemSetChangeListener) l[i])
- .containerItemSetChange(event);
- }
- }
-
- /**
- * Adds new single Property change listener.
- * @param propertyId
- * the ID of the Property to add.
- * @param itemId
- * the ID of the Item .
- * @param listener
- * the listener to be added.
- */
- private void addSinglePropertyChangeListener(Object propertyId,
- Object itemId, Property.ValueChangeListener listener) {
- if (listener != null) {
- if (singlePropertyValueChangeListeners == null)
- singlePropertyValueChangeListeners = new Hashtable();
- Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners
- .get(propertyId);
- if (propertySetToListenerListMap == null) {
- propertySetToListenerListMap = new Hashtable();
- singlePropertyValueChangeListeners.put(propertyId,
- propertySetToListenerListMap);
- }
- LinkedList listenerList = (LinkedList) propertySetToListenerListMap
- .get(itemId);
- if (listenerList == null) {
- listenerList = new LinkedList();
- propertySetToListenerListMap.put(itemId, listenerList);
- }
- listenerList.addLast(listener);
- }
- }
-
- /**
- * Removes a previously registered single Property change listener.
- * @param propertyId
- * the ID of the Property to remove.
- * @param itemId
- * the ID of the Item.
- * @param listener
- * the listener to be removed.
- */
- private void removeSinglePropertyChangeListener(Object propertyId,
- Object itemId, Property.ValueChangeListener listener) {
- if (listener != null && singlePropertyValueChangeListeners != null) {
- Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners
- .get(propertyId);
- if (propertySetToListenerListMap != null) {
- LinkedList listenerList = (LinkedList) propertySetToListenerListMap
- .get(itemId);
- if (listenerList != null) {
- listenerList.remove(listener);
- if (listenerList.isEmpty())
- propertySetToListenerListMap.remove(itemId);
- }
- if (propertySetToListenerListMap.isEmpty())
- singlePropertyValueChangeListeners.remove(propertyId);
- }
- if (singlePropertyValueChangeListeners.isEmpty())
- singlePropertyValueChangeListeners = null;
- }
- }
-
- /* Internal Item and Property implementations *************************** */
-
- /*
- * A class implementing the com.itmill.toolkit.data.Item interface to be
- * contained in the list. @author IT Mill Ltd.
- *
- * @version @VERSION@
- * @since 3.0
- */
- class IndexedContainerItem implements Item {
-
- /**
- * Item ID in the host container for this Item.
- */
- private Object itemId;
-
- /**
- * Constructs a new ListItem instance and connects it to a host
- * container.
- *
- * @param itemId
- * the Item ID of the new Item.
- */
- private IndexedContainerItem(Object itemId) {
-
- // Gets the item contents from the host
- if (itemId == null)
- throw new NullPointerException();
- this.itemId = itemId;
- }
-
- /**
- * Gets the Property corresponding to the given Property ID stored in
- * the Item. If the Item does not contain the Property,
- * <code>null</code> is returned.
- *
- * @param id
- * the identifier of the Property to get.
- * @return the Property with the given ID or <code>null</code>
- */
- public Property getItemProperty(Object id) {
- return new IndexedContainerProperty(itemId, id);
- }
-
- /**
- * Gets the collection containing the IDs of all Properties stored in
- * the Item.
- *
- * @return unmodifiable collection contaning IDs of the Properties
- * stored the Item
- */
- public Collection getItemPropertyIds() {
- return Collections.unmodifiableCollection(propertyIds);
- }
-
- /**
- * Gets the <code>String</code> representation of the contents of the
- * Item. The format of the string is a space separated catenation of the
- * <code>String</code> representations of the Properties contained by
- * the Item.
- *
- * @return <code>String</code> representation of the Item contents
- */
- public String toString() {
- String retValue = "";
-
- for (Iterator i = propertyIds.iterator(); i.hasNext();) {
- Object propertyId = i.next();
- retValue += getItemProperty(propertyId).toString();
- if (i.hasNext())
- retValue += " ";
- }
-
- return retValue;
- }
-
- /**
- * Calculates a integer hash-code for the Item that's unique inside the
- * list. Two Items inside the same list have always different
- * hash-codes, though Items in different lists may have identical
- * hash-codes.
- *
- * @return A locally unique hash-code as integer
- */
- public int hashCode() {
- return getHost().hashCode() ^ itemId.hashCode();
- }
-
- /**
- * Tests if the given object is the same as the this object. Two Items
- * got from a list container with the same ID are equal.
- *
- * @param obj
- * an object to compare with this object
- * @return <code>true</code> if the given object is the same as this
- * object, <code>false</code> if not
- */
- public boolean equals(Object obj) {
- if (obj == null
- || !obj.getClass().equals(IndexedContainerItem.class))
- return false;
- IndexedContainerItem li = (IndexedContainerItem) obj;
- return getHost() == li.getHost() && itemId.equals(li.itemId);
- }
- /**
- *
- * @return
- */
- private IndexedContainer getHost() {
- return IndexedContainer.this;
- }
-
- /**
- * Indexed container does not support adding new properties.
- *
- * @see com.itmill.toolkit.data.Item#addProperty(Object, Property)
- */
- public boolean addItemProperty(Object id, Property property)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Indexed container item "
- + "does not support adding new properties");
- }
-
- /**
- * Indexed container does not support removing properties.
- *
- * @see com.itmill.toolkit.data.Item#removeProperty(Object)
- */
- public boolean removeItemProperty(Object id)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException(
- "Indexed container item does not support property removal");
- }
-
- }
-
- /**
- * A class implementing the com.itmill.toolkit.data.Property interface to be
- * contained in the Items contained in the list. @author IT Mill Ltd.
- *
- * @version @VERSION@
- * @since 3.0
- */
- private class IndexedContainerProperty implements Property,
- Property.ValueChangeNotifier {
-
- /**
- * ID of the Item, where the Property resides.
- */
- private Object itemId;
-
- /**
- * Id of the Property.
- */
- private Object propertyId;
-
- /**
- * Constructs a new ListProperty object and connect it to a ListItem and
- * a ListContainer.
- *
- * @param itemId
- * the ID of the Item to connect the new Property to.
- * @param propertyId
- * the Property ID of the new Property.
- * @param host
- * the list that contains the Item to contain the new
- * Property.
- */
- private IndexedContainerProperty(Object itemId, Object propertyId) {
- if (itemId == null || propertyId == null)
- throw new NullPointerException();
- this.propertyId = propertyId;
- this.itemId = itemId;
- }
-
- /**
- * Returns the type of the Property. The methods <code>getValue</code>
- * and <code>setValue</code> must be compatible with this type: one
- * must be able to safely cast the value returned from
- * <code>getValue</code> to the given type and pass any variable
- * assignable to this type as a parameter to <code>setValue</code.
- *
- * @return the type of the Property.
- */
- public Class getType() {
- return (Class) types.get(propertyId);
- }
-
- /**
- * Gets the value stored in the Property.
- *
- * @return the value stored in the Property.
- */
- public Object getValue() {
- return ((Hashtable) items.get(itemId)).get(propertyId);
- }
-
- /**
- * <p>
- * Tests if the Property is in read-only mode. In read-only mode calls to
- * the method <code>setValue</code> will throw
- * <code>ReadOnlyException</code> s and will not modify the value of
- * the Property.
- * </p>
- *
- * @return <code>true</code> if the Property is in read-only mode,
- * <code>false</code> if it's not.
- */
- public boolean isReadOnly() {
- return readOnlyProperties.contains(this);
- }
-
- /**
- * Sets the Property's read-only mode to the specified status.
- *
- * @param newStatus
- * the new read-only status of the Property.
- */
- public void setReadOnly(boolean newStatus) {
- if (newStatus)
- readOnlyProperties.add(this);
- else
- readOnlyProperties.remove(this);
- }
-
- /**
- * Sets the value of the Property. By default this method will try to
- * assign the value directly, but if it is unassignable, it will try to
- * use the <code>String</code> constructor of the internal data type
- * to assign the value,
- *
- * @param newValue
- * the New value of the Property. This should be assignable to
- * the Property's internal type or support
- * <code>toString</code>.
- *
- * @throws Property.ReadOnlyException
- * if the object is in read-only mode
- * @throws Property.ConversionException
- * if <code>newValue</code> can't be converted into the
- * Property's native type directly or through
- * <code>String</code>
- */
- public void setValue(Object newValue)
- throws Property.ReadOnlyException, Property.ConversionException {
-
- // Gets the Property set
- Hashtable propertySet = (Hashtable) items.get(itemId);
-
- // Support null values on all types
- if (newValue == null)
- propertySet.remove(propertyId);
-
- // Try to assign the compatible value directly
- else if (getType().isAssignableFrom(newValue.getClass()))
- propertySet.put(propertyId, newValue);
-
- // Otherwise try to convert the value trough string constructor
- else
- try {
-
- // Gets the string constructor
- 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) {
- throw new Property.ConversionException(
- "Conversion for value '" + newValue + "' of class "
- + newValue.getClass().getName() + " to "
- + getType().getName() + " failed");
- }
-
- firePropertyValueChange(this);
- }
-
- /**
- * Returns the value of the Property in human readable textual format.
- * The return value should be assignable to the <code>setValue</code>
- * method if the Property is not in read-only mode.
- *
- * @return <code>String</code> representation of the value stored in
- * the Property
- */
- public String toString() {
- Object value = getValue();
- if (value == null)
- return null;
- return value.toString();
- }
-
- /**
- * Calculates a integer hash-code for the Property that's unique inside
- * the Item containing the Property. Two different Properties inside the
- * same Item contained in the same list always have different
- * hash-codes, though Properties in different Items may have identical
- * hash-codes.
- *
- * @return A locally unique hash-code as integer
- */
- public int hashCode() {
- return itemId.hashCode() ^ propertyId.hashCode()
- ^ IndexedContainer.this.hashCode();
- }
-
- /**
- * Tests if the given object is the same as the this object. Two
- * Properties got from an Item with the same ID are equal.
- *
- * @param obj
- * an object to compare with this object
- * @return <code>true</code> if the given object is the same as this
- * object, <code>false</code> if not
- */
- public boolean equals(Object obj) {
- if (obj == null
- || !obj.getClass().equals(IndexedContainerProperty.class))
- return false;
- IndexedContainerProperty lp = (IndexedContainerProperty) obj;
- return lp.getHost() == getHost()
- && lp.propertyId.equals(propertyId)
- && lp.itemId.equals(itemId);
- }
-
- /**
- * Registers a new value change listener for this Property.
- *
- * @param listener
- * the new Listener to be registered.
- * @see com.itmill.toolkit.data.Property.ValueChangeNotifier#addListener(ValueChangeListener)
- */
- public void addListener(Property.ValueChangeListener listener) {
- addSinglePropertyChangeListener(propertyId, itemId, listener);
- }
-
- /**
- * Removes a previously registered value change listener.
- *
- * @param listener
- * listener to be removed
- * @see com.itmill.toolkit.data.Property.ValueChangeNotifier#removeListener(ValueChangeListener)
- */
- public void removeListener(Property.ValueChangeListener listener) {
- removeSinglePropertyChangeListener(propertyId, itemId, listener);
- }
-
- private IndexedContainer getHost() {
- return IndexedContainer.this;
- }
-
- }
-
- /**
- * @see com.itmill.toolkit.data.Container.Sortable#sort(java.lang.Object[],
- * boolean[])
- */
- 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();
- for (int i = 0; i < propertyId.length; i++)
- if (sortable.contains(propertyId[i])) {
- ids.add(propertyId[i]);
- orders.add(new Boolean(i < ascending.length ? ascending[i]
- : true));
- }
-
- if (ids.size() == 0)
- return;
- sortPropertyId = ids.toArray();
- sortDirection = new boolean[orders.size()];
- for (int i = 0; i < sortDirection.length; i++)
- sortDirection[i] = ((Boolean) orders.get(i)).booleanValue();
-
- // Sort
- Collections.sort(this.itemIds, this);
- fireContentsChange();
-
- // Remove temporary references
- sortPropertyId = null;
- sortDirection = null;
-
- }
-
- /**
- * @see com.itmill.toolkit.data.Container.Sortable#getSortableContainerPropertyIds()
- */
- public Collection getSortableContainerPropertyIds() {
-
- LinkedList list = new LinkedList();
- for (Iterator i = this.propertyIds.iterator(); i.hasNext();) {
- Object id = i.next();
- Class type = this.getType(id);
- if (type != null &&
- Comparable.class.isAssignableFrom(type)) {
- list.add(id);
- }
- }
-
- return list;
- }
-
- /**
- * Compares two items for sorting.
- *
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- * @see #sort((java.lang.Object[], boolean[])
- */
- public int compare(Object o1, Object o2) {
-
- for (int i = 0; i < sortPropertyId.length; i++) {
-
- // Get the compared properties
- Property pp1 = getContainerProperty(o1, this.sortPropertyId[i]);
- Property pp2 = getContainerProperty(o2, this.sortPropertyId[i]);
-
- // Get the compared values
- Object p1 = pp1 == null ? null : pp1.getValue();
- Object p2 = pp2 == null ? null : pp2.getValue();
-
- // Result of the comparison
- int r = 0;
-
- // Normal non-null comparison
- if (p1 != null && p2 != null) {
- if ((p1 instanceof Boolean) && (p2 instanceof Boolean))
- r = p1.equals(p2) ? 0 : ((this.sortDirection[i] ? 1 : -1) * (((Boolean)p1).booleanValue() ? 1 : -1));
- else
- r = this.sortDirection[i] ? ((Comparable) p1).compareTo(p2)
- : -((Comparable) p1).compareTo(p2);
- }
-
- // If both are nulls
- else if (p1 == p2)
- r = 0;
-
- // If one of the properties are null
- else
- r = (this.sortDirection[i] ? 1 : -1) * (p1 == null ? -1 : 1);
-
- // If order can be decided
- if (r != 0)
- return r;
- }
-
- return 0;
- }
-
- /**
- * Supports cloning of the IndexedContainer cleanly.
- * @throws CloneNotSupportedException
- * if an object cannot be cloned.
-.
- */
- public Object clone() throws CloneNotSupportedException {
-
- // Creates the clone
- IndexedContainer nc = new IndexedContainer();
-
- // Clone the shallow properties
- nc.itemIds = this.itemIds != null ? (ArrayList) this.itemIds.clone()
- : null;
- nc.itemSetChangeListeners = this.itemSetChangeListeners != null ? (LinkedList) this.itemSetChangeListeners
- .clone()
- : null;
- nc.propertyIds = this.propertyIds != null ? (ArrayList) this.propertyIds
- .clone()
- : null;
- nc.propertySetChangeListeners = this.propertySetChangeListeners != null ? (LinkedList) this.propertySetChangeListeners
- .clone()
- : null;
- nc.propertyValueChangeListeners = this.propertyValueChangeListeners != null ? (LinkedList) this.propertyValueChangeListeners
- .clone()
- : null;
- nc.readOnlyProperties = this.readOnlyProperties != null ? (HashSet) this.readOnlyProperties
- .clone()
- : null;
- nc.singlePropertyValueChangeListeners = this.singlePropertyValueChangeListeners != null ? (Hashtable) this.singlePropertyValueChangeListeners
- .clone()
- : null;
- nc.sortDirection = this.sortDirection != null ? (boolean[]) this.sortDirection
- .clone()
- : null;
- nc.sortPropertyId = this.sortPropertyId != null ? (Object[]) this.sortPropertyId
- .clone()
- : null;
- nc.types = this.types != null ? (Hashtable) this.types.clone() : null;
-
- // Clone property-values
- if (this.items == null)
- nc.items = null;
- else {
- nc.items = new Hashtable();
- for (Iterator i = this.items.keySet().iterator(); i.hasNext();) {
- Object id = i.next();
- Hashtable it = (Hashtable) this.items.get(id);
- nc.items.put(id, it.clone());
- }
- }
-
- return nc;
- }
-
+ Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier,
+ Property.ValueChangeNotifier, Container.Sortable, Comparator, Cloneable {
+
+ /* Internal structure *************************************************** */
+
+ /**
+ * Linked list of ordered Item IDs.
+ */
+ private ArrayList itemIds = new ArrayList();
+
+ /**
+ * Linked list of ordered Property IDs.
+ */
+ private ArrayList propertyIds = new ArrayList();
+
+ /**
+ * Property ID to type mapping.
+ */
+ private Hashtable types = new Hashtable();
+
+ /**
+ * Hash of Items, where each Item is implemented as a mapping from Property
+ * ID to Property value.
+ */
+ private Hashtable items = new Hashtable();
+
+ /**
+ * Set of properties that are read-only.
+ */
+ private HashSet readOnlyProperties = new HashSet();
+
+ /**
+ * List of all Property value change event listeners listening all the
+ * properties.
+ */
+ private LinkedList propertyValueChangeListeners = null;
+
+ /**
+ * Data structure containing all listeners interested in changes to single
+ * Properties. The data structure is a hashtable mapping Property IDs to a
+ * hashtable that maps Item IDs to a linked list of listeners listening
+ * Property identified by given Property ID and Item ID.
+ */
+ private Hashtable singlePropertyValueChangeListeners = null;
+
+ /**
+ * List of all Property set change event listeners.
+ */
+ private LinkedList propertySetChangeListeners = null;
+
+ /**
+ * List of all container Item set change event listeners.
+ */
+ private LinkedList itemSetChangeListeners = null;
+
+ /**
+ * Temporary store for sorting property ids.
+ */
+ private Object[] sortPropertyId;
+
+ /**
+ * Temporary store for sorting direction.
+ */
+ private boolean[] sortDirection;
+
+ /* Container constructors *********************************************** */
+
+ public IndexedContainer() {
+ }
+
+ public IndexedContainer(Collection itemIds) {
+ if (items != null) {
+ for (Iterator i = itemIds.iterator(); i.hasNext();) {
+ this.addItem(i.next());
+ }
+ }
+ }
+
+ /* Container methods **************************************************** */
+
+ /**
+ * Gets the Item with the given Item ID from the list. If the list does not
+ * contain the requested Item, <code>null</code> is returned.
+ *
+ * @param itemId
+ * the ID of the Item to retrieve.
+ * @return the Item with the given ID or <code>null</code> if the Item is
+ * not found in the list
+ */
+ public Item getItem(Object itemId) {
+ if (items.containsKey(itemId))
+ return new IndexedContainerItem(itemId);
+ return null;
+ }
+
+ /**
+ * Gets the ID's of all Items stored in the list. The ID's are returned as a
+ * unmodifiable collection.
+ *
+ * @return unmodifiable collection of Item IDs
+ */
+ public Collection getItemIds() {
+ return Collections.unmodifiableCollection(itemIds);
+ }
+
+ /**
+ * Gets the ID's of all Properties stored in the list. The ID's are returned
+ * as a unmodifiable collection.
+ *
+ * @return unmodifiable collection of Property IDs
+ */
+ public Collection getContainerPropertyIds() {
+ return Collections.unmodifiableCollection(propertyIds);
+ }
+
+ /**
+ * Gets the type of a Property stored in the list.
+ *
+ * @param id
+ * the ID of the Property.
+ * @return Type of the requested Property
+ */
+ public Class getType(Object propertyId) {
+ return (Class) types.get(propertyId);
+ }
+
+ /**
+ * Gets the Property identified by the given Item ID and Property ID from
+ * the lsit. If the list does not contain the Property, <code>null</code>
+ * is returned.
+ *
+ * @param itemId
+ * the ID of the Item which contains the requested Property.
+ * @param propertyId
+ * the ID of the Property to retrieve.
+ * @return Property with the given ID or <code>null</code>
+ *
+ * @see com.itmill.toolkit.data.Container#getContainerProperty(Object,
+ * Object)
+ */
+ public Property getContainerProperty(Object itemId, Object propertyId) {
+ if (!items.containsKey(itemId))
+ return null;
+ return new IndexedContainerProperty(itemId, propertyId);
+ }
+
+ /**
+ * Gets the number of Items in the list.
+ *
+ * @return number of Items in the list
+ */
+ public int size() {
+ return itemIds.size();
+ }
+
+ /**
+ * Tests if the list contains the specified Item
+ *
+ * @param itemId
+ * the ID the of Item to be tested for.
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean containsId(Object itemId) {
+ return items.containsKey(itemId);
+ }
+
+ /**
+ * Adds a new Property to all Items in the list. The Property ID, data type
+ * and default value of the new Property are given as parameters.
+ *
+ * @param propertyId
+ * the ID of the new Property.
+ * @param type
+ * the Data type of the new Property.
+ * @param defaultValue
+ * the value all created Properties are initialized to.
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean addContainerProperty(Object propertyId, Class type,
+ Object defaultValue) {
+
+ // Fails, if nulls are given
+ if (propertyId == null || type == null)
+ return false;
+
+ // Fails if the Property is already present
+ if (propertyIds.contains(propertyId))
+ return false;
+
+ // Adds the Property to Property list and types
+ propertyIds.add(propertyId);
+ types.put(propertyId, type);
+
+ // If default value is given, set it
+ if (defaultValue != null)
+ for (Iterator i = itemIds.iterator(); i.hasNext();)
+ getItem(i.next()).getItemProperty(propertyId).setValue(
+ defaultValue);
+
+ // Sends a change event
+ fireContainerPropertySetChange();
+
+ return true;
+ }
+
+ /**
+ * Removes all Items from the list.
+ * <p>
+ * Note : The Property ID and type information is preserved.
+ * </p>
+ *
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean removeAllItems() {
+
+ // Removes all Items
+ itemIds.clear();
+ items.clear();
+
+ // Sends a change event
+ fireContentsChange();
+
+ return true;
+ }
+
+ /**
+ * Creates a new Item into the list, and assign it an automatic ID. The new
+ * ID is returned, or <code>null</code> if the operation fails. After a
+ * successful call you can use the
+ * {@link #getItem(Object ItemId) <code>getItem</code>}method to fetch the
+ * Item.
+ *
+ * @return ID of the newly created Item, or <code>null</code> in case of a
+ * failure
+ */
+ public Object addItem() {
+
+ // Creates a new id
+ Object id = new Object();
+
+ // Adds the Item into container
+ addItem(id);
+
+ return id;
+ }
+
+ /**
+ * Creates a new Item with the given ID into the list. The new Item is
+ * returned, and it is ready to have its Properties modified. Returns
+ * <code>null</code> if the operation fails or the Container already
+ * contains a Item with the given ID.
+ *
+ * @param itemId
+ * the ID of the Item to be created.
+ * @return Created new Item, or <code>null</code> in case of a failure
+ */
+ public Item addItem(Object itemId) {
+
+ // Makes sure that the Item has not been created yet
+ if (items.containsKey(itemId))
+ return null;
+
+ // Adds the Item to container
+ itemIds.add(itemId);
+ items.put(itemId, new Hashtable());
+
+ // Sends the event
+ fireContentsChange();
+
+ return getItem(itemId);
+ }
+
+ /**
+ * Removes the Item corresponding to the given Item ID from the list.
+ *
+ * @param itemId
+ * the ID of the Item to remove.
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean removeItem(Object itemId) {
+
+ if (items.remove(itemId) == null)
+ return false;
+ itemIds.remove(itemId);
+
+ fireContentsChange();
+
+ return true;
+ }
+
+ /**
+ * Removes a Property specified by the given Property ID from the list. Note
+ * that the Property will be removed from all Items in the list.
+ *
+ * @param propertyId
+ * the ID of the Property to remove.
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean removeContainerProperty(Object propertyId) {
+
+ // Fails if the Property is not present
+ if (!propertyIds.contains(propertyId))
+ return false;
+
+ // Removes the Property to Property list and types
+ propertyIds.remove(propertyId);
+ types.remove(propertyId);
+
+ // If remove the Property from all Items
+ for (Iterator i = itemIds.iterator(); i.hasNext();)
+ ((Hashtable) items.get(i.next())).remove(propertyId);
+
+ // Sends a change event
+ fireContainerPropertySetChange();
+
+ return true;
+ }
+
+ /* Container.Ordered methods ******************************************** */
+
+ /**
+ * Gets the ID of the first Item in the list.
+ *
+ * @return ID of the first Item in the list
+ */
+ public Object firstItemId() {
+ try {
+ return itemIds.get(0);
+ } catch (IndexOutOfBoundsException e) {
+ }
+ return null;
+ }
+
+ /**
+ * Gets the ID of the last Item in the list.
+ *
+ * @return ID of the last Item in the list
+ */
+ public Object lastItemId() {
+ try {
+ return itemIds.get(itemIds.size() - 1);
+ } catch (IndexOutOfBoundsException e) {
+ }
+ return null;
+ }
+
+ /**
+ * Gets the ID of the Item following the Item that corresponds to the
+ * itemId. If the given Item is the last or not found in the list,
+ * <code>null</code> is returned.
+ *
+ * @param itemId
+ * the ID of an Item in the list.
+ * @return ID of the next Item or <code>null</code>
+ */
+ public Object nextItemId(Object itemId) {
+ try {
+ return itemIds.get(itemIds.indexOf(itemId) + 1);
+ } catch (IndexOutOfBoundsException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Gets the ID of the Item preceding the Item that corresponds to the
+ * itemId. If the given Item is the first or not found in the list,
+ * <code>null</code> is returned.
+ *
+ * @param itemId
+ * the ID of an Item in the list.
+ * @return ID of the previous Item or <code>null</code>
+ */
+ public Object prevItemId(Object itemId) {
+ try {
+ return itemIds.get(itemIds.indexOf(itemId) - 1);
+ } catch (IndexOutOfBoundsException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Tests if the Item corresponding to the given Item ID is the first Item in
+ * the list.
+ *
+ * @param itemId
+ * the ID of an Item in the list.
+ * @return <code>true</code> if the Item is first in the list,
+ * <code>false</code> if not
+ */
+ public boolean isFirstId(Object itemId) {
+ return (size() >= 1 && itemIds.get(0).equals(itemId));
+ }
+
+ /**
+ * Tests if the Item corresponding to the given Item ID is the last Item in
+ * the list.
+ *
+ * @param itemId
+ * the ID of an Item in the list.
+ * @return <code>true</code> if the Item is last in the list,
+ * <code>false</code> if not
+ */
+ public boolean isLastId(Object itemId) {
+ int s = size();
+ return (s >= 1 && itemIds.get(s - 1).equals(itemId));
+ }
+
+ /**
+ * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object,
+ * Object)
+ */
+ public Item addItemAfter(Object previousItemId, Object newItemId) {
+
+ // Get the index of the addition
+ int index = 0;
+ if (previousItemId != null) {
+ index = 1 + indexOfId(previousItemId);
+ if (index <= 0 || index > size())
+ return null;
+ }
+
+ return addItemAt(index, newItemId);
+ }
+
+ /**
+ * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object)
+ */
+ public Object addItemAfter(Object previousItemId) {
+
+ // Get the index of the addition
+ int index = 0;
+ if (previousItemId != null) {
+ index = 1 + indexOfId(previousItemId);
+ if (index <= 0 || index > size())
+ return null;
+ }
+
+ return addItemAt(index);
+ }
+
+ /**
+ * Gets ID with the index. The following is true for the index: 0 <= index <
+ * size().
+ *
+ * @return ID in the given index.
+ * @param index
+ * Index of the requested ID in the container.
+ */
+ public Object getIdByIndex(int index) {
+ return itemIds.get(index);
+ }
+
+ /**
+ * Gets the index of an id. The following is true for the index: 0 <= index <
+ * size().
+ *
+ * @return Index of the Item or -1 if the Item is not in the container.
+ * @param itemId
+ * ID of an Item in the collection
+ */
+ public int indexOfId(Object itemId) {
+ return itemIds.indexOf(itemId);
+ }
+
+ /**
+ * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int, Object)
+ */
+ public Item addItemAt(int index, Object newItemId) {
+
+ // Make sure that the Item has not been created yet
+ if (items.containsKey(newItemId))
+ return null;
+
+ // Adds the Item to container
+ itemIds.add(index, newItemId);
+ items.put(newItemId, new Hashtable());
+
+ // Sends the event
+ fireContentsChange();
+
+ return getItem(newItemId);
+ }
+
+ /**
+ * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int)
+ */
+ public Object addItemAt(int index) {
+
+ // Creates a new id
+ Object id = new Object();
+
+ // Adds the Item into container
+ addItemAt(index, id);
+
+ return id;
+ }
+
+ /* Event notifiers ****************************************************** */
+
+ /**
+ * An <code>event</code> object specifying the list whose Property set has
+ * changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ private class PropertySetChangeEvent extends EventObject implements
+ Container.PropertySetChangeEvent {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3257002172528079926L;
+
+ private PropertySetChangeEvent(IndexedContainer source) {
+ super(source);
+ }
+
+ /**
+ * Gets the list whose Property set has changed.
+ *
+ * @return source object of the event as a Container
+ */
+ public Container getContainer() {
+ return (Container) getSource();
+ }
+ }
+
+ /**
+ * An <code>event</code> object specifying the list whose Item set has
+ * changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ private class ItemSetChangeEvent extends EventObject implements
+ Container.ItemSetChangeEvent {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3832616279386372147L;
+
+ private ItemSetChangeEvent(IndexedContainer source) {
+ super(source);
+ }
+
+ /**
+ * Gets the list whose Item set has changed.
+ *
+ * @return source object of the event as a Container
+ */
+ public Container getContainer() {
+ return (Container) getSource();
+ }
+
+ }
+
+ /**
+ * An <code>event</code> object specifying the Propery in a list whose
+ * value has changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ private class PropertyValueChangeEvent extends EventObject implements
+ Property.ValueChangeEvent {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3833749884498359857L;
+
+ private PropertyValueChangeEvent(Property source) {
+ super(source);
+ }
+
+ /**
+ * Gets the Property whose value has changed.
+ *
+ * @return source object of the event as a Property
+ */
+ public Property getProperty() {
+ return (Property) getSource();
+ }
+
+ }
+
+ /**
+ * Registers a new Property set change listener for this list.
+ *
+ * @param listener
+ * the new Listener to be registered.
+ */
+ public void addListener(Container.PropertySetChangeListener listener) {
+ if (propertySetChangeListeners == null)
+ propertySetChangeListeners = new LinkedList();
+ propertySetChangeListeners.add(listener);
+ }
+
+ /**
+ * Removes a previously registered Property set change listener.
+ *
+ * @param listener
+ * the listener to be removed.
+ */
+ public void removeListener(Container.PropertySetChangeListener listener) {
+ if (propertySetChangeListeners != null)
+ propertySetChangeListeners.remove(listener);
+ }
+
+ /**
+ * Adds a Item set change listener for the list.
+ *
+ * @param listener
+ * the listener to be added.
+ */
+ public void addListener(Container.ItemSetChangeListener listener) {
+ if (itemSetChangeListeners == null)
+ itemSetChangeListeners = new LinkedList();
+ itemSetChangeListeners.add(listener);
+ }
+
+ /**
+ * Removes a Item set change listener from the object.
+ *
+ * @param listener
+ * the listener to be removed.
+ */
+ public void removeListener(Container.ItemSetChangeListener listener) {
+ if (itemSetChangeListeners != null)
+ itemSetChangeListeners.remove(listener);
+ }
+
+ /**
+ * Registers a new value change listener for this object.
+ *
+ * @param listener
+ * the new Listener to be registered
+ */
+ public void addListener(Property.ValueChangeListener listener) {
+ if (propertyValueChangeListeners == null)
+ propertyValueChangeListeners = new LinkedList();
+ propertyValueChangeListeners.add(listener);
+ }
+
+ /**
+ * Removes a previously registered value change listener.
+ *
+ * @param listener
+ * the listener to be removed.
+ */
+ public void removeListener(Property.ValueChangeListener listener) {
+ if (propertyValueChangeListeners != null)
+ propertyValueChangeListeners.remove(listener);
+ }
+
+ /**
+ * Sends a Property value change event to all interested listeners.
+ *
+ * @param source
+ * the IndexedContainerProperty object.
+ */
+ private void firePropertyValueChange(IndexedContainerProperty source) {
+
+ // Sends event to listeners listening all value changes
+ if (propertyValueChangeListeners != null) {
+ Object[] l = propertyValueChangeListeners.toArray();
+ 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
+ .get(source.propertyId);
+ if (propertySetToListenerListMap != null) {
+ LinkedList listenerList = (LinkedList) propertySetToListenerListMap
+ .get(source.itemId);
+ if (listenerList != null) {
+ Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent(
+ source);
+ for (Iterator i = listenerList.iterator(); i.hasNext();)
+ ((Property.ValueChangeListener) i.next())
+ .valueChange(event);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Sends a Property set change event to all interested listeners.
+ */
+ private void fireContainerPropertySetChange() {
+ if (propertySetChangeListeners != null) {
+ Object[] l = propertySetChangeListeners.toArray();
+ Container.PropertySetChangeEvent event = new IndexedContainer.PropertySetChangeEvent(
+ this);
+ for (int i = 0; i < l.length; i++)
+ ((Container.PropertySetChangeListener) l[i])
+ .containerPropertySetChange(event);
+ }
+ }
+
+ /**
+ * Sends Item set change event to all registered interested listeners.
+ */
+ private void fireContentsChange() {
+ if (itemSetChangeListeners != null) {
+ Object[] l = itemSetChangeListeners.toArray();
+ Container.ItemSetChangeEvent event = new IndexedContainer.ItemSetChangeEvent(
+ this);
+ for (int i = 0; i < l.length; i++)
+ ((Container.ItemSetChangeListener) l[i])
+ .containerItemSetChange(event);
+ }
+ }
+
+ /**
+ * Adds new single Property change listener.
+ *
+ * @param propertyId
+ * the ID of the Property to add.
+ * @param itemId
+ * the ID of the Item .
+ * @param listener
+ * the listener to be added.
+ */
+ private void addSinglePropertyChangeListener(Object propertyId,
+ Object itemId, Property.ValueChangeListener listener) {
+ if (listener != null) {
+ if (singlePropertyValueChangeListeners == null)
+ singlePropertyValueChangeListeners = new Hashtable();
+ Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners
+ .get(propertyId);
+ if (propertySetToListenerListMap == null) {
+ propertySetToListenerListMap = new Hashtable();
+ singlePropertyValueChangeListeners.put(propertyId,
+ propertySetToListenerListMap);
+ }
+ LinkedList listenerList = (LinkedList) propertySetToListenerListMap
+ .get(itemId);
+ if (listenerList == null) {
+ listenerList = new LinkedList();
+ propertySetToListenerListMap.put(itemId, listenerList);
+ }
+ listenerList.addLast(listener);
+ }
+ }
+
+ /**
+ * Removes a previously registered single Property change listener.
+ *
+ * @param propertyId
+ * the ID of the Property to remove.
+ * @param itemId
+ * the ID of the Item.
+ * @param listener
+ * the listener to be removed.
+ */
+ private void removeSinglePropertyChangeListener(Object propertyId,
+ Object itemId, Property.ValueChangeListener listener) {
+ if (listener != null && singlePropertyValueChangeListeners != null) {
+ Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners
+ .get(propertyId);
+ if (propertySetToListenerListMap != null) {
+ LinkedList listenerList = (LinkedList) propertySetToListenerListMap
+ .get(itemId);
+ if (listenerList != null) {
+ listenerList.remove(listener);
+ if (listenerList.isEmpty())
+ propertySetToListenerListMap.remove(itemId);
+ }
+ if (propertySetToListenerListMap.isEmpty())
+ singlePropertyValueChangeListeners.remove(propertyId);
+ }
+ if (singlePropertyValueChangeListeners.isEmpty())
+ singlePropertyValueChangeListeners = null;
+ }
+ }
+
+ /* Internal Item and Property implementations *************************** */
+
+ /*
+ * A class implementing the com.itmill.toolkit.data.Item interface to be
+ * contained in the list. @author IT Mill Ltd.
+ *
+ * @version @VERSION@
+ * @since 3.0
+ */
+ class IndexedContainerItem implements Item {
+
+ /**
+ * Item ID in the host container for this Item.
+ */
+ private Object itemId;
+
+ /**
+ * Constructs a new ListItem instance and connects it to a host
+ * container.
+ *
+ * @param itemId
+ * the Item ID of the new Item.
+ */
+ private IndexedContainerItem(Object itemId) {
+
+ // Gets the item contents from the host
+ if (itemId == null)
+ throw new NullPointerException();
+ this.itemId = itemId;
+ }
+
+ /**
+ * Gets the Property corresponding to the given Property ID stored in
+ * the Item. If the Item does not contain the Property,
+ * <code>null</code> is returned.
+ *
+ * @param id
+ * the identifier of the Property to get.
+ * @return the Property with the given ID or <code>null</code>
+ */
+ public Property getItemProperty(Object id) {
+ return new IndexedContainerProperty(itemId, id);
+ }
+
+ /**
+ * Gets the collection containing the IDs of all Properties stored in
+ * the Item.
+ *
+ * @return unmodifiable collection contaning IDs of the Properties
+ * stored the Item
+ */
+ public Collection getItemPropertyIds() {
+ return Collections.unmodifiableCollection(propertyIds);
+ }
+
+ /**
+ * Gets the <code>String</code> representation of the contents of the
+ * Item. The format of the string is a space separated catenation of the
+ * <code>String</code> representations of the Properties contained by
+ * the Item.
+ *
+ * @return <code>String</code> representation of the Item contents
+ */
+ public String toString() {
+ String retValue = "";
+
+ for (Iterator i = propertyIds.iterator(); i.hasNext();) {
+ Object propertyId = i.next();
+ retValue += getItemProperty(propertyId).toString();
+ if (i.hasNext())
+ retValue += " ";
+ }
+
+ return retValue;
+ }
+
+ /**
+ * Calculates a integer hash-code for the Item that's unique inside the
+ * list. Two Items inside the same list have always different
+ * hash-codes, though Items in different lists may have identical
+ * hash-codes.
+ *
+ * @return A locally unique hash-code as integer
+ */
+ public int hashCode() {
+ return getHost().hashCode() ^ itemId.hashCode();
+ }
+
+ /**
+ * Tests if the given object is the same as the this object. Two Items
+ * got from a list container with the same ID are equal.
+ *
+ * @param obj
+ * an object to compare with this object
+ * @return <code>true</code> if the given object is the same as this
+ * object, <code>false</code> if not
+ */
+ public boolean equals(Object obj) {
+ if (obj == null
+ || !obj.getClass().equals(IndexedContainerItem.class))
+ return false;
+ IndexedContainerItem li = (IndexedContainerItem) obj;
+ return getHost() == li.getHost() && itemId.equals(li.itemId);
+ }
+
+ /**
+ *
+ * @return
+ */
+ private IndexedContainer getHost() {
+ return IndexedContainer.this;
+ }
+
+ /**
+ * Indexed container does not support adding new properties.
+ *
+ * @see com.itmill.toolkit.data.Item#addProperty(Object, Property)
+ */
+ public boolean addItemProperty(Object id, Property property)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Indexed container item "
+ + "does not support adding new properties");
+ }
+
+ /**
+ * Indexed container does not support removing properties.
+ *
+ * @see com.itmill.toolkit.data.Item#removeProperty(Object)
+ */
+ public boolean removeItemProperty(Object id)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "Indexed container item does not support property removal");
+ }
+
+ }
+
+ /**
+ * A class implementing the com.itmill.toolkit.data.Property interface to be
+ * contained in the Items contained in the list.
+ *
+ * @author IT Mill Ltd.
+ *
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ private class IndexedContainerProperty implements Property,
+ Property.ValueChangeNotifier {
+
+ /**
+ * ID of the Item, where the Property resides.
+ */
+ private Object itemId;
+
+ /**
+ * Id of the Property.
+ */
+ private Object propertyId;
+
+ /**
+ * Constructs a new ListProperty object and connect it to a ListItem and
+ * a ListContainer.
+ *
+ * @param itemId
+ * the ID of the Item to connect the new Property to.
+ * @param propertyId
+ * the Property ID of the new Property.
+ * @param host
+ * the list that contains the Item to contain the new
+ * Property.
+ */
+ private IndexedContainerProperty(Object itemId, Object propertyId) {
+ if (itemId == null || propertyId == null)
+ throw new NullPointerException();
+ this.propertyId = propertyId;
+ this.itemId = itemId;
+ }
+
+ /**
+ * Returns the type of the Property. The methods <code>getValue</code>
+ * and <code>setValue</code> must be compatible with this type: one
+ * must be able to safely cast the value returned from
+ * <code>getValue</code> to the given type and pass any variable
+ * assignable to this type as a parameter to <code>setValue</code.
+ *
+ * @return the type of the Property.
+ */
+ public Class getType() {
+ return (Class) types.get(propertyId);
+ }
+
+ /**
+ * Gets the value stored in the Property.
+ *
+ * @return the value stored in the Property.
+ */
+ public Object getValue() {
+ return ((Hashtable) items.get(itemId)).get(propertyId);
+ }
+
+ /**
+ * <p>
+ * Tests if the Property is in read-only mode. In read-only mode calls
+ * to the method <code>setValue</code> will throw
+ * <code>ReadOnlyException</code> s and will not modify the value of
+ * the Property.
+ * </p>
+ *
+ * @return <code>true</code> if the Property is in read-only mode,
+ * <code>false</code> if it's not.
+ */
+ public boolean isReadOnly() {
+ return readOnlyProperties.contains(this);
+ }
+
+ /**
+ * Sets the Property's read-only mode to the specified status.
+ *
+ * @param newStatus
+ * the new read-only status of the Property.
+ */
+ public void setReadOnly(boolean newStatus) {
+ if (newStatus)
+ readOnlyProperties.add(this);
+ else
+ readOnlyProperties.remove(this);
+ }
+
+ /**
+ * Sets the value of the Property. By default this method will try to
+ * assign the value directly, but if it is unassignable, it will try to
+ * use the <code>String</code> constructor of the internal data type
+ * to assign the value,
+ *
+ * @param newValue
+ * the New value of the Property. This should be assignable
+ * to the Property's internal type or support
+ * <code>toString</code>.
+ *
+ * @throws Property.ReadOnlyException
+ * if the object is in read-only mode
+ * @throws Property.ConversionException
+ * if <code>newValue</code> can't be converted into the
+ * Property's native type directly or through
+ * <code>String</code>
+ */
+ public void setValue(Object newValue)
+ throws Property.ReadOnlyException, Property.ConversionException {
+
+ // Gets the Property set
+ Hashtable propertySet = (Hashtable) items.get(itemId);
+
+ // Support null values on all types
+ if (newValue == null)
+ propertySet.remove(propertyId);
+
+ // Try to assign the compatible value directly
+ else if (getType().isAssignableFrom(newValue.getClass()))
+ propertySet.put(propertyId, newValue);
+
+ // Otherwise try to convert the value trough string constructor
+ else
+ try {
+
+ // Gets the string constructor
+ 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) {
+ throw new Property.ConversionException(
+ "Conversion for value '" + newValue + "' of class "
+ + newValue.getClass().getName() + " to "
+ + getType().getName() + " failed");
+ }
+
+ firePropertyValueChange(this);
+ }
+
+ /**
+ * Returns the value of the Property in human readable textual format.
+ * The return value should be assignable to the <code>setValue</code>
+ * method if the Property is not in read-only mode.
+ *
+ * @return <code>String</code> representation of the value stored in
+ * the Property
+ */
+ public String toString() {
+ Object value = getValue();
+ if (value == null)
+ return null;
+ return value.toString();
+ }
+
+ /**
+ * Calculates a integer hash-code for the Property that's unique inside
+ * the Item containing the Property. Two different Properties inside the
+ * same Item contained in the same list always have different
+ * hash-codes, though Properties in different Items may have identical
+ * hash-codes.
+ *
+ * @return A locally unique hash-code as integer
+ */
+ public int hashCode() {
+ return itemId.hashCode() ^ propertyId.hashCode()
+ ^ IndexedContainer.this.hashCode();
+ }
+
+ /**
+ * Tests if the given object is the same as the this object. Two
+ * Properties got from an Item with the same ID are equal.
+ *
+ * @param obj
+ * an object to compare with this object
+ * @return <code>true</code> if the given object is the same as this
+ * object, <code>false</code> if not
+ */
+ public boolean equals(Object obj) {
+ if (obj == null
+ || !obj.getClass().equals(IndexedContainerProperty.class))
+ return false;
+ IndexedContainerProperty lp = (IndexedContainerProperty) obj;
+ return lp.getHost() == getHost()
+ && lp.propertyId.equals(propertyId)
+ && lp.itemId.equals(itemId);
+ }
+
+ /**
+ * Registers a new value change listener for this Property.
+ *
+ * @param listener
+ * the new Listener to be registered.
+ * @see com.itmill.toolkit.data.Property.ValueChangeNotifier#addListener(ValueChangeListener)
+ */
+ public void addListener(Property.ValueChangeListener listener) {
+ addSinglePropertyChangeListener(propertyId, itemId, listener);
+ }
+
+ /**
+ * Removes a previously registered value change listener.
+ *
+ * @param listener
+ * listener to be removed
+ * @see com.itmill.toolkit.data.Property.ValueChangeNotifier#removeListener(ValueChangeListener)
+ */
+ public void removeListener(Property.ValueChangeListener listener) {
+ removeSinglePropertyChangeListener(propertyId, itemId, listener);
+ }
+
+ private IndexedContainer getHost() {
+ return IndexedContainer.this;
+ }
+
+ }
+
+ /**
+ * @see com.itmill.toolkit.data.Container.Sortable#sort(java.lang.Object[],
+ * boolean[])
+ */
+ 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();
+ for (int i = 0; i < propertyId.length; i++)
+ if (sortable.contains(propertyId[i])) {
+ ids.add(propertyId[i]);
+ orders.add(new Boolean(i < ascending.length ? ascending[i]
+ : true));
+ }
+
+ if (ids.size() == 0)
+ return;
+ sortPropertyId = ids.toArray();
+ sortDirection = new boolean[orders.size()];
+ for (int i = 0; i < sortDirection.length; i++)
+ sortDirection[i] = ((Boolean) orders.get(i)).booleanValue();
+
+ // Sort
+ Collections.sort(this.itemIds, this);
+ fireContentsChange();
+
+ // Remove temporary references
+ sortPropertyId = null;
+ sortDirection = null;
+
+ }
+
+ /**
+ * @see com.itmill.toolkit.data.Container.Sortable#getSortableContainerPropertyIds()
+ */
+ public Collection getSortableContainerPropertyIds() {
+
+ LinkedList list = new LinkedList();
+ for (Iterator i = this.propertyIds.iterator(); i.hasNext();) {
+ Object id = i.next();
+ Class type = this.getType(id);
+ if (type != null && Comparable.class.isAssignableFrom(type)) {
+ list.add(id);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * Compares two items for sorting.
+ *
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ * @see #sort((java.lang.Object[], boolean[])
+ */
+ public int compare(Object o1, Object o2) {
+
+ for (int i = 0; i < sortPropertyId.length; i++) {
+
+ // Get the compared properties
+ Property pp1 = getContainerProperty(o1, this.sortPropertyId[i]);
+ Property pp2 = getContainerProperty(o2, this.sortPropertyId[i]);
+
+ // Get the compared values
+ Object p1 = pp1 == null ? null : pp1.getValue();
+ Object p2 = pp2 == null ? null : pp2.getValue();
+
+ // Result of the comparison
+ int r = 0;
+
+ // Normal non-null comparison
+ if (p1 != null && p2 != null) {
+ if ((p1 instanceof Boolean) && (p2 instanceof Boolean))
+ r = p1.equals(p2) ? 0
+ : ((this.sortDirection[i] ? 1 : -1) * (((Boolean) p1)
+ .booleanValue() ? 1 : -1));
+ else
+ r = this.sortDirection[i] ? ((Comparable) p1).compareTo(p2)
+ : -((Comparable) p1).compareTo(p2);
+ }
+
+ // If both are nulls
+ else if (p1 == p2)
+ r = 0;
+
+ // If one of the properties are null
+ else
+ r = (this.sortDirection[i] ? 1 : -1) * (p1 == null ? -1 : 1);
+
+ // If order can be decided
+ if (r != 0)
+ return r;
+ }
+
+ return 0;
+ }
+
+ /**
+ * Supports cloning of the IndexedContainer cleanly.
+ *
+ * @throws CloneNotSupportedException
+ * if an object cannot be cloned. .
+ */
+ public Object clone() throws CloneNotSupportedException {
+
+ // Creates the clone
+ IndexedContainer nc = new IndexedContainer();
+
+ // Clone the shallow properties
+ nc.itemIds = this.itemIds != null ? (ArrayList) this.itemIds.clone()
+ : null;
+ nc.itemSetChangeListeners = this.itemSetChangeListeners != null ? (LinkedList) this.itemSetChangeListeners
+ .clone()
+ : null;
+ nc.propertyIds = this.propertyIds != null ? (ArrayList) this.propertyIds
+ .clone()
+ : null;
+ nc.propertySetChangeListeners = this.propertySetChangeListeners != null ? (LinkedList) this.propertySetChangeListeners
+ .clone()
+ : null;
+ nc.propertyValueChangeListeners = this.propertyValueChangeListeners != null ? (LinkedList) this.propertyValueChangeListeners
+ .clone()
+ : null;
+ nc.readOnlyProperties = this.readOnlyProperties != null ? (HashSet) this.readOnlyProperties
+ .clone()
+ : null;
+ nc.singlePropertyValueChangeListeners = this.singlePropertyValueChangeListeners != null ? (Hashtable) this.singlePropertyValueChangeListeners
+ .clone()
+ : null;
+ nc.sortDirection = this.sortDirection != null ? (boolean[]) this.sortDirection
+ .clone()
+ : null;
+ nc.sortPropertyId = this.sortPropertyId != null ? (Object[]) this.sortPropertyId
+ .clone()
+ : null;
+ nc.types = this.types != null ? (Hashtable) this.types.clone() : null;
+
+ // Clone property-values
+ if (this.items == null)
+ nc.items = null;
+ else {
+ nc.items = new Hashtable();
+ for (Iterator i = this.items.keySet().iterator(); i.hasNext();) {
+ Object id = i.next();
+ Hashtable it = (Hashtable) this.items.get(id);
+ nc.items.put(id, it.clone());
+ }
+ }
+
+ return nc;
+ }
+
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
- public boolean equals(Object obj) {
-
- // Only ones of the objects of the same class can be equal
- if (!(obj instanceof IndexedContainer))
- return false;
- IndexedContainer o = (IndexedContainer) obj;
-
- // Checks the properties one by one
- if (itemIds != o.itemIds && o.itemIds != null
- && !o.itemIds.equals(this.itemIds))
- return false;
- if (items != o.items && o.items != null && !o.items.equals(this.items))
- return false;
- if (itemSetChangeListeners != o.itemSetChangeListeners
- && o.itemSetChangeListeners != null
- && !o.itemSetChangeListeners
- .equals(this.itemSetChangeListeners))
- return false;
- if (propertyIds != o.propertyIds && o.propertyIds != null
- && !o.propertyIds.equals(this.propertyIds))
- return false;
- if (propertySetChangeListeners != o.propertySetChangeListeners
- && o.propertySetChangeListeners != null
- && !o.propertySetChangeListeners
- .equals(this.propertySetChangeListeners))
- return false;
- if (propertyValueChangeListeners != o.propertyValueChangeListeners
- && o.propertyValueChangeListeners != null
- && !o.propertyValueChangeListeners
- .equals(this.propertyValueChangeListeners))
- return false;
- if (readOnlyProperties != o.readOnlyProperties
- && o.readOnlyProperties != null
- && !o.readOnlyProperties.equals(this.readOnlyProperties))
- return false;
- if (singlePropertyValueChangeListeners != o.singlePropertyValueChangeListeners
- && o.singlePropertyValueChangeListeners != null
- && !o.singlePropertyValueChangeListeners
- .equals(this.singlePropertyValueChangeListeners))
- return false;
- if (sortDirection != o.sortDirection && o.sortDirection != null
- && !o.sortDirection.equals(this.sortDirection))
- return false;
- if (sortPropertyId != o.sortPropertyId && o.sortPropertyId != null
- && !o.sortPropertyId.equals(this.sortPropertyId))
- return false;
- if (types != o.types && o.types != null && !o.types.equals(this.types))
- return false;
-
- return true;
- }
-
+ public boolean equals(Object obj) {
+
+ // Only ones of the objects of the same class can be equal
+ if (!(obj instanceof IndexedContainer))
+ return false;
+ IndexedContainer o = (IndexedContainer) obj;
+
+ // Checks the properties one by one
+ if (itemIds != o.itemIds && o.itemIds != null
+ && !o.itemIds.equals(this.itemIds))
+ return false;
+ if (items != o.items && o.items != null && !o.items.equals(this.items))
+ return false;
+ if (itemSetChangeListeners != o.itemSetChangeListeners
+ && o.itemSetChangeListeners != null
+ && !o.itemSetChangeListeners
+ .equals(this.itemSetChangeListeners))
+ return false;
+ if (propertyIds != o.propertyIds && o.propertyIds != null
+ && !o.propertyIds.equals(this.propertyIds))
+ return false;
+ if (propertySetChangeListeners != o.propertySetChangeListeners
+ && o.propertySetChangeListeners != null
+ && !o.propertySetChangeListeners
+ .equals(this.propertySetChangeListeners))
+ return false;
+ if (propertyValueChangeListeners != o.propertyValueChangeListeners
+ && o.propertyValueChangeListeners != null
+ && !o.propertyValueChangeListeners
+ .equals(this.propertyValueChangeListeners))
+ return false;
+ if (readOnlyProperties != o.readOnlyProperties
+ && o.readOnlyProperties != null
+ && !o.readOnlyProperties.equals(this.readOnlyProperties))
+ return false;
+ if (singlePropertyValueChangeListeners != o.singlePropertyValueChangeListeners
+ && o.singlePropertyValueChangeListeners != null
+ && !o.singlePropertyValueChangeListeners
+ .equals(this.singlePropertyValueChangeListeners))
+ return false;
+ if (sortDirection != o.sortDirection && o.sortDirection != null
+ && !o.sortDirection.equals(this.sortDirection))
+ return false;
+ if (sortPropertyId != o.sortPropertyId && o.sortPropertyId != null
+ && !o.sortPropertyId.equals(this.sortPropertyId))
+ return false;
+ if (types != o.types && o.types != null && !o.types.equals(this.types))
+ return false;
+
+ return true;
+ }
+
/**
* @see java.lang.Object#hashCode()
*/
- public int hashCode() {
-
- // The hash-code is calculated as combination hash of the members
- return (this.itemIds != null ? this.itemIds.hashCode() : 0)
- ^ (this.items != null ? this.items.hashCode() : 0)
- ^ (this.itemSetChangeListeners != null ? this.itemSetChangeListeners
- .hashCode()
- : 0)
- ^ (this.propertyIds != null ? this.propertyIds.hashCode() : 0)
- ^ (this.propertySetChangeListeners != null ? this.propertySetChangeListeners
- .hashCode()
- : 0)
- ^ (this.propertyValueChangeListeners != null ? this.propertyValueChangeListeners
- .hashCode()
- : 0)
- ^ (this.readOnlyProperties != null ? this.readOnlyProperties
- .hashCode() : 0)
- ^ (this.singlePropertyValueChangeListeners != null ? this.singlePropertyValueChangeListeners
- .hashCode()
- : 0)
- ^ (this.sortPropertyId != null ? this.sortPropertyId.hashCode()
- : 0)
- ^ (this.types != null ? this.types.hashCode() : 0)
- ^ (this.sortDirection != null ? this.sortDirection.hashCode()
- : 0);
- }
+ public int hashCode() {
+
+ // The hash-code is calculated as combination hash of the members
+ return (this.itemIds != null ? this.itemIds.hashCode() : 0)
+ ^ (this.items != null ? this.items.hashCode() : 0)
+ ^ (this.itemSetChangeListeners != null ? this.itemSetChangeListeners
+ .hashCode()
+ : 0)
+ ^ (this.propertyIds != null ? this.propertyIds.hashCode() : 0)
+ ^ (this.propertySetChangeListeners != null ? this.propertySetChangeListeners
+ .hashCode()
+ : 0)
+ ^ (this.propertyValueChangeListeners != null ? this.propertyValueChangeListeners
+ .hashCode()
+ : 0)
+ ^ (this.readOnlyProperties != null ? this.readOnlyProperties
+ .hashCode() : 0)
+ ^ (this.singlePropertyValueChangeListeners != null ? this.singlePropertyValueChangeListeners
+ .hashCode()
+ : 0)
+ ^ (this.sortPropertyId != null ? this.sortPropertyId.hashCode()
+ : 0)
+ ^ (this.types != null ? this.types.hashCode() : 0)
+ ^ (this.sortDirection != null ? this.sortDirection.hashCode()
+ : 0);
+ }
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/data/util/MethodProperty.java b/src/com/itmill/toolkit/data/util/MethodProperty.java
index d058feb029..7c56f7e3bb 100644
--- a/src/com/itmill/toolkit/data/util/MethodProperty.java
+++ b/src/com/itmill/toolkit/data/util/MethodProperty.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -35,97 +35,100 @@ import java.util.LinkedList;
import com.itmill.toolkit.data.Property;
-/**
+/**
* <p>
- * Proxy class for creating Properties from pairs of getter and setter
- * methods of a Bean property. An instance of this class can be thought as
- * having been attached to a field of an object. Accessing the object
- * through the Property interface directly manipulates the underlying
- * field.
+ * Proxy class for creating Properties from pairs of getter and setter methods
+ * of a Bean property. An instance of this class can be thought as having been
+ * attached to a field of an object. Accessing the object through the Property
+ * interface directly manipulates the underlying field.
* </p>
*
* <p>
- * It's assumed that the return value returned by the getter method
- * is assignable to the type of the property, and the setter method
- * parameter is assignable to that value.
+ * It's assumed that the return value returned by the getter method is
+ * assignable to the type of the property, and the setter method parameter is
+ * assignable to that value.
* </p>
*
* <p>
- * A valid getter method must always be available, but instance of this
- * class can be constructed with a <code>null</code> setter method in which
- * case the resulting MethodProperty is read-only.
+ * A valid getter method must always be available, but instance of this class
+ * can be constructed with a <code>null</code> setter method in which case the
+ * resulting MethodProperty is read-only.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class MethodProperty implements Property {
- /**
- * The object that includes the property the MethodProperty is bound to.
+ /**
+ * The object that includes the property the MethodProperty is bound to.
*/
private Object instance;
- /**
- * Argument arrays for the getter and setter methods.
+ /**
+ * Argument arrays for the getter and setter methods.
*/
private Object[] setArgs, getArgs;
/**
- * Is the MethodProperty read-only?
+ * Is the MethodProperty read-only?
*/
private boolean readOnly;
/**
- * The getter and setter methods.
+ * The getter and setter methods.
*/
private Method setMethod, getMethod;
- /**
- * Index of the new value in the argument list for the setter method.
- * If the setter method requires several parameters, this index tells
- * which one is the actual value to change.
+ /**
+ * Index of the new value in the argument list for the setter method. If the
+ * setter method requires several parameters, this index tells which one is
+ * the actual value to change.
*/
private int setArgumentIndex;
- /**
- * Type of the property.
+ /**
+ * Type of the property.
*/
private Class type;
- /**
- * List of listeners who are interested in the read-only status changes
- * of the MethodProperty
+ /**
+ * List of listeners who are interested in the read-only status changes of
+ * the MethodProperty
*/
private LinkedList readOnlyStatusChangeListeners = null;
- /**
+ /**
* <p>
* Creates a new instance of <code>MethodProperty</code> from a named bean
* property. This constructor takes an object and the name of a bean
* property and initializes itself with the accessor methods for the
* property.
- *</p>
+ * </p>
* <p>
- * The getter method of a <code>MethodProperty</code> instantiated
- * with this constructor will be called with no arguments, and the
- * setter method with only the new value as the sole argument.
+ * The getter method of a <code>MethodProperty</code> instantiated with
+ * this constructor will be called with no arguments, and the setter method
+ * with only the new value as the sole argument.
* </p>
*
* <p>
- * If the setter method is unavailable, the resulting <code>MethodProperty</code>
- * will be read-only, otherwise it will be read-write.
+ * If the setter method is unavailable, the resulting
+ * <code>MethodProperty</code> will be read-only, otherwise it will be
+ * read-write.
* </p>
*
* <p>
* Method names are constucted from the bean property by adding
- * get/is/are/set prefix and capitalising the first character in the
- * name of the given bean property.
+ * get/is/are/set prefix and capitalising the first character in the name of
+ * the given bean property.
* </p>
*
- * @param instance the object that includes the property.
- * @param beanPropertyName the name of the property to bind to.
+ * @param instance
+ * the object that includes the property.
+ * @param beanPropertyName
+ * the name of the property to bind to.
*/
public MethodProperty(Object instance, String beanPropertyName) {
@@ -142,25 +145,19 @@ public class MethodProperty implements Property {
// Find the get method
getMethod = null;
try {
- getMethod =
- beanClass.getMethod("get" + beanPropertyName, new Class[] {
- });
+ getMethod = beanClass.getMethod("get" + beanPropertyName,
+ new Class[] {});
} catch (java.lang.NoSuchMethodException ignored) {
try {
- getMethod =
- beanClass.getMethod("is" + beanPropertyName, new Class[] {
- });
+ getMethod = beanClass.getMethod("is" + beanPropertyName,
+ new Class[] {});
} catch (java.lang.NoSuchMethodException ignoredAsWell) {
try {
- getMethod =
- beanClass
- .getMethod("are" + beanPropertyName, new Class[] {
- });
+ getMethod = beanClass.getMethod("are" + beanPropertyName,
+ new Class[] {});
} catch (java.lang.NoSuchMethodException e) {
- throw new MethodProperty.MethodException(
- "Bean property "
- + beanPropertyName
- + " can not be found");
+ throw new MethodProperty.MethodException("Bean property "
+ + beanPropertyName + " can not be found");
}
}
}
@@ -171,9 +168,7 @@ public class MethodProperty implements Property {
// Finds the set method
setMethod = null;
try {
- setMethod =
- beanClass.getMethod(
- "set" + beanPropertyName,
+ setMethod = beanClass.getMethod("set" + beanPropertyName,
new Class[] { type });
} catch (java.lang.NoSuchMethodException skipped) {
}
@@ -198,117 +193,123 @@ public class MethodProperty implements Property {
type = Long.class;
}
- setArguments(new Object[] {
- }, new Object[] { null }, 0);
+ setArguments(new Object[] {}, new Object[] { null }, 0);
this.readOnly = (setMethod == null);
this.instance = instance;
}
- /**
+ /**
* <p>
- * Creates a new instance of <code>MethodProperty</code> from named getter and
- * setter methods. The getter method of a <code>MethodProperty</code> instantiated
- * with this constructor will be called with no arguments, and the
- * setter method with only the new value as the sole argument.
+ * Creates a new instance of <code>MethodProperty</code> from named getter
+ * and setter methods. The getter method of a <code>MethodProperty</code>
+ * instantiated with this constructor will be called with no arguments, and
+ * the setter method with only the new value as the sole argument.
* </p>
- *
+ *
* <p>
* If the setter method is <code>null</code>, the resulting
* <code>MethodProperty</code> will be read-only, otherwise it will be
* read-write.
* </p>
*
- * @param type the type of the property.
- * @param instance the object that includes the property.
- * @param getMethodName the name of the getter method.
- * @param setMethodName the name of the setter method.
- *
+ * @param type
+ * the type of the property.
+ * @param instance
+ * the object that includes the property.
+ * @param getMethodName
+ * the name of the getter method.
+ * @param setMethodName
+ * the name of the setter method.
+ *
*/
- public MethodProperty(
- Class type,
- Object instance,
- String getMethodName,
- String setMethodName) {
- this(type, instance, getMethodName, setMethodName, new Object[] {
- }, new Object[] { null }, 0);
+ public MethodProperty(Class type, Object instance, String getMethodName,
+ String setMethodName) {
+ this(type, instance, getMethodName, setMethodName, new Object[] {},
+ new Object[] { null }, 0);
}
- /**
+ /**
* <p>
- * Creates a new instance of <code>MethodProperty</code> with the getter and
- * setter methods. The getter method of a <code>MethodProperty</code> instantiated
- * with this constructor will be called with no arguments, and the
- * setter method with only the new value as the sole argument.
+ * Creates a new instance of <code>MethodProperty</code> with the getter
+ * and setter methods. The getter method of a <code>MethodProperty</code>
+ * instantiated with this constructor will be called with no arguments, and
+ * the setter method with only the new value as the sole argument.
* </p>
- *
+ *
* <p>
* If the setter method is <code>null</code>, the resulting
* <code>MethodProperty</code> will be read-only, otherwise it will be
* read-write.
* </p>
- *
- * @param type the type of the property.
- * @param instance the object that includes the property.
- * @param getMethod the getter method.
- * @param setMethod the setter method.
+ *
+ * @param type
+ * the type of the property.
+ * @param instance
+ * the object that includes the property.
+ * @param getMethod
+ * the getter method.
+ * @param setMethod
+ * the setter method.
*/
- public MethodProperty(
- Class type,
- Object instance,
- Method getMethod,
- Method setMethod) {
- this(type, instance, getMethod, setMethod, new Object[] {
- }, new Object[] { null }, 0);
+ public MethodProperty(Class type, Object instance, Method getMethod,
+ Method setMethod) {
+ this(type, instance, getMethod, setMethod, new Object[] {},
+ new Object[] { null }, 0);
}
- /**
+ /**
* <p>
- * Creates a new instance of <code>MethodProperty</code> from named getter and
- * setter methods and argument lists. The getter method of a
- * <code>MethodProperty</code> instantiated with this constructor will be called with
- * the getArgs as arguments. The setArgs will be used
- * as the arguments for the setter method, though the argument indexed
- * by the setArgumentIndex will be replaced with the argument
- * passed to the {@link #setValue(Object newValue)} method.
+ * Creates a new instance of <code>MethodProperty</code> from named getter
+ * and setter methods and argument lists. The getter method of a
+ * <code>MethodProperty</code> instantiated with this constructor will be
+ * called with the getArgs as arguments. The setArgs will be used as the
+ * arguments for the setter method, though the argument indexed by the
+ * setArgumentIndex will be replaced with the argument passed to the
+ * {@link #setValue(Object newValue)} method.
* </p>
*
* <p>
* For example, if the <code>setArgs</code> contains <code>A</code>,
* <code>B</code> and <code>C</code>, and <code>setArgumentIndex =
- * 1</code>, the call <code>methodProperty.setValue(X)</code> would
- * result in the setter method to be called with the parameter set of
+ * 1</code>,
+ * the call <code>methodProperty.setValue(X)</code> would result in the
+ * setter method to be called with the parameter set of
* <code>{A, X, C}</code>
* </p>
- *
- * @param type the type of the property.
- * @param instance the object that includes the property.
- * @param getMethodName the name of the getter method.
- * @param setMethodName the name of the setter method.
- * @param getArgs the fixed argument list to be passed to the getter method.
- * @param setArgs the fixed argument list to be passed to the setter method.
- * @param setArgumentIndex the index of the argument in
- * <code>setArgs</code> to be replaced with <code>newValue</code> when
- * {@link #setValue(Object newValue)} is called.
+ *
+ * @param type
+ * the type of the property.
+ * @param instance
+ * the object that includes the property.
+ * @param getMethodName
+ * the name of the getter method.
+ * @param setMethodName
+ * the name of the setter method.
+ * @param getArgs
+ * the fixed argument list to be passed to the getter method.
+ * @param setArgs
+ * the fixed argument list to be passed to the setter method.
+ * @param setArgumentIndex
+ * the index of the argument in <code>setArgs</code> to be
+ * replaced with <code>newValue</code> when
+ * {@link #setValue(Object newValue)} is called.
*/
- public MethodProperty(
- Class type,
- Object instance,
- String getMethodName,
- String setMethodName,
- Object[] getArgs,
- Object[] setArgs,
- int setArgumentIndex) {
+ public MethodProperty(Class type, Object instance, String getMethodName,
+ String setMethodName, Object[] getArgs, Object[] setArgs,
+ int setArgumentIndex) {
// Check the setargs and setargs index
if (setMethodName != null && setArgs == null)
throw new IndexOutOfBoundsException("The setArgs can not be null");
- if (setMethodName != null && (setArgumentIndex < 0 || setArgumentIndex >= setArgs.length))
- throw new IndexOutOfBoundsException("The setArgumentIndex must be >= 0 and < setArgs.length");
+ if (setMethodName != null
+ && (setArgumentIndex < 0 || setArgumentIndex >= setArgs.length))
+ throw new IndexOutOfBoundsException(
+ "The setArgumentIndex must be >= 0 and < setArgs.length");
// Set type
this.type = type;
- // Find set and get -methods
+ // Find set and get -methods
Method[] m = instance.getClass().getMethods();
// Finds get method
@@ -336,7 +337,7 @@ public class MethodProperty implements Property {
int j = 0;
while (j < c.length) {
if (getArgs[j] != null
- && !c[j].isAssignableFrom(getArgs[j].getClass())) {
+ && !c[j].isAssignableFrom(getArgs[j].getClass())) {
// parameter type does not match, try next method
break;
@@ -348,9 +349,8 @@ public class MethodProperty implements Property {
// all paramteters matched
if (found == true) {
throw new MethodProperty.MethodException(
- "Could not uniquely identify "
- + getMethodName
- + "-method");
+ "Could not uniquely identify " + getMethodName
+ + "-method");
} else {
found = true;
getMethod = m[i];
@@ -358,8 +358,8 @@ public class MethodProperty implements Property {
}
}
if (found != true) {
- throw new MethodProperty.MethodException(
- "Could not find " + getMethodName + "-method");
+ throw new MethodProperty.MethodException("Could not find "
+ + getMethodName + "-method");
}
// Finds set method
@@ -386,7 +386,7 @@ public class MethodProperty implements Property {
int j = 0;
while (j < c.length) {
if (setArgs[j] != null
- && !c[j].isAssignableFrom(setArgs[j].getClass())) {
+ && !c[j].isAssignableFrom(setArgs[j].getClass())) {
// parameter type does not match, try next method
break;
@@ -402,9 +402,8 @@ public class MethodProperty implements Property {
// all parameters match
if (found == true) {
throw new MethodProperty.MethodException(
- "Could not identify unique "
- + setMethodName
- + "-method");
+ "Could not identify unique " + setMethodName
+ + "-method");
} else {
found = true;
setMethod = m[i];
@@ -412,8 +411,8 @@ public class MethodProperty implements Property {
}
}
if (found != true) {
- throw new MethodProperty.MethodException(
- "Could not identify " + setMethodName + "-method");
+ throw new MethodProperty.MethodException("Could not identify "
+ + setMethodName + "-method");
}
}
@@ -442,45 +441,49 @@ public class MethodProperty implements Property {
this.instance = instance;
}
- /**
+ /**
* <p>
- * Creates a new instance of <code>MethodProperty</code> from the getter and
- * setter methods, and argument lists.
+ * Creates a new instance of <code>MethodProperty</code> from the getter
+ * and setter methods, and argument lists.
* </p>
* <p>
- * This constructor behaves exactly like {@link #MethodProperty(Class type, Object instance, String
- * getMethodName, String setMethodName, Object [] getArgs, Object []
- * setArgs, int setArgumentIndex)} except that instead of names of
- * the getter and setter methods this constructor is given the actual
- * methods themselves.
+ * This constructor behaves exactly like
+ * {@link #MethodProperty(Class type, Object instance, String getMethodName,
+ * String setMethodName, Object [] getArgs, Object [] setArgs, int
+ * setArgumentIndex)} except that instead of names of the getter and setter
+ * methods this constructor is given the actual methods themselves.
* </p>
- *
- * @param type the type of the property.
- * @param instance the object that includes the property.
- * @param getMethod the getter method.
- * @param setMethod the setter method.
- * @param getArgs the fixed argument list to be passed to the getter method.
- * @param setArgs the fixed argument list to be passed to the setter method.
- * @param setArgumentIndex the index of the argument in
- * <code>setArgs</code> to be replaced with <code>newValue</code> when
- * {@link #setValue(Object newValue)} is called.
+ *
+ * @param type
+ * the type of the property.
+ * @param instance
+ * the object that includes the property.
+ * @param getMethod
+ * the getter method.
+ * @param setMethod
+ * the setter method.
+ * @param getArgs
+ * the fixed argument list to be passed to the getter method.
+ * @param setArgs
+ * the fixed argument list to be passed to the setter method.
+ * @param setArgumentIndex
+ * the index of the argument in <code>setArgs</code> to be
+ * replaced with <code>newValue</code> when
+ * {@link #setValue(Object newValue)} is called.
*/
- public MethodProperty(
- Class type,
- Object instance,
- Method getMethod,
- Method setMethod,
- Object[] getArgs,
- Object[] setArgs,
- int setArgumentIndex) {
+ public MethodProperty(Class type, Object instance, Method getMethod,
+ Method setMethod, Object[] getArgs, Object[] setArgs,
+ int setArgumentIndex) {
if (getMethod == null) {
throw new MethodProperty.MethodException(
- "Property GET-method cannot not be null: "+type);
+ "Property GET-method cannot not be null: " + type);
}
- if (setMethod != null && ( setArgumentIndex < 0 || setArgumentIndex >= setArgs.length))
- throw new IndexOutOfBoundsException("The setArgumentIndex must be >= 0 and < setArgs.length");
+ if (setMethod != null
+ && (setArgumentIndex < 0 || setArgumentIndex >= setArgs.length))
+ throw new IndexOutOfBoundsException(
+ "The setArgumentIndex must be >= 0 and < setArgs.length");
// Gets the return type from get method
if (type.isPrimitive()) {
@@ -510,12 +513,12 @@ public class MethodProperty implements Property {
this.type = type;
}
- /**
- * Returns the type of the Property. The methods <code>getValue</code>
- * and <code>setValue</code> must be compatible with this type: one
- * must be able to safely cast the value returned from
- * <code>getValue</code> to the given type and pass any variable
- * assignable to this type as an argument to <code>setValue</code>.
+ /**
+ * Returns the type of the Property. The methods <code>getValue</code> and
+ * <code>setValue</code> must be compatible with this type: one must be
+ * able to safely cast the value returned from <code>getValue</code> to
+ * the given type and pass any variable assignable to this type as an
+ * argument to <code>setValue</code>.
*
* @return type of the Property
*/
@@ -523,23 +526,22 @@ public class MethodProperty implements Property {
return type;
}
- /**
- * Tests if the object is in read-only mode. In read-only mode calls
- * to <code>setValue</code> will throw <code>ReadOnlyException</code>
- * and will not modify the value of the Property.
- *
+ /**
+ * Tests if the object is in read-only mode. In read-only mode calls to
+ * <code>setValue</code> will throw <code>ReadOnlyException</code> and
+ * will not modify the value of the Property.
+ *
* @return <code>true</code> if the object is in read-only mode,
- * <code>false</code> if it's not
+ * <code>false</code> if it's not
*/
public boolean isReadOnly() {
return readOnly;
}
- /**
- * Gets the value stored in the Property. The value is resolved by
- * calling the specified getter method with the argument specified
- * at instantiation.
- *
+ /**
+ * Gets the value stored in the Property. The value is resolved by calling
+ * the specified getter method with the argument specified at instantiation.
+ *
* @return the value of the Property
*/
public Object getValue() {
@@ -550,11 +552,10 @@ public class MethodProperty implements Property {
}
}
- /**
- * Returns the value of the <code>MethodProperty</code> in human readable textual
- * format. The return value should be assignable to the
- * <code>setValue</code> method if the Property is not in read-only
- * mode.
+ /**
+ * Returns the value of the <code>MethodProperty</code> in human readable
+ * textual format. The return value should be assignable to the
+ * <code>setValue</code> method if the Property is not in read-only mode.
*
* @return String representation of the value stored in the Property
*/
@@ -565,21 +566,22 @@ public class MethodProperty implements Property {
return value.toString();
}
- /**
+ /**
* <p>
* Sets the setter method and getter method argument lists.
* </p>
- *
- * @param getArgs the fixed argument list to be passed to the getter method.
- * @param setArgs the fixed argument list to be passed to the setter method.
- * @param setArgumentIndex the index of the argument in
- * <code>setArgs</code> to be replaced with <code>newValue</code> when
- * {@link #setValue(Object newValue)} is called.
+ *
+ * @param getArgs
+ * the fixed argument list to be passed to the getter method.
+ * @param setArgs
+ * the fixed argument list to be passed to the setter method.
+ * @param setArgumentIndex
+ * the index of the argument in <code>setArgs</code> to be
+ * replaced with <code>newValue</code> when
+ * {@link #setValue(Object newValue)} is called.
*/
- public void setArguments(
- Object[] getArgs,
- Object[] setArgs,
- int setArgumentIndex) {
+ public void setArguments(Object[] getArgs, Object[] setArgs,
+ int setArgumentIndex) {
this.getArgs = new Object[getArgs.length];
for (int i = 0; i < getArgs.length; i++)
this.getArgs[i] = getArgs[i];
@@ -589,22 +591,23 @@ public class MethodProperty implements Property {
this.setArgumentIndex = setArgumentIndex;
}
- /**
+ /**
* Sets the value of the property. This method supports setting from
* <code>String</code>s if either <code>String</code> is directly
* assignable to property type, or the type class contains a string
* constructor.
- *
- * @param newValue the New value of the property.
+ *
+ * @param newValue
+ * the New value of the property.
* @throws <code>Property.ReadOnlyException</code> if the object is in
- * read-only mode.
- * @throws <code>Property.ConversionException</code> if
- * <code>newValue</code> can't be converted into the Property's native
- * type directly or through <code>String</code>.
+ * read-only mode.
+ * @throws <code>Property.ConversionException</code> if <code>newValue</code>
+ * can't be converted into the Property's native type directly
+ * or through <code>String</code>.
* @see #invokeSetMethod(Object)
*/
- public void setValue(Object newValue)
- throws Property.ReadOnlyException, Property.ConversionException {
+ public void setValue(Object newValue) throws Property.ReadOnlyException,
+ Property.ConversionException {
// Checks the mode
if (isReadOnly())
@@ -621,10 +624,11 @@ public class MethodProperty implements Property {
try {
// Gets the string constructor
- Constructor constr =
- getType().getConstructor(new Class[] { String.class });
+ Constructor constr = getType().getConstructor(
+ new Class[] { String.class });
- value = constr.newInstance(new Object[] { newValue.toString()});
+ value = constr
+ .newInstance(new Object[] { newValue.toString() });
} catch (java.lang.Exception e) {
throw new Property.ConversionException(e);
@@ -635,10 +639,11 @@ public class MethodProperty implements Property {
}
}
- /**
+ /**
* Internal method to actually call the setter method of the wrapped
* property.
- * @param value
+ *
+ * @param value
*/
private void invokeSetMethod(Object value) {
@@ -662,10 +667,11 @@ public class MethodProperty implements Property {
}
}
- /**
+ /**
* Sets the Property's read-only mode to the specified status.
*
- * @param newStatus the new read-only status of the Property.
+ * @param newStatus
+ * the new read-only status of the Property.
*/
public void setReadOnly(boolean newStatus) {
boolean prevStatus = readOnly;
@@ -677,44 +683,50 @@ public class MethodProperty implements Property {
fireReadOnlyStatusChange();
}
- /**
- * <code>Exception</code> object that signals that there were
- * problems calling or finding the specified getter or setter methods
- * of the property.
+ /**
+ * <code>Exception</code> object that signals that there were problems
+ * calling or finding the specified getter or setter methods of the
+ * property.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class MethodException extends RuntimeException {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3690473623827855153L;
- /**
- * Cause of the method exception
- */
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3690473623827855153L;
+
+ /**
+ * Cause of the method exception
+ */
private Throwable cause;
- /**
- * Constructs a new <code>MethodException</code> with the
- * specified detail message.
+ /**
+ * Constructs a new <code>MethodException</code> with the specified
+ * detail message.
*
- * @param msg the detail message.
+ * @param msg
+ * the detail message.
*/
public MethodException(String msg) {
super(msg);
}
- /**
+ /**
* Constructs a new <code>MethodException</code> from another
* exception.
*
- * @param cause the cause of the exception.
+ * @param cause
+ * the cause of the exception.
*/
public MethodException(Throwable cause) {
this.cause = cause;
}
+
/**
* @see java.lang.Throwable#getCause()
*/
@@ -722,8 +734,8 @@ public class MethodProperty implements Property {
return cause;
}
- /**
- * Gets the method property this exception originates from.
+ /**
+ * Gets the method property this exception originates from.
*/
public MethodProperty getMethodProperty() {
return MethodProperty.this;
@@ -732,32 +744,34 @@ public class MethodProperty implements Property {
/* Events *************************************************************** */
- /**
+ /**
* An <code>Event</code> object specifying the Property whose read-only
* status has been changed.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
- private class ReadOnlyStatusChangeEvent
- extends java.util.EventObject
- implements Property.ReadOnlyStatusChangeEvent {
+ private class ReadOnlyStatusChangeEvent extends java.util.EventObject
+ implements Property.ReadOnlyStatusChangeEvent {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3258129163305955896L;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3258129163305955896L;
- /**
- * Constructs a new read-only status change event for this object.
+ /**
+ * Constructs a new read-only status change event for this object.
*
- * @param source source object of the event.
+ * @param source
+ * source object of the event.
*/
protected ReadOnlyStatusChangeEvent(MethodProperty source) {
super(source);
}
- /**
+ /**
* Gets the Property whose read-only state has changed.
*
* @return source Property of the event.
@@ -768,10 +782,11 @@ public class MethodProperty implements Property {
}
- /**
+ /**
* Registers a new read-only status change listener for this Property.
*
- * @param listener the new Listener to be registered.
+ * @param listener
+ * the new Listener to be registered.
*/
public void addListener(Property.ReadOnlyStatusChangeListener listener) {
if (readOnlyStatusChangeListeners == null)
@@ -779,32 +794,28 @@ public class MethodProperty implements Property {
readOnlyStatusChangeListeners.add(listener);
}
- /**
+ /**
* Removes a previously registered read-only status change listener.
*
- * @param listener the listener to be removed.
+ * @param listener
+ * the listener to be removed.
*/
- public void removeListener(
- Property.ReadOnlyStatusChangeListener listener) {
+ public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
if (readOnlyStatusChangeListeners != null)
readOnlyStatusChangeListeners.remove(listener);
}
- /**
+ /**
* Sends a read only status change event to all registered listeners.
*/
private void fireReadOnlyStatusChange() {
if (readOnlyStatusChangeListeners != null) {
Object[] l = readOnlyStatusChangeListeners.toArray();
- Property.ReadOnlyStatusChangeEvent event =
- new MethodProperty.ReadOnlyStatusChangeEvent(this);
+ Property.ReadOnlyStatusChangeEvent event = new MethodProperty.ReadOnlyStatusChangeEvent(
+ this);
for (int i = 0; i < l.length; i++)
- (
- (
- Property
- .ReadOnlyStatusChangeListener) l[i])
- .readOnlyStatusChange(
- event);
+ ((Property.ReadOnlyStatusChangeListener) l[i])
+ .readOnlyStatusChange(event);
}
}
diff --git a/src/com/itmill/toolkit/data/util/ObjectProperty.java b/src/com/itmill/toolkit/data/util/ObjectProperty.java
index 21a7669bf6..4f20dc230f 100644
--- a/src/com/itmill/toolkit/data/util/ObjectProperty.java
+++ b/src/com/itmill/toolkit/data/util/ObjectProperty.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -33,324 +33,343 @@ import com.itmill.toolkit.data.Property;
import java.lang.reflect.Constructor;
import java.util.LinkedList;
-/**
+/**
* A simple data object containing one typed value. This class is a
* straightforward implementation of the the
* {@link com.itmill.toolkit.data.Property} interface.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class ObjectProperty implements Property, Property.ValueChangeNotifier,
-Property.ReadOnlyStatusChangeNotifier {
-
- /**
- * A boolean value storing the Property's read-only status
- * information.
- */
- private boolean readOnly = false;
-
- /**
- * The value contained by the Property.
- */
- private Object value;
-
- /**
- * Data type of the Property's value.
- */
- private Class type;
-
- /**
- * Internal list of registered value change listeners.
- */
- private LinkedList valueChangeListeners = null;
-
- /**
- * Internal list of registered read-only status change listeners.
- */
- private LinkedList readOnlyStatusChangeListeners = null;
-
- /**
- * Creates a new instance of ObjectProperty with the given value.
- * The type of the property is automatically initialized to be
- * the type of the given value.
- *
- * @param value the Initial value of the Property.
- */
- public ObjectProperty(Object value) {
- this(value,value.getClass());
- }
-
- /**
- * Creates a new instance of ObjectProperty with the given value and
- * type.
- *
- * @param value the Initial value of the Property.
- * @param type the type of the value. The value must be assignable to
- * given type.
- */
- public ObjectProperty(Object value, Class type) {
-
- // Set the values
- this.type = type;
- setValue(value);
- }
-
- /**
- * Creates a new instance of ObjectProperty with the given value, type
- * and read-only mode status.
- *
- * @param value the Initial value of the property.
- * @param type the type of the value. <code>value</code> must be
- * assignable to this type.
- * @param readOnly Sets the read-only mode.
- */
- public ObjectProperty(Object value, Class type, boolean readOnly) {
- this(value,type);
- setReadOnly(readOnly);
- }
-
- /**
- * Returns the type of the ObjectProperty. The methods
- * <code>getValue</code> and <code>setValue</code> must be compatible
- * with this type: one must be able to safely cast the value returned
- * from <code>getValue</code> to the given type and pass any variable
- * assignable to this type as an argument to <code>setValue</code>.
- *
- * @return type of the Property
- */
- public final Class getType() {
- return type;
- }
-
- /**
- * Gets the value stored in the Property.
- *
- * @return the value stored in the Property
- */
- public Object getValue() {
- return value;
- }
-
- /**
- * Returns the value of the ObjectProperty in human readable textual
- * format. The return value should be assignable to the
- * <code>setValue</code> method if the Property is not in read-only
- * mode.
- *
- * @return <code>String</code> representation of the value stored in the
- * ObjectProperty
- */
- public String toString() {
- Object value = getValue();
- if (value != null)
- return value.toString();
- else
- return null;
- }
-
- /**
- * Tests if the Property is in read-only mode. In read-only mode calls
- * to the method <code>setValue</code> will throw
- * <code>ReadOnlyException</code>s and will not modify the value of the
- * Property.
- *
- * @return <code>true</code> if the Property is in read-only mode,
- * <code>false</code> if it's not
- */
- public boolean isReadOnly() {
- return readOnly;
- }
-
- /**
- * Sets the Property's read-only mode to the specified status.
- *
- * @param newStatus the new read-only status of the Property.
- */
- public void setReadOnly(boolean newStatus) {
- if (newStatus != readOnly) {
- readOnly = newStatus;
- fireReadOnlyStatusChange();
- }
- }
-
- /**
- * Sets the value of the property. This method supports setting from
- * <code>String</code> if either <code>String</code> is directly
- * assignable to property type, or the type class contains a string
- * constructor.
- *
- * @param newValue the New value of the property.
- * @throws <code>Property.ReadOnlyException</code> if the object is in
- * read-only mode
- * @throws <code>Property.ConversionException</code> if the
- * newValue can't be converted into the Property's native
- * type directly or through <code>String</code>
- */
- public void setValue(Object newValue)
- throws Property.ReadOnlyException, Property.ConversionException {
-
- // Checks the mode
- if (isReadOnly()) throw new Property.ReadOnlyException();
-
- // Tries to assign the compatible value directly
- if (newValue == null || type.isAssignableFrom(newValue.getClass()))
- value = newValue;
-
- // Otherwise try to convert the value trough string constructor
- else try {
-
- // Gets the string constructor
- 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) {
- throw new Property.ConversionException(e);
- }
-
- fireValueChange();
- }
-
- /* Events *************************************************************** */
-
- /**
- * An <code>Event</code> object specifying the ObjectProperty whose value
- * has changed.
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
- private class ValueChangeEvent extends java.util.EventObject
- implements Property.ValueChangeEvent {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3256718468479725873L;
-
- /**
- * Constructs a new value change event for this object.
- *
- * @param source the source object of the event.
- */
- protected ValueChangeEvent(ObjectProperty source) {
- super(source);
- }
-
- /**
- * Gets the Property whose read-only state has changed.
- *
- * @return source the Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
- }
-
- /**
- * An <code>Event</code> object specifying the Property whose read-only
- * status has been changed.
- * @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
+ Property.ReadOnlyStatusChangeNotifier {
+
+ /**
+ * A boolean value storing the Property's read-only status information.
+ */
+ private boolean readOnly = false;
+
+ /**
+ * The value contained by the Property.
+ */
+ private Object value;
+
+ /**
+ * Data type of the Property's value.
+ */
+ private Class type;
+
+ /**
+ * Internal list of registered value change listeners.
+ */
+ private LinkedList valueChangeListeners = null;
+
+ /**
+ * Internal list of registered read-only status change listeners.
+ */
+ private LinkedList readOnlyStatusChangeListeners = null;
+
+ /**
+ * Creates a new instance of ObjectProperty with the given value. The type
+ * of the property is automatically initialized to be the type of the given
+ * value.
+ *
+ * @param value
+ * the Initial value of the Property.
+ */
+ public ObjectProperty(Object value) {
+ this(value, value.getClass());
+ }
+
+ /**
+ * Creates a new instance of ObjectProperty with the given value and type.
+ *
+ * @param value
+ * the Initial value of the Property.
+ * @param type
+ * the type of the value. The value must be assignable to given
+ * type.
+ */
+ public ObjectProperty(Object value, Class type) {
+
+ // Set the values
+ this.type = type;
+ setValue(value);
+ }
+
+ /**
+ * Creates a new instance of ObjectProperty with the given value, type and
+ * read-only mode status.
+ *
+ * @param value
+ * the Initial value of the property.
+ * @param type
+ * the type of the value. <code>value</code> must be assignable
+ * to this type.
+ * @param readOnly
+ * Sets the read-only mode.
+ */
+ public ObjectProperty(Object value, Class type, boolean readOnly) {
+ this(value, type);
+ setReadOnly(readOnly);
+ }
+
+ /**
+ * Returns the type of the ObjectProperty. The methods <code>getValue</code>
+ * and <code>setValue</code> must be compatible with this type: one must
+ * be able to safely cast the value returned from <code>getValue</code> to
+ * the given type and pass any variable assignable to this type as an
+ * argument to <code>setValue</code>.
+ *
+ * @return type of the Property
+ */
+ public final Class getType() {
+ return type;
+ }
+
+ /**
+ * Gets the value stored in the Property.
+ *
+ * @return the value stored in the Property
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * Returns the value of the ObjectProperty in human readable textual format.
+ * The return value should be assignable to the <code>setValue</code>
+ * method if the Property is not in read-only mode.
+ *
+ * @return <code>String</code> representation of the value stored in the
+ * ObjectProperty
+ */
+ public String toString() {
+ Object value = getValue();
+ if (value != null)
+ return value.toString();
+ else
+ return null;
+ }
+
+ /**
+ * Tests if the Property is in read-only mode. In read-only mode calls to
+ * the method <code>setValue</code> will throw
+ * <code>ReadOnlyException</code>s and will not modify the value of the
+ * Property.
+ *
+ * @return <code>true</code> if the Property is in read-only mode,
+ * <code>false</code> if it's not
+ */
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ /**
+ * Sets the Property's read-only mode to the specified status.
+ *
+ * @param newStatus
+ * the new read-only status of the Property.
+ */
+ public void setReadOnly(boolean newStatus) {
+ if (newStatus != readOnly) {
+ readOnly = newStatus;
+ fireReadOnlyStatusChange();
+ }
+ }
+
+ /**
+ * Sets the value of the property. This method supports setting from
+ * <code>String</code> if either <code>String</code> is directly
+ * assignable to property type, or the type class contains a string
+ * constructor.
+ *
+ * @param newValue
+ * the New value of the property.
+ * @throws <code>Property.ReadOnlyException</code> if the object is in
+ * read-only mode
+ * @throws <code>Property.ConversionException</code> if the newValue can't be
+ * converted into the Property's native type directly or through
+ * <code>String</code>
+ */
+ public void setValue(Object newValue) throws Property.ReadOnlyException,
+ Property.ConversionException {
+
+ // Checks the mode
+ if (isReadOnly())
+ throw new Property.ReadOnlyException();
+
+ // Tries to assign the compatible value directly
+ if (newValue == null || type.isAssignableFrom(newValue.getClass()))
+ value = newValue;
+
+ // Otherwise try to convert the value trough string constructor
+ else
+ try {
+
+ // Gets the string constructor
+ 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) {
+ throw new Property.ConversionException(e);
+ }
+
+ fireValueChange();
+ }
+
+ /* Events *************************************************************** */
+
+ /**
+ * An <code>Event</code> object specifying the ObjectProperty whose value
+ * has changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ private class ValueChangeEvent extends java.util.EventObject implements
+ Property.ValueChangeEvent {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3256718468479725873L;
+
+ /**
+ * Constructs a new value change event for this object.
+ *
+ * @param source
+ * the source object of the event.
+ */
+ protected ValueChangeEvent(ObjectProperty source) {
+ super(source);
+ }
+
+ /**
+ * Gets the Property whose read-only state has changed.
+ *
+ * @return source the Property of the event.
+ */
+ public Property getProperty() {
+ return (Property) getSource();
+ }
+ }
+
+ /**
+ * An <code>Event</code> object specifying the Property whose read-only
+ * status has been changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
private class ReadOnlyStatusChangeEvent extends java.util.EventObject
- implements Property.ReadOnlyStatusChangeEvent {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3907208273529616696L;
-
- /**
- * Constructs a new read-only status change event for this object.
- *
- * @param source source object of the event
- */
- protected ReadOnlyStatusChangeEvent(ObjectProperty source) {
- super(source);
- }
-
- /**
- * Gets the Property whose read-only state has changed.
- *
- * @return source Property of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
- }
-
- /**
- * Removes a previously registered value change listener.
- *
- * @param listener the listener to be removed.
- */
- public void removeListener(Property.ValueChangeListener listener) {
- if (valueChangeListeners != null)
- valueChangeListeners.remove(listener);
- }
-
- /**
- * Registers a new value change listener for this ObjectProperty.
- *
- * @param listener the new Listener to be registered
- */
- public void addListener(Property.ValueChangeListener listener) {
- if (valueChangeListeners == null)
- valueChangeListeners = new LinkedList();
- valueChangeListeners.add(listener);
- }
-
- /**
- * Registers a new read-only status change listener for this Property.
- *
- * @param listener the new Listener to be registered
- */
- public void addListener(Property.ReadOnlyStatusChangeListener listener) {
- if (readOnlyStatusChangeListeners == null)
- readOnlyStatusChangeListeners = new LinkedList();
- readOnlyStatusChangeListeners.add(listener);
- }
-
- /**
- * Removes a previously registered read-only status change listener.
- *
- * @param listener the listener to be removed.
- */
- public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
- if (readOnlyStatusChangeListeners != null)
- readOnlyStatusChangeListeners.remove(listener);
- }
-
- /**
- * Sends a value change event to all registered listeners.
- */
- private void fireValueChange() {
- if (valueChangeListeners != null) {
- Object[] l = valueChangeListeners.toArray();
- Property.ValueChangeEvent event =
- new ObjectProperty.ValueChangeEvent(this);
- for (int i=0; i<l.length; i++)
- ((Property.ValueChangeListener)l[i]).valueChange(event);
- }
- }
-
- /**
- * Sends a read only status change event to all registered listeners.
- */
- private void fireReadOnlyStatusChange() {
- if (readOnlyStatusChangeListeners != null) {
- Object[] l = readOnlyStatusChangeListeners.toArray();
- Property.ReadOnlyStatusChangeEvent event =
- new ObjectProperty.ReadOnlyStatusChangeEvent(this);
- for (int i=0; i<l.length; i++)
- ((Property.ReadOnlyStatusChangeListener)l[i]).
- readOnlyStatusChange(event);
- }
- }
+ implements Property.ReadOnlyStatusChangeEvent {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3907208273529616696L;
+
+ /**
+ * Constructs a new read-only status change event for this object.
+ *
+ * @param source
+ * source object of the event
+ */
+ protected ReadOnlyStatusChangeEvent(ObjectProperty source) {
+ super(source);
+ }
+
+ /**
+ * Gets the Property whose read-only state has changed.
+ *
+ * @return source Property of the event.
+ */
+ public Property getProperty() {
+ return (Property) getSource();
+ }
+ }
+
+ /**
+ * Removes a previously registered value change listener.
+ *
+ * @param listener
+ * the listener to be removed.
+ */
+ public void removeListener(Property.ValueChangeListener listener) {
+ if (valueChangeListeners != null)
+ valueChangeListeners.remove(listener);
+ }
+
+ /**
+ * Registers a new value change listener for this ObjectProperty.
+ *
+ * @param listener
+ * the new Listener to be registered
+ */
+ public void addListener(Property.ValueChangeListener listener) {
+ if (valueChangeListeners == null)
+ valueChangeListeners = new LinkedList();
+ valueChangeListeners.add(listener);
+ }
+
+ /**
+ * Registers a new read-only status change listener for this Property.
+ *
+ * @param listener
+ * the new Listener to be registered
+ */
+ public void addListener(Property.ReadOnlyStatusChangeListener listener) {
+ if (readOnlyStatusChangeListeners == null)
+ readOnlyStatusChangeListeners = new LinkedList();
+ readOnlyStatusChangeListeners.add(listener);
+ }
+
+ /**
+ * Removes a previously registered read-only status change listener.
+ *
+ * @param listener
+ * the listener to be removed.
+ */
+ public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
+ if (readOnlyStatusChangeListeners != null)
+ readOnlyStatusChangeListeners.remove(listener);
+ }
+
+ /**
+ * Sends a value change event to all registered listeners.
+ */
+ private void fireValueChange() {
+ if (valueChangeListeners != null) {
+ Object[] l = valueChangeListeners.toArray();
+ Property.ValueChangeEvent event = new ObjectProperty.ValueChangeEvent(
+ this);
+ for (int i = 0; i < l.length; i++)
+ ((Property.ValueChangeListener) l[i]).valueChange(event);
+ }
+ }
+
+ /**
+ * Sends a read only status change event to all registered listeners.
+ */
+ private void fireReadOnlyStatusChange() {
+ if (readOnlyStatusChangeListeners != null) {
+ Object[] l = readOnlyStatusChangeListeners.toArray();
+ Property.ReadOnlyStatusChangeEvent event = new ObjectProperty.ReadOnlyStatusChangeEvent(
+ this);
+ for (int i = 0; i < l.length; i++)
+ ((Property.ReadOnlyStatusChangeListener) l[i])
+ .readOnlyStatusChange(event);
+ }
+ }
}
diff --git a/src/com/itmill/toolkit/data/util/PropertysetItem.java b/src/com/itmill/toolkit/data/util/PropertysetItem.java
index f2fb4c9279..b8d299941e 100644
--- a/src/com/itmill/toolkit/data/util/PropertysetItem.java
+++ b/src/com/itmill/toolkit/data/util/PropertysetItem.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.util;
@@ -50,271 +50,279 @@ import com.itmill.toolkit.data.Property;
* @since 3.0
*/
public class PropertysetItem implements Item, Item.PropertySetChangeNotifier,
- Cloneable {
-
- /* Private representation of the item *********************************** */
-
- /**
- * Mapping from property id to property.
- */
- private HashMap map = new HashMap();
-
- /**
- * List of all property ids to maintain the order.
- */
- private LinkedList list = new LinkedList();
-
- /**
- * List of property set modification listeners.
- */
- private LinkedList propertySetChangeListeners = null;
-
- /* Item methods ******************************************************** */
-
- /**
- * Gets the Property corresponding to the given Property ID stored in the
- * Item. If the Item does not contain the Property, <code>null</code> is
- * returned.
- *
- * @param id
- * the identifier of the Property to get.
- * @return the Property with the given ID or <code>null</code>
- */
- public Property getItemProperty(Object id) {
- return (Property) map.get(id);
- }
-
- /**
- * Gets the collection of IDs of all Properties stored in the Item.
- *
- * @return unmodifiable collection containing IDs of the Properties stored
- * the Item
- */
- public Collection getItemPropertyIds() {
- return Collections.unmodifiableCollection(list);
- }
-
- /* Item.Managed methods ************************************************* */
-
- /**
- * Removes the Property identified by ID from the Item. This functionality
- * is optional. If the method is not implemented, the method always returns
- * <code>false</code>.
- *
- * @param id
- * the ID of the Property to be removed.
- * @return <code>true</code> if the operation succeeded <code>false</code>
- * if not
- */
- public boolean removeItemProperty(Object id) {
-
- // Cant remove missing properties
- if (map.remove(id) == null) {
- return false;
- }
- list.remove(id);
-
- // Send change events
- fireItemPropertySetChange();
-
- return true;
- }
-
- /**
- * Tries to add a new Property into the Item.
- *
- * @param id
- * the ID of the new Property.
- * @param property
- * the Property to be added and associated with the id.
- * @return <code>true</code> if the operation succeeded,
- * <code>false</code> if not
- */
- public boolean addItemProperty(Object id, Property property) {
-
- // Cant add a property twice
- if (map.containsKey(id))
- return false;
-
- // Put the property to map
- map.put(id, property);
- list.add(id);
-
- // Send event
- fireItemPropertySetChange();
-
- return true;
- }
-
- /**
- * Gets the <code>String</code> representation of the contents of the
- * Item. The format of the string is a space separated catenation of the
- * <code>String</code> representations of the Properties contained by the
- * Item.
- *
- * @return <code>String</code> representation of the Item contents
- */
- public String toString() {
- String retValue = "";
-
- for (Iterator i = getItemPropertyIds().iterator(); i.hasNext();) {
- Object propertyId = i.next();
- retValue += getItemProperty(propertyId).toString();
- if (i.hasNext())
- retValue += " ";
- }
-
- return retValue;
- }
-
- /* Notifiers ************************************************************ */
-
- /**
- * An <code>event</code> object specifying an Item whose Property set has
- * changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
- private class PropertySetChangeEvent extends EventObject implements
- Item.PropertySetChangeEvent {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3257562910590055991L;
-
- private PropertySetChangeEvent(Item source) {
- super(source);
- }
-
- /**
- * Gets the Item whose Property set has changed.
- *
- * @return source object of the event as an <code>Item</code>
- */
- public Item getItem() {
- return (Item) getSource();
- }
- }
-
- /**
- * Registers a new property set change listener for this Item.
- *
- * @param listener
- * the new Listener to be registered.
- */
- public void addListener(Item.PropertySetChangeListener listener) {
- if (propertySetChangeListeners == null)
- propertySetChangeListeners = new LinkedList();
- propertySetChangeListeners.add(listener);
- }
-
- /**
- * Removes a previously registered property set change listener.
- *
- * @param listener
- * the Listener to be removed.
- */
- public void removeListener(Item.PropertySetChangeListener listener) {
- if (propertySetChangeListeners != null)
- propertySetChangeListeners.remove(listener);
- }
-
- /**
- * Sends a Property set change event to all interested listeners.
- */
- private void fireItemPropertySetChange() {
- if (propertySetChangeListeners != null) {
- Object[] l = propertySetChangeListeners.toArray();
- Item.PropertySetChangeEvent event = new PropertysetItem.PropertySetChangeEvent(
- this);
- for (int i = 0; i < l.length; i++)
- ((Item.PropertySetChangeListener) l[i])
- .itemPropertySetChange(event);
- }
- }
-
+ Cloneable {
+
+ /* Private representation of the item *********************************** */
+
+ /**
+ * Mapping from property id to property.
+ */
+ private HashMap map = new HashMap();
+
+ /**
+ * List of all property ids to maintain the order.
+ */
+ private LinkedList list = new LinkedList();
+
+ /**
+ * List of property set modification listeners.
+ */
+ private LinkedList propertySetChangeListeners = null;
+
+ /* Item methods ******************************************************** */
+
+ /**
+ * Gets the Property corresponding to the given Property ID stored in the
+ * Item. If the Item does not contain the Property, <code>null</code> is
+ * returned.
+ *
+ * @param id
+ * the identifier of the Property to get.
+ * @return the Property with the given ID or <code>null</code>
+ */
+ public Property getItemProperty(Object id) {
+ return (Property) map.get(id);
+ }
+
+ /**
+ * Gets the collection of IDs of all Properties stored in the Item.
+ *
+ * @return unmodifiable collection containing IDs of the Properties stored
+ * the Item
+ */
+ public Collection getItemPropertyIds() {
+ return Collections.unmodifiableCollection(list);
+ }
+
+ /* Item.Managed methods ************************************************* */
+
+ /**
+ * Removes the Property identified by ID from the Item. This functionality
+ * is optional. If the method is not implemented, the method always returns
+ * <code>false</code>.
+ *
+ * @param id
+ * the ID of the Property to be removed.
+ * @return <code>true</code> if the operation succeeded <code>false</code>
+ * if not
+ */
+ public boolean removeItemProperty(Object id) {
+
+ // Cant remove missing properties
+ if (map.remove(id) == null) {
+ return false;
+ }
+ list.remove(id);
+
+ // Send change events
+ fireItemPropertySetChange();
+
+ return true;
+ }
+
+ /**
+ * Tries to add a new Property into the Item.
+ *
+ * @param id
+ * the ID of the new Property.
+ * @param property
+ * the Property to be added and associated with the id.
+ * @return <code>true</code> if the operation succeeded,
+ * <code>false</code> if not
+ */
+ public boolean addItemProperty(Object id, Property property) {
+
+ // Cant add a property twice
+ if (map.containsKey(id))
+ return false;
+
+ // Put the property to map
+ map.put(id, property);
+ list.add(id);
+
+ // Send event
+ fireItemPropertySetChange();
+
+ return true;
+ }
+
+ /**
+ * Gets the <code>String</code> representation of the contents of the
+ * Item. The format of the string is a space separated catenation of the
+ * <code>String</code> representations of the Properties contained by the
+ * Item.
+ *
+ * @return <code>String</code> representation of the Item contents
+ */
+ public String toString() {
+ String retValue = "";
+
+ for (Iterator i = getItemPropertyIds().iterator(); i.hasNext();) {
+ Object propertyId = i.next();
+ retValue += getItemProperty(propertyId).toString();
+ if (i.hasNext())
+ retValue += " ";
+ }
+
+ return retValue;
+ }
+
+ /* Notifiers ************************************************************ */
+
+ /**
+ * An <code>event</code> object specifying an Item whose Property set has
+ * changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ private class PropertySetChangeEvent extends EventObject implements
+ Item.PropertySetChangeEvent {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3257562910590055991L;
+
+ private PropertySetChangeEvent(Item source) {
+ super(source);
+ }
+
+ /**
+ * Gets the Item whose Property set has changed.
+ *
+ * @return source object of the event as an <code>Item</code>
+ */
+ public Item getItem() {
+ return (Item) getSource();
+ }
+ }
+
+ /**
+ * Registers a new property set change listener for this Item.
+ *
+ * @param listener
+ * the new Listener to be registered.
+ */
+ public void addListener(Item.PropertySetChangeListener listener) {
+ if (propertySetChangeListeners == null)
+ propertySetChangeListeners = new LinkedList();
+ propertySetChangeListeners.add(listener);
+ }
+
+ /**
+ * Removes a previously registered property set change listener.
+ *
+ * @param listener
+ * the Listener to be removed.
+ */
+ public void removeListener(Item.PropertySetChangeListener listener) {
+ if (propertySetChangeListeners != null)
+ propertySetChangeListeners.remove(listener);
+ }
+
+ /**
+ * Sends a Property set change event to all interested listeners.
+ */
+ private void fireItemPropertySetChange() {
+ if (propertySetChangeListeners != null) {
+ Object[] l = propertySetChangeListeners.toArray();
+ Item.PropertySetChangeEvent event = new PropertysetItem.PropertySetChangeEvent(
+ this);
+ for (int i = 0; i < l.length; i++)
+ ((Item.PropertySetChangeListener) l[i])
+ .itemPropertySetChange(event);
+ }
+ }
+
/**
* Creates and returns a copy of this object.
* <p>
- * The method <code>clone</code> performs a shallow copy of the <code>PropertysetItem</code>.
+ * The method <code>clone</code> performs a shallow copy of the
+ * <code>PropertysetItem</code>.
* </p>
* <p>
- * Note : All arrays are considered to implement the interface Cloneable.
- * Otherwise, this method creates a new instance of the class of this object
- * and initializes all its fields with exactly the contents of the corresponding
- * fields of this object, as if by assignment, the contents of the fields are not
- * themselves cloned. Thus, this method performs a "shallow copy" of this object,
- * not a "deep copy" operation.
+ * Note : All arrays are considered to implement the interface Cloneable.
+ * Otherwise, this method creates a new instance of the class of this object
+ * and initializes all its fields with exactly the contents of the
+ * corresponding fields of this object, as if by assignment, the contents of
+ * the fields are not themselves cloned. Thus, this method performs a
+ * "shallow copy" of this object, not a "deep copy" operation.
* </p>
+ *
* @throws CloneNotSupportedException
- * if the object's class does not support the Cloneable interface.
+ * if the object's class does not support the Cloneable
+ * interface.
*
* @see java.lang.Object#clone()
*/
- public Object clone() throws CloneNotSupportedException {
+ public Object clone() throws CloneNotSupportedException {
- PropertysetItem npsi = new PropertysetItem();
+ PropertysetItem npsi = new PropertysetItem();
- npsi.list = this.list != null ? (LinkedList) list.clone() : null;
- npsi.propertySetChangeListeners = this.propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners
- .clone()
- : null;
- npsi.map = (HashMap) this.map.clone();
+ npsi.list = this.list != null ? (LinkedList) list.clone() : null;
+ npsi.propertySetChangeListeners = this.propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners
+ .clone()
+ : null;
+ npsi.map = (HashMap) this.map.clone();
+
+ return npsi;
+ }
- return npsi;
- }
-
/**
- * Returns <code>true</code> if and only if the argument is not <code>null</code> and is a
- * Boolean object that represents the same boolean value as this object.
- * @param obj the object to compare with.
- * @return <code>true</code> if the Boolean objects represent the same value otherwise <code>false</code>.
+ * Returns <code>true</code> if and only if the argument is not
+ * <code>null</code> and is a Boolean object that represents the same
+ * boolean value as this object.
+ *
+ * @param obj
+ * the object to compare with.
+ * @return <code>true</code> if the Boolean objects represent the same
+ * value otherwise <code>false</code>.
* @see java.lang.Object#equals(java.lang.Object)
*/
- public boolean equals(Object obj) {
-
- if (obj == null || !(obj instanceof PropertysetItem))
- return false;
-
- PropertysetItem other = (PropertysetItem) obj;
-
- if (other.list != this.list) {
- if (other.list == null)
- return false;
- if (!other.list.equals(this.list))
- return false;
- }
- if (other.map != this.map) {
- if (other.map == null)
- return false;
- if (!other.map.equals(this.map))
- return false;
- }
- if (other.propertySetChangeListeners != this.propertySetChangeListeners) {
- if (other.propertySetChangeListeners == null)
- return false;
- if (!other.propertySetChangeListeners
- .equals(this.propertySetChangeListeners))
- return false;
- }
-
- return true;
- }
-
+ public boolean equals(Object obj) {
+
+ if (obj == null || !(obj instanceof PropertysetItem))
+ return false;
+
+ PropertysetItem other = (PropertysetItem) obj;
+
+ if (other.list != this.list) {
+ if (other.list == null)
+ return false;
+ if (!other.list.equals(this.list))
+ return false;
+ }
+ if (other.map != this.map) {
+ if (other.map == null)
+ return false;
+ if (!other.map.equals(this.map))
+ return false;
+ }
+ if (other.propertySetChangeListeners != this.propertySetChangeListeners) {
+ if (other.propertySetChangeListeners == null)
+ return false;
+ if (!other.propertySetChangeListeners
+ .equals(this.propertySetChangeListeners))
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Returns the hash code value for this list.
+ *
* @return the hash code value.
* @see java.lang.Object#hashCode()
*/
- public int hashCode() {
+ public int hashCode() {
- return (list == null ? 0 : list.hashCode())
- ^ (map == null ? 0 : map.hashCode())
- ^ (propertySetChangeListeners == null ? 0
- : propertySetChangeListeners.hashCode());
- }
+ return (list == null ? 0 : list.hashCode())
+ ^ (map == null ? 0 : map.hashCode())
+ ^ (propertySetChangeListeners == null ? 0
+ : propertySetChangeListeners.hashCode());
+ }
}
diff --git a/src/com/itmill/toolkit/data/validator/CompositeValidator.java b/src/com/itmill/toolkit/data/validator/CompositeValidator.java
index bbecc78e85..1a5839455e 100644
--- a/src/com/itmill/toolkit/data/validator/CompositeValidator.java
+++ b/src/com/itmill/toolkit/data/validator/CompositeValidator.java
@@ -1,31 +1,31 @@
/* *************************************************************************
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
-
+ IT Mill Toolkit
+
+ Development of Browser User Interfaces Made Easy
+
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
+
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
+
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
+
+ ********************************************************************** */
+
package com.itmill.toolkit.data.validator;
import java.util.Collection;
@@ -35,69 +35,71 @@ import java.util.LinkedList;
import com.itmill.toolkit.data.*;
-/**
- * The <code>CompositeValidator</code> allows you to chain (compose) many validators
- * to validate one field. The contained validators may be required
- * to all validate the value to validate or it may be enough that
- * one contained validator validates the value. This behaviour is
- * controlled by the modes <code>AND</code> and <code>OR</code>.
+/**
+ * The <code>CompositeValidator</code> allows you to chain (compose) many
+ * validators to validate one field. The contained validators may be required to
+ * all validate the value to validate or it may be enough that one contained
+ * validator validates the value. This behaviour is controlled by the modes
+ * <code>AND</code> and <code>OR</code>.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class CompositeValidator implements Validator {
- /**
- * The validators are combined with <code>AND</code> clause: validity of the
- * composite implies validity of the all validators it is composed of
+ /**
+ * The validators are combined with <code>AND</code> clause: validity of
+ * the composite implies validity of the all validators it is composed of
* must be valid.
*/
public static final int MODE_AND = 0;
- /**
- * The validators are combined with <code>OR</code> clause: validity of the
- * composite implies that some of validators it is composed of
- * must be valid.
+ /**
+ * The validators are combined with <code>OR</code> clause: validity of
+ * the composite implies that some of validators it is composed of must be
+ * valid.
*/
public static final int MODE_OR = 1;
- /**
- * The validators are combined with and clause: validity of the
- * composite implies validity of the all validators it is composed of
+ /**
+ * The validators are combined with and clause: validity of the composite
+ * implies validity of the all validators it is composed of
*/
public static final int MODE_DEFAULT = MODE_AND;
- /**
- * Operation mode.
+ /**
+ * Operation mode.
*/
private int mode = MODE_DEFAULT;
- /**
- * List of contained validators.
+ /**
+ * List of contained validators.
*/
private LinkedList validators = new LinkedList();
- /**
- * Error message.
+ /**
+ * Error message.
*/
private String errorMessage;
- /**
- * Construct a composite validator in <code>AND</code> mode without error message.
+ /**
+ * Construct a composite validator in <code>AND</code> mode without error
+ * message.
*/
public CompositeValidator() {
}
- /**
- * Constructs a composite validator in given mode.
+ /**
+ * Constructs a composite validator in given mode.
*/
public CompositeValidator(int mode, String errorMessage) {
setMode(mode);
setErrorMessage(errorMessage);
}
- /**
+ /**
* Validates the given value.
* <p>
* The value is valid, if:
@@ -106,84 +108,96 @@ public class CompositeValidator implements Validator {
* <li><code>MODE_OR</code>: Any of the sub-validators are valid
* </ul>
*
- * If the value is invalid, validation error is thrown. If the
- * error message is set (non-null), it is used. If the error message
- * has not been set, the first error occurred is thrown.
+ * If the value is invalid, validation error is thrown. If the error message
+ * is set (non-null), it is used. If the error message has not been set, the
+ * first error occurred is thrown.
* </p>
- * @param value the value to check.
+ *
+ * @param value
+ * the value to check.
* @throws Validator.InvalidValueException
- * if the value is not valid.
+ * if the value is not valid.
*/
public void validate(Object value) throws Validator.InvalidValueException {
switch (mode) {
- case MODE_AND :
- for (Iterator i = validators.iterator(); i.hasNext();)
+ case MODE_AND:
+ for (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();)
+ try {
((Validator) i.next()).validate(value);
+ return;
+ } catch (Validator.InvalidValueException e) {
+ if (first == null)
+ first = e;
+ }
+ if (first == null)
return;
-
- case MODE_OR :
- Validator.InvalidValueException first = null;
- for (Iterator i = validators.iterator(); i.hasNext();)
- try {
- ((Validator) i.next()).validate(value);
- return;
- } catch (Validator.InvalidValueException e) {
- if (first == null) first = e;
- }
- if (first == null) return;
- String em = getErrorMessage();
- if (em != null) throw new Validator.InvalidValueException(em);
- else throw first;
+ String em = getErrorMessage();
+ if (em != null)
+ throw new Validator.InvalidValueException(em);
+ else
+ throw first;
}
- throw new IllegalStateException("The validator is in unsupported operation mode");
+ throw new IllegalStateException(
+ "The validator is in unsupported operation mode");
}
- /**
- * Checks the validity of the the given value.
- * The value is valid, if:
+ /**
+ * Checks the validity of the the given value. The value is valid, if:
* <ul>
* <li><code>MODE_AND</code>: All of the sub-validators are valid
* <li><code>MODE_OR</code>: Any of the sub-validators are valid
* </ul>
- * @param value the value to check.
+ *
+ * @param value
+ * the value to check.
*/
public boolean isValid(Object value) {
switch (mode) {
- case MODE_AND :
- for (Iterator i = validators.iterator(); i.hasNext();) {
- Validator v = (Validator) i.next();
- if (!v.isValid(value))
- return false;
- }
- return true;
+ case MODE_AND:
+ for (Iterator i = validators.iterator(); i.hasNext();) {
+ 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();
- if (v.isValid(value))
- return true;
- }
- return false;
+ case MODE_OR:
+ for (Iterator i = validators.iterator(); i.hasNext();) {
+ Validator v = (Validator) i.next();
+ if (v.isValid(value))
+ return true;
+ }
+ return false;
}
- throw new IllegalStateException("The valitor is in unsupported operation mode");
+ throw new IllegalStateException(
+ "The valitor is in unsupported operation mode");
}
- /**
+ /**
* Gets the mode of the validator.
- * @return Operation mode of the validator:
- * <code>MODE_AND</code> or <code>MODE_OR</code>.
+ *
+ * @return Operation mode of the validator: <code>MODE_AND</code> or
+ * <code>MODE_OR</code>.
*/
public final int getMode() {
return mode;
}
- /**
+ /**
* Sets the mode of the validator. The valid modes are:
* <ul>
- * <li><code>MODE_AND</code> (default)
+ * <li><code>MODE_AND</code> (default)
* <li><code>MODE_OR</code>
* </ul>
- * @param mode the mode to set.
+ *
+ * @param mode
+ * the mode to set.
*/
public void setMode(int mode) {
if (mode != MODE_AND && mode != MODE_OR)
@@ -191,33 +205,36 @@ public class CompositeValidator implements Validator {
this.mode = mode;
}
- /**
- * Gets the error message for the composite validator.
- * If the error message is null, original error messages of the
- * sub-validators are used instead.
+ /**
+ * Gets the error message for the composite validator. If the error message
+ * is null, original error messages of the sub-validators are used instead.
*/
public String getErrorMessage() {
- if (this.errorMessage != null) return this.errorMessage;
-
+ if (this.errorMessage != null)
+ return this.errorMessage;
+
// TODO Return composite error message
-
+
return null;
}
- /**
- * Sets the error message for the composite validator.
- * If the error message is null, original error messages of the
- * sub-validators are used instead.
- * @param errorMessage the Error Message to set.
+ /**
+ * Sets the error message for the composite validator. If the error message
+ * is null, original error messages of the sub-validators are used instead.
+ *
+ * @param errorMessage
+ * the Error Message to set.
*/
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
- /**
+ /**
* Adds validator to the interface.
- * @param validator the Validator object which performs validation checks
- * on this set of data field values.
+ *
+ * @param validator
+ * the Validator object which performs validation checks on this
+ * set of data field values.
*/
public void addValidator(Validator validator) {
if (validator == null)
@@ -227,27 +244,32 @@ public class CompositeValidator implements Validator {
/**
* Removes a validator from the composite.
- * @param validator the Validator object which performs validation checks
- * on this set of data field values.
+ *
+ * @param validator
+ * the Validator object which performs validation checks on this
+ * set of data field values.
*/
public void removeValidator(Validator validator) {
validators.remove(validator);
}
- /**
- * Gets sub-validators by class.
+ /**
+ * Gets sub-validators by class.
*
- * <p>If the component contains
- * directly or recursively (it contains another composite
- * containing the validator) validators compatible with given type they
- * are returned. This only applies to <code>AND</code> mode composite
- * validators.</p>
+ * <p>
+ * If the component contains directly or recursively (it contains another
+ * composite containing the validator) validators compatible with given type
+ * they are returned. This only applies to <code>AND</code> mode composite
+ * validators.
+ * </p>
+ *
+ * <p>
+ * If the validator is in <code>OR</code> mode or does not contain any
+ * validators of given type null is returned.
+ * </p>
*
- * <p>If the validator is in <code>OR</code> mode or does not contain any
- * validators of given type null is returned. </p>
- *
- * @return Collection of validators compatible with given type that
- * must apply or null if none fould.
+ * @return Collection of validators compatible with given type that must
+ * apply or null if none fould.
*/
public Collection getSubValidators(Class validatorType) {
if (mode != MODE_AND)
@@ -259,9 +281,9 @@ public class CompositeValidator implements Validator {
if (validatorType.isAssignableFrom(v.getClass()))
found.add(v);
if (v instanceof CompositeValidator
- && ((CompositeValidator) v).getMode() == MODE_AND) {
- Collection c =
- ((CompositeValidator) v).getSubValidators(validatorType);
+ && ((CompositeValidator) v).getMode() == MODE_AND) {
+ Collection c = ((CompositeValidator) v)
+ .getSubValidators(validatorType);
if (c != null)
found.addAll(c);
}
@@ -269,5 +291,5 @@ public class CompositeValidator implements Validator {
return found.isEmpty() ? null : found;
}
-
+
}
diff --git a/src/com/itmill/toolkit/data/validator/NullValidator.java b/src/com/itmill/toolkit/data/validator/NullValidator.java
index b492d96a1a..694b6c2fa6 100644
--- a/src/com/itmill/toolkit/data/validator/NullValidator.java
+++ b/src/com/itmill/toolkit/data/validator/NullValidator.java
@@ -1,106 +1,120 @@
/* *************************************************************************
- IT Mill Toolkit
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
-
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
-
+ IT Mill Toolkit
+
+ Development of Browser User Interfaces Made Easy
+
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
+
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
+
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
+
+ ********************************************************************** */
+
package com.itmill.toolkit.data.validator;
import com.itmill.toolkit.data.*;
-
-/**
- * This validator is used for validating properties that
- * do or do not allow null values.
+/**
+ * This validator is used for validating properties that do or do not allow null
+ * values.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class NullValidator implements Validator {
private boolean allowNull;
+
private String errorMessage;
- /**
+ /**
* Creates a new NullValidator.
- * @param errorMessage the error message to display on invalidation.
- * @param allowNull Are nulls allowed?
+ *
+ * @param errorMessage
+ * the error message to display on invalidation.
+ * @param allowNull
+ * Are nulls allowed?
*/
- public NullValidator(String errorMessage,boolean allowNull) {
+ public NullValidator(String errorMessage, boolean allowNull) {
setErrorMessage(errorMessage);
setNullAllowed(allowNull);
}
- /**
+ /**
* Validates the data given in value.
- * @param value the value to validate.
- * @throws Validator.InvalidValueException if the value was invalid.
+ *
+ * @param value
+ * the value to validate.
+ * @throws Validator.InvalidValueException
+ * if the value was invalid.
*/
public void validate(Object value) throws Validator.InvalidValueException {
if ((allowNull && value != null) || (!allowNull && value == null))
throw new Validator.InvalidValueException(errorMessage);
}
- /**
+ /**
* Tests if the given value is valid.
- * @param value the value to validate.
- * @returns <code>true</code> for valid value, otherwise <code>false</code>.
+ *
+ * @param value
+ * the value to validate.
+ * @returns <code>true</code> for valid value, otherwise
+ * <code>false</code>.
*/
public boolean isValid(Object value) {
return allowNull ? value == null : value != null;
}
- /**
- * Returns <code>true</code> if nulls are allowed otherwise <code>false</code>.
+ /**
+ * Returns <code>true</code> if nulls are allowed otherwise
+ * <code>false</code>.
*/
public final boolean isNullAllowed() {
return allowNull;
}
- /**
+ /**
* Sets if nulls are to be allowed.
- * @param allowNull Do we allow nulls?
+ *
+ * @param allowNull
+ * Do we allow nulls?
*/
public void setNullAllowed(boolean allowNull) {
this.allowNull = allowNull;
}
-
- /**
- * Gets the error message that is displayed in case the
- * value is invalid.
+
+ /**
+ * Gets the error message that is displayed in case the value is invalid.
+ *
* @return the Error Message.
*/
public String getErrorMessage() {
return errorMessage;
}
- /**
- * Sets the error message to be displayed on invalid
- * value.
+ /**
+ * Sets the error message to be displayed on invalid value.
+ *
* @param errorMessage
- * the Error Message to set.
+ * the Error Message to set.
*/
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
diff --git a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java
index bfeb55b5b9..4159041e1b 100644
--- a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java
+++ b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java
@@ -1,83 +1,92 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.data.validator;
import com.itmill.toolkit.data.*;
-/**
- * This <code>StringLengthValidator</code> is used to validate the length of strings.
+/**
+ * This <code>StringLengthValidator</code> is used to validate the length of
+ * strings.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class StringLengthValidator implements Validator {
private int minLength = -1;
+
private int maxLength = -1;
+
private boolean allowNull = true;
+
private String errorMessage;
- /**
+ /**
* Creates a new StringLengthValidator with a given error message.
*
- * @param errorMessage the message to display in case the value does not validate.
+ * @param errorMessage
+ * the message to display in case the value does not validate.
*/
public StringLengthValidator(String errorMessage) {
setErrorMessage(errorMessage);
}
- /**
+ /**
* Creates a new StringLengthValidator with a given error message,
* permissable lengths and null-string allowance.
*
- * @param errorMessage the message to display in case the value does not validate.
- * @param minLength the minimum permissable length of the string.
- * @param maxLength the maximum permissable length of the string.
- * @param allowNull Are null strings permissable?
+ * @param errorMessage
+ * the message to display in case the value does not validate.
+ * @param minLength
+ * the minimum permissable length of the string.
+ * @param maxLength
+ * the maximum permissable length of the string.
+ * @param allowNull
+ * Are null strings permissable?
*/
- public StringLengthValidator(
- String errorMessage,
- int minLength,
- int maxLength,
- boolean allowNull) {
+ public StringLengthValidator(String errorMessage, int minLength,
+ int maxLength, boolean allowNull) {
this(errorMessage);
setMinLength(minLength);
setMaxLength(maxLength);
setNullAllowed(allowNull);
}
- /**
+ /**
* Validates the value.
- * @param value the value to validate.
+ *
+ * @param value
+ * the value to validate.
* @throws Validator.InvalidValueException
- * if the value was invalid.
+ * if the value was invalid.
*/
public void validate(Object value) throws Validator.InvalidValueException {
if (value == null && !allowNull)
@@ -87,13 +96,15 @@ public class StringLengthValidator implements Validator {
throw new Validator.InvalidValueException(errorMessage);
int len = s.length();
if ((minLength >= 0 && len < minLength)
- || (maxLength >= 0 && len > maxLength))
+ || (maxLength >= 0 && len > maxLength))
throw new Validator.InvalidValueException(errorMessage);
}
- /**
+ /**
* Checks if the given value is valid.
- * @param value the value to validate.
+ *
+ * @param value
+ * the value to validate.
* @return <code>true</code> for valid value, otherwise <code>false</code>.
*/
public boolean isValid(Object value) {
@@ -104,29 +115,33 @@ public class StringLengthValidator implements Validator {
return true;
int len = s.length();
if ((minLength >= 0 && len < minLength)
- || (maxLength >= 0 && len > maxLength))
+ || (maxLength >= 0 && len > maxLength))
return false;
return true;
}
- /**
+ /**
* Returns <code>true</code> if null strings are allowed.
- * @return <code>true</code> if allows null string, otherwise <code>false</code>.
+ *
+ * @return <code>true</code> if allows null string, otherwise
+ * <code>false</code>.
*/
public final boolean isNullAllowed() {
return allowNull;
}
- /**
+ /**
* Gets the maximum permissable length of the string.
+ *
* @return the maximum length of the string.
*/
public final int getMaxLength() {
return maxLength;
}
- /**
+ /**
* Gets the minimum permissable length of the string.
+ *
* @return the minimum length of the string.
*/
public final int getMinLength() {
@@ -139,10 +154,12 @@ public class StringLengthValidator implements Validator {
public void setNullAllowed(boolean allowNull) {
this.allowNull = allowNull;
}
-
- /**
+
+ /**
* Sets the maximum permissable length of the string.
- * @param maxLength the length to set.
+ *
+ * @param maxLength
+ * the length to set.
*/
public void setMaxLength(int maxLength) {
if (maxLength < -1)
@@ -150,9 +167,11 @@ public class StringLengthValidator implements Validator {
this.maxLength = maxLength;
}
- /**
+ /**
* Sets the minimum permissable length.
- * @param minLength the length to set.
+ *
+ * @param minLength
+ * the length to set.
*/
public void setMinLength(int minLength) {
if (minLength < -1)
@@ -160,20 +179,20 @@ public class StringLengthValidator implements Validator {
this.minLength = minLength;
}
- /**
- * Gets the message to be displayed in case the
- * value does not validate.
+ /**
+ * Gets the message to be displayed in case the value does not validate.
+ *
* @return the Error Message.
*/
public String getErrorMessage() {
return errorMessage;
}
- /**
- * Sets the message to be displayer in case the
- * value does not validate.
+ /**
+ * Sets the message to be displayer in case the value does not validate.
+ *
* @param errorMessage
- * the Error Message to set.
+ * the Error Message to set.
*/
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
diff --git a/src/com/itmill/toolkit/demo/Calc.java b/src/com/itmill/toolkit/demo/Calc.java
index 73f9f55273..da4c32844c 100644
--- a/src/com/itmill/toolkit/demo/Calc.java
+++ b/src/com/itmill/toolkit/demo/Calc.java
@@ -2,21 +2,25 @@ package com.itmill.toolkit.demo;
import com.itmill.toolkit.ui.*;
-/** <p>An example application implementing a simple web-based calculator
- * using IT Mill Toolkit. The application opens up a window and
- * places the needed UI components (display label, buttons etc.) on it, and
- * registers a button click listener for them.</p>
+/**
+ * <p>
+ * An example application implementing a simple web-based calculator using IT
+ * Mill Toolkit. The application opens up a window and places the needed UI
+ * components (display label, buttons etc.) on it, and registers a button click
+ * listener for them.
+ * </p>
+ *
+ * <p>
+ * When any of the buttons are pressed the application finds out which button
+ * was pressed, figures what that button does, and updates the user interface
+ * accordingly.
+ * </p>
*
- * <p>When any of the buttons are pressed the application finds out which
- * button was pressed, figures what that button does, and updates the user
- * interface accordingly.</p>
- *
* @see com.itmill.toolkit.Application
* @see com.itmill.toolkit.ui.Button.ClickListener
*/
-public class Calc
- extends com.itmill.toolkit.Application
- implements Button.ClickListener {
+public class Calc extends com.itmill.toolkit.Application implements
+ Button.ClickListener {
/** The label used as the display */
private Label display = null;
@@ -31,23 +35,28 @@ public class Calc
private String operation = "C";
/** Button captions. */
- private static String[] captions = // Captions for the buttons
- {"7","8","9","/","4","5","6","*","1","2","3","-","0","=","C","+" };
-
- /** <p>Initializes the application. This is the only method an
- * application is required to implement. It's called by the framework
- * and it should perform whatever initialization tasks the application
- * needs to perform.</p>
+ private static String[] captions = // Captions for the buttons
+ { "7", "8", "9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", "=",
+ "C", "+" };
+
+ /**
+ * <p>
+ * Initializes the application. This is the only method an application is
+ * required to implement. It's called by the framework and it should perform
+ * whatever initialization tasks the application needs to perform.
+ * </p>
*
- * <p>In this case we create the main window, the display, the grid to
- * hold the buttons, and the buttons themselves.</p>
+ * <p>
+ * In this case we create the main window, the display, the grid to hold the
+ * buttons, and the buttons themselves.
+ * </p>
*/
public void init() {
- //Create a new layout for the components used by the calculator
+ // Create a new layout for the components used by the calculator
GridLayout layout = new GridLayout(4, 5);
- //Create a new label component for displaying the result
+ // Create a new label component for displaying the result
display = new Label(Double.toString(current));
display.setCaption("Result");
@@ -62,31 +71,35 @@ public class Calc
// Create the main window with a caption and add it to the application.
addWindow(new Window("Calculator", layout));
-
- //Set the application to use Corporate -theme
+
+ // Set the application to use Corporate -theme
setTheme("corporate");
}
- /** <p>The button listener method called any time a button is pressed.
- * This method catches all button presses, figures out what the user
- * wanted the application to do, and updates the UI accordingly.</p>
+ /**
+ * <p>
+ * The button listener method called any time a button is pressed. This
+ * method catches all button presses, figures out what the user wanted the
+ * application to do, and updates the UI accordingly.
+ * </p>
*
- * <p>The button click event passed to this method contains information
- * about which button was pressed. If it was a number, the currently
- * edited number is updated. If it was something else, the requested
- * operation is performed. In either case the display label is updated
- * to include the outcome of the button click.</p>
+ * <p>
+ * The button click event passed to this method contains information about
+ * which button was pressed. If it was a number, the currently edited number
+ * is updated. If it was something else, the requested operation is
+ * performed. In either case the display label is updated to include the
+ * outcome of the button click.
+ * </p>
*
- * @param event the button click event specifying which button was
- * pressed
+ * @param event
+ * the button click event specifying which button was pressed
*/
public void buttonClick(Button.ClickEvent event) {
try {
// Number button pressed
- current =
- current * 10
+ current = current * 10
+ Double.parseDouble(event.getButton().getCaption());
display.setValue(Double.toString(current));
} catch (java.lang.NumberFormatException e) {
diff --git a/src/com/itmill/toolkit/demo/HelloWorld.java b/src/com/itmill/toolkit/demo/HelloWorld.java
index 435a56e5a0..d4ab04e486 100644
--- a/src/com/itmill/toolkit/demo/HelloWorld.java
+++ b/src/com/itmill/toolkit/demo/HelloWorld.java
@@ -2,11 +2,11 @@ package com.itmill.toolkit.demo;
import com.itmill.toolkit.ui.*;
-/** The classic "hello, world!" example for IT Mill Toolkit. The
- * class simply implements the abstract
- * {@link com.itmill.toolkit.Application#init() init()} method
- * in which it creates a Window and adds a Label to it.
- *
+/**
+ * The classic "hello, world!" example for IT Mill Toolkit. The class simply
+ * implements the abstract {@link com.itmill.toolkit.Application#init() init()}
+ * method in which it creates a Window and adds a Label to it.
+ *
* @author IT Mill Ltd.
* @see com.itmill.toolkit.Application
* @see com.itmill.toolkit.ui.Window
@@ -14,30 +14,29 @@ import com.itmill.toolkit.ui.*;
*/
public class HelloWorld extends com.itmill.toolkit.Application {
- /** The initialization method that is the only requirement for
- * inheriting the com.itmill.toolkit.service.Application class. It will
- * be automatically called by the framework when a user accesses the
- * application.
+ /**
+ * The initialization method that is the only requirement for inheriting the
+ * com.itmill.toolkit.service.Application class. It will be automatically
+ * called by the framework when a user accesses the application.
*/
- public void init() {
-
- /*
- * - 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");
- setMainWindow(main);
-
- /*
- * - Create a label with the classic text
- * - Add the label to the main window
- */
- main.addComponent(new Label("Hello World!"));
-
- /*
+ public void init() {
+
+ /*
+ * - 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");
+ setMainWindow(main);
+
+ /*
+ * - Create a label with the classic text - Add the label to the main
+ * window
+ */
+ main.addComponent(new Label("Hello World!"));
+
+ /*
* And that's it! The framework will display the main window and its
* contents when the application is accessed with the terminal.
*/
- }
+ }
}
diff --git a/src/com/itmill/toolkit/demo/KeyboardShortcut.java b/src/com/itmill/toolkit/demo/KeyboardShortcut.java
index 40b66e19b4..6798dc25fd 100644
--- a/src/com/itmill/toolkit/demo/KeyboardShortcut.java
+++ b/src/com/itmill/toolkit/demo/KeyboardShortcut.java
@@ -5,20 +5,21 @@ import com.itmill.toolkit.event.ShortcutAction;
import com.itmill.toolkit.event.Action.Handler;
import com.itmill.toolkit.ui.*;
-public class KeyboardShortcut extends com.itmill.toolkit.Application implements Handler {
- Window main;
+public class KeyboardShortcut extends com.itmill.toolkit.Application implements
+ Handler {
+ private Window main;
- Button a;
+ private Button a;
- Button b;
+ private Button b;
- Button c;
+ private Button c;
- Button close;
+ private Button close;
- Button d;
+ private Button d;
- Button e;
+ private Button e;
private AbstractField f;
@@ -101,8 +102,8 @@ public class KeyboardShortcut extends com.itmill.toolkit.Application implements
} else if (sender == e) {
actions[0] = (Action) new ShortcutAction("Button E action 2",
ShortcutAction.KeyCode.X, new int[] {
- ShortcutAction.ModifierKey.CTRL,
- ShortcutAction.ModifierKey.SHIFT});
+ ShortcutAction.ModifierKey.CTRL,
+ ShortcutAction.ModifierKey.SHIFT });
} else if (sender == a) {
actions[0] = (Action) new ShortcutAction("Button a action",
ShortcutAction.KeyCode.A,
@@ -139,6 +140,7 @@ public class KeyboardShortcut extends com.itmill.toolkit.Application implements
public void buttonCHandler() {
main.addComponent(new Label("Button C handler fired"));
}
+
public void buttonEHandler() {
main.addComponent(new Label("Button E handler fired"));
}
diff --git a/src/com/itmill/toolkit/demo/QueryContainerDemo.java b/src/com/itmill/toolkit/demo/QueryContainerDemo.java
index 51cb0c378b..c277c96878 100644
--- a/src/com/itmill/toolkit/demo/QueryContainerDemo.java
+++ b/src/com/itmill/toolkit/demo/QueryContainerDemo.java
@@ -32,6 +32,9 @@ public class QueryContainerDemo extends com.itmill.toolkit.Application
+ "actions menu.<br />Note: on Opera you use meta key "
+ "and left mouse button.";
+ private static final String TABLE_CAPTION = SampleDatabase.ROWCOUNT
+ + " dynamically loaded rows from example SQL table";
+
// Table component where SQL rows are attached (using QueryContainer)
private Table table = new Table();
@@ -68,8 +71,12 @@ public class QueryContainerDemo extends com.itmill.toolkit.Application
setTheme("corporate");
// Main window contains heading, table, select and tree
- main.addComponent(new Label("<h2>QueryContainer demo</h2>"
- + ACTION_DESCRIPTION, Label.CONTENT_XHTML));
+ main
+ .addComponent(new Label(
+ "<h2>QueryContainer demo</h2>"
+ + "<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));
main.addComponent(table);
main.addComponent(tableLastAction);
main.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
@@ -93,7 +100,7 @@ public class QueryContainerDemo extends com.itmill.toolkit.Application
*/
private void initTable() {
// init table
- table.setCaption("All rows from employee table");
+ table.setCaption(TABLE_CAPTION);
table.setPageLength(10);
table.setSelectable(true);
table.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX);
diff --git a/src/com/itmill/toolkit/demo/TableDemo.java b/src/com/itmill/toolkit/demo/TableDemo.java
index 71e255e323..6448a14557 100644
--- a/src/com/itmill/toolkit/demo/TableDemo.java
+++ b/src/com/itmill/toolkit/demo/TableDemo.java
@@ -23,11 +23,12 @@ import com.itmill.toolkit.ui.Window;
public class TableDemo extends com.itmill.toolkit.Application implements
Action.Handler {
- private static final String ACTION_DESCRIPTION = "Try right mouse button to initiate "
- + "actions menu.<br />Note: on Opera you use meta key "
+ private static final String ACTION_DESCRIPTION = "Use right mouse button to initiate "
+ + "actions menu.<br />Note: on Opera use meta key "
+ "and left mouse button.";
- private static final String TABLE_CAPTION = "All rows from employee table";
+ private static final String TABLE_CAPTION = SampleDatabase.ROWCOUNT
+ + " dynamically loaded rows from example SQL table";
private Link menuLink = new Link("Go back to menu", new ExternalResource(
"index.html"));
@@ -91,8 +92,12 @@ public class TableDemo extends com.itmill.toolkit.Application implements
sampleDatabase = new SampleDatabase();
// Main window contains heading, two buttons, table and label
- main.addComponent(new Label("<h2>Table demo</h2>" + ACTION_DESCRIPTION,
- Label.CONTENT_XHTML));
+ main
+ .addComponent(new Label(
+ "<h2>Table demo</h2>"
+ + "<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(
OrderedLayout.ORIENTATION_HORIZONTAL);
layout.addComponent(tableVisibility);
diff --git a/src/com/itmill/toolkit/event/Action.java b/src/com/itmill/toolkit/event/Action.java
index 34ccd8a192..cc1bbd723b 100644
--- a/src/com/itmill/toolkit/event/Action.java
+++ b/src/com/itmill/toolkit/event/Action.java
@@ -1,77 +1,81 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.event;
import com.itmill.toolkit.terminal.*;
-/**
- * Implements the action framework. This class contains
- * subinterfaces for action handling and listing, and for action handler
- * registrations and unregistration.
- *
+/**
+ * Implements the action framework. This class contains subinterfaces for action
+ * handling and listing, and for action handler registrations and
+ * unregistration.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Action {
/**
- * Action title.
- */
+ * Action title.
+ */
private String caption;
-
- /**
+
+ /**
* Action icon.
*/
private Resource icon = null;
- /**
+ /**
* Constructs a new action with the given caption.
*
- * @param caption the caption for the new action.
+ * @param caption
+ * the caption for the new action.
*/
public Action(String caption) {
this.caption = caption;
}
- /**
+ /**
* Constructs a new action with the given caption string and icon.
*
- * @param caption the caption for the new action.
- * @param icon the icon for the new action.
+ * @param caption
+ * the caption for the new action.
+ * @param icon
+ * the icon for the new action.
*/
public Action(String caption, Resource icon) {
this.caption = caption;
this.icon = icon;
}
- /**
+ /**
* Returns the action's caption.
*
* @return the action's caption as a <code>String</code>.
@@ -80,7 +84,7 @@ public class Action {
return caption;
}
- /**
+ /**
* Returns the action's icon.
*
* @return the action's Icon.
@@ -89,77 +93,92 @@ public class Action {
return icon;
}
- /**
+ /**
* Interface implemented by classes who wish to handle actions.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- */
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
public interface Handler {
-
- /**
+
+ /**
* Gets the list of actions applicable to this handler.
- *
- * @param target the target handler to list actions for. For item
- * containers this is the item id.
- * @param sender the party that would be sending the actions.
- * Most of this is the action container.
+ *
+ * @param target
+ * the target handler to list actions for. For item
+ * containers this is the item id.
+ * @param sender
+ * the party that would be sending the actions. Most of this
+ * is the action container.
* @return the list of Action
*/
public Action[] getActions(Object target, Object sender);
-
- /**
- * Handles an action for the given target. The handler method
- * may just discard the action if it's not suitable.
+
+ /**
+ * Handles an action for the given target. The handler method may just
+ * discard the action if it's not suitable.
*
- * @param action the action to be handled.
- * @param sender the sender of the action. This is most often the
- * action container.
- * @param target the target of the action. For item
- * containers this is the item id.
+ * @param action
+ * the action to be handled.
+ * @param sender
+ * the sender of the action. This is most often the action
+ * container.
+ * @param target
+ * the target of the action. For item containers this is the
+ * item id.
*/
public void handleAction(Action action, Object sender, Object target);
}
-
- /**
- * Interface implemented by all components where actions can be
- * registered. This means that the components lets others to register
- * as action handlers to it. When the component receives an action
- * targeting its contents it should loop all action handlers registered
- * to it and let them handle the action.
+
+ /**
+ * Interface implemented by all components where actions can be registered.
+ * This means that the components lets others to register as action handlers
+ * to it. When the component receives an action targeting its contents it
+ * should loop all action handlers registered to it and let them handle the
+ * action.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
+ * @version
+ * @VERSION@
+ * @since 3.0
*/
public interface Container {
-
- /**
+
+ /**
* Registers a new action handler for this container
*
- * @param actionHandler the new handler to be added.
+ * @param actionHandler
+ * the new handler to be added.
*/
public void addActionHandler(Action.Handler actionHandler);
- /**
- * Removes a previously registered action handler for the contents
- * of this container.
+ /**
+ * Removes a previously registered action handler for the contents of
+ * this container.
*
- * @param actionHandler the handler to be removed.
+ * @param actionHandler
+ * the handler to be removed.
*/
public void removeActionHandler(Action.Handler actionHandler);
}
-
- /**
+
+ /**
* Sets the caption.
- * @param caption the caption to set.
+ *
+ * @param caption
+ * the caption to set.
*/
public void setCaption(String caption) {
this.caption = caption;
}
- /**
+ /**
* Sets the icon.
- * @param icon the icon to set.
+ *
+ * @param icon
+ * the icon to set.
*/
public void setIcon(Resource icon) {
this.icon = icon;
diff --git a/src/com/itmill/toolkit/event/EventRouter.java b/src/com/itmill/toolkit/event/EventRouter.java
index d3c1042acd..563bb7c639 100644
--- a/src/com/itmill/toolkit/event/EventRouter.java
+++ b/src/com/itmill/toolkit/event/EventRouter.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.event;
@@ -33,141 +33,146 @@ import java.util.LinkedList;
import java.util.Iterator;
import java.lang.reflect.Method;
-/**
- * <code>EventRouter</code> class implementing the inheritable event
- * listening model. For more information on the event model see the
+/**
+ * <code>EventRouter</code> class implementing the inheritable event listening
+ * model. For more information on the event model see the
* {@link com.itmill.toolkit.event package documentation}.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class EventRouter implements MethodEventSource {
-
- /**
- * List of registered listeners.
- */
- private LinkedList listenerList = null;
-
- /* Registers a new listener with the specified activation method to
- * listen events generated by this component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+
+ /**
+ * List of registered listeners.
*/
- public void addListener(Class eventType, Object object, Method method) {
-
- if (listenerList == null)
- listenerList = new LinkedList();
-
- listenerList.add(new ListenerMethod(eventType, object, method));
- }
-
- /* Registers a new listener with the specified named activation method
- * to listen events generated by this component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ private LinkedList listenerList = null;
+
+ /*
+ * Registers a new listener with the specified activation method to listen
+ * events generated by this component. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
*/
- public void addListener(Class eventType, Object object, String methodName) {
-
- if (listenerList == null)
- listenerList = new LinkedList();
-
- listenerList.add(new ListenerMethod(eventType, object, methodName));
- }
-
- /* Removes all registered listeners matching the given parameters.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ public void addListener(Class eventType, Object object, Method method) {
+
+ if (listenerList == null)
+ listenerList = new LinkedList();
+
+ listenerList.add(new ListenerMethod(eventType, object, method));
+ }
+
+ /*
+ * Registers a new listener with the specified named activation method to
+ * listen events generated by this component. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
- public void removeListener(Class eventType, Object target) {
-
- if (listenerList != null) {
- Iterator i = listenerList.iterator();
- while (i.hasNext()) {
- try {
- ListenerMethod lm = (ListenerMethod) i.next();
- if (lm.matches(eventType,target))
- i.remove();
- } catch (java.lang.ClassCastException e) {
- // Class cast exceptions are ignored
- }
- }
- }
- }
-
- /* Removes the event listener methods matching the given given
- * paramaters.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ public void addListener(Class eventType, Object object, String methodName) {
+
+ if (listenerList == null)
+ listenerList = new LinkedList();
+
+ listenerList.add(new ListenerMethod(eventType, object, methodName));
+ }
+
+ /*
+ * Removes all registered listeners matching the given parameters. Don't add
+ * a JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
- public void removeListener(Class eventType, Object target, Method method) {
-
- if (listenerList != null) {
- Iterator i = listenerList.iterator();
- while (i.hasNext()) {
- try {
- ListenerMethod lm = (ListenerMethod) i.next();
- if (lm.matches(eventType,target,method))
- i.remove();
- } catch (java.lang.ClassCastException e) {
- // Class cast exceptions are ignored
- }
- }
- }
- }
-
- /* Removes the event listener method matching the given given
- * paramaters.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ public void removeListener(Class eventType, Object target) {
+
+ if (listenerList != null) {
+ Iterator i = listenerList.iterator();
+ while (i.hasNext()) {
+ try {
+ ListenerMethod lm = (ListenerMethod) i.next();
+ if (lm.matches(eventType, target))
+ i.remove();
+ } catch (java.lang.ClassCastException e) {
+ // Class cast exceptions are ignored
+ }
+ }
+ }
+ }
+
+ /*
+ * Removes the event listener methods matching the given given paramaters.
+ * Don't add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
+ */
+ public void removeListener(Class eventType, Object target, Method method) {
+
+ if (listenerList != null) {
+ Iterator i = listenerList.iterator();
+ while (i.hasNext()) {
+ try {
+ ListenerMethod lm = (ListenerMethod) i.next();
+ if (lm.matches(eventType, target, method))
+ i.remove();
+ } catch (java.lang.ClassCastException e) {
+ // Class cast exceptions are ignored
+ }
+ }
+ }
+ }
+
+ /*
+ * Removes the event listener method matching the given given paramaters.
+ * Don't add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
+ */
+ public void removeListener(Class eventType, Object target, String methodName) {
+
+ // Find the correct method
+ Method[] methods = target.getClass().getMethods();
+ Method method = null;
+ for (int i = 0; i < methods.length; i++)
+ if (methods[i].getName().equals(methodName))
+ method = methods[i];
+ if (method == null)
+ throw new IllegalArgumentException();
+
+ // Remove the listeners
+ if (listenerList != null) {
+ Iterator i = listenerList.iterator();
+ while (i.hasNext()) {
+ try {
+ ListenerMethod lm = (ListenerMethod) i.next();
+ if (lm.matches(eventType, target, method))
+ i.remove();
+ } catch (java.lang.ClassCastException e) {
+ // Class cast exceptions are ignored
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes all listeners from event router.
+ */
+ public void removeAllListeners() {
+ listenerList = null;
+ }
+
+ /**
+ * Sends an event to all registered listeners. The listeners will decide if
+ * the activation method should be called or not.
+ *
+ * @param event
+ * the Event to be sent to all listeners.
*/
- public void removeListener(Class eventType, Object target, String methodName) {
-
- // Find the correct method
- Method[] methods = target.getClass().getMethods();
- Method method = null;
- for (int i=0; i<methods.length; i++)
- if (methods[i].getName().equals(methodName))
- method = methods[i];
- if (method == null) throw new IllegalArgumentException();
-
- // Remove the listeners
- if (listenerList != null) {
- Iterator i = listenerList.iterator();
- while (i.hasNext()) {
- try {
- ListenerMethod lm = (ListenerMethod) i.next();
- if (lm.matches(eventType,target,method))
- i.remove();
- } catch (java.lang.ClassCastException e) {
- // Class cast exceptions are ignored
- }
- }
- }
- }
-
- /**
- * Removes all listeners from event router.
- */
- public void removeAllListeners() {
- listenerList = null;
- }
-
- /**
- * Sends an event to all registered listeners. The listeners will decide
- * if the activation method should be called or not.
- *
- * @param event the Event to be sent to all listeners.
- */
- public void fireEvent(EventObject event) {
-
- // It is not necessary to send any events if there are no listeners
- if (listenerList != null) {
-
- // Send the event to all listeners. The listeners themselves
- // will filter out unwanted events.
- Iterator i = new LinkedList(listenerList).iterator();
- while(i.hasNext()) ((ListenerMethod)i.next()).receiveEvent(event);
- }
- }
+ public void fireEvent(EventObject event) {
+
+ // It is not necessary to send any events if there are no listeners
+ if (listenerList != null) {
+
+ // Send the event to all listeners. The listeners themselves
+ // will filter out unwanted events.
+ Iterator i = new LinkedList(listenerList).iterator();
+ while (i.hasNext())
+ ((ListenerMethod) i.next()).receiveEvent(event);
+ }
+ }
}
diff --git a/src/com/itmill/toolkit/event/ListenerMethod.java b/src/com/itmill/toolkit/event/ListenerMethod.java
index 66ab99868c..f88b691987 100644
--- a/src/com/itmill/toolkit/event/ListenerMethod.java
+++ b/src/com/itmill/toolkit/event/ListenerMethod.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.event;
@@ -32,12 +32,12 @@ import java.util.EventListener;
import java.util.EventObject;
import java.lang.reflect.Method;
-/**
+/**
* <p>
- * One registered event listener. This class contains the listener
- * object reference, listened event type, the trigger method to call when
- * the event fires, and the optional argument list to pass to the method and
- * the index of the argument to replace with the event object.
+ * One registered event listener. This class contains the listener object
+ * reference, listened event type, the trigger method to call when the event
+ * fires, and the optional argument list to pass to the method and the index of
+ * the argument to replace with the event object.
* </p>
*
* <p>
@@ -49,79 +49,81 @@ import java.lang.reflect.Method;
* <p>
* It should be pointed out that the method
* {@link #receiveEvent(EventObject event)} is the one that filters out the
- * events that do not match with the given event type and thus do not result
- * in calling of the trigger method.
+ * events that do not match with the given event type and thus do not result in
+ * calling of the trigger method.
* </p>
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class ListenerMethod implements EventListener {
- /**
- * Type of the event that should trigger this listener. Also the
- * subclasses of this class are accepted to trigger the listener.
+ /**
+ * Type of the event that should trigger this listener. Also the subclasses
+ * of this class are accepted to trigger the listener.
*/
private Class eventType;
- /**
- * The object containing the trigger method.
+ /**
+ * The object containing the trigger method.
*/
private Object object;
- /**
+ /**
* The trigger method to call when an event passing the given criteria
* fires.
*/
private Method method;
- /**
- * Optional argument set to pass to the trigger method.
+ /**
+ * Optional argument set to pass to the trigger method.
*/
private Object[] arguments;
- /**
+ /**
* Optional index to <code>arguments</code> that point out which one
- * should be replaced with the triggering event object and thus be
- * passed to the trigger method.
+ * should be replaced with the triggering event object and thus be passed to
+ * the trigger method.
*/
private int eventArgumentIndex;
- /**
+ /**
* <p>
- * Constructs a new event listener from a trigger method, it's
- * arguments and the argument index specifying which one is replaced
- * with the event object when the trigger method is called.
+ * Constructs a new event listener from a trigger method, it's arguments and
+ * the argument index specifying which one is replaced with the event object
+ * when the trigger method is called.
* </p>
*
* <p>
- * This constructor gets the trigger method as a parameter so it
- * does not need to reflect to find it out.
+ * This constructor gets the trigger method as a parameter so it does not
+ * need to reflect to find it out.
* </p>
*
- * @param eventType the event type that is listener listens to. All
- * events of this kind (or its subclasses) result in calling the trigger
- * method.
- * @param object the object instance that contains the trigger method
- * @param method the trigger method
- * @param arguments the arguments to be passed to the trigger method
- * @param eventArgumentIndex An index to the argument list. This index
- * points out the argument that is replaced with the event object before
- * the argument set is passed to the trigger method. If
- * the eventArgumentIndex is negative, the triggering event
- * object will not be passed to the trigger method, though it is still
- * called.
- * @throws java.lang.IllegalArgumentException if <code>method</code>
- * is not a member of <code>object</code>.
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param object
+ * the object instance that contains the trigger method
+ * @param method
+ * the trigger method
+ * @param arguments
+ * the arguments to be passed to the trigger method
+ * @param eventArgumentIndex
+ * An index to the argument list. This index points out the
+ * argument that is replaced with the event object before the
+ * argument set is passed to the trigger method. If the
+ * eventArgumentIndex is negative, the triggering event object
+ * will not be passed to the trigger method, though it is still
+ * called.
+ * @throws java.lang.IllegalArgumentException
+ * if <code>method</code> is not a member of
+ * <code>object</code>.
*/
- public ListenerMethod(
- Class eventType,
- Object object,
- Method method,
- Object[] arguments,
- int eventArgumentIndex)
- throws java.lang.IllegalArgumentException {
+ public ListenerMethod(Class eventType, Object object, Method method,
+ Object[] arguments, int eventArgumentIndex)
+ throws java.lang.IllegalArgumentException {
// Checks that the object is of correct type
if (!method.getDeclaringClass().isAssignableFrom(object.getClass()))
@@ -133,8 +135,8 @@ public class ListenerMethod implements EventListener {
// Checks the event type is supported by the method
if (eventArgumentIndex >= 0
- && !method.getParameterTypes()[eventArgumentIndex].isAssignableFrom(
- eventType))
+ && !method.getParameterTypes()[eventArgumentIndex]
+ .isAssignableFrom(eventType))
throw new java.lang.IllegalArgumentException();
this.eventType = eventType;
@@ -144,40 +146,41 @@ public class ListenerMethod implements EventListener {
this.eventArgumentIndex = eventArgumentIndex;
}
- /**
+ /**
* <p>
* Constructs a new event listener from a trigger method name, it's
- * arguments and the argument index specifying which one is replaced
- * with the event object. The actual trigger method is reflected from
+ * arguments and the argument index specifying which one is replaced with
+ * the event object. The actual trigger method is reflected from
* <code>object</code>, and
* <code>java.lang.IllegalArgumentException</code> is thrown unless
* exactly one match is found.
* </p>
- * @param eventType the event type that is listener listens to. All
- * events of this kind (or its subclasses) result in calling the trigger
- * method.
- * @param object the object instance that contains the trigger method.
- * @param methodName the name of the trigger method. If the
- * object does not contain the method or it contains more
- * than one matching methods
- * <code>java.lang.IllegalArgumentException</code> is thrown.
- * @param arguments the arguments to be passed to the trigger method.
- * @param eventArgumentIndex An index to the argument list. This index
- * points out the argument that is replaced with the event object before
- * the argument set is passed to the trigger method. If the
- * eventArgumentIndex is negative, the triggering event
- * object will not be passed to the trigger method, though it is still
- * called.
- * @throws java.lang.IllegalArgumentException unless exactly one match
- * <code>methodName</code> is found in <code>object</code>.
+ *
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param object
+ * the object instance that contains the trigger method.
+ * @param methodName
+ * the name of the trigger method. If the object does not contain
+ * the method or it contains more than one matching methods
+ * <code>java.lang.IllegalArgumentException</code> is thrown.
+ * @param arguments
+ * the arguments to be passed to the trigger method.
+ * @param eventArgumentIndex
+ * An index to the argument list. This index points out the
+ * argument that is replaced with the event object before the
+ * argument set is passed to the trigger method. If the
+ * eventArgumentIndex is negative, the triggering event object
+ * will not be passed to the trigger method, though it is still
+ * called.
+ * @throws java.lang.IllegalArgumentException
+ * unless exactly one match <code>methodName</code> is found
+ * in <code>object</code>.
*/
- public ListenerMethod(
- Class eventType,
- Object object,
- String methodName,
- Object[] arguments,
- int eventArgumentIndex)
- throws java.lang.IllegalArgumentException {
+ public ListenerMethod(Class eventType, Object object, String methodName,
+ Object[] arguments, int eventArgumentIndex)
+ throws java.lang.IllegalArgumentException {
// Finds the correct method
Method[] methods = object.getClass().getMethods();
@@ -194,8 +197,8 @@ public class ListenerMethod implements EventListener {
// Checks the event type is supported by the method
if (eventArgumentIndex >= 0
- && !method.getParameterTypes()[eventArgumentIndex].isAssignableFrom(
- eventType))
+ && !method.getParameterTypes()[eventArgumentIndex]
+ .isAssignableFrom(eventType))
throw new java.lang.IllegalArgumentException();
this.eventType = eventType;
@@ -205,34 +208,34 @@ public class ListenerMethod implements EventListener {
this.eventArgumentIndex = eventArgumentIndex;
}
- /**
+ /**
* <p>
* Constructs a new event listener from the trigger method and it's
- * arguments. Since the the index to the replaced parameter is not
- * specified the event triggering this listener will not be passed to
- * the trigger method.
+ * arguments. Since the the index to the replaced parameter is not specified
+ * the event triggering this listener will not be passed to the trigger
+ * method.
* </p>
*
* <p>
- * This constructor gets the trigger method as a parameter so it
- * does not need to reflect to find it out.
+ * This constructor gets the trigger method as a parameter so it does not
+ * need to reflect to find it out.
* </p>
*
- * @param eventType the event type that is listener listens to. All
- * events of this kind (or its subclasses) result in calling the trigger
- * method.
- * @param object the object instance that contains the trigger method.
- * @param method the trigger method.
- * @param arguments the arguments to be passed to the trigger method.
- * @throws java.lang.IllegalArgumentException if <code>method</code>
- * is not a member of <code>object</code>.
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param object
+ * the object instance that contains the trigger method.
+ * @param method
+ * the trigger method.
+ * @param arguments
+ * the arguments to be passed to the trigger method.
+ * @throws java.lang.IllegalArgumentException
+ * if <code>method</code> is not a member of
+ * <code>object</code>.
*/
- public ListenerMethod(
- Class eventType,
- Object object,
- Method method,
- Object[] arguments)
- throws java.lang.IllegalArgumentException {
+ public ListenerMethod(Class eventType, Object object, Method method,
+ Object[] arguments) throws java.lang.IllegalArgumentException {
// Check that the object is of correct type
if (!method.getDeclaringClass().isAssignableFrom(object.getClass()))
@@ -245,38 +248,37 @@ public class ListenerMethod implements EventListener {
this.eventArgumentIndex = -1;
}
- /**
+ /**
* <p>
- * Constructs a new event listener from a trigger method name and
- * it's arguments. Since the the index to the replaced parameter is not
- * specified the event triggering this listener will not be passed to
- * the trigger method.
+ * Constructs a new event listener from a trigger method name and it's
+ * arguments. Since the the index to the replaced parameter is not specified
+ * the event triggering this listener will not be passed to the trigger
+ * method.
* </p>
*
* <p>
- * The actual trigger method is reflected from <code>object</code>,
- * and <code>java.lang.IllegalArgumentException</code> is thrown unless
+ * The actual trigger method is reflected from <code>object</code>, and
+ * <code>java.lang.IllegalArgumentException</code> is thrown unless
* exactly one match is found.
* </p>
*
- * @param eventType the event type that is listener listens to. All
- * events of this kind (or its subclasses) result in calling the trigger
- * method.
- * @param object the object instance that contains the trigger method.
- * @param methodName the name of the trigger method. If the
- * object does not contain the method or it contains more
- * than one matching methods
- * <code>java.lang.IllegalArgumentException</code> is thrown.
- * @param arguments the arguments to be passed to the trigger method.
- * @throws java.lang.IllegalArgumentException unless exactly one match
- * <code>methodName</code> is found in <code>object</code>.
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param object
+ * the object instance that contains the trigger method.
+ * @param methodName
+ * the name of the trigger method. If the object does not contain
+ * the method or it contains more than one matching methods
+ * <code>java.lang.IllegalArgumentException</code> is thrown.
+ * @param arguments
+ * the arguments to be passed to the trigger method.
+ * @throws java.lang.IllegalArgumentException
+ * unless exactly one match <code>methodName</code> is found
+ * in <code>object</code>.
*/
- public ListenerMethod(
- Class eventType,
- Object object,
- String methodName,
- Object[] arguments)
- throws java.lang.IllegalArgumentException {
+ public ListenerMethod(Class eventType, Object object, String methodName,
+ Object[] arguments) throws java.lang.IllegalArgumentException {
// Find the correct method
Method[] methods = object.getClass().getMethods();
@@ -294,28 +296,31 @@ public class ListenerMethod implements EventListener {
this.eventArgumentIndex = -1;
}
- /**
+ /**
* <p>
- * Constructs a new event listener from a trigger method. Since the
- * argument list is unspecified no parameters are passed to the trigger
- * method when the listener is triggered.
+ * Constructs a new event listener from a trigger method. Since the argument
+ * list is unspecified no parameters are passed to the trigger method when
+ * the listener is triggered.
* </p>
*
* <p>
- * This constructor gets the trigger method as a parameter so it
- * does not need to reflect to find it out.
+ * This constructor gets the trigger method as a parameter so it does not
+ * need to reflect to find it out.
* </p>
*
- * @param eventType the event type that is listener listens to. All
- * events of this kind (or its subclasses) result in calling the trigger
- * method.
- * @param object the object instance that contains the trigger method.
- * @param method the trigger method.
- * @throws java.lang.IllegalArgumentException if <code>method</code>
- * is not a member of <code>object</code>.
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param object
+ * the object instance that contains the trigger method.
+ * @param method
+ * the trigger method.
+ * @throws java.lang.IllegalArgumentException
+ * if <code>method</code> is not a member of
+ * <code>object</code>.
*/
public ListenerMethod(Class eventType, Object object, Method method)
- throws java.lang.IllegalArgumentException {
+ throws java.lang.IllegalArgumentException {
// Checks that the object is of correct type
if (!method.getDeclaringClass().isAssignableFrom(object.getClass()))
@@ -337,32 +342,34 @@ public class ListenerMethod implements EventListener {
throw new IllegalArgumentException();
}
- /**
+ /**
* <p>
- * Constructs a new event listener from a trigger method name. Since
- * the argument list is unspecified no parameters are passed to the
- * trigger method when the listener is triggered.
+ * Constructs a new event listener from a trigger method name. Since the
+ * argument list is unspecified no parameters are passed to the trigger
+ * method when the listener is triggered.
* </p>
*
* <p>
- * The actual trigger method is reflected from <code>object</code>,
- * and <code>java.lang.IllegalArgumentException</code> is thrown unless
+ * The actual trigger method is reflected from <code>object</code>, and
+ * <code>java.lang.IllegalArgumentException</code> is thrown unless
* exactly one match is found.
* </p>
*
- * @param eventType the event type that is listener listens to. All
- * events of this kind (or its subclasses) result in calling the trigger
- * method.
- * @param object the object instance that contains the trigger method.
- * @param methodName the name of the trigger method. If the
- * object does not contain the method or it contains more
- * than one matching methods
- * <code>java.lang.IllegalArgumentException</code> is thrown.
- * @throws java.lang.IllegalArgumentException unless exactly one match
- * <code>methodName</code> is found in <code>object</code>.
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param object
+ * the object instance that contains the trigger method.
+ * @param methodName
+ * the name of the trigger method. If the object does not contain
+ * the method or it contains more than one matching methods
+ * <code>java.lang.IllegalArgumentException</code> is thrown.
+ * @throws java.lang.IllegalArgumentException
+ * unless exactly one match <code>methodName</code> is found
+ * in <code>object</code>.
*/
public ListenerMethod(Class eventType, Object object, String methodName)
- throws java.lang.IllegalArgumentException {
+ throws java.lang.IllegalArgumentException {
// Finds the correct method
Method[] methods = object.getClass().getMethods();
@@ -389,15 +396,16 @@ public class ListenerMethod implements EventListener {
throw new IllegalArgumentException();
}
- /**
- * Receives one event from the <code>EventRouter</code> and calls the trigger
- * method if it matches with the criteria defined for the listener.
- * Only the events of the same or subclass of the specified event
- * class result in the trigger method to be called.
+ /**
+ * Receives one event from the <code>EventRouter</code> and calls the
+ * trigger method if it matches with the criteria defined for the listener.
+ * Only the events of the same or subclass of the specified event class
+ * result in the trigger method to be called.
*
- * @param event the fired event. Unless the trigger method's
- * argument list and the index to the to be replaced argument is
- * specified, this event will not be passed to the trigger method.
+ * @param event
+ * the fired event. Unless the trigger method's argument list and
+ * the index to the to be replaced argument is specified, this
+ * event will not be passed to the trigger method.
*/
public void receiveEvent(EventObject event) {
@@ -420,78 +428,90 @@ public class ListenerMethod implements EventListener {
} catch (java.lang.IllegalAccessException e) {
// This should never happen
throw new java.lang.RuntimeException(
- "Internal error - please report: " + e.toString());
+ "Internal error - please report: " + e.toString());
} catch (java.lang.reflect.InvocationTargetException e) {
// This should never happen
- throw new MethodException(
- "Invocation if method " + method + " failed.",
- e.getTargetException());
+ throw new MethodException("Invocation if method " + method
+ + " failed.", e.getTargetException());
}
}
}
- /**
- * Checks if the given object and event match with the ones stored
- * in this listener.
- *
- * @param target the object to be matched against the object stored by this
+ /**
+ * Checks if the given object and event match with the ones stored in this
* listener.
- * @param eventType the type to be tested for equality against the type
- * stored by this listener.
+ *
+ * @param target
+ * the object to be matched against the object stored by this
+ * listener.
+ * @param eventType
+ * the type to be tested for equality against the type stored by
+ * this listener.
* @return <code>true</code> if <code>target</code> is the same object
- * as the one stored in this object and <code>eventType</code> equals
- * the event type stored in this object.
+ * as the one stored in this object and <code>eventType</code>
+ * equals the event type stored in this object.
*/
public boolean matches(Class eventType, Object target) {
return (target == object) && (eventType.equals(this.eventType));
}
- /**
- * Checks if the given object, event and method match with the ones
- * stored in this listener.
+ /**
+ * Checks if the given object, event and method match with the ones stored
+ * in this listener.
*
- * @param target the object to be matched against the object stored by this
- * listener.
- * @param eventType the type to be tested for equality against the type
- * stored by this listener.
- * @param method the method to be tested for equality against the method
- * stored by this listener.
+ * @param target
+ * the object to be matched against the object stored by this
+ * listener.
+ * @param eventType
+ * the type to be tested for equality against the type stored by
+ * this listener.
+ * @param method
+ * the method to be tested for equality against the method stored
+ * by this listener.
* @return <code>true</code> if <code>target</code> is the same object
- * as the one stored in this object, <code>eventType</code> equals
- * with the event type stored in this object and <code>method</code>
- * equals with the method stored in this object
+ * as the one stored in this object, <code>eventType</code> equals
+ * with the event type stored in this object and <code>method</code>
+ * equals with the method stored in this object
*/
public boolean matches(Class eventType, Object target, Method method) {
return (target == object)
- && (eventType.equals(this.eventType) && method.equals(this.method));
+ && (eventType.equals(this.eventType) && method
+ .equals(this.method));
}
- /**
- * Exception that wraps an exception thrown by an invoked method.
- * When <code>ListenerMethod</code> invokes the target method, it may throw arbitrary
- * exception. The original exception is wrapped into MethodException instance and
- * rethrown by the <code>ListenerMethod</code>.
+ /**
+ * Exception that wraps an exception thrown by an invoked method. When
+ * <code>ListenerMethod</code> invokes the target method, it may throw
+ * arbitrary exception. The original exception is wrapped into
+ * MethodException instance and rethrown by the <code>ListenerMethod</code>.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
- * */
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
public class MethodException extends RuntimeException {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3257005445242894135L;
-
- private Throwable cause;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3257005445242894135L;
+
+ private Throwable cause;
+
private String message;
private MethodException(String message, Throwable cause) {
super(message);
this.cause = cause;
}
+
/**
- * Retrieves the cause of this throwable or <code>null</code> if the cause does not exist or not known.
- * @return the cause of this throwable or <code>null</code> if the cause is nonexistent or unknown.
+ * Retrieves the cause of this throwable or <code>null</code> if the
+ * cause does not exist or not known.
+ *
+ * @return the cause of this throwable or <code>null</code> if the
+ * cause is nonexistent or unknown.
* @see java.lang.Throwable#getCause()
*/
public Throwable getCause() {
@@ -500,13 +520,14 @@ public class ListenerMethod implements EventListener {
/**
* Returns the error message string of this throwable object.
+ *
* @return the error message.
* @see java.lang.Throwable#getMessage()
*/
public String getMessage() {
return message;
}
-
+
/**
* @see java.lang.Throwable#toString()
*/
diff --git a/src/com/itmill/toolkit/event/MethodEventSource.java b/src/com/itmill/toolkit/event/MethodEventSource.java
index 4df6d9674f..a11c23df92 100644
--- a/src/com/itmill/toolkit/event/MethodEventSource.java
+++ b/src/com/itmill/toolkit/event/MethodEventSource.java
@@ -1,82 +1,84 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.event;
import java.lang.reflect.Method;
-/**
+/**
* <p>
- * Interface for classes supporting registeration of methods as event
- * receivers.
+ * Interface for classes supporting registeration of methods as event receivers.
* </p>
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface MethodEventSource {
-
- /**
+
+ /**
* <p>
- * Registers a new event listener with the specified activation
- * method to listen events generated by this component. If the
- * activation method does not have any arguments the event object will
- * not be passed to it when it's called.
+ * Registers a new event listener with the specified activation method to
+ * listen events generated by this component. If the activation method does
+ * not have any arguments the event object will not be passed to it when
+ * it's called.
* </p>
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the type of the listened event. Events of this type or
- * its subclasses activate the listener.
- * @param object the object instance who owns the activation method.
- * @param method the activation method.
- * @throws java.lang.IllegalArgumentException unless <code>method</code>
- * has exactly one match in <code>object</code>
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param object
+ * the object instance who owns the activation method.
+ * @param method
+ * the activation method.
+ * @throws java.lang.IllegalArgumentException
+ * unless <code>method</code> has exactly one match in
+ * <code>object</code>
*/
- public void addListener(Class eventType, Object object, Method method);
-
- /**
+ public void addListener(Class eventType, Object object, Method method);
+
+ /**
* <p>
- * Registers a new listener with the specified activation method to
- * listen events generated by this component. If the activation method
- * does not have any arguments the event object will not be passed to it
- * when it's called.
+ * Registers a new listener with the specified activation method to listen
+ * events generated by this component. If the activation method does not
+ * have any arguments the event object will not be passed to it when it's
+ * called.
* </p>
*
* <p>
@@ -87,83 +89,91 @@ public interface MethodEventSource {
* </p>
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the type of the listened event. Events of this type or
- * its subclasses activate the listener.
- * @param object the object instance who owns the activation method.
- * @param methodName the name of the activation method.
- * @throws java.lang.IllegalArgumentException unless <code>method</code>
- * has exactly one match in <code>object</code>
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param object
+ * the object instance who owns the activation method.
+ * @param methodName
+ * the name of the activation method.
+ * @throws java.lang.IllegalArgumentException
+ * unless <code>method</code> has exactly one match in
+ * <code>object</code>
*/
- public void addListener(Class eventType, Object object, String methodName);
-
- /**
- * Removes all registered listeners matching the given parameters.
- * Since this method receives the event type and the listener object as
+ public void addListener(Class eventType, Object object, String methodName);
+
+ /**
+ * Removes all registered listeners matching the given parameters. Since
+ * this method receives the event type and the listener object as
* parameters, it will unregister all <code>object</code>'s methods that
* are registered to listen to events of type <code>eventType</code>
* generated by this component.
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the exact event type the <code>object</code> listens to.
- * @param target the target object that has registered to listen to events
- * of type <code>eventType</code> with one or more methods.
+ * @param eventType
+ * the exact event type the <code>object</code> listens to.
+ * @param target
+ * the target object that has registered to listen to events of
+ * type <code>eventType</code> with one or more methods.
*/
- public void removeListener(Class eventType, Object target);
-
- /**
- * Removes one registered listener method. The given method owned by
- * the given object will no longer be called when the specified events
- * are generated by this component.
+ public void removeListener(Class eventType, Object target);
+
+ /**
+ * Removes one registered listener method. The given method owned by the
+ * given object will no longer be called when the specified events are
+ * generated by this component.
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the exact event type the <code>object</code> listens to.
- * @param target the target object that has registered to listen to events
- * of type eventType with one or more methods.
- * @param method the method owned by the target that's
- * registered to listen to events of type eventType.
+ * @param eventType
+ * the exact event type the <code>object</code> listens to.
+ * @param target
+ * the target object that has registered to listen to events of
+ * type eventType with one or more methods.
+ * @param method
+ * the method owned by the target that's registered to listen to
+ * events of type eventType.
*/
- public void removeListener(Class eventType, Object target, Method method);
+ public void removeListener(Class eventType, Object target, Method method);
- /**
+ /**
* <p>
- * Removes one registered listener method. The given method owned by
- * the given object will no longer be called when the specified events
- * are generated by this component.
+ * Removes one registered listener method. The given method owned by the
+ * given object will no longer be called when the specified events are
+ * generated by this component.
* </p>
*
* <p>
* This version of <code>removeListener</code> gets the name of the
- * activation method as a parameter. The actual method is reflected from
- * the target, and unless exactly one match is found,
+ * activation method as a parameter. The actual method is reflected from the
+ * target, and unless exactly one match is found,
* <code>java.lang.IllegalArgumentException</code> is thrown.
* </p>
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the exact event type the <code>object</code> listens to.
- * @param target the target object that has registered to listen to events
- * of type <code>eventType</code> with one or more methods.
- * @param methodName the name of the method owned by <code>target</code>
- * that's registered to listen to events of type <code>eventType</code>.
+ * @param eventType
+ * the exact event type the <code>object</code> listens to.
+ * @param target
+ * the target object that has registered to listen to events of
+ * type <code>eventType</code> with one or more methods.
+ * @param methodName
+ * the name of the method owned by <code>target</code> that's
+ * registered to listen to events of type <code>eventType</code>.
*/
- public void removeListener(Class eventType, Object target, String methodName);
+ public void removeListener(Class eventType, Object target, String methodName);
}
diff --git a/src/com/itmill/toolkit/event/ShortcutAction.java b/src/com/itmill/toolkit/event/ShortcutAction.java
index 0621b4ca22..8071b25097 100644
--- a/src/com/itmill/toolkit/event/ShortcutAction.java
+++ b/src/com/itmill/toolkit/event/ShortcutAction.java
@@ -143,25 +143,25 @@ public class ShortcutAction extends Action {
public static final int Y = 89;
public static final int Z = 90;
-
+
public static final int NUM0 = 48;
-
+
public static final int NUM1 = 49;
-
+
public static final int NUM2 = 50;
-
+
public static final int NUM3 = 51;
-
+
public static final int NUM4 = 52;
-
+
public static final int NUM5 = 53;
-
+
public static final int NUM6 = 54;
-
+
public static final int NUM7 = 55;
-
+
public static final int NUM8 = 56;
-
+
public static final int NUM9 = 57;
}
diff --git a/src/com/itmill/toolkit/service/ApplicationContext.java b/src/com/itmill/toolkit/service/ApplicationContext.java
index 5486c4189f..36c1d49b83 100644
--- a/src/com/itmill/toolkit/service/ApplicationContext.java
+++ b/src/com/itmill/toolkit/service/ApplicationContext.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.service;
@@ -33,31 +33,32 @@ import java.util.Collection;
import com.itmill.toolkit.Application;
-/**
- * <code>ApplicationContext</code> provides information about the running context of
- * the application. Each context is shared by all applications that are open
- * for one user. In web-environment this corresponds to HttpSession.
+/**
+ * <code>ApplicationContext</code> provides information about the running
+ * context of the application. Each context is shared by all applications that
+ * are open for one user. In web-environment this corresponds to HttpSession.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.1
*/
public interface ApplicationContext {
-
- /**
+
+ /**
* Returns application context base directory.
*
- * Typically an application is deployed in a such way that is
- * has application directory. For web applications this directory is the
- * root directory of the web applications. In some cases application
- * might not have application directory (for example web applications
- * running inside of war).
+ * Typically an application is deployed in a such way that is has
+ * application directory. For web applications this directory is the root
+ * directory of the web applications. In some cases application might not
+ * have application directory (for example web applications running inside
+ * of war).
*
* @return The application base directory
*/
public File getBaseDirectory();
-
- /**
+
+ /**
* Gets the applications in this context.
*
* Gets all applications in this context. Each application context contains
@@ -66,44 +67,54 @@ public interface ApplicationContext {
* @return Collection containing all applications in this context
*/
public Collection getApplications();
-
-
- /**
+
+ /**
* Adds transaction listener to this context.
- * @param listener the listener to be added.
+ *
+ * @param listener
+ * the listener to be added.
* @see TransactionListener
*/
public void addTransactionListener(TransactionListener listener);
- /**
+ /**
* Removes transaction listener from this context.
- * @param listener the listener to be removed.
+ *
+ * @param listener
+ * the listener to be removed.
* @see TransactionListener
*/
public void removeTransactionListener(TransactionListener listener);
-
- /**
- * Interface for listening the application transaction events.
- * Implementations of this interface can be used to listen all
- * transactions between the client and the application.
- *
+
+ /**
+ * Interface for listening the application transaction events.
+ * Implementations of this interface can be used to listen all transactions
+ * between the client and the application.
+ *
*/
public interface TransactionListener {
-
- /**
+
+ /**
* Invoked at the beginning of every transaction.
- * @param application the Application object.
- * @param transactionData the Data identifying the transaction.
+ *
+ * @param application
+ * the Application object.
+ * @param transactionData
+ * the Data identifying the transaction.
*/
- public void transactionStart(Application application, Object transactionData);
-
+ public void transactionStart(Application application,
+ Object transactionData);
- /**
+ /**
* Invoked at the end of every transaction.
- * @param applcation the Application object.
- * @param transactionData the Data identifying the transaction.
+ *
+ * @param applcation
+ * the Application object.
+ * @param transactionData
+ * the Data identifying the transaction.
*/
- public void transactionEnd(Application application, Object transactionData);
+ public void transactionEnd(Application application,
+ Object transactionData);
}
}
diff --git a/src/com/itmill/toolkit/service/FileTypeResolver.java b/src/com/itmill/toolkit/service/FileTypeResolver.java
index 9e19d41cad..68030cbc15 100644
--- a/src/com/itmill/toolkit/service/FileTypeResolver.java
+++ b/src/com/itmill/toolkit/service/FileTypeResolver.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.service;
@@ -37,33 +37,35 @@ import java.util.StringTokenizer;
import com.itmill.toolkit.terminal.Resource;
import com.itmill.toolkit.terminal.ThemeResource;
-/**
+/**
* Utility class that can figure out mime-types and icons related to files.
* <p>
- * Note : The icons are associated purely to mime-types, so a file
- * may not have a custom icon accessible with this class.
+ * Note : The icons are associated purely to mime-types, so a file may not have
+ * a custom icon accessible with this class.
* </p>
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class FileTypeResolver {
- /**
- * Default icon given if no icon is specified for a mime-type.
+ /**
+ * Default icon given if no icon is specified for a mime-type.
*/
- static public Resource DEFAULT_ICON = new ThemeResource("icon/files/file.gif");
-
- /**
- * Default mime-type.
+ static public Resource DEFAULT_ICON = new ThemeResource(
+ "icon/files/file.gif");
+
+ /**
+ * Default mime-type.
*/
- static public String DEFAULT_MIME_TYPE = "application/octet-stream";
+ static public String DEFAULT_MIME_TYPE = "application/octet-stream";
- /**
- * Initial file extension to mime-type mapping.
+ /**
+ * Initial file extension to mime-type mapping.
*/
- static private String initialExtToMIMEMap =
- "application/cu-seeme csm cu,"
+ static private String initialExtToMIMEMap = "application/cu-seeme csm cu,"
+ "application/dsptype tsp,"
+ "application/futuresplash spl,"
+ "application/mac-binhex40 hqx,"
@@ -211,20 +213,20 @@ public class FileTypeResolver {
+ "video/x-sgi-movie movie,"
+ "x-world/x-vrml vrm vrml wrl";
- /**
- * File extension to MIME type mapping.
+ /**
+ * File extension to MIME type mapping.
*/
static private Hashtable extToMIMEMap = new Hashtable();
- /**
- * MIME type to Icon mapping.
+ /**
+ * MIME type to Icon mapping.
*/
static private Hashtable MIMEToIconMap = new Hashtable();
static {
-
+
// Initialize extension to MIME map
- StringTokenizer lines = new StringTokenizer(initialExtToMIMEMap,",");
+ StringTokenizer lines = new StringTokenizer(initialExtToMIMEMap, ",");
while (lines.hasMoreTokens()) {
String line = lines.nextToken();
StringTokenizer exts = new StringTokenizer(line);
@@ -234,143 +236,155 @@ public class FileTypeResolver {
addExtension(ext, type);
}
}
-
+
// Initialize Icons
addIcon("inode/drive", new ThemeResource("icon/files/drive.gif"));
addIcon("inode/directory", new ThemeResource("icon/files/folder.gif"));
}
- /**
- * Gets the mime-type of a file. Currently the mime-type is resolved
- * based only on the file name extension.
+ /**
+ * Gets the mime-type of a file. Currently the mime-type is resolved based
+ * only on the file name extension.
*
- * @param fileName the name of the file whose mime-type is requested.
+ * @param fileName
+ * the name of the file whose mime-type is requested.
* @return mime-type <code>String</code> for the given filename
*/
public static String getMIMEType(String fileName) {
// Checks for nulls
- if (fileName == null)
+ if (fileName == null)
throw new NullPointerException("Filename can not be null");
// Calculates the extension of the file
int dotIndex = fileName.indexOf(".");
- while (dotIndex >= 0 && fileName.indexOf(".",dotIndex+1) >= 0)
- dotIndex = fileName.indexOf(".",dotIndex+1);
+ while (dotIndex >= 0 && fileName.indexOf(".", dotIndex + 1) >= 0)
+ dotIndex = fileName.indexOf(".", dotIndex + 1);
dotIndex++;
-
+
if (fileName.length() > dotIndex) {
String ext = fileName.substring(dotIndex);
// Return type from extension map, if found
String type = (String) extToMIMEMap.get(ext);
- if (type != null) return type;
+ if (type != null)
+ return type;
}
return DEFAULT_MIME_TYPE;
}
- /**
- * Gets the descriptive icon representing file, based on the filename.
- * First the mime-type for the given filename is resolved, and then the
- * corresponding icon is fetched from the internal icon storage. If it
- * is not found the default icon is returned.
+ /**
+ * Gets the descriptive icon representing file, based on the filename. First
+ * the mime-type for the given filename is resolved, and then the
+ * corresponding icon is fetched from the internal icon storage. If it is
+ * not found the default icon is returned.
*
- * @param fileName the name of the file whose icon is requested.
+ * @param fileName
+ * the name of the file whose icon is requested.
* @return the icon corresponding to the given file
*/
public static Resource getIcon(String fileName) {
String mimeType = getMIMEType(fileName);
Resource icon = (Resource) MIMEToIconMap.get(mimeType);
- if (icon != null) return icon;
+ if (icon != null)
+ return icon;
// If nothing is known about the file-type, general file
- // icon is used
+ // icon is used
return DEFAULT_ICON;
}
- /**
- * Gets the descriptive icon representing a file. First the mime-type
- * for the given file name is resolved, and then the corresponding
- * icon is fetched from the internal icon storage. If it is not found
- * the default icon is returned.
+ /**
+ * Gets the descriptive icon representing a file. First the mime-type for
+ * the given file name is resolved, and then the corresponding icon is
+ * fetched from the internal icon storage. If it is not found the default
+ * icon is returned.
*
- * @param file the file whose icon is requested.
+ * @param file
+ * the file whose icon is requested.
* @return the icon corresponding to the given file
*/
public static Resource getIcon(File file) {
String mimeType = getMIMEType(file);
Resource icon = (Resource) MIMEToIconMap.get(mimeType);
- if (icon != null) return icon;
+ if (icon != null)
+ return icon;
// If nothing is known about the file-type, general file
- // icon is used
+ // icon is used
return DEFAULT_ICON;
}
- /**
+ /**
* Gets the mime-type for a file. Currently the returned file type is
* resolved by the filename extension only.
*
- * @param file the file whose mime-type is requested.
+ * @param file
+ * the file whose mime-type is requested.
* @return the files mime-type <code>String</code>
*/
public static String getMIMEType(File file) {
// Checks for nulls
- if (file == null)
+ if (file == null)
throw new NullPointerException("File can not be null");
// Drives
- if (file.getParentFile() == null) return "inode/drive";
+ if (file.getParentFile() == null)
+ return "inode/drive";
// Directories
- if (file.isDirectory()) return "inode/directory";
+ if (file.isDirectory())
+ return "inode/directory";
// Return type from extension
return getMIMEType(file.getName());
}
- /**
- * Adds a mime-type mapping for the given filename extension. If
- * the extension is already in the internal mapping it is overwritten.
+ /**
+ * Adds a mime-type mapping for the given filename extension. If the
+ * extension is already in the internal mapping it is overwritten.
*
- * @param extension the filename extension to be associated with
- * <code>MIMEType</code>.
- * @param MIMEType the new mime-type for <code>extension</code>.
+ * @param extension
+ * the filename extension to be associated with
+ * <code>MIMEType</code>.
+ * @param MIMEType
+ * the new mime-type for <code>extension</code>.
*/
public static void addExtension(String extension, String MIMEType) {
extToMIMEMap.put(extension, MIMEType);
}
- /**
+ /**
* Adds a icon for the given mime-type. If the mime-type also has a
* corresponding icon, it is replaced with the new icon.
*
- * @param MIMEType the mime-type whose icon is to be changed.
- * @param icon the new icon to be associated with <code>MIMEType</code>.
+ * @param MIMEType
+ * the mime-type whose icon is to be changed.
+ * @param icon
+ * the new icon to be associated with <code>MIMEType</code>.
*/
public static void addIcon(String MIMEType, Resource icon) {
MIMEToIconMap.put(MIMEType, icon);
}
-
- /**
+
+ /**
* Gets the internal file extension to mime-type mapping.
*
* @return unmodifiable map containing the current file extension to
- * mime-type mapping
+ * mime-type mapping
*/
public static Map getExtensionToMIMETypeMapping() {
return Collections.unmodifiableMap(extToMIMEMap);
}
- /**
+ /**
* Gets the internal mime-type to icon mapping.
*
- * @return unmodifiable map containing the current mime-type to icon
- * mapping
+ * @return unmodifiable map containing the current mime-type to icon mapping
*/
public static Map getMIMETypeToIconMapping() {
return Collections.unmodifiableMap(MIMEToIconMap);
diff --git a/src/com/itmill/toolkit/service/License.java b/src/com/itmill/toolkit/service/License.java
index 3be858666c..84f6d69154 100644
--- a/src/com/itmill/toolkit/service/License.java
+++ b/src/com/itmill/toolkit/service/License.java
@@ -60,7 +60,7 @@ import org.xml.sax.SAXException;
public class License {
/**
- * IT Mill License Manager certificate.
+ * IT Mill License Manager certificate.
*/
private static String certificate = "-----BEGIN CERTIFICATE-----\n"
+ "MIIDJjCCAuQCBEVqxNwwCwYHKoZIzjgEAwUAMHkxCzAJBgNVBAYTAkZJMRAwDgYDVQQIEwdVbmtu\n"
@@ -79,13 +79,13 @@ public class License {
+ "LwAkKye6dzALBgcqhkjOOAQDBQADLwAwLAIUDgvWt7ItRyZfpWNEeJ0P9yaxOwoCFC21LRtwLi1t\n"
+ "c+yomHtX+mpxF7VO\n" + "-----END CERTIFICATE-----\n";
- /**
- * License XML Document.
+ /**
+ * License XML Document.
*/
private Document licenseXML = null;
- /**
- * The signature has already been checked and is valid.
+ /**
+ * The signature has already been checked and is valid.
*/
private boolean signatureIsValid = false;
@@ -145,17 +145,18 @@ public class License {
return "true".equalsIgnoreCase(print);
}
+
/**
* Gets the description for this license.
- * @return
- * the description.
+ *
+ * @return the description.
* @throws LicenseFileHasNotBeenRead
- * if the license file has not been read.
+ * if the license file has not been read.
* @throws InvalidLicenseFile
- * if the license file is not of correct XML format.
+ * if the license file is not of correct XML format.
* @throws LicenseSignatureIsInvalid
- * if the license file has been changed or signature is
- * otherwise invalid.
+ * if the license file has been changed or signature is
+ * otherwise invalid.
*/
public String getDescription() throws LicenseFileHasNotBeenRead,
InvalidLicenseFile, LicenseSignatureIsInvalid {
@@ -512,9 +513,10 @@ public class License {
return null;
return name;
}
-
+
/**
- * Gets the purpose for this license.
+ * Gets the purpose for this license.
+ *
* @return the purpose.
*/
private String getPurpose() {
@@ -523,12 +525,14 @@ public class License {
return null;
return getTextContent(purposeL.item(0));
}
-
+
/**
- * Gets the license number for this license.
- * @return the license number of this license, or <code>null</code> if not set.
+ * Gets the license number for this license.
+ *
+ * @return the license number of this license, or <code>null</code> if not
+ * set.
* @throws InvalidLicenseFile
- * if the license file is not of correct XML format.
+ * if the license file is not of correct XML format.
*/
private String getLicenseNumber() throws InvalidLicenseFile {
Element lic = (Element) licenseXML.getElementsByTagName("license")
@@ -627,17 +631,19 @@ public class License {
return base64_decode(base64);
}
-
+
/**
* Returns whether the signature is valid or not.
- * @return <code>true</code> if the signature is valid otherwise <code>false</code> .
- * @throws InvalidLicenseFile
- * if the license file is not of correct XML format.
- * @throws LicenseFileHasNotBeenRead
- * if the license file has not been read.
+ *
+ * @return <code>true</code> if the signature is valid otherwise
+ * <code>false</code> .
+ * @throws InvalidLicenseFile
+ * if the license file is not of correct XML format.
+ * @throws LicenseFileHasNotBeenRead
+ * if the license file has not been read.
* @throws LicenseSignatureIsInvalid
- * if the license file has been changed or signature is
- * otherwise invalid.
+ * if the license file has been changed or signature is
+ * otherwise invalid.
*/
private boolean isSignatureValid() throws InvalidLicenseFile,
LicenseFileHasNotBeenRead, LicenseSignatureIsInvalid {
@@ -750,13 +756,13 @@ public class License {
}
/* ****** BASE64 implementation created by Robert Harder ****** */
- /**
- * The equals sign (=) as a byte.
+ /**
+ * The equals sign (=) as a byte.
*/
private final static byte Base64_EQUALS_SIGN = (byte) '=';
- /**
- * Preferred encoding.
+ /**
+ * Preferred encoding.
*/
private final static String Base64_PREFERRED_ENCODING = "UTF-8";
@@ -807,23 +813,23 @@ public class License {
* Decodes four bytes from array <var>source</var> and writes the resulting
* bytes (up to three of them) to <var>destination</var>. The source and
* destination arrays can be manipulated anywhere along their length by
- * specifying <var>srcOffset</var> and <var>destOffset</var>.
+ * specifying <var>srcOffset</var> and <var>destOffset</var>.
* <p>
- * This method does not check to make sure your arrays are large enough
- * to accomodate <var>srcOffset</var> + 4 for the <var>source</var> array or
+ * This method does not check to make sure your arrays are large enough to
+ * accomodate <var>srcOffset</var> + 4 for the <var>source</var> array or
* <var>destOffset</var> + 3 for the <var>destination</var> array. This
* method returns the actual number of bytes that were converted from the
* Base64 encoding.
* </p>
*
* @param source
- * the array to convert.
+ * the array to convert.
* @param srcOffset
- * the index where conversion begins.
+ * the index where conversion begins.
* @param destination
- * the array to hold the conversion.
+ * the array to hold the conversion.
* @param destOffset
- * the index where output will be put.
+ * the index where output will be put.
* @return the number of decoded bytes converted
* @since 1.3
*/
diff --git a/src/com/itmill/toolkit/terminal/ApplicationResource.java b/src/com/itmill/toolkit/terminal/ApplicationResource.java
index 22f286ef66..53e1540cb6 100644
--- a/src/com/itmill/toolkit/terminal/ApplicationResource.java
+++ b/src/com/itmill/toolkit/terminal/ApplicationResource.java
@@ -1,92 +1,96 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import com.itmill.toolkit.Application;
-/**
- * This interface must be implemented by classes wishing to provide Application resources.
+/**
+ * This interface must be implemented by classes wishing to provide Application
+ * resources.
* <p>
- * <code>ApplicationResource</code> are a set of named resources (pictures, sounds, etc) associated
- * with some specific application. Having named application resources provides a convenient
- * method for having inter-theme common resources for an application.
+ * <code>ApplicationResource</code> are a set of named resources (pictures,
+ * sounds, etc) associated with some specific application. Having named
+ * application resources provides a convenient method for having inter-theme
+ * common resources for an application.
* </p>
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface ApplicationResource extends Resource {
- /**
- * Default cache time.
+ /**
+ * Default cache time.
*/
- public static final long DEFAULT_CACHETIME = 1000*60*60*24;
+ public static final long DEFAULT_CACHETIME = 1000 * 60 * 60 * 24;
- /**
- * Gets resource as stream.
+ /**
+ * Gets resource as stream.
*/
public DownloadStream getStream();
-
- /**
- * Gets the application of the resource.
+
+ /**
+ * Gets the application of the resource.
*/
public Application getApplication();
- /**
- * Gets the virtual filename for this resource.
+ /**
+ * Gets the virtual filename for this resource.
+ *
* @return the file name associated to this resource.
*/
public String getFilename();
-
- /**
+
+ /**
* Gets the length of cache expiration time.
*
* <p>
- * This gives the adapter the possibility cache streams sent to the
- * client. The caching may be made in adapter or at the client if the
- * client supports caching. Default is <code>DEFAULT_CACHETIME</code>.
+ * This gives the adapter the possibility cache streams sent to the client.
+ * The caching may be made in adapter or at the client if the client
+ * supports caching. Default is <code>DEFAULT_CACHETIME</code>.
* </p>
*
* @return Cache time in milliseconds
*/
public long getCacheTime();
- /**
+ /**
* Gets the size of the download buffer used for this resource.
*
* <p>
- * If the buffer size is 0, the buffer size is decided by the
- * terminal adapter. The default value is 0.
+ * If the buffer size is 0, the buffer size is decided by the terminal
+ * adapter. The default value is 0.
* </p>
*
- * @return int
- * the size of the buffer in bytes.
+ * @return int the size of the buffer in bytes.
*/
public int getBufferSize();
diff --git a/src/com/itmill/toolkit/terminal/ClassResource.java b/src/com/itmill/toolkit/terminal/ClassResource.java
index efdfee4ad3..c53375350e 100644
--- a/src/com/itmill/toolkit/terminal/ClassResource.java
+++ b/src/com/itmill/toolkit/terminal/ClassResource.java
@@ -1,80 +1,85 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import com.itmill.toolkit.Application;
import com.itmill.toolkit.service.FileTypeResolver;
-/**
- * <code>ClassResource</code> is a named resource accessed with the class loader.
- *
+/**
+ * <code>ClassResource</code> is a named resource accessed with the class
+ * loader.
+ *
* This can be used to access resources such as icons, files, etc.
+ *
* @see java.lang.Class#getResource(java.lang.String)
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class ClassResource implements ApplicationResource {
- /**
- * Default buffer size for this stream resource.
+ /**
+ * Default buffer size for this stream resource.
*/
private int bufferSize = 0;
- /**
- * Default cache time for this stream resource.
+ /**
+ * Default cache time for this stream resource.
*/
- private long cacheTime = DEFAULT_CACHETIME;
+ private long cacheTime = DEFAULT_CACHETIME;
- /**
- * Associated class used for indetifying the source of the resource.
+ /**
+ * Associated class used for indetifying the source of the resource.
*/
private Class associatedClass;
-
- /**
- * Name of the resource is relative to the associated class.
+
+ /**
+ * Name of the resource is relative to the associated class.
*/
private String resourceName;
-
- /**
- * Application used for serving the class.
+
+ /**
+ * Application used for serving the class.
*/
private Application application;
- /**
- * Creates a new application resource instance.
- * The resource id is relative to the location of the application class.
+ /**
+ * Creates a new application resource instance. The resource id is relative
+ * to the location of the application class.
*
- * @param resourceName the Unique identifier of the resource within the application.
- * @param application the application this resource will be added to.
- * */
+ * @param resourceName
+ * the Unique identifier of the resource within the application.
+ * @param application
+ * the application this resource will be added to.
+ */
public ClassResource(String resourceName, Application application) {
this.associatedClass = application.getClass();
this.resourceName = resourceName;
@@ -84,17 +89,18 @@ public class ClassResource implements ApplicationResource {
application.addResource(this);
}
- /**
- * Creates a new application resource instance.
+ /**
+ * Creates a new application resource instance.
*
- * @param associatedClass the class of the which the resource is associated.
- * @param resourceName the Unique identifier of the resource within the application.
- * @param application the application this resource will be added to.
+ * @param associatedClass
+ * the class of the which the resource is associated.
+ * @param resourceName
+ * the Unique identifier of the resource within the application.
+ * @param application
+ * the application this resource will be added to.
*/
- public ClassResource(
- Class associatedClass,
- String resourceName,
- Application application) {
+ public ClassResource(Class associatedClass, String resourceName,
+ Application application) {
this.associatedClass = associatedClass;
this.resourceName = resourceName;
this.application = application;
@@ -102,22 +108,28 @@ public class ClassResource implements ApplicationResource {
throw new NullPointerException();
application.addResource(this);
}
+
/**
* Gets the MIME type of this resource.
+ *
* @see com.itmill.toolkit.terminal.Resource#getMIMEType()
*/
public String getMIMEType() {
return FileTypeResolver.getMIMEType(this.resourceName);
}
+
/**
* Gets the application of this resource.
+ *
* @see com.itmill.toolkit.terminal.ApplicationResource#getApplication()
*/
public Application getApplication() {
return application;
}
+
/**
* Gets the virtual filename for this resource.
+ *
* @return the file name associated to this resource.
* @see com.itmill.toolkit.terminal.ApplicationResource#getFilename()
*/
@@ -125,19 +137,20 @@ public class ClassResource implements ApplicationResource {
int index = 0;
int next = 0;
while ((next = resourceName.indexOf('/', index)) > 0
- && next + 1 < resourceName.length())
+ && next + 1 < resourceName.length())
index = next + 1;
return resourceName.substring(index);
}
+
/**
* Gets resource as stream.
+ *
* @see com.itmill.toolkit.terminal.ApplicationResource#getStream()
*/
public DownloadStream getStream() {
- DownloadStream ds = new DownloadStream(
- associatedClass.getResourceAsStream(resourceName),
- getMIMEType(),
- getFilename());
+ DownloadStream ds = new DownloadStream(associatedClass
+ .getResourceAsStream(resourceName), getMIMEType(),
+ getFilename());
ds.setBufferSize(getBufferSize());
ds.setCacheTime(cacheTime);
return ds;
@@ -148,9 +161,11 @@ public class ClassResource implements ApplicationResource {
return bufferSize;
}
- /**
+ /**
* Sets the size of the download buffer used for this resource.
- * @param bufferSize the size of the buffer in bytes.
+ *
+ * @param bufferSize
+ * the size of the buffer in bytes.
*/
public void setBufferSize(int bufferSize) {
this.bufferSize = bufferSize;
@@ -161,17 +176,18 @@ public class ClassResource implements ApplicationResource {
return cacheTime;
}
- /**
+ /**
* Sets the length of cache expiration time.
*
* <p>
- * This gives the adapter the possibility cache streams sent to the
- * client. The caching may be made in adapter or at the client if the
- * client supports caching. Zero or negavive value disbales the
- * caching of this stream.
+ * This gives the adapter the possibility cache streams sent to the client.
+ * The caching may be made in adapter or at the client if the client
+ * supports caching. Zero or negavive value disbales the caching of this
+ * stream.
* </p>
*
- * @param cacheTime the cache time in milliseconds.
+ * @param cacheTime
+ * the cache time in milliseconds.
*
*/
public void setCacheTime(long cacheTime) {
diff --git a/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java b/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java
index 778df1a41e..469efdbf7b 100644
--- a/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java
+++ b/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
@@ -33,30 +33,32 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-/**
+/**
* Class for combining multiple error messages together.
- *
- * @author IT Mill Ltd
- * @version @VERSION@
+ *
+ * @author IT Mill Ltd
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class CompositeErrorMessage implements ErrorMessage {
- /**
- * Array of all the errors.
+ /**
+ * Array of all the errors.
*/
private List errors;
- /**
- * Level of the error.
+ /**
+ * Level of the error.
*/
private int level;
- /**
+ /**
* Constructor for CompositeErrorMessage.
*
- * @param errorMessages the Array of error messages that are listed togeter.
- * Nulls are ignored, but at least one message is required.
+ * @param errorMessages
+ * the Array of error messages that are listed togeter. Nulls are
+ * ignored, but at least one message is required.
*/
public CompositeErrorMessage(ErrorMessage[] errorMessages) {
errors = new ArrayList(errorMessages.length);
@@ -67,14 +69,17 @@ public class CompositeErrorMessage implements ErrorMessage {
}
if (errors.size() == 0)
- throw new IllegalArgumentException("Composite error message must have at least one error");
+ throw new IllegalArgumentException(
+ "Composite error message must have at least one error");
}
- /**
+ /**
* Constructor for CompositeErrorMessage.
- * @param errorMessages the Collection of error messages that are listed
- * togeter. At least one message is required.
+ *
+ * @param errorMessages
+ * the Collection of error messages that are listed togeter. At
+ * least one message is required.
*/
public CompositeErrorMessage(Collection errorMessages) {
errors = new ArrayList(errorMessages.size());
@@ -85,21 +90,25 @@ public class CompositeErrorMessage implements ErrorMessage {
}
if (errors.size() == 0)
- throw new IllegalArgumentException("Composite error message must have at least one error");
+ throw new IllegalArgumentException(
+ "Composite error message must have at least one error");
}
- /**
- * The error level is the largest error level in
+ /**
+ * The error level is the largest error level in
+ *
* @see com.itmill.toolkit.terminal.ErrorMessage#getErrorLevel()
*/
public final int getErrorLevel() {
return level;
}
- /**
- * Adds a error message into this composite message.
- * Updates the level field.
- * @param error the error message to be added. Duplicate errors are ignored.
+ /**
+ * Adds a error message into this composite message. Updates the level
+ * field.
+ *
+ * @param error
+ * the error message to be added. Duplicate errors are ignored.
*/
private void addErrorMessage(ErrorMessage error) {
if (error != null && !errors.contains(error)) {
@@ -110,21 +119,22 @@ public class CompositeErrorMessage implements ErrorMessage {
}
}
- /**
+ /**
* Gets Error Iterator.
- * @return the error iterator.
+ *
+ * @return the error iterator.
*/
public Iterator iterator() {
return errors.iterator();
}
-
+
/**
* @see com.itmill.toolkit.terminal.Paintable#paint(com.itmill.toolkit.terminal.PaintTarget)
*/
public void paint(PaintTarget target) throws PaintException {
if (errors.size() == 1)
- ((ErrorMessage) errors.iterator().next()).paint(target);
+ ((ErrorMessage) errors.iterator().next()).paint(target);
else {
target.startTag("error");
@@ -164,8 +174,9 @@ public class CompositeErrorMessage implements ErrorMessage {
public void requestRepaintRequests() {
}
- /**
+ /**
* Returns a comma separated list of the error messages.
+ *
* @return String, comma separated list of error messages.
*/
public String toString() {
diff --git a/src/com/itmill/toolkit/terminal/DownloadStream.java b/src/com/itmill/toolkit/terminal/DownloadStream.java
index c4b481e70e..86995036e9 100644
--- a/src/com/itmill/toolkit/terminal/DownloadStream.java
+++ b/src/com/itmill/toolkit/terminal/DownloadStream.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
@@ -33,102 +33,117 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-/**
+/**
* Downloadable stream.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class DownloadStream {
- /**
- * Maximum cache time.
+ /**
+ * Maximum cache time.
*/
public static final long MAX_CACHETIME = Long.MAX_VALUE;
-
- /**
- * Default cache time.
+
+ /**
+ * Default cache time.
*/
- public static final long DEFAULT_CACHETIME = 1000*60*60*24;
-
+ public static final long DEFAULT_CACHETIME = 1000 * 60 * 60 * 24;
+
private InputStream stream;
+
private String contentType;
+
private String fileName;
+
private Map params;
+
private long cacheTime = DEFAULT_CACHETIME;
+
private int bufferSize = 0;
- /**
- * Creates a new instance of DownloadStream.
+ /**
+ * Creates a new instance of DownloadStream.
*/
- public DownloadStream(
- InputStream stream,
- String contentType,
- String fileName) {
+ public DownloadStream(InputStream stream, String contentType,
+ String fileName) {
setStream(stream);
setContentType(contentType);
setFileName(fileName);
}
- /**
+ /**
* Gets downloadable stream.
+ *
* @return output stream.
*/
public InputStream getStream() {
return this.stream;
}
- /**
+ /**
* Sets the stream.
- * @param stream The stream to set
+ *
+ * @param stream
+ * The stream to set
*/
public void setStream(InputStream stream) {
this.stream = stream;
}
- /**
+ /**
* Gets stream content type.
+ *
* @return type of the stream content.
*/
public String getContentType() {
return this.contentType;
}
- /**
+ /**
* Sets stream content type.
- * @param contentType the contentType to set
+ *
+ * @param contentType
+ * the contentType to set
*/
public void setContentType(String contentType) {
this.contentType = contentType;
}
- /**
+ /**
* Returns the file name.
+ *
* @return the name of the file.
*/
public String getFileName() {
return fileName;
}
- /**
+ /**
* Sets the file name.
- * @param fileName the file name to set.
+ *
+ * @param fileName
+ * the file name to set.
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
- /**
- * Sets a paramater for download stream.
- * Parameters are optional information about the downloadable stream
- * and their meaning depends on the used adapter. For example in
- * WebAdapter they are interpreted as HTTP response headers.
- *
+ /**
+ * Sets a paramater for download stream. Parameters are optional information
+ * about the downloadable stream and their meaning depends on the used
+ * adapter. For example in WebAdapter they are interpreted as HTTP response
+ * headers.
+ *
* If the parameters by this name exists, the old value is replaced.
*
- * @param name the Name of the parameter to set.
- * @param value the Value of the parameter to set.
+ * @param name
+ * the Name of the parameter to set.
+ * @param value
+ * the Value of the parameter to set.
*/
public void setParameter(String name, String value) {
if (this.params == null) {
@@ -137,12 +152,14 @@ public class DownloadStream {
this.params.put(name, value);
}
- /**
- * Gets a paramater for download stream.
- * Parameters are optional information about the downloadable stream
- * and their meaning depends on the used adapter. For example in
- * WebAdapter they are interpreted as HTTP response headers.
- * @param name the Name of the parameter to set.
+ /**
+ * Gets a paramater for download stream. Parameters are optional information
+ * about the downloadable stream and their meaning depends on the used
+ * adapter. For example in WebAdapter they are interpreted as HTTP response
+ * headers.
+ *
+ * @param name
+ * the Name of the parameter to set.
* @return Value of the parameter or null if the parameter does not exist.
*/
public String getParameter(String name) {
@@ -151,8 +168,9 @@ public class DownloadStream {
return null;
}
- /**
+ /**
* Gets the names of the parameters.
+ *
* @return Iterator of names or null if no parameters are set.
*/
public Iterator getParameterNames() {
@@ -160,40 +178,46 @@ public class DownloadStream {
return this.params.keySet().iterator();
return null;
}
-
- /**
- * Gets length of cache expiration time.
- * This gives the adapter the possibility cache streams sent to the client.
- * The caching may be made in adapter or at the client if the client supports
- * caching. Default is <code>DEFAULT_CACHETIME</code>.
+
+ /**
+ * Gets length of cache expiration time. This gives the adapter the
+ * possibility cache streams sent to the client. The caching may be made in
+ * adapter or at the client if the client supports caching. Default is
+ * <code>DEFAULT_CACHETIME</code>.
+ *
* @return Cache time in milliseconds
*/
public long getCacheTime() {
return cacheTime;
}
- /**
- * Sets length of cache expiration time.
- * This gives the adapter the possibility cache streams sent to the client.
- * The caching may be made in adapter or at the client if the client supports
- * caching. Zero or negavive value disbales the caching of this stream.
- * @param cacheTime the cache time in milliseconds.
+ /**
+ * Sets length of cache expiration time. This gives the adapter the
+ * possibility cache streams sent to the client. The caching may be made in
+ * adapter or at the client if the client supports caching. Zero or negavive
+ * value disbales the caching of this stream.
+ *
+ * @param cacheTime
+ * the cache time in milliseconds.
*/
public void setCacheTime(long cacheTime) {
this.cacheTime = cacheTime;
}
- /**
+ /**
* Gets the size of the download buffer.
+ *
* @return int The size of the buffer in bytes.
*/
public int getBufferSize() {
return bufferSize;
}
- /**
+ /**
* Sets the size of the download buffer.
- * @param bufferSize the size of the buffer in bytes.
+ *
+ * @param bufferSize
+ * the size of the buffer in bytes.
*/
public void setBufferSize(int bufferSize) {
this.bufferSize = bufferSize;
diff --git a/src/com/itmill/toolkit/terminal/ErrorMessage.java b/src/com/itmill/toolkit/terminal/ErrorMessage.java
index 5e0d52f296..d26c1c74a4 100644
--- a/src/com/itmill/toolkit/terminal/ErrorMessage.java
+++ b/src/com/itmill/toolkit/terminal/ErrorMessage.java
@@ -1,95 +1,100 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
-/**
+/**
* Interface for rendering error messages to terminal. All the visible errors
* shown to user must implement this interface.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface ErrorMessage extends Paintable {
- /**
- * Error code for system errors and bugs.
+ /**
+ * Error code for system errors and bugs.
*/
public static final int SYSTEMERROR = 5000;
- /**
- * Error code for critical error messages.
+ /**
+ * Error code for critical error messages.
*/
public static final int CRITICAL = 4000;
- /**
- * Error code for regular error messages.
+ /**
+ * Error code for regular error messages.
*/
public static final int ERROR = 3000;
- /**
- * Error code for warning messages.
+ /**
+ * Error code for warning messages.
*/
public static final int WARNING = 2000;
- /**
- * Error code for informational messages.
+ /**
+ * Error code for informational messages.
*/
public static final int INFORMATION = 1000;
- /**
+ /**
* Gets the errors level.
*
* @return the level of error as an integer.
*/
public int getErrorLevel();
- /**
+ /**
* Error messages are inmodifiable and thus listeners are not needed. This
* method should be implemented as empty.
- * @param listener the listener to be added.
+ *
+ * @param listener
+ * the listener to be added.
* @see com.itmill.toolkit.terminal.Paintable#addListener(Paintable.RepaintRequestListener)
*/
public void addListener(RepaintRequestListener listener);
- /**
+ /**
* Error messages are inmodifiable and thus listeners are not needed. This
* method should be implemented as empty.
- * @param listener the listener to be removed.
+ *
+ * @param listener
+ * the listener to be removed.
* @see com.itmill.toolkit.terminal.Paintable#removeListener(Paintable.RepaintRequestListener)
*/
public void removeListener(RepaintRequestListener listener);
- /**
+ /**
* Error messages are inmodifiable and thus listeners are not needed. This
* method should be implemented as empty.
- *
+ *
* @see com.itmill.toolkit.terminal.Paintable#requestRepaint()
*/
public void requestRepaint();
diff --git a/src/com/itmill/toolkit/terminal/ExternalResource.java b/src/com/itmill/toolkit/terminal/ExternalResource.java
index f169895879..6509d44534 100644
--- a/src/com/itmill/toolkit/terminal/ExternalResource.java
+++ b/src/com/itmill/toolkit/terminal/ExternalResource.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
@@ -32,55 +32,61 @@ import java.net.URL;
import com.itmill.toolkit.service.FileTypeResolver;
-/**
- * <code>ExternalResource</code> implements source for resources fetched from
- * location specified by URL:s. The resources are fetched directly by the
- * client terminal and are not fetched trough the terminal adapter.
+/**
+ * <code>ExternalResource</code> implements source for resources fetched from
+ * location specified by URL:s. The resources are fetched directly by the client
+ * terminal and are not fetched trough the terminal adapter.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class ExternalResource implements Resource {
- /**
- * Url of the download.
+ /**
+ * Url of the download.
*/
private String sourceURL = null;
-
- /**
+ /**
* Creates a new download component for downloading directly from given URL.
- * @param sourceURL the source URL.
+ *
+ * @param sourceURL
+ * the source URL.
*/
public ExternalResource(URL sourceURL) {
- if (sourceURL == null)
+ if (sourceURL == null)
throw new RuntimeException("Source must be non-null");
-
+
this.sourceURL = sourceURL.toString();
}
- /**
+ /**
* Creates a new download component for downloading directly from given URL.
- * @param sourceURL the source URL.
+ *
+ * @param sourceURL
+ * the source URL.
*/
public ExternalResource(String sourceURL) {
- if (sourceURL == null)
+ if (sourceURL == null)
throw new RuntimeException("Source must be non-null");
-
+
this.sourceURL = sourceURL.toString();
}
- /**
+ /**
* Gets the URL of the external resource.
- * @return the URL of the external resource.
+ *
+ * @return the URL of the external resource.
*/
public String getURL() {
return sourceURL;
}
-
+
/**
* Gets the MIME type of the resource.
+ *
* @see com.itmill.toolkit.terminal.Resource#getMIMEType()
*/
public String getMIMEType() {
diff --git a/src/com/itmill/toolkit/terminal/FileResource.java b/src/com/itmill/toolkit/terminal/FileResource.java
index 497baa065c..2ca1332f08 100644
--- a/src/com/itmill/toolkit/terminal/FileResource.java
+++ b/src/com/itmill/toolkit/terminal/FileResource.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
@@ -35,77 +35,80 @@ import java.io.FileNotFoundException;
import com.itmill.toolkit.Application;
import com.itmill.toolkit.service.FileTypeResolver;
-/**
- * <code>FileResources</code> are files or directories on local filesystem. The files and directories
- * are served through URI:s to the client terminal and thus must be registered to an
- * URI context before they can be used. The resource is automatically registered
- * to the application when it is created.
- *
+/**
+ * <code>FileResources</code> are files or directories on local filesystem.
+ * The files and directories are served through URI:s to the client terminal and
+ * thus must be registered to an URI context before they can be used. The
+ * resource is automatically registered to the application when it is created.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class FileResource implements ApplicationResource {
- /**
- * Default buffer size for this stream resource.
+ /**
+ * Default buffer size for this stream resource.
*/
private int bufferSize = 0;
- /**
- * File where the downloaded content is fetched from.
+ /**
+ * File where the downloaded content is fetched from.
*/
private File sourceFile;
- /**
- * Application.
+ /**
+ * Application.
*/
private Application application;
- /**
- * Default cache time for this stream resource.
+ /**
+ * Default cache time for this stream resource.
*/
- private long cacheTime = DownloadStream.DEFAULT_CACHETIME;
+ private long cacheTime = DownloadStream.DEFAULT_CACHETIME;
- /**
- * Creates a new file resource for providing given file for
- * client terminals.
+ /**
+ * Creates a new file resource for providing given file for client
+ * terminals.
*/
public FileResource(File sourceFile, Application application) {
this.application = application;
setSourceFile(sourceFile);
application.addResource(this);
}
-
+
/**
* Gets the resource as stream.
+ *
* @see com.itmill.toolkit.terminal.ApplicationResource#getStream()
*/
public DownloadStream getStream() {
try {
- DownloadStream ds = new DownloadStream(
- new FileInputStream(this.sourceFile),
- getMIMEType(),
- getFilename());
+ DownloadStream ds = new DownloadStream(new FileInputStream(
+ this.sourceFile), getMIMEType(), getFilename());
ds.setCacheTime(cacheTime);
return ds;
} catch (FileNotFoundException e) {
- // No logging for non-existing files at this level.
+ // No logging for non-existing files at this level.
return null;
}
}
- /**
+ /**
* Gets the source file.
+ *
* @return the source File.
*/
public File getSourceFile() {
return sourceFile;
}
- /**
+ /**
* Sets the source file.
- * @param sourceFile the source file to set.
+ *
+ * @param sourceFile
+ * the source file to set.
*/
public void setSourceFile(File sourceFile) {
this.sourceFile = sourceFile;
@@ -131,37 +134,42 @@ public class FileResource implements ApplicationResource {
public String getMIMEType() {
return FileTypeResolver.getMIMEType(sourceFile);
}
-
- /**
- * Gets the length of cache expiration time.
- * This gives the adapter the possibility cache streams sent to the client.
- * The caching may be made in adapter or at the client if the client supports
- * caching. Default is <code>DownloadStream.DEFAULT_CACHETIME</code>.
+
+ /**
+ * Gets the length of cache expiration time. This gives the adapter the
+ * possibility cache streams sent to the client. The caching may be made in
+ * adapter or at the client if the client supports caching. Default is
+ * <code>DownloadStream.DEFAULT_CACHETIME</code>.
+ *
* @return Cache time in milliseconds.
*/
public long getCacheTime() {
return cacheTime;
}
- /**
- * Sets the length of cache expiration time.
- * This gives the adapter the possibility cache streams sent to the client.
- * The caching may be made in adapter or at the client if the client supports
- * caching. Zero or negavive value disbales the caching of this stream.
- * @param cacheTime the cache time in milliseconds.
+ /**
+ * Sets the length of cache expiration time. This gives the adapter the
+ * possibility cache streams sent to the client. The caching may be made in
+ * adapter or at the client if the client supports caching. Zero or negavive
+ * value disbales the caching of this stream.
+ *
+ * @param cacheTime
+ * the cache time in milliseconds.
*/
public void setCacheTime(long cacheTime) {
this.cacheTime = cacheTime;
- }
-
+ }
+
/* documented in superclass */
public int getBufferSize() {
return bufferSize;
}
- /**
+ /**
* Sets the size of the download buffer used for this resource.
- * @param bufferSize the size of the buffer in bytes.
+ *
+ * @param bufferSize
+ * the size of the buffer in bytes.
*/
public void setBufferSize(int bufferSize) {
this.bufferSize = bufferSize;
diff --git a/src/com/itmill/toolkit/terminal/KeyMapper.java b/src/com/itmill/toolkit/terminal/KeyMapper.java
index 871fa10751..59967f2d32 100644
--- a/src/com/itmill/toolkit/terminal/KeyMapper.java
+++ b/src/com/itmill/toolkit/terminal/KeyMapper.java
@@ -1,109 +1,123 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import java.util.Hashtable;
-/**
- * <code>KeyMapper</code> is the simple two-way map for generating textual
+/**
+ * <code>KeyMapper</code> is the simple two-way map for generating textual
* keys for objects and retrieving the objects later with the key.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class KeyMapper {
-
- private int lastKey = 0;
- private Hashtable objectKeyMap = new Hashtable();
- private Hashtable keyObjectMap = new Hashtable();
-
- /**
- * Gets key for an object.
- * @param o the object.
- */
- public String key(Object o) {
-
- if (o == null) return "null";
-
- // If the object is already mapped, use existing key
- String key = (String) objectKeyMap.get(o);
- if (key != null) return key;
-
- // If the object is not yet mapped, map it
- key = String.valueOf(++lastKey);
- objectKeyMap.put(o,key);
- keyObjectMap.put(key,o);
-
- return key;
- }
-
- /**
- * Checks if the key belongs to a new id.
- * <p>Usage of new id:s are specific to components, but for example Select
- * component uses newItemId:s for selection of newly added items in
+
+ private int lastKey = 0;
+
+ private Hashtable objectKeyMap = new Hashtable();
+
+ private Hashtable keyObjectMap = new Hashtable();
+
+ /**
+ * Gets key for an object.
+ *
+ * @param o
+ * the object.
+ */
+ public String key(Object o) {
+
+ if (o == null)
+ return "null";
+
+ // If the object is already mapped, use existing key
+ String key = (String) objectKeyMap.get(o);
+ if (key != null)
+ return key;
+
+ // If the object is not yet mapped, map it
+ key = String.valueOf(++lastKey);
+ objectKeyMap.put(o, key);
+ keyObjectMap.put(key, o);
+
+ return key;
+ }
+
+ /**
+ * Checks if the key belongs to a new id.
+ * <p>
+ * Usage of new id:s are specific to components, but for example Select
+ * component uses newItemId:s for selection of newly added items in
* <code>allowNewItems</code>-mode.
+ *
* @param key
- * @return <code>true</code> if the key belongs to the new id,otherwise <code>false</code>.
- */
+ * @return <code>true</code> if the key belongs to the new id,otherwise
+ * <code>false</code>.
+ */
public boolean isNewIdKey(String key) {
return "NEW".equals(key);
}
-
- /**
- * Retrieves object with the key.
- * @param key the name with the desired value.
- * @return the object with the key.
- */
- public Object get(String key) {
-
- return keyObjectMap.get(key);
- }
-
- /**
- * Removes object from the mapper.
- * @param removeobj the object to be removed.
- */
- public void remove(Object removeobj) {
- String key = (String) objectKeyMap.get(removeobj);
-
- if (key != null) {
- objectKeyMap.remove(key);
- keyObjectMap.remove(removeobj);
- }
- }
-
- /**
- * Removes all objects from the mapper.
- */
- public void removeAll() {
- objectKeyMap.clear();
- keyObjectMap.clear();
- }
+
+ /**
+ * Retrieves object with the key.
+ *
+ * @param key
+ * the name with the desired value.
+ * @return the object with the key.
+ */
+ public Object get(String key) {
+
+ return keyObjectMap.get(key);
+ }
+
+ /**
+ * Removes object from the mapper.
+ *
+ * @param removeobj
+ * the object to be removed.
+ */
+ public void remove(Object removeobj) {
+ String key = (String) objectKeyMap.get(removeobj);
+
+ if (key != null) {
+ objectKeyMap.remove(key);
+ keyObjectMap.remove(removeobj);
+ }
+ }
+
+ /**
+ * Removes all objects from the mapper.
+ */
+ public void removeAll() {
+ objectKeyMap.clear();
+ keyObjectMap.clear();
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/PaintException.java b/src/com/itmill/toolkit/terminal/PaintException.java
index 766e964b22..8d49ebc41e 100644
--- a/src/com/itmill/toolkit/terminal/PaintException.java
+++ b/src/com/itmill/toolkit/terminal/PaintException.java
@@ -1,62 +1,69 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import java.io.IOException;
-/**
+/**
* <code>PaintExcepection</code> is thrown if painting of a component fails.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class PaintException extends IOException {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3762535607221891897L;
-
- /**
- * Constructs an instance of <code>PaintExeception</code> with the specified detail message.
- * @param msg the detail message.
- */
- public PaintException(String msg) {
- super(msg);
- }
-
- /**
- * Constructs an instance of <code>PaintExeception</code> from IOException.
- * @param exception the original exception.
- */
- public PaintException(IOException exception) {
- super(exception.getMessage());
- }
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3762535607221891897L;
+
+ /**
+ * Constructs an instance of <code>PaintExeception</code> with the
+ * specified detail message.
+ *
+ * @param msg
+ * the detail message.
+ */
+ public PaintException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs an instance of <code>PaintExeception</code> from
+ * IOException.
+ *
+ * @param exception
+ * the original exception.
+ */
+ public PaintException(IOException exception) {
+ super(exception.getMessage());
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/PaintTarget.java b/src/com/itmill/toolkit/terminal/PaintTarget.java
index 6202b2c399..e63406c38c 100644
--- a/src/com/itmill/toolkit/terminal/PaintTarget.java
+++ b/src/com/itmill/toolkit/terminal/PaintTarget.java
@@ -1,246 +1,307 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
-/**
- * This interface defines the methods for
- * painting XML to the UIDL stream.
- *
+/**
+ * This interface defines the methods for painting XML to the UIDL stream.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface PaintTarget {
- /**
+ /**
* Prints single XMLsection.
- *
+ *
* Prints full XML section. The section data is escaped from XML tags and
* surrounded by XML start and end-tags.
- * @param sectionTagName the name of the tag.
- * @param sectionData the scetion data.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param sectionTagName
+ * the name of the tag.
+ * @param sectionData
+ * the scetion data.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addSection(String sectionTagName, String sectionData)
- throws PaintException;
-
- /**
- * Prints element start tag of a paintable section.
- * Starts a paintable section using the given tag. The PaintTarget may
- * implement a caching scheme, that checks the paintable has actually
- * changed or can a cached version be used instead. This method should call
- * the startTag method.
+ throws PaintException;
+
+ /**
+ * Prints element start tag of a paintable section. Starts a paintable
+ * section using the given tag. The PaintTarget may implement a caching
+ * scheme, that checks the paintable has actually changed or can a cached
+ * version be used instead. This method should call the startTag method.
* <p>
* If the Paintable is found in cache and this function returns true it may
* omit the content and close the tag, in which case cached content should
* be used.
* </p>
- * @param paintable the paintable to start.
- * @param tag the name of the start tag.
- * @return <code>true</code> if paintable found in cache, <code>false</code> otherwise.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param paintable
+ * the paintable to start.
+ * @param tag
+ * the name of the start tag.
+ * @return <code>true</code> if paintable found in cache,
+ * <code>false</code> otherwise.
+ * @throws PaintException
+ * if the paint operation failed.
* @see #startTag(String)
* @since 3.1
*/
public boolean startTag(Paintable paintable, String tag)
- throws PaintException;
+ throws PaintException;
-
- /**
+ /**
* Prints element start tag.
- *
- * <pre>Todo:
+ *
+ * <pre>
+ * Todo:
* Checking of input values
* </pre>
- *
- * @param tagName the name of the start tag.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param tagName
+ * the name of the start tag.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void startTag(String tagName) throws PaintException;
- /**
+ /**
* Prints element end tag.
- *
- * If the parent tag is closed before
- * every child tag is closed an PaintException is raised.
- *
- * @param tagName the name of the end tag.
- * @throws PaintException if the paint operation failed.
+ *
+ * If the parent tag is closed before every child tag is closed an
+ * PaintException is raised.
+ *
+ * @param tagName
+ * the name of the end tag.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void endTag(String tagName) throws PaintException;
- /**
- * Adds a boolean attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Attribute name.
- * @param value the Attribute value.
+ /**
+ * Adds a boolean attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
*
- * @throws PaintException if the paint operation failed.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addAttribute(String name, boolean value) throws PaintException;
- /**
- * Adds a integer attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Attribute name.
- * @param value the Attribute value.
+ /**
+ * Adds a integer attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
*
- * @throws PaintException if the paint operation failed.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addAttribute(String name, int value) throws PaintException;
- /**
- * Adds a resource attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Attribute name
- * @param value the Attribute value
+ /**
+ * Adds a resource attribute to component. Atributes must be added before
+ * any content is written.
*
- * @throws PaintException if the paint operation failed.
+ * @param name
+ * the Attribute name
+ * @param value
+ * the Attribute value
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
- public void addAttribute(String name, Resource value)
- throws PaintException;
+ public void addAttribute(String name, Resource value) throws PaintException;
- /**
- * Adds a long attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Attribute name.
- * @param value the Attribute value.
+ /**
+ * Adds a long attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
*
- * @throws PaintException if the paint operation failed.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addAttribute(String name, long value) throws PaintException;
- /**
- * Adds a string attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Boolean attribute name.
- * @param value the Boolean attribute value.
+ /**
+ * Adds a string attribute to component. Atributes must be added before any
+ * content is written.
*
- * @throws PaintException if the paint operation failed.
+ * @param name
+ * the Boolean attribute name.
+ * @param value
+ * the Boolean attribute value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addAttribute(String name, String value) throws PaintException;
- /**
+ /**
* Adds a string type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
- * @param value the Variable initial value.
*
- * @throws PaintException if the paint operation failed.
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addVariable(VariableOwner owner, String name, String value)
- throws PaintException;
+ throws PaintException;
- /**
+ /**
* Adds a int type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
- * @param value the Variable initial value.
*
- * @throws PaintException if the paint operation failed.
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addVariable(VariableOwner owner, String name, int value)
- throws PaintException;
+ throws PaintException;
- /**
+ /**
* Adds a boolean type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
- * @param value the Variable initial value.
*
- * @throws PaintException if the paint operation failed.
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addVariable(VariableOwner owner, String name, boolean value)
- throws PaintException;
+ throws PaintException;
- /**
+ /**
* Adds a string array type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
- * @param value the Variable initial value.
*
- * @throws PaintException if the paint operation failed.
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addVariable(VariableOwner owner, String name, String[] value)
- throws PaintException;
+ throws PaintException;
- /**
+ /**
* Adds a upload stream type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
*
- * @throws PaintException if the paint operation failed.
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addUploadStreamVariable(VariableOwner owner, String name)
- throws PaintException;
+ throws PaintException;
- /**
+ /**
* Prints single XML section.
* <p>
* Prints full XML section. The section data must be XML and it is
* surrounded by XML start and end-tags.
* </p>
- * @param sectionTagName the tag name.
- * @param sectionData the section data to be printed.
- * @param namespace the namespace.
- * @throws PaintException if the paint operation failed.
- */
- public void addXMLSection(
- String sectionTagName,
- String sectionData,
- String namespace)
- throws PaintException;
-
- /**
- * Adds UIDL directly.
- * The UIDL must be valid in accordance with the UIDL.dtd
- * @param uidl the UIDL to be added.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param sectionTagName
+ * the tag name.
+ * @param sectionData
+ * the section data to be printed.
+ * @param namespace
+ * the namespace.
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addXMLSection(String sectionTagName, String sectionData,
+ String namespace) throws PaintException;
+
+ /**
+ * Adds UIDL directly. The UIDL must be valid in accordance with the
+ * UIDL.dtd
+ *
+ * @param uidl
+ * the UIDL to be added.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addUIDL(java.lang.String uidl) throws PaintException;
- /**
+ /**
* Adds text node. All the contents of the text are XML-escaped.
- * @param text the Text to add
- * @throws PaintException if the paint operation failed.
+ *
+ * @param text
+ * the Text to add
+ * @throws PaintException
+ * if the paint operation failed.
*/
void addText(String text) throws PaintException;
- /**
+ /**
* Adds CDATA node to target UIDL-tree.
- * @param text the Character data to add
- * @throws PaintException if the paint operation failed.
+ *
+ * @param text
+ * the Character data to add
+ * @throws PaintException
+ * if the paint operation failed.
* @since 3.1
*/
void addCharacterData(String text) throws PaintException;
diff --git a/src/com/itmill/toolkit/terminal/Paintable.java b/src/com/itmill/toolkit/terminal/Paintable.java
index 577964efa4..29e01e0bf5 100644
--- a/src/com/itmill/toolkit/terminal/Paintable.java
+++ b/src/com/itmill/toolkit/terminal/Paintable.java
@@ -1,141 +1,151 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import java.util.EventObject;
-/**
- * Interface implemented by all classes that can be painted.
- * Classes implementing this interface know how to output themselves
- * to a UIDL stream and that way describing to the terminal how it
- * should be displayed in the UI.
- *
+/**
+ * Interface implemented by all classes that can be painted. Classes
+ * implementing this interface know how to output themselves to a UIDL stream
+ * and that way describing to the terminal how it should be displayed in the UI.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Paintable extends java.util.EventListener {
-
- /**
+
+ /**
* <p>
- * Paints the paintable into a UIDL stream. This method creates
- * the UIDL sequence describing it and outputs it to the given UIDL
- * stream.
+ * Paints the paintable into a UIDL stream. This method creates the UIDL
+ * sequence describing it and outputs it to the given UIDL stream.
* </p>
*
* <p>
- * It is called when the contents of the component should be
- * painted in response to the component first being shown or having been
- * altered so that its visual representation is changed.
+ * It is called when the contents of the component should be painted in
+ * response to the component first being shown or having been altered so
+ * that its visual representation is changed.
* </p>
*
- * @param target the target UIDL stream where the component should paint
- * itself to.
- * @throws PaintException if the paint operation failed.
+ * @param target
+ * the target UIDL stream where the component should paint itself
+ * to.
+ * @throws PaintException
+ * if the paint operation failed.
*/
- public void paint(PaintTarget target) throws PaintException;
-
- /**
+ public void paint(PaintTarget target) throws PaintException;
+
+ /**
* Requests that the paintable should be repainted as soon as possible.
*/
public void requestRepaint();
-
- /**
- * Repaint request event is thrown when the paintable needs to be repainted.
- * This is typically done when the <code>paint</code> method would return dissimilar
- * UIDL from the previous call of the method.
+
+ /**
+ * Repaint request event is thrown when the paintable needs to be repainted.
+ * This is typically done when the <code>paint</code> method would return
+ * dissimilar UIDL from the previous call of the method.
*/
public class RepaintRequestEvent extends EventObject {
-
+
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3256725095530442805L;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3256725095530442805L;
- /**
- * Constructs a new event.
- * @param source the paintable needing repaint.
+ /**
+ * Constructs a new event.
+ *
+ * @param source
+ * the paintable needing repaint.
*/
public RepaintRequestEvent(Paintable source) {
- super(source);
+ super(source);
}
-
- /**
- * Gets the paintable needing repainting.
- * @return Paintable for which the <code>paint</code> method will return
- * dissimilar UIDL from the previous call of the method.
+
+ /**
+ * Gets the paintable needing repainting.
+ *
+ * @return Paintable for which the <code>paint</code> method will
+ * return dissimilar UIDL from the previous call of the method.
*/
public Paintable getPaintable() {
- return (Paintable) getSource();
+ return (Paintable) getSource();
}
}
-
- /**
- * Listens repaint requests. The <code>repaintRequested</code> method is called when the
- * paintable needs to be repainted.
- * This is typically done when the <code>paint</code> method would return dissimilar
- * UIDL from the previous call of the method.
+
+ /**
+ * Listens repaint requests. The <code>repaintRequested</code> method is
+ * called when the paintable needs to be repainted. This is typically done
+ * when the <code>paint</code> method would return dissimilar UIDL from
+ * the previous call of the method.
*/
public interface RepaintRequestListener {
- /**
- * Receives repaint request events.
- * @param event the repaint request event specifying the paintable source.
+ /**
+ * Receives repaint request events.
+ *
+ * @param event
+ * the repaint request event specifying the paintable source.
*/
public void repaintRequested(RepaintRequestEvent event);
}
-
- /**
- * Adds repaint request listener. In order to assure that no repaint requests are
- * missed, the new repaint listener should paint the paintable right after adding
- * itself as listener.
- * @param listener the listener to be added.
+
+ /**
+ * Adds repaint request listener. In order to assure that no repaint
+ * requests are missed, the new repaint listener should paint the paintable
+ * right after adding itself as listener.
+ *
+ * @param listener
+ * the listener to be added.
*/
public void addListener(RepaintRequestListener listener);
- /**
- * Removes repaint request listener.
- * @param listener the listener to be removed.
+ /**
+ * Removes repaint request listener.
+ *
+ * @param listener
+ * the listener to be removed.
*/
public void removeListener(RepaintRequestListener listener);
-
- /**
+
+ /**
* Request sending of repaint events on any further visible changes.
- * Normally the paintable only send up to one repaint request
- * for listeners after paint as the paintable as the paintable
- * assumes that the listeners already know about the repaint need.
- * This method resets the assumtion. Paint implicitly does the
- * assumtion reset functionality implemented by this method.
+ * Normally the paintable only send up to one repaint request for listeners
+ * after paint as the paintable as the paintable assumes that the listeners
+ * already know about the repaint need. This method resets the assumtion.
+ * Paint implicitly does the assumtion reset functionality implemented by
+ * this method.
* <p>
- * This method is normally used only by the terminals to note
- * paintables about implicit repaints (painting the component
- * without actually invoking paint method).
+ * This method is normally used only by the terminals to note paintables
+ * about implicit repaints (painting the component without actually invoking
+ * paint method).
* </p>
*/
public void requestRepaintRequests();
diff --git a/src/com/itmill/toolkit/terminal/ParameterHandler.java b/src/com/itmill/toolkit/terminal/ParameterHandler.java
index f46c67e0a4..1f847ae1c0 100644
--- a/src/com/itmill/toolkit/terminal/ParameterHandler.java
+++ b/src/com/itmill/toolkit/terminal/ParameterHandler.java
@@ -1,73 +1,78 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import java.util.Map;
-/**
- * Interface implemented by all the classes capable of handling external parameters.
+/**
+ * Interface implemented by all the classes capable of handling external
+ * parameters.
*
* <p>
* Some terminals can provide external parameters for application. For example
- * GET and POST parameters are passed to application as external parameters on
- * Web Adapter. The parameters can be received at any time during the application
- * lifecycle. All the parameter handlers implementing this interface and registered
- * to {@link com.itmill.toolkit.ui.Window} receive all the parameters got from
- * the terminal in the given window.
+ * GET and POST parameters are passed to application as external parameters on
+ * Web Adapter. The parameters can be received at any time during the
+ * application lifecycle. All the parameter handlers implementing this interface
+ * and registered to {@link com.itmill.toolkit.ui.Window} receive all the
+ * parameters got from the terminal in the given window.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface ParameterHandler {
-
- /**
- * <p>
- * Handles the given parameters. The parameters are given as inmodifieable
- * name to value map. All parameters names are of type: {@link java.lang.String}.
- * All the parameter values are arrays of strings.
- * </p>
- *
- * @param parameters the Inmodifiable name to value[] mapping.
- *
- */
- public void handleParameters(Map parameters);
- /**
- * ParameterHandler error event.
+ /**
+ * <p>
+ * Handles the given parameters. The parameters are given as inmodifieable
+ * name to value map. All parameters names are of type:
+ * {@link java.lang.String}. All the parameter values are arrays of
+ * strings.
+ * </p>
+ *
+ * @param parameters
+ * the Inmodifiable name to value[] mapping.
+ *
+ */
+ public void handleParameters(Map parameters);
+
+ /**
+ * ParameterHandler error event.
*/
public interface ErrorEvent extends Terminal.ErrorEvent {
- /**
+ /**
* Gets the source ParameterHandler.
- * @return the source Parameter Handler.
+ *
+ * @return the source Parameter Handler.
*/
public ParameterHandler getParameterHandler();
diff --git a/src/com/itmill/toolkit/terminal/Resource.java b/src/com/itmill/toolkit/terminal/Resource.java
index 74163b8ef5..28578ee022 100644
--- a/src/com/itmill/toolkit/terminal/Resource.java
+++ b/src/com/itmill/toolkit/terminal/Resource.java
@@ -1,46 +1,48 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
-/**
+/**
* <code>Resource</code> provided to the client terminal. Support for actually
* displaying the resource type is left to the terminal.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Resource {
-
- /**
+
+ /**
* Gets the MIME type of the resource.
- * @return the MIME type of the resource.
+ *
+ * @return the MIME type of the resource.
*/
public String getMIMEType();
}
diff --git a/src/com/itmill/toolkit/terminal/Scrollable.java b/src/com/itmill/toolkit/terminal/Scrollable.java
index dcc1528e66..de88dbce13 100644
--- a/src/com/itmill/toolkit/terminal/Scrollable.java
+++ b/src/com/itmill/toolkit/terminal/Scrollable.java
@@ -1,103 +1,119 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
-/**
+/**
* <p>
- * This interface is implemented by all visual objects that can be scrolled.
- * The unit of scrolling is pixel.
+ * This interface is implemented by all visual objects that can be scrolled. The
+ * unit of scrolling is pixel.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Scrollable {
-
- /**
- * Gets scroll X offset.
+ /**
+ * Gets scroll X offset.
*
- * <p>Scrolling offset is the number of pixels this scrollable has
- * been scrolled to left.</p>
+ * <p>
+ * Scrolling offset is the number of pixels this scrollable has been
+ * scrolled to left.
+ * </p>
*
* @return Horizontal scrolling position in pixels.
*/
public int getScrollOffsetX();
- /**
+ /**
* Sets scroll X offset.
*
- * <p>Scrolling offset is the number of pixels this scrollable has
- * been scrolled to left.</p>
+ * <p>
+ * Scrolling offset is the number of pixels this scrollable has been
+ * scrolled to left.
+ * </p>
*
- * @param pixelsScrolledLeft the xOffset.
+ * @param pixelsScrolledLeft
+ * the xOffset.
*/
public void setScrollOffsetX(int pixelsScrolledLeft);
- /**
- * Gets scroll Y offset.
+ /**
+ * Gets scroll Y offset.
*
- * <p>Scrolling offset is the number of pixels this scrollable has
- * been scrolled to down.</p>
+ * <p>
+ * Scrolling offset is the number of pixels this scrollable has been
+ * scrolled to down.
+ * </p>
*
* @return Vertical scrolling position in pixels.
*/
public int getScrollOffsetY();
- /**
+ /**
* Sets scroll Y offset.
*
- * <p>Scrolling offset is the number of pixels this scrollable has
- * been scrolled to down.</p>
+ * <p>
+ * Scrolling offset is the number of pixels this scrollable has been
+ * scrolled to down.
+ * </p>
*
- * @param pixelsScrolledDown the yOffset.
+ * @param pixelsScrolledDown
+ * the yOffset.
*/
public void setScrollOffsetY(int pixelsScrolledDown);
- /**
+ /**
* Is the scrolling enabled.
*
- * <p>Enabling scrolling allows the user to scroll the scrollable view
- * interactively</p>
+ * <p>
+ * Enabling scrolling allows the user to scroll the scrollable view
+ * interactively
+ * </p>
*
- * @return <code>true</code> if the scrolling is allowed, otherwise <code>false</code>.
+ * @return <code>true</code> if the scrolling is allowed, otherwise
+ * <code>false</code>.
*/
public boolean isScrollable();
- /**
+ /**
* Enables or disables scrolling..
*
- * <p>Enabling scrolling allows the user to scroll the scrollable view
- * interactively</p>
- *
- * @param isScrollingEnabled true if the scrolling is allowed.
+ * <p>
+ * Enabling scrolling allows the user to scroll the scrollable view
+ * interactively
+ * </p>
+ *
+ * @param isScrollingEnabled
+ * true if the scrolling is allowed.
*/
public void setScrollable(boolean isScrollingEnabled);
diff --git a/src/com/itmill/toolkit/terminal/Sizeable.java b/src/com/itmill/toolkit/terminal/Sizeable.java
index 3a191b52f3..8849808df1 100644
--- a/src/com/itmill/toolkit/terminal/Sizeable.java
+++ b/src/com/itmill/toolkit/terminal/Sizeable.java
@@ -1,99 +1,100 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
-/**
- * Interface to be implemented by components wishing to
- * display some object that may be dynamically
- * resized during runtime.
- *
+/**
+ * Interface to be implemented by components wishing to display some object that
+ * may be dynamically resized during runtime.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Sizeable {
- /**
- * Unit code representing pixels.
+ /**
+ * Unit code representing pixels.
*/
public static final int UNITS_PIXELS = 0;
- /**
- * Unit code representing points (1/72nd of an inch).
+ /**
+ * Unit code representing points (1/72nd of an inch).
*/
public static final int UNITS_POINTS = 1;
- /**
- * Unit code representing picas (12 points).
+ /**
+ * Unit code representing picas (12 points).
*/
public static final int UNITS_PICAS = 2;
- /**
- * Unit code representing the font-size of the relevant font.
+ /**
+ * Unit code representing the font-size of the relevant font.
*/
public static final int UNITS_EM = 3;
- /**
- * Unit code representing the x-height of the relevant font.
+ /**
+ * Unit code representing the x-height of the relevant font.
*/
public static final int UNITS_EX = 4;
- /**
- * Unit code representing millimetres.
+ /**
+ * Unit code representing millimetres.
*/
public static final int UNITS_MM = 5;
- /**
- * Unit code representing centimetres.
+ /**
+ * Unit code representing centimetres.
*/
public static final int UNITS_CM = 6;
- /**
- * Unit code representing inches.
+ /**
+ * Unit code representing inches.
*/
public static final int UNITS_INCH = 7;
- /**
- * Unit code representing in percentage of the containing element
- * defined by terminal.
+ /**
+ * Unit code representing in percentage of the containing element defined by
+ * terminal.
*/
public static final int UNITS_PERCENTAGE = 8;
- /**
- * Unit code representing in rows of text. This unit is only applicaple
- * to some components can it's meaning is specified by component implementation.
+ /**
+ * Unit code representing in rows of text. This unit is only applicaple to
+ * some components can it's meaning is specified by component
+ * implementation.
*/
public static final int UNITS_ROWS = 9;
- /**
- * Textual representations of units symbols.
- * Supported units and their symbols are:
+ /**
+ * Textual representations of units symbols. Supported units and their
+ * symbols are:
* <ul>
* <li><code>UNITS_PIXELS</code>: "" (unit is omitted for pixels)</li>
* <li><code>UNITS_POINTS</code>: "pt"</li>
@@ -108,58 +109,72 @@ public interface Sizeable {
* </ul>
* These can be used like <code>Sizeable.UNIT_SYMBOLS[UNITS_PIXELS]</code>.
*/
- public static final String[] UNIT_SYMBOLS =
- { "", "pt", "pc", "em", "ex", "mm", "cm", "in", "%", "rows" };
+ public static final String[] UNIT_SYMBOLS = { "", "pt", "pc", "em", "ex",
+ "mm", "cm", "in", "%", "rows" };
- /**
+ /**
* Gets the width of the object. Negative number implies unspecified size
* (terminal is free to set the size).
+ *
* @return width of the object in units specified by widthUnits property.
*/
public int getWidth();
- /**
+ /**
* Sets the width of the object. Negative number implies unspecified size
* (terminal is free to set the size).
- * @param width the width of the object in units specified by widthUnits property.
+ *
+ * @param width
+ * the width of the object in units specified by widthUnits
+ * property.
*/
public void setWidth(int width);
- /**
+ /**
* Gets the height of the object. Negative number implies unspecified size
* (terminal is free to set the size).
+ *
* @return height of the object in units specified by heightUnits property.
*/
public int getHeight();
- /**
+ /**
* Sets the height of the object. Negative number implies unspecified size
* (terminal is free to set the size).
- * @param height the height of the object in units specified by heightUnits property.
+ *
+ * @param height
+ * the height of the object in units specified by heightUnits
+ * property.
*/
public void setHeight(int height);
- /**
- * Gets the width property units.
+ /**
+ * Gets the width property units.
+ *
* @return units used in width property.
*/
public int getWidthUnits();
- /**
- * Sets the width property units.
- * @param units the units used in width property.
+ /**
+ * Sets the width property units.
+ *
+ * @param units
+ * the units used in width property.
*/
public void setWidthUnits(int units);
- /**
- * Gets the height property units.
+ /**
+ * Gets the height property units.
+ *
* @return units used in height property.
*/
public int getHeightUnits();
- /**
- * Sets the height property units.
- * @param units the units used in height property.
+ /**
+ * Sets the height property units.
+ *
+ * @param units
+ * the units used in height property.
*/
public void setHeightUnits(int units);
diff --git a/src/com/itmill/toolkit/terminal/StreamResource.java b/src/com/itmill/toolkit/terminal/StreamResource.java
index dfefe72d15..d7a467d95a 100644
--- a/src/com/itmill/toolkit/terminal/StreamResource.java
+++ b/src/com/itmill/toolkit/terminal/StreamResource.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
@@ -33,58 +33,61 @@ import java.io.InputStream;
import com.itmill.toolkit.Application;
import com.itmill.toolkit.service.FileTypeResolver;
-/**
+/**
* <code>StreamResource</code> is a resource provided to the client directly
- * by the application. The strean resource is fetched from URI
- * that is most often in the context of the application or window.
- * The resource is automatically registered to window in creation.
+ * by the application. The strean resource is fetched from URI that is most
+ * often in the context of the application or window. The resource is
+ * automatically registered to window in creation.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class StreamResource implements ApplicationResource {
- /**
- * Source stream the downloaded content is fetched from.
+ /**
+ * Source stream the downloaded content is fetched from.
*/
private StreamSource streamSource = null;
- /**
- * Explicit mime-type.
+ /**
+ * Explicit mime-type.
*/
private String MIMEType = null;
/**
- * Filename.
+ * Filename.
*/
private String filename;
- /**
- * Application.
+ /**
+ * Application.
*/
private Application application;
- /**
- * Default buffer size for this stream resource.
+ /**
+ * Default buffer size for this stream resource.
*/
private int bufferSize = 0;
- /**
- * Default cache time for this stream resource.
+ /**
+ * Default cache time for this stream resource.
*/
- private long cacheTime = DEFAULT_CACHETIME;
+ private long cacheTime = DEFAULT_CACHETIME;
- /**
+ /**
* Creates a new stream resource for downloading from stream.
- * @param streamSource the source Stream.
- * @param filename the name of the file.
- * @param application the Application object.
+ *
+ * @param streamSource
+ * the source Stream.
+ * @param filename
+ * the name of the file.
+ * @param application
+ * the Application object.
*/
- public StreamResource(
- StreamSource streamSource,
- String filename,
- Application application) {
+ public StreamResource(StreamSource streamSource, String filename,
+ Application application) {
this.application = application;
setFilename(filename);
@@ -94,6 +97,7 @@ public class StreamResource implements ApplicationResource {
application.addResource(this);
}
+
/**
* @see com.itmill.toolkit.terminal.Resource#getMIMEType()
*/
@@ -103,18 +107,20 @@ public class StreamResource implements ApplicationResource {
return FileTypeResolver.getMIMEType(filename);
}
- /**
+ /**
* Sets the mime type of the resource.
- * @param MIMEType the MIME type to be set.
+ *
+ * @param MIMEType
+ * the MIME type to be set.
*/
public void setMIMEType(String MIMEType) {
this.MIMEType = MIMEType;
}
- /**
- * Returns the source for this <code>StreamResource</code>.
- * StreamSource is queried when the resource is about to be streamed
- * to the client.
+ /**
+ * Returns the source for this <code>StreamResource</code>. StreamSource
+ * is queried when the resource is about to be streamed to the client.
+ *
* @return Source of the StreamResource.
*/
public StreamSource getStreamSource() {
@@ -123,25 +129,30 @@ public class StreamResource implements ApplicationResource {
/**
* Sets the source for this <code>StreamResource</code>.
- * <code>StreamSource</code> is queried when the resource is about to be streamed
- * to the client.
- * @param streamSource the source to set.
+ * <code>StreamSource</code> is queried when the resource is about to be
+ * streamed to the client.
+ *
+ * @param streamSource
+ * the source to set.
*/
public void setStreamSource(StreamSource streamSource) {
this.streamSource = streamSource;
}
- /**
+ /**
* Gets the filename.
+ *
* @return the filename.
*/
public String getFilename() {
return filename;
}
- /**
+ /**
* Sets the filename.
- * @param filename the filename to set.
+ *
+ * @param filename
+ * the filename to set.
*/
public void setFilename(String filename) {
this.filename = filename;
@@ -161,23 +172,25 @@ public class StreamResource implements ApplicationResource {
StreamSource ss = getStreamSource();
if (ss == null)
return null;
- DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename());
+ DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(),
+ getFilename());
ds.setBufferSize(getBufferSize());
ds.setCacheTime(cacheTime);
return ds;
}
- /**
+ /**
* Interface implemented by the source of a StreamResource.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
+ * @version
+ * @VERSION@
+ * @since 3.0
*/
public interface StreamSource {
- /**
- * Returns new input stream that is used for reading
- * the resource.
+ /**
+ * Returns new input stream that is used for reading the resource.
*/
public InputStream getStream();
}
@@ -187,9 +200,11 @@ public class StreamResource implements ApplicationResource {
return bufferSize;
}
- /**
+ /**
* Sets the size of the download buffer used for this resource.
- * @param bufferSize the size of the buffer in bytes.
+ *
+ * @param bufferSize
+ * the size of the buffer in bytes.
*/
public void setBufferSize(int bufferSize) {
this.bufferSize = bufferSize;
@@ -200,15 +215,18 @@ public class StreamResource implements ApplicationResource {
return cacheTime;
}
- /**
+ /**
* Sets the length of cache expiration time.
*
- * <p>This gives the adapter the possibility cache streams sent to the
- * client. The caching may be made in adapter or at the client if the
- * client supports caching. Zero or negavive value disbales the
- * caching of this stream.</p>
+ * <p>
+ * This gives the adapter the possibility cache streams sent to the client.
+ * The caching may be made in adapter or at the client if the client
+ * supports caching. Zero or negavive value disbales the caching of this
+ * stream.
+ * </p>
*
- * @param cacheTime the cache time in milliseconds.
+ * @param cacheTime
+ * the cache time in milliseconds.
*
*/
public void setCacheTime(long cacheTime) {
diff --git a/src/com/itmill/toolkit/terminal/SystemError.java b/src/com/itmill/toolkit/terminal/SystemError.java
index 617bfe43b4..1e3f9fa8a9 100644
--- a/src/com/itmill/toolkit/terminal/SystemError.java
+++ b/src/com/itmill/toolkit/terminal/SystemError.java
@@ -1,91 +1,100 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import java.io.PrintWriter;
import java.io.StringWriter;
-/**
- * <code>SystemError</code> is a runtime exception caused by error in system. The system
- * error can be shown to the user as it implements <code>ErrorMessage</code> interface,
- * but contains technical information such as stack trace and exception.
- *
+/**
+ * <code>SystemError</code> is a runtime exception caused by error in system.
+ * The system error can be shown to the user as it implements
+ * <code>ErrorMessage</code> interface, but contains technical information
+ * such as stack trace and exception.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class SystemError extends RuntimeException implements ErrorMessage {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3256445789512675891L;
-
- /**
- * The cause of the system error. The cause is stored separately as
- * JDK 1.3 does not support causes natively.
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3256445789512675891L;
+
+ /**
+ * The cause of the system error. The cause is stored separately as JDK 1.3
+ * does not support causes natively.
*/
private Throwable cause = null;
- /**
+ /**
* Constructor for SystemError with error message specified.
- * @param message the Textual error description.
+ *
+ * @param message
+ * the Textual error description.
*/
public SystemError(String message) {
super(message);
}
- /**
+ /**
* Constructor for SystemError with causing exception and error message.
- * @param message the Textual error description.
- * @param cause the throwable causing the system error.
+ *
+ * @param message
+ * the Textual error description.
+ * @param cause
+ * the throwable causing the system error.
*/
public SystemError(String message, Throwable cause) {
super(message);
this.cause = cause;
}
- /**
+ /**
* Constructor for SystemError with cause.
- * @param cause the throwable causing the system error.
+ *
+ * @param cause
+ * the throwable causing the system error.
*/
public SystemError(Throwable cause) {
this.cause = cause;
}
-
+
/**
* @see com.itmill.toolkit.terminal.ErrorMessage#getErrorLevel()
*/
public final int getErrorLevel() {
return ErrorMessage.SYSTEMERROR;
}
-
+
/**
* @see com.itmill.toolkit.terminal.Paintable#paint(com.itmill.toolkit.terminal.PaintTarget)
*/
@@ -102,7 +111,7 @@ public class SystemError extends RuntimeException implements ErrorMessage {
// Paint the exception
if (cause != null) {
- if (message != null)
+ if (message != null)
target.addUIDL("<br/><br/>");
target.addSection("b", "Exception");
target.addUIDL("<br/><br/>");
@@ -112,11 +121,12 @@ public class SystemError extends RuntimeException implements ErrorMessage {
}
target.endTag("error");
-
+
}
/**
* Gets cause for the error.
+ *
* @return the cause.
* @see java.lang.Throwable#getCause()
*/
diff --git a/src/com/itmill/toolkit/terminal/Terminal.java b/src/com/itmill/toolkit/terminal/Terminal.java
index d1ab02239e..e8054d2e88 100644
--- a/src/com/itmill/toolkit/terminal/Terminal.java
+++ b/src/com/itmill/toolkit/terminal/Terminal.java
@@ -1,82 +1,87 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
-/**
+/**
* Interface for different terminal types.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Terminal {
-
-
- /**
- * Gets the name of the default theme.
- * @return the Name of the terminal window.
- */
- public String getDefaultTheme();
-
- /**
- * Gets the width of the terminal window in pixels.
- * @return the Width of the terminal window.
- */
- public int getScreenWidth();
-
- /**
- * Gets the height of the terminal window in pixels.
- * @return the Height of the terminal window.
- */
- public int getScreenHeight();
-
- /**
- * Terminal error event.
+
+ /**
+ * Gets the name of the default theme.
+ *
+ * @return the Name of the terminal window.
+ */
+ public String getDefaultTheme();
+
+ /**
+ * Gets the width of the terminal window in pixels.
+ *
+ * @return the Width of the terminal window.
+ */
+ public int getScreenWidth();
+
+ /**
+ * Gets the height of the terminal window in pixels.
+ *
+ * @return the Height of the terminal window.
+ */
+ public int getScreenHeight();
+
+ /**
+ * Terminal error event.
*/
public interface ErrorEvent {
- /**
- * Gets the contained throwable.
+ /**
+ * Gets the contained throwable.
*/
public Throwable getThrowable();
}
- /**
- * Terminal error listener interface.
+ /**
+ * Terminal error listener interface.
*/
public interface ErrorListener {
- /**
+ /**
* Invoked when terminal error occurs.
- * @param event the fired event.
+ *
+ * @param event
+ * the fired event.
*/
public void terminalError(Terminal.ErrorEvent event);
- }
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/ThemeResource.java b/src/com/itmill/toolkit/terminal/ThemeResource.java
index 5215ade6ab..566e5b71ab 100644
--- a/src/com/itmill/toolkit/terminal/ThemeResource.java
+++ b/src/com/itmill/toolkit/terminal/ThemeResource.java
@@ -1,105 +1,108 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import com.itmill.toolkit.service.FileTypeResolver;
-/**
- * <code>ThemeResource</code> is a named theme dependant resource provided and
- * managed by a theme. The actual resource contents are dynamically
- * resolved to comply with the used theme by the terminal adapter.
- * This is commonly used to provide static images, flash,
- * java-applets, etc for the terminals.
- *
+/**
+ * <code>ThemeResource</code> is a named theme dependant resource provided and
+ * managed by a theme. The actual resource contents are dynamically resolved to
+ * comply with the used theme by the terminal adapter. This is commonly used to
+ * provide static images, flash, java-applets, etc for the terminals.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class ThemeResource implements Resource {
- /**
- * Id of the terminal managed resource.
+ /**
+ * Id of the terminal managed resource.
*/
- private String resourceID = null;
+ private String resourceID = null;
- /**
- * Creates a resource.
- * @param resourceId the Id of the resource.
+ /**
+ * Creates a resource.
+ *
+ * @param resourceId
+ * the Id of the resource.
*/
public ThemeResource(String resourceId) {
- if (resourceId == null)
+ if (resourceId == null)
throw new NullPointerException("Resource ID must not be null");
if (resourceId.length() == 0)
- throw new IllegalArgumentException(
- "Resource ID can not be empty");
+ throw new IllegalArgumentException("Resource ID can not be empty");
if (resourceId.charAt(0) == '/')
throw new IllegalArgumentException(
- "Resource ID must be relative (can not begin with /)");
-
+ "Resource ID must be relative (can not begin with /)");
+
this.resourceID = resourceId;
}
- /**
+ /**
* Tests if the given object equals this Resource.
*
- * @param obj the object to be tested for equality.
+ * @param obj
+ * the object to be tested for equality.
* @return <code>true</code> if the given object equals this Icon,
- * <code>false</code> if not.
+ * <code>false</code> if not.
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object obj) {
- return obj instanceof ThemeResource &&
- resourceID.equals(((ThemeResource)obj).resourceID);
+ return obj instanceof ThemeResource
+ && resourceID.equals(((ThemeResource) obj).resourceID);
}
- /**
+ /**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return resourceID.hashCode();
}
-
+
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return resourceID.toString();
}
-
- /**
+
+ /**
* Gets the resource id.
- * @return the resource id.
+ *
+ * @return the resource id.
*/
public String getResourceId() {
- return resourceID;
+ return resourceID;
}
-
+
/**
* @see com.itmill.toolkit.terminal.Resource#getMIMEType()
*/
diff --git a/src/com/itmill/toolkit/terminal/URIHandler.java b/src/com/itmill/toolkit/terminal/URIHandler.java
index 1030743e6a..9883606c2a 100644
--- a/src/com/itmill/toolkit/terminal/URIHandler.java
+++ b/src/com/itmill/toolkit/terminal/URIHandler.java
@@ -1,66 +1,71 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import java.net.URL;
-/**
+/**
* Interface implemented by all the classes capable of handling URI:s.
*
* <p>
- * <code>URIHandler</code> can provide <code>DownloadStream</code>
- * for transferring data for client.
+ * <code>URIHandler</code> can provide <code>DownloadStream</code> for
+ * transferring data for client.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface URIHandler {
-
- /**
- * Handles a given relative URI. If the URI handling wants to emit
- * a downloadable stream it can return download stream object. If no
- * emitting stream is necessary, null should be returned instead.
- * @param context the URl.
- * @param relativeUri the relative uri.
- * @return the download stream object.
- */
- public DownloadStream handleURI(URL context, String relativeUri);
- /**
- * URIHandler error event.
+ /**
+ * Handles a given relative URI. If the URI handling wants to emit a
+ * downloadable stream it can return download stream object. If no emitting
+ * stream is necessary, null should be returned instead.
+ *
+ * @param context
+ * the URl.
+ * @param relativeUri
+ * the relative uri.
+ * @return the download stream object.
+ */
+ public DownloadStream handleURI(URL context, String relativeUri);
+
+ /**
+ * URIHandler error event.
*/
public interface ErrorEvent extends Terminal.ErrorEvent {
- /**
- * Gets the source URIHandler.
+ /**
+ * Gets the source URIHandler.
+ *
* @return the URIHandler.
*/
public URIHandler getURIHandler();
diff --git a/src/com/itmill/toolkit/terminal/UploadStream.java b/src/com/itmill/toolkit/terminal/UploadStream.java
index 5877800233..5a63ac4139 100644
--- a/src/com/itmill/toolkit/terminal/UploadStream.java
+++ b/src/com/itmill/toolkit/terminal/UploadStream.java
@@ -1,69 +1,73 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import java.io.InputStream;
-/**
+/**
* Defines a variable type, that is used for passing uploaded files from
- * terminal. Most often, file upload is implented using the
+ * terminal. Most often, file upload is implented using the
* {@link com.itmill.toolkit.ui.Upload Upload} component.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public interface UploadStream {
-
- /**
- * Gets the name of the stream.
- * @return the name of the stream.
- */
- public String getStreamName();
-
- /**
- * Gets the input stream.
- * @return the Input stream.
- */
- public InputStream getStream();
+public interface UploadStream {
+
+ /**
+ * Gets the name of the stream.
+ *
+ * @return the name of the stream.
+ */
+ public String getStreamName();
+
+ /**
+ * Gets the input stream.
+ *
+ * @return the Input stream.
+ */
+ public InputStream getStream();
+
+ /**
+ * Gets the input stream content type.
+ *
+ * @return the content type of the input stream.
+ */
+ public String getContentType();
- /**
- * Gets the input stream content type.
- * @return the content type of the input stream.
- */
- public String getContentType();
-
- /**
- * Gets stream content name.
- * Stream content name usually differs from the actual stream name.
- * It is used to identify the content of the stream.
- * @return the Name of the stream content.
- */
- public String getContentName();
+ /**
+ * Gets stream content name. Stream content name usually differs from the
+ * actual stream name. It is used to identify the content of the stream.
+ *
+ * @return the Name of the stream content.
+ */
+ public String getContentName();
}
diff --git a/src/com/itmill/toolkit/terminal/UserError.java b/src/com/itmill/toolkit/terminal/UserError.java
index e1bd1ed6b3..53b44fded8 100644
--- a/src/com/itmill/toolkit/terminal/UserError.java
+++ b/src/com/itmill/toolkit/terminal/UserError.java
@@ -1,95 +1,101 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
-/**
- * <code>UserError</code> is a controlled error occurred in application. User errors
- * are occur in normal usage of the application and guide the user.
- *
+/**
+ * <code>UserError</code> is a controlled error occurred in application. User
+ * errors are occur in normal usage of the application and guide the user.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class UserError implements ErrorMessage {
- /**
- * Content mode, where the error contains only plain text.
+ /**
+ * Content mode, where the error contains only plain text.
*/
public static final int CONTENT_TEXT = 0;
- /**
+ /**
* Content mode, where the error contains preformatted text.
*/
public static final int CONTENT_PREFORMATTED = 1;
- /**
- * Formatted content mode, where the contents is XML restricted to the
- * UIDL 1.0 formatting markups.
+ /**
+ * Formatted content mode, where the contents is XML restricted to the UIDL
+ * 1.0 formatting markups.
*/
public static final int CONTENT_UIDL = 2;
- /**
- * Content mode.
+ /**
+ * Content mode.
*/
private int mode = CONTENT_TEXT;
- /**
- * Message in content mode.
+ /**
+ * Message in content mode.
*/
private String msg;
- /**
- * Error level.
+ /**
+ * Error level.
*/
private int level = ErrorMessage.ERROR;
- /**
+ /**
* Creates a textual error message of level ERROR.
*
- * @param textErrorMessage the text of the error message.
+ * @param textErrorMessage
+ * the text of the error message.
*/
public UserError(String textErrorMessage) {
this.msg = textErrorMessage;
}
- /**
+ /**
* Creates a error message with level and content mode.
- * @param message the error message.
- * @param contentMode the content Mode.
- * @param errorLevel the level of error.
+ *
+ * @param message
+ * the error message.
+ * @param contentMode
+ * the content Mode.
+ * @param errorLevel
+ * the level of error.
*/
public UserError(String message, int contentMode, int errorLevel) {
// Check the parameters
if (contentMode < 0 || contentMode > 2)
throw new java.lang.IllegalArgumentException(
- "Unsupported content mode: " + contentMode);
+ "Unsupported content mode: " + contentMode);
this.msg = message;
this.mode = contentMode;
@@ -132,16 +138,16 @@ public class UserError implements ErrorMessage {
// Paint the message
switch (mode) {
- case CONTENT_TEXT :
- target.addText(msg);
- break;
- case CONTENT_UIDL :
- target.addUIDL(msg);
- break;
- case CONTENT_PREFORMATTED :
- target.startTag("pre");
- target.addText(msg);
- target.endTag("pre");
+ case CONTENT_TEXT:
+ target.addText(msg);
+ break;
+ case CONTENT_UIDL:
+ target.addUIDL(msg);
+ break;
+ case CONTENT_PREFORMATTED:
+ target.startTag("pre");
+ target.addText(msg);
+ target.endTag("pre");
}
target.endTag("error");
@@ -150,7 +156,7 @@ public class UserError implements ErrorMessage {
/* Documenten in interface */
public void requestRepaintRequests() {
}
-
+
/* Documented in superclass */
public String toString() {
return msg;
diff --git a/src/com/itmill/toolkit/terminal/VariableOwner.java b/src/com/itmill/toolkit/terminal/VariableOwner.java
index a56460c517..4564ceec58 100644
--- a/src/com/itmill/toolkit/terminal/VariableOwner.java
+++ b/src/com/itmill/toolkit/terminal/VariableOwner.java
@@ -1,128 +1,132 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal;
import java.util.Map;
import java.util.Set;
-/**
+/**
* <p>
- * Listener interface for UI variable changes. The user communicates
- * with the application using the so-called <i>variables</i>. When the user
- * makes a change using the UI the terminal trasmits the changed variables
- * to the application, and the components owning those variables may then
- * process those changes.
+ * Listener interface for UI variable changes. The user communicates with the
+ * application using the so-called <i>variables</i>. When the user makes a
+ * change using the UI the terminal trasmits the changed variables to the
+ * application, and the components owning those variables may then process those
+ * changes.
* </p>
*
* <p>
- * The variable-owning components can be linked with <i>dependency
- * relationships</i>. A dependency between two components means that all
- * variable change events to the depended component will be handled
- * before any such events to the depending component.
+ * The variable-owning components can be linked with <i>dependency relationships</i>.
+ * A dependency between two components means that all variable change events to
+ * the depended component will be handled before any such events to the
+ * depending component.
* </p>
*
* <p>
- * For example, the commit button for a text field will depend on that
- * text field. This is because we want to handle any pending changes the
- * user makes to the contents on the text field before we accept the
- * click of the commit button which starts processing the text field
- * contents.
+ * For example, the commit button for a text field will depend on that text
+ * field. This is because we want to handle any pending changes the user makes
+ * to the contents on the text field before we accept the click of the commit
+ * button which starts processing the text field contents.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface VariableOwner {
-
- /**
- * Gets the variable change listeners this <code>VariableOwner</code>
- * directly depends on. This list does not contain any indirect
- * dependencies, for example, if A depends on B and B depends on C,
- * the dependency list of A does not include C.
- *
- * @return Set of <code>VariableOwners</code> this component directly
- * depend on, <code>null</code> if this component does not depend on
- * anybody.
- */
- public Set getDirectDependencies();
-
- /**
- * Called when one or more variables handled by the implementing class
- * are changed.
- *
- * @param source the Source of the variable change. This is the origin of the
- * event. For example in Web Adapter this is the request.
- * @param variables the Mapping from variable names to new variable values.
- */
- public void changeVariables(Object source, Map variables);
-
- /**
- * Makes this <code>VariableOwner</code> depend on the given
- * <code>VariableOwner</code>. This means that any variable change
- * events relating to <code>depended</code> must be sent before any
- * such events that relate to this object.
- *
- * @param depended the <code>VariableOwner</code> component who
- * this component depends on.
- */
- public void dependsOn(VariableOwner depended);
-
- /**
- * Removes the given component from this component's dependency list.
- * After the call this component will no longer depend on
- * <code>depended</code> wdepende direct dependency from the component.
- * Indirect dependencies are not removed.
- *
- * @param depended the component to be removed from this component's
- * dependency list.
- */
- public void removeDirectDependency(VariableOwner depended);
-
- /**
+
+ /**
+ * Gets the variable change listeners this <code>VariableOwner</code>
+ * directly depends on. This list does not contain any indirect
+ * dependencies, for example, if A depends on B and B depends on C, the
+ * dependency list of A does not include C.
+ *
+ * @return Set of <code>VariableOwners</code> this component directly
+ * depend on, <code>null</code> if this component does not depend
+ * on anybody.
+ */
+ public Set getDirectDependencies();
+
+ /**
+ * Called when one or more variables handled by the implementing class are
+ * changed.
+ *
+ * @param source
+ * the Source of the variable change. This is the origin of the
+ * event. For example in Web Adapter this is the request.
+ * @param variables
+ * the Mapping from variable names to new variable values.
+ */
+ public void changeVariables(Object source, Map variables);
+
+ /**
+ * Makes this <code>VariableOwner</code> depend on the given
+ * <code>VariableOwner</code>. This means that any variable change events
+ * relating to <code>depended</code> must be sent before any such events
+ * that relate to this object.
+ *
+ * @param depended
+ * the <code>VariableOwner</code> component who this component
+ * depends on.
+ */
+ public void dependsOn(VariableOwner depended);
+
+ /**
+ * Removes the given component from this component's dependency list. After
+ * the call this component will no longer depend on <code>depended</code>
+ * wdepende direct dependency from the component. Indirect dependencies are
+ * not removed.
+ *
+ * @param depended
+ * the component to be removed from this component's dependency
+ * list.
+ */
+ public void removeDirectDependency(VariableOwner depended);
+
+ /**
* <p>
- * Tests if the variable owner is enabled or not. The terminal
- * should not send any variable changes to disabled variable owners.
+ * Tests if the variable owner is enabled or not. The terminal should not
+ * send any variable changes to disabled variable owners.
* </p>
*
* @return <code>true</code> if the variable owner is enabled,
- * <code>false</code> if not
+ * <code>false</code> if not
*/
public boolean isEnabled();
- /**
+ /**
* <p>
* Tests if the variable owner is in immediate mode or not. Being in
* immediate mode means that all variable changes are required to be sent
* back from the terminal immediately when they occur.
* </p>
- *
+ *
* <p>
* <strong>Note:</strong> <code>VariableOwner</code> does not include a
* set- method for the immediateness property. This is because not all
@@ -130,20 +134,21 @@ public interface VariableOwner {
* never in the immediate mode, thus they always return <code>false</code>
* in {@link #isImmediate()}.
* </p>
- *
+ *
* @return <code>true</code> if the component is in immediate mode,
- * <code>false</code> if not.
+ * <code>false</code> if not.
*/
public boolean isImmediate();
-
- /**
- * VariableOwner error event.
+
+ /**
+ * VariableOwner error event.
*/
public interface ErrorEvent extends Terminal.ErrorEvent {
- /**
+ /**
* Gets the source VariableOwner.
- * @return the variable owner.
+ *
+ * @return the variable owner.
*/
public VariableOwner getVariableOwner();
diff --git a/src/com/itmill/toolkit/terminal/web/AjaxApplicationManager.java b/src/com/itmill/toolkit/terminal/web/AjaxApplicationManager.java
index 2e43005574..29270595cf 100644
--- a/src/com/itmill/toolkit/terminal/web/AjaxApplicationManager.java
+++ b/src/com/itmill/toolkit/terminal/web/AjaxApplicationManager.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -61,635 +61,652 @@ import com.itmill.toolkit.ui.Component;
import com.itmill.toolkit.ui.FrameWindow;
import com.itmill.toolkit.ui.Window;
-/**
- * Application manager processes changes and paints for single
- * application instance.
+/**
+ * Application manager processes changes and paints for single application
+ * instance.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.1
*/
-public class AjaxApplicationManager implements Paintable.RepaintRequestListener,
- Application.WindowAttachListener, Application.WindowDetachListener {
+public class AjaxApplicationManager implements
+ Paintable.RepaintRequestListener, Application.WindowAttachListener,
+ Application.WindowDetachListener {
- private static String GET_PARAM_REPAINT_ALL = "repaintAll";
+ private static String GET_PARAM_REPAINT_ALL = "repaintAll";
- private static int DEFAULT_BUFFER_SIZE = 32 * 1024;
+ private static int DEFAULT_BUFFER_SIZE = 32 * 1024;
- private static int MAX_BUFFER_SIZE = 64 * 1024;
+ private static int MAX_BUFFER_SIZE = 64 * 1024;
- private WeakHashMap applicationToVariableMapMap = new WeakHashMap();
+ private WeakHashMap applicationToVariableMapMap = new WeakHashMap();
- private HashSet dirtyPaintabletSet = new HashSet();
+ private HashSet dirtyPaintabletSet = new HashSet();
- private WeakHashMap paintableIdMap = new WeakHashMap();
+ private WeakHashMap paintableIdMap = new WeakHashMap();
- private int idSequence = 0;
+ private int idSequence = 0;
- private Application application;
+ private Application application;
- private Set removedWindows = new HashSet();
+ private Set removedWindows = new HashSet();
- private AjaxPaintTarget paintTarget;
+ private AjaxPaintTarget paintTarget;
- public AjaxApplicationManager(Application application) {
- this.application = application;
- }
-
-/**
- *
- * @return
- */
- private AjaxVariableMap getVariableMap() {
- AjaxVariableMap vm = (AjaxVariableMap) applicationToVariableMapMap
- .get(application);
- if (vm == null) {
- vm = new AjaxVariableMap();
- applicationToVariableMapMap.put(application, vm);
- }
- return vm;
- }
-
-/**
- *
- *
- */
- public void takeControl() {
- application.addListener((Application.WindowAttachListener) this);
- application.addListener((Application.WindowDetachListener) this);
+ public AjaxApplicationManager(Application application) {
+ this.application = application;
+ }
+
+ /**
+ *
+ * @return
+ */
+ private AjaxVariableMap getVariableMap() {
+ AjaxVariableMap vm = (AjaxVariableMap) applicationToVariableMapMap
+ .get(application);
+ if (vm == null) {
+ vm = new AjaxVariableMap();
+ applicationToVariableMapMap.put(application, vm);
+ }
+ return vm;
+ }
+
+ /**
+ *
+ *
+ */
+ public void takeControl() {
+ application.addListener((Application.WindowAttachListener) this);
+ application.addListener((Application.WindowDetachListener) this);
+
+ }
+
+ /**
+ *
+ *
+ */
+ public void releaseControl() {
+ application.removeListener((Application.WindowAttachListener) this);
+ application.removeListener((Application.WindowDetachListener) this);
+ }
+
+ /**
+ *
+ * @param request
+ * the HTTP Request.
+ * @param response
+ * the HTTP Response.
+ * @throws IOException
+ * if the writing failed due to input/output error.
+ */
+ public void handleUidlRequest(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+
+ // repaint requested or sesssion has timed out and new one is created
+ boolean repaintAll = (request.getParameter(GET_PARAM_REPAINT_ALL) != null)
+ || request.getSession().isNew();
+
+ OutputStream out = response.getOutputStream();
+ try {
+
+ // Is this a download request from application
+ DownloadStream download = null;
+
+ // The rest of the process is synchronized with the application
+ // in order to guarantee that no parallel variable handling is
+ // made
+ synchronized (application) {
+
+ // Change all variables based on request parameters
+ Map unhandledParameters = getVariableMap().handleVariables(
+ request, application);
+
+ // Handles the URI if the application is still running
+ if (application.isRunning())
+ download = handleURI(application, request, response);
+
+ // If this is not a download request
+ if (download == null) {
+
+ // Finds the window within the application
+ Window window = null;
+ if (application.isRunning())
+ window = getApplicationWindow(request, application);
+
+ // Handles the unhandled parameters if the application is
+ // still running
+ if (window != null && unhandledParameters != null
+ && !unhandledParameters.isEmpty())
+ window.handleParameters(unhandledParameters);
+
+ // Removes application if it has stopped
+ if (!application.isRunning()) {
+ endApplication(request, response, application);
+ return;
+ }
+
+ // Returns if no window found
+ if (window == null)
+ return;
+
+ // Sets the response type
+ response.setContentType("application/xml; charset=UTF-8");
+
+ paintTarget = new AjaxPaintTarget(getVariableMap(), this,
+ out);
+
+ // Render the removed windows
+ Set removed = new HashSet(getRemovedWindows());
+ if (removed.size() > 0) {
+ for (Iterator i = removed.iterator(); i.hasNext();) {
+ Window w = (Window) i.next();
+ paintTarget.startTag("change");
+ paintTarget.addAttribute("format", "uidl");
+ String pid = getPaintableId(w);
+ paintTarget.addAttribute("pid", pid);
+ paintTarget.addAttribute("windowname", w.getName());
+ paintTarget.addAttribute("visible", false);
+ paintTarget.endTag("change");
+ removedWindowNotified(w);
+
+ }
+ }
+
+ // Paints components
+ Set paintables;
+ if (repaintAll) {
+ paintables = new LinkedHashSet();
+ paintables.add(window);
+
+ // Adds all non-native windows
+ for (Iterator i = window.getApplication().getWindows()
+ .iterator(); i.hasNext();) {
+ Window w = (Window) i.next();
+ if (!"native".equals(w.getStyle()) && w != window)
+ paintables.add(w);
+ }
+ } else
+ paintables = getDirtyComponents();
+ if (paintables != null) {
+
+ // Creates "working copy" of the current state.
+ List currentPaintables = new ArrayList(paintables);
+
+ // Sorts the paintable so that parent windows
+ // are always painted before child windows
+ Collections.sort(currentPaintables, new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+
+ // If first argumement is now window
+ // the second is "smaller" if it is.
+ if (!(o1 instanceof Window)) {
+ return (o2 instanceof Window) ? 1 : 0;
+ }
+
+ // Now, if second is not window the
+ // first is smaller.
+ if (!(o2 instanceof Window)) {
+ return -1;
+ }
+
+ // Both are windows.
+ String n1 = ((Window) o1).getName();
+ String n2 = ((Window) o2).getName();
+ if (o1 instanceof FrameWindow) {
+ if (((FrameWindow) o1).getFrameset()
+ .getFrame(n2) != null) {
+ return -1;
+ } else if (!(o2 instanceof FrameWindow)) {
+ return -1;
+ }
+ }
+ if (o2 instanceof FrameWindow) {
+ if (((FrameWindow) o2).getFrameset()
+ .getFrame(n1) != null) {
+ return 1;
+ } else if (!(o1 instanceof FrameWindow)) {
+ return 1;
+ }
+ }
+
+ return 0;
+ }
+ });
+
+ for (Iterator i = currentPaintables.iterator(); i
+ .hasNext();) {
+ Paintable p = (Paintable) i.next();
+
+ // TODO CLEAN
+ if (p instanceof Window) {
+ Window w = (Window) p;
+ if (w.getTerminal() == null)
+ w.setTerminal(application.getMainWindow()
+ .getTerminal());
+ }
+
+ paintTarget.startTag("change");
+ paintTarget.addAttribute("format", "uidl");
+ String pid = getPaintableId(p);
+ paintTarget.addAttribute("pid", pid);
+
+ // Track paints to identify empty paints
+ paintTarget.setTrackPaints(true);
+ p.paint(paintTarget);
+
+ // If no paints add attribute empty
+ if (paintTarget.getNumberOfPaints() <= 0) {
+ paintTarget.addAttribute("visible", false);
+ }
+ paintTarget.endTag("change");
+ paintablePainted(p);
+ }
+ }
+
+ // add meta instruction for client to set focus if it is set
+ Paintable f = (Paintable) application.consumeFocus();
+ if (f != null) {
+ paintTarget.startTag("meta");
+ paintTarget.startTag("focus");
+ paintTarget.addAttribute("pid", getPaintableId(f));
+ paintTarget.endTag("focus");
+ paintTarget.endTag("meta");
+ }
+
+ paintTarget.close();
+ out.flush();
+ } else {
+
+ // For download request, transfer the downloaded data
+ handleDownload(download, request, response);
+ }
+ }
+
+ out.flush();
+ out.close();
+
+ } catch (Throwable e) {
+ // Writes the error report to client
+ OutputStreamWriter w = new OutputStreamWriter(out);
+ PrintWriter err = new PrintWriter(w);
+ err
+ .write("<html><head><title>Application Internal Error</title></head><body>");
+ err.write("<h1>" + e.toString() + "</h1><pre>\n");
+ e.printStackTrace(new PrintWriter(err));
+ err.write("\n</pre></body></html>");
+ err.close();
+ } finally {
+
+ }
+
+ }
+
+ /**
+ * Gets the existing application or create a new one. Get a window within an
+ * application based on the requested URI.
+ *
+ * @param request
+ * the HTTP Request.
+ * @param application
+ * the Application to query for window.
+ * @return Window mathing the given URI or null if not found.
+ * @throws ServletException
+ * if an exception has occurred that interferes with the
+ * servlet's normal operation.
+ */
+ private Window getApplicationWindow(HttpServletRequest request,
+ Application application) throws ServletException {
+
+ Window window = null;
+
+ // Find the window where the request is handled
+ String path = request.getPathInfo();
+
+ // Main window as the URI is empty
+ if (path == null || path.length() == 0 || path.equals("/"))
+ window = application.getMainWindow();
+
+ // Try to search by window name
+ else {
+ String windowName = null;
+ if (path.charAt(0) == '/')
+ path = path.substring(1);
+ int index = path.indexOf('/');
+ if (index < 0) {
+ windowName = path;
+ path = "";
+ } else {
+ windowName = path.substring(0, index);
+ path = path.substring(index + 1);
+ }
+ window = application.getWindow(windowName);
+
+ // By default, we use main window
+ if (window == null)
+ window = application.getMainWindow();
+ }
+
+ return window;
+ }
+
+ /**
+ * Handles the requested URI. An application can add handlers to do special
+ * processing, when a certain URI is requested. The handlers are invoked
+ * before any windows URIs are processed and if a DownloadStream is returned
+ * it is sent to the client.
+ *
+ * @param application
+ * the Application owning the URI.
+ * @param request
+ * the HTTP request instance.
+ * @param response
+ * the HTTP response to write to.
+ * @return boolean <code>true</code> if the request was handled and
+ * further processing should be suppressed, otherwise
+ * <code>false</code>.
+ * @see com.itmill.toolkit.terminal.URIHandler
+ */
+ private DownloadStream handleURI(Application application,
+ HttpServletRequest request, HttpServletResponse response) {
+
+ String uri = request.getPathInfo();
+
+ // If no URI is available
+ if (uri == null || uri.length() == 0 || uri.equals("/"))
+ return null;
+
+ // Remove the leading /
+ while (uri.startsWith("/") && uri.length() > 0)
+ uri = uri.substring(1);
+
+ // Handle the uri
+ DownloadStream stream = null;
+ try {
+ stream = application.handleURI(application.getURL(), uri);
+ } catch (Throwable t) {
+ application.terminalError(new URIHandlerErrorImpl(application, t));
+ }
+
+ return stream;
+ }
+
+ /**
+ * Handles the requested URI. An application can add handlers to do special
+ * processing, when a certain URI is requested. The handlers are invoked
+ * before any windows URIs are processed and if a DownloadStream is returned
+ * it is sent to the client.
+ *
+ * @param stream
+ * the downloadable stream.
+ *
+ * @param request
+ * the HTTP request instance.
+ * @param response
+ * the HTTP response to write to.
+ *
+ * @see com.itmill.toolkit.terminal.URIHandler
+ */
+ private void handleDownload(DownloadStream stream,
+ HttpServletRequest request, HttpServletResponse response) {
+
+ // Download from given stream
+ InputStream data = stream.getStream();
+ if (data != null) {
+
+ // Sets content type
+ response.setContentType(stream.getContentType());
+
+ // Sets cache headers
+ long cacheTime = stream.getCacheTime();
+ if (cacheTime <= 0) {
+ response.setHeader("Cache-Control", "no-cache");
+ response.setHeader("Pragma", "no-cache");
+ response.setDateHeader("Expires", 0);
+ } else {
+ response.setHeader("Cache-Control", "max-age=" + cacheTime
+ / 1000);
+ response.setDateHeader("Expires", System.currentTimeMillis()
+ + cacheTime);
+ response.setHeader("Pragma", "cache"); // Required to apply
+ // caching in some
+ // Tomcats
+ }
+
+ // Copy download stream parameters directly
+ // to HTTP headers.
+ Iterator i = stream.getParameterNames();
+ if (i != null) {
+ while (i.hasNext()) {
+ String param = (String) i.next();
+ response.setHeader((String) param, stream
+ .getParameter(param));
+ }
+ }
+
+ int bufferSize = stream.getBufferSize();
+ if (bufferSize <= 0 || bufferSize > MAX_BUFFER_SIZE)
+ bufferSize = DEFAULT_BUFFER_SIZE;
+ byte[] buffer = new byte[bufferSize];
+ int bytesRead = 0;
+
+ try {
+ OutputStream out = response.getOutputStream();
+
+ while ((bytesRead = data.read(buffer)) > 0) {
+ out.write(buffer, 0, bytesRead);
+ out.flush();
+ }
+ out.close();
+ } catch (IOException ignored) {
+ }
+
+ }
+
+ }
+
+ /**
+ * Ends the Application.
+ *
+ * @param request
+ * the HTTP request instance.
+ * @param response
+ * the HTTP response to write to.
+ * @param application
+ * the Application to end.
+ * @throws IOException
+ * if the writing failed due to input/output error.
+ */
+ private void endApplication(HttpServletRequest request,
+ HttpServletResponse response, Application application)
+ throws IOException {
+
+ String logoutUrl = application.getLogoutURL();
+ if (logoutUrl == null)
+ logoutUrl = application.getURL().toString();
+ // clients JS app is still running, send a special xml file to
+ // tell client that application is quit and where to point browser now
+ // Set the response type
+ response.setContentType("application/xml; charset=UTF-8");
+ ServletOutputStream out = response.getOutputStream();
+ out.println("<redirect url=\"" + logoutUrl + "\">");
+ out.println("</redirect>");
+ }
+
+ /**
+ * Gets the Paintable Id.
+ *
+ * @param paintable
+ * @return the paintable Id.
+ */
+ public synchronized String getPaintableId(Paintable paintable) {
+
+ String id = (String) paintableIdMap.get(paintable);
+ if (id == null) {
+ id = "PID" + Integer.toString(idSequence++);
+ paintableIdMap.put(paintable, id);
+ }
+
+ return id;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public synchronized Set getDirtyComponents() {
+
+ // Remove unnecessary repaints from the list
+ Object[] paintables = dirtyPaintabletSet.toArray();
+ for (int i = 0; i < paintables.length; i++) {
+ if (paintables[i] instanceof Component) {
+ Component c = (Component) paintables[i];
+
+ // Check if any of the parents of c already exist in the list
+ Component p = c.getParent();
+ while (p != null) {
+ if (dirtyPaintabletSet.contains(p)) {
+
+ // Remove component c from the dirty paintables as its
+ // parent is also dirty
+ dirtyPaintabletSet.remove(c);
+ p = null;
+ } else
+ p = p.getParent();
+ }
+ }
+ }
+
+ return Collections.unmodifiableSet(dirtyPaintabletSet);
+ }
- }
-
-/**
- *
- *
- */
- public void releaseControl() {
- application.removeListener((Application.WindowAttachListener) this);
- application.removeListener((Application.WindowDetachListener) this);
- }
-
-/**
- *
- * @param request the HTTP Request.
- * @param response the HTTP Response.
- * @throws IOException if the writing failed due to input/output error.
- */
- public void handleUidlRequest(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
-
- // repaint requested or sesssion has timed out and new one is created
- boolean repaintAll = ( request.getParameter(GET_PARAM_REPAINT_ALL) != null )
- || request.getSession().isNew();
-
- OutputStream out = response.getOutputStream();
- try {
-
- // Is this a download request from application
- DownloadStream download = null;
-
- // The rest of the process is synchronized with the application
- // in order to guarantee that no parallel variable handling is
- // made
- synchronized (application) {
-
- // Change all variables based on request parameters
- Map unhandledParameters = getVariableMap().handleVariables(
- request, application);
-
- // Handles the URI if the application is still running
- if (application.isRunning())
- download = handleURI(application, request, response);
-
- // If this is not a download request
- if (download == null) {
-
- // Finds the window within the application
- Window window = null;
- if (application.isRunning())
- window = getApplicationWindow(request, application);
-
- // Handles the unhandled parameters if the application is
- // still running
- if (window != null && unhandledParameters != null
- && !unhandledParameters.isEmpty())
- window.handleParameters(unhandledParameters);
-
- // Removes application if it has stopped
- if (!application.isRunning()) {
- endApplication(request, response, application);
- return;
- }
-
- // Returns if no window found
- if (window == null)
- return;
-
- // Sets the response type
- response.setContentType("application/xml; charset=UTF-8");
-
- paintTarget = new AjaxPaintTarget(
- getVariableMap(), this, out);
-
- // Render the removed windows
- Set removed = new HashSet(getRemovedWindows());
- if (removed.size() > 0) {
- for (Iterator i = removed.iterator(); i.hasNext();) {
- Window w = (Window) i.next();
- paintTarget.startTag("change");
- paintTarget.addAttribute("format", "uidl");
- String pid = getPaintableId(w);
- paintTarget.addAttribute("pid", pid);
- paintTarget.addAttribute("windowname", w
- .getName());
- paintTarget.addAttribute("visible", false);
- paintTarget.endTag("change");
- removedWindowNotified(w);
-
- }
- }
-
- // Paints components
- Set paintables;
- if (repaintAll) {
- paintables = new LinkedHashSet();
- paintables.add(window);
-
- // Adds all non-native windows
- for (Iterator i=window.getApplication().getWindows().iterator(); i.hasNext();) {
- Window w = (Window) i.next();
- if (!"native".equals(w.getStyle()) && w != window)
- paintables.add(w);
- }
- } else
- paintables = getDirtyComponents();
- if (paintables != null) {
-
- // Creates "working copy" of the current state.
- List currentPaintables = new ArrayList(paintables);
-
- // Sorts the paintable so that parent windows
- // are always painted before child windows
- Collections.sort(currentPaintables, new Comparator() {
-
- public int compare(Object o1, Object o2) {
-
- // If first argumement is now window
- // the second is "smaller" if it is.
- if (!(o1 instanceof Window)) {
- return (o2 instanceof Window) ? 1 : 0;
- }
-
- // Now, if second is not window the
- // first is smaller.
- if (!(o2 instanceof Window)) {
- return -1;
- }
-
- // Both are windows.
- String n1 = ((Window) o1).getName();
- String n2 = ((Window) o2).getName();
- if (o1 instanceof FrameWindow) {
- if (((FrameWindow) o1).getFrameset()
- .getFrame(n2) != null) {
- return -1;
- } else if (!(o2 instanceof FrameWindow)) {
- return -1;
- }
- }
- if (o2 instanceof FrameWindow) {
- if (((FrameWindow) o2).getFrameset()
- .getFrame(n1) != null) {
- return 1;
- } else if (!(o1 instanceof FrameWindow)) {
- return 1;
- }
- }
-
- return 0;
- }
- });
-
- for (Iterator i = currentPaintables.iterator(); i
- .hasNext();) {
- Paintable p = (Paintable) i.next();
-
-
- // TODO CLEAN
- if (p instanceof Window) {
- Window w = (Window)p;
- if (w.getTerminal() == null)
- w.setTerminal(application.getMainWindow().getTerminal());
- }
-
- paintTarget.startTag("change");
- paintTarget.addAttribute("format", "uidl");
- String pid = getPaintableId(p);
- paintTarget.addAttribute("pid", pid);
-
- // Track paints to identify empty paints
- paintTarget.setTrackPaints(true);
- p.paint(paintTarget);
-
- // If no paints add attribute empty
- if (paintTarget.getNumberOfPaints() <= 0) {
- paintTarget.addAttribute("visible", false);
- }
- paintTarget.endTag("change");
- paintablePainted(p);
- }
- }
-
- // add meta instruction for client to set focus if it is set
- Paintable f = (Paintable) application.consumeFocus();
- if(f != null) {
- paintTarget.startTag("meta");
- paintTarget.startTag("focus");
- paintTarget.addAttribute("pid", getPaintableId(f));
- paintTarget.endTag("focus");
- paintTarget.endTag("meta");
- }
-
- paintTarget.close();
- out.flush();
- } else {
-
- // For download request, transfer the downloaded data
- handleDownload(download, request, response);
- }
- }
-
- out.flush();
- out.close();
-
- } catch (Throwable e) {
- // Writes the error report to client
- OutputStreamWriter w = new OutputStreamWriter(out);
- PrintWriter err = new PrintWriter(w);
- err
- .write("<html><head><title>Application Internal Error</title></head><body>");
- err.write("<h1>" + e.toString() + "</h1><pre>\n");
- e.printStackTrace(new PrintWriter(err));
- err.write("\n</pre></body></html>");
- err.close();
- } finally {
-
- }
-
- }
-
- /**
- * Gets the existing application or create a new one. Get a window within an
- * application based on the requested URI.
- *
- * @param request
- * the HTTP Request.
- * @param application
- * the Application to query for window.
- * @return Window mathing the given URI or null if not found.
- * @throws ServletException if an exception has occurred that interferes with the
- * servlet's normal operation.
- */
- private Window getApplicationWindow(HttpServletRequest request,
- Application application) throws ServletException {
-
- Window window = null;
-
- // Find the window where the request is handled
- String path = request.getPathInfo();
-
- // Main window as the URI is empty
- if (path == null || path.length() == 0 || path.equals("/"))
- window = application.getMainWindow();
-
- // Try to search by window name
- else {
- String windowName = null;
- if (path.charAt(0) == '/')
- path = path.substring(1);
- int index = path.indexOf('/');
- if (index < 0) {
- windowName = path;
- path = "";
- } else {
- windowName = path.substring(0, index);
- path = path.substring(index + 1);
- }
- window = application.getWindow(windowName);
-
- // By default, we use main window
- if (window == null)
- window = application.getMainWindow();
- }
-
- return window;
- }
-
- /**
- * Handles the requested URI. An application can add handlers to do special
- * processing, when a certain URI is requested. The handlers are invoked
- * before any windows URIs are processed and if a DownloadStream is returned
- * it is sent to the client.
- *
- * @param application
- * the Application owning the URI.
- * @param request
- * the HTTP request instance.
- * @param response
- * the HTTP response to write to.
- * @return boolean <code>true</code> if the request was handled and further processing
- * should be suppressed, otherwise <code>false</code>.
- * @see com.itmill.toolkit.terminal.URIHandler
- */
- private DownloadStream handleURI(Application application,
- HttpServletRequest request, HttpServletResponse response) {
-
- String uri = request.getPathInfo();
-
- // If no URI is available
- if (uri == null || uri.length() == 0 || uri.equals("/"))
- return null;
-
- // Remove the leading /
- while (uri.startsWith("/") && uri.length() > 0)
- uri = uri.substring(1);
-
- // Handle the uri
- DownloadStream stream = null;
- try {
- stream = application.handleURI(application.getURL(), uri);
- } catch (Throwable t) {
- application.terminalError(new URIHandlerErrorImpl(application, t));
- }
-
- return stream;
- }
-
- /**
- * Handles the requested URI. An application can add handlers to do special
- * processing, when a certain URI is requested. The handlers are invoked
- * before any windows URIs are processed and if a DownloadStream is returned
- * it is sent to the client.
- * @param stream the downloadable stream.
- *
- * @param request
- * the HTTP request instance.
- * @param response
- * the HTTP response to write to.
- *
- * @see com.itmill.toolkit.terminal.URIHandler
- */
- private void handleDownload(DownloadStream stream,
- HttpServletRequest request, HttpServletResponse response) {
-
- // Download from given stream
- InputStream data = stream.getStream();
- if (data != null) {
-
- // Sets content type
- response.setContentType(stream.getContentType());
-
- // Sets cache headers
- long cacheTime = stream.getCacheTime();
- if (cacheTime <= 0) {
- response.setHeader("Cache-Control", "no-cache");
- response.setHeader("Pragma", "no-cache");
- response.setDateHeader("Expires", 0);
- } else {
- response.setHeader("Cache-Control", "max-age=" + cacheTime
- / 1000);
- response.setDateHeader("Expires", System.currentTimeMillis()
- + cacheTime);
- response.setHeader("Pragma", "cache"); // Required to apply
- // caching in some
- // Tomcats
- }
-
- // Copy download stream parameters directly
- // to HTTP headers.
- Iterator i = stream.getParameterNames();
- if (i != null) {
- while (i.hasNext()) {
- String param = (String) i.next();
- response.setHeader((String) param, stream
- .getParameter(param));
- }
- }
-
- int bufferSize = stream.getBufferSize();
- if (bufferSize <= 0 || bufferSize > MAX_BUFFER_SIZE)
- bufferSize = DEFAULT_BUFFER_SIZE;
- byte[] buffer = new byte[bufferSize];
- int bytesRead = 0;
-
- try {
- OutputStream out = response.getOutputStream();
-
- while ((bytesRead = data.read(buffer)) > 0) {
- out.write(buffer, 0, bytesRead);
- out.flush();
- }
- out.close();
- } catch (IOException ignored) {
- }
-
- }
-
- }
-
- /**
- * Ends the Application.
- * @param request the HTTP request instance.
- * @param response the HTTP response to write to.
- * @param application the Application to end.
- * @throws IOException if the writing failed due to input/output error.
- */
- private void endApplication(HttpServletRequest request,
- HttpServletResponse response, Application application)
- throws IOException {
-
- String logoutUrl = application.getLogoutURL();
- if (logoutUrl == null)
- logoutUrl = application.getURL().toString();
- // clients JS app is still running, send a special xml file to
- // tell client that application is quit and where to point browser now
- // Set the response type
- response.setContentType("application/xml; charset=UTF-8");
- ServletOutputStream out = response.getOutputStream();
- out.println("<redirect url=\""+logoutUrl+"\">");
- out.println("</redirect>");
- }
-
- /**
- * Gets the Paintable Id.
- * @param paintable
- * @return the paintable Id.
- */
- public synchronized String getPaintableId(Paintable paintable) {
-
- String id = (String) paintableIdMap.get(paintable);
- if (id == null) {
- id = "PID" + Integer.toString(idSequence++);
- paintableIdMap.put(paintable, id);
- }
-
- return id;
- }
-
-/**
- *
- * @return
- */
- public synchronized Set getDirtyComponents() {
-
- // Remove unnecessary repaints from the list
- Object[] paintables = dirtyPaintabletSet.toArray();
- for (int i=0; i<paintables.length; i++) {
- if (paintables[i] instanceof Component) {
- Component c = (Component) paintables[i];
-
- // Check if any of the parents of c already exist in the list
- Component p = c.getParent();
- while (p != null) {
- if (dirtyPaintabletSet.contains(p)) {
-
- // Remove component c from the dirty paintables as its parent is also dirty
- dirtyPaintabletSet.remove(c);
- p = null;
- } else
- p = p.getParent();
- }
- }
- }
-
- return Collections.unmodifiableSet(dirtyPaintabletSet);
- }
-
/**
* Clears the Dirty Components.
- *
+ *
*/
- public synchronized void clearDirtyComponents() {
- dirtyPaintabletSet.clear();
- }
-
+ public synchronized void clearDirtyComponents() {
+ dirtyPaintabletSet.clear();
+ }
+
/**
* @see com.itmill.toolkit.terminal.Paintable.RepaintRequestListener#repaintRequested(com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent)
*/
- public void repaintRequested(RepaintRequestEvent event) {
- Paintable p = event.getPaintable();
- dirtyPaintabletSet.add(p);
-
- // For FrameWindows we mark all frames (windows) dirty
- if (p instanceof FrameWindow) {
- FrameWindow fw = (FrameWindow)p;
- repaintFrameset(fw.getFrameset());
- }
- }
-
- /**
- * Recursively request repaint for all frames in frameset.
- *
- * @param fs the Framewindow.Frameset.
- */
- private void repaintFrameset(FrameWindow.Frameset fs) {
- List frames = fs.getFrames();
- for (Iterator i = frames.iterator(); i.hasNext();) {
- FrameWindow.Frame f = (FrameWindow.Frame) i.next();
- if (f instanceof FrameWindow.Frameset) {
- repaintFrameset((FrameWindow.Frameset) f);
- } else {
- Window w = f.getWindow();
- if (w != null) {
- w.requestRepaint();
- }
- }
- }
- }
-
-/**
- *
- * @param p
- */
- public void paintablePainted(Paintable p) {
- dirtyPaintabletSet.remove(p);
- p.requestRepaintRequests();
- }
-
-/**
- *
- * @param paintable
- * @return
- */
- public boolean isDirty(Paintable paintable) {
- return (dirtyPaintabletSet.contains(paintable));
- }
-
+ public void repaintRequested(RepaintRequestEvent event) {
+ Paintable p = event.getPaintable();
+ dirtyPaintabletSet.add(p);
+
+ // For FrameWindows we mark all frames (windows) dirty
+ if (p instanceof FrameWindow) {
+ FrameWindow fw = (FrameWindow) p;
+ repaintFrameset(fw.getFrameset());
+ }
+ }
+
+ /**
+ * Recursively request repaint for all frames in frameset.
+ *
+ * @param fs
+ * the Framewindow.Frameset.
+ */
+ private void repaintFrameset(FrameWindow.Frameset fs) {
+ List frames = fs.getFrames();
+ for (Iterator i = frames.iterator(); i.hasNext();) {
+ FrameWindow.Frame f = (FrameWindow.Frame) i.next();
+ if (f instanceof FrameWindow.Frameset) {
+ repaintFrameset((FrameWindow.Frameset) f);
+ } else {
+ Window w = f.getWindow();
+ if (w != null) {
+ w.requestRepaint();
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param p
+ */
+ public void paintablePainted(Paintable p) {
+ dirtyPaintabletSet.remove(p);
+ p.requestRepaintRequests();
+ }
+
+ /**
+ *
+ * @param paintable
+ * @return
+ */
+ public boolean isDirty(Paintable paintable) {
+ return (dirtyPaintabletSet.contains(paintable));
+ }
+
/**
* @see com.itmill.toolkit.Application.WindowAttachListener#windowAttached(com.itmill.toolkit.Application.WindowAttachEvent)
*/
- public void windowAttached(WindowAttachEvent event) {
- event.getWindow().addListener(this);
- dirtyPaintabletSet.add(event.getWindow());
- }
-
+ public void windowAttached(WindowAttachEvent event) {
+ event.getWindow().addListener(this);
+ dirtyPaintabletSet.add(event.getWindow());
+ }
+
/**
* @see com.itmill.toolkit.Application.WindowDetachListener#windowDetached(com.itmill.toolkit.Application.WindowDetachEvent)
*/
- public void windowDetached(WindowDetachEvent event) {
- event.getWindow().removeListener(this);
- // Notify client of the close operation
- removedWindows.add(event.getWindow());
- }
-
-/**
- *
- * @return
- */
- public synchronized Set getRemovedWindows() {
- return Collections.unmodifiableSet(removedWindows);
+ public void windowDetached(WindowDetachEvent event) {
+ event.getWindow().removeListener(this);
+ // Notify client of the close operation
+ removedWindows.add(event.getWindow());
+ }
- }
-
-/**
- *
- * @param w
- */
- private void removedWindowNotified(Window w) {
- this.removedWindows.remove(w);
- }
+ /**
+ *
+ * @return
+ */
+ public synchronized Set getRemovedWindows() {
+ return Collections.unmodifiableSet(removedWindows);
- /**
- * Implementation of URIHandler.ErrorEvent interface.
- */
- public class URIHandlerErrorImpl implements URIHandler.ErrorEvent {
+ }
- private URIHandler owner;
+ /**
+ *
+ * @param w
+ */
+ private void removedWindowNotified(Window w) {
+ this.removedWindows.remove(w);
+ }
- private Throwable throwable;
-
-/**
- *
- * @param owner
- * @param throwable
- */
- private URIHandlerErrorImpl(URIHandler owner, Throwable throwable) {
- this.owner = owner;
- this.throwable = throwable;
- }
-
- /**
- * @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
- */
- public Throwable getThrowable() {
- return this.throwable;
- }
-
- /**
- * @see com.itmill.toolkit.terminal.URIHandler.ErrorEvent#getURIHandler()
- */
- public URIHandler getURIHandler() {
- return this.owner;
- }
- }
+ /**
+ * Implementation of URIHandler.ErrorEvent interface.
+ */
+ public class URIHandlerErrorImpl implements URIHandler.ErrorEvent {
+
+ private URIHandler owner;
+
+ private Throwable throwable;
+
+ /**
+ *
+ * @param owner
+ * @param throwable
+ */
+ private URIHandlerErrorImpl(URIHandler owner, Throwable throwable) {
+ this.owner = owner;
+ this.throwable = throwable;
+ }
+
+ /**
+ * @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
+ */
+ public Throwable getThrowable() {
+ return this.throwable;
+ }
+
+ /**
+ * @see com.itmill.toolkit.terminal.URIHandler.ErrorEvent#getURIHandler()
+ */
+ public URIHandler getURIHandler() {
+ return this.owner;
+ }
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/web/AjaxHttpUploadStream.java b/src/com/itmill/toolkit/terminal/web/AjaxHttpUploadStream.java
index 29a9abc192..d277bd16cd 100644
--- a/src/com/itmill/toolkit/terminal/web/AjaxHttpUploadStream.java
+++ b/src/com/itmill/toolkit/terminal/web/AjaxHttpUploadStream.java
@@ -1,103 +1,111 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
import java.io.InputStream;
-/**
+/**
* AjaxAdapter implementation of the UploadStream interface.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.1
*/
-public class AjaxHttpUploadStream
- implements com.itmill.toolkit.terminal.UploadStream {
+public class AjaxHttpUploadStream implements
+ com.itmill.toolkit.terminal.UploadStream {
- /**
- * Holds value of property variableName.
+ /**
+ * Holds value of property variableName.
*/
private String streamName;
+
private String contentName;
+
private String contentType;
- /**
- * Holds value of property variableValue.
+ /**
+ * Holds value of property variableValue.
*/
private InputStream stream;
- /**
+ /**
* Creates a new instance of UploadStreamImpl.
- * @param name the name of the stream.
- * @param stream the input stream.
- * @param contentName the name of the content.
- * @param contentType the type of the content.
+ *
+ * @param name
+ * the name of the stream.
+ * @param stream
+ * the input stream.
+ * @param contentName
+ * the name of the content.
+ * @param contentType
+ * the type of the content.
*/
- public AjaxHttpUploadStream(
- String name,
- InputStream stream,
- String contentName,
- String contentType) {
+ public AjaxHttpUploadStream(String name, InputStream stream,
+ String contentName, String contentType) {
this.streamName = name;
this.stream = stream;
this.contentName = contentName;
this.contentType = contentType;
}
- /**
+ /**
* Gets the name of the stream.
+ *
* @return the name of the stream.
*/
public String getStreamName() {
return this.streamName;
}
- /**
+ /**
* Gets the input stream.
+ *
* @return the Input stream.
*/
public InputStream getStream() {
return this.stream;
}
- /**
+ /**
* Gets the input stream content type.
+ *
* @return the content type of the input stream.
*/
public String getContentType() {
return this.contentType;
}
- /**
- * Gets the stream content name.
- * Stream content name usually differs from the actual stream name.
- * It is used to identify the content of the stream.
+ /**
+ * Gets the stream content name. Stream content name usually differs from
+ * the actual stream name. It is used to identify the content of the stream.
+ *
* @return the Name of the stream content.
*/
public String getContentName() {
diff --git a/src/com/itmill/toolkit/terminal/web/AjaxPaintTarget.java b/src/com/itmill/toolkit/terminal/web/AjaxPaintTarget.java
index 5db631fe2b..6f6840833c 100644
--- a/src/com/itmill/toolkit/terminal/web/AjaxPaintTarget.java
+++ b/src/com/itmill/toolkit/terminal/web/AjaxPaintTarget.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -56,647 +56,685 @@ import java.util.Stack;
*/
public class AjaxPaintTarget implements PaintTarget {
- /* Document type declarations */
- private final static String UIDL_XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-
- private final static String UIDL_ARG_NAME = "name";
-
- private final static String UIDL_ARG_VALUE = "value";
-
- private final static String UIDL_ARG_ID = "id";
-
- private Stack mOpenTags;
-
- private boolean mTagArgumentListOpen;
-
- private PrintWriter uidlBuffer;
-
- private AjaxVariableMap variableMap;
-
- private boolean closed = false;
-
- private AjaxApplicationManager manager;
-
- private boolean trackPaints = false;
-
- private int numberOfPaints = 0;
-
- /**
- * Creates a new XMLPrintWriter, without automatic line flushing.
- *
- * @param variableMap
- * @param manager
- * @param output
- * A character-output stream.
- * @throws PaintException if the paint operation failed.
- */
- public AjaxPaintTarget(AjaxVariableMap variableMap, AjaxApplicationManager manager,
- OutputStream output) throws PaintException {
-
- // Sets the cache
- this.manager = manager;
-
- // Sets the variable map
- this.variableMap = variableMap;
-
- // Sets the target for UIDL writing
- try {
- this.uidlBuffer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(output,"UTF-8")));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Internal error");
- }
-
- // Initialize tag-writing
- mOpenTags = new Stack();
- mTagArgumentListOpen = false;
-
- //Adds document declaration
- this.print(UIDL_XML_DECL + "\n\n");
-
- // Adds UIDL start tag and its attributes
- this.startTag("changes");
-
- }
-
- /**
- * Ensures that the currently open element tag is closed.
- */
- private void ensureClosedTag() {
- if (mTagArgumentListOpen) {
- append(">");
- mTagArgumentListOpen = false;
- }
- }
-
- /**
- * Method append.This method is thread safe.
- *
- * @param string the text to insert.
- */
- private void append(String string) {
- uidlBuffer.print(string);
- }
-
- /**
- * Prints the element start tag.
- *
- * <pre>
- * Todo:
- * Checking of input values
- *
- * </pre>
- *
- * @param tagName
- * the name of the start tag.
- * @throws PaintException if the paint operation failed.
- *
- */
- public void startTag(String tagName) throws PaintException {
- // In case of null data output nothing:
- if (tagName == null)
- throw new NullPointerException();
-
- // Increments paint tracker
- if (this.isTrackPaints()) {
- this.numberOfPaints++;
- }
-
- //Ensures that the target is open
- if (this.closed)
- throw new PaintException(
- "Attempted to write to a closed PaintTarget.");
-
- // Makes sure that the open start tag is closed before
- // anything is written.
- ensureClosedTag();
-
- // Checks tagName and attributes here
- mOpenTags.push(tagName);
-
- // Prints the tag with attributes
- append("<" + tagName);
-
- mTagArgumentListOpen = true;
- }
-
- /**
- * Prints the element end tag.
- *
- * If the parent tag is closed before every child tag is closed an
- * PaintException is raised.
- *
- * @param tag
- * the name of the end tag.
- * @throws Paintexception if the paint operation failed.
- */
- public void endTag(String tagName) throws PaintException {
- // In case of null data output nothing:
- if (tagName == null)
- throw new NullPointerException();
-
- //Ensure that the target is open
- if (this.closed)
- throw new PaintException(
- "Attempted to write to a closed PaintTarget.");
-
- String lastTag = "";
-
- lastTag = (String) mOpenTags.pop();
- if (!tagName.equalsIgnoreCase(lastTag))
- throw new PaintException("Invalid UIDL: wrong ending tag: '"
- + tagName + "' expected: '" + lastTag + "'.");
-
- // Make sure that the open start tag is closed before
- // anything is written.
- if (mTagArgumentListOpen) {
- append(">");
- mTagArgumentListOpen = false;
- }
-
- //Writes the end (closing) tag
- append("</" + lastTag + ">");
- flush();
- }
-
- /**
- * Substitutes the XML sensitive characters with predefined XML entities.
- * @param xml
- * the String to be substituted.
- * @return A new string instance where all occurrences of XML sensitive
- * characters are substituted with entities.
- */
- static public String escapeXML(String xml) {
- if (xml == null || xml.length() <= 0)
- return "";
- return escapeXML(new StringBuffer(xml)).toString();
- }
-
- /**
- * Substitutes the XML sensitive characters with predefined XML entities.
- *
- * @param xml
- * the String to be substituted.
- * @return A new StringBuffer instance where all occurrences of XML
- * sensitive characters are substituted with entities.
- *
- */
- static public StringBuffer escapeXML(StringBuffer xml) {
- if (xml == null || xml.length() <= 0)
- return new StringBuffer("");
-
- StringBuffer result = new StringBuffer(xml.length() * 2);
-
- for (int i = 0; i < xml.length(); i++) {
- char c = xml.charAt(i);
- String s = toXmlChar(c);
- if (s != null) {
- result.append(s);
- } else {
- result.append(c);
- }
- }
- return result;
- }
-
- /**
- * Substitutes a XML sensitive character with predefined XML entity.
- *
- * @param c
- * the Character to be replaced with an entity.
- * @return String of the entity or null if character is not to be replaced
- * with an entity.
- */
- private static String toXmlChar(char c) {
- switch (c) {
- case '&':
- return "&amp;"; // & => &amp;
- case '>':
- return "&gt;"; // > => &gt;
- case '<':
- return "&lt;"; // < => &lt;
- case '"':
- return "&quot;"; // " => &quot;
- case '\'':
- return "&apos;"; // ' => &apos;
- default:
- return null;
- }
- }
-
- /**
- * Prints XML.
- *
- * Writes pre-formatted XML to stream. Well-formness of XML is checked.
- *
- * <pre>
- *
- * TODO: XML checking should be made
- *
- * </pre>
- * @param str the string to print.
- */
- private void print(String str) {
- // In case of null data output nothing:
- if (str == null)
- return;
-
- // Make sure that the open start tag is closed before
- // anything is written.
- ensureClosedTag();
-
- // Write what was given
- append(str);
- }
-
- /**
- * Prints XML-escaped text.
- * @param str
- * @throws PaintException if the paint operation failed.
- *
- */
- public void addText(String str) throws PaintException {
- addUIDL(escapeXML(str));
- }
-
- /**
- * Adds a boolean attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- * @throws PaintException if the paint operation failed.
- */
- public void addAttribute(String name, boolean value) throws PaintException {
- addAttribute(name, String.valueOf(value));
- }
-
- /**
- * Adds a resource attribute to component. Atributes must be added before
- * any content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addAttribute(String name, Resource value) throws PaintException {
-
- if (value instanceof ExternalResource) {
- addAttribute(name, ((ExternalResource) value).getURL());
-
- } else if (value instanceof ApplicationResource) {
- ApplicationResource r = (ApplicationResource) value;
- Application a = r.getApplication();
- if (a == null)
- throw new PaintException(
- "Application not specified for resorce "
- + value.getClass().getName());
- String uri = a.getURL().getPath();
- if (uri.charAt(uri.length() - 1) != '/')
- uri += "/";
- uri += a.getRelativeLocation(r);
- addAttribute(name, uri);
-
- } else if (value instanceof ThemeResource) {
- String uri = "theme://"+((ThemeResource)value).getResourceId();
- addAttribute(name,uri);
- } else
- throw new PaintException("Ajax adapter does not "
- + "support resources of type: "
- + value.getClass().getName());
-
- }
-
- /**
- * Adds a integer attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addAttribute(String name, int value) throws PaintException {
- addAttribute(name, String.valueOf(value));
- }
-
- /**
- * Adds a long attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addAttribute(String name, long value) throws PaintException {
- addAttribute(name, String.valueOf(value));
- }
-
- /**
- * Adds a string attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Boolean attribute name.
- * @param value
- * the Boolean attribute value.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addAttribute(String name, String value) throws PaintException {
- // In case of null data output nothing:
- if ((value == null) || (name == null))
- throw new NullPointerException(
- "Parameters must be non-null strings");
-
- //Ensure that the target is open
- if (this.closed)
- throw new PaintException(
- "Attempted to write to a closed PaintTarget.");
-
- // Check that argument list is writable.
- if (!mTagArgumentListOpen)
- throw new PaintException("XML argument list not open.");
-
- append(" " + name + "=\"" + escapeXML(value) + "\"");
- }
-
- /**
- * Adds a string type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addVariable(VariableOwner owner, String name, String value)
- throws PaintException {
- String code = variableMap.registerVariable(name, String.class, value,
- owner);
- startTag("string");
- addAttribute(UIDL_ARG_ID, code);
- addAttribute(UIDL_ARG_NAME, name);
- addText(value);
- endTag("string");
- }
-
- /**
- * Adds a int type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addVariable(VariableOwner owner, String name, int value)
- throws PaintException {
- String code = variableMap.registerVariable(name, Integer.class,
- new Integer(value), owner);
- startTag("integer");
- addAttribute(UIDL_ARG_ID, code);
- addAttribute(UIDL_ARG_NAME, name);
- addAttribute(UIDL_ARG_VALUE, String.valueOf(value));
- endTag("integer");
- }
-
- /**
- * Adds a boolean type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addVariable(VariableOwner owner, String name, boolean value)
- throws PaintException {
- String code = variableMap.registerVariable(name, Boolean.class,
- new Boolean(value), owner);
- startTag("boolean");
- addAttribute(UIDL_ARG_ID, code);
- addAttribute(UIDL_ARG_NAME, name);
- addAttribute(UIDL_ARG_VALUE, String.valueOf(value));
- endTag("boolean");
- }
-
- /**
- * Adds a string array type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addVariable(VariableOwner owner, String name, String[] value)
- throws PaintException {
- String code = variableMap.registerVariable(name, String[].class, value,
- owner);
- startTag("array");
- addAttribute(UIDL_ARG_ID, code);
- addAttribute(UIDL_ARG_NAME, name);
- for (int i = 0; i < value.length; i++)
- addSection("ai", value[i]);
- endTag("array");
- }
-
- /**
- * Adds a upload stream type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- *
- * @throws PaintException if the paint operation failed.
- */
- public void addUploadStreamVariable(VariableOwner owner, String name)
- throws PaintException {
- String code = variableMap.registerVariable(name, UploadStream.class,
- null, owner);
- startTag("uploadstream");
- addAttribute(UIDL_ARG_ID, code);
- addAttribute(UIDL_ARG_NAME, name);
- endTag("uploadstream");
- }
-
- /**
- * Prints the single text section.
- *
- * Prints full text section. The section data is escaped from XML tags and
- * surrounded by XML start and end-tags.
- * @param sectionTagName the name of the tag.
- * @param sectionData the section data to be printed.
- * @throws PaintException if the paint operation failed.
- */
- public void addSection(String sectionTagName, String sectionData)
- throws PaintException {
- startTag(sectionTagName);
- addText(sectionData);
- endTag(sectionTagName);
- }
-
- /**
- * Adds XML directly to UIDL.
- * @param xml the Xml to be added.
- * @throws PaintException if the paint operation failed.
- */
- public void addUIDL(String xml) throws PaintException {
-
- //Ensure that the target is open
- if (this.closed)
- throw new PaintException(
- "Attempted to write to a closed PaintTarget.");
-
- // Make sure that the open start tag is closed before
- // anything is written.
- ensureClosedTag();
-
- // Escape and write what was given
- if (xml != null)
- append(xml);
-
- }
-
- /**
- * Adds XML section with namespace.
- * @param sectionTagName the name of the tag.
- * @param sectionData the section data.
- * @param namespace the namespace to be added.
- * @throws PaintException if the paint operation failed.
- *
- * @see com.itmill.toolkit.terminal.PaintTarget#addXMLSection(String,
- * String, String)
- */
- public void addXMLSection(String sectionTagName, String sectionData,
- String namespace) throws PaintException {
-
- //Ensure that the target is open
- if (this.closed)
- throw new PaintException(
- "Attempted to write to a closed PaintTarget.");
-
- startTag(sectionTagName);
- if (namespace != null)
- addAttribute("xmlns", namespace);
- append(">");
- mTagArgumentListOpen = false;
-
- if (sectionData != null)
- append(sectionData);
- endTag(sectionTagName);
- }
-
- /**
- * Gets the UIDL already printed to stream. Paint target must be closed
- * before the <code>getUIDL</code> can be called.
- * @return the UIDL.
- */
- public String getUIDL() {
- if (this.closed) {
- return uidlBuffer.toString();
- }
- throw new IllegalStateException(
- "Tried to read UIDL from open PaintTarget");
- }
-
- /**
- * Closes the paint target. Paint target must be closed before the <code>getUIDL</code>
- * can be called. Subsequent attempts to write to paint target. If the target
- * was already closed, call to this function is ignored. will generate an
- * exception.
- * @throws PaintException if the paint operation failed.
- */
- public void close() throws PaintException {
- if (!this.closed) {
- this.endTag("changes");
- flush();
-
- // Close all
- this.uidlBuffer.close();
- this.closed = true;
- }
- }
-
- /**
- * Method flush.
- */
- private void flush() {
- this.uidlBuffer.flush();
- }
-
- /**
- * @see com.itmill.toolkit.terminal.PaintTarget#startTag(com.itmill.toolkit.terminal.Paintable,
- * java.lang.String)
- */
- public boolean startTag(Paintable paintable, String tag)
- throws PaintException {
- startTag(tag);
- String id = manager.getPaintableId(paintable);
- paintable.addListener(manager);
- addAttribute("id", id);
- return false;
- }
-
- /**
- * @see com.itmill.toolkit.terminal.PaintTarget#addCharacterData(java.lang.String)
- */
- public void addCharacterData(String text) throws PaintException {
- // TODO: This should check the validity of characters
- ensureClosedTag();
- append(escapeXML(text));
- }
-
-/**
- *
- * @return
- */
+ /* Document type declarations */
+ private final static String UIDL_XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+
+ private final static String UIDL_ARG_NAME = "name";
+
+ private final static String UIDL_ARG_VALUE = "value";
+
+ private final static String UIDL_ARG_ID = "id";
+
+ private Stack mOpenTags;
+
+ private boolean mTagArgumentListOpen;
+
+ private PrintWriter uidlBuffer;
+
+ private AjaxVariableMap variableMap;
+
+ private boolean closed = false;
+
+ private AjaxApplicationManager manager;
+
+ private boolean trackPaints = false;
+
+ private int numberOfPaints = 0;
+
+ /**
+ * Creates a new XMLPrintWriter, without automatic line flushing.
+ *
+ * @param variableMap
+ * @param manager
+ * @param output
+ * A character-output stream.
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public AjaxPaintTarget(AjaxVariableMap variableMap,
+ AjaxApplicationManager manager, OutputStream output)
+ throws PaintException {
+
+ // Sets the cache
+ this.manager = manager;
+
+ // Sets the variable map
+ this.variableMap = variableMap;
+
+ // Sets the target for UIDL writing
+ try {
+ this.uidlBuffer = new PrintWriter(new BufferedWriter(
+ new OutputStreamWriter(output, "UTF-8")));
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("Internal error");
+ }
+
+ // Initialize tag-writing
+ mOpenTags = new Stack();
+ mTagArgumentListOpen = false;
+
+ // Adds document declaration
+ this.print(UIDL_XML_DECL + "\n\n");
+
+ // Adds UIDL start tag and its attributes
+ this.startTag("changes");
+
+ }
+
+ /**
+ * Ensures that the currently open element tag is closed.
+ */
+ private void ensureClosedTag() {
+ if (mTagArgumentListOpen) {
+ append(">");
+ mTagArgumentListOpen = false;
+ }
+ }
+
+ /**
+ * Method append.This method is thread safe.
+ *
+ * @param string
+ * the text to insert.
+ */
+ private void append(String string) {
+ uidlBuffer.print(string);
+ }
+
+ /**
+ * Prints the element start tag.
+ *
+ * <pre>
+ * Todo:
+ * Checking of input values
+ *
+ * </pre>
+ *
+ * @param tagName
+ * the name of the start tag.
+ * @throws PaintException
+ * if the paint operation failed.
+ *
+ */
+ public void startTag(String tagName) throws PaintException {
+ // In case of null data output nothing:
+ if (tagName == null)
+ throw new NullPointerException();
+
+ // Increments paint tracker
+ if (this.isTrackPaints()) {
+ this.numberOfPaints++;
+ }
+
+ // Ensures that the target is open
+ if (this.closed)
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
+
+ // Makes sure that the open start tag is closed before
+ // anything is written.
+ ensureClosedTag();
+
+ // Checks tagName and attributes here
+ mOpenTags.push(tagName);
+
+ // Prints the tag with attributes
+ append("<" + tagName);
+
+ mTagArgumentListOpen = true;
+ }
+
+ /**
+ * Prints the element end tag.
+ *
+ * If the parent tag is closed before every child tag is closed an
+ * PaintException is raised.
+ *
+ * @param tag
+ * the name of the end tag.
+ * @throws Paintexception
+ * if the paint operation failed.
+ */
+ public void endTag(String tagName) throws PaintException {
+ // In case of null data output nothing:
+ if (tagName == null)
+ throw new NullPointerException();
+
+ // Ensure that the target is open
+ if (this.closed)
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
+
+ String lastTag = "";
+
+ lastTag = (String) mOpenTags.pop();
+ if (!tagName.equalsIgnoreCase(lastTag))
+ throw new PaintException("Invalid UIDL: wrong ending tag: '"
+ + tagName + "' expected: '" + lastTag + "'.");
+
+ // Make sure that the open start tag is closed before
+ // anything is written.
+ if (mTagArgumentListOpen) {
+ append(">");
+ mTagArgumentListOpen = false;
+ }
+
+ // Writes the end (closing) tag
+ append("</" + lastTag + ">");
+ flush();
+ }
+
+ /**
+ * Substitutes the XML sensitive characters with predefined XML entities.
+ *
+ * @param xml
+ * the String to be substituted.
+ * @return A new string instance where all occurrences of XML sensitive
+ * characters are substituted with entities.
+ */
+ static public String escapeXML(String xml) {
+ if (xml == null || xml.length() <= 0)
+ return "";
+ return escapeXML(new StringBuffer(xml)).toString();
+ }
+
+ /**
+ * Substitutes the XML sensitive characters with predefined XML entities.
+ *
+ * @param xml
+ * the String to be substituted.
+ * @return A new StringBuffer instance where all occurrences of XML
+ * sensitive characters are substituted with entities.
+ *
+ */
+ static public StringBuffer escapeXML(StringBuffer xml) {
+ if (xml == null || xml.length() <= 0)
+ return new StringBuffer("");
+
+ StringBuffer result = new StringBuffer(xml.length() * 2);
+
+ for (int i = 0; i < xml.length(); i++) {
+ char c = xml.charAt(i);
+ String s = toXmlChar(c);
+ if (s != null) {
+ result.append(s);
+ } else {
+ result.append(c);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Substitutes a XML sensitive character with predefined XML entity.
+ *
+ * @param c
+ * the Character to be replaced with an entity.
+ * @return String of the entity or null if character is not to be replaced
+ * with an entity.
+ */
+ private static String toXmlChar(char c) {
+ switch (c) {
+ case '&':
+ return "&amp;"; // & => &amp;
+ case '>':
+ return "&gt;"; // > => &gt;
+ case '<':
+ return "&lt;"; // < => &lt;
+ case '"':
+ return "&quot;"; // " => &quot;
+ case '\'':
+ return "&apos;"; // ' => &apos;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Prints XML.
+ *
+ * Writes pre-formatted XML to stream. Well-formness of XML is checked.
+ *
+ * <pre>
+ *
+ * TODO: XML checking should be made
+ *
+ * </pre>
+ *
+ * @param str
+ * the string to print.
+ */
+ private void print(String str) {
+ // In case of null data output nothing:
+ if (str == null)
+ return;
+
+ // Make sure that the open start tag is closed before
+ // anything is written.
+ ensureClosedTag();
+
+ // Write what was given
+ append(str);
+ }
+
+ /**
+ * Prints XML-escaped text.
+ *
+ * @param str
+ * @throws PaintException
+ * if the paint operation failed.
+ *
+ */
+ public void addText(String str) throws PaintException {
+ addUIDL(escapeXML(str));
+ }
+
+ /**
+ * Adds a boolean attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addAttribute(String name, boolean value) throws PaintException {
+ addAttribute(name, String.valueOf(value));
+ }
+
+ /**
+ * Adds a resource attribute to component. Atributes must be added before
+ * any content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addAttribute(String name, Resource value) throws PaintException {
+
+ if (value instanceof ExternalResource) {
+ addAttribute(name, ((ExternalResource) value).getURL());
+
+ } else if (value instanceof ApplicationResource) {
+ ApplicationResource r = (ApplicationResource) value;
+ Application a = r.getApplication();
+ if (a == null)
+ throw new PaintException(
+ "Application not specified for resorce "
+ + value.getClass().getName());
+ String uri = a.getURL().getPath();
+ if (uri.charAt(uri.length() - 1) != '/')
+ uri += "/";
+ uri += a.getRelativeLocation(r);
+ addAttribute(name, uri);
+
+ } else if (value instanceof ThemeResource) {
+ String uri = "theme://" + ((ThemeResource) value).getResourceId();
+ addAttribute(name, uri);
+ } else
+ throw new PaintException("Ajax adapter does not "
+ + "support resources of type: "
+ + value.getClass().getName());
+
+ }
+
+ /**
+ * Adds a integer attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addAttribute(String name, int value) throws PaintException {
+ addAttribute(name, String.valueOf(value));
+ }
+
+ /**
+ * Adds a long attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addAttribute(String name, long value) throws PaintException {
+ addAttribute(name, String.valueOf(value));
+ }
+
+ /**
+ * Adds a string attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Boolean attribute name.
+ * @param value
+ * the Boolean attribute value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addAttribute(String name, String value) throws PaintException {
+ // In case of null data output nothing:
+ if ((value == null) || (name == null))
+ throw new NullPointerException(
+ "Parameters must be non-null strings");
+
+ // Ensure that the target is open
+ if (this.closed)
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
+
+ // Check that argument list is writable.
+ if (!mTagArgumentListOpen)
+ throw new PaintException("XML argument list not open.");
+
+ append(" " + name + "=\"" + escapeXML(value) + "\"");
+ }
+
+ /**
+ * Adds a string type variable.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addVariable(VariableOwner owner, String name, String value)
+ throws PaintException {
+ String code = variableMap.registerVariable(name, String.class, value,
+ owner);
+ startTag("string");
+ addAttribute(UIDL_ARG_ID, code);
+ addAttribute(UIDL_ARG_NAME, name);
+ addText(value);
+ endTag("string");
+ }
+
+ /**
+ * Adds a int type variable.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addVariable(VariableOwner owner, String name, int value)
+ throws PaintException {
+ String code = variableMap.registerVariable(name, Integer.class,
+ new Integer(value), owner);
+ startTag("integer");
+ addAttribute(UIDL_ARG_ID, code);
+ addAttribute(UIDL_ARG_NAME, name);
+ addAttribute(UIDL_ARG_VALUE, String.valueOf(value));
+ endTag("integer");
+ }
+
+ /**
+ * Adds a boolean type variable.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addVariable(VariableOwner owner, String name, boolean value)
+ throws PaintException {
+ String code = variableMap.registerVariable(name, Boolean.class,
+ new Boolean(value), owner);
+ startTag("boolean");
+ addAttribute(UIDL_ARG_ID, code);
+ addAttribute(UIDL_ARG_NAME, name);
+ addAttribute(UIDL_ARG_VALUE, String.valueOf(value));
+ endTag("boolean");
+ }
+
+ /**
+ * Adds a string array type variable.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addVariable(VariableOwner owner, String name, String[] value)
+ throws PaintException {
+ String code = variableMap.registerVariable(name, String[].class, value,
+ owner);
+ startTag("array");
+ addAttribute(UIDL_ARG_ID, code);
+ addAttribute(UIDL_ARG_NAME, name);
+ for (int i = 0; i < value.length; i++)
+ addSection("ai", value[i]);
+ endTag("array");
+ }
+
+ /**
+ * Adds a upload stream type variable.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addUploadStreamVariable(VariableOwner owner, String name)
+ throws PaintException {
+ String code = variableMap.registerVariable(name, UploadStream.class,
+ null, owner);
+ startTag("uploadstream");
+ addAttribute(UIDL_ARG_ID, code);
+ addAttribute(UIDL_ARG_NAME, name);
+ endTag("uploadstream");
+ }
+
+ /**
+ * Prints the single text section.
+ *
+ * Prints full text section. The section data is escaped from XML tags and
+ * surrounded by XML start and end-tags.
+ *
+ * @param sectionTagName
+ * the name of the tag.
+ * @param sectionData
+ * the section data to be printed.
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addSection(String sectionTagName, String sectionData)
+ throws PaintException {
+ startTag(sectionTagName);
+ addText(sectionData);
+ endTag(sectionTagName);
+ }
+
+ /**
+ * Adds XML directly to UIDL.
+ *
+ * @param xml
+ * the Xml to be added.
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void addUIDL(String xml) throws PaintException {
+
+ // Ensure that the target is open
+ if (this.closed)
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
+
+ // Make sure that the open start tag is closed before
+ // anything is written.
+ ensureClosedTag();
+
+ // Escape and write what was given
+ if (xml != null)
+ append(xml);
+
+ }
+
+ /**
+ * Adds XML section with namespace.
+ *
+ * @param sectionTagName
+ * the name of the tag.
+ * @param sectionData
+ * the section data.
+ * @param namespace
+ * the namespace to be added.
+ * @throws PaintException
+ * if the paint operation failed.
+ *
+ * @see com.itmill.toolkit.terminal.PaintTarget#addXMLSection(String,
+ * String, String)
+ */
+ public void addXMLSection(String sectionTagName, String sectionData,
+ String namespace) throws PaintException {
+
+ // Ensure that the target is open
+ if (this.closed)
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
+
+ startTag(sectionTagName);
+ if (namespace != null)
+ addAttribute("xmlns", namespace);
+ append(">");
+ mTagArgumentListOpen = false;
+
+ if (sectionData != null)
+ append(sectionData);
+ endTag(sectionTagName);
+ }
+
+ /**
+ * Gets the UIDL already printed to stream. Paint target must be closed
+ * before the <code>getUIDL</code> can be called.
+ *
+ * @return the UIDL.
+ */
+ public String getUIDL() {
+ if (this.closed) {
+ return uidlBuffer.toString();
+ }
+ throw new IllegalStateException(
+ "Tried to read UIDL from open PaintTarget");
+ }
+
+ /**
+ * Closes the paint target. Paint target must be closed before the
+ * <code>getUIDL</code> can be called. Subsequent attempts to write to
+ * paint target. If the target was already closed, call to this function is
+ * ignored. will generate an exception.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void close() throws PaintException {
+ if (!this.closed) {
+ this.endTag("changes");
+ flush();
+
+ // Close all
+ this.uidlBuffer.close();
+ this.closed = true;
+ }
+ }
+
+ /**
+ * Method flush.
+ */
+ private void flush() {
+ this.uidlBuffer.flush();
+ }
+
+ /**
+ * @see com.itmill.toolkit.terminal.PaintTarget#startTag(com.itmill.toolkit.terminal.Paintable,
+ * java.lang.String)
+ */
+ public boolean startTag(Paintable paintable, String tag)
+ throws PaintException {
+ startTag(tag);
+ String id = manager.getPaintableId(paintable);
+ paintable.addListener(manager);
+ addAttribute("id", id);
+ return false;
+ }
+
+ /**
+ * @see com.itmill.toolkit.terminal.PaintTarget#addCharacterData(java.lang.String)
+ */
+ public void addCharacterData(String text) throws PaintException {
+ // TODO: This should check the validity of characters
+ ensureClosedTag();
+ append(escapeXML(text));
+ }
+
+ /**
+ *
+ * @return
+ */
public boolean isTrackPaints() {
return trackPaints;
}
-
- /**
- * Gets the number of paints.
+
+ /**
+ * Gets the number of paints.
*
* @return the number of paints.
*/
public int getNumberOfPaints() {
return numberOfPaints;
}
-
- /**
+
+ /**
* Sets the tracking to true or false.
*
* This also resets the number of paints.
- * @param enabled is the tracking is enabled or not.
+ *
+ * @param enabled
+ * is the tracking is enabled or not.
* @see #getNumberOfPaints()
*/
public void setTrackPaints(boolean enabled) {
this.trackPaints = enabled;
this.numberOfPaints = 0;
}
-
+
}
diff --git a/src/com/itmill/toolkit/terminal/web/AjaxVariableMap.java b/src/com/itmill/toolkit/terminal/web/AjaxVariableMap.java
index 00b5b00320..5cea2afe06 100644
--- a/src/com/itmill/toolkit/terminal/web/AjaxVariableMap.java
+++ b/src/com/itmill/toolkit/terminal/web/AjaxVariableMap.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -50,43 +50,49 @@ import com.itmill.toolkit.terminal.Terminal;
import com.itmill.toolkit.terminal.UploadStream;
import com.itmill.toolkit.terminal.VariableOwner;
-/**
+/**
* Variable map for ajax applications.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.1
*/
public class AjaxVariableMap {
-
// Id <-> (Owner,Name) mapping
private Map idToNameMap = new HashMap();
+
private Map idToTypeMap = new HashMap();
+
private Map idToOwnerMap = new HashMap();
+
private Map idToValueMap = new HashMap();
+
private Map ownerToNameToIdMap = new WeakHashMap();
+
private Object mapLock = new Object();
-
+
// Id generator
private long lastId = 0;
/**
- * Converts the string to a supported class.
+ * Converts the string to a supported class.
+ *
* @param type
* @param value
* @return
- * @throws java.lang.ClassCastException if the code has
- * attempted to cast an object to a subclass of which it is not an instance
+ * @throws java.lang.ClassCastException
+ * if the code has attempted to cast an object to a subclass of
+ * which it is not an instance
*/
private static Object convert(Class type, String value)
- throws java.lang.ClassCastException {
+ throws java.lang.ClassCastException {
try {
// Boolean typed variables
if (type.equals(Boolean.class))
- return new Boolean(
- !(value.equals("") || value.equals("false")));
+ return new Boolean(!(value.equals("") || value.equals("false")));
// Integer typed variables
if (type.equals(Integer.class))
@@ -102,28 +108,26 @@ public class AjaxVariableMap {
}
}
- /**
+ /**
* Registers a new variable.
- * @param name the Variable name.
+ *
+ * @param name
+ * the Variable name.
* @param type
* @param value
- * @param owner the Listener for variable changes.
+ * @param owner
+ * the Listener for variable changes.
* @return id to assigned for this variable.
*/
- public String registerVariable(
- String name,
- Class type,
- Object value,
- VariableOwner owner) {
+ public String registerVariable(String name, Class type, Object value,
+ VariableOwner owner) {
// Checks that the type of the class is supported
- if (!(type.equals(Boolean.class)
- || type.equals(Integer.class)
- || type.equals(String.class)
- || type.equals(String[].class)
- || type.equals(UploadStream.class)))
- throw new SystemError(
- "Unsupported variable type: " + type.getClass());
+ if (!(type.equals(Boolean.class) || type.equals(Integer.class)
+ || type.equals(String.class) || type.equals(String[].class) || type
+ .equals(UploadStream.class)))
+ throw new SystemError("Unsupported variable type: "
+ + type.getClass());
synchronized (mapLock) {
@@ -150,10 +154,13 @@ public class AjaxVariableMap {
}
}
- /**
+ /**
* Unregisters the variable.
- * @param name the Variable name.
- * @param owner the Listener for variable changes.
+ *
+ * @param name
+ * the Variable name.
+ * @param owner
+ * the Listener for variable changes.
*/
public void unregisterVariable(String name, VariableOwner owner) {
@@ -181,42 +188,44 @@ public class AjaxVariableMap {
/**
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
private class ParameterContainer {
- /**
- * Constructs the mapping: listener to set of listened parameter names.
+ /**
+ * Constructs the mapping: listener to set of listened parameter names.
*/
private HashMap parameters = new HashMap();
/**
- * Parameter values.
+ * Parameter values.
*/
private HashMap values = new HashMap();
- /**
- * Multipart parser used for parsing the request.
+ /**
+ * Multipart parser used for parsing the request.
*/
private ServletMultipartRequest parser = null;
- /**
- * Name - Value mapping of parameters that are not variables.
+ /**
+ * Name - Value mapping of parameters that are not variables.
*/
private HashMap nonVariables = new HashMap();
- /**
- * Creates a new parameter container and parse the parameters from the request using
- * GET, POST and POST/MULTIPART parsing
- * @param req the Http request to handle.
- * @throws IOException if the writing failed due to input/output error.
+ /**
+ * Creates a new parameter container and parse the parameters from the
+ * request using GET, POST and POST/MULTIPART parsing
+ *
+ * @param req
+ * the Http request to handle.
+ * @throws IOException
+ * if the writing failed due to input/output error.
*/
public ParameterContainer(HttpServletRequest req) throws IOException {
// Parse GET / POST parameters
- for (Enumeration e = req.getParameterNames();
- e.hasMoreElements();
- ) {
+ for (Enumeration e = req.getParameterNames(); e.hasMoreElements();) {
String paramName = (String) e.nextElement();
String[] paramValues = req.getParameterValues(paramName);
addParam(paramName, paramValues);
@@ -224,28 +233,25 @@ public class AjaxVariableMap {
// Parse multipart variables
try {
- parser =
- new ServletMultipartRequest(
- req,
+ parser = new ServletMultipartRequest(req,
MultipartRequest.MAX_READ_BYTES);
} catch (IllegalArgumentException ignored) {
parser = null;
}
if (parser != null) {
- for (Enumeration e = parser.getFileParameterNames();
- e.hasMoreElements();
- ) {
+ for (Enumeration e = parser.getFileParameterNames(); e
+ .hasMoreElements();) {
String paramName = (String) e.nextElement();
addParam(paramName, null);
}
- for (Enumeration e = parser.getParameterNames();
- e.hasMoreElements();
- ) {
+ for (Enumeration e = parser.getParameterNames(); e
+ .hasMoreElements();) {
String paramName = (String) e.nextElement();
Enumeration val = parser.getURLParameters(paramName);
- // Create a linked list from enumeration to calculate elements
+ // Create a linked list from enumeration to calculate
+ // elements
LinkedList l = new LinkedList();
while (val.hasMoreElements())
l.addLast(val.nextElement());
@@ -262,10 +268,13 @@ public class AjaxVariableMap {
}
- /**
+ /**
* Adds the parameter to container.
- * @param name the Parameter name.
- * @param value the Parameter value.
+ *
+ * @param name
+ * the Parameter name.
+ * @param value
+ * the Parameter value.
*/
private void addParam(String name, String[] value) {
@@ -282,50 +291,46 @@ public class AjaxVariableMap {
newVal[i] = curVal[i];
value = newVal;
- // Special case - if the set:-method is used for
- // declaring array of length 2, where either of the
+ // Special case - if the set:-method is used for
+ // declaring array of length 2, where either of the
// following conditions are true:
- // - the both items are the same
- // - the both items have the same length and
- // - the items only differ on last character
- // - second last character is '.'
- // - last char of one string is 'x' and other is 'y'
- // Browser is unporposely modifying the name.
+ // - the both items are the same
+ // - the both items have the same length and
+ // - the items only differ on last character
+ // - second last character is '.'
+ // - last char of one string is 'x' and other is 'y'
+ // Browser is unporposely modifying the name.
if (value.length == 2
- && value[0].length() == value[1].length()) {
+ && value[0].length() == value[1].length()) {
boolean same = true;
for (int i = 0; i < value[0].length() - 1 && same; i++)
if (value[0].charAt(i) != value[1].charAt(i))
same = false;
if (same
- && ((value[0].charAt(value[0].length() - 1) == 'x'
- && value[1].charAt(value[1].length() - 1) == 'y')
- || (value[0].charAt(value[0].length() - 1) == 'y'
- && value[1].charAt(value[1].length() - 1)
- == 'x'))) {
- value =
- new String[] {
- value[0].substring(
- 0,
- value[1].length() - 2)};
- } else
- if (same && value[0].equals(value[1]))
+ && ((value[0].charAt(value[0].length() - 1) == 'x' && value[1]
+ .charAt(value[1].length() - 1) == 'y') || (value[0]
+ .charAt(value[0].length() - 1) == 'y' && value[1]
+ .charAt(value[1].length() - 1) == 'x'))) {
+ value = new String[] { value[0].substring(0,
+ value[1].length() - 2) };
+ } else if (same && value[0].equals(value[1]))
value = new String[] { value[0] };
}
- // Special case - if the set:-method is used for
- // declaring array of length 3, where all of the
+ // Special case - if the set:-method is used for
+ // declaring array of length 3, where all of the
// following conditions are true:
- // - two last items have the same length
- // - the first item is 2 chars shorter
- // - the longer items only differ on last character
- // - the shortest item is a prefix of the longer ones
- // - second last character of longer ones is '.'
- // - last char of one long string is 'x' and other is 'y'
- // Browser is unporposely modifying the name. (Mozilla, Firefox, ..)
+ // - two last items have the same length
+ // - the first item is 2 chars shorter
+ // - the longer items only differ on last character
+ // - the shortest item is a prefix of the longer ones
+ // - second last character of longer ones is '.'
+ // - last char of one long string is 'x' and other is 'y'
+ // Browser is unporposely modifying the name. (Mozilla,
+ // Firefox, ..)
if (value.length == 3
- && value[1].length() == value[2].length() &&
- value[0].length() +2 == value[1].length()) {
+ && value[1].length() == value[2].length()
+ && value[0].length() + 2 == value[1].length()) {
boolean same = true;
for (int i = 0; i < value[1].length() - 1 && same; i++)
if (value[2].charAt(i) != value[1].charAt(i))
@@ -334,14 +339,11 @@ public class AjaxVariableMap {
if (value[0].charAt(i) != value[1].charAt(i))
same = false;
if (same
- && (value[2].charAt(value[2].length() - 1) == 'x'
- && value[1].charAt(value[1].length() - 1) == 'y')
- || (value[2].charAt(value[2].length() - 1) == 'y'
- && value[1].charAt(value[1].length() - 1)
- == 'x')) {
- value =
- new String[] {
- value[0]};
+ && (value[2].charAt(value[2].length() - 1) == 'x' && value[1]
+ .charAt(value[1].length() - 1) == 'y')
+ || (value[2].charAt(value[2].length() - 1) == 'y' && value[1]
+ .charAt(value[1].length() - 1) == 'x')) {
+ value = new String[] { value[0] };
}
}
@@ -355,8 +357,8 @@ public class AjaxVariableMap {
if (equalsIndex < 0)
return;
- StringTokenizer commalist =
- new StringTokenizer(name.substring(equalsIndex + 1), ",");
+ StringTokenizer commalist = new StringTokenizer(name
+ .substring(equalsIndex + 1), ",");
name = name.substring(10, equalsIndex);
String[] curVal = (String[]) values.get(name);
ArrayList elems = new ArrayList();
@@ -428,7 +430,8 @@ public class AjaxVariableMap {
// If the owner can not be found
else {
- // If parameter has been mapped before, remove the old owner mapping
+ // If parameter has been mapped before, remove the old owner
+ // mapping
if (ref != null) {
// The owner has been destroyed, so we remove the mappings
@@ -444,10 +447,12 @@ public class AjaxVariableMap {
}
- /**
+ /**
* Gets the set of all parameters connected to given variable owner.
- * @param owner the Listener for variable changes.
- * @return the set of all the parameters.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @return the set of all the parameters.
*/
public Set getParameters(VariableOwner owner) {
if (owner == null)
@@ -455,52 +460,60 @@ public class AjaxVariableMap {
return (Set) parameters.get(owner);
}
- /**
- * Gets the set of all variable owners owning parameters in this request.
- * @return the set of all varaible owners.
+ /**
+ * Gets the set of all variable owners owning parameters in this
+ * request.
+ *
+ * @return the set of all varaible owners.
*/
public Set getOwners() {
return parameters.keySet();
}
- /**
+ /**
* Gets the value of a parameter.
- * @param parameterName the name of the parameter.
- * @return the value of the parameter.
+ *
+ * @param parameterName
+ * the name of the parameter.
+ * @return the value of the parameter.
*/
public String[] getValue(String parameterName) {
return (String[]) values.get(parameterName);
}
- /**
+ /**
* Gets the servlet multipart parser.
+ *
* @return the parser.
*/
public ServletMultipartRequest getParser() {
return parser;
}
- /**
+ /**
* Gets the name - value[] mapping of non variable parameters.
- * @return the mapping of non variable parameters.
+ *
+ * @return the mapping of non variable parameters.
*/
public Map getNonVariables() {
return nonVariables;
}
}
- /**
+ /**
* Handles all variable changes in this request.
- * @param req the Http request to handle.
- * @param errorListener the listeners If the list is non null, only the listed listeners are
- * served. Otherwise all the listeners are served.
+ *
+ * @param req
+ * the Http request to handle.
+ * @param errorListener
+ * the listeners If the list is non null, only the listed
+ * listeners are served. Otherwise all the listeners are served.
* @return Name to Value[] mapping of unhandled variables.
- * @throws IOException if the writing failed due to input/output error.
+ * @throws IOException
+ * if the writing failed due to input/output error.
*/
- public Map handleVariables(
- HttpServletRequest req,
- Terminal.ErrorListener errorListener)
- throws IOException {
+ public Map handleVariables(HttpServletRequest req,
+ Terminal.ErrorListener errorListener) throws IOException {
// Gets the parameters
ParameterContainer parcon = new ParameterContainer(req);
@@ -511,7 +524,8 @@ public class AjaxVariableMap {
// Handles all parameters for all listeners
while (!listeners.isEmpty()) {
VariableOwner listener = (VariableOwner) listeners.remove(0);
- boolean changed = false; // Has any of this owners variabes changed
+ boolean changed = false; // Has any of this owners variabes
+ // changed
// Handles all parameters for listener
Set params = parcon.getParameters(listener);
if (params != null) { // Name value mapping
@@ -525,14 +539,13 @@ public class AjaxVariableMap {
Object varOldValue = idToValueMap.get(param);
if (varName == null || varType == null)
// TODO Remove this?
- System.err.println(
- "VariableMap: No variable found for parameter "
- + param
- + " ("
- + varName
- + ","
- + listener
- + ")");
+ System.err
+ .println("VariableMap: No variable found for parameter "
+ + param
+ + " ("
+ + varName
+ + ","
+ + listener + ")");
else {
ServletMultipartRequest parser = parcon.getParser();
@@ -540,24 +553,17 @@ public class AjaxVariableMap {
// Uploads events
if (varType.equals(UploadStream.class)) {
if (parser != null
- && parser.getFileParameter(
- param,
- MultipartRequest.FILENAME)
- != null) {
- String filename =
- (String) parser.getFileParameter(
- param,
- MultipartRequest.FILENAME);
- String contentType =
- (String) parser.getFileParameter(
- param,
- MultipartRequest.CONTENT_TYPE);
- UploadStream upload =
- new AjaxHttpUploadStream(
- varName,
- parser.getFileContents(param),
- filename,
- contentType);
+ && parser.getFileParameter(param,
+ MultipartRequest.FILENAME) != null) {
+ String filename = (String) parser
+ .getFileParameter(param,
+ MultipartRequest.FILENAME);
+ String contentType = (String) parser
+ .getFileParameter(param,
+ MultipartRequest.CONTENT_TYPE);
+ UploadStream upload = new AjaxHttpUploadStream(
+ varName, parser.getFileContents(param),
+ filename, contentType);
variables.put(varName, upload);
changed = true;
}
@@ -571,47 +577,41 @@ public class AjaxVariableMap {
if (varType.equals(String[].class)) {
variables.put(varName, values);
- changed
- |= (!Arrays
- .equals(
- values,
- (String[]) varOldValue));
+ changed |= (!Arrays.equals(values,
+ (String[]) varOldValue));
} else {
try {
if (values.length == 1) {
- Object val =
- convert(varType, values[0]);
+ Object val = convert(varType,
+ values[0]);
variables.put(varName, val);
- changed
- |= ((val == null
- && varOldValue != null)
- || (val != null
- && !val.equals(
- varOldValue)));
- } else if (
- values.length == 0
- && varType.equals(
- Boolean.class)) {
+ changed |= ((val == null && varOldValue != null) || (val != null && !val
+ .equals(varOldValue)));
+ } else if (values.length == 0
+ && varType
+ .equals(Boolean.class)) {
Object val = new Boolean(false);
variables.put(varName, val);
- changed
- |= (!val.equals(varOldValue));
+ changed |= (!val
+ .equals(varOldValue));
} else {
// TODO Remove this?
- System.err.println(
- "Empty variable '"
- + varName
- + "' of type "
- + varType.toString());
+ System.err
+ .println("Empty variable '"
+ + varName
+ + "' of type "
+ + varType
+ .toString());
}
} catch (java.lang.ClassCastException e) {
// TODO Remove this?
- System.err.println(
- "WebVariableMap conversion exception");
- e.printStackTrace(System.err);
- errorListener.terminalError(
- new TerminalErrorImpl(e));
+ System.err
+ .println("WebVariableMap conversion exception");
+ e.printStackTrace(System.err);
+ errorListener
+ .terminalError(new TerminalErrorImpl(
+ e));
}
}
}
@@ -625,8 +625,8 @@ public class AjaxVariableMap {
listener.changeVariables(req, variables);
} catch (Throwable t) {
// Notify the error listener
- errorListener.terminalError(
- new VariableOwnerErrorImpl(listener, t));
+ errorListener.terminalError(new VariableOwnerErrorImpl(
+ listener, t));
}
}
}
@@ -635,16 +635,16 @@ public class AjaxVariableMap {
return parcon.getNonVariables();
}
- /**
- * Implementation of VariableOwner.Error interface.
+ /**
+ * Implementation of VariableOwner.Error interface.
*/
public class TerminalErrorImpl implements Terminal.ErrorEvent {
private Throwable throwable;
-
-/**
- *
- * @param throwable
- */
+
+ /**
+ *
+ * @param throwable
+ */
private TerminalErrorImpl(Throwable throwable) {
this.throwable = throwable;
}
@@ -658,22 +658,21 @@ public class AjaxVariableMap {
}
- /**
- * Implementation of VariableOwner.Error interface.
+ /**
+ * Implementation of VariableOwner.Error interface.
*/
- public class VariableOwnerErrorImpl
- extends TerminalErrorImpl
- implements VariableOwner.ErrorEvent {
+ public class VariableOwnerErrorImpl extends TerminalErrorImpl implements
+ VariableOwner.ErrorEvent {
private VariableOwner owner;
-/**
- *
- * @param owner the Listener for variable changes.
- * @param throwable
- */
- private VariableOwnerErrorImpl(
- VariableOwner owner,
- Throwable throwable) {
+
+ /**
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param throwable
+ */
+ private VariableOwnerErrorImpl(VariableOwner owner, Throwable throwable) {
super(throwable);
this.owner = owner;
}
@@ -687,13 +686,13 @@ public class AjaxVariableMap {
}
- /**
- * Resolves the VariableOwners needed from the request and sort
- * them to assure that the dependencies are met (as well as possible).
+ /**
+ * Resolves the VariableOwners needed from the request and sort them to
+ * assure that the dependencies are met (as well as possible).
*
- * @param listeners
- * @return List of variable list changers, that are needed for handling
- * all the variables in the request
+ * @param listeners
+ * @return List of variable list changers, that are needed for handling all
+ * the variables in the request
*/
private List getDependencySortedListenerList(Set listeners) {
@@ -710,7 +709,8 @@ public class AjaxVariableMap {
if (listener != null) {
Set dependencies = listener.getDirectDependencies();
- // The listeners with no dependencies are added to the front of the
+ // The listeners with no dependencies are added to the front of
+ // the
// list directly
if (dependencies == null || dependencies.isEmpty()) {
if (listener.isImmediate())
@@ -734,8 +734,8 @@ public class AjaxVariableMap {
HashSet tmpdeepdeps = new HashSet();
while (!unresolved.isEmpty()) {
- VariableOwner l =
- (VariableOwner) unresolved.removeFirst();
+ VariableOwner l = (VariableOwner) unresolved
+ .removeFirst();
if (!tmpdeepdeps.contains(l)) {
tmpdeepdeps.add(l);
if (deepdeps.containsKey(l)) {
@@ -743,12 +743,11 @@ public class AjaxVariableMap {
} else {
Set deps = l.getDirectDependencies();
if (deps != null && !deps.isEmpty())
- for (Iterator di = deps.iterator();
- di.hasNext();
- ) {
+ for (Iterator di = deps.iterator(); di
+ .hasNext();) {
Object d = di.next();
if (d != null
- && !tmpdeepdeps.contains(d))
+ && !tmpdeepdeps.contains(d))
unresolved.addLast(d);
}
}
@@ -769,23 +768,21 @@ public class AjaxVariableMap {
// Adds each listener after the last depended listener already in
// the list
int index = -1;
- for (Iterator di = ((Set) deepdeps.get(l)).iterator();
- di.hasNext();
- ) {
+ for (Iterator di = ((Set) deepdeps.get(l)).iterator(); di.hasNext();) {
int k;
Object depended = di.next();
if (immediate) {
- k = resultImmediate.lastIndexOf(depended);
- }else {
- k = resultNormal.lastIndexOf(depended);
- }
+ k = resultImmediate.lastIndexOf(depended);
+ } else {
+ k = resultNormal.lastIndexOf(depended);
+ }
if (k > index)
index = k;
}
if (immediate) {
resultImmediate.add(index + 1, l);
} else {
- resultNormal.add(index + 1, l);
+ resultNormal.add(index + 1, l);
}
}
diff --git a/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java
index 0476e60b42..58910db589 100644
--- a/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java
+++ b/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java
@@ -103,23 +103,23 @@ public class ApplicationServlet extends HttpServlet implements
private static final long serialVersionUID = -4937882979845826574L;
- /**
- * Version number of this release. For example "4.0.0".
+ /**
+ * Version number of this release. For example "4.0.0".
*/
public static final String VERSION;
- /**
- * Major version number. For example 4 in 4.1.0.
+ /**
+ * Major version number. For example 4 in 4.1.0.
*/
public static final int VERSION_MAJOR;
- /**
- * Minor version number. For example 1 in 4.1.0.
+ /**
+ * Minor version number. For example 1 in 4.1.0.
*/
public static final int VERSION_MINOR;
- /**
- * Builds number. For example 0-beta1 in 4.0.0-beta1.
+ /**
+ * Builds number. For example 0-beta1 in 4.0.0-beta1.
*/
public static final String VERSION_BUILD;
@@ -400,19 +400,20 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Gets ThemeSources from given path. Construct the list of avalable themes
* in path using the following sources:
- * <p>
- * 1. Content of <code>THEME_PATH</code> directory (if available).
+ * <p>
+ * 1. Content of <code>THEME_PATH</code> directory (if available).
* </p>
* <p>
* 2. The themes listed in <code>THEME_LIST_FILE</code>.
* </p>
- * <p>
+ * <p>
* 3. "themesource" application parameter - "ThemeSource" system property.
* </p>
+ *
* @return the List
* @throws ServletException
- * if an exception has occurred that interferes with the
- * servlet's normal operation.
+ * if an exception has occurred that interferes with the
+ * servlet's normal operation.
*/
private List getThemeSources() throws ServletException {
@@ -510,8 +511,8 @@ public class ApplicationServlet extends HttpServlet implements
* the object that contains the request the client made of the
* servlet.
* @param response
- * the object that contains the response the servlet returns to the
- * client.
+ * the object that contains the response the servlet returns to
+ * the client.
* @throws ServletException
* if an input or output error occurs while the servlet is
* handling the TRACE request.
@@ -849,21 +850,24 @@ public class ApplicationServlet extends HttpServlet implements
ThemeFunctionLibrary.cleanState();
}
}
-/**
- *
- * @param request the HTTP request.
- * @param response the HTTP response to write to.
- * @param out
- * @param unhandledParameters
- * @param window
- * @param terminalType
- * @param theme
- * @throws IOException
- * if the writing failed due to input/output error.
- * @throws MalformedURLException
- * if the application is denied access
- * the persistent data store represented by the given URL.
- */
+
+ /**
+ *
+ * @param request
+ * the HTTP request.
+ * @param response
+ * the HTTP response to write to.
+ * @param out
+ * @param unhandledParameters
+ * @param window
+ * @param terminalType
+ * @param theme
+ * @throws IOException
+ * if the writing failed due to input/output error.
+ * @throws MalformedURLException
+ * if the application is denied access the persistent data store
+ * represented by the given URL.
+ */
private void writeAjaxPage(HttpServletRequest request,
HttpServletResponse response, OutputStream out,
Map unhandledParameters, Window window, WebBrowser terminalType,
@@ -972,8 +976,9 @@ public class ApplicationServlet extends HttpServlet implements
* the HTTP request instance.
* @param response
* the HTTP response to write to.
- * @return boolean <code>true</code> if the request was handled and further processing
- * should be suppressed, <code>false</code> otherwise.
+ * @return boolean <code>true</code> if the request was handled and
+ * further processing should be suppressed, <code>false</code>
+ * otherwise.
* @see com.itmill.toolkit.terminal.URIHandler
*/
private DownloadStream handleURI(Application application,
@@ -1006,8 +1011,9 @@ public class ApplicationServlet extends HttpServlet implements
* before any windows URIs are processed and if a DownloadStream is returned
* it is sent to the client.
*
- * @param stream the download stream.
- *
+ * @param stream
+ * the download stream.
+ *
* @param request
* the HTTP request instance.
* @param response
@@ -1075,6 +1081,7 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Looks for default theme JAR file.
+ *
* @param fileList
* @return Jar file or null if not found.
*/
@@ -1159,10 +1166,12 @@ public class ApplicationServlet extends HttpServlet implements
* the HTTP request.
* @param response
* the HTTP response.
- * @return boolean <code>true</code> if the request was handled and further processing
- * should be suppressed, <code>false</code> otherwise.
- * @throws ServletException if an exception has occurred that interferes with the
- * servlet's normal operation.
+ * @return boolean <code>true</code> if the request was handled and
+ * further processing should be suppressed, <code>false</code>
+ * otherwise.
+ * @throws ServletException
+ * if an exception has occurred that interferes with the
+ * servlet's normal operation.
*/
private boolean handleResourceRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
@@ -1230,12 +1239,14 @@ public class ApplicationServlet extends HttpServlet implements
return true;
}
- /**
+ /**
* Gets the variable map for the session.
+ *
* @param application
- * @param request the HTTP request.
+ * @param request
+ * the HTTP request.
* @return the variable map.
- *
+ *
*/
private static synchronized HttpVariableMap getVariableMap(
Application application, HttpServletRequest request) {
@@ -1260,11 +1271,14 @@ public class ApplicationServlet extends HttpServlet implements
return variableMap;
}
- /**
+ /**
* Gets the current application URL from request.
- * @param request the HTTP request.
- * @throws MalformedURLException if the application is denied access to the
- * persistent data store represented by the given URL.
+ *
+ * @param request
+ * the HTTP request.
+ * @throws MalformedURLException
+ * if the application is denied access to the persistent data
+ * store represented by the given URL.
*/
private URL getApplicationUrl(HttpServletRequest request)
throws MalformedURLException {
@@ -1302,8 +1316,9 @@ public class ApplicationServlet extends HttpServlet implements
* the HTTP request.
* @return Application instance, or null if the URL does not map to valid
* application.
- * @throws MalformedURLException if the application is denied access to the
- * persistent data store represented by the given URL.
+ * @throws MalformedURLException
+ * if the application is denied access to the persistent data
+ * store represented by the given URL.
*/
private Application getApplication(HttpServletRequest request)
throws MalformedURLException {
@@ -1344,26 +1359,28 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Creates a new application.
- * @param request the HTTP request.
+ *
+ * @param request
+ * the HTTP request.
* @return the New application instance.
- * @throws MalformedURLException
- * if the application is denied access to the persistent
- * data store represented by the given URL.
+ * @throws MalformedURLException
+ * if the application is denied access to the persistent data
+ * store represented by the given URL.
* @throws InstantiationException
- * if a new instance of the class cannot be instantiated.
+ * if a new instance of the class cannot be instantiated.
* @throws IllegalAccessException
- * if it does not have access to the property accessor method.
+ * if it does not have access to the property accessor method.
* @throws LicenseFileHasNotBeenRead
- * if the license file has not been read.
- * @throws LicenseSignatureIsInvalid
- * if the license file has been changed or signature is
- * otherwise invalid.
+ * if the license file has not been read.
+ * @throws LicenseSignatureIsInvalid
+ * if the license file has been changed or signature is
+ * otherwise invalid.
* @throws InvalidLicenseFile
- * if the license file is not of correct XML format.
+ * if the license file is not of correct XML format.
* @throws LicenseViolation
*
- * @throws SAXException
- * the Error parsing the license file.
+ * @throws SAXException
+ * the Error parsing the license file.
*/
private Application createApplication(HttpServletRequest request)
throws MalformedURLException, InstantiationException,
@@ -1429,11 +1446,11 @@ public class ApplicationServlet extends HttpServlet implements
return application;
}
-
-/**
- *
- * @param application
- */
+
+ /**
+ *
+ * @param application
+ */
private void initializeLicense(Application application) {
License license = (License) licenseForApplicationClass.get(application
@@ -1444,22 +1461,22 @@ public class ApplicationServlet extends HttpServlet implements
}
application.setToolkitLicense(license);
}
-
-/**
- *
- * @param application
- * @throws LicenseFileHasNotBeenRead
- * if the license file has not been read.
- * @throws LicenseSignatureIsInvalid
- * if the license file has been changed or signature is
- * otherwise invalid.
- * @throws InvalidLicenseFile
- * if the license file is not of correct XML format.
- * @throws LicenseViolation
- *
- * @throws SAXException
- * the Error parsing the license file.
- */
+
+ /**
+ *
+ * @param application
+ * @throws LicenseFileHasNotBeenRead
+ * if the license file has not been read.
+ * @throws LicenseSignatureIsInvalid
+ * if the license file has been changed or signature is
+ * otherwise invalid.
+ * @throws InvalidLicenseFile
+ * if the license file is not of correct XML format.
+ * @throws LicenseViolation
+ *
+ * @throws SAXException
+ * the Error parsing the license file.
+ */
private void checkLicense(Application application)
throws LicenseFileHasNotBeenRead, LicenseSignatureIsInvalid,
InvalidLicenseFile, LicenseViolation, SAXException {
@@ -1538,12 +1555,17 @@ public class ApplicationServlet extends HttpServlet implements
return active;
}
- /**
+ /**
* Ends the application.
- * @param request the HTTP request.
- * @param response the HTTP response to write to.
- * @param application the application to end.
- * @throws IOException if the writing failed due to input/output error.
+ *
+ * @param request
+ * the HTTP request.
+ * @param response
+ * the HTTP response to write to.
+ * @param application
+ * the application to end.
+ * @throws IOException
+ * if the writing failed due to input/output error.
*/
private void endApplication(HttpServletRequest request,
HttpServletResponse response, Application application)
@@ -1571,10 +1593,11 @@ public class ApplicationServlet extends HttpServlet implements
* @param request
* the HTTP Request.
* @param application
- * the Application to query for window.
+ * the Application to query for window.
* @return Window mathing the given URI or null if not found.
- * @throws ServletException if an exception has occurred that interferes with the
- * servlet's normal operation.
+ * @throws ServletException
+ * if an exception has occurred that interferes with the
+ * servlet's normal operation.
*/
private Window getApplicationWindow(HttpServletRequest request,
Application application, Map params) throws ServletException {
@@ -1667,8 +1690,10 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Checks if web adapter is in debug mode. Extra output is generated to log
* when debug mode is enabled.
+ *
* @param parameters
- * @return <code>true</code> if the web adapter is in debug mode. otherwise <code>false</code>.
+ * @return <code>true</code> if the web adapter is in debug mode.
+ * otherwise <code>false</code>.
*/
public boolean isDebugMode(Map parameters) {
if (parameters != null) {
@@ -1688,12 +1713,12 @@ public class ApplicationServlet extends HttpServlet implements
public ThemeSource getThemeSource() {
return themeSource;
}
-
-/**
- *
- * @param application
- * @param window
- */
+
+ /**
+ *
+ * @param application
+ * @param window
+ */
protected void addDirtyWindow(Application application, Window window) {
synchronized (applicationToDirtyWindowSetMap) {
HashSet dirtyWindows = (HashSet) applicationToDirtyWindowSetMap
@@ -1705,12 +1730,12 @@ public class ApplicationServlet extends HttpServlet implements
dirtyWindows.add(window);
}
}
-
-/**
- *
- * @param application
- * @param window
- */
+
+ /**
+ *
+ * @param application
+ * @param window
+ */
protected void removeDirtyWindow(Application application, Window window) {
synchronized (applicationToDirtyWindowSetMap) {
HashSet dirtyWindows = (HashSet) applicationToDirtyWindowSetMap
@@ -1752,6 +1777,7 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Receives repaint request events.
+ *
* @see com.itmill.toolkit.terminal.Paintable.RepaintRequestListener#repaintRequested(Paintable.RepaintRequestEvent)
*/
public void repaintRequested(RepaintRequestEvent event) {
@@ -1771,10 +1797,11 @@ public class ApplicationServlet extends HttpServlet implements
}
}
- /**
+ /**
* Gets the list of dirty windows in application.
- * @param app
- * @return
+ *
+ * @param app
+ * @return
*/
protected Set getDirtyWindows(Application app) {
HashSet dirtyWindows;
@@ -1784,10 +1811,11 @@ public class ApplicationServlet extends HttpServlet implements
return dirtyWindows;
}
- /**
+ /**
* Removes a window from the list of dirty windows.
+ *
* @param app
- * @param window
+ * @param window
*/
private void windowPainted(Application app, Window window) {
removeDirtyWindow(app, window);
@@ -1796,8 +1824,11 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Generates server commands stream. If the server commands are not
* requested, return false.
- * @param request the HTTP request instance.
- * @param response the HTTP response to write to.
+ *
+ * @param request
+ * the HTTP request instance.
+ * @param response
+ * the HTTP response to write to.
*/
private boolean handleServerCommands(HttpServletRequest request,
HttpServletResponse response) {
@@ -1913,10 +1944,11 @@ public class ApplicationServlet extends HttpServlet implements
private class SessionBindingListener implements HttpSessionBindingListener {
private LinkedList applications;
-/**
- *
- * @param applications
- */
+
+ /**
+ *
+ * @param applications
+ */
protected SessionBindingListener(LinkedList applications) {
this.applications = applications;
}
@@ -1963,8 +1995,8 @@ public class ApplicationServlet extends HttpServlet implements
}
- /**
- * Implementation of ParameterHandler.ErrorEvent interface.
+ /**
+ * Implementation of ParameterHandler.ErrorEvent interface.
*/
public class ParameterHandlerErrorImpl implements
ParameterHandler.ErrorEvent {
@@ -1972,11 +2004,12 @@ public class ApplicationServlet extends HttpServlet implements
private ParameterHandler owner;
private Throwable throwable;
-/**
- *
- * @param owner
- * @param throwable
- */
+
+ /**
+ *
+ * @param owner
+ * @param throwable
+ */
private ParameterHandlerErrorImpl(ParameterHandler owner,
Throwable throwable) {
this.owner = owner;
@@ -1985,6 +2018,7 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Gets the contained throwable.
+ *
* @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
*/
public Throwable getThrowable() {
@@ -1993,6 +2027,7 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Gets the source ParameterHandler.
+ *
* @see com.itmill.toolkit.terminal.ParameterHandler.ErrorEvent#getParameterHandler()
*/
public ParameterHandler getParameterHandler() {
@@ -2001,19 +2036,20 @@ public class ApplicationServlet extends HttpServlet implements
}
- /**
- * Implementation of URIHandler.ErrorEvent interface.
+ /**
+ * Implementation of URIHandler.ErrorEvent interface.
*/
public class URIHandlerErrorImpl implements URIHandler.ErrorEvent {
private URIHandler owner;
private Throwable throwable;
-/**
- *
- * @param owner
- * @param throwable
- */
+
+ /**
+ *
+ * @param owner
+ * @param throwable
+ */
private URIHandlerErrorImpl(URIHandler owner, Throwable throwable) {
this.owner = owner;
this.throwable = throwable;
@@ -2021,6 +2057,7 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Gets the contained throwable.
+ *
* @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
*/
public Throwable getThrowable() {
@@ -2029,6 +2066,7 @@ public class ApplicationServlet extends HttpServlet implements
/**
* Gets the source URIHandler.
+ *
* @see com.itmill.toolkit.terminal.URIHandler.ErrorEvent#getURIHandler()
*/
public URIHandler getURIHandler() {
@@ -2074,11 +2112,13 @@ public class ApplicationServlet extends HttpServlet implements
}
/**
- * Gets resource path using different implementations. Required fo supporting
- * different servlet container implementations (application servers).
+ * Gets resource path using different implementations. Required fo
+ * supporting different servlet container implementations (application
+ * servers).
*
* @param servletContext
- * @param path the resource path.
+ * @param path
+ * the resource path.
* @return the resource path.
*/
protected static String getResourcePath(ServletContext servletContext,
diff --git a/src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java b/src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java
index 1b94e1e836..047b787bf5 100644
--- a/src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java
+++ b/src/com/itmill/toolkit/terminal/web/CollectionThemeSource.java
@@ -51,6 +51,7 @@ public class CollectionThemeSource implements ThemeSource {
/**
* Gets the name of the ThemeSource.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getName()
*/
public String getName() {
@@ -59,6 +60,7 @@ public class CollectionThemeSource implements ThemeSource {
/**
* Gets the XSL stream for the specified theme and web-browser type.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getXSLStreams(Theme,
* WebBrowser)
*/
@@ -78,15 +80,16 @@ public class CollectionThemeSource implements ThemeSource {
return xslFiles;
}
-
-/**
- *
- * @param theme
- * @param type
- * @return
- * @throws ThemeException If the resource is not found or there was
- * some problem finding the resource.
- */
+
+ /**
+ *
+ * @param theme
+ * @param type
+ * @return
+ * @throws ThemeException
+ * If the resource is not found or there was some problem
+ * finding the resource.
+ */
private Collection getParentXSLStreams(Theme theme, WebBrowser type)
throws ThemeException {
Collection xslFiles = new LinkedList();
@@ -105,6 +108,7 @@ public class CollectionThemeSource implements ThemeSource {
/**
* Gets the last modification time, used to reload theme on changes.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getModificationTime()
*/
public long getModificationTime() {
@@ -119,6 +123,7 @@ public class CollectionThemeSource implements ThemeSource {
/**
* Gets the input stream for the resource with the specified resource id.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getResource(String)
*/
public InputStream getResource(String resourceId) throws ThemeException {
@@ -136,7 +141,7 @@ public class CollectionThemeSource implements ThemeSource {
List themes = new LinkedList();
while (themeName != null && themeName.length() > 0) {
Theme t = this.getThemeByName(themeName);
- if (t != null)
+ if (t != null)
themes.add(themeName);
themeName = t.getParent();
}
@@ -164,6 +169,7 @@ public class CollectionThemeSource implements ThemeSource {
/**
* Gets the list of themes in the theme source.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getThemes()
*/
public Collection getThemes() {
@@ -177,7 +183,9 @@ public class CollectionThemeSource implements ThemeSource {
/**
* Gets the theme instance by name.
- * @param name the theme name.
+ *
+ * @param name
+ * the theme name.
* @see com.itmill.toolkit.terminal.web.ThemeSource#getThemeByName(String)
*/
public Theme getThemeByName(String name) {
diff --git a/src/com/itmill/toolkit/terminal/web/DebugWindow.java b/src/com/itmill/toolkit/terminal/web/DebugWindow.java
index cabfbcae2a..42d9f11fe5 100644
--- a/src/com/itmill/toolkit/terminal/web/DebugWindow.java
+++ b/src/com/itmill/toolkit/terminal/web/DebugWindow.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -51,13 +51,14 @@ import com.itmill.toolkit.terminal.FileResource;
import com.itmill.toolkit.ui.*;
/**
- * This class provides a debugging window where one may view the UIDL of
- * the current window, or in a tabset the UIDL of an active frameset.
+ * This class provides a debugging window where one may view the UIDL of the
+ * current window, or in a tabset the UIDL of an active frameset.
*
* It is primarily intended for creating and debugging themes.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class DebugWindow extends Window {
@@ -65,39 +66,45 @@ public class DebugWindow extends Window {
protected static String WINDOW_NAME = "debug";
private Application debuggedApplication;
+
private HashMap rawUIDL = new HashMap();
+
private ApplicationServlet servlet;
+
private HttpSession session;
private TabSheet tabs = new TabSheet();
+
private Select themeSelector;
+
private Label applicationInfo = new Label("", Label.CONTENT_XHTML);
/**
* Creates a new debug window for an application.
- * @param debuggedApplication the Application to be debugged.
- * @param session the Session to be debugged.
- * @param servlet the Servlet to be debugged.
+ *
+ * @param debuggedApplication
+ * the Application to be debugged.
+ * @param session
+ * the Session to be debugged.
+ * @param servlet
+ * the Servlet to be debugged.
*/
- protected DebugWindow(
- Application debuggedApplication,
- HttpSession session,
- ApplicationServlet servlet) {
+ protected DebugWindow(Application debuggedApplication, HttpSession session,
+ ApplicationServlet servlet) {
super("Debug window");
setName(WINDOW_NAME);
setServlet(servlet);
setSession(session);
setBorder(Window.BORDER_NONE);
-
// Creates control buttons
- OrderedLayout controls =
- new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
- controls.addComponent(
- new Button("Restart Application", this, "restartApplication"));
- controls.addComponent(
- new Button("Clear Session", this, "clearSession"));
+ OrderedLayout controls = new OrderedLayout(
+ OrderedLayout.ORIENTATION_HORIZONTAL);
+ controls.addComponent(new Button("Restart Application", this,
+ "restartApplication"));
+ controls
+ .addComponent(new Button("Clear Session", this, "clearSession"));
Collection themes = servlet.getThemeSource().getThemes();
Collection names = new LinkedList();
for (Iterator i = themes.iterator(); i.hasNext();) {
@@ -109,23 +116,19 @@ public class DebugWindow extends Window {
themeSelector.setWriteThrough(false);
// Terminal type editor
- Label terminal =
- new Label("<h2>Terminal Information</h2> ", Label.CONTENT_XHTML);
+ Label terminal = new Label("<h2>Terminal Information</h2> ",
+ Label.CONTENT_XHTML);
Form browser = new Form();
- browser.setItemDataSource(
- new BeanItem(WebBrowserProbe.getTerminalType(session)));
+ browser.setItemDataSource(new BeanItem(WebBrowserProbe
+ .getTerminalType(session)));
browser.removeItemProperty("class");
- browser.replaceWithSelect(
- "javaScriptVersion",
- WebBrowser.JAVASCRIPT_VERSIONS,
- WebBrowser.JAVASCRIPT_VERSIONS);
- browser.replaceWithSelect(
- "markupVersion",
- WebBrowser.MARKUP_VERSIONS,
- WebBrowser.MARKUP_VERSIONS);
+ browser.replaceWithSelect("javaScriptVersion",
+ WebBrowser.JAVASCRIPT_VERSIONS, WebBrowser.JAVASCRIPT_VERSIONS);
+ browser.replaceWithSelect("markupVersion", WebBrowser.MARKUP_VERSIONS,
+ WebBrowser.MARKUP_VERSIONS);
browser.setWriteThrough(false);
- Button setbrowser =
- new Button("Set terminal information", browser, "commit");
+ Button setbrowser = new Button("Set terminal information", browser,
+ "commit");
setbrowser.dependsOn(browser);
// Arrange the UI in tabsheet
@@ -133,20 +136,19 @@ public class DebugWindow extends Window {
addComponent(infoTabs);
OrderedLayout appInfo = new OrderedLayout();
- infoTabs.addTab(appInfo, "Application",null);
+ infoTabs.addTab(appInfo, "Application", null);
appInfo.addComponent(applicationInfo);
appInfo.addComponent(controls);
appInfo.addComponent(themeSelector);
appInfo.addComponent(new Button("Change theme", this, "commitTheme"));
-
OrderedLayout winInfo = new OrderedLayout();
- infoTabs.addTab(winInfo, "Windows",null);
+ infoTabs.addTab(winInfo, "Windows", null);
winInfo.addComponent(tabs);
winInfo.addComponent(new Button("Save UIDL", this, "saveUIDL"));
OrderedLayout termInfo = new OrderedLayout();
- infoTabs.addTab(termInfo, "Terminal",null);
+ infoTabs.addTab(termInfo, "Terminal", null);
termInfo.addComponent(terminal);
termInfo.addComponent(browser);
termInfo.addComponent(setbrowser);
@@ -155,18 +157,15 @@ public class DebugWindow extends Window {
setDebuggedApplication(debuggedApplication);
}
-
-/**
- *
- * @param caption
- * @param keys
- * @param names
- * @return
- */
- protected Select createSelect(
- String caption,
- Object[] keys,
- String[] names) {
+
+ /**
+ *
+ * @param caption
+ * @param keys
+ * @param names
+ * @return
+ */
+ protected Select createSelect(String caption, Object[] keys, String[] names) {
Select s = new Select(caption);
s.addContainerProperty("name", String.class, "");
for (int i = 0; i < keys.length; i++) {
@@ -175,7 +174,7 @@ public class DebugWindow extends Window {
s.setItemCaptionPropertyId("name");
return s;
}
-
+
/**
* Saves the UIDL.
*/
@@ -189,19 +188,15 @@ public class DebugWindow extends Window {
return;
DateFormat df = new SimpleDateFormat("yyyyMMdd-HHmmss");
- File file =
- new File(
- "/uidl-debug"
- + df.format(new Date(System.currentTimeMillis()))
- + ".xml");
+ File file = new File("/uidl-debug"
+ + df.format(new Date(System.currentTimeMillis())) + ".xml");
try {
- BufferedWriter out =
- new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(file)));
+ BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file)));
out.write(currentUIDL);
out.close();
- //Open the UIDL also
+ // Open the UIDL also
open(new FileResource(file, this.getApplication()));
Log.info("UIDL written to file " + file);
} catch (FileNotFoundException e) {
@@ -211,36 +206,36 @@ public class DebugWindow extends Window {
}
}
}
-
+
/**
* Commits the theme.
- *
+ *
*/
public void commitTheme() {
themeSelector.commit();
}
-
+
/**
* Clears the session.
*/
public void clearSession() {
session.invalidate();
}
-
+
/**
* Restarts the Application.
- *
+ *
*/
public void restartApplication() {
if (debuggedApplication != null)
debuggedApplication.close();
}
-
-/**
- *
- * @param window
- * @param uidl
- */
+
+ /**
+ *
+ * @param window
+ * @param uidl
+ */
protected void setWindowUIDL(Window window, String uidl) {
String caption = "UIDL:" + window.getName();
synchronized (tabs) {
@@ -263,36 +258,33 @@ public class DebugWindow extends Window {
}
}
}
-
-/**
- *
- * @param caption
- * @param uidl
- * @return
- */
+
+ /**
+ *
+ * @param caption
+ * @param uidl
+ * @return
+ */
protected String getHTMLFormattedUIDL(String caption, String uidl) {
StringBuffer sb = new StringBuffer();
// Print formatted UIDL with errors embedded
- //Perl5Util util = new Perl5Util();
+ // Perl5Util util = new Perl5Util();
int row = 0;
int prev = 0;
int index = 0;
boolean lastLineWasEmpty = false;
- sb.append(
- "<TABLE WIDTH=\"100%\" STYLE=\"border-left: 1px solid black; "
- + "border-right: 1px solid black; border-bottom: "
- + "1px solid black; border-top: 1px solid black\""
- + " cellpadding=\"0\" cellspacing=\"0\" BORDER=\"0\">");
+ sb
+ .append("<TABLE WIDTH=\"100%\" STYLE=\"border-left: 1px solid black; "
+ + "border-right: 1px solid black; border-bottom: "
+ + "1px solid black; border-top: 1px solid black\""
+ + " cellpadding=\"0\" cellspacing=\"0\" BORDER=\"0\">");
if (caption != null)
- sb.append(
- "<TR><TH BGCOLOR=\"#ddddff\" COLSPAN=\"2\">"
- + "<FONT SIZE=\"+2\">"
- + caption
- + "</FONT></TH></TR>\n");
+ sb.append("<TR><TH BGCOLOR=\"#ddddff\" COLSPAN=\"2\">"
+ + "<FONT SIZE=\"+2\">" + caption + "</FONT></TH></TR>\n");
boolean unfinished = true;
while (unfinished) {
@@ -313,10 +305,7 @@ public class DebugWindow extends Window {
line = WebPaintTarget.escapeXML(line);
// Code beautification : Comment lines
- line =
- replaceAll(
- line,
- "&lt;!--",
+ line = replaceAll(line, "&lt;!--",
"<SPAN STYLE = \"color: #00dd00\">&lt;!--");
line = replaceAll(line, "--&gt;", "--&gt;</SPAN>");
@@ -327,15 +316,13 @@ public class DebugWindow extends Window {
line = " " + line;
if (!(isEmpty && lastLineWasEmpty))
- sb.append(
- "<TR"
- + ((row % 10) > 4 ? " BGCOLOR=\"#eeeeff\"" : "")
- + ">"
- + "<TD VALIGN=\"top\" ALIGN=\"rigth\" STYLE=\"border-right: 1px solid gray\"> "
- + String.valueOf(row)
- + " </TD><TD>"
- + line
- + "</TD></TR>\n");
+ sb
+ .append("<TR"
+ + ((row % 10) > 4 ? " BGCOLOR=\"#eeeeff\"" : "")
+ + ">"
+ + "<TD VALIGN=\"top\" ALIGN=\"rigth\" STYLE=\"border-right: 1px solid gray\"> "
+ + String.valueOf(row) + " </TD><TD>" + line
+ + "</TD></TR>\n");
lastLineWasEmpty = isEmpty;
@@ -347,11 +334,11 @@ public class DebugWindow extends Window {
}
/**
- * Replaces the characters in a substring of this <code>String</code>
- * with characters in the specified <code>String</code>. The substring
- * begins at the specified <code>start</code> and extends to the character
- * at index <code>end - 1</code> or to the end of the
- * <code>String</code> if no such character exists.
+ * Replaces the characters in a substring of this <code>String</code> with
+ * characters in the specified <code>String</code>. The substring begins
+ * at the specified <code>start</code> and extends to the character at
+ * index <code>end - 1</code> or to the end of the <code>String</code>
+ * if no such character exists.
* <p>
* First the characters in the substring are removed and then the specified
* <code>String</code> is inserted at <code>start</code>. (The
@@ -361,31 +348,28 @@ public class DebugWindow extends Window {
* <p>
* NOTE: This operation is slow.
* </p>
- * @param text
- * @param start the beginning index, inclusive.
- * @param end the ending index, exclusive.
- * @param str the String that will replace previous contents.
- * @return This string buffer.
+ *
+ * @param text
+ * @param start
+ * the beginning index, inclusive.
+ * @param end
+ * the ending index, exclusive.
+ * @param str
+ * the String that will replace previous contents.
+ * @return This string buffer.
*/
- protected static String replace(
- String text,
- int start,
- int end,
- String str) {
+ protected static String replace(String text, int start, int end, String str) {
return new StringBuffer(text).replace(start, end, str).toString();
}
-
-/**
- *
- * @param text
- * @param oldStr
- * @param newStr
- * @return
- */
- protected static String replaceAll(
- String text,
- String oldStr,
- String newStr) {
+
+ /**
+ *
+ * @param text
+ * @param oldStr
+ * @param newStr
+ * @return
+ */
+ protected static String replaceAll(String text, String oldStr, String newStr) {
StringBuffer sb = new StringBuffer(text);
int newStrLen = newStr.length();
@@ -407,21 +391,23 @@ public class DebugWindow extends Window {
/**
* Sets the application.
- * @param application the application to set.
+ *
+ * @param application
+ * the application to set.
*/
protected void setDebuggedApplication(Application application) {
this.debuggedApplication = application;
if (application != null) {
- applicationInfo.setValue(
- "<h2>Application Class</h2> "
+ applicationInfo.setValue("<h2>Application Class</h2> "
+ application.getClass().getName());
- themeSelector.setPropertyDataSource(
- new MethodProperty(application, "theme"));
+ themeSelector.setPropertyDataSource(new MethodProperty(application,
+ "theme"));
}
}
/**
* Returns the servlet.
+ *
* @return the WebAdapterServlet.
*/
protected ApplicationServlet getServlet() {
@@ -430,6 +416,7 @@ public class DebugWindow extends Window {
/**
* Returns the session.
+ *
* @return the HttpSession.
*/
protected HttpSession getSession() {
@@ -438,7 +425,9 @@ public class DebugWindow extends Window {
/**
* Sets the servlet.
- * @param servlet the servlet to set.
+ *
+ * @param servlet
+ * the servlet to set.
*/
protected void setServlet(ApplicationServlet servlet) {
this.servlet = servlet;
@@ -446,7 +435,9 @@ public class DebugWindow extends Window {
/**
* Sets the session.
- * @param session the session to set.
+ *
+ * @param session
+ * the session to set.
*/
protected void setSession(HttpSession session) {
this.session = session;
diff --git a/src/com/itmill/toolkit/terminal/web/DirectoryThemeSource.java b/src/com/itmill/toolkit/terminal/web/DirectoryThemeSource.java
index f2df815716..7130d4c6c3 100644
--- a/src/com/itmill/toolkit/terminal/web/DirectoryThemeSource.java
+++ b/src/com/itmill/toolkit/terminal/web/DirectoryThemeSource.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -39,33 +39,42 @@ import java.util.LinkedList;
/**
* Theme source for reading themes from a directory on the Filesystem.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class DirectoryThemeSource implements ThemeSource {
private File path;
+
private Theme theme;
+
private ApplicationServlet webAdapterServlet;
- /**
- * Collection of subdirectory entries.
+ /**
+ * Collection of subdirectory entries.
*/
private Collection subdirs = new LinkedList();
- /**
- * Creates a new instance of ThemeRepository by reading the themes
- * from a local directory.
- * @param path the Path to the source directory .
- * @param webAdapterServlet
- * @throws ThemeException If the resource is not found or there was
- * some problem finding the resource.
- * @throws FileNotFoundException if no theme files are found.
- * @throws IOException if the writing failed due to input/output error.
+ /**
+ * Creates a new instance of ThemeRepository by reading the themes from a
+ * local directory.
+ *
+ * @param path
+ * the Path to the source directory .
+ * @param webAdapterServlet
+ * @throws ThemeException
+ * If the resource is not found or there was some problem
+ * finding the resource.
+ * @throws FileNotFoundException
+ * if no theme files are found.
+ * @throws IOException
+ * if the writing failed due to input/output error.
*/
public DirectoryThemeSource(File path, ApplicationServlet webAdapterServlet)
- throws ThemeException, FileNotFoundException, IOException {
+ throws ThemeException, FileNotFoundException, IOException {
this.path = path;
this.theme = null;
@@ -73,7 +82,7 @@ public class DirectoryThemeSource implements ThemeSource {
if (!this.path.isDirectory())
throw new java.io.FileNotFoundException(
- "Theme path must be a directory ('" + this.path + "')");
+ "Theme path must be a directory ('" + this.path + "')");
// Loads description file
File description = new File(path, Theme.DESCRIPTIONFILE);
@@ -81,8 +90,8 @@ public class DirectoryThemeSource implements ThemeSource {
try {
this.theme = new Theme(description);
} catch (Exception e) {
- throw new ThemeException(
- "ServletThemeSource: Failed to load '" + path,e);
+ throw new ThemeException("ServletThemeSource: Failed to load '"
+ + path, e);
}
// Debug info
@@ -91,24 +100,24 @@ public class DirectoryThemeSource implements ThemeSource {
}
} else {
- // There was no description file found.
- // Handle subdirectories recursively
+ // There was no description file found.
+ // Handle subdirectories recursively
File[] files = this.path.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
- this.subdirs.add(
- new DirectoryThemeSource(files[i], webAdapterServlet));
+ this.subdirs.add(new DirectoryThemeSource(files[i],
+ webAdapterServlet));
} else if (files[i].getName().toLowerCase().endsWith(".jar")) {
- this.subdirs.add(
- new JarThemeSource(files[i], webAdapterServlet, ""));
+ this.subdirs.add(new JarThemeSource(files[i],
+ webAdapterServlet, ""));
}
}
if (this.subdirs.isEmpty()) {
if (webAdapterServlet.isDebugMode(null)) {
- Log.debug(
- "DirectoryThemeSource: Ignoring empty directory: "
- + path);
+ Log
+ .debug("DirectoryThemeSource: Ignoring empty directory: "
+ + path);
}
}
}
@@ -116,14 +125,16 @@ public class DirectoryThemeSource implements ThemeSource {
/**
* Gets the XSL stream for the specified theme and web-browser type.
- * @see com.itmill.toolkit.terminal.web.ThemeSource#getXSLStreams(Theme, WebBrowser)
+ *
+ * @see com.itmill.toolkit.terminal.web.ThemeSource#getXSLStreams(Theme,
+ * WebBrowser)
*/
public Collection getXSLStreams(Theme theme, WebBrowser type)
- throws ThemeException {
+ throws ThemeException {
Collection xslFiles = new LinkedList();
- // If this directory contains a theme
- // return XSL from this theme
+ // If this directory contains a theme
+ // return XSL from this theme
if (this.theme != null) {
if (webAdapterServlet.isDebugMode(null)) {
@@ -137,7 +148,7 @@ public class DirectoryThemeSource implements ThemeSource {
this.theme = new Theme(description);
} catch (IOException e) {
throw new ThemeException(
- "Failed to reload theme description" + e);
+ "Failed to reload theme description" + e);
}
}
@@ -147,11 +158,12 @@ public class DirectoryThemeSource implements ThemeSource {
for (Iterator i = fileNames.iterator(); i.hasNext();) {
File f = new File(this.path, (String) i.next());
if (f.getName().endsWith(".xsl"))
- try {
- xslFiles.add(new XSLStream(f.getName(),new FileInputStream(f)));
- } catch (FileNotFoundException e) {
- throw new ThemeException("XSL File not found: " + f);
- }
+ try {
+ xslFiles.add(new XSLStream(f.getName(),
+ new FileInputStream(f)));
+ } catch (FileNotFoundException e) {
+ throw new ThemeException("XSL File not found: " + f);
+ }
}
} else {
@@ -171,14 +183,15 @@ public class DirectoryThemeSource implements ThemeSource {
/**
* Gets the last modification time, used to reload theme on changes.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getModificationTime()
*/
public long getModificationTime() {
long modTime = 0;
- // If this directory contains a theme
- // returns XSL from this theme
+ // If this directory contains a theme
+ // returns XSL from this theme
if (this.theme != null) {
// Gets modification time of the description file
@@ -213,20 +226,21 @@ public class DirectoryThemeSource implements ThemeSource {
/**
* Gets the input stream for the resource with the specified resource id.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getResource(String)
*/
public InputStream getResource(String resourceId)
- throws ThemeSource.ThemeException {
+ throws ThemeSource.ThemeException {
- // If this directory contains a theme
- // return resource from this theme
+ // If this directory contains a theme
+ // return resource from this theme
if (this.theme != null) {
try {
return new FileInputStream(new File(this.path, resourceId));
} catch (FileNotFoundException e) {
- throw new ThemeSource.ThemeException(
- "Resource " + resourceId + " not found.");
+ throw new ThemeSource.ThemeException("Resource " + resourceId
+ + " not found.");
}
} else {
@@ -243,13 +257,14 @@ public class DirectoryThemeSource implements ThemeSource {
}
}
- throw new ThemeSource.ThemeException(
- "Resource " + resourceId + " not found.");
+ throw new ThemeSource.ThemeException("Resource " + resourceId
+ + " not found.");
}
/**
* Gets the list of themes in the theme source.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getThemes()
*/
public Collection getThemes() {
@@ -268,6 +283,7 @@ public class DirectoryThemeSource implements ThemeSource {
/**
* Gets the name of the ThemeSource.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getName()
*/
public String getName() {
@@ -280,6 +296,7 @@ public class DirectoryThemeSource implements ThemeSource {
/**
* Gets the Theme instance by name.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getThemeByName(String)
*/
public Theme getThemeByName(String name) {
diff --git a/src/com/itmill/toolkit/terminal/web/HttpUploadStream.java b/src/com/itmill/toolkit/terminal/web/HttpUploadStream.java
index 0a54120ed9..deaeaeafec 100644
--- a/src/com/itmill/toolkit/terminal/web/HttpUploadStream.java
+++ b/src/com/itmill/toolkit/terminal/web/HttpUploadStream.java
@@ -1,103 +1,111 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
import java.io.InputStream;
-/**
+/**
* WebAdapter implementation of the UploadStream interface.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class HttpUploadStream
- implements com.itmill.toolkit.terminal.UploadStream {
+public class HttpUploadStream implements
+ com.itmill.toolkit.terminal.UploadStream {
- /**
- * Holds value of property variableName.
+ /**
+ * Holds value of property variableName.
*/
private String streamName;
+
private String contentName;
+
private String contentType;
- /**
- * Holds value of property variableValue.
+ /**
+ * Holds value of property variableValue.
*/
private InputStream stream;
- /**
+ /**
* Creates a new instance of UploadStreamImpl
- * @param name the name of the stream.
- * @param stream the input stream.
- * @param contentName the name of the content.
- * @param contentType the type of the content.
+ *
+ * @param name
+ * the name of the stream.
+ * @param stream
+ * the input stream.
+ * @param contentName
+ * the name of the content.
+ * @param contentType
+ * the type of the content.
*/
- public HttpUploadStream(
- String name,
- InputStream stream,
- String contentName,
- String contentType) {
+ public HttpUploadStream(String name, InputStream stream,
+ String contentName, String contentType) {
this.streamName = name;
this.stream = stream;
this.contentName = contentName;
this.contentType = contentType;
}
- /**
+ /**
* Gets the name of the stream.
+ *
* @return the name of the stream.
*/
public String getStreamName() {
return this.streamName;
}
- /**
+ /**
* Gets the input stream.
+ *
* @return the Input stream.
*/
public InputStream getStream() {
return this.stream;
}
- /**
+ /**
* Gets the input stream content type.
+ *
* @return the content type of the input stream.
*/
public String getContentType() {
return this.contentType;
}
- /**
- * Gets the stream content name.
- * Stream content name usually differs from the actual stream name.
- * It is used to identify the content of the stream.
+ /**
+ * Gets the stream content name. Stream content name usually differs from
+ * the actual stream name. It is used to identify the content of the stream.
+ *
* @return the Name of the stream content.
*/
public String getContentName() {
diff --git a/src/com/itmill/toolkit/terminal/web/HttpVariableMap.java b/src/com/itmill/toolkit/terminal/web/HttpVariableMap.java
index a54a67f7a3..a22d1a37f0 100644
--- a/src/com/itmill/toolkit/terminal/web/HttpVariableMap.java
+++ b/src/com/itmill/toolkit/terminal/web/HttpVariableMap.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -54,36 +54,42 @@ import java.util.Iterator;
* Class implementing the variable mappings.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class HttpVariableMap {
// Id <-> (Owner,Name) mapping
private Map idToNameMap = new HashMap();
+
private Map idToTypeMap = new HashMap();
+
private Map idToOwnerMap = new HashMap();
+
private Map idToValueMap = new HashMap();
+
private Map ownerToNameToIdMap = new WeakHashMap();
+
private Object mapLock = new Object();
// Id generator
private long lastId = 0;
- /**
+ /**
* Converts the string to a supported class.
- * @param type
- * @param value
+ *
+ * @param type
+ * @param value
* @throws java.lang.ClassCastException
*/
private static Object convert(Class type, String value)
- throws java.lang.ClassCastException {
+ throws java.lang.ClassCastException {
try {
// Boolean typed variables
if (type.equals(Boolean.class))
- return new Boolean(
- !(value.equals("") || value.equals("false")));
+ return new Boolean(!(value.equals("") || value.equals("false")));
// Integer typed variables
if (type.equals(Integer.class))
@@ -99,29 +105,27 @@ public class HttpVariableMap {
}
}
- /**
+ /**
* Registers a new variable.
- * @param name the name of the variable.
+ *
+ * @param name
+ * the name of the variable.
* @param type
* @param value
- * @param owner the Listener for variable changes.
- *
+ * @param owner
+ * the Listener for variable changes.
+ *
* @return id to assigned for this variable.
*/
- public String registerVariable(
- String name,
- Class type,
- Object value,
- VariableOwner owner) {
+ public String registerVariable(String name, Class type, Object value,
+ VariableOwner owner) {
// Checks that the type of the class is supported
- if (!(type.equals(Boolean.class)
- || type.equals(Integer.class)
- || type.equals(String.class)
- || type.equals(String[].class)
- || type.equals(UploadStream.class)))
- throw new SystemError(
- "Unsupported variable type: " + type.getClass());
+ if (!(type.equals(Boolean.class) || type.equals(Integer.class)
+ || type.equals(String.class) || type.equals(String[].class) || type
+ .equals(UploadStream.class)))
+ throw new SystemError("Unsupported variable type: "
+ + type.getClass());
synchronized (mapLock) {
@@ -148,10 +152,13 @@ public class HttpVariableMap {
}
}
- /**
+ /**
* Unregisters the variable.
- * @param name the name of the variable.
- * @param owner the Listener for variable changes.
+ *
+ * @param name
+ * the name of the variable.
+ * @param owner
+ * the Listener for variable changes.
*/
public void unregisterVariable(String name, VariableOwner owner) {
@@ -179,42 +186,44 @@ public class HttpVariableMap {
/**
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
private class ParameterContainer {
- /**
- * Constructs the mapping: listener to set of listened parameter names.
+ /**
+ * Constructs the mapping: listener to set of listened parameter names.
*/
private HashMap parameters = new HashMap();
- /**
- * Parameter values.
+ /**
+ * Parameter values.
*/
private HashMap values = new HashMap();
- /**
- * Multipart parser used for parsing the request.
+ /**
+ * Multipart parser used for parsing the request.
*/
private ServletMultipartRequest parser = null;
- /**
- * Name - Value mapping of parameters that are not variables.
+ /**
+ * Name - Value mapping of parameters that are not variables.
*/
private HashMap nonVariables = new HashMap();
- /**
- * Creates a new parameter container and parse the parameters from the request using
- * GET, POST and POST/MULTIPART parsing.
- * @param req the HTTP request.
- * @throws IOException if the writing failed due to input/output error.
+ /**
+ * Creates a new parameter container and parse the parameters from the
+ * request using GET, POST and POST/MULTIPART parsing.
+ *
+ * @param req
+ * the HTTP request.
+ * @throws IOException
+ * if the writing failed due to input/output error.
*/
public ParameterContainer(HttpServletRequest req) throws IOException {
// Parse GET / POST parameters
- for (Enumeration e = req.getParameterNames();
- e.hasMoreElements();
- ) {
+ for (Enumeration e = req.getParameterNames(); e.hasMoreElements();) {
String paramName = (String) e.nextElement();
String[] paramValues = req.getParameterValues(paramName);
addParam(paramName, paramValues);
@@ -222,28 +231,25 @@ public class HttpVariableMap {
// Parse multipart variables
try {
- parser =
- new ServletMultipartRequest(
- req,
+ parser = new ServletMultipartRequest(req,
MultipartRequest.MAX_READ_BYTES);
} catch (IllegalArgumentException ignored) {
parser = null;
}
if (parser != null) {
- for (Enumeration e = parser.getFileParameterNames();
- e.hasMoreElements();
- ) {
+ for (Enumeration e = parser.getFileParameterNames(); e
+ .hasMoreElements();) {
String paramName = (String) e.nextElement();
addParam(paramName, null);
}
- for (Enumeration e = parser.getParameterNames();
- e.hasMoreElements();
- ) {
+ for (Enumeration e = parser.getParameterNames(); e
+ .hasMoreElements();) {
String paramName = (String) e.nextElement();
Enumeration val = parser.getURLParameters(paramName);
- // Create a linked list from enumeration to calculate elements
+ // Create a linked list from enumeration to calculate
+ // elements
LinkedList l = new LinkedList();
while (val.hasMoreElements())
l.addLast(val.nextElement());
@@ -260,10 +266,12 @@ public class HttpVariableMap {
}
- /**
+ /**
* Adds the parameter to container.
- * @param name the name of the parameter.
- * @param value
+ *
+ * @param name
+ * the name of the parameter.
+ * @param value
*/
private void addParam(String name, String[] value) {
@@ -280,50 +288,46 @@ public class HttpVariableMap {
newVal[i] = curVal[i];
value = newVal;
- // Special case - if the set:-method is used for
- // declaring array of length 2, where either of the
+ // Special case - if the set:-method is used for
+ // declaring array of length 2, where either of the
// following conditions are true:
- // - the both items are the same
- // - the both items have the same length and
- // - the items only differ on last character
- // - second last character is '.'
- // - last char of one string is 'x' and other is 'y'
- // Browser is unporposely modifying the name.
+ // - the both items are the same
+ // - the both items have the same length and
+ // - the items only differ on last character
+ // - second last character is '.'
+ // - last char of one string is 'x' and other is 'y'
+ // Browser is unporposely modifying the name.
if (value.length == 2
- && value[0].length() == value[1].length()) {
+ && value[0].length() == value[1].length()) {
boolean same = true;
for (int i = 0; i < value[0].length() - 1 && same; i++)
if (value[0].charAt(i) != value[1].charAt(i))
same = false;
if (same
- && ((value[0].charAt(value[0].length() - 1) == 'x'
- && value[1].charAt(value[1].length() - 1) == 'y')
- || (value[0].charAt(value[0].length() - 1) == 'y'
- && value[1].charAt(value[1].length() - 1)
- == 'x'))) {
- value =
- new String[] {
- value[0].substring(
- 0,
- value[1].length() - 2)};
- } else
- if (same && value[0].equals(value[1]))
+ && ((value[0].charAt(value[0].length() - 1) == 'x' && value[1]
+ .charAt(value[1].length() - 1) == 'y') || (value[0]
+ .charAt(value[0].length() - 1) == 'y' && value[1]
+ .charAt(value[1].length() - 1) == 'x'))) {
+ value = new String[] { value[0].substring(0,
+ value[1].length() - 2) };
+ } else if (same && value[0].equals(value[1]))
value = new String[] { value[0] };
}
- // Special case - if the set:-method is used for
- // declaring array of length 3, where all of the
+ // Special case - if the set:-method is used for
+ // declaring array of length 3, where all of the
// following conditions are true:
- // - two last items have the same length
- // - the first item is 2 chars shorter
- // - the longer items only differ on last character
- // - the shortest item is a prefix of the longer ones
- // - second last character of longer ones is '.'
- // - last char of one long string is 'x' and other is 'y'
- // Browser is unporposely modifying the name. (Mozilla, Firefox, ..)
+ // - two last items have the same length
+ // - the first item is 2 chars shorter
+ // - the longer items only differ on last character
+ // - the shortest item is a prefix of the longer ones
+ // - second last character of longer ones is '.'
+ // - last char of one long string is 'x' and other is 'y'
+ // Browser is unporposely modifying the name. (Mozilla,
+ // Firefox, ..)
if (value.length == 3
- && value[1].length() == value[2].length() &&
- value[0].length() +2 == value[1].length()) {
+ && value[1].length() == value[2].length()
+ && value[0].length() + 2 == value[1].length()) {
boolean same = true;
for (int i = 0; i < value[1].length() - 1 && same; i++)
if (value[2].charAt(i) != value[1].charAt(i))
@@ -332,14 +336,11 @@ public class HttpVariableMap {
if (value[0].charAt(i) != value[1].charAt(i))
same = false;
if (same
- && (value[2].charAt(value[2].length() - 1) == 'x'
- && value[1].charAt(value[1].length() - 1) == 'y')
- || (value[2].charAt(value[2].length() - 1) == 'y'
- && value[1].charAt(value[1].length() - 1)
- == 'x')) {
- value =
- new String[] {
- value[0]};
+ && (value[2].charAt(value[2].length() - 1) == 'x' && value[1]
+ .charAt(value[1].length() - 1) == 'y')
+ || (value[2].charAt(value[2].length() - 1) == 'y' && value[1]
+ .charAt(value[1].length() - 1) == 'x')) {
+ value = new String[] { value[0] };
}
}
@@ -353,8 +354,8 @@ public class HttpVariableMap {
if (equalsIndex < 0)
return;
- StringTokenizer commalist =
- new StringTokenizer(name.substring(equalsIndex + 1), ",");
+ StringTokenizer commalist = new StringTokenizer(name
+ .substring(equalsIndex + 1), ",");
name = name.substring(10, equalsIndex);
String[] curVal = (String[]) values.get(name);
ArrayList elems = new ArrayList();
@@ -426,7 +427,8 @@ public class HttpVariableMap {
// If the owner can not be found
else {
- // If parameter has been mapped before, remove the old owner mapping
+ // If parameter has been mapped before, remove the old owner
+ // mapping
if (ref != null) {
// The owner has been destroyed, so we remove the mappings
@@ -442,10 +444,12 @@ public class HttpVariableMap {
}
- /**
+ /**
* Gets the set of all parameters connected to given variable owner.
- * @param owner the Listener for variable changes.
- * @return the set of all parameters connected to variable owner.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @return the set of all parameters connected to variable owner.
*/
public Set getParameters(VariableOwner owner) {
if (owner == null)
@@ -453,52 +457,60 @@ public class HttpVariableMap {
return (Set) parameters.get(owner);
}
- /**
- * Gets the set of all variable owners owning parameters in this request.
- * @return
+ /**
+ * Gets the set of all variable owners owning parameters in this
+ * request.
+ *
+ * @return
*/
public Set getOwners() {
return parameters.keySet();
}
- /**
+ /**
* Gets the value of a parameter.
- * @param parameterName the name of the parameter.
- * @return the value of the parameter.
+ *
+ * @param parameterName
+ * the name of the parameter.
+ * @return the value of the parameter.
*/
public String[] getValue(String parameterName) {
return (String[]) values.get(parameterName);
}
- /**
+ /**
* Gets the servlet multipart parser.
+ *
* @return the parser.
*/
public ServletMultipartRequest getParser() {
return parser;
}
- /**
+ /**
* Gets the name - value[] mapping of non variable paramteres.
- * @return
+ *
+ * @return
*/
public Map getNonVariables() {
return nonVariables;
}
}
- /**
+ /**
* Handles all variable changes in this request.
- * @param req the Http request to handle.
- * @param errorListener If the list is non null, only the listed listeners are
- * served. Otherwise all the listeners are served.
+ *
+ * @param req
+ * the Http request to handle.
+ * @param errorListener
+ * If the list is non null, only the listed listeners are served.
+ * Otherwise all the listeners are served.
* @return Name to Value[] mapping of unhandled variables.
- * @throws IOException if the writing failed due to input/output error.
+ * @throws IOException
+ * if the writing failed due to input/output error.
*/
- public Map handleVariables(
- HttpServletRequest req,
- Terminal.ErrorListener errorListener)
- throws IOException {
+ public Map handleVariables(HttpServletRequest req,
+ Terminal.ErrorListener errorListener) throws IOException {
// Gets the parameters
ParameterContainer parcon = new ParameterContainer(req);
@@ -509,7 +521,8 @@ public class HttpVariableMap {
// Handles all parameters for all listeners
while (!listeners.isEmpty()) {
VariableOwner listener = (VariableOwner) listeners.remove(0);
- boolean changed = false; // Has any of this owners variabes changed
+ boolean changed = false; // Has any of this owners variabes
+ // changed
// Handle all parameters for listener
Set params = parcon.getParameters(listener);
if (params != null) { // Name value mapping
@@ -522,14 +535,13 @@ public class HttpVariableMap {
Class varType = (Class) idToTypeMap.get(param);
Object varOldValue = idToValueMap.get(param);
if (varName == null || varType == null)
- Log.warn(
- "VariableMap: No variable found for parameter "
- + param
- + " ("
- + varName
- + ","
- + listener
- + ")");
+ Log
+ .warn("VariableMap: No variable found for parameter "
+ + param
+ + " ("
+ + varName
+ + ","
+ + listener + ")");
else {
ServletMultipartRequest parser = parcon.getParser();
@@ -537,24 +549,17 @@ public class HttpVariableMap {
// Upload events
if (varType.equals(UploadStream.class)) {
if (parser != null
- && parser.getFileParameter(
- param,
- MultipartRequest.FILENAME)
- != null) {
- String filename =
- (String) parser.getFileParameter(
- param,
- MultipartRequest.FILENAME);
- String contentType =
- (String) parser.getFileParameter(
- param,
- MultipartRequest.CONTENT_TYPE);
- UploadStream upload =
- new HttpUploadStream(
- varName,
- parser.getFileContents(param),
- filename,
- contentType);
+ && parser.getFileParameter(param,
+ MultipartRequest.FILENAME) != null) {
+ String filename = (String) parser
+ .getFileParameter(param,
+ MultipartRequest.FILENAME);
+ String contentType = (String) parser
+ .getFileParameter(param,
+ MultipartRequest.CONTENT_TYPE);
+ UploadStream upload = new HttpUploadStream(
+ varName, parser.getFileContents(param),
+ filename, contentType);
variables.put(varName, upload);
changed = true;
}
@@ -568,45 +573,37 @@ public class HttpVariableMap {
if (varType.equals(String[].class)) {
variables.put(varName, values);
- changed
- |= (!Arrays
- .equals(
- values,
- (String[]) varOldValue));
+ changed |= (!Arrays.equals(values,
+ (String[]) varOldValue));
} else {
try {
if (values.length == 1) {
- Object val =
- convert(varType, values[0]);
+ Object val = convert(varType,
+ values[0]);
variables.put(varName, val);
- changed
- |= ((val == null
- && varOldValue != null)
- || (val != null
- && !val.equals(
- varOldValue)));
- } else if (
- values.length == 0
- && varType.equals(
- Boolean.class)) {
+ changed |= ((val == null && varOldValue != null) || (val != null && !val
+ .equals(varOldValue)));
+ } else if (values.length == 0
+ && varType
+ .equals(Boolean.class)) {
Object val = new Boolean(false);
variables.put(varName, val);
- changed
- |= (!val.equals(varOldValue));
+ changed |= (!val
+ .equals(varOldValue));
} else {
- Log.warn(
- "Empty variable '"
- + varName
- + "' of type "
+ Log.warn("Empty variable '"
+ + varName + "' of type "
+ varType.toString());
}
} catch (java.lang.ClassCastException e) {
- Log.except(
- "WebVariableMap conversion exception",
- e);
- errorListener.terminalError(
- new TerminalErrorImpl(e));
+ Log
+ .except(
+ "WebVariableMap conversion exception",
+ e);
+ errorListener
+ .terminalError(new TerminalErrorImpl(
+ e));
}
}
}
@@ -620,8 +617,8 @@ public class HttpVariableMap {
listener.changeVariables(req, variables);
} catch (Throwable t) {
// Notify the error listener
- errorListener.terminalError(
- new VariableOwnerErrorImpl(listener, t));
+ errorListener.terminalError(new VariableOwnerErrorImpl(
+ listener, t));
}
}
}
@@ -630,22 +627,23 @@ public class HttpVariableMap {
return parcon.getNonVariables();
}
- /**
- * Implementation of VariableOwner.Error interface.
+ /**
+ * Implementation of VariableOwner.Error interface.
*/
public class TerminalErrorImpl implements Terminal.ErrorEvent {
private Throwable throwable;
-
-/**
- *
- * @param throwable
- */
+
+ /**
+ *
+ * @param throwable
+ */
private TerminalErrorImpl(Throwable throwable) {
this.throwable = throwable;
}
/**
* Gets the contained throwable.
+ *
* @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
*/
public Throwable getThrowable() {
@@ -654,29 +652,28 @@ public class HttpVariableMap {
}
- /**
- * Implementation of VariableOwner.Error interface.
+ /**
+ * Implementation of VariableOwner.Error interface.
*/
- public class VariableOwnerErrorImpl
- extends TerminalErrorImpl
- implements VariableOwner.ErrorEvent {
+ public class VariableOwnerErrorImpl extends TerminalErrorImpl implements
+ VariableOwner.ErrorEvent {
private VariableOwner owner;
-
-/**
- *
- * @param owner the Listener for variable changes.
- * @param throwable
- */
- private VariableOwnerErrorImpl(
- VariableOwner owner,
- Throwable throwable) {
+
+ /**
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param throwable
+ */
+ private VariableOwnerErrorImpl(VariableOwner owner, Throwable throwable) {
super(throwable);
this.owner = owner;
}
/**
* Gets the source VariableOwner.
+ *
* @see com.itmill.toolkit.terminal.VariableOwner.ErrorEvent#getVariableOwner()
*/
public VariableOwner getVariableOwner() {
@@ -685,13 +682,13 @@ public class HttpVariableMap {
}
- /**
- * Resolves the VariableOwners needed from the request and sort
- * them to assure that the dependencies are met (as well as possible).
+ /**
+ * Resolves the VariableOwners needed from the request and sort them to
+ * assure that the dependencies are met (as well as possible).
*
- * @param listeners
- * @return List of variable list changers, that are needed for handling
- * all the variables in the request
+ * @param listeners
+ * @return List of variable list changers, that are needed for handling all
+ * the variables in the request
*/
private List getDependencySortedListenerList(Set listeners) {
@@ -708,7 +705,8 @@ public class HttpVariableMap {
if (listener != null) {
Set dependencies = listener.getDirectDependencies();
- // The listeners with no dependencies are added to the front of the
+ // The listeners with no dependencies are added to the front of
+ // the
// list directly
if (dependencies == null || dependencies.isEmpty()) {
if (listener.isImmediate())
@@ -732,8 +730,8 @@ public class HttpVariableMap {
HashSet tmpdeepdeps = new HashSet();
while (!unresolved.isEmpty()) {
- VariableOwner l =
- (VariableOwner) unresolved.removeFirst();
+ VariableOwner l = (VariableOwner) unresolved
+ .removeFirst();
if (!tmpdeepdeps.contains(l)) {
tmpdeepdeps.add(l);
if (deepdeps.containsKey(l)) {
@@ -741,12 +739,11 @@ public class HttpVariableMap {
} else {
Set deps = l.getDirectDependencies();
if (deps != null && !deps.isEmpty())
- for (Iterator di = deps.iterator();
- di.hasNext();
- ) {
+ for (Iterator di = deps.iterator(); di
+ .hasNext();) {
Object d = di.next();
if (d != null
- && !tmpdeepdeps.contains(d))
+ && !tmpdeepdeps.contains(d))
unresolved.addLast(d);
}
}
@@ -767,23 +764,21 @@ public class HttpVariableMap {
// Adds each listener after the last depended listener already in
// the list
int index = -1;
- for (Iterator di = ((Set) deepdeps.get(l)).iterator();
- di.hasNext();
- ) {
+ for (Iterator di = ((Set) deepdeps.get(l)).iterator(); di.hasNext();) {
int k;
Object depended = di.next();
if (immediate) {
- k = resultImmediate.lastIndexOf(depended);
- }else {
- k = resultNormal.lastIndexOf(depended);
- }
+ k = resultImmediate.lastIndexOf(depended);
+ } else {
+ k = resultNormal.lastIndexOf(depended);
+ }
if (k > index)
index = k;
}
if (immediate) {
resultImmediate.add(index + 1, l);
} else {
- resultNormal.add(index + 1, l);
+ resultNormal.add(index + 1, l);
}
}
diff --git a/src/com/itmill/toolkit/terminal/web/JarThemeSource.java b/src/com/itmill/toolkit/terminal/web/JarThemeSource.java
index 47bf98150e..2761f795ff 100644
--- a/src/com/itmill/toolkit/terminal/web/JarThemeSource.java
+++ b/src/com/itmill/toolkit/terminal/web/JarThemeSource.java
@@ -69,8 +69,8 @@ public class JarThemeSource implements ThemeSource {
private Cache resourceCache = new Cache();
- /**
- * Collection of subdirectory entries.
+ /**
+ * Collection of subdirectory entries.
*/
private Collection subdirs = new LinkedList();
@@ -83,14 +83,14 @@ public class JarThemeSource implements ThemeSource {
* @param webAdapterServlet
* @param path
* the Path inside the archive to be processed.
- * @throws ThemeException
- * If the resource is not found or there was
- * some problem finding the resource.
+ * @throws ThemeException
+ * If the resource is not found or there was some problem
+ * finding the resource.
*
* @throws FileNotFoundException
* if no theme files are found.
* @throws IOException
- * if the writing failed due to input/output error.
+ * if the writing failed due to input/output error.
*/
public JarThemeSource(File file, ApplicationServlet webAdapterServlet,
String path) throws ThemeException, FileNotFoundException,
@@ -152,6 +152,7 @@ public class JarThemeSource implements ThemeSource {
/**
* Gets the XSL stream for the specified theme and web-browser type.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getXSLStreams(Theme,
* WebBrowser)
*/
@@ -219,6 +220,7 @@ public class JarThemeSource implements ThemeSource {
/**
* Gets the input stream for the resource with the specified resource id.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getResource(String)
*/
public InputStream getResource(String resourceId)
@@ -265,6 +267,7 @@ public class JarThemeSource implements ThemeSource {
/**
* Gets the list of themes in the theme source.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getThemes()
*/
public Collection getThemes() {
@@ -282,6 +285,7 @@ public class JarThemeSource implements ThemeSource {
/**
* Gets the name of the ThemeSource.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getName()
*/
public String getName() {
@@ -294,6 +298,7 @@ public class JarThemeSource implements ThemeSource {
/**
* Gets the Theme instance by name.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getThemeByName(String)
*/
public Theme getThemeByName(String name) {
@@ -315,29 +320,36 @@ public class JarThemeSource implements ThemeSource {
private class Cache {
private Map data = new HashMap();
-
+
/**
- * Associates the specified value with the specified key in this map.
- * If the map previously contained a mapping for this key, the old value
- * is replaced by the specified value.
- * @param key the key with which the specified value is to be associated.
- * @param value the value to be associated with the specified key.
+ * Associates the specified value with the specified key in this map. If
+ * the map previously contained a mapping for this key, the old value is
+ * replaced by the specified value.
+ *
+ * @param key
+ * the key with which the specified value is to be
+ * associated.
+ * @param value
+ * the value to be associated with the specified key.
*/
public void put(Object key, Object value) {
data.put(key, new SoftReference(new CacheItem(value)));
}
-
+
/**
- * Returns the value to which this map maps the specified key. Returns null
- * if the map contains no mapping for this key.
+ * Returns the value to which this map maps the specified key. Returns
+ * null if the map contains no mapping for this key.
* <p>
- * A return value of null does not necessarily indicate that the map contains
- * no mapping for the key; it's also possible that the map explicitly maps
- * the key to null. The containsKey operation may be used to distinguish these two cases.
+ * A return value of null does not necessarily indicate that the map
+ * contains no mapping for the key; it's also possible that the map
+ * explicitly maps the key to null. The containsKey operation may be
+ * used to distinguish these two cases.
* </p>
- * @param key the key whose associated value is to be returned.
+ *
+ * @param key
+ * the key whose associated value is to be returned.
* @return the value to which this map maps the specified key, or null
- * if the map contains no mapping for this key.
+ * if the map contains no mapping for this key.
*/
public Object get(Object key) {
SoftReference ref = (SoftReference) data.get(key);
@@ -345,10 +357,10 @@ public class JarThemeSource implements ThemeSource {
return ((CacheItem) ref.get()).getData();
return null;
}
-
+
/**
* Clears the data.
- *
+ *
*/
public void clear() {
data.clear();
@@ -364,7 +376,7 @@ public class JarThemeSource implements ThemeSource {
private class CacheItem {
private Object data;
-
+
/**
*
* @param data
@@ -372,7 +384,7 @@ public class JarThemeSource implements ThemeSource {
public CacheItem(Object data) {
this.data = data;
}
-
+
/**
*
* @return
@@ -380,7 +392,7 @@ public class JarThemeSource implements ThemeSource {
public Object getData() {
return this.data;
};
-
+
/**
* @see java.lang.Object#finalize()
*/
diff --git a/src/com/itmill/toolkit/terminal/web/Log.java b/src/com/itmill/toolkit/terminal/web/Log.java
index a46ba3a01b..ddc6ec2e3a 100644
--- a/src/com/itmill/toolkit/terminal/web/Log.java
+++ b/src/com/itmill/toolkit/terminal/web/Log.java
@@ -1,38 +1,38 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
-/**
+/**
* <p>
- * Class providing centralized logging services. The logger defines
- * five message types, and provides methods to create messages of those
- * types. These types are:
+ * Class providing centralized logging services. The logger defines five message
+ * types, and provides methods to create messages of those types. These types
+ * are:
* </p>
*
* <ul>
@@ -40,8 +40,8 @@ package com.itmill.toolkit.terminal.web;
* operation of the application.
* <li> <code>warning</code> - An error situation has occurred, but the
* operation was able to finish succesfully.
- * <li> <code>error</code> - An error situation which prevented the
- * operation from finishing succesfully.
+ * <li> <code>error</code> - An error situation which prevented the operation
+ * from finishing succesfully.
* <li> <code>debug</code> - Internal information from the application meant
* for developers.
* <li> <code>exception</code> - A Java exception reported using the logger.
@@ -51,66 +51,83 @@ package com.itmill.toolkit.terminal.web;
* <p>
* Currently the class offers logging only to the standard output.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Log {
- private static boolean useStdOut = true;
-
- private static String LOG_MSG_INFO = "[INFO]";
- private static String LOG_MSG_ERROR = "[ERROR]";
- private static String LOG_MSG_WARN = "[WARNING]";
- private static String LOG_MSG_DEBUG = "[DEBUG]";
- private static String LOG_MSG_EXCEPT = "[EXCEPTION]";
-
- /**
- * Logs the <code>warning</code> message.
- *
- * @param message the Message String to be logged.
- */
- protected static synchronized void warn(java.lang.String message) {
- if (Log.useStdOut) System.out.println(LOG_MSG_WARN+ " "+message);
- }
- /**
- * Logs the <code>debug</code> message.
- *
- * @param message the Message String to be logged.
- */
- protected static synchronized void debug(java.lang.String message) {
- if (Log.useStdOut) System.out.println(LOG_MSG_DEBUG+ " "+message);
- }
-
- /**
- * Logs an <code>info</code> message.
- *
- * @param message the Message String to be logged.
- */
- protected static synchronized void info(java.lang.String message) {
- if (Log.useStdOut) System.out.println(LOG_MSG_INFO+ " "+message);
- }
-
- /**
- * Logs the Java exception and an accompanying error message.
- *
- * @param message the Message String to be logged.
- * @param e the Exception to be logged.
- */
- protected static synchronized void except(java.lang.String message, Exception e) {
- if (Log.useStdOut) {
- System.out.println(LOG_MSG_EXCEPT+ " "+message);
- e.printStackTrace();
- }
- }
-
- /**
- * Logs the <code>error</code> message.
- *
- * @param message the Message String to be logged.
- */
- protected static synchronized void error(java.lang.String message) {
- if (Log.useStdOut) System.out.println(LOG_MSG_ERROR+ " "+message);
- }
+ private static boolean useStdOut = true;
+
+ private static String LOG_MSG_INFO = "[INFO]";
+
+ private static String LOG_MSG_ERROR = "[ERROR]";
+
+ private static String LOG_MSG_WARN = "[WARNING]";
+
+ private static String LOG_MSG_DEBUG = "[DEBUG]";
+
+ private static String LOG_MSG_EXCEPT = "[EXCEPTION]";
+
+ /**
+ * Logs the <code>warning</code> message.
+ *
+ * @param message
+ * the Message String to be logged.
+ */
+ protected static synchronized void warn(java.lang.String message) {
+ if (Log.useStdOut)
+ System.out.println(LOG_MSG_WARN + " " + message);
+ }
+
+ /**
+ * Logs the <code>debug</code> message.
+ *
+ * @param message
+ * the Message String to be logged.
+ */
+ protected static synchronized void debug(java.lang.String message) {
+ if (Log.useStdOut)
+ System.out.println(LOG_MSG_DEBUG + " " + message);
+ }
+
+ /**
+ * Logs an <code>info</code> message.
+ *
+ * @param message
+ * the Message String to be logged.
+ */
+ protected static synchronized void info(java.lang.String message) {
+ if (Log.useStdOut)
+ System.out.println(LOG_MSG_INFO + " " + message);
+ }
+
+ /**
+ * Logs the Java exception and an accompanying error message.
+ *
+ * @param message
+ * the Message String to be logged.
+ * @param e
+ * the Exception to be logged.
+ */
+ protected static synchronized void except(java.lang.String message,
+ Exception e) {
+ if (Log.useStdOut) {
+ System.out.println(LOG_MSG_EXCEPT + " " + message);
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Logs the <code>error</code> message.
+ *
+ * @param message
+ * the Message String to be logged.
+ */
+ protected static synchronized void error(java.lang.String message) {
+ if (Log.useStdOut)
+ System.out.println(LOG_MSG_ERROR + " " + message);
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/web/MultipartRequest.java b/src/com/itmill/toolkit/terminal/web/MultipartRequest.java
index a6358480db..3b2620c6a5 100644
--- a/src/com/itmill/toolkit/terminal/web/MultipartRequest.java
+++ b/src/com/itmill/toolkit/terminal/web/MultipartRequest.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -44,73 +44,84 @@ import java.util.Vector;
import java.io.File;
/**
- * A Multipart form data parser. Parses an input stream and writes out any files found,
- * making available a hashtable of other url parameters. As of version 1.17 the files can
- * be saved to memory, and optionally written to a database, etc.
- *
- * <BR>
+ * A Multipart form data parser. Parses an input stream and writes out any files
+ * found, making available a hashtable of other url parameters. As of version
+ * 1.17 the files can be saved to memory, and optionally written to a database,
+ * etc.
+ *
* <BR>
- * Copyright (C)2001 Jason Pell.
* <BR>
- *
+ * Copyright (C)2001 Jason Pell. <BR>
+ *
* <PRE>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * <BR>
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * <BR>
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * <BR>
- * Email: jasonpell@hotmail.com
- * Url: http://www.geocities.com/jasonpell
- * </PRE>
- *
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version. <BR>
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details. <BR>
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA <BR>
+ * Email: jasonpell@hotmail.com Url: http://www.geocities.com/jasonpell
+ *
+ * </PRE>
+ *
* @author Jason Pell
- *
- * @version 1.18 Fixed some serious bugs. A new method readAndWrite(InputStream in, OutputStream out) which now does
- * the generic processing in common for readAndWriteFile and readFile. The differences are that now
- * the two extra bytes at the end of a file upload are processed once, instead of after each line. Also
- * if an empty file is encountered, an outputstream is opened, but then deleted if no data written to it.
- * The <code>getCharArray</code> method has been removed. Replaced by the new String(bytes, encoding) method using
- * a specific encoding (Defaults to ISO-8859-1) to ensure that extended characters are supported.
- * All strings are processed using this encoding. The addition of static methods setEncoding(String)
- * and <code>getEncoding</code> method to allow the use of <code>MultipartRequest</code> with a specific encoding type. All instances
- * of MultipartRequest will utilise the static charEncoding variable value, that the <code>setEncoding</code> method
- * can be used to set. Started to introduce support for multiple file uploads with the same form field
- * name, but not completed for v1.18. 26/06/2001
- *
- * @version 1.17 A few _very_ minor fixes. Plus a cool new feature added. The ability to save files into memory.
- * <b>Thanks to Mark Latham for the idea and some of the code.</b> 11/04/2001
- * @version 1.16 Added support for multiple parameter values. Also fixed getCharArray(...) method to support
- * parameters with non-english ascii values (ascii above 127). Thanks to Stefan Schmidt &
- * Michael Elvers for this. (No fix yet for reported problems with Tomcat 3.2 or a single extra
- * byte appended to uploads of certain files). By 1.17 hopefully will have a resolution for the
- * second problem. 14/03/2001
- * @version 1.15 A new parameter added, intMaxReadBytes, to allow arbitrary length files. Released under
- * the LGPL (Lesser General Public License). 03/02/2001
- * @version 1.14 Fix for IE problem with filename being empty. This is because IE includes a default Content-Type
- * even when no file is uploaded. 16/02/2001
- * @version 1.13 If an upload directory is not specified, then all file contents are sent into oblivion, but the
- * rest of the parsing works as normal.
- * @version 1.12 Fix, was allowing zero length files. Will not even create the output file until there is
- * something to write. getFile(String) now returns null, if a zero length file was specified. 06/11/2000
- * @version 1.11 Fix, in case Content-type is not specified.
- * @version 1.1 Removed dependence on Servlets. Now passes in a generic InputStream instead.
- * "Borrowed" readLine from Tomcat 3.1 ServletInputStream class,
- * so we can remove some of the dependencies on ServletInputStream.
- * Fixed bug where a empty INPUT TYPE="FILE" value, would cause an exception.
- * @version 1.0 Initial Release.
+ *
+ * @version 1.18 Fixed some serious bugs. A new method readAndWrite(InputStream
+ * in, OutputStream out) which now does the generic processing in
+ * common for readAndWriteFile and readFile. The differences are that
+ * now the two extra bytes at the end of a file upload are processed
+ * once, instead of after each line. Also if an empty file is
+ * encountered, an outputstream is opened, but then deleted if no data
+ * written to it. The <code>getCharArray</code> method has been
+ * removed. Replaced by the new String(bytes, encoding) method using a
+ * specific encoding (Defaults to ISO-8859-1) to ensure that extended
+ * characters are supported. All strings are processed using this
+ * encoding. The addition of static methods setEncoding(String) and
+ * <code>getEncoding</code> method to allow the use of
+ * <code>MultipartRequest</code> with a specific encoding type. All
+ * instances of MultipartRequest will utilise the static charEncoding
+ * variable value, that the <code>setEncoding</code> method can be
+ * used to set. Started to introduce support for multiple file uploads
+ * with the same form field name, but not completed for v1.18.
+ * 26/06/2001
+ *
+ * @version 1.17 A few _very_ minor fixes. Plus a cool new feature added. The
+ * ability to save files into memory. <b>Thanks to Mark Latham for the
+ * idea and some of the code.</b> 11/04/2001
+ * @version 1.16 Added support for multiple parameter values. Also fixed
+ * getCharArray(...) method to support parameters with non-english
+ * ascii values (ascii above 127). Thanks to Stefan Schmidt & Michael
+ * Elvers for this. (No fix yet for reported problems with Tomcat 3.2
+ * or a single extra byte appended to uploads of certain files). By
+ * 1.17 hopefully will have a resolution for the second problem.
+ * 14/03/2001
+ * @version 1.15 A new parameter added, intMaxReadBytes, to allow arbitrary
+ * length files. Released under the LGPL (Lesser General Public
+ * License). 03/02/2001
+ * @version 1.14 Fix for IE problem with filename being empty. This is because
+ * IE includes a default Content-Type even when no file is uploaded.
+ * 16/02/2001
+ * @version 1.13 If an upload directory is not specified, then all file contents
+ * are sent into oblivion, but the rest of the parsing works as normal.
+ * @version 1.12 Fix, was allowing zero length files. Will not even create the
+ * output file until there is something to write. getFile(String) now
+ * returns null, if a zero length file was specified. 06/11/2000
+ * @version 1.11 Fix, in case Content-type is not specified.
+ * @version 1.1 Removed dependence on Servlets. Now passes in a generic
+ * InputStream instead. "Borrowed" readLine from Tomcat 3.1
+ * ServletInputStream class, so we can remove some of the dependencies
+ * on ServletInputStream. Fixed bug where a empty INPUT TYPE="FILE"
+ * value, would cause an exception.
+ * @version 1.0 Initial Release.
*/
-public class MultipartRequest
-{
+public class MultipartRequest {
/**
* Defines Character Encoding method here.
*/
@@ -120,22 +131,27 @@ public class MultipartRequest
private PrintWriter debug = null;
private Hashtable htParameters = null;
+
private Hashtable htFiles = null;
private String strBoundary = null;
-
- // If this Directory spec remains null, writing of files will be disabled...
+
+ // If this Directory spec remains null, writing of files will be disabled...
private File fileOutPutDirectory = null;
+
private boolean loadIntoMemory = false;
private long intContentLength = -1;
+
private long intTotalRead = -1;
/**
* Prevent a denial of service by defining this, will never read more data.
- * If Content-Length is specified to be more than this, will throw an exception.
- *
- * This limits the maximum number of bytes to the value of an int, which is 2 Gigabytes.
+ * If Content-Length is specified to be more than this, will throw an
+ * exception.
+ *
+ * This limits the maximum number of bytes to the value of an int, which is
+ * 2 Gigabytes.
*/
public static final int MAX_READ_BYTES = Integer.MAX_VALUE;
@@ -145,7 +161,8 @@ public class MultipartRequest
public static final int READ_LINE_BLOCK = 1024 * 128;
/**
- * Store a read from the input stream here. Global so we do not keep creating new arrays each read.
+ * Store a read from the input stream here. Global so we do not keep
+ * creating new arrays each read.
*/
private byte[] blockOfBytes = null;
@@ -153,48 +170,50 @@ public class MultipartRequest
* Type constant for File FILENAME.
*/
public static final int FILENAME = 0;
-
+
/**
* Type constant for the File CONTENT_TYPE.
*/
public static final int CONTENT_TYPE = 1;
/**
- * Type constant for the File SIZE.
+ * Type constant for the File SIZE.
*/
public static final int SIZE = 2;
-
+
/**
* Type constant for the File CONTENTS.
- *
+ *
* <b>Note: </b>Only used for file upload to memory.
*/
public static final int CONTENTS = 3;
/**
- * This method should be called on the <code>MultipartRequest</code> itself, not on any
- * instances of <code>MultipartRequest</code>, because this sets up the encoding for all
- * instances of multipartrequest. You can set the encoding to null, in which
- * case the default encoding will be applied. The default encoding if this method
- * is not called has been set to ISO-8859-1, which seems to offer the best hope
- * of support for international characters, such as german "Umlaut" characters.
- *
- * <p><b>Warning:</b> In multithreaded environments it is the responsibility of the
- * implementer to make sure that this method is not called while another instance
- * is being constructed. When an instance of MultipartRequest is constructed, it parses
- * the input data, and uses the result of <code>getEncoding</code> method to convert between bytes and
- * strings. If <code>setEncoding</code> method is called by another thread, while the private <code>parse</code> method is
- * executing, the method will utilise this new encoding, which may cause serious
- * problems.</p>
+ * This method should be called on the <code>MultipartRequest</code>
+ * itself, not on any instances of <code>MultipartRequest</code>, because
+ * this sets up the encoding for all instances of multipartrequest. You can
+ * set the encoding to null, in which case the default encoding will be
+ * applied. The default encoding if this method is not called has been set
+ * to ISO-8859-1, which seems to offer the best hope of support for
+ * international characters, such as german "Umlaut" characters.
+ *
+ * <p>
+ * <b>Warning:</b> In multithreaded environments it is the responsibility
+ * of the implementer to make sure that this method is not called while
+ * another instance is being constructed. When an instance of
+ * MultipartRequest is constructed, it parses the input data, and uses the
+ * result of <code>getEncoding</code> method to convert between bytes and
+ * strings. If <code>setEncoding</code> method is called by another
+ * thread, while the private <code>parse</code> method is executing, the
+ * method will utilise this new encoding, which may cause serious problems.
+ * </p>
*/
- public void setEncoding(String enc) throws UnsupportedEncodingException
- {
- if (enc==null || enc.trim()=="")
+ public void setEncoding(String enc) throws UnsupportedEncodingException {
+ if (enc == null || enc.trim() == "")
charEncoding = System.getProperty("file.encoding");
- else
- {
+ else {
// This will test the encoding for validity.
- new String(new byte[]{'\n'}, enc);
+ new String(new byte[] { '\n' }, enc);
charEncoding = enc;
}
@@ -202,183 +221,241 @@ public class MultipartRequest
/**
* Gets the current encoding method.
+ *
* @return the encoding method.
*/
- public String getEncoding()
- {
+ public String getEncoding() {
return charEncoding;
}
- /**
+ /**
* Constructor.
- *
- * @param strContentTypeText the &quot;Content-Type&quot; HTTP header value.
- * @param intContentLength the &quot;Content-Length&quot; HTTP header value.
- * @param in the InputStream to read and parse.
- * @param strSaveDirectory the temporary directory to save the file from where they can then be moved to wherever by the
- * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
- * will be silently ignored.</b>
- *
- * @exception IllegalArgumentException If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
- * @exception IOException If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
- *
+ *
+ * @param strContentTypeText
+ * the &quot;Content-Type&quot; HTTP header value.
+ * @param intContentLength
+ * the &quot;Content-Length&quot; HTTP header value.
+ * @param in
+ * the InputStream to read and parse.
+ * @param strSaveDirectory
+ * the temporary directory to save the file from where they can
+ * then be moved to wherever by the calling process. <b>If you
+ * specify <u>null</u> for this parameter, then any files
+ * uploaded will be silently ignored.</b>
+ *
+ * @exception IllegalArgumentException
+ * If the strContentTypeText does not contain a Content-Type
+ * of "multipart/form-data" or the boundary is not found.
+ * @exception IOException
+ * If the intContentLength is higher than MAX_READ_BYTES or
+ * strSaveDirectory is invalid or cannot be written to.
+ *
* @see #MAX_READ_BYTES
*/
- public MultipartRequest(String strContentTypeText,
- int intContentLength,
- InputStream in,
- String strSaveDirectory) throws IllegalArgumentException, IOException
- {
- this(null, strContentTypeText, intContentLength, in, strSaveDirectory, MAX_READ_BYTES);
+ public MultipartRequest(String strContentTypeText, int intContentLength,
+ InputStream in, String strSaveDirectory)
+ throws IllegalArgumentException, IOException {
+ this(null, strContentTypeText, intContentLength, in, strSaveDirectory,
+ MAX_READ_BYTES);
}
-
- /**
+
+ /**
* Constructor.
- *
- * @param strContentTypeText the &quot;Content-Type&quot; HTTP header value.
- * @param intContentLength the &quot;Content-Length&quot; HTTP header value.
- * @param in the InputStream to read and parse.
- * @param strSaveDirectory the temporary directory to save the file from where they can then be moved to wherever by the
- * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
- * will be silently ignored.</B>
- * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
- *
- * @exception IllegalArgumentException If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
- * @exception IOException If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
- *
+ *
+ * @param strContentTypeText
+ * the &quot;Content-Type&quot; HTTP header value.
+ * @param intContentLength
+ * the &quot;Content-Length&quot; HTTP header value.
+ * @param in
+ * the InputStream to read and parse.
+ * @param strSaveDirectory
+ * the temporary directory to save the file from where they can
+ * then be moved to wherever by the calling process. <b>If you
+ * specify <u>null</u> for this parameter, then any files
+ * uploaded will be silently ignored.</B>
+ * @param intMaxReadBytes
+ * Overrides the MAX_BYTES_READ value, to allow arbitrarily long
+ * files.
+ *
+ * @exception IllegalArgumentException
+ * If the strContentTypeText does not contain a Content-Type
+ * of "multipart/form-data" or the boundary is not found.
+ * @exception IOException
+ * If the intContentLength is higher than MAX_READ_BYTES or
+ * strSaveDirectory is invalid or cannot be written to.
+ *
* @see #MAX_READ_BYTES
*/
- public MultipartRequest(String strContentTypeText,
- int intContentLength,
- InputStream in,
- String strSaveDirectory,
- int intMaxReadBytes) throws IllegalArgumentException, IOException
- {
- this(null, strContentTypeText, intContentLength, in, strSaveDirectory, intMaxReadBytes);
+ public MultipartRequest(String strContentTypeText, int intContentLength,
+ InputStream in, String strSaveDirectory, int intMaxReadBytes)
+ throws IllegalArgumentException, IOException {
+ this(null, strContentTypeText, intContentLength, in, strSaveDirectory,
+ intMaxReadBytes);
}
- /**
+ /**
* Constructor.
- *
- * @param debug A PrintWriter that can be used for debugging.
- * @param strContentTypeText the &quot;Content-Type&quot; HTTP header value.
- * @param intContentLength the &quot;Content-Length&quot; HTTP header value.
- * @param in the InputStream to read and parse.
- * @param strSaveDirectory the temporary directory to save the file from where they can then be moved to wherever by the
- * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
- * will be silently ignored.</B>
- *
- * @exception IllegalArgumentException If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
- * @exception IOException If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
- *
+ *
+ * @param debug
+ * A PrintWriter that can be used for debugging.
+ * @param strContentTypeText
+ * the &quot;Content-Type&quot; HTTP header value.
+ * @param intContentLength
+ * the &quot;Content-Length&quot; HTTP header value.
+ * @param in
+ * the InputStream to read and parse.
+ * @param strSaveDirectory
+ * the temporary directory to save the file from where they can
+ * then be moved to wherever by the calling process. <b>If you
+ * specify <u>null</u> for this parameter, then any files
+ * uploaded will be silently ignored.</B>
+ *
+ * @exception IllegalArgumentException
+ * If the strContentTypeText does not contain a Content-Type
+ * of "multipart/form-data" or the boundary is not found.
+ * @exception IOException
+ * If the intContentLength is higher than MAX_READ_BYTES or
+ * strSaveDirectory is invalid or cannot be written to.
+ *
* @see #MAX_READ_BYTES
- * @deprecated Replaced by MultipartRequest(PrintWriter, String, int, InputStream, int)
- * You can specify MultipartRequest.MAX_READ_BYTES for the intMaxReadBytes parameter
+ * @deprecated Replaced by MultipartRequest(PrintWriter, String, int,
+ * InputStream, int) You can specify
+ * MultipartRequest.MAX_READ_BYTES for the intMaxReadBytes
+ * parameter
*/
- public MultipartRequest(PrintWriter debug,
- String strContentTypeText,
- int intContentLength,
- InputStream in,
- String strSaveDirectory) throws IllegalArgumentException, IOException
- {
- this(debug, strContentTypeText, intContentLength, in, strSaveDirectory, MAX_READ_BYTES);
+ public MultipartRequest(PrintWriter debug, String strContentTypeText,
+ int intContentLength, InputStream in, String strSaveDirectory)
+ throws IllegalArgumentException, IOException {
+ this(debug, strContentTypeText, intContentLength, in, strSaveDirectory,
+ MAX_READ_BYTES);
}
- /**
+ /**
* Constructor - load into memory constructor
- *
- * @param debug A PrintWriter that can be used for debugging.
- * @param strContentTypeText the &quot;Content-Type&quot; HTTP header value.
- * @param intContentLength the &quot;Content-Length&quot; HTTP header value.
- * @param in the InputStream to read and parse.
- * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
- *
- * @exception IllegalArgumentException If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
- * @exception IOException If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
- *
+ *
+ * @param debug
+ * A PrintWriter that can be used for debugging.
+ * @param strContentTypeText
+ * the &quot;Content-Type&quot; HTTP header value.
+ * @param intContentLength
+ * the &quot;Content-Length&quot; HTTP header value.
+ * @param in
+ * the InputStream to read and parse.
+ * @param intMaxReadBytes
+ * Overrides the MAX_BYTES_READ value, to allow arbitrarily long
+ * files.
+ *
+ * @exception IllegalArgumentException
+ * If the strContentTypeText does not contain a Content-Type
+ * of "multipart/form-data" or the boundary is not found.
+ * @exception IOException
+ * If the intContentLength is higher than MAX_READ_BYTES or
+ * strSaveDirectory is invalid or cannot be written to.
+ *
* @see #MAX_READ_BYTES
*/
- public MultipartRequest(PrintWriter debug,
- String strContentTypeText,
- int intContentLength,
- InputStream in,
- int intMaxReadBytes) throws IllegalArgumentException, IOException
- {
+ public MultipartRequest(PrintWriter debug, String strContentTypeText,
+ int intContentLength, InputStream in, int intMaxReadBytes)
+ throws IllegalArgumentException, IOException {
this.loadIntoMemory = true;
- // Now initialise the object, which will actually call the parse method to parse multipart stream.
+ // Now initialise the object, which will actually call the parse method
+ // to parse multipart stream.
init(debug, strContentTypeText, intContentLength, in, intMaxReadBytes);
}
- /**
+ /**
* Constructor.
- *
- * @param debug A PrintWriter that can be used for debugging.
- * @param strContentTypeText the &quot;Content-Type&quot; HTTP header value.
- * @param intContentLength the &quot;Content-Length&quot; HTTP header value.
- * @param in the InputStream to read and parse.
- * @param strSaveDirectory the temporary directory to save the file from where they can then be moved to wherever by the
- * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
- * will be silently ignored.</B>
- * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
- *
- * @exception IllegalArgumentException If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
- * @exception IOException If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
- *
+ *
+ * @param debug
+ * A PrintWriter that can be used for debugging.
+ * @param strContentTypeText
+ * the &quot;Content-Type&quot; HTTP header value.
+ * @param intContentLength
+ * the &quot;Content-Length&quot; HTTP header value.
+ * @param in
+ * the InputStream to read and parse.
+ * @param strSaveDirectory
+ * the temporary directory to save the file from where they can
+ * then be moved to wherever by the calling process. <b>If you
+ * specify <u>null</u> for this parameter, then any files
+ * uploaded will be silently ignored.</B>
+ * @param intMaxReadBytes
+ * Overrides the MAX_BYTES_READ value, to allow arbitrarily long
+ * files.
+ *
+ * @exception IllegalArgumentException
+ * If the strContentTypeText does not contain a Content-Type
+ * of "multipart/form-data" or the boundary is not found.
+ * @exception IOException
+ * If the intContentLength is higher than MAX_READ_BYTES or
+ * strSaveDirectory is invalid or cannot be written to.
+ *
* @see #MAX_READ_BYTES
*/
- public MultipartRequest(PrintWriter debug,
- String strContentTypeText,
- int intContentLength,
- InputStream in,
- String strSaveDirectory,
- int intMaxReadBytes) throws IllegalArgumentException, IOException
- {
- // IF strSaveDirectory == NULL, then we should ignore any files uploaded.
- if (strSaveDirectory!=null)
- {
+ public MultipartRequest(PrintWriter debug, String strContentTypeText,
+ int intContentLength, InputStream in, String strSaveDirectory,
+ int intMaxReadBytes) throws IllegalArgumentException, IOException {
+ // IF strSaveDirectory == NULL, then we should ignore any files
+ // uploaded.
+ if (strSaveDirectory != null) {
fileOutPutDirectory = new File(strSaveDirectory);
if (!fileOutPutDirectory.exists())
- throw new IOException("Directory ["+strSaveDirectory+"] is invalid.");
+ throw new IOException("Directory [" + strSaveDirectory
+ + "] is invalid.");
else if (!fileOutPutDirectory.canWrite())
- throw new IOException("Directory ["+strSaveDirectory+"] is readonly.");
+ throw new IOException("Directory [" + strSaveDirectory
+ + "] is readonly.");
}
- // Now initialise the object, which will actually call the parse method to parse multipart stream.
+ // Now initialise the object, which will actually call the parse method
+ // to parse multipart stream.
init(debug, strContentTypeText, intContentLength, in, intMaxReadBytes);
}
- /**
+ /**
* Initialise the parser.
- *
- * @param debug A PrintWriter that can be used for debugging.
- * @param strContentTypeText the &quot;Content-Type&quot; HTTP header value.
- * @param intContentLength the &quot;Content-Length&quot; HTTP header value.
- * @param in the InputStream to read and parse.
- * @param strSaveDirectory the temporary directory to save the file from where they can then be moved to wherever by the
- * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
- * will be silently ignored.</B>
- * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
- *
- * @exception IllegalArgumentException If the strContentTypeText does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
- * @exception IOException If the intContentLength is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
- *
+ *
+ * @param debug
+ * A PrintWriter that can be used for debugging.
+ * @param strContentTypeText
+ * the &quot;Content-Type&quot; HTTP header value.
+ * @param intContentLength
+ * the &quot;Content-Length&quot; HTTP header value.
+ * @param in
+ * the InputStream to read and parse.
+ * @param strSaveDirectory
+ * the temporary directory to save the file from where they can
+ * then be moved to wherever by the calling process. <b>If you
+ * specify <u>null</u> for this parameter, then any files
+ * uploaded will be silently ignored.</B>
+ * @param intMaxReadBytes
+ * Overrides the MAX_BYTES_READ value, to allow arbitrarily long
+ * files.
+ *
+ * @exception IllegalArgumentException
+ * If the strContentTypeText does not contain a Content-Type
+ * of "multipart/form-data" or the boundary is not found.
+ * @exception IOException
+ * If the intContentLength is higher than MAX_READ_BYTES or
+ * strSaveDirectory is invalid or cannot be written to.
+ *
* @see #MAX_READ_BYTES
*/
- private void init(PrintWriter debug,
- String strContentTypeText,
- int intContentLength,
- InputStream in,
- int intMaxReadBytes) throws IllegalArgumentException, IOException
- {
+ private void init(PrintWriter debug, String strContentTypeText,
+ int intContentLength, InputStream in, int intMaxReadBytes)
+ throws IllegalArgumentException, IOException {
// saves reference to debug stream for later.
this.debug = debug;
- if (strContentTypeText!=null && strContentTypeText.startsWith("multipart/form-data") && strContentTypeText.indexOf("boundary=")!=-1)
- strBoundary = strContentTypeText.substring(strContentTypeText.indexOf("boundary=")+"boundary=".length()).trim();
- else
- {
+ if (strContentTypeText != null
+ && strContentTypeText.startsWith("multipart/form-data")
+ && strContentTypeText.indexOf("boundary=") != -1)
+ strBoundary = strContentTypeText.substring(
+ strContentTypeText.indexOf("boundary=")
+ + "boundary=".length()).trim();
+ else {
// <mtl,jpell>
debug("ContentType = " + strContentTypeText);
throw new IllegalArgumentException("Invalid Content Type.");
@@ -387,10 +464,11 @@ public class MultipartRequest
this.intContentLength = intContentLength;
// FIX: 115
if (intContentLength > intMaxReadBytes)
- throw new IOException("Content Length Error (" + intContentLength + " > " + intMaxReadBytes + ")");
+ throw new IOException("Content Length Error (" + intContentLength
+ + " > " + intMaxReadBytes + ")");
// Instantiate the hashtable...
- htParameters = new Hashtable();
+ htParameters = new Hashtable();
htFiles = new Hashtable();
blockOfBytes = new byte[READ_LINE_BLOCK];
@@ -398,46 +476,47 @@ public class MultipartRequest
parse(new BufferedInputStream(in));
// No need for this once parse is complete.
- this.blockOfBytes=null;
+ this.blockOfBytes = null;
this.debug = null;
- this.strBoundary=null;
+ this.strBoundary = null;
}
/**
- * Gets the value of the strName URLParameter.
- * If more than one value for a particular Parameter, will return the first.
- * If an error occurs will return null.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
- * @return the value of the URL Parameter.
- */
- public String getURLParameter(String strName)
- {
+ * Gets the value of the strName URLParameter. If more than one value for a
+ * particular Parameter, will return the first. If an error occurs will
+ * return null.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
+ * @return the value of the URL Parameter.
+ */
+ public String getURLParameter(String strName) {
Object value = htParameters.get(strName);
if (value instanceof Vector)
- return (String) ((Vector)value).firstElement();
+ return (String) ((Vector) value).firstElement();
else
- return (String) htParameters.get(strName);
+ return (String) htParameters.get(strName);
}
/**
- * Gets an enumeration of all values for the strName parameter.
- * Even if a single value for, will always return an enumeration, although
- * it may actually be empty if no value was encountered for strName or
- * it is an invalid parameter name.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
+ * Gets an enumeration of all values for the strName parameter. Even if a
+ * single value for, will always return an enumeration, although it may
+ * actually be empty if no value was encountered for strName or it is an
+ * invalid parameter name.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
* @return the enumeration of all values.
*/
- public Enumeration getURLParameters(String strName)
- {
+ public Enumeration getURLParameters(String strName) {
Object value = htParameters.get(strName);
if (value instanceof Vector)
- return ((Vector)value).elements();
- else
- {
+ return ((Vector) value).elements();
+ else {
Vector vector = new Vector();
- if(value!=null)
+ if (value != null)
vector.addElement(value);
return vector.elements();
}
@@ -445,74 +524,74 @@ public class MultipartRequest
/**
* Gets the enumeration of all URL Parameters for the current HTTP Request.
+ *
* @return the enumeration of URl Parameters.
*/
- public Enumeration getParameterNames()
- {
+ public Enumeration getParameterNames() {
return htParameters.keys();
}
/**
- * Gets the enumeration of all INPUT TYPE=FILE parameter NAMES as encountered
- * during the upload.
- * @return
+ * Gets the enumeration of all INPUT TYPE=FILE parameter NAMES as
+ * encountered during the upload.
+ *
+ * @return
*/
- public Enumeration getFileParameterNames()
- {
+ public Enumeration getFileParameterNames() {
return htFiles.keys();
}
/**
* Returns the Content-Type of a file.
- *
+ *
* @see #getFileParameter(java.lang.String, int)
*/
- public String getContentType(String strName)
- {
+ public String getContentType(String strName) {
// Can cast null, it will be ignored.
- return (String)getFileParameter(strName, CONTENT_TYPE);
+ return (String) getFileParameter(strName, CONTENT_TYPE);
}
-
+
/**
- * If files were uploaded into memory, this method will retrieve the contents
- * of the file as a InputStream.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
- * @return the contents of the file as a InputStream, or null if not file uploaded,
- * or file uploaded to file system directory.
+ * If files were uploaded into memory, this method will retrieve the
+ * contents of the file as a InputStream.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
+ * @return the contents of the file as a InputStream, or null if not file
+ * uploaded, or file uploaded to file system directory.
* @see #getFileParameter(java.lang.String, int)
*/
- public InputStream getFileContents(String strName)
- {
+ public InputStream getFileContents(String strName) {
Object obj = getFileParameter(strName, CONTENTS);
- if (obj!=null)
- return new ByteArrayInputStream((byte[])obj);
+ if (obj != null)
+ return new ByteArrayInputStream((byte[]) obj);
else
return null;
}
/**
- * Returns a File reference to the uploaded file. This
- * reference is to the files uploaded location,
- * and allows you to read/move/delete the file.
- * This method is only of use, if files were uploaded to the
- * file system. Will return null if
- * uploaded to memory, in which case you should use
+ * Returns a File reference to the uploaded file. This reference is to the
+ * files uploaded location, and allows you to read/move/delete the file.
+ * This method is only of use, if files were uploaded to the file system.
+ * Will return null if uploaded to memory, in which case you should use
* getFileContents(strName) instead.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
- * @return a null file reference if a call to
- * getFileSize(strName) returns zero or files were
- * uploaded to memory.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
+ * @return a null file reference if a call to getFileSize(strName) returns
+ * zero or files were uploaded to memory.
* @see #getFileSize(java.lang.String)
* @see #getFileContents(java.lang.String)
* @see #getFileSystemName(java.lang.String)
*/
- public File getFile(String strName)
- {
+ public File getFile(String strName) {
String filename = getFileSystemName(strName);
- // Fix: If fileOutPutDirectory is null, then we are ignoring any file contents, so we must return null.
- if(filename!=null && getFileSize(strName)>0 && fileOutPutDirectory!=null)
+ // Fix: If fileOutPutDirectory is null, then we are ignoring any file
+ // contents, so we must return null.
+ if (filename != null && getFileSize(strName) > 0
+ && fileOutPutDirectory != null)
return new File(fileOutPutDirectory, filename);
else
return null;
@@ -520,71 +599,78 @@ public class MultipartRequest
/**
* Gets the file system basename of an uploaded file.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
* @return null if strName not found.
- *
+ *
* @see #getFileParameter(java.lang.String, int)
*/
- public String getFileSystemName(String strName)
- {
+ public String getFileSystemName(String strName) {
// Can cast null, it will be ignored.
- return (String)getFileParameter(strName, FILENAME);
+ return (String) getFileParameter(strName, FILENAME);
}
/**
* Returns the File Size of a uploaded file.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
* @return -1 if file size not defined.
- *
+ *
* @see #getFileParameter(java.lang.String, int)
*/
- public long getFileSize(String strName)
- {
+ public long getFileSize(String strName) {
Object obj = getFileParameter(strName, SIZE);
- if (obj!=null)
- return ((Long)obj).longValue();
+ if (obj != null)
+ return ((Long) obj).longValue();
else
- return (long)-1;
+ return (long) -1;
}
/**
* Access an attribute of a file upload parameter record.
- * <p>The getFileSystemName(String strName),getFileSize(String strName),getContentType(String strName),
- * getContents(String strName) methods all use this method passing in a different type argument.</p>
- *
- * <p><b>Note: </b>This class has been changed to provide for future functionality where you
- * will be able to access all files uploaded, even if they are uploaded using the same
- * form field name. At this point however, only the first file uploaded via a form
- * field name is accessible.</p>
+ * <p>
+ * The getFileSystemName(String strName),getFileSize(String
+ * strName),getContentType(String strName), getContents(String strName)
+ * methods all use this method passing in a different type argument.
+ * </p>
+ *
+ * <p>
+ * <b>Note: </b>This class has been changed to provide for future
+ * functionality where you will be able to access all files uploaded, even
+ * if they are uploaded using the same form field name. At this point
+ * however, only the first file uploaded via a form field name is
+ * accessible.
+ * </p>
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
*
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
- *
- * @param type What attribute you want from the File Parameter.
- * The following types are supported:
- * MultipartRequest.FILENAME,
- * MultipartRequest.CONTENT_TYPE,
- * MultipartRequest.SIZE,
- * MultipartRequest.CONTENTS
- *
- * @see #getContentType(java.lang.String)
+ * @param type
+ * What attribute you want from the File Parameter. The following
+ * types are supported: MultipartRequest.FILENAME,
+ * MultipartRequest.CONTENT_TYPE, MultipartRequest.SIZE,
+ * MultipartRequest.CONTENTS
+ *
+ * @see #getContentType(java.lang.String)
* @see #getFileSize(java.lang.String)
* @see #getFileContents(java.lang.String)
* @see #getFileSystemName(java.lang.String)
*/
- public Object getFileParameter(String strName, int type)
- {
+ public Object getFileParameter(String strName, int type) {
Object[] objArray = null;
Object value = htFiles.get(strName);
if (value instanceof Vector)
- objArray = (Object[]) ((Vector)value).firstElement();
+ objArray = (Object[]) ((Vector) value).firstElement();
else
- objArray = (Object[]) htFiles.get(strName);
+ objArray = (Object[]) htFiles.get(strName);
// Now ensure valid value.
- if (objArray!=null && type>=FILENAME && type<=CONTENTS)
+ if (objArray != null && type >= FILENAME && type <= CONTENTS)
return objArray[type];
else
return null;
@@ -592,69 +678,77 @@ public class MultipartRequest
/**
* This is the main parse method.
- * @param in the InputStream to read and parse.
- * @throws IOException If the intContentLength is higher than MAX_READ_BYTES or
- * strSaveDirectory is invalid or cannot be written to.
+ *
+ * @param in
+ * the InputStream to read and parse.
+ * @throws IOException
+ * If the intContentLength is higher than MAX_READ_BYTES or
+ * strSaveDirectory is invalid or cannot be written to.
*/
- private void parse(InputStream in) throws IOException
- {
+ private void parse(InputStream in) throws IOException {
String strContentType = null;
String strName = null;
String strFilename = null;
String strLine = null;
int read = -1;
- // First run through, check that the first line is a boundary, otherwise throw a exception as format incorrect.
+ // First run through, check that the first line is a boundary, otherwise
+ // throw a exception as format incorrect.
read = readLine(in, blockOfBytes);
- strLine = read>0? new String(blockOfBytes, 0, read, charEncoding): null;
+ strLine = read > 0 ? new String(blockOfBytes, 0, read, charEncoding)
+ : null;
// Must be boundary at top of loop, otherwise we have finished.
- if (strLine==null || strLine.indexOf(this.strBoundary)==-1)
- // Just exit. Exception would be overkill
- return;
- //throw new IOException("Invalid Form Data, no boundary encountered.");
+ if (strLine == null || strLine.indexOf(this.strBoundary) == -1)
+ // Just exit. Exception would be overkill
+ return;
+ // throw new IOException("Invalid Form Data, no boundary encountered.");
- // At the top of loop, we assume that the Content-Disposition line is next, otherwise we are at the end.
- while (true)
- {
+ // At the top of loop, we assume that the Content-Disposition line is
+ // next, otherwise we are at the end.
+ while (true) {
// Get Content-Disposition line.
read = readLine(in, blockOfBytes);
- if (read<=0)
+ if (read <= 0)
break; // Nothing to do.
- else
- {
+ else {
strLine = new String(blockOfBytes, 0, read, charEncoding);
-
+
// Mac IE4 adds extra line after last boundary - 1.21
- if(strLine==null || strLine.length() == 0 || strLine.trim().length() == 0)
- break;
-
+ if (strLine == null || strLine.length() == 0
+ || strLine.trim().length() == 0)
+ break;
+
strName = trimQuotes(getValue("name", strLine));
- // If this is not null, it indicates that we are processing a filename.
+ // If this is not null, it indicates that we are processing a
+ // filename.
strFilename = trimQuotes(getValue("filename", strLine));
// Now if not null, strip it of any directory information.
- if (strFilename!=null)
- {
- // Fix: did not check whether filename was empty string indicating FILE contents were not passed.
- if (strFilename.length()>0)
- {
+ if (strFilename != null) {
+ // Fix: did not check whether filename was empty string
+ // indicating FILE contents were not passed.
+ if (strFilename.length() > 0) {
// Need to get the content type.
read = readLine(in, blockOfBytes);
- strLine = read>0? new String(blockOfBytes, 0, read, charEncoding): null;
-
+ strLine = read > 0 ? new String(blockOfBytes, 0, read,
+ charEncoding) : null;
+
strContentType = "application/octet-stream";
- // Fix 1.11: If not null AND strLine.length() is long enough.
- if (strLine!=null&&strLine.length()>"Content-Type: ".length())
- strContentType = strLine.substring("Content-Type: ".length());// Changed 1.13
- }
- else
- {
+ // Fix 1.11: If not null AND strLine.length() is long
+ // enough.
+ if (strLine != null
+ && strLine.length() > "Content-Type: ".length())
+ strContentType = strLine.substring("Content-Type: "
+ .length());// Changed 1.13
+ } else {
// FIX 1.14: IE problem with empty filename.
read = readLine(in, blockOfBytes);
- strLine = read>0? new String(blockOfBytes, 0, read, charEncoding): null;
-
- if (strLine!=null && strLine.startsWith("Content-Type:"))
+ strLine = read > 0 ? new String(blockOfBytes, 0, read,
+ charEncoding) : null;
+
+ if (strLine != null
+ && strLine.startsWith("Content-Type:"))
readLine(in, blockOfBytes);
}
}
@@ -663,146 +757,161 @@ public class MultipartRequest
readLine(in, blockOfBytes);
// No filename specified at all.
- if (strFilename==null)
- {
+ if (strFilename == null) {
String param = readParameter(in);
addParameter(strName, param);
- }
- else
- {
- if (strFilename.length()>0)
- {
+ } else {
+ if (strFilename.length() > 0) {
long filesize = -1;
// Will remain null for read onto file system uploads.
byte[] contentsOfFile = null;
-
+
// Get the BASENAME version of strFilename.
strFilename = getBasename(strFilename);
- // Are we loading files into memory instead of the filesystem?
- if (loadIntoMemory)
- {
+ // Are we loading files into memory instead of the
+ // filesystem?
+ if (loadIntoMemory) {
contentsOfFile = readFile(in);
- if (contentsOfFile!=null)
- filesize = contentsOfFile.length;
- }
- else// Read the file onto file system.
- filesize = readAndWriteFile(in, strFilename);
+ if (contentsOfFile != null)
+ filesize = contentsOfFile.length;
+ } else
+ // Read the file onto file system.
+ filesize = readAndWriteFile(in, strFilename);
// Fix 1.18 for multiple FILE parameter values.
- if (filesize>0)
- addFileParameter(strName, new Object[] {strFilename, strContentType, new Long(filesize), contentsOfFile});
- else // Zero length file.
- addFileParameter(strName, new Object[] {strFilename, null, new Long(0), null});
- }
- else // Fix: FILE INPUT TYPE, but no file passed as input...
+ if (filesize > 0)
+ addFileParameter(strName, new Object[] {
+ strFilename, strContentType,
+ new Long(filesize), contentsOfFile });
+ else
+ // Zero length file.
+ addFileParameter(strName, new Object[] {
+ strFilename, null, new Long(0), null });
+ } else // Fix: FILE INPUT TYPE, but no file passed as
+ // input...
{
- addFileParameter(strName, new Object[] {null, null, null, null});
- readLine(in, blockOfBytes);
+ addFileParameter(strName, new Object[] { null, null,
+ null, null });
+ readLine(in, blockOfBytes);
}
}
}
- }// while
+ }// while
}
-
+
/**
* So we can put the logic for supporting multiple parameters with the same
* form field name in the one location.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
- * @param value the form field value.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
+ * @param value
+ * the form field value.
*/
- private void addParameter(String strName, String value)
- {
+ private void addParameter(String strName, String value) {
// Fix NPE in case of null name
if (strName == null)
return;
-
+
// Fix 1.16: for multiple parameter values.
Object objParms = htParameters.get(strName);
// Adds an new entry to the param vector.
if (objParms instanceof Vector)
- ((Vector)objParms).addElement(value);
- else if (objParms instanceof String)// There is only one entry, so we create a vector!
+ ((Vector) objParms).addElement(value);
+ else if (objParms instanceof String)// There is only one entry, so we
+ // create a vector!
{
Vector vecParms = new Vector();
vecParms.addElement(objParms);
vecParms.addElement(value);
htParameters.put(strName, vecParms);
- }
- else // first entry for strName.
+ } else
+ // first entry for strName.
htParameters.put(strName, value);
}
/**
- * So we can put the logic for supporting multiple files with the same
- * form field name in the one location.
- *
- * Assumes that this method will never be called with a null fileObj or strFilename.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
- * @param fileObj
+ * So we can put the logic for supporting multiple files with the same form
+ * field name in the one location.
+ *
+ * Assumes that this method will never be called with a null fileObj or
+ * strFilename.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
+ * @param fileObj
*/
- private void addFileParameter(String strName, Object[] fileObj)
- {
+ private void addFileParameter(String strName, Object[] fileObj) {
Object objParms = htFiles.get(strName);
// Add an new entry to the param vector.
if (objParms instanceof Vector)
- ((Vector)objParms).addElement(fileObj);
- else if (objParms instanceof Object[])// There is only one entry, so we create a vector!
+ ((Vector) objParms).addElement(fileObj);
+ else if (objParms instanceof Object[])// There is only one entry, so
+ // we create a vector!
{
Vector vecParms = new Vector();
vecParms.addElement(objParms);
vecParms.addElement(fileObj);
-
+
htFiles.put(strName, vecParms);
- }
- else // first entry for strName.
+ } else
+ // first entry for strName.
htFiles.put(strName, fileObj);
}
/**
- * Reads the parameters, assume already passed Content-Disposition and blank line.
- * @param in the InputStream to read and parse.
+ * Reads the parameters, assume already passed Content-Disposition and blank
+ * line.
+ *
+ * @param in
+ * the InputStream to read and parse.
* @return the value read in.
- * @throws IOException if an error occurs writing the file.
+ * @throws IOException
+ * if an error occurs writing the file.
*/
- private String readParameter(InputStream in) throws IOException
- {
+ private String readParameter(InputStream in) throws IOException {
StringBuffer buf = new StringBuffer();
- int read=-1;
+ int read = -1;
String line = null;
- while(true)
- {
+ while (true) {
read = readLine(in, blockOfBytes);
- if (read<0)
+ if (read < 0)
throw new IOException("Stream ended prematurely.");
- // Change v1.18: Only instantiate string once for performance reasons.
+ // Change v1.18: Only instantiate string once for performance
+ // reasons.
line = new String(blockOfBytes, 0, read, charEncoding);
- if (read<blockOfBytes.length && line.indexOf(this.strBoundary)!=-1)
+ if (read < blockOfBytes.length
+ && line.indexOf(this.strBoundary) != -1)
break; // Boundary found, we need to finish up.
- else
+ else
buf.append(line);
}
- if (buf.length()>0)
+ if (buf.length() > 0)
buf.setLength(getLengthMinusEnding(buf));
return buf.toString();
}
/**
* Read from in, write to out, minus last two line ending bytes.
- * @param in the InputStream to read and parse.
- * @param out the OutputStream.
- * @throws IOException if an error occurs writing the file.
+ *
+ * @param in
+ * the InputStream to read and parse.
+ * @param out
+ * the OutputStream.
+ * @throws IOException
+ * if an error occurs writing the file.
*/
- private long readAndWrite(InputStream in, OutputStream out) throws IOException
- {
+ private long readAndWrite(InputStream in, OutputStream out)
+ throws IOException {
long fileSize = 0;
int read = -1;
@@ -811,369 +920,411 @@ public class MultipartRequest
// So we do not have to keep creating the second array.
int sizeOfSecondArray = 0;
- while(true)
- {
+ while (true) {
read = readLine(in, blockOfBytes);
- if (read<0)
+ if (read < 0)
throw new IOException("Stream ended prematurely.");
// Found boundary.
- if (read<blockOfBytes.length && new String(blockOfBytes, 0, read, charEncoding).indexOf(this.strBoundary)!=-1)
- {
+ if (read < blockOfBytes.length
+ && new String(blockOfBytes, 0, read, charEncoding)
+ .indexOf(this.strBoundary) != -1) {
// Writes the line, minus any line ending bytes.
- //The secondLineOfBytes will NEVER BE NON-NULL if out==null, so there is no need to included this in the test
- if(sizeOfSecondArray!=0)
- {
+ // The secondLineOfBytes will NEVER BE NON-NULL if out==null, so
+ // there is no need to included this in the test
+ if (sizeOfSecondArray != 0) {
// Only used once, so declare here.
- int actualLength = getLengthMinusEnding(secondLineOfBytes, sizeOfSecondArray);
- if (actualLength>0 && out!=null)
- {
+ int actualLength = getLengthMinusEnding(secondLineOfBytes,
+ sizeOfSecondArray);
+ if (actualLength > 0 && out != null) {
out.write(secondLineOfBytes, 0, actualLength);
// Updates the file size.
- fileSize+=actualLength;
+ fileSize += actualLength;
}
}
break;
- }
- else
- {
+ } else {
// Writes the out previous line.
- //The sizeOfSecondArray will NEVER BE ZERO if out==null, so there is no need to included this in the test
- if(sizeOfSecondArray!=0)
- {
+ // The sizeOfSecondArray will NEVER BE ZERO if out==null, so
+ // there is no need to included this in the test
+ if (sizeOfSecondArray != 0) {
out.write(secondLineOfBytes, 0, sizeOfSecondArray);
// Updates the file size.
- fileSize+=sizeOfSecondArray;
+ fileSize += sizeOfSecondArray;
}
- // out will always be null, so there is no need to reset sizeOfSecondArray to zero each time.
- if(out!=null)
- {
- //Copy the read bytes into the array.
- System.arraycopy(blockOfBytes,0,secondLineOfBytes,0,read);
+ // out will always be null, so there is no need to reset
+ // sizeOfSecondArray to zero each time.
+ if (out != null) {
+ // Copy the read bytes into the array.
+ System.arraycopy(blockOfBytes, 0, secondLineOfBytes, 0,
+ read);
// That is how many bytes to read from the secondLineOfBytes
- sizeOfSecondArray=read;
+ sizeOfSecondArray = read;
}
}
}
- //Returns the number of bytes written to outstream.
+ // Returns the number of bytes written to outstream.
return fileSize;
}
/**
- * Reads a Multipart section that is a file type. Assumes that the Content-Disposition/Content-Type and blank line
- * have already been processed. So we read until we hit a boundary, then close file and return.
- * @param in the InputStream to read and parse.
- * @param strFilename the FileSystemName of the file.
- * @return the number of bytes read.
- * @throws IOException if an error occurs writing the file.
- */
- private long readAndWriteFile(InputStream in, String strFilename) throws IOException
- {
+ * Reads a Multipart section that is a file type. Assumes that the
+ * Content-Disposition/Content-Type and blank line have already been
+ * processed. So we read until we hit a boundary, then close file and
+ * return.
+ *
+ * @param in
+ * the InputStream to read and parse.
+ * @param strFilename
+ * the FileSystemName of the file.
+ * @return the number of bytes read.
+ * @throws IOException
+ * if an error occurs writing the file.
+ */
+ private long readAndWriteFile(InputStream in, String strFilename)
+ throws IOException {
// Stores a reference to this, as we may need to delete it later.
File outFile = new File(fileOutPutDirectory, strFilename);
BufferedOutputStream out = null;
- // Do not bother opening a OutputStream, if we cannot even write the file.
- if(fileOutPutDirectory!=null)
+ // Do not bother opening a OutputStream, if we cannot even write the
+ // file.
+ if (fileOutPutDirectory != null)
out = new BufferedOutputStream(new FileOutputStream(outFile));
-
+
long count = readAndWrite(in, out);
// Count would NOT be larger than zero if out was null.
- if (count>0)
- {
+ if (count > 0) {
out.flush();
out.close();
- }
- else
- {
+ } else {
out.close();
- // Deletes the file as empty. We should be able to delete it, if we can open it!
+ // Deletes the file as empty. We should be able to delete it, if we
+ // can open it!
outFile.delete();
}
return count;
}
/**
- * If the fileOutPutDirectory wasn't specified, just read the file to memory.
- *
- * @param in the InputStream to read and parse.
+ * If the fileOutPutDirectory wasn't specified, just read the file to
+ * memory.
+ *
+ * @param in
+ * the InputStream to read and parse.
* @return contents of file, from which you can garner the size as well.
- * @throws IOException if the writing failed due to input/output error.
+ * @throws IOException
+ * if the writing failed due to input/output error.
*/
- private byte[] readFile(InputStream in) throws IOException
- {
+ private byte[] readFile(InputStream in) throws IOException {
// In this case, we do not need to worry about a outputdirectory.
ByteArrayOutputStream out = new ByteArrayOutputStream();
long count = readAndWrite(in, out);
// Count would NOT be larger than zero if out was null.
- if (count>0)
- {
- // Return contents of file to parse method for inclusion in htFiles object.
+ if (count > 0) {
+ // Return contents of file to parse method for inclusion in htFiles
+ // object.
return out.toByteArray();
- }
- else
+ } else
return null;
}
/**
* Gets the length of the line minus line ending.
+ *
* @param byteLine
- * @param endOfArray This is because in many cases the byteLine will have garbage data at the end, so we
- * act as though the actual end of the array is this parameter. If you want to process
- * the complete byteLine, specify byteLine.length as the endOfArray parameter.
- *@return the length.
+ * @param endOfArray
+ * This is because in many cases the byteLine will have garbage
+ * data at the end, so we act as though the actual end of the
+ * array is this parameter. If you want to process the complete
+ * byteLine, specify byteLine.length as the endOfArray parameter.
+ * @return the length.
*/
- private static final int getLengthMinusEnding(byte byteLine[], int endOfArray)
- {
- if (byteLine==null)
+ private static final int getLengthMinusEnding(byte byteLine[],
+ int endOfArray) {
+ if (byteLine == null)
return 0;
-
- if (endOfArray>=2 && byteLine[endOfArray-2] == '\r' && byteLine[endOfArray-1] == '\n')
- return endOfArray-2;
- else if (endOfArray>=1 && byteLine[endOfArray-1] == '\n' || byteLine[endOfArray-1] == '\r')
- return endOfArray-1;
+
+ if (endOfArray >= 2 && byteLine[endOfArray - 2] == '\r'
+ && byteLine[endOfArray - 1] == '\n')
+ return endOfArray - 2;
+ else if (endOfArray >= 1 && byteLine[endOfArray - 1] == '\n'
+ || byteLine[endOfArray - 1] == '\r')
+ return endOfArray - 1;
else
return endOfArray;
}
-
+
/**
*
* @param buf
* @return
*/
- private static final int getLengthMinusEnding(StringBuffer buf)
- {
- if (buf.length()>=2 && buf.charAt(buf.length()-2) == '\r' && buf.charAt(buf.length()-1) == '\n')
- return buf.length()-2;
- else if (buf.length()>=1 && buf.charAt(buf.length()-1) == '\n' || buf.charAt(buf.length()-1) == '\r')
- return buf.length()-1;
+ private static final int getLengthMinusEnding(StringBuffer buf) {
+ if (buf.length() >= 2 && buf.charAt(buf.length() - 2) == '\r'
+ && buf.charAt(buf.length() - 1) == '\n')
+ return buf.length() - 2;
+ else if (buf.length() >= 1 && buf.charAt(buf.length() - 1) == '\n'
+ || buf.charAt(buf.length() - 1) == '\r')
+ return buf.length() - 1;
else
return buf.length();
}
/**
- * Reads at most READ_BLOCK blocks of data, or a single line whichever is smaller.
- * Returns -1, if nothing to read, or we have reached the specified content-length.
- *
+ * Reads at most READ_BLOCK blocks of data, or a single line whichever is
+ * smaller. Returns -1, if nothing to read, or we have reached the specified
+ * content-length.
+ *
* Assumes that bytToBeRead.length indicates the block size to read.
- * @param in the InputStream to read and parse.
- * @param bytesToBeRead the bytes to be read.
- * @return -1 if stream has ended, before a newline encountered (should never happen) OR
- * we have read past the Content-Length specified. (Should also not happen). Otherwise
- * return the number of characters read. You can test whether the number returned is less
- * than bytesToBeRead.length, which indicates that we have read the last line of a file or parameter or
- * a border line, or some other formatting stuff.
- * @throws IOException if the writing failed due to input/output error.
+ *
+ * @param in
+ * the InputStream to read and parse.
+ * @param bytesToBeRead
+ * the bytes to be read.
+ * @return -1 if stream has ended, before a newline encountered (should
+ * never happen) OR we have read past the Content-Length specified.
+ * (Should also not happen). Otherwise return the number of
+ * characters read. You can test whether the number returned is less
+ * than bytesToBeRead.length, which indicates that we have read the
+ * last line of a file or parameter or a border line, or some other
+ * formatting stuff.
+ * @throws IOException
+ * if the writing failed due to input/output error.
*/
- private int readLine(InputStream in, byte[] bytesToBeRead) throws IOException
- {
+ private int readLine(InputStream in, byte[] bytesToBeRead)
+ throws IOException {
// Ensure that there is still stuff to read...
- if (intTotalRead >= intContentLength)
+ if (intTotalRead >= intContentLength)
return -1;
// Get the length of what we are wanting to read.
int length = bytesToBeRead.length;
- // End of content, but some servers (apparently) may not realise this and end the InputStream, so
+ // End of content, but some servers (apparently) may not realise this
+ // and end the InputStream, so
// we cover ourselves this way.
if (length > (intContentLength - intTotalRead))
- length = (int) (intContentLength - intTotalRead); // So we only read the data that is left.
+ length = (int) (intContentLength - intTotalRead); // So we only
+ // read the data
+ // that is left.
int result = readLine(in, bytesToBeRead, 0, length);
- // Only if we get actually read something, otherwise something weird has happened, such as the end of stream.
- if (result > 0)
+ // Only if we get actually read something, otherwise something weird has
+ // happened, such as the end of stream.
+ if (result > 0)
intTotalRead += result;
- return result;
+ return result;
}
/**
* This needs to support the possibility of a / or a \ separator.
- * @param strFilename the FileSystemName of the file.
+ *
+ * @param strFilename
+ * the FileSystemName of the file.
* @return the strFilename after removing all characters before the last
- * occurence of / or \.
+ * occurence of / or \.
*/
- private static final String getBasename (String strFilename)
- {
- if (strFilename==null)
+ private static final String getBasename(String strFilename) {
+ if (strFilename == null)
return strFilename;
int intIndex = strFilename.lastIndexOf("/");
- if (intIndex==-1 || strFilename.lastIndexOf("\\")>intIndex)
+ if (intIndex == -1 || strFilename.lastIndexOf("\\") > intIndex)
intIndex = strFilename.lastIndexOf("\\");
- if (intIndex!=-1)
- return strFilename.substring(intIndex+1);
+ if (intIndex != -1)
+ return strFilename.substring(intIndex + 1);
else
return strFilename;
}
/**
* Trims any quotes from the start and end of a string.
+ *
* @param strItem
* @return the trimmed string.
*/
- private static final String trimQuotes (String strItem)
- {
+ private static final String trimQuotes(String strItem) {
// Saves having to go any further....
- if (strItem==null || strItem.indexOf("\"")==-1)
+ if (strItem == null || strItem.indexOf("\"") == -1)
return strItem;
-
+
// Gets the rid of any whitespace..
- strItem = strItem.trim();
+ strItem = strItem.trim();
if (strItem.charAt(0) == '\"')
strItem = strItem.substring(1);
-
- if (strItem.charAt(strItem.length()-1) == '\"')
- strItem = strItem.substring(0, strItem.length()-1);
+
+ if (strItem.charAt(strItem.length() - 1) == '\"')
+ strItem = strItem.substring(0, strItem.length() - 1);
return strItem;
}
/**
- * Format of string name=value; name=value;
- * If not found, will return null.
- * @param strName the form field name, used to upload the file. This identifies
- * the formfield location in the storage facility.
- * @param strToDecode
+ * Format of string name=value; name=value; If not found, will return null.
+ *
+ * @param strName
+ * the form field name, used to upload the file. This identifies
+ * the formfield location in the storage facility.
+ * @param strToDecode
*
*/
- private static final String getValue(String strName, String strToDecode)
- {
+ private static final String getValue(String strName, String strToDecode) {
strName = strName + "=";
- int startIndexOf=0;
- while (startIndexOf<strToDecode.length())
- {
+ int startIndexOf = 0;
+ while (startIndexOf < strToDecode.length()) {
int indexOf = strToDecode.indexOf(strName, startIndexOf);
// Ensure either first name, or a space or ; precedes it.
- if (indexOf!=-1)
- {
- if (indexOf==0 || Character.isWhitespace(strToDecode.charAt(indexOf-1)) || strToDecode.charAt(indexOf-1)==';')
- {
- int endIndexOf = strToDecode.indexOf(";", indexOf+strName.length());
- if (endIndexOf==-1) // May return an empty string...
- return strToDecode.substring(indexOf+strName.length());
+ if (indexOf != -1) {
+ if (indexOf == 0
+ || Character.isWhitespace(strToDecode
+ .charAt(indexOf - 1))
+ || strToDecode.charAt(indexOf - 1) == ';') {
+ int endIndexOf = strToDecode.indexOf(";", indexOf
+ + strName.length());
+ if (endIndexOf == -1) // May return an empty string...
+ return strToDecode
+ .substring(indexOf + strName.length());
else
- return strToDecode.substring(indexOf+strName.length(), endIndexOf);
- }
- else
- startIndexOf=indexOf+strName.length();
- }
- else
+ return strToDecode.substring(
+ indexOf + strName.length(), endIndexOf);
+ } else
+ startIndexOf = indexOf + strName.length();
+ } else
return null;
}
return null;
}
/**
- * <I>Tomcat's ServletInputStream.readLine(byte[],int,int) Slightly Modified to utilise in.read()</I>
- * <BR>
- * Reads the input stream, one line at a time. Starting at an
- * offset, reads bytes into an array, until it reads a certain number
- * of bytes or reaches a newline character, which it reads into the
- * array as well.
- *
- * <p>This method <u><b>does not</b></u> returns -1 if it reaches the end of the input
- * stream before reading the maximum number of bytes, it returns -1, if no bytes read.
- * @param in the InputStream to read and parse.
- * @param b an array of bytes into which data is read.
- *
- * @param off an integer specifying the character at which
- * this method begins reading.
- *
- * @param len an integer specifying the maximum number of
- * bytes to read.
- *
- * @return an integer specifying the actual number of bytes
- * read, or -1 if the end of the stream is reached.
- *
- * @throws IOException if an input or output exception has occurred
- *
- *
- * Note: We have a problem with Tomcat reporting an erroneous number of bytes, so we need to check this.
- * This is the method where we get an infinite loop, but only with binary files.
- */
- private int readLine(InputStream in, byte[] b, int off, int len) throws IOException
- {
- if (len <= 0)
- return 0;
+ * <I>Tomcat's ServletInputStream.readLine(byte[],int,int) Slightly Modified
+ * to utilise in.read()</I> <BR>
+ * Reads the input stream, one line at a time. Starting at an offset, reads
+ * bytes into an array, until it reads a certain number of bytes or reaches
+ * a newline character, which it reads into the array as well.
+ *
+ * <p>
+ * This method <u><b>does not</b></u> returns -1 if it reaches the end of
+ * the input stream before reading the maximum number of bytes, it returns
+ * -1, if no bytes read.
+ *
+ * @param in
+ * the InputStream to read and parse.
+ * @param b
+ * an array of bytes into which data is read.
+ *
+ * @param off
+ * an integer specifying the character at which this method
+ * begins reading.
+ *
+ * @param len
+ * an integer specifying the maximum number of bytes to read.
+ *
+ * @return an integer specifying the actual number of bytes read, or -1 if
+ * the end of the stream is reached.
+ *
+ * @throws IOException
+ * if an input or output exception has occurred
+ *
+ *
+ * Note: We have a problem with Tomcat reporting an erroneous number of
+ * bytes, so we need to check this. This is the method where we get an
+ * infinite loop, but only with binary files.
+ */
+ private int readLine(InputStream in, byte[] b, int off, int len)
+ throws IOException {
+ if (len <= 0)
+ return 0;
int count = 0, c;
- while ((c = in.read()) != -1)
- {
- b[off++] = (byte)c;
- count++;
- if (c == '\n' || count == len)
+ while ((c = in.read()) != -1) {
+ b[off++] = (byte) c;
+ count++;
+ if (c == '\n' || count == len)
break;
}
return count > 0 ? count : -1;
- }
+ }
/**
* Prints the given debugging message.
- * @param x the message to print.
+ *
+ * @param x
+ * the message to print.
*/
- protected void debug(String x)
- {
- if (debug!=null)
- {
+ protected void debug(String x) {
+ if (debug != null) {
debug.println(x);
debug.flush();
}
}
- /**
+ /**
* Gets the Html Table.For debugging.
*/
- public String getHtmlTable()
- {
+ public String getHtmlTable() {
StringBuffer sbReturn = new StringBuffer();
sbReturn.append("<h2>Parameters</h2>");
- sbReturn.append("\n<table border=3><tr><td><b>Name</b></td><td><b>Value</b></td></tr>");
- for (Enumeration e = getParameterNames() ; e.hasMoreElements() ;)
- {
+ sbReturn
+ .append("\n<table border=3><tr><td><b>Name</b></td><td><b>Value</b></td></tr>");
+ for (Enumeration e = getParameterNames(); e.hasMoreElements();) {
String strName = (String) e.nextElement();
- sbReturn.append("\n<tr>" +
- "<td>" + strName + "</td>");
+ sbReturn.append("\n<tr>" + "<td>" + strName + "</td>");
sbReturn.append("<td><table border=1><tr>");
- for (Enumeration f = getURLParameters(strName); f.hasMoreElements() ;)
- {
- String value = (String)f.nextElement();
- sbReturn.append("<td>"+value+"</td>");
+ for (Enumeration f = getURLParameters(strName); f.hasMoreElements();) {
+ String value = (String) f.nextElement();
+ sbReturn.append("<td>" + value + "</td>");
}
sbReturn.append("</tr></table></td></tr>");
- }
+ }
sbReturn.append("</table>");
sbReturn.append("<h2>File Parameters</h2>");
- sbReturn.append("\n<table border=2><tr><td><b>Name</b></td><td><b>Filename</b></td><td><b>Path</b></td><td><b>Content Type</b></td><td><b>Size</b></td></tr>");
- for (Enumeration e = getFileParameterNames() ; e.hasMoreElements() ;)
- {
+ sbReturn
+ .append("\n<table border=2><tr><td><b>Name</b></td><td><b>Filename</b></td><td><b>Path</b></td><td><b>Content Type</b></td><td><b>Size</b></td></tr>");
+ for (Enumeration e = getFileParameterNames(); e.hasMoreElements();) {
String strName = (String) e.nextElement();
- sbReturn.append("\n<tr>" +
- "<td>" + strName + "</td>" +
- "<td>" + (getFileSystemName(strName)!=null?getFileSystemName(strName):"") + "</td>");
+ sbReturn
+ .append("\n<tr>"
+ + "<td>"
+ + strName
+ + "</td>"
+ + "<td>"
+ + (getFileSystemName(strName) != null ? getFileSystemName(strName)
+ : "") + "</td>");
if (loadIntoMemory)
- sbReturn.append("<td>" + (getFileSize(strName)>0?"<i>in memory</i>":"") + "</td>");
+ sbReturn.append("<td>"
+ + (getFileSize(strName) > 0 ? "<i>in memory</i>" : "")
+ + "</td>");
else
- sbReturn.append("<td>" + (getFile(strName)!=null?getFile(strName).getAbsolutePath():"") + "</td>");
-
- sbReturn.append("<td>" + (getContentType(strName)!=null?getContentType(strName):"") + "</td>" +
- "<td>" + (getFileSize(strName)!=-1?getFileSize(strName)+"":"") + "</td>" +
- "</tr>");
- }
+ sbReturn.append("<td>"
+ + (getFile(strName) != null ? getFile(strName)
+ .getAbsolutePath() : "") + "</td>");
+
+ sbReturn
+ .append("<td>"
+ + (getContentType(strName) != null ? getContentType(strName)
+ : "")
+ + "</td>"
+ + "<td>"
+ + (getFileSize(strName) != -1 ? getFileSize(strName)
+ + ""
+ : "") + "</td>" + "</tr>");
+ }
sbReturn.append("</table>");
return sbReturn.toString();
diff --git a/src/com/itmill/toolkit/terminal/web/ServletMultipartRequest.java b/src/com/itmill/toolkit/terminal/web/ServletMultipartRequest.java
index 193129d95a..1980b0e92c 100644
--- a/src/com/itmill/toolkit/terminal/web/ServletMultipartRequest.java
+++ b/src/com/itmill/toolkit/terminal/web/ServletMultipartRequest.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -32,90 +32,108 @@ import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
-/**
- * This class wraps the MultipartRequest class by Jason Pell
- * for the Servlet environment.
+/**
+ * This class wraps the MultipartRequest class by Jason Pell for the Servlet
+ * environment.
*
* @author IT Mill Ltd
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class ServletMultipartRequest extends MultipartRequest
-{
- /**
- * Constructor wrapper, unwraps the InputStream,
- * content type and content length from the servlet request object.
- *
- * @param request the HttpServletRequest will be used to initialise the MultipartRequest super class.
- * @param strSaveDirectory the temporary directory to save the file from where they can then be moved to wherever by the
- * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
- * will be silently ignored.</B>
- *
- * @throws IllegalArgumentException If the request.getContentType() does not contain a Content-Type
- * of "multipart/form-data" or the boundary is not found.
- * @throws IOException If the request.getContentLength() is higher than MAX_READ_BYTES or
- * strSaveDirectory is invalid or cannot be written to.
- *
+public class ServletMultipartRequest extends MultipartRequest {
+ /**
+ * Constructor wrapper, unwraps the InputStream, content type and content
+ * length from the servlet request object.
+ *
+ * @param request
+ * the HttpServletRequest will be used to initialise the
+ * MultipartRequest super class.
+ * @param strSaveDirectory
+ * the temporary directory to save the file from where they can
+ * then be moved to wherever by the calling process. <b>If you
+ * specify <u>null</u> for this parameter, then any files
+ * uploaded will be silently ignored.</B>
+ *
+ * @throws IllegalArgumentException
+ * If the request.getContentType() does not contain a
+ * Content-Type of "multipart/form-data" or the boundary is not
+ * found.
+ * @throws IOException
+ * If the request.getContentLength() is higher than
+ * MAX_READ_BYTES or strSaveDirectory is invalid or cannot be
+ * written to.
+ *
* @see MultipartRequest#MAX_READ_BYTES
*/
- public ServletMultipartRequest(HttpServletRequest request, String strSaveDirectory) throws IllegalArgumentException, IOException
- {
- super(null,
- request.getContentType(),
- request.getContentLength(),
- request.getInputStream(),
- strSaveDirectory,
- MultipartRequest.MAX_READ_BYTES);
+ public ServletMultipartRequest(HttpServletRequest request,
+ String strSaveDirectory) throws IllegalArgumentException,
+ IOException {
+ super(null, request.getContentType(), request.getContentLength(),
+ request.getInputStream(), strSaveDirectory,
+ MultipartRequest.MAX_READ_BYTES);
}
- /**
- * Constructor wrapper, unwraps the InputStream,
- * content type and content lenght from the servlet request object.
- * Also allow to explicitly set the max permissable length of the request.
- *
- * @param request the HttpServletRequest will be used to initialise the MultipartRequest super class.
- * @param strSaveDirectory the temporary directory to save the file from where they can then be moved to wherever by the
- * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
- * will be silently ignored.</B>
- * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
- *
- * @throws IllegalArgumentException If the request.getContentType() does not contain a Content-Type
- * of "multipart/form-data" or the boundary is not found.
- * @throws IOException If the request.getContentLength() is higher than MAX_READ_BYTES
- * or strSaveDirectory is invalid or cannot be written to.
- *
+ /**
+ * Constructor wrapper, unwraps the InputStream, content type and content
+ * lenght from the servlet request object. Also allow to explicitly set the
+ * max permissable length of the request.
+ *
+ * @param request
+ * the HttpServletRequest will be used to initialise the
+ * MultipartRequest super class.
+ * @param strSaveDirectory
+ * the temporary directory to save the file from where they can
+ * then be moved to wherever by the calling process. <b>If you
+ * specify <u>null</u> for this parameter, then any files
+ * uploaded will be silently ignored.</B>
+ * @param intMaxReadBytes
+ * Overrides the MAX_BYTES_READ value, to allow arbitrarily long
+ * files.
+ *
+ * @throws IllegalArgumentException
+ * If the request.getContentType() does not contain a
+ * Content-Type of "multipart/form-data" or the boundary is not
+ * found.
+ * @throws IOException
+ * If the request.getContentLength() is higher than
+ * MAX_READ_BYTES or strSaveDirectory is invalid or cannot be
+ * written to.
+ *
* @see MultipartRequest#MAX_READ_BYTES
*/
- public ServletMultipartRequest(HttpServletRequest request, String strSaveDirectory, int intMaxReadBytes) throws IllegalArgumentException, IOException
- {
- super(null,
- request.getContentType(),
- request.getContentLength(),
- request.getInputStream(),
- strSaveDirectory,
- intMaxReadBytes);
+ public ServletMultipartRequest(HttpServletRequest request,
+ String strSaveDirectory, int intMaxReadBytes)
+ throws IllegalArgumentException, IOException {
+ super(null, request.getContentType(), request.getContentLength(),
+ request.getInputStream(), strSaveDirectory, intMaxReadBytes);
}
- /**
- * Constructor wrapper for loading the request into memory rather than temp-file.
- *
- * @param request the HttpServletRequest will be used to initialise the
- * MultipartRequest super class.
- * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
- *
- * @throws IllegalArgumentException If the request.getContentType() does not contain a Content-Type
- * of "multipart/form-data" or the boundary is not found.
- * @throws IOException If the request.getContentLength() is higher than MAX_READ_BYTES
- * or strSaveDirectory is invalid or cannot be written to.
- *
+ /**
+ * Constructor wrapper for loading the request into memory rather than
+ * temp-file.
+ *
+ * @param request
+ * the HttpServletRequest will be used to initialise the
+ * MultipartRequest super class.
+ * @param intMaxReadBytes
+ * Overrides the MAX_BYTES_READ value, to allow arbitrarily long
+ * files.
+ *
+ * @throws IllegalArgumentException
+ * If the request.getContentType() does not contain a
+ * Content-Type of "multipart/form-data" or the boundary is not
+ * found.
+ * @throws IOException
+ * If the request.getContentLength() is higher than
+ * MAX_READ_BYTES or strSaveDirectory is invalid or cannot be
+ * written to.
+ *
* @see MultipartRequest#MAX_READ_BYTES
*/
- public ServletMultipartRequest(HttpServletRequest request, int intMaxReadBytes) throws IllegalArgumentException, IOException
- {
- super(null,
- request.getContentType(),
- request.getContentLength(),
- request.getInputStream(),
- intMaxReadBytes);
+ public ServletMultipartRequest(HttpServletRequest request,
+ int intMaxReadBytes) throws IllegalArgumentException, IOException {
+ super(null, request.getContentType(), request.getContentLength(),
+ request.getInputStream(), intMaxReadBytes);
}
}
diff --git a/src/com/itmill/toolkit/terminal/web/ServletThemeSource.java b/src/com/itmill/toolkit/terminal/web/ServletThemeSource.java
index 231ffdc969..8221d04ab7 100644
--- a/src/com/itmill/toolkit/terminal/web/ServletThemeSource.java
+++ b/src/com/itmill/toolkit/terminal/web/ServletThemeSource.java
@@ -64,8 +64,8 @@ public class ServletThemeSource implements ThemeSource {
private Cache resourceCache = new Cache();
- /**
- * Collection of subdirectory entries.
+ /**
+ * Collection of subdirectory entries.
*/
private URL descFile;
@@ -79,8 +79,9 @@ public class ServletThemeSource implements ThemeSource {
* the Path inside the archive to be processed.
* @throws IOException
* if the writing failed due to input/output error.
- * @throws ThemeException If the resource is not found or there was
- * some problem finding the resource.
+ * @throws ThemeException
+ * If the resource is not found or there was some problem
+ * finding the resource.
*/
public ServletThemeSource(ServletContext context,
ApplicationServlet webAdapterServlet, String path)
@@ -131,6 +132,7 @@ public class ServletThemeSource implements ThemeSource {
/**
* Gets the XSL stream for the specified theme and web-browser type.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getXSLStreams(Theme,
* WebBrowser)
*/
@@ -198,6 +200,7 @@ public class ServletThemeSource implements ThemeSource {
/**
* Gets the input stream for the resource with the specified resource id.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getResource(String)
*/
public InputStream getResource(String resourceId)
@@ -247,7 +250,8 @@ public class ServletThemeSource implements ThemeSource {
}
/**
- * Gets the list of themes in the theme source.
+ * Gets the list of themes in the theme source.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getThemes()
*/
public Collection getThemes() {
@@ -260,6 +264,7 @@ public class ServletThemeSource implements ThemeSource {
/**
* Gets the name of the ThemeSource.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getName()
*/
public String getName() {
@@ -268,6 +273,7 @@ public class ServletThemeSource implements ThemeSource {
/**
* Gets the Theme instance by name.
+ *
* @see com.itmill.toolkit.terminal.web.ThemeSource#getThemeByName(String)
*/
public Theme getThemeByName(String name) {
@@ -289,29 +295,36 @@ public class ServletThemeSource implements ThemeSource {
private class Cache {
private Map data = new HashMap();
-
+
/**
- * Associates the specified value with the specified key in this map.
- * If the map previously contained a mapping for this key, the old value
- * is replaced by the specified value.
- * @param key the key with which the specified value is to be associated.
- * @param value the value to be associated with the specified key.
+ * Associates the specified value with the specified key in this map. If
+ * the map previously contained a mapping for this key, the old value is
+ * replaced by the specified value.
+ *
+ * @param key
+ * the key with which the specified value is to be
+ * associated.
+ * @param value
+ * the value to be associated with the specified key.
*/
public void put(Object key, Object value) {
data.put(key, new SoftReference(new CacheItem(value)));
}
-
+
/**
- * Returns the value to which this map maps the specified key. Returns null
- * if the map contains no mapping for this key.
+ * Returns the value to which this map maps the specified key. Returns
+ * null if the map contains no mapping for this key.
* <p>
- * A return value of null does not necessarily indicate that the map contains
- * no mapping for the key; it's also possible that the map explicitly maps
- * the key to null. The containsKey operation may be used to distinguish these two cases.
+ * A return value of null does not necessarily indicate that the map
+ * contains no mapping for the key; it's also possible that the map
+ * explicitly maps the key to null. The containsKey operation may be
+ * used to distinguish these two cases.
* </p>
- * @param key the key whose associated value is to be returned.
+ *
+ * @param key
+ * the key whose associated value is to be returned.
* @return the value to which this map maps the specified key, or null
- * if the map contains no mapping for this key.
+ * if the map contains no mapping for this key.
*/
public Object get(Object key) {
SoftReference ref = (SoftReference) data.get(key);
@@ -319,7 +332,7 @@ public class ServletThemeSource implements ThemeSource {
return ((CacheItem) ref.get()).getData();
return null;
}
-
+
/**
* Clears the data and removes all mappings from this map .
*/
@@ -337,7 +350,7 @@ public class ServletThemeSource implements ThemeSource {
private class CacheItem {
private Object data;
-
+
/**
*
* @param data
@@ -345,25 +358,28 @@ public class ServletThemeSource implements ThemeSource {
public CacheItem(Object data) {
this.data = data;
}
-
+
/**
* Gets the data.
+ *
* @return the data.
*/
public Object getData() {
return this.data;
};
-
+
/**
- * Called by the garbage collector on an object when garbage collection
- * determines that there are no more references to the object. A subclass
- * overrides the finalize method to dispose of system resources or to
- * perform other cleanup.
+ * Called by the garbage collector on an object when garbage collection
+ * determines that there are no more references to the object. A
+ * subclass overrides the finalize method to dispose of system resources
+ * or to perform other cleanup.
* <p>
* The finalize method is never invoked more than once by a Java virtual
* machine for any given object.
* </p>
- * @throws Throwable the Exception raised by this method
+ *
+ * @throws Throwable
+ * the Exception raised by this method
* @see java.lang.Object#finalize()
*/
public void finalize() throws Throwable {
diff --git a/src/com/itmill/toolkit/terminal/web/Theme.java b/src/com/itmill/toolkit/terminal/web/Theme.java
index 38f7d1e799..931a85ada3 100644
--- a/src/com/itmill/toolkit/terminal/web/Theme.java
+++ b/src/com/itmill/toolkit/terminal/web/Theme.java
@@ -48,9 +48,9 @@ import org.xml.sax.Attributes;
/**
* This class provides an interface to the meta-information regarding a
- * particular theme. This entails for instanace the inheritance tree
- * of the various xsl-template files, the different requirments that the theme
- * imposes on the client browser, etc.
+ * particular theme. This entails for instanace the inheritance tree of the
+ * various xsl-template files, the different requirments that the theme imposes
+ * on the client browser, etc.
* <p>
* The WebAdapter uses themes to convert the UIDL description into client
* representation, typically HTML or XHTML. A theme consists of set of XSL
@@ -87,8 +87,8 @@ import org.xml.sax.Attributes;
*/
public class Theme extends DefaultHandler {
- /**
- * Default description file name.
+ /**
+ * Default description file name.
*/
public static final String DESCRIPTIONFILE = "description.xml";
@@ -138,63 +138,63 @@ public class Theme extends DefaultHandler {
public static final String MODE_FALLBACK = MODE_HTML;
- /**
- * Name of the theme.
+ /**
+ * Name of the theme.
*/
private String name;
- /**
- * Theme description.
+ /**
+ * Theme description.
*/
private String description;
- /**
- * Author of the theme.
+ /**
+ * Author of the theme.
*/
private Author author;
- /**
- * Name of the theme, which this theme extends.
+ /**
+ * Name of the theme, which this theme extends.
*/
private String parentTheme = null;
- /**
- * Fileset of included XSL files.
+ /**
+ * Fileset of included XSL files.
*/
private Fileset files = null;
- /**
- * Stack of fileset used while parsing XML.
+ /**
+ * Stack of fileset used while parsing XML.
*/
private Stack openFilesets = new Stack();
- /**
- * Stack of string buffers used while parsing XML.
+ /**
+ * Stack of string buffers used while parsing XML.
*/
private Stack openStrings = new Stack();
- /**
- * Supported modes name-to-requirements.
+ /**
+ * Supported modes name-to-requirements.
*/
private LinkedHashMap supportedModes = new LinkedHashMap();
- /**
- * Currently open mode.
+ /**
+ * Currently open mode.
*/
private String currentlyOpenMode = null;
- /**
- * Are we processing modes.
+ /**
+ * Are we processing modes.
*/
private boolean modesListCurrentlyOpen = false;
- /**
- * Is a NOT requirement element open.
+ /**
+ * Is a NOT requirement element open.
*/
private boolean isNOTRequirementOpen = false;
- /**
- * Currently open requirements while parsing.
+ /**
+ * Currently open requirements while parsing.
*/
private Stack openRequirements = new Stack();
@@ -232,43 +232,48 @@ public class Theme extends DefaultHandler {
/**
* Gets the preferred operating mode supported by this theme for given
* terminal.
- * @param terminal the type of the web browser.
+ *
+ * @param terminal
+ * the type of the web browser.
* @param themeSource
*/
public String getPreferredMode(WebBrowser terminal, ThemeSource themeSource) {
// If no supported modes are declared, then we use parents preferred
// mode
- if (parentTheme != null
- && supportedModes.keySet().isEmpty()) {
+ if (parentTheme != null && supportedModes.keySet().isEmpty()) {
Theme parent = themeSource.getThemeByName(parentTheme);
if (parent == null)
- throw new IllegalStateException("Parent theme '"+parentTheme+"' is not found for theme '"+getName()+"'.");
+ throw new IllegalStateException("Parent theme '" + parentTheme
+ + "' is not found for theme '" + getName() + "'.");
return parent.getPreferredMode(terminal, themeSource);
}
-
+
// Iterate and test the modes in order
for (Iterator i = supportedModes.keySet().iterator(); i.hasNext();) {
String mode = (String) i.next();
- if (supportsMode(mode, terminal,themeSource))
+ if (supportsMode(mode, terminal, themeSource))
return mode;
}
return null;
}
- /**
- * Tests if this theme suppors given mode.
+ /**
+ * Tests if this theme suppors given mode.
+ *
* @param mode
- * @param terminal the type of the web browser.
+ * @param terminal
+ * the type of the web browser.
* @param themeSource
*/
- public boolean supportsMode(String mode, WebBrowser terminal, ThemeSource themeSource) {
+ public boolean supportsMode(String mode, WebBrowser terminal,
+ ThemeSource themeSource) {
// Theme must explicitly support the given mode
RequirementCollection rc = (RequirementCollection) supportedModes
.get(mode);
-
+
if (rc == null || !rc.isMet(terminal))
return false;
@@ -276,9 +281,10 @@ public class Theme extends DefaultHandler {
if (parentTheme != null) {
Theme parent = themeSource.getThemeByName(parentTheme);
if (parent == null)
- throw new IllegalStateException("Parent theme '"+parentTheme+"' is not found for theme '"+getName()+"'.");
- if(!parent.supportsMode(mode, terminal, themeSource))
- return false;
+ throw new IllegalStateException("Parent theme '" + parentTheme
+ + "' is not found for theme '" + getName() + "'.");
+ if (!parent.supportsMode(mode, terminal, themeSource))
+ return false;
}
return true;
@@ -340,7 +346,8 @@ public class Theme extends DefaultHandler {
throw new IllegalArgumentException("Theme " + this.name
+ " extends itself.");
if (parentTheme != null)
- throw new IllegalArgumentException("Only one extends statement is allowed");
+ throw new IllegalArgumentException(
+ "Only one extends statement is allowed");
this.parentTheme = themeName;
} else if (TAG_FILE.equals(qName)) {
File f = new File(atts.getValue(ATTR_NAME));
@@ -402,7 +409,10 @@ public class Theme extends DefaultHandler {
RequirementCollection rc = (RequirementCollection) supportedModes
.get(this.currentlyOpenMode);
if (rc == null)
- throw new IllegalStateException("Tried to add requirements to mode '" + name + "', but requirements set was not properly created. (internal error)");
+ throw new IllegalStateException(
+ "Tried to add requirements to mode '"
+ + name
+ + "', but requirements set was not properly created. (internal error)");
this.openRequirements.push(rc);
} else {
if (this.openFilesets.isEmpty()) {
@@ -455,10 +465,11 @@ public class Theme extends DefaultHandler {
} else if (TAG_MODE.equals(qName)) {
this.currentlyOpenMode = null;
} else if (TAG_OR.equals(qName) || TAG_AND.equals(qName)) {
- RequirementCollection r = (RequirementCollection) openRequirements.pop();
+ RequirementCollection r = (RequirementCollection) openRequirements
+ .pop();
if (openRequirements.size() < 1)
throw new IllegalStateException();
- ((RequirementCollection)openRequirements.peek()).addRequirement(r);
+ ((RequirementCollection) openRequirements.peek()).addRequirement(r);
}
}
@@ -539,9 +550,12 @@ public class Theme extends DefaultHandler {
/**
* Gets the list of file names matching WebBrowserType.
- * @param terminal the type of the web browser.
+ *
+ * @param terminal
+ * the type of the web browser.
* @param mode
- * @return the list of filenames in this theme supporting the given terminal.
+ * @return the list of filenames in this theme supporting the given
+ * terminal.
*/
public List getFileNames(WebBrowser terminal, String mode) {
if (files == null)
@@ -555,9 +569,13 @@ public class Theme extends DefaultHandler {
* @see java.lang.Object#toString()
*/
public String toString() {
- return this.name + " author='" + this.author + "'" + (parentTheme != null ? " inherits='"
- + parentTheme + "'" : "" )+ " files={"
- + (files != null ? files.toString() : "null") + "}";
+ return this.name
+ + " author='"
+ + this.author
+ + "'"
+ + (parentTheme != null ? " inherits='" + parentTheme + "'" : "")
+ + " files={" + (files != null ? files.toString() : "null")
+ + "}";
}
/**
@@ -570,15 +588,19 @@ public class Theme extends DefaultHandler {
* @since 3.0
*/
public class Author {
- //name of the author.
+ // name of the author.
private String name;
- //email address of the author.
+
+ // email address of the author.
private String email;
-
+
/**
* Constructor for Author Information Class.
- * @param name the name of the author.
- * @param email the email address of the author.
+ *
+ * @param name
+ * the name of the author.
+ * @param email
+ * the email address of the author.
*/
public Author(String name, String email) {
this.name = name;
@@ -627,8 +649,9 @@ public class Theme extends DefaultHandler {
*
* @param terminal
* the type of the web browser.
- * @return <code>true</code> if terminal is compatible with this rule,otherwise <code>false</code>.
- *
+ * @return <code>true</code> if terminal is compatible with this
+ * rule,otherwise <code>false</code>.
+ *
*/
public boolean isMet(WebBrowser terminal);
@@ -689,8 +712,9 @@ public class Theme extends DefaultHandler {
*
* @param terminal
* the type of the web browser.
- * @return <code>true</code> if terminal is compatible with this rule,otherwise <code>false</code>.
- *
+ * @return <code>true</code> if terminal is compatible with this
+ * rule,otherwise <code>false</code>.
+ *
*/
public boolean isMet(WebBrowser terminal) {
return !this.requirement.isMet(terminal);
@@ -720,7 +744,7 @@ public class Theme extends DefaultHandler {
public AndRequirement() {
}
-
+
/**
*
* @param requirements
@@ -728,7 +752,7 @@ public class Theme extends DefaultHandler {
public AndRequirement(Collection requirements) {
this.requirements.addAll(requirements);
}
-
+
/**
*
* @param req1
@@ -738,17 +762,19 @@ public class Theme extends DefaultHandler {
this.addRequirement(req1);
this.addRequirement(req2);
}
-
+
/**
* Adds the new requirement to this collection.
+ *
* @see com.itmill.toolkit.terminal.web.Theme.RequirementCollection#addRequirement(com.itmill.toolkit.terminal.web.Theme.Requirement)
*/
public void addRequirement(Requirement requirement) {
this.requirements.add(requirement);
}
-
+
/**
* Removes the requirement from this collection.
+ *
* @see com.itmill.toolkit.terminal.web.Theme.RequirementCollection#removeRequirement(com.itmill.toolkit.terminal.web.Theme.Requirement)
*/
public void removeRequirement(Requirement requirement) {
@@ -757,7 +783,9 @@ public class Theme extends DefaultHandler {
/**
* Checks that all os the requirements in this collection are met.
- * @param terminal the type of the web browser.
+ *
+ * @param terminal
+ * the type of the web browser.
* @see Theme.Requirement#isMet(WebBrowser)
*/
public boolean isMet(WebBrowser terminal) {
@@ -768,7 +796,7 @@ public class Theme extends DefaultHandler {
}
return true;
}
-
+
/**
* @see java.lang.Object#toString()
*/
@@ -799,7 +827,7 @@ public class Theme extends DefaultHandler {
public OrRequirement() {
}
-
+
/**
*
* @param requirements
@@ -807,7 +835,7 @@ public class Theme extends DefaultHandler {
public OrRequirement(Collection requirements) {
this.requirements.addAll(requirements);
}
-
+
/**
*
* @param req1
@@ -817,17 +845,19 @@ public class Theme extends DefaultHandler {
this.addRequirement(req1);
this.addRequirement(req2);
}
-
+
/**
* Adds the new requirement to this collection.
+ *
* @see com.itmill.toolkit.terminal.web.Theme.RequirementCollection#addRequirement(com.itmill.toolkit.terminal.web.Theme.Requirement)
*/
public void addRequirement(Requirement requirement) {
this.requirements.add(requirement);
}
-
+
/**
* Removes the requirement from this collection.
+ *
* @see com.itmill.toolkit.terminal.web.Theme.RequirementCollection#removeRequirement(com.itmill.toolkit.terminal.web.Theme.Requirement)
*/
public void removeRequirement(Requirement requirement) {
@@ -836,7 +866,9 @@ public class Theme extends DefaultHandler {
/**
* Checks that some of the requirements in this collection is met.
- * @param terminal the type of the web browser.
+ *
+ * @param terminal
+ * the type of the web browser.
* @see Theme.Requirement#isMet(WebBrowser)
*/
public boolean isMet(WebBrowser terminal) {
@@ -847,7 +879,7 @@ public class Theme extends DefaultHandler {
}
return false;
}
-
+
/**
* @see java.lang.Object#toString()
*/
@@ -875,7 +907,7 @@ public class Theme extends DefaultHandler {
public class AgentRequirement implements Requirement {
private String agentSubstring;
-
+
/**
*
* @param agentSubString
@@ -883,13 +915,15 @@ public class Theme extends DefaultHandler {
public AgentRequirement(String agentSubString) {
this.agentSubstring = agentSubString;
}
-
+
/**
* Checks that this requirement is met by given type of browser.
+ *
* @see com.itmill.toolkit.terminal.web.Theme.Requirement#isMet(com.itmill.toolkit.terminal.web.WebBrowser)
*/
public boolean isMet(WebBrowser terminal) {
- return terminal.getBrowserApplication().indexOf(this.agentSubstring) >= 0;
+ return terminal.getBrowserApplication()
+ .indexOf(this.agentSubstring) >= 0;
}
/**
@@ -912,7 +946,7 @@ public class Theme extends DefaultHandler {
public class JavaScriptRequirement implements Requirement {
private WebBrowser.JavaScriptVersion requiredVersion;
-
+
/**
*
* @param requiredVersion
@@ -921,9 +955,10 @@ public class Theme extends DefaultHandler {
WebBrowser.JavaScriptVersion requiredVersion) {
this.requiredVersion = requiredVersion;
}
-
+
/**
* Checks that this requirement is met by given type of browser.
+ *
* @see com.itmill.toolkit.terminal.web.Theme.Requirement#isMet(com.itmill.toolkit.terminal.web.WebBrowser)
*/
public boolean isMet(WebBrowser terminal) {
@@ -952,7 +987,7 @@ public class Theme extends DefaultHandler {
public class MarkupLanguageRequirement implements Requirement {
private WebBrowser.MarkupVersion requiredVersion;
-
+
/**
*
* @param requiredVersion
@@ -961,9 +996,10 @@ public class Theme extends DefaultHandler {
WebBrowser.MarkupVersion requiredVersion) {
this.requiredVersion = requiredVersion;
}
-
+
/**
* Checks that this requirement is met by given type of browser.
+ *
* @see com.itmill.toolkit.terminal.web.Theme.Requirement#isMet(com.itmill.toolkit.terminal.web.WebBrowser)
*/
public boolean isMet(WebBrowser terminal) {
@@ -1006,8 +1042,8 @@ public class Theme extends DefaultHandler {
}
/**
- * Gets the name of the file. The file name is relative and unique within a
- * theme.
+ * Gets the name of the file. The file name is relative and unique
+ * within a theme.
*
* @return the Name of the file.
*/
@@ -1018,7 +1054,9 @@ public class Theme extends DefaultHandler {
/**
* Does this file support the given terminal. Single file requirements
* are not supported and therefore this always returns true.
- * @param terminal the type of the web browser.
+ *
+ * @param terminal
+ * the type of the web browser.
* @return Always returns true.
* @see Theme.Fileset
*/
@@ -1055,24 +1093,27 @@ public class Theme extends DefaultHandler {
* Creates a new empty fileset.
*
* @param mode
- *
+ *
*/
public Fileset(String mode) {
super(null);
this.mode = mode;
}
- /**
+ /**
* Adds a file into fileset.
- * @param file the file to add.
+ *
+ * @param file
+ * the file to add.
*/
private void addFile(File file) {
this.files.add(file);
}
- /**
+ /**
* Gets the requirements in this fileset.
- * @return the requirements.
+ *
+ * @return the requirements.
*/
private RequirementCollection getRequirements() {
return this.requirements;
@@ -1103,8 +1144,10 @@ public class Theme extends DefaultHandler {
/**
* Gets the list of file names matching WebBrowserType.
- * @param terminal the type of the web browser.
- * @param mode
+ *
+ * @param terminal
+ * the type of the web browser.
+ * @param mode
* @return the list of filenames supporting the given terminal.
*/
public List getFileNames(WebBrowser terminal, String mode) {
@@ -1135,7 +1178,8 @@ public class Theme extends DefaultHandler {
/**
* Does this file support the given terminal.
- * @terminal the type of the web browser.
+ *
+ * @terminal the type of the web browser.
* @return True if fileset supports the given browser. False otherwise.
*/
public boolean supports(WebBrowser terminal) {
@@ -1173,15 +1217,17 @@ public class Theme extends DefaultHandler {
/**
* Gets the name of the parent theme.
+ *
* @return the name of the parent theme.
*/
public String getParent() {
return parentTheme;
}
- /**
+ /**
* Gets the theme description.
- * @return the theme description.
+ *
+ * @return the theme description.
*/
public String getDescription() {
return description;
diff --git a/src/com/itmill/toolkit/terminal/web/ThemeFunctionLibrary.java b/src/com/itmill/toolkit/terminal/web/ThemeFunctionLibrary.java
index 79417700b6..a7b62af8d7 100644
--- a/src/com/itmill/toolkit/terminal/web/ThemeFunctionLibrary.java
+++ b/src/com/itmill/toolkit/terminal/web/ThemeFunctionLibrary.java
@@ -71,16 +71,16 @@ public class ThemeFunctionLibrary {
static private final int THEME = 5;
static private ThreadLocal state = new ThreadLocal();
-
-/**
- *
- * @param application
- * @param window
- * @param webBrowser
- * @param session
- * @param webAdapterServlet
- * @param theme
- */
+
+ /**
+ *
+ * @param application
+ * @param window
+ * @param webBrowser
+ * @param session
+ * @param webAdapterServlet
+ * @param theme
+ */
static protected void setState(Application application, Window window,
WebBrowser webBrowser, HttpSession session,
ApplicationServlet webAdapterServlet, String theme) {
@@ -154,6 +154,7 @@ public class ThemeFunctionLibrary {
/**
* Returns an URI to the named resource from the named theme.
+ *
* @param resource
* @param theme
*/
@@ -168,6 +169,7 @@ public class ThemeFunctionLibrary {
/**
* Returns an URI to the named resource.
+ *
* @param resource
*/
static public String resource(String resource) {
@@ -180,7 +182,8 @@ public class ThemeFunctionLibrary {
}
/**
- * Generates the JavaScript for page that performs client-side combility checks.
+ * Generates the JavaScript for page that performs client-side combility
+ * checks.
*/
static public boolean probeClient() {
return (browser().performClientCheck() && !browser()
@@ -197,6 +200,7 @@ public class ThemeFunctionLibrary {
* <li>Sets the window name</li>
* <li>Closes window if it is set to be closed </li>
* <ul>
+ *
* @return
*/
static public String windowScript() {
@@ -206,15 +210,15 @@ public class ThemeFunctionLibrary {
(ApplicationServlet) ((Object[]) state.get())[WEBADAPTERSERVLET],
browser());
}
-
-/**
- *
- * @param window
- * @param app
- * @param wa
- * @param browser
- * @return
- */
+
+ /**
+ *
+ * @param window
+ * @param app
+ * @param wa
+ * @param browser
+ * @return
+ */
static protected String generateWindowScript(Window window,
Application app, ApplicationServlet wa, WebBrowser browser) {
@@ -288,10 +292,11 @@ public class ThemeFunctionLibrary {
/**
* Returns an unique target name for a given window name.
+ *
* @param application
* @param window
* the Name of the window.
- * @return An unique ID for window target.
+ * @return An unique ID for window target.
*/
static public String getWindowTargetName(Application application,
Window window) {
@@ -313,7 +318,9 @@ public class ThemeFunctionLibrary {
/**
* Returns an unique target name for current window.
- * @param name the name of the window.
+ *
+ * @param name
+ * the name of the window.
* @return An unique ID for window target.
*/
static public String getWindowTargetName(String name) {
@@ -361,7 +368,8 @@ public class ThemeFunctionLibrary {
/**
* Gets the name of first day of the week.
- * @return
+ *
+ * @return
*/
static public int getFirstDayOfWeek() {
try {
@@ -382,7 +390,7 @@ public class ThemeFunctionLibrary {
* Gets the name for week day.
*
* @param dayOfWeek
- * the Number of week day. 0 sunday, 1 monday, ...
+ * the Number of week day. 0 sunday, 1 monday, ...
* @return the Name of week day in applications current locale.
*/
static public String getShortWeekday(int dayOfWeek) {
@@ -399,7 +407,7 @@ public class ThemeFunctionLibrary {
* Gets the short name for month.
*
* @param month
- * the Number of month. 0 is January, 1 is February, and so on.
+ * the Number of month. 0 is January, 1 is February, and so on.
* @return the Name of month in applications current locale.
*/
static public String getShortMonth(int month) {
@@ -416,8 +424,8 @@ public class ThemeFunctionLibrary {
/**
* Gets the name for month.
*
- * @param month
- * the Number of month. 0 is January, 1 is February, and so on.
+ * @param month
+ * the Number of month. 0 is January, 1 is February, and so on.
* @return the Name of month in applications current locale.
*/
static public String getMonth(int month) {
@@ -450,9 +458,10 @@ public class ThemeFunctionLibrary {
.getWindowFormAction(win);
}
- /**
- * Generates the links for CSS files to be included in html head.
- * @return
+ /**
+ * Generates the links for CSS files to be included in html head.
+ *
+ * @return
*/
static public String getCssLinksForHead() {
ApplicationServlet as = (ApplicationServlet) ((Object[]) state.get())[WEBADAPTERSERVLET];
@@ -470,7 +479,8 @@ public class ThemeFunctionLibrary {
// Generates links
StringBuffer links = new StringBuffer();
for (int k = themes.size() - 1; k >= 0; k--) {
- Collection allFiles = ((Theme)themes.get(k)).getFileNames(browser(), Theme.MODE_HTML);
+ Collection allFiles = ((Theme) themes.get(k)).getFileNames(
+ browser(), Theme.MODE_HTML);
for (Iterator i = allFiles.iterator(); i.hasNext();) {
String file = (String) i.next();
if (file.endsWith(".css")) {
@@ -484,9 +494,10 @@ public class ThemeFunctionLibrary {
return links.toString();
}
- /**
- * Generates the links for JavaScript files to be included in html head.
- * @return
+ /**
+ * Generates the links for JavaScript files to be included in html head.
+ *
+ * @return
*/
static public String getJavaScriptLinksForHead() {
ApplicationServlet as = (ApplicationServlet) ((Object[]) state.get())[WEBADAPTERSERVLET];
@@ -518,8 +529,9 @@ public class ThemeFunctionLibrary {
return links.toString();
}
- /**
- * Generates the JavaScript for updating given window.
+ /**
+ * Generates the JavaScript for updating given window.
+ *
* @param application
* @param window
* @param browser
diff --git a/src/com/itmill/toolkit/terminal/web/ThemeSource.java b/src/com/itmill/toolkit/terminal/web/ThemeSource.java
index 81f8cb85eb..c2ff054683 100644
--- a/src/com/itmill/toolkit/terminal/web/ThemeSource.java
+++ b/src/com/itmill/toolkit/terminal/web/ThemeSource.java
@@ -1,156 +1,178 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
import java.io.InputStream;
import java.util.Collection;
-/**
+/**
* Interface implemented by theme sources.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface ThemeSource {
- /**
+ /**
* Gets the name of the ThemeSource.
+ *
* @return the Name of the theme source.
*/
public String getName();
-
- /**
- * Gets the XSL stream for the specified theme and web-browser type.
- * Returns the XSL templates, which are used to process the
- * UIDL data. The <code>type</code> parameter is used to limit
- * the templates, which are returned based on the theme fileset
- * requirements.
+
+ /**
+ * Gets the XSL stream for the specified theme and web-browser type. Returns
+ * the XSL templates, which are used to process the UIDL data. The
+ * <code>type</code> parameter is used to limit the templates, which are
+ * returned based on the theme fileset requirements.
* <p>
* Note : This implicitly operates in xslt mode.
* </p>
- * @param theme the Theme, which XSL should be returned.
- * @param type the type of the current client.
+ *
+ * @param theme
+ * the Theme, which XSL should be returned.
+ * @param type
+ * the type of the current client.
* @return Collection of ThemeSource.XSLStream objects.
- * @throws ThemeException If the resource is not found or there was
- * some problem finding the resource.
+ * @throws ThemeException
+ * If the resource is not found or there was some problem
+ * finding the resource.
* @see Theme
*/
public Collection getXSLStreams(Theme theme, WebBrowser type)
- throws ThemeException;
+ throws ThemeException;
- /**
+ /**
* Gets the last modification time, used to reload theme on changes.
+ *
* @return the Last modification time of the theme source.
*/
public long getModificationTime();
- /**
+ /**
* Gets the input stream for the resource with the specified resource id.
- * @param resourceId the resource id.
+ *
+ * @param resourceId
+ * the resource id.
* @return Stream where the resource can be read.
- * @throws ThemeException If the resource is not found or there was
- * some problem finding the resource.
+ * @throws ThemeException
+ * If the resource is not found or there was some problem
+ * finding the resource.
*/
public InputStream getResource(String resourceId) throws ThemeException;
- /**
- * Gets the list of themes in the theme source.
+ /**
+ * Gets the list of themes in the theme source.
+ *
* @return the List of themes included in the theme source.
*/
public Collection getThemes();
- /**
+ /**
* Returns the Theme instance by name.
- * @param name the Theme name.
+ *
+ * @param name
+ * the Theme name.
* @return the Theme instance matching the name, or null if not found.
*/
public Theme getThemeByName(String name);
- /**
- * <code>ThemeException</code> is thrown by classes implementing
- * the <code>ThemeSource</code> interface if some error occurs during processing.
+ /**
+ * <code>ThemeException</code> is thrown by classes implementing the
+ * <code>ThemeSource</code> interface if some error occurs during
+ * processing.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class ThemeException extends Exception {
private static final long serialVersionUID = -7823850742197580285L;
- /**
+ /**
* Creates a new theme exception.
- * @param message the Error message.
+ *
+ * @param message
+ * the Error message.
*/
public ThemeException(String message) {
super(message);
}
- /**
- * Creates a new theme exception.
- *
- * @param message the error message.
- * @param cause the cause of the exception.
- */
- public ThemeException(String message, Throwable cause) {
- super(message,cause);
- }
+ /**
+ * Creates a new theme exception.
+ *
+ * @param message
+ * the error message.
+ * @param cause
+ * the cause of the exception.
+ */
+ public ThemeException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
- /**
- * Wrapper class for XSL InputStreams.
+ /**
+ * Wrapper class for XSL InputStreams.
*/
public class XSLStream {
private String id;
+
private InputStream stream;
-
-/**
- *
- * @param id
- * @param stream the input stream.
- */
+
+ /**
+ *
+ * @param id
+ * @param stream
+ * the input stream.
+ */
public XSLStream(String id, InputStream stream) {
this.id = id;
this.stream = stream;
}
-
- /**
+
+ /**
* Returns id of this stream.
- * @return the id of the stream.
+ *
+ * @return the id of the stream.
*/
public String getId() {
return id;
}
- /**
+ /**
* Returns the actual XSL Stream.
+ *
* @return the XSL Stream.
*/
public InputStream getStream() {
diff --git a/src/com/itmill/toolkit/terminal/web/UIDLTransformer.java b/src/com/itmill/toolkit/terminal/web/UIDLTransformer.java
index a6e4c21f25..d06223b21a 100644
--- a/src/com/itmill/toolkit/terminal/web/UIDLTransformer.java
+++ b/src/com/itmill/toolkit/terminal/web/UIDLTransformer.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -51,75 +51,78 @@ import javax.xml.transform.ErrorListener;
import javax.xml.transform.SourceLocator;
import javax.xml.transform.OutputKeys;
-/**
+/**
* Class implementing the UIDLTransformer.
- *
- * The transformer should not be created directly; it should be contructed
- * using <code>getTransformer</code> provided by <code>UIDLTransformerFactory</code>.
+ *
+ * The transformer should not be created directly; it should be contructed using
+ * <code>getTransformer</code> provided by <code>UIDLTransformerFactory</code>.
*
* After the transform has been done, the transformer can be recycled with
* <code>releaseTransformer</code> by <code>UIDLTransformerFactory</code>.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class UIDLTransformer {
- /**
- * XSLT factory.
+ /**
+ * XSLT factory.
*/
protected static javax.xml.transform.TransformerFactory xsltFactory;
static {
xsltFactory = javax.xml.transform.TransformerFactory.newInstance();
if (xsltFactory == null)
- throw new RuntimeException(
- "Could not instantiate "
+ throw new RuntimeException("Could not instantiate "
+ "transformer factory. Maybe XSLT processor is "
+ "not included in classpath.");
}
- /**
- * Source of the transform containing UIDL.
+ /**
+ * Source of the transform containing UIDL.
*/
private WebPaintTarget paintTarget;
- /**
- * Holds the type of the transformer.
+ /**
+ * Holds the type of the transformer.
*/
private UIDLTransformerType transformerType;
- /**
- * Prepared XSLT transformer for UIDL transformations.
+ /**
+ * Prepared XSLT transformer for UIDL transformations.
*/
private javax.xml.transform.Transformer uidlTransformer;
- /**
- * Error handled used.
+ /**
+ * Error handled used.
*/
private TransformerErrorHandler errorHandler;
- /**
- * Theme repository used for late error reporting.
+ /**
+ * Theme repository used for late error reporting.
*/
private ThemeSource themeSource;
private ApplicationServlet webAdapterServlet;
- /**
+ /**
* UIDLTransformer constructor.
- * @param type the Type of the transformer.
- * @param themes the theme implemented by the transformer.
- * @param webAdapterServlet the Adapter servlet.
- * @throws UIDLTransformerException UIDLTransformer exception is thrown,
- * if the transform can not be created.
+ *
+ * @param type
+ * the Type of the transformer.
+ * @param themes
+ * the theme implemented by the transformer.
+ * @param webAdapterServlet
+ * the Adapter servlet.
+ * @throws UIDLTransformerException
+ * UIDLTransformer exception is thrown, if the transform can not
+ * be created.
*/
- public UIDLTransformer(
- UIDLTransformerType type,
- ThemeSource themes,
- ApplicationServlet webAdapterServlet)
- throws UIDLTransformerException {
+ public UIDLTransformer(UIDLTransformerType type, ThemeSource themes,
+ ApplicationServlet webAdapterServlet)
+ throws UIDLTransformerException {
this.transformerType = type;
this.themeSource = themes;
this.webAdapterServlet = webAdapterServlet;
@@ -137,12 +140,8 @@ public class UIDLTransformer {
// Creates XML reader for concatenating
// multiple XSL files as one.
- XMLReader xmlReader =
- new XSLReader(
- parser,
- themes.getXSLStreams(
- type.getTheme(),
- type.getWebBrowser()));
+ XMLReader xmlReader = new XSLReader(parser, themes.getXSLStreams(
+ type.getTheme(), type.getWebBrowser()));
xmlReader.setErrorHandler(errorHandler);
@@ -166,60 +165,58 @@ public class UIDLTransformer {
// UIDL error or error in XSL/T semantics (like XPath)
if (errorHandler.hasFatalErrors()) {
throw new UIDLTransformerException(
- "XSL Transformer creation failed",
- errorHandler.getFirstFatalError(),
- errorHandler.getUIDLErrorReport()
- + "<br /><br />"
- + errorHandler.getXSLErrorReport(
- themeSource,
- transformerType));
+ "XSL Transformer creation failed", errorHandler
+ .getFirstFatalError(), errorHandler
+ .getUIDLErrorReport()
+ + "<br /><br />"
+ + errorHandler.getXSLErrorReport(themeSource,
+ transformerType));
}
} catch (Exception e) {
// Pass the new XHTML coded error forwards
- throw new UIDLTransformerException(
- e.toString(),
- e,
- errorHandler.getXSLErrorReport(themeSource, transformerType));
+ throw new UIDLTransformerException(e.toString(), e, errorHandler
+ .getXSLErrorReport(themeSource, transformerType));
}
}
- /**
+ /**
* Gets the type of the transformer.
+ *
* @return the Type of the transformer.
*/
public UIDLTransformerType getTransformerType() {
return this.transformerType;
}
- /**
- * Attaches the output stream to transformer and get corresponding UIDLStream for
- * writing UI description language trough transform to given output.
- * @param variableMap the variable map used for UIDL creation.
- * @return returns UI description language stream, that can be used for writing UIDL to
- * transformer.
+ /**
+ * Attaches the output stream to transformer and get corresponding
+ * UIDLStream for writing UI description language trough transform to given
+ * output.
+ *
+ * @param variableMap
+ * the variable map used for UIDL creation.
+ * @return returns UI description language stream, that can be used for
+ * writing UIDL to transformer.
*/
public WebPaintTarget getPaintTarget(HttpVariableMap variableMap) {
try {
- paintTarget =
- new WebPaintTarget(
- variableMap,
- transformerType,
- webAdapterServlet,
- transformerType.getTheme());
+ paintTarget = new WebPaintTarget(variableMap, transformerType,
+ webAdapterServlet, transformerType.getTheme());
} catch (PaintException e) {
throw new IllegalArgumentException(
- "Failed to instantiate new WebPaintTarget: " + e);
+ "Failed to instantiate new WebPaintTarget: " + e);
}
return paintTarget;
}
- /**
+ /**
* Resets the transformer, before it can be used again. This also interrupts
* any ongoing transform and thus should not be called before the transform
- * is ready. This is automatically called by the UIDLTransformFactory, when the UIDLTransformer
- * has been released.
+ * is ready. This is automatically called by the UIDLTransformFactory, when
+ * the UIDLTransformer has been released.
+ *
* @see UIDLTransformerFactory#releaseTransformer(UIDLTransformer)
*/
protected void reset() {
@@ -238,153 +235,146 @@ public class UIDLTransformer {
/**
* Transforms the UIDL to HTML and output to the OutputStream.
*
- * @param outputStream the output stream to render to.
- * @throws UIDLTransformerException UIDLTransformer exception is thrown,
- * if the transform can not be created.
+ * @param outputStream
+ * the output stream to render to.
+ * @throws UIDLTransformerException
+ * UIDLTransformer exception is thrown, if the transform can not
+ * be created.
*/
public void transform(OutputStream outputStream)
- throws UIDLTransformerException {
+ throws UIDLTransformerException {
- StreamResult result =
- new StreamResult(new BufferedOutputStream(outputStream));
+ StreamResult result = new StreamResult(new BufferedOutputStream(
+ outputStream));
// XSL Transform
try {
- InputSource uidl =
- new InputSource(new StringReader(paintTarget.getUIDL()));
- XMLReader reader =
- org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
+ InputSource uidl = new InputSource(new StringReader(paintTarget
+ .getUIDL()));
+ XMLReader reader = org.xml.sax.helpers.XMLReaderFactory
+ .createXMLReader();
reader.setErrorHandler(this.errorHandler);
// Validates if requested. We validate the UIDL separately,
// toget the SAXExceptions instead of TransformerExceptions.
// This is required to get the line numbers right.
- /* FIXME: Disable due abnormalities in DTD handling.
- if (webAdapterServlet.isDebugMode()) {
- reader.setFeature(
- "http://xml.org/sax/features/validation",
- true);
- reader.parse(uidl);
- uidl =
- new InputSource(new StringReader(paintTarget.getUIDL()));
-
- }
- */
+ /*
+ * FIXME: Disable due abnormalities in DTD handling. if
+ * (webAdapterServlet.isDebugMode()) { reader.setFeature(
+ * "http://xml.org/sax/features/validation", true);
+ * reader.parse(uidl); uidl = new InputSource(new
+ * StringReader(paintTarget.getUIDL()));
+ * }
+ */
SAXSource source = new SAXSource(reader, uidl);
uidlTransformer.transform(source, result);
} catch (Exception e) {
// XSL parsing failed. Pass the new XHTML coded error forwards
- throw new UIDLTransformerException(
- e.toString(),
- e,
- errorHandler.getUIDLErrorReport());
+ throw new UIDLTransformerException(e.toString(), e, errorHandler
+ .getUIDLErrorReport());
}
// Checks if transform itself failed, meaning either
// UIDL error or error in XSL/T semantics (like XPath)
if (errorHandler.hasFatalErrors()) {
- throw new UIDLTransformerException(
- "UIDL Transform failed",
- errorHandler.getFirstFatalError(),
- errorHandler.getUIDLErrorReport()
- + "<br /><br />"
- + errorHandler.getXSLErrorReport(
- themeSource,
- transformerType));
+ throw new UIDLTransformerException("UIDL Transform failed",
+ errorHandler.getFirstFatalError(), errorHandler
+ .getUIDLErrorReport()
+ + "<br /><br />"
+ + errorHandler.getXSLErrorReport(themeSource,
+ transformerType));
}
}
-
-/**
- *
- *
- *
- */
- protected class TransformerErrorHandler
- implements ErrorListener, org.xml.sax.ErrorHandler {
+
+ /**
+ *
+ *
+ *
+ */
+ protected class TransformerErrorHandler implements ErrorListener,
+ org.xml.sax.ErrorHandler {
LinkedList errors = new LinkedList();
+
LinkedList warnings = new LinkedList();
+
LinkedList fatals = new LinkedList();
+
Hashtable rowToErrorMap = new Hashtable();
+
Hashtable errorToRowMap = new Hashtable();
-
-/**
- *
- * @return
- */
+
+ /**
+ *
+ * @return
+ */
public boolean hasNoErrors() {
return errors.isEmpty() && warnings.isEmpty() && fatals.isEmpty();
}
-
-/**
- *
- * @return
- */
+
+ /**
+ *
+ * @return
+ */
public boolean hasFatalErrors() {
return !fatals.isEmpty();
}
-
-/**
- *
- *
- */
+
+ /**
+ *
+ *
+ */
public void clear() {
errors.clear();
warnings.clear();
fatals.clear();
}
-
+
/**
* @see java.lang.Object#toString()
*/
public String toString() {
- return getHTMLErrors("Fatal Errors", fatals)
- + "<br />"
- + getHTMLErrors("Errors", errors)
- + "<br />"
- + getHTMLErrors("Warnings", warnings)
- + "<br />";
+ return getHTMLErrors("Fatal Errors", fatals) + "<br />"
+ + getHTMLErrors("Errors", errors) + "<br />"
+ + getHTMLErrors("Warnings", warnings) + "<br />";
}
-
-/**
- *
- * @param title
- * @param l
- * @return
- */
+
+ /**
+ *
+ * @param title
+ * @param l
+ * @return
+ */
private String getHTMLErrors(String title, LinkedList l) {
String r = "";
r = "<b>" + title + "</b><br />";
if (l.size() > 0) {
for (Iterator i = l.iterator(); i.hasNext();) {
Exception e = (Exception) i.next();
- if (e
- instanceof javax.xml.transform.TransformerException) {
+ if (e instanceof javax.xml.transform.TransformerException) {
Integer line = (Integer) errorToRowMap.get(e);
r += " - "
- + WebPaintTarget.escapeXML(
- ((javax.xml.transform.TransformerException) e)
- .getMessage());
- Throwable cause =
- ((javax.xml.transform.TransformerException) e)
+ + WebPaintTarget
+ .escapeXML(((javax.xml.transform.TransformerException) e)
+ .getMessage());
+ Throwable cause = ((javax.xml.transform.TransformerException) e)
.getException();
// Append cause if available
if (cause != null) {
r += ": "
- + WebPaintTarget.escapeXML(cause.getMessage());
+ + WebPaintTarget.escapeXML(cause
+ .getMessage());
}
- r += line != null
- ? " (line:" + line.intValue() + ")"
- : " (line unknown)";
+ r += line != null ? " (line:" + line.intValue() + ")"
+ : " (line unknown)";
r += "<br />\n";
} else {
Integer line = (Integer) errorToRowMap.get(e);
r += " - " + WebPaintTarget.escapeXML(e.toString());
- r += line != null
- ? " (line:" + line.intValue() + ")"
- : " (line unknown)";
+ r += line != null ? " (line:" + line.intValue() + ")"
+ : " (line unknown)";
r += "<br />\n";
}
@@ -401,13 +391,10 @@ public class UIDLTransformer {
errors.addLast(exception);
SourceLocator l = exception.getLocator();
if (l != null) {
- rowToErrorMap.put(
- new Integer(
+ rowToErrorMap.put(new Integer(
((XSLReader.XSLStreamLocator) l).getLineNumber()),
- exception);
- errorToRowMap.put(
- exception,
- new Integer(
+ exception);
+ errorToRowMap.put(exception, new Integer(
((XSLReader.XSLStreamLocator) l).getLineNumber()));
}
}
@@ -417,17 +404,15 @@ public class UIDLTransformer {
* @see javax.xml.transform.ErrorListener#fatalError(TransformerException)
*/
public void fatalError(
- javax.xml.transform.TransformerException exception) {
+ javax.xml.transform.TransformerException exception) {
if (exception != null) {
fatals.addLast(exception);
SourceLocator l = exception.getLocator();
if (l != null) {
- rowToErrorMap.put(
- new Integer(l.getLineNumber()),
- exception);
- errorToRowMap.put(
- exception,
- new Integer(l.getLineNumber()));
+ rowToErrorMap
+ .put(new Integer(l.getLineNumber()), exception);
+ errorToRowMap
+ .put(exception, new Integer(l.getLineNumber()));
}
}
}
@@ -435,40 +420,37 @@ public class UIDLTransformer {
/**
* @see javax.xml.transform.ErrorListener#warning(TransformerException)
*/
- public void warning(
- javax.xml.transform.TransformerException exception) {
+ public void warning(javax.xml.transform.TransformerException exception) {
if (exception != null) {
warnings.addLast(exception);
SourceLocator l = exception.getLocator();
if (l != null) {
- rowToErrorMap.put(
- new Integer(l.getLineNumber()),
- exception);
- errorToRowMap.put(
- exception,
- new Integer(l.getLineNumber()));
+ rowToErrorMap
+ .put(new Integer(l.getLineNumber()), exception);
+ errorToRowMap
+ .put(exception, new Integer(l.getLineNumber()));
}
}
}
- /**
- * Gets the formated error report on XSL.
+ /**
+ * Gets the formated error report on XSL.
+ *
* @param themes
* @param type
*/
- public String getXSLErrorReport(
- ThemeSource themes,
- UIDLTransformerType type) {
+ public String getXSLErrorReport(ThemeSource themes,
+ UIDLTransformerType type) {
// Recreates the XSL for error reporting
StringBuffer readBuffer = new StringBuffer();
try {
- Collection c =
- themes.getXSLStreams(type.getTheme(), type.getWebBrowser());
+ Collection c = themes.getXSLStreams(type.getTheme(), type
+ .getWebBrowser());
for (Iterator i = c.iterator(); i.hasNext();) {
- java.io.InputStream is =
- ((ThemeSource.XSLStream) i.next()).getStream();
+ java.io.InputStream is = ((ThemeSource.XSLStream) i.next())
+ .getStream();
byte[] buffer = new byte[1024];
int read = 0;
while ((read = is.read(buffer)) >= 0)
@@ -495,16 +477,16 @@ public class UIDLTransformer {
boolean lastLineWasEmpty = false;
sb.append(toString());
- sb.append(
- "<font size=\"+1\"><a href=\"#err1\">"
- + "Go to first error</a></font>"
- + "<table width=\"100%\" style=\"border-left: 1px solid black; "
- + "border-right: 1px solid black; border-bottom: "
- + "1px solid black; border-top: 1px solid black\""
- + " cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>"
- + "<th bgcolor=\"#ddddff\" colspan=\"2\">"
- + "<font size=\"+2\">XSL</font><br />"
- + "</th></tr>\n");
+ sb
+ .append("<font size=\"+1\"><a href=\"#err1\">"
+ + "Go to first error</a></font>"
+ + "<table width=\"100%\" style=\"border-left: 1px solid black; "
+ + "border-right: 1px solid black; border-bottom: "
+ + "1px solid black; border-top: 1px solid black\""
+ + " cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>"
+ + "<th bgcolor=\"#ddddff\" colspan=\"2\">"
+ + "<font size=\"+2\">XSL</font><br />"
+ + "</th></tr>\n");
while ((index = xsl.indexOf('\n', prev)) >= 0) {
String line = xsl.substring(prev, index);
@@ -523,40 +505,28 @@ public class UIDLTransformer {
if (exp != null) {
errornro++;
- head =
- "<a name=\"err"
- + String.valueOf(errornro)
+ head = "<a name=\"err" + String.valueOf(errornro)
+ "\"><table width=\"100%\">"
+ "<tr><th bgcolor=\"#ff3030\">"
- + exp.getLocalizedMessage()
- + "</th></tr>"
+ + exp.getLocalizedMessage() + "</th></tr>"
+ "<tr><td bgcolor=\"#ffcccc\">";
- tail =
- "</tr><tr><th bgcolor=\"#ff3030\">"
- + (errornro > 1
- ? "<a href=\"#err"
+ tail = "</tr><tr><th bgcolor=\"#ff3030\">"
+ + (errornro > 1 ? "<a href=\"#err"
+ String.valueOf(errornro - 1)
- + "\">Previous error</a> "
- : "")
- + "<a href=\"#err"
- + String.valueOf(errornro + 1)
- + "\">Next error</a>"
- + "</th></tr></table></a>\n";
+ + "\">Previous error</a> " : "")
+ + "<a href=\"#err" + String.valueOf(errornro + 1)
+ + "\">Next error</a>" + "</th></tr></table></a>\n";
}
if (!(isEmpty && lastLineWasEmpty))
- sb.append(
- "<tr"
- + ((row % 10) > 4 ? " bgcolor=\"#eeeeff\"" : "")
- + "><td style=\"border-right: 1px solid gray\">&nbsp;"
- + String.valueOf(row)
- + "&nbsp;</td><td>"
- + head
- + "<nobr>"
- + line
- + "</nobr>"
- + tail
- + "</td></tr>\n");
+ sb
+ .append("<tr"
+ + ((row % 10) > 4 ? " bgcolor=\"#eeeeff\""
+ : "")
+ + "><td style=\"border-right: 1px solid gray\">&nbsp;"
+ + String.valueOf(row) + "&nbsp;</td><td>"
+ + head + "<nobr>" + line + "</nobr>" + tail
+ + "</td></tr>\n");
lastLineWasEmpty = isEmpty;
@@ -567,8 +537,9 @@ public class UIDLTransformer {
return sb.toString();
}
- /**
- * Gets the formated error report on UIDL.
+ /**
+ * Gets the formated error report on UIDL.
+ *
* @return the formatted error report.
*/
public String getUIDLErrorReport() {
@@ -588,14 +559,14 @@ public class UIDLTransformer {
sb.append(toString());
// Appends UIDL
- sb.append(
- "<table width=\"100%\" style=\"border-left: 1px solid black; "
- + "border-right: 1px solid black; border-bottom: "
- + "1px solid black; border-top: 1px solid black\""
- + " cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>"
- + "<th bgcolor=\"#ddddff\" colspan=\"2\">"
- + "<font size=\"+2\">UIDL</font><br />"
- + "</th></tr>\n");
+ sb
+ .append("<table width=\"100%\" style=\"border-left: 1px solid black; "
+ + "border-right: 1px solid black; border-bottom: "
+ + "1px solid black; border-top: 1px solid black\""
+ + " cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>"
+ + "<th bgcolor=\"#ddddff\" colspan=\"2\">"
+ + "<font size=\"+2\">UIDL</font><br />"
+ + "</th></tr>\n");
while ((index = uidl.indexOf('\n', prev)) >= 0) {
String line = uidl.substring(prev, index);
@@ -605,20 +576,18 @@ public class UIDLTransformer {
line = WebPaintTarget.escapeXML(line);
boolean isEmpty = (line.length() == 0 || line.equals("\r"));
- // Highlight source
+ // Highlight source
// line = xmlHighlight(line);
if (!(isEmpty && lastLineWasEmpty))
- sb.append(
- "<tr"
- + ((row % 10) > 4 ? " bgcolor=\"#eeeeff\"" : "")
- + "><td style=\"border-right: 1px solid gray\">&nbsp;"
- + String.valueOf(row)
- + "&nbsp;</td><td>"
- + "<nobr>"
- + line
- + "</nobr>"
- + "</td></tr>\n");
+ sb
+ .append("<tr"
+ + ((row % 10) > 4 ? " bgcolor=\"#eeeeff\""
+ : "")
+ + "><td style=\"border-right: 1px solid gray\">&nbsp;"
+ + String.valueOf(row) + "&nbsp;</td><td>"
+ + "<nobr>" + line + "</nobr>"
+ + "</td></tr>\n");
lastLineWasEmpty = isEmpty;
}
@@ -628,19 +597,18 @@ public class UIDLTransformer {
return sb.toString();
}
- /**
+ /**
* Highlights the XML source.
+ *
* @param xmlSnippet
- * @return
+ * @return
*/
private String xmlHighlight(String xmlSnippet) {
String res = xmlSnippet;
- // Code beautification : Comment lines
- DebugWindow.replaceAll(
- res,
- "&lt;!--",
- "<SPAN STYLE=\"color: #00dd00\">&lt;!--");
+ // Code beautification : Comment lines
+ DebugWindow.replaceAll(res, "&lt;!--",
+ "<SPAN STYLE=\"color: #00dd00\">&lt;!--");
res = DebugWindow.replaceAll(res, "--&gt;", "--&gt;</SPAN>");
// nbsp instead of blanks
@@ -654,9 +622,10 @@ public class UIDLTransformer {
return res;
}
- /**
+ /**
* Gets the first fatal error.
- * @return the fatal error.
+ *
+ * @return the fatal error.
*/
public Throwable getFirstFatalError() {
return (Throwable) fatals.iterator().next();
@@ -667,26 +636,21 @@ public class UIDLTransformer {
*/
public void error(SAXParseException exception) throws SAXException {
errors.addLast(exception);
- rowToErrorMap.put(
- new Integer(exception.getLineNumber()),
- exception);
- errorToRowMap.put(
- exception,
- new Integer(exception.getLineNumber()));
+ rowToErrorMap
+ .put(new Integer(exception.getLineNumber()), exception);
+ errorToRowMap
+ .put(exception, new Integer(exception.getLineNumber()));
}
/**
* @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
*/
- public void fatalError(SAXParseException exception)
- throws SAXException {
+ public void fatalError(SAXParseException exception) throws SAXException {
fatals.addLast(exception);
- rowToErrorMap.put(
- new Integer(exception.getLineNumber()),
- exception);
- errorToRowMap.put(
- exception,
- new Integer(exception.getLineNumber()));
+ rowToErrorMap
+ .put(new Integer(exception.getLineNumber()), exception);
+ errorToRowMap
+ .put(exception, new Integer(exception.getLineNumber()));
}
/**
@@ -694,12 +658,10 @@ public class UIDLTransformer {
*/
public void warning(SAXParseException exception) throws SAXException {
warnings.addLast(exception);
- rowToErrorMap.put(
- new Integer(exception.getLineNumber()),
- exception);
- errorToRowMap.put(
- exception,
- new Integer(exception.getLineNumber()));
+ rowToErrorMap
+ .put(new Integer(exception.getLineNumber()), exception);
+ errorToRowMap
+ .put(exception, new Integer(exception.getLineNumber()));
}
}
diff --git a/src/com/itmill/toolkit/terminal/web/UIDLTransformerException.java b/src/com/itmill/toolkit/terminal/web/UIDLTransformerException.java
index a974c2f987..2aa9c8b535 100644
--- a/src/com/itmill/toolkit/terminal/web/UIDLTransformerException.java
+++ b/src/com/itmill/toolkit/terminal/web/UIDLTransformerException.java
@@ -1,46 +1,49 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
-/**
+/**
* Exception in the transform process.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class UIDLTransformerException extends java.lang.Exception {
private static final long serialVersionUID = 5648982356058143223L;
+
private String HTMLDescription = null;
+
private Throwable transformException = null;
-
+
/**
* Creates a new instance of UIDLTransformerException without detail
* message.
@@ -51,26 +54,32 @@ public class UIDLTransformerException extends java.lang.Exception {
/**
* Constructs an instance of UIDLTransformerException with the specified
* detail message.
- * @param msg the description of exception that occurred.
- * @param te the Transform exception that occurred.
- * @param desc the detailed description.
+ *
+ * @param msg
+ * the description of exception that occurred.
+ * @param te
+ * the Transform exception that occurred.
+ * @param desc
+ * the detailed description.
*/
public UIDLTransformerException(String msg, Throwable te, String desc) {
super(msg);
this.transformException = te;
this.HTMLDescription = desc;
}
-
- /**
+
+ /**
* Returns the detailed description.
+ *
* @return the Detailed description of exception.
*/
public String getHTMLDescription() {
return HTMLDescription;
}
- /**
+ /**
* Returns the nested transform exception that occurred.
+ *
* @return the transform exception
*/
public Throwable getTransformException() {
diff --git a/src/com/itmill/toolkit/terminal/web/UIDLTransformerFactory.java b/src/com/itmill/toolkit/terminal/web/UIDLTransformerFactory.java
index 6bf66dd942..abaecd7f8a 100644
--- a/src/com/itmill/toolkit/terminal/web/UIDLTransformerFactory.java
+++ b/src/com/itmill/toolkit/terminal/web/UIDLTransformerFactory.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -35,72 +35,78 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Iterator;
-/**
- * Class implementing the UIDLTransformer Factory.
- * The factory creates and maintains a pool of transformers that are used
- * for transforming UIDL to HTML.
+/**
+ * Class implementing the UIDLTransformer Factory. The factory creates and
+ * maintains a pool of transformers that are used for transforming UIDL to HTML.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class UIDLTransformerFactory {
- /**
- * Time between repository modified queries.
+ /**
+ * Time between repository modified queries.
*/
private static final int CACHE_CHECK_INTERVAL_MILLIS = 5 * 1000;
- /**
+ /**
* The time transformers are cached by default.
*/
private static final long DEFAULT_TRANSFORMER_CACHETIME = 60 * 60 * 1000;
- /**
- * Maximum number of transformers in use.
+ /**
+ * Maximum number of transformers in use.
*/
private int maxConcurrentTransformers = 1;
- /**
- * Last time theme modification time was checked.
+ /**
+ * Last time theme modification time was checked.
*/
private long lastModificationCheckTime = 0;
- /**
- * Last time theme source was modified.
+ /**
+ * Last time theme source was modified.
*/
private long themeSourceModificationTime = 0;
- /**
- * How long to cache transformers.
+ /**
+ * How long to cache transformers.
*/
private long cacheTime = DEFAULT_TRANSFORMER_CACHETIME;
- /**
- * Spool manager thread.
+ /**
+ * Spool manager thread.
*/
private SpoolManager spoolManager;
private Map transformerSpool = new HashMap();
+
private ThemeSource themeSource;
+
private ApplicationServlet webAdapterServlet;
+
private int transformerCount = 0;
+
private int transformersInUse = 0;
- /**
- * Constructor for transformer factory.
- * Method UIDLTransformerFactory.
- * @param themeSource the Theme source to be used for themes.
- * @param webAdapterServlet the Adapter servlet.
- * @param maxConcurrentTransformers the Maximum number of concurrent themes in use.
- * @param cacheTime the Time to cache the transformers.
+ /**
+ * Constructor for transformer factory. Method UIDLTransformerFactory.
+ *
+ * @param themeSource
+ * the Theme source to be used for themes.
+ * @param webAdapterServlet
+ * the Adapter servlet.
+ * @param maxConcurrentTransformers
+ * the Maximum number of concurrent themes in use.
+ * @param cacheTime
+ * the Time to cache the transformers.
*/
- public UIDLTransformerFactory(
- ThemeSource themeSource,
- ApplicationServlet webAdapterServlet,
- int maxConcurrentTransformers,
- long cacheTime) {
+ public UIDLTransformerFactory(ThemeSource themeSource,
+ ApplicationServlet webAdapterServlet,
+ int maxConcurrentTransformers, long cacheTime) {
this.webAdapterServlet = webAdapterServlet;
if (themeSource == null)
throw new NullPointerException();
@@ -111,20 +117,22 @@ public class UIDLTransformerFactory {
this.cacheTime = cacheTime;
this.spoolManager = new SpoolManager(this.cacheTime);
this.spoolManager.setDaemon(true);
- //Enable manager only if time > 0
+ // Enable manager only if time > 0
if (this.cacheTime > 0)
this.spoolManager.start();
}
- /**
+ /**
* Gets the new transformer of the specified type.
- * @param type the Type of the requested transformer.
+ *
+ * @param type
+ * the Type of the requested transformer.
* @return Created new transformer.
- * @throws UIDLTransformerException
- * if the transform can not be created.
+ * @throws UIDLTransformerException
+ * if the transform can not be created.
*/
public synchronized UIDLTransformer getTransformer(UIDLTransformerType type)
- throws UIDLTransformerException {
+ throws UIDLTransformerException {
while (transformersInUse >= maxConcurrentTransformers) {
try {
@@ -135,26 +143,23 @@ public class UIDLTransformerFactory {
}
// Gets the list of transformers for this type
- TransformerList list =
- (TransformerList) this.transformerSpool.get(type);
+ TransformerList list = (TransformerList) this.transformerSpool
+ .get(type);
// Checks the modification time between fixed intervals
long now = System.currentTimeMillis();
- if (now - CACHE_CHECK_INTERVAL_MILLIS
- > this.lastModificationCheckTime) {
+ if (now - CACHE_CHECK_INTERVAL_MILLIS > this.lastModificationCheckTime) {
this.lastModificationCheckTime = now;
- // Checks if the theme source has been modified and flush
- // list if necessary
+ // Checks if the theme source has been modified and flush
+ // list if necessary
long lastmod = this.themeSource.getModificationTime();
if (list != null && this.themeSourceModificationTime < lastmod) {
if (webAdapterServlet.isDebugMode(null)) {
- Log.info(
- "Theme source modified since "
+ Log.info("Theme source modified since "
+ new Date(this.themeSourceModificationTime)
- .toString()
- + ". Reloading...");
+ .toString() + ". Reloading...");
}
// Force refresh by removing from spool
this.transformerSpool.clear();
@@ -174,15 +179,13 @@ public class UIDLTransformerFactory {
}
} else {
- // Creates the new transformer and return it. Transformers are added to
+ // Creates the new transformer and return it. Transformers are added
+ // to
// spool when they are released.
t = new UIDLTransformer(type, themeSource, webAdapterServlet);
transformerCount++;
if (webAdapterServlet.isDebugMode(null)) {
- Log.info(
- "Created new transformer ("
- + transformerCount
- + "):"
+ Log.info("Created new transformer (" + transformerCount + "):"
+ type);
}
@@ -200,10 +203,12 @@ public class UIDLTransformerFactory {
return t;
}
- /**
- * Recycle a used transformer back to spool.
- * One must guarantee not to use the transformer after it have been released.
- * @param transformer the UIDLTransformer to be recycled.
+ /**
+ * Recycle a used transformer back to spool. One must guarantee not to use
+ * the transformer after it have been released.
+ *
+ * @param transformer
+ * the UIDLTransformer to be recycled.
*/
public synchronized void releaseTransformer(UIDLTransformer transformer) {
@@ -212,28 +217,20 @@ public class UIDLTransformerFactory {
transformer.reset();
// Recycle the transformer back to spool
- TransformerList list =
- (TransformerList) this.transformerSpool.get(
- transformer.getTransformerType());
+ TransformerList list = (TransformerList) this.transformerSpool
+ .get(transformer.getTransformerType());
if (list != null) {
list.add(transformer);
if (webAdapterServlet.isDebugMode(null)) {
- Log.info(
- "Released transformer: "
- + transformer.getTransformerType()
- + "(In use: "
- + transformersInUse
- + ",Spooled: "
- + list.size()
+ Log.info("Released transformer: "
+ + transformer.getTransformerType() + "(In use: "
+ + transformersInUse + ",Spooled: " + list.size()
+ ")");
}
list.lastUsed = System.currentTimeMillis();
} else {
- Log.info(
- "Tried to release non-existing transformer. Ignoring."
- + " (Type:"
- + transformer.getTransformerType()
- + ")");
+ Log.info("Tried to release non-existing transformer. Ignoring."
+ + " (Type:" + transformer.getTransformerType() + ")");
}
} finally {
if (transformersInUse > 0)
@@ -241,71 +238,69 @@ public class UIDLTransformerFactory {
notifyAll();
}
}
-
-/**
- *
- *
- *
- */
+
+ /**
+ *
+ *
+ *
+ */
private class TransformerList {
private LinkedList list = new LinkedList();
+
private long lastUsed = 0;
-
-/**
- *
- * @param transformer
- */
+
+ /**
+ *
+ * @param transformer
+ */
public void add(UIDLTransformer transformer) {
list.add(transformer);
}
-
-/**
- *
- * @return
- */
+
+ /**
+ *
+ * @return
+ */
public UIDLTransformer removeFirst() {
return (UIDLTransformer) ((LinkedList) list).removeFirst();
}
-
-/**
- *
- * @return
- */
+
+ /**
+ *
+ * @return
+ */
public boolean isEmpty() {
return list.isEmpty();
}
-
-/**
- *
- * @return
- */
+
+ /**
+ *
+ * @return
+ */
public int size() {
return list.size();
}
}
-
-/**
- *
- *
- */
+
+ /**
+ *
+ *
+ */
private synchronized void removeUnusedTransformers() {
long currentTime = System.currentTimeMillis();
HashSet keys = new HashSet();
keys.addAll(this.transformerSpool.keySet());
for (Iterator i = keys.iterator(); i.hasNext();) {
UIDLTransformerType type = (UIDLTransformerType) i.next();
- TransformerList l =
- (TransformerList) this.transformerSpool.get(type);
+ TransformerList l = (TransformerList) this.transformerSpool
+ .get(type);
if (l != null) {
if (l.lastUsed > 0
- && l.lastUsed < (currentTime - this.cacheTime)) {
+ && l.lastUsed < (currentTime - this.cacheTime)) {
if (webAdapterServlet.isDebugMode(null)) {
- Log.info(
- "Removed transformer: "
- + type
- + " Not used since "
- + new Date(l.lastUsed));
+ Log.info("Removed transformer: " + type
+ + " Not used since " + new Date(l.lastUsed));
}
this.transformerSpool.remove(type);
}
@@ -313,27 +308,29 @@ public class UIDLTransformerFactory {
}
}
- /**
+ /**
* Class for periodically remove unused transformers from memory.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
protected class SpoolManager extends Thread {
long refreshTime;
-
-/**
- *
- * @param refreshTime
- */
+
+ /**
+ *
+ * @param refreshTime
+ */
public SpoolManager(long refreshTime) {
super("UIDLTransformerFactory.SpoolManager");
this.refreshTime = refreshTime;
}
-
+
/**
- *
+ *
* @see java.lang.Thread#run()
*/
public void run() {
diff --git a/src/com/itmill/toolkit/terminal/web/UIDLTransformerType.java b/src/com/itmill/toolkit/terminal/web/UIDLTransformerType.java
index 501beca12f..33ef3762a4 100644
--- a/src/com/itmill/toolkit/terminal/web/UIDLTransformerType.java
+++ b/src/com/itmill/toolkit/terminal/web/UIDLTransformerType.java
@@ -1,83 +1,91 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
-/**
+/**
* Type of the transformer.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class UIDLTransformerType {
- /**
- * Holds the value of property webBrowserType.
+ /**
+ * Holds the value of property webBrowserType.
*/
private WebBrowser webBrowser;
- /**
- * Holds the value of property theme.
+ /**
+ * Holds the value of property theme.
*/
private Theme theme;
- /**
+ /**
* Creates a new instance of TransformerType.
- * @param webBrowserType the web browser type.
- * @param theme the property theme.
+ *
+ * @param webBrowserType
+ * the web browser type.
+ * @param theme
+ * the property theme.
*/
public UIDLTransformerType(WebBrowser webBrowserType, Theme theme) {
if (webBrowserType == null || theme == null)
- throw new IllegalArgumentException("WebBrowserType and Theme must be non-null values");
+ throw new IllegalArgumentException(
+ "WebBrowserType and Theme must be non-null values");
this.webBrowser = webBrowserType;
this.theme = theme;
}
- /**
+ /**
* Returns the hash code for this string.
- * @return the hash code value.
+ *
+ * @return the hash code value.
*/
public int hashCode() {
return this.toString().hashCode();
}
- /**
+ /**
* Gets the web browser type used in the UIDLTransformer of this type.
+ *
* @return the Web browser type used.
*/
public WebBrowser getWebBrowser() {
return this.webBrowser;
}
- /**
+ /**
* Gets the theme used in the UIDLTransformer of this type.
+ *
* @return the Theme used.
*/
public Theme getTheme() {
@@ -86,6 +94,7 @@ public class UIDLTransformerType {
/**
* Two types are equal, if their properties are equal.
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
@@ -99,16 +108,13 @@ public class UIDLTransformerType {
/**
* Textual representation of the UIDLTransformer type.
+ *
* @see java.lang.Object#toString()
*/
public String toString() {
- return " theme='"
- + theme.getName()
- + "' js="
- + webBrowser.getJavaScriptVersion()
- + "' markup='"
- + webBrowser.getMarkupVersion()
- + "'";
+ return " theme='" + theme.getName() + "' js="
+ + webBrowser.getJavaScriptVersion() + "' markup='"
+ + webBrowser.getMarkupVersion() + "'";
}
}
diff --git a/src/com/itmill/toolkit/terminal/web/WebApplicationContext.java b/src/com/itmill/toolkit/terminal/web/WebApplicationContext.java
index 0537cedcdb..09a1279995 100644
--- a/src/com/itmill/toolkit/terminal/web/WebApplicationContext.java
+++ b/src/com/itmill/toolkit/terminal/web/WebApplicationContext.java
@@ -61,9 +61,11 @@ public class WebApplicationContext implements ApplicationContext {
private WeakHashMap formActions = new WeakHashMap();
- /**
+ /**
* Creates a new Web Application Context.
- * @param session the HTTP session.
+ *
+ * @param session
+ * the HTTP session.
*/
WebApplicationContext(HttpSession session) {
this.session = session;
@@ -73,10 +75,11 @@ public class WebApplicationContext implements ApplicationContext {
* Gets the form action for given window.
* <p>
* By default, this action is "", which preserves the current url. Commonly
- * this is wanted to be set to <code>application.getUrl.toString</code>
- * or <code>window.getUrl.toString</code> in order to clean any local
- * links or parameters set from the action.
+ * this is wanted to be set to <code>application.getUrl.toString</code> or
+ * <code>window.getUrl.toString</code> in order to clean any local links
+ * or parameters set from the action.
* </p>
+ *
* @param window
* the Window for which the action is queried.
* @return the Action to be set into Form action attribute.
@@ -90,10 +93,11 @@ public class WebApplicationContext implements ApplicationContext {
* Sets the form action for given window.
* <p>
* By default, this action is "", which preserves the current url. Commonly
- * this is wanted to be set to <code>application.getUrl.toString</code>
- * or <code>window.getUrl.toString</code> in order to clean any local
- * links or parameters set from the action.
+ * this is wanted to be set to <code>application.getUrl.toString</code> or
+ * <code>window.getUrl.toString</code> in order to clean any local links
+ * or parameters set from the action.
* </p>
+ *
* @param window
* the Window for which the action is set.
* @param action
@@ -108,6 +112,7 @@ public class WebApplicationContext implements ApplicationContext {
/**
* Gets the application context base directory.
+ *
* @see com.itmill.toolkit.service.ApplicationContext#getBaseDirectory()
*/
public File getBaseDirectory() {
@@ -129,6 +134,7 @@ public class WebApplicationContext implements ApplicationContext {
/**
* Gets the applications in this context.
+ *
* @see com.itmill.toolkit.service.ApplicationContext#getApplications()
*/
public Collection getApplications() {
@@ -142,7 +148,9 @@ public class WebApplicationContext implements ApplicationContext {
/**
* Gets the application context for HttpSession.
- * @param session the HTTP session.
+ *
+ * @param session
+ * the HTTP session.
* @return the application context for HttpSession.
*/
static public WebApplicationContext getApplicationContext(
@@ -151,9 +159,12 @@ public class WebApplicationContext implements ApplicationContext {
}
/**
- * Returns <code>true</code> if and only if the argument is not <code>null</code> and is a
- * Boolean object that represents the same boolean value as this object.
- * @param obj the object to compare with.
+ * Returns <code>true</code> if and only if the argument is not
+ * <code>null</code> and is a Boolean object that represents the same
+ * boolean value as this object.
+ *
+ * @param obj
+ * the object to compare with.
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
@@ -162,6 +173,7 @@ public class WebApplicationContext implements ApplicationContext {
/**
* Returns the hash code value .
+ *
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
@@ -170,6 +182,7 @@ public class WebApplicationContext implements ApplicationContext {
/**
* Adds the transaction listener to this context.
+ *
* @see com.itmill.toolkit.service.ApplicationContext#addTransactionListener(com.itmill.toolkit.service.ApplicationContext.TransactionListener)
*/
public void addTransactionListener(TransactionListener listener) {
@@ -180,6 +193,7 @@ public class WebApplicationContext implements ApplicationContext {
/**
* Removes the transaction listener from this context.
+ *
* @see com.itmill.toolkit.service.ApplicationContext#removeTransactionListener(com.itmill.toolkit.service.ApplicationContext.TransactionListener)
*/
public void removeTransactionListener(TransactionListener listener) {
@@ -188,10 +202,12 @@ public class WebApplicationContext implements ApplicationContext {
}
- /**
+ /**
* Notifies the transaction start.
- * @param application
- * @param request the HTTP request.
+ *
+ * @param application
+ * @param request
+ * the HTTP request.
*/
protected void startTransaction(Application application,
HttpServletRequest request) {
@@ -203,10 +219,12 @@ public class WebApplicationContext implements ApplicationContext {
}
}
- /**
+ /**
* Notifies the transaction end.
- * @param application
- * @param request the HTTP request.
+ *
+ * @param application
+ * @param request
+ * the HTTP request.
*/
protected void endTransaction(Application application,
HttpServletRequest request) {
diff --git a/src/com/itmill/toolkit/terminal/web/WebBrowser.java b/src/com/itmill/toolkit/terminal/web/WebBrowser.java
index 81b4f97b03..93515291d2 100644
--- a/src/com/itmill/toolkit/terminal/web/WebBrowser.java
+++ b/src/com/itmill/toolkit/terminal/web/WebBrowser.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -35,80 +35,81 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
-/**
+/**
* Web browser terminal type.
- *
+ *
* This class implements web browser properties, which declare the features of
* the web browser.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class WebBrowser implements Terminal {
private static WebBrowser DEFAULT = new WebBrowser();
- /**
- * Content type.
+ /**
+ * Content type.
*/
private String contentType = "text/html; charset=utf-8";
- /**
- * Holds the collection of accepted locales.
+ /**
+ * Holds the collection of accepted locales.
*/
private Collection locales = new ArrayList();
- /**
- * Holds value of property browserApplication.
+ /**
+ * Holds value of property browserApplication.
*/
private String browserApplication = null;
- /**
- * Should the client side checkking be done.
+ /**
+ * Should the client side checkking be done.
*/
private boolean performClientCheck = true;
- /**
- * Holds value for property isClientSideChecked.
+ /**
+ * Holds value for property isClientSideChecked.
*/
private boolean clientSideChecked = false;
- /**
- * Holds value of property javaScriptVersion.
+ /**
+ * Holds value of property javaScriptVersion.
*/
private JavaScriptVersion javaScriptVersion = JAVASCRIPT_UNCHECKED;
- /**
- * Holds value of property javaEnabled.
+ /**
+ * Holds value of property javaEnabled.
*/
private boolean javaEnabled = false;
- /**
- * Holds value of property frameSupport.
+ /**
+ * Holds value of property frameSupport.
*/
private boolean frameSupport = false;
- /**
- * Holds value of property markup version.
+ /**
+ * Holds value of property markup version.
*/
private MarkupVersion markupVersion = MARKUP_HTML_3_2;
- /**
- * Pixel width of the terminal screen.
+ /**
+ * Pixel width of the terminal screen.
*/
private int screenWidth = -1;
- /**
- * Pixel height of the terminal screen.
+ /**
+ * Pixel height of the terminal screen.
*/
private int screenHeight = -1;
-
+
private RenderingMode renderingMode = RENDERING_MODE_UNDEFINED;
- /**
- * Constuctor with some autorecognition capabilities
- * Retrieves all capability information reported in http request headers:
+ /**
+ * Constuctor with some autorecognition capabilities Retrieves all
+ * capability information reported in http request headers:
* <ul>
* <li>User web browser (User-Agent)</li>
* <li>Supported locale(s)</li>
@@ -116,23 +117,23 @@ public class WebBrowser implements Terminal {
*/
/**
- * Constructor WebBrowserType.
- * Creates a default WebBrowserType instance.
+ * Constructor WebBrowserType. Creates a default WebBrowserType instance.
*/
public WebBrowser() {
}
- /**
+ /**
* Gets the name of the default theme.
+ *
* @return the Name of the terminal window.
*/
public String getDefaultTheme() {
return ApplicationServlet.DEFAULT_THEME;
}
- /**
- * Gets the name and version of the web browser application.
- * This is the version string reported by the web-browser in http headers.
+ /**
+ * Gets the name and version of the web browser application. This is the
+ * version string reported by the web-browser in http headers.
*
* @return the Web browser application.
*/
@@ -140,59 +141,67 @@ public class WebBrowser implements Terminal {
return this.browserApplication;
}
- /**
+ /**
* Gets the version of the supported Java Script by the browser.
- *
+ *
* <code>Null</code> if the Java Script is not supported.
+ *
* @return the Version of the supported Java Script.
*/
public JavaScriptVersion getJavaScriptVersion() {
return this.javaScriptVersion;
}
- /**
+ /**
* Does the browser support frames ?
- * @return <code>true</code> if the browser supports frames, otherwise <code>false</code>.
+ *
+ * @return <code>true</code> if the browser supports frames, otherwise
+ * <code>false</code>.
*/
public boolean isFrameSupport() {
return this.frameSupport;
}
- /**
+ /**
* Sets the browser frame support.
- * @param frameSupport True if the browser supports frames, False if not.
+ *
+ * @param frameSupport
+ * True if the browser supports frames, False if not.
*/
public void setFrameSupport(boolean frameSupport) {
this.frameSupport = frameSupport;
}
- /**
+ /**
* Gets the supported markup language.
- *
+ *
* @return the Supported markup language
*/
public MarkupVersion getMarkupVersion() {
return this.markupVersion;
}
- /**
+ /**
* Gets the height of the terminal window in pixels.
+ *
* @return the Height of the terminal window.
*/
public int getScreenHeight() {
return this.screenHeight;
}
- /**
+ /**
* Gets the width of the terminal window in pixels.
+ *
* @return the Width of the terminal window.
*/
public int getScreenWidth() {
return this.screenWidth;
}
- /**
+ /**
* Gets the default locale requested by the browser.
+ *
* @return the Default locale.
*/
public Locale getDefaultLocale() {
@@ -203,6 +212,7 @@ public class WebBrowser implements Terminal {
/**
* Hash code composed of the properties of the web browser type.
+ *
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
@@ -211,6 +221,7 @@ public class WebBrowser implements Terminal {
/**
* Tests the equality of the properties for two web browser types.
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
@@ -226,81 +237,67 @@ public class WebBrowser implements Terminal {
public String toString() {
String localeString = "[";
- for (Iterator i = this.locales.iterator();
- i.hasNext();
- localeString += ",") {
+ for (Iterator i = this.locales.iterator(); i.hasNext(); localeString += ",") {
localeString += ((Locale) i.next()).toString();
}
localeString += "]";
// Returns catenation of the properties
- return "Browser:"
- + this.browserApplication
- + ", "
- + "Locales:"
- + localeString
- + ", "
- + "Frames:"
- + this.frameSupport
- + ", "
- + "JavaScript:"
- + this.javaScriptVersion
- + ", "
- + "Java: "
- + this.javaEnabled
- + ", "
- + "Markup:"
- + this.markupVersion
- + ", "
- + "Height:"
- + this.screenHeight
- + ", "
- + "Width:"
- + this.screenWidth
- + ", ClientCheck:"
- + this.performClientCheck
- + ", ClientCheckDone:"
- + this.clientSideChecked;
- }
-
- /**
+ return "Browser:" + this.browserApplication + ", " + "Locales:"
+ + localeString + ", " + "Frames:" + this.frameSupport + ", "
+ + "JavaScript:" + this.javaScriptVersion + ", " + "Java: "
+ + this.javaEnabled + ", " + "Markup:" + this.markupVersion
+ + ", " + "Height:" + this.screenHeight + ", " + "Width:"
+ + this.screenWidth + ", ClientCheck:" + this.performClientCheck
+ + ", ClientCheckDone:" + this.clientSideChecked;
+ }
+
+ /**
* Gets the preferred content type.
- * @return the content type.
+ *
+ * @return the content type.
*/
public String getContentType() {
return contentType;
}
- /**
+ /**
* Checks if this type supports also given browser.
- * @param browser the browser type.
+ *
+ * @param browser
+ * the browser type.
* @return true if this type matches the given browser.
*/
public boolean supports(String browser) {
return this.getBrowserApplication().indexOf(browser) >= 0;
}
- /**
+ /**
* Checks if this type supports given markup language version.
- * @param html the markup language version.
+ *
+ * @param html
+ * the markup language version.
* @return <code>true</ocde> if this type supports the given markup version,otherwise <code>false</code>.
*/
public boolean supports(MarkupVersion html) {
return this.getMarkupVersion().supports(html);
}
- /**
+ /**
* Checks if this type supports given javascript version.
- * @param js the javascript version to check for.
+ *
+ * @param js
+ * the javascript version to check for.
* @return true if this type supports the given javascript version.
*/
public boolean supports(JavaScriptVersion js) {
return this.getJavaScriptVersion().supports(js);
}
- /**
+ /**
* Parses HTML version from string.
- * @param html
+ *
+ * @param html
* @return HTMLVersion instance.
*/
private MarkupVersion doParseHTMLVersion(String html) {
@@ -311,24 +308,25 @@ public class WebBrowser implements Terminal {
return MARKUP_UNKNOWN;
}
- /**
+ /**
* Parses JavaScript version from string.
- * @param js the javascript version to check for.
+ *
+ * @param js
+ * the javascript version to check for.
* @return HTMLVersion instance.
*/
private JavaScriptVersion doParseJavaScriptVersion(String js) {
for (int i = 0; i < JAVASCRIPT_VERSIONS.length; i++) {
- if (JAVASCRIPT_VERSIONS[i]
- .name
- .toLowerCase()
- .startsWith(js.toLowerCase()))
+ if (JAVASCRIPT_VERSIONS[i].name.toLowerCase().startsWith(
+ js.toLowerCase()))
return JAVASCRIPT_VERSIONS[i];
}
return JAVASCRIPT_NONE;
}
- /**
+ /**
* Parses HTML version from string.
+ *
* @param html
* @return the HTMLVersion instance.
*/
@@ -336,94 +334,107 @@ public class WebBrowser implements Terminal {
return DEFAULT.doParseHTMLVersion(html);
}
- /**
+ /**
* Parse JavaScript version from string.
- * @param js the javascript version to check for.
+ *
+ * @param js
+ * the javascript version to check for.
* @return the HTMLVersion instance.
*/
public static JavaScriptVersion parseJavaScriptVersion(String js) {
return DEFAULT.doParseJavaScriptVersion(js);
}
- /**
- * Gets the client side cheked property.
- * Certain terminal features can only be detected at client side. This
- * property indicates if the client side detections have been performed
- * for this type.
- * @return <code>true</code> if client has sent information about its properties. Default is <code>false</code>.
+ /**
+ * Gets the client side cheked property. Certain terminal features can only
+ * be detected at client side. This property indicates if the client side
+ * detections have been performed for this type.
+ *
+ * @return <code>true</code> if client has sent information about its
+ * properties. Default is <code>false</code>.
*/
public boolean isClientSideChecked() {
return this.clientSideChecked;
}
- /**
- * Sets the client side checked property.
- * Certain terminal features can only be detected at client side. This
- * property indicates if the client side detections have been performed
- * for this type.
- * @param value true if client has sent information about its properties, false otherweise.
+ /**
+ * Sets the client side checked property. Certain terminal features can only
+ * be detected at client side. This property indicates if the client side
+ * detections have been performed for this type.
+ *
+ * @param value
+ * true if client has sent information about its properties,
+ * false otherweise.
*/
public void setClientSideChecked(boolean value) {
this.clientSideChecked = value;
}
- /**
- * Should the client features be checked using remote scripts.
- * Should the client side terminal feature check be performed.
- * @return <code>true</code> if client side checking should be performed
- * for this terminal type. Default is <code>false</code>.
+ /**
+ * Should the client features be checked using remote scripts. Should the
+ * client side terminal feature check be performed.
+ *
+ * @return <code>true</code> if client side checking should be performed
+ * for this terminal type. Default is <code>false</code>.
*/
public boolean performClientCheck() {
return this.performClientCheck;
}
- /**
- * Should the client features be checked using remote scripts.
+ /**
+ * Should the client features be checked using remote scripts.
+ *
* @param value
* @return <code>true</code> if client side checking should be performed
- * for this terminal type. Default <code>false</code>.
+ * for this terminal type. Default <code>false</code>.
*/
public void performClientCheck(boolean value) {
this.performClientCheck = value;
}
- /**
+ /**
* Checks if web browser supports Java.
+ *
* @return <code>true<code> if the browser supports java otherwise <code>false</code>.
*/
public boolean isJavaEnabled() {
return javaEnabled;
}
- /**
+ /**
* Returns the locales supported by the web browser.
+ *
* @return the Collection.
*/
public Collection getLocales() {
return locales;
}
- /**
- * Sets the browser application.
- * This corresponds to User-Agent HTTP header.
- * @param browserApplication the browserApplication to set.
+ /**
+ * Sets the browser application. This corresponds to User-Agent HTTP header.
+ *
+ * @param browserApplication
+ * the browserApplication to set.
*/
public void setBrowserApplication(String browserApplication) {
this.browserApplication = browserApplication;
}
- /**
- * Sets the default content type.
- * Default is <code>text/html</code>
- * @param contentType the contentType to set.
+ /**
+ * Sets the default content type. Default is <code>text/html</code>
+ *
+ * @param contentType
+ * the contentType to set.
*/
public void setContentType(String contentType) {
this.contentType = contentType;
}
- /**
+ /**
* Sets the java enabled property.
- * @param javaEnabled the javaEnabled to set.
+ *
+ * @param javaEnabled
+ * the javaEnabled to set.
*/
public void setJavaEnabled(boolean javaEnabled) {
this.javaEnabled = javaEnabled;
@@ -431,50 +442,63 @@ public class WebBrowser implements Terminal {
/**
* Sets the JavaScript version.
- * @param javaScriptVersion the JavaScript version to set.
+ *
+ * @param javaScriptVersion
+ * the JavaScript version to set.
*/
public void setJavaScriptVersion(JavaScriptVersion javaScriptVersion) {
this.javaScriptVersion = javaScriptVersion;
}
- /**
+ /**
* Sets the markup language version.
- * @param markupVersion the markup language version to set.
+ *
+ * @param markupVersion
+ * the markup language version to set.
*/
public void setMarkupVersion(MarkupVersion markupVersion) {
this.markupVersion = markupVersion;
}
- /**
+ /**
* Sets the screen height.
- * @param screenHeight the screen height to set in pixels.
+ *
+ * @param screenHeight
+ * the screen height to set in pixels.
*/
public void setScreenHeight(int screenHeight) {
this.screenHeight = screenHeight;
}
- /**
+ /**
* Sets the screen width.
- * @param screenWidth the screenWidth to set in pixels.
+ *
+ * @param screenWidth
+ * the screenWidth to set in pixels.
*/
public void setScreenWidth(int screenWidth) {
this.screenWidth = screenWidth;
}
/*
- * Consts defining the supported markup language versions
- * @author IT Mill Ltd.
+ * Consts defining the supported markup language versions @author IT Mill
+ * Ltd.
+ *
* @version @VERSION@
* @since 3.0
*/
public class MarkupVersion {
private String name;
+
private int order;
/**
- * Returns <code>true</code> if and only if the argument is not <code>null</code> and is a
- * Boolean object that represents the same boolean value as this object.
- * @param obj the object to compare with.
+ * Returns <code>true</code> if and only if the argument is not
+ * <code>null</code> and is a Boolean object that represents the same
+ * boolean value as this object.
+ *
+ * @param obj
+ * the object to compare with.
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object obj) {
@@ -489,21 +513,24 @@ public class WebBrowser implements Terminal {
public String toString() {
return name;
}
-
-/**
- *
- * @param name
- * @param order
- */
+
+ /**
+ *
+ * @param name
+ * @param order
+ */
private MarkupVersion(String name, int order) {
this.name = name;
this.order = order;
}
- /**
+ /**
* Checks the compability with other HTML version.
- * @param other the HTML version.
- * @return <code>true</code> if this is compatible with the other, otherwise <code>false</code>.
+ *
+ * @param other
+ * the HTML version.
+ * @return <code>true</code> if this is compatible with the other,
+ * otherwise <code>false</code>.
*/
public boolean supports(MarkupVersion other) {
return (this.order >= other.order);
@@ -511,44 +538,47 @@ public class WebBrowser implements Terminal {
}
- public static final MarkupVersion MARKUP_UNKNOWN =
- DEFAULT.new MarkupVersion("HTML unknown", 0);
- public static final MarkupVersion MARKUP_HTML_2_0 =
- DEFAULT.new MarkupVersion("HTML 2.0", 20);
- public static final MarkupVersion MARKUP_HTML_3_2 =
- DEFAULT.new MarkupVersion("HTML 3.2", 32);
- public static final MarkupVersion MARKUP_HTML_4_0 =
- DEFAULT.new MarkupVersion("HTML 4.0", 40);
- public static final MarkupVersion MARKUP_XHTML_1_0 =
- DEFAULT.new MarkupVersion("XHTML 1.0", 110);
- public static final MarkupVersion MARKUP_XHTML_2_0 =
- DEFAULT.new MarkupVersion("XHTML 2.0", 120);
- public static final MarkupVersion MARKUP_WML_1_0 =
- DEFAULT.new MarkupVersion("WML 1.0", 10);
- public static final MarkupVersion MARKUP_WML_1_1 =
- DEFAULT.new MarkupVersion("WML 1.1", 11);
- public static final MarkupVersion MARKUP_WML_1_2 =
- DEFAULT.new MarkupVersion("WML 1.2", 12);
-
- public static final MarkupVersion[] MARKUP_VERSIONS =
- new MarkupVersion[] {
- MARKUP_UNKNOWN,
- MARKUP_HTML_2_0,
- MARKUP_HTML_3_2,
- MARKUP_HTML_4_0,
- MARKUP_XHTML_1_0,
- MARKUP_XHTML_2_0,
- MARKUP_WML_1_0,
- MARKUP_WML_1_1,
+ public static final MarkupVersion MARKUP_UNKNOWN = DEFAULT.new MarkupVersion(
+ "HTML unknown", 0);
+
+ public static final MarkupVersion MARKUP_HTML_2_0 = DEFAULT.new MarkupVersion(
+ "HTML 2.0", 20);
+
+ public static final MarkupVersion MARKUP_HTML_3_2 = DEFAULT.new MarkupVersion(
+ "HTML 3.2", 32);
+
+ public static final MarkupVersion MARKUP_HTML_4_0 = DEFAULT.new MarkupVersion(
+ "HTML 4.0", 40);
+
+ public static final MarkupVersion MARKUP_XHTML_1_0 = DEFAULT.new MarkupVersion(
+ "XHTML 1.0", 110);
+
+ public static final MarkupVersion MARKUP_XHTML_2_0 = DEFAULT.new MarkupVersion(
+ "XHTML 2.0", 120);
+
+ public static final MarkupVersion MARKUP_WML_1_0 = DEFAULT.new MarkupVersion(
+ "WML 1.0", 10);
+
+ public static final MarkupVersion MARKUP_WML_1_1 = DEFAULT.new MarkupVersion(
+ "WML 1.1", 11);
+
+ public static final MarkupVersion MARKUP_WML_1_2 = DEFAULT.new MarkupVersion(
+ "WML 1.2", 12);
+
+ public static final MarkupVersion[] MARKUP_VERSIONS = new MarkupVersion[] {
+ MARKUP_UNKNOWN, MARKUP_HTML_2_0, MARKUP_HTML_3_2, MARKUP_HTML_4_0,
+ MARKUP_XHTML_1_0, MARKUP_XHTML_2_0, MARKUP_WML_1_0, MARKUP_WML_1_1,
MARKUP_WML_1_2 };
+
/*
- * Consts defining the supported JavaScript versions
- * @author IT Mill Ltd.
+ * Consts defining the supported JavaScript versions @author IT Mill Ltd.
+ *
* @version @VERSION@
* @since 3.0
*/
public class JavaScriptVersion {
private String name;
+
private int order;
/**
@@ -566,23 +596,25 @@ public class WebBrowser implements Terminal {
public String toString() {
return name;
}
-
-/**
- *
- * @param name
- * @param order
- */
+
+ /**
+ *
+ * @param name
+ * @param order
+ */
private JavaScriptVersion(String name, int order) {
this.name = name;
this.order = order;
}
- /**
- * Checks the compability with other JavaScript version.
- * Use this like:
+ /**
+ * Checks the compability with other JavaScript version. Use this like:
* <code>boolean isEcma = someVersion.supports(ECMA_262);</code>
- * @param other the java script version.
- * @return <code>true</code> if this supports the other, otherwise <code>false</code>.
+ *
+ * @param other
+ * the java script version.
+ * @return <code>true</code> if this supports the other, otherwise
+ * <code>false</code>.
*/
public boolean supports(JavaScriptVersion other) {
@@ -612,78 +644,85 @@ public class WebBrowser implements Terminal {
}
}
- public static final JavaScriptVersion JAVASCRIPT_UNCHECKED =
- DEFAULT.new JavaScriptVersion("JavaScript unchecked", -1);
- public static final JavaScriptVersion JAVASCRIPT_NONE =
- DEFAULT.new JavaScriptVersion("JavaScript none", -1);
- public static final JavaScriptVersion JAVASCRIPT_1_0 =
- DEFAULT.new JavaScriptVersion("JavaScript 1.0", 10);
- public static final JavaScriptVersion JAVASCRIPT_1_1 =
- DEFAULT.new JavaScriptVersion("JavaScript 1.1", 11);
- public static final JavaScriptVersion JAVASCRIPT_1_2 =
- DEFAULT.new JavaScriptVersion("JavaScript 1.2", 12);
- public static final JavaScriptVersion JAVASCRIPT_1_3 =
- DEFAULT.new JavaScriptVersion("JavaScript 1.3", 13);
- public static final JavaScriptVersion JAVASCRIPT_1_4 =
- DEFAULT.new JavaScriptVersion("JavaScript 1.4", 14);
- public static final JavaScriptVersion JAVASCRIPT_1_5 =
- DEFAULT.new JavaScriptVersion("JavaScript 1.5", 15);
- public static final JavaScriptVersion JSCRIPT_1_0 =
- DEFAULT.new JavaScriptVersion("JScript 1.0", 110);
- public static final JavaScriptVersion JSCRIPT_3_0 =
- DEFAULT.new JavaScriptVersion("JScript 3.0", 130);
- public static final JavaScriptVersion JSCRIPT_4_0 =
- DEFAULT.new JavaScriptVersion("JScript 4.0", 140);
- public static final JavaScriptVersion JSCRIPT_5_0 =
- DEFAULT.new JavaScriptVersion("JScript 5.0", 150);
- public static final JavaScriptVersion JSCRIPT_5_1 =
- DEFAULT.new JavaScriptVersion("JScript 5.1", 151);
- public static final JavaScriptVersion JSCRIPT_5_5 =
- DEFAULT.new JavaScriptVersion("JScript 5.5", 155);
- public static final JavaScriptVersion JSCRIPT_5_6 =
- DEFAULT.new JavaScriptVersion("JScript 5.6", 156);
- public static final JavaScriptVersion JSCRIPT_5_7 =
- DEFAULT.new JavaScriptVersion("JScript 5.7", 157);
- public static final JavaScriptVersion ECMA_262 =
- DEFAULT.new JavaScriptVersion("ECMA-262", 262);
-
- public static final JavaScriptVersion[] JAVASCRIPT_VERSIONS =
- new JavaScriptVersion[] {
- JAVASCRIPT_UNCHECKED,
- JAVASCRIPT_NONE,
- JAVASCRIPT_1_0,
- JAVASCRIPT_1_1,
- JAVASCRIPT_1_2,
- JAVASCRIPT_1_3,
- JAVASCRIPT_1_4,
- JAVASCRIPT_1_5,
- JSCRIPT_1_0,
- JSCRIPT_3_0,
- JSCRIPT_4_0,
- JSCRIPT_5_0,
- JSCRIPT_5_1,
- JSCRIPT_5_5,
- JSCRIPT_5_6,
- JSCRIPT_5_7,
- ECMA_262 };
-
+
+ public static final JavaScriptVersion JAVASCRIPT_UNCHECKED = DEFAULT.new JavaScriptVersion(
+ "JavaScript unchecked", -1);
+
+ public static final JavaScriptVersion JAVASCRIPT_NONE = DEFAULT.new JavaScriptVersion(
+ "JavaScript none", -1);
+
+ public static final JavaScriptVersion JAVASCRIPT_1_0 = DEFAULT.new JavaScriptVersion(
+ "JavaScript 1.0", 10);
+
+ public static final JavaScriptVersion JAVASCRIPT_1_1 = DEFAULT.new JavaScriptVersion(
+ "JavaScript 1.1", 11);
+
+ public static final JavaScriptVersion JAVASCRIPT_1_2 = DEFAULT.new JavaScriptVersion(
+ "JavaScript 1.2", 12);
+
+ public static final JavaScriptVersion JAVASCRIPT_1_3 = DEFAULT.new JavaScriptVersion(
+ "JavaScript 1.3", 13);
+
+ public static final JavaScriptVersion JAVASCRIPT_1_4 = DEFAULT.new JavaScriptVersion(
+ "JavaScript 1.4", 14);
+
+ public static final JavaScriptVersion JAVASCRIPT_1_5 = DEFAULT.new JavaScriptVersion(
+ "JavaScript 1.5", 15);
+
+ public static final JavaScriptVersion JSCRIPT_1_0 = DEFAULT.new JavaScriptVersion(
+ "JScript 1.0", 110);
+
+ public static final JavaScriptVersion JSCRIPT_3_0 = DEFAULT.new JavaScriptVersion(
+ "JScript 3.0", 130);
+
+ public static final JavaScriptVersion JSCRIPT_4_0 = DEFAULT.new JavaScriptVersion(
+ "JScript 4.0", 140);
+
+ public static final JavaScriptVersion JSCRIPT_5_0 = DEFAULT.new JavaScriptVersion(
+ "JScript 5.0", 150);
+
+ public static final JavaScriptVersion JSCRIPT_5_1 = DEFAULT.new JavaScriptVersion(
+ "JScript 5.1", 151);
+
+ public static final JavaScriptVersion JSCRIPT_5_5 = DEFAULT.new JavaScriptVersion(
+ "JScript 5.5", 155);
+
+ public static final JavaScriptVersion JSCRIPT_5_6 = DEFAULT.new JavaScriptVersion(
+ "JScript 5.6", 156);
+
+ public static final JavaScriptVersion JSCRIPT_5_7 = DEFAULT.new JavaScriptVersion(
+ "JScript 5.7", 157);
+
+ public static final JavaScriptVersion ECMA_262 = DEFAULT.new JavaScriptVersion(
+ "ECMA-262", 262);
+
+ public static final JavaScriptVersion[] JAVASCRIPT_VERSIONS = new JavaScriptVersion[] {
+ JAVASCRIPT_UNCHECKED, JAVASCRIPT_NONE, JAVASCRIPT_1_0,
+ JAVASCRIPT_1_1, JAVASCRIPT_1_2, JAVASCRIPT_1_3, JAVASCRIPT_1_4,
+ JAVASCRIPT_1_5, JSCRIPT_1_0, JSCRIPT_3_0, JSCRIPT_4_0, JSCRIPT_5_0,
+ JSCRIPT_5_1, JSCRIPT_5_5, JSCRIPT_5_6, JSCRIPT_5_7, ECMA_262 };
+
/*
- * Consts defining the rendering mode
- * @author IT Mill Ltd.
+ * Consts defining the rendering mode @author IT Mill Ltd.
+ *
* @version @VERSION@
* @since 4.0
*/
public class RenderingMode {
RenderingMode() {
-
+
}
}
+
public static final RenderingMode RENDERING_MODE_UNDEFINED = DEFAULT.new RenderingMode();
+
public static final RenderingMode RENDERING_MODE_HTML = DEFAULT.new RenderingMode();
+
public static final RenderingMode RENDERING_MODE_AJAX = DEFAULT.new RenderingMode();
/**
* Gets the current rendering mode.
+ *
* @return the current rendering mode.
*/
public RenderingMode getRenderingMode() {
@@ -692,11 +731,12 @@ public class WebBrowser implements Terminal {
/**
* Sets the current rendering mode.
- * @param renderingMode the rendering mode.
+ *
+ * @param renderingMode
+ * the rendering mode.
*/
public void setRenderingMode(RenderingMode renderingMode) {
this.renderingMode = renderingMode;
}
-
}
diff --git a/src/com/itmill/toolkit/terminal/web/WebBrowserProbe.java b/src/com/itmill/toolkit/terminal/web/WebBrowserProbe.java
index 835705082c..76bcd1f986 100644
--- a/src/com/itmill/toolkit/terminal/web/WebBrowserProbe.java
+++ b/src/com/itmill/toolkit/terminal/web/WebBrowserProbe.java
@@ -37,8 +37,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
- * The <code>WebBrowserProbe</code> uses JavaScript to determine the capabilities of the
- * client browser.
+ * The <code>WebBrowserProbe</code> uses JavaScript to determine the
+ * capabilities of the client browser.
*
* @author IT Mill Ltd.
* @version
@@ -53,7 +53,9 @@ public class WebBrowserProbe {
/**
* Returns the terminal type from the given session.
- * @param session the HTTP session.
+ *
+ * @param session
+ * the HTTP session.
* @return WebBrowser instance for the given session.
*/
public static WebBrowser getTerminalType(HttpSession session) {
@@ -64,8 +66,11 @@ public class WebBrowserProbe {
/**
* Sets the terminal type for the given session.
- * @param session the HTTP session.
- * @param terminal the web browser.
+ *
+ * @param session
+ * the HTTP session.
+ * @param terminal
+ * the web browser.
* @return WebBrowser instance for the given session.
*/
public static void setTerminalType(HttpSession session, WebBrowser terminal) {
@@ -80,9 +85,11 @@ public class WebBrowserProbe {
* the HTTP request to process.
* @param parameters
* the Parameters to be used as defaults.
- * @return <code>true</code> if response should include a probe script,otherwise <code>false</code>.
- * @throws ServletException if an exception has occurred that interferes with the
- * servlet's normal operation.
+ * @return <code>true</code> if response should include a probe
+ * script,otherwise <code>false</code>.
+ * @throws ServletException
+ * if an exception has occurred that interferes with the
+ * servlet's normal operation.
*/
public static boolean handleProbeRequest(HttpServletRequest request,
Map parameters) throws ServletException {
diff --git a/src/com/itmill/toolkit/terminal/web/WebPaintTarget.java b/src/com/itmill/toolkit/terminal/web/WebPaintTarget.java
index 27b5c7e93d..b17cfd24ba 100644
--- a/src/com/itmill/toolkit/terminal/web/WebPaintTarget.java
+++ b/src/com/itmill/toolkit/terminal/web/WebPaintTarget.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -41,43 +41,55 @@ import com.itmill.toolkit.terminal.VariableOwner;
import java.util.Stack;
-/**
+/**
* User Interface Description Language Target.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class WebPaintTarget implements PaintTarget {
/* Document type declarations */
- private final static String UIDL_XML_DECL =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ private final static String UIDL_XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+
/* commonly used tags and argument names */
private final static String UIDL_ARG_NAME = "name";
+
private final static String UIDL_ARG_VALUE = "value";
+
private final static String UIDL_ARG_ID = "id";
+
private Stack mOpenTags;
+
private boolean mTagArgumentListOpen;
+
private StringBuffer uidlBuffer;
+
private StringBuffer tagBuffer;
+
private HttpVariableMap variableMap;
+
private boolean closed = false;
+
private ApplicationServlet webAdapterServlet;
+
private Theme theme;
- private static final int TAG_BUFFER_DEFAULT_SIZE = 20;
- private boolean mSuppressOutput = false;
+ private static final int TAG_BUFFER_DEFAULT_SIZE = 20;
- /**
+ private boolean mSuppressOutput = false;
+
+ /**
* Creates a new XMLPrintWriter, without automatic line flushing.
- * @param out A character-output stream.
+ *
+ * @param out
+ * A character-output stream.
*/
- public WebPaintTarget(
- HttpVariableMap variableMap,
- UIDLTransformerType type,
- ApplicationServlet webAdapterServlet,
- Theme theme)
- throws PaintException {
+ public WebPaintTarget(HttpVariableMap variableMap,
+ UIDLTransformerType type, ApplicationServlet webAdapterServlet,
+ Theme theme) throws PaintException {
// Host servlet
this.webAdapterServlet = webAdapterServlet;
@@ -93,12 +105,12 @@ public class WebPaintTarget implements PaintTarget {
// Sets the target for TAG data
this.tagBuffer = new StringBuffer();
-
+
// Initialize tag-writing
mOpenTags = new Stack();
mTagArgumentListOpen = false;
- //Adds document declaration
+ // Adds document declaration
this.print(UIDL_XML_DECL + "\n\n");
// Adds UIDL start tag and its attributes
@@ -109,35 +121,40 @@ public class WebPaintTarget implements PaintTarget {
}
- /**
+ /**
* Ensures that the currently open element tag is closed.
*/
private void ensureClosedTag() {
if (mTagArgumentListOpen) {
tagBuffer.append(">");
mTagArgumentListOpen = false;
- append(tagBuffer);
+ append(tagBuffer);
}
}
- /**
+
+ /**
* Prints element start tag.
- *
- * <pre>Todo:
+ *
+ * <pre>
+ * Todo:
* Checking of input values
* </pre>
- *
- * @param tagName the name of the start tag.
- * @throws PaintException if the paint operation failed.
- *
+ *
+ * @param tagName
+ * the name of the start tag.
+ * @throws PaintException
+ * if the paint operation failed.
+ *
*/
public void startTag(String tagName) throws PaintException {
// In case of null data output nothing:
if (tagName == null)
throw new NullPointerException();
- //Ensure that the target is open
+ // Ensure that the target is open
if (this.closed)
- throw new PaintException("Attempted to write to a closed PaintTarget.");
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
// Make sure that the open start tag is closed before
// anything is written.
@@ -153,75 +170,77 @@ public class WebPaintTarget implements PaintTarget {
mTagArgumentListOpen = true;
}
- /**
+ /**
* Prints element end tag.
- *
- * If the parent tag is closed before
- * every child tag is closed a PaintException is raised.
- *
- * @param tagName the name of the end tag.
- * @throws PaintException if the paint operation failed.
+ *
+ * If the parent tag is closed before every child tag is closed a
+ * PaintException is raised.
+ *
+ * @param tagName
+ * the name of the end tag.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void endTag(String tagName) throws PaintException {
// In case of null data output nothing:
if (tagName == null)
throw new NullPointerException();
- //Ensures that the target is open
+ // Ensures that the target is open
if (this.closed)
- throw new PaintException("Attempted to write to a closed PaintTarget.");
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
String lastTag = "";
lastTag = (String) mOpenTags.pop();
if (!tagName.equalsIgnoreCase(lastTag))
- throw new PaintException(
- "Invalid UIDL: wrong ending tag: '"
- + tagName
- + "' expected: '"
- + lastTag
- + "'.");
+ throw new PaintException("Invalid UIDL: wrong ending tag: '"
+ + tagName + "' expected: '" + lastTag + "'.");
// Makes sure that the open start tag is closed before
// anything is written.
ensureClosedTag();
- //Writes the end (closing) tag
+ // Writes the end (closing) tag
append("</" + lastTag + "\n>");
-
+
// NOTE: We re-enable the output (if it has been disabled)
// for subsequent tags. The output is suppressed if tag
// contains attribute "invisible" with value true.
mSuppressOutput = false;
}
-
- /**
+
+ /**
* Appends data into UIDL output buffer.
*
- * @param data the String to be appended.
+ * @param data
+ * the String to be appended.
*/
private void append(String data) {
- if (!mSuppressOutput) {
- uidlBuffer.append(data);
- }
+ if (!mSuppressOutput) {
+ uidlBuffer.append(data);
+ }
}
- /**
+ /**
* Appends data into UIDL output buffer.
*
- * @param data the StringBuffer to be appended.
+ * @param data
+ * the StringBuffer to be appended.
*/
private void append(StringBuffer data) {
- if (!mSuppressOutput) {
- uidlBuffer.append(data);
- }
+ if (!mSuppressOutput) {
+ uidlBuffer.append(data);
+ }
}
-
- /**
+
+ /**
* Substitutes the XML sensitive characters with predefined XML entities.
+ *
* @param xml
* @return A new string instance where all occurrences of XML sensitive
- * characters are substituted with entities.
+ * characters are substituted with entities.
*/
static public String escapeXML(String xml) {
if (xml == null || xml.length() <= 0)
@@ -229,18 +248,20 @@ public class WebPaintTarget implements PaintTarget {
return escapeXML(new StringBuffer(xml)).toString();
}
- /**
+ /**
* Substitutes the XML sensitive characters with predefined XML entities.
- * @param xml the String to be substituted.
+ *
+ * @param xml
+ * the String to be substituted.
* @return A new StringBuffer instance where all occurrences of XML
- * sensitive characters are substituted with entities.
- *
+ * sensitive characters are substituted with entities.
+ *
*/
static public StringBuffer escapeXML(StringBuffer xml) {
if (xml == null || xml.length() <= 0)
return new StringBuffer("");
- StringBuffer result = new StringBuffer(xml.length()*2);
+ StringBuffer result = new StringBuffer(xml.length() * 2);
for (int i = 0; i < xml.length(); i++) {
char c = xml.charAt(i);
@@ -249,41 +270,45 @@ public class WebPaintTarget implements PaintTarget {
result.append(s);
} else {
result.append(c);
- }
+ }
}
return result;
}
- /**
+ /**
* Substitutes a XML sensitive character with predefined XML entity.
- * @param c the Character to be replaced with an entity.
+ *
+ * @param c
+ * the Character to be replaced with an entity.
* @return String of the entity or null if character is not to be replaced
- * with an entity.
+ * with an entity.
*/
private static String toXmlChar(char c) {
switch (c) {
- case '&' :
- return "&amp;"; // & => &amp;
- case '>' :
- return "&gt;"; // > => &gt;
- case '<' :
- return "&lt;"; // < => &lt;
- case '"' :
- return "&quot;"; // " => &quot;
- case '\'' :
- return "&apos;"; // ' => &apos;
- default :
- return null;
+ case '&':
+ return "&amp;"; // & => &amp;
+ case '>':
+ return "&gt;"; // > => &gt;
+ case '<':
+ return "&lt;"; // < => &lt;
+ case '"':
+ return "&quot;"; // " => &quot;
+ case '\'':
+ return "&apos;"; // ' => &apos;
+ default:
+ return null;
}
}
- /**
+ /**
* Prints XML.
- *
+ *
* Writes pre-formatted XML to stream. Well-formness of XML is checked.
+ *
* <pre>
* TODO: XML checking should be made
* </pre>
+ *
* @param str
*/
private void print(String str) {
@@ -299,46 +324,52 @@ public class WebPaintTarget implements PaintTarget {
append(str);
}
- /**
+ /**
* Prints XML-escaped text.
+ *
* @param str
- * @throws PaintException if the paint operation failed.
- *
+ * @throws PaintException
+ * if the paint operation failed.
+ *
*/
public void addText(String str) throws PaintException {
addUIDL(escapeXML(str));
}
- /**
- * Adds a boolean attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Attribute name.
- * @param value the Attribute value.
- * @throws PaintException if the paint operation failed.
+ /**
+ * Adds a boolean attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
- public void addAttribute(String name, boolean value)
- throws PaintException {
- if ("invisible".equals(name) && value) {
- // NOTE: If we receive the "invisible attribute
- // we filter these tags (and ceontent) from
- // them out from the output.
- this.mSuppressOutput = true;
- } else {
- addAttribute(name, String.valueOf(value));
- }
+ public void addAttribute(String name, boolean value) throws PaintException {
+ if ("invisible".equals(name) && value) {
+ // NOTE: If we receive the "invisible attribute
+ // we filter these tags (and ceontent) from
+ // them out from the output.
+ this.mSuppressOutput = true;
+ } else {
+ addAttribute(name, String.valueOf(value));
+ }
}
- /**
- * Adds a resource attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Attribute name.
- * @param value the Attribute value.
- * @throws PaintException if the paint operation failed.
+ /**
+ * Adds a resource attribute to component. Atributes must be added before
+ * any content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
- public void addAttribute(String name, Resource value)
- throws PaintException {
+ public void addAttribute(String name, Resource value) throws PaintException {
if (value instanceof ExternalResource) {
addAttribute(name, ((ExternalResource) value).getURL());
@@ -348,8 +379,8 @@ public class WebPaintTarget implements PaintTarget {
Application a = r.getApplication();
if (a == null)
throw new PaintException(
- "Application not specified for resorce "
- + value.getClass().getName());
+ "Application not specified for resorce "
+ + value.getClass().getName());
String uri = a.getURL().getPath();
if (uri.charAt(uri.length() - 1) != '/')
uri += "/";
@@ -357,59 +388,67 @@ public class WebPaintTarget implements PaintTarget {
addAttribute(name, uri);
} else if (value instanceof ThemeResource) {
- addAttribute(
- name,
- webAdapterServlet.getResourceLocation(
- theme.getName(),
- (ThemeResource) value));
+ addAttribute(name, webAdapterServlet.getResourceLocation(theme
+ .getName(), (ThemeResource) value));
} else
- throw new PaintException(
- "Web adapter does not "
+ throw new PaintException("Web adapter does not "
+ "support resources of type: "
+ value.getClass().getName());
}
- /**
- * Adds a integer attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Attribute name.
- * @param value the Attribute value.
- * @throws PaintException if the paint operation failed.
+ /**
+ * Adds a integer attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addAttribute(String name, int value) throws PaintException {
addAttribute(name, String.valueOf(value));
}
- /**
- * Adds a long attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Attribute name.
- * @param value the Attribute value.
- * @throws PaintException if the paint operation failed.
+ /**
+ * Adds a long attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Attribute name.
+ * @param value
+ * the Attribute value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addAttribute(String name, long value) throws PaintException {
addAttribute(name, String.valueOf(value));
}
- /**
- * Adds a string attribute to component.
- * Atributes must be added before any content is written.
- *
- * @param name the Boolean attribute name.
- * @param value the Boolean attribute value.
- * @throws PaintException if the paint operation failed.
+ /**
+ * Adds a string attribute to component. Atributes must be added before any
+ * content is written.
+ *
+ * @param name
+ * the Boolean attribute name.
+ * @param value
+ * the Boolean attribute value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addAttribute(String name, String value) throws PaintException {
// In case of null data output nothing:
if ((value == null) || (name == null))
- throw new NullPointerException("Parameters must be non-null strings ("+name+"="+value+")");
+ throw new NullPointerException(
+ "Parameters must be non-null strings (" + name + "="
+ + value + ")");
- //Ensure that the target is open
+ // Ensure that the target is open
if (this.closed)
- throw new PaintException("Attempted to write to a closed PaintTarget.");
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
// Check that argument list is writable.
if (!mTagArgumentListOpen)
@@ -418,16 +457,22 @@ public class WebPaintTarget implements PaintTarget {
tagBuffer.append(" " + name + "=\"" + escapeXML(value) + "\"");
}
- /**
+ /**
* Adds a string type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
- * @param value the Variable initial value.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addVariable(VariableOwner owner, String name, String value)
- throws PaintException {
- String code = variableMap.registerVariable(name, String.class, value, owner);
+ throws PaintException {
+ String code = variableMap.registerVariable(name, String.class, value,
+ owner);
startTag("string");
addAttribute(UIDL_ARG_ID, code);
addAttribute(UIDL_ARG_NAME, name);
@@ -435,16 +480,22 @@ public class WebPaintTarget implements PaintTarget {
endTag("string");
}
- /**
+ /**
* Adds a int type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
- * @param value the Variable initial value.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addVariable(VariableOwner owner, String name, int value)
- throws PaintException {
- String code = variableMap.registerVariable(name, Integer.class, new Integer(value), owner);
+ throws PaintException {
+ String code = variableMap.registerVariable(name, Integer.class,
+ new Integer(value), owner);
startTag("integer");
addAttribute(UIDL_ARG_ID, code);
addAttribute(UIDL_ARG_NAME, name);
@@ -452,16 +503,22 @@ public class WebPaintTarget implements PaintTarget {
endTag("integer");
}
- /**
+ /**
* Adds a boolean type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
- * @param value the Variable initial value.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addVariable(VariableOwner owner, String name, boolean value)
- throws PaintException {
- String code = variableMap.registerVariable(name, Boolean.class, new Boolean(value), owner);
+ throws PaintException {
+ String code = variableMap.registerVariable(name, Boolean.class,
+ new Boolean(value), owner);
startTag("boolean");
addAttribute(UIDL_ARG_ID, code);
addAttribute(UIDL_ARG_NAME, name);
@@ -469,16 +526,22 @@ public class WebPaintTarget implements PaintTarget {
endTag("boolean");
}
- /**
+ /**
* Adds a string array type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
- * @param value the Variable initial value.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ * @param value
+ * the Variable initial value.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addVariable(VariableOwner owner, String name, String[] value)
- throws PaintException {
- String code = variableMap.registerVariable(name, String[].class, value, owner);
+ throws PaintException {
+ String code = variableMap.registerVariable(name, String[].class, value,
+ owner);
startTag("array");
addAttribute(UIDL_ARG_ID, code);
addAttribute(UIDL_ARG_NAME, name);
@@ -487,17 +550,21 @@ public class WebPaintTarget implements PaintTarget {
endTag("array");
}
- /**
+ /**
* Adds a upload stream type variable.
- * @param owner the Listener for variable changes.
- * @param name the Variable name.
*
- * @throws PaintException if the paint operation failed.
+ * @param owner
+ * the Listener for variable changes.
+ * @param name
+ * the Variable name.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addUploadStreamVariable(VariableOwner owner, String name)
- throws PaintException {
- String code =
- variableMap.registerVariable(name, UploadStream.class, null, owner);
+ throws PaintException {
+ String code = variableMap.registerVariable(name, UploadStream.class,
+ null, owner);
startTag("uploadstream");
addAttribute(UIDL_ARG_ID, code);
addAttribute(UIDL_ARG_NAME, name);
@@ -510,12 +577,16 @@ public class WebPaintTarget implements PaintTarget {
* Prints full text section. The section data is escaped from XML tags and
* surrounded by XML start and end-tags.
* </p>
- * @param sectionTagName the name of the tag.
- * @param sectionData the section data.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param sectionTagName
+ * the name of the tag.
+ * @param sectionData
+ * the section data.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addSection(String sectionTagName, String sectionData)
- throws PaintException {
+ throws PaintException {
startTag(sectionTagName);
addText(sectionData);
endTag(sectionTagName);
@@ -523,14 +594,18 @@ public class WebPaintTarget implements PaintTarget {
/**
* Adds XML directly to UIDL.
- * @param xml the XML to be added.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param xml
+ * the XML to be added.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void addUIDL(String xml) throws PaintException {
- //Ensure that the target is open
+ // Ensure that the target is open
if (this.closed)
- throw new PaintException("Attempted to write to a closed PaintTarget.");
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
// Make sure that the open start tag is closed before
// anything is written.
@@ -541,20 +616,20 @@ public class WebPaintTarget implements PaintTarget {
append(xml);
}
- /**
+
+ /**
* Adds XML section with namespace.
*
- * @see com.itmill.toolkit.terminal.PaintTarget#addXMLSection(String, String, String)
+ * @see com.itmill.toolkit.terminal.PaintTarget#addXMLSection(String,
+ * String, String)
*/
- public void addXMLSection(
- String sectionTagName,
- String sectionData,
- String namespace)
- throws PaintException {
+ public void addXMLSection(String sectionTagName, String sectionData,
+ String namespace) throws PaintException {
- //Ensures that the target is open
+ // Ensures that the target is open
if (this.closed)
- throw new PaintException("Attempted to write to a closed PaintTarget.");
+ throw new PaintException(
+ "Attempted to write to a closed PaintTarget.");
startTag(sectionTagName);
if (namespace != null)
@@ -568,28 +643,28 @@ public class WebPaintTarget implements PaintTarget {
endTag(sectionTagName);
}
- /**
- * Gets the UIDL already printed to stream.
- * Paint target must be closed before the <code>getUIDL</code>
- * can be called.
+ /**
+ * Gets the UIDL already printed to stream. Paint target must be closed
+ * before the <code>getUIDL</code> can be called.
+ *
* @return the UIDL.
*/
public String getUIDL() {
if (this.closed) {
return uidlBuffer.toString();
}
- throw new IllegalStateException("Tried to read UIDL from open PaintTarget");
+ throw new IllegalStateException(
+ "Tried to read UIDL from open PaintTarget");
}
- /**
- * Closes the paint target.
- * Paint target must be closed before the <code>getUIDL</code>
- * can be called.
- * Subsequent attempts to write to paint target.
- * If the target was already closed, call to this
- * function is ignored.
- * will generate an exception.
- * @throws PaintException if the paint operation failed.
+ /**
+ * Closes the paint target. Paint target must be closed before the
+ * <code>getUIDL</code> can be called. Subsequent attempts to write to
+ * paint target. If the target was already closed, call to this function is
+ * ignored. will generate an exception.
+ *
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void close() throws PaintException {
if (!this.closed) {
@@ -597,42 +672,48 @@ public class WebPaintTarget implements PaintTarget {
this.closed = true;
}
}
-
- /**
- * Prints element start tag of a paintable section.
- * Starts a paintable section using the given tag. The PaintTarget may
- * implement a caching scheme, that checks the paintable has actually
- * changed or can a cached version be used instead. This method should call
- * the startTag method.
+
+ /**
+ * Prints element start tag of a paintable section. Starts a paintable
+ * section using the given tag. The PaintTarget may implement a caching
+ * scheme, that checks the paintable has actually changed or can a cached
+ * version be used instead. This method should call the startTag method.
* <p>
- * If the Paintable is found in cache and this
- * function returns true it may omit the content and close the tag, in which
- * case cached content should be used.
+ * If the Paintable is found in cache and this function returns true it may
+ * omit the content and close the tag, in which case cached content should
+ * be used.
* </p>
- * <b>Note:</b> Web adapter does not currently implement caching and
- * this function always returns false.
- * @param paintable the paintable to start.
- * @param tag the name of the start tag.
+ * <b>Note:</b> Web adapter does not currently implement caching and this
+ * function always returns false.
+ *
+ * @param paintable
+ * the paintable to start.
+ * @param tag
+ * the name of the start tag.
* @return false
- * @throws PaintException if the paint operation failed.
+ * @throws PaintException
+ * if the paint operation failed.
* @see com.itmill.toolkit.terminal.PaintTarget#startTag(Paintable, String),
- * #startTag(String)
+ * #startTag(String)
* @since 3.1
*/
public boolean startTag(Paintable paintable, String tag)
- throws PaintException {
- startTag(tag);
+ throws PaintException {
+ startTag(tag);
return false;
}
- /**
+ /**
* Adds CDATA node to target UIDL-tree.
- * @param text the Character data to add.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param text
+ * the Character data to add.
+ * @throws PaintException
+ * if the paint operation failed.
* @since 3.1
*/
public void addCharacterData(String text) throws PaintException {
- addUIDL("<![CDATA["+text+"]]>");
+ addUIDL("<![CDATA[" + text + "]]>");
}
}
diff --git a/src/com/itmill/toolkit/terminal/web/XSLReader.java b/src/com/itmill/toolkit/terminal/web/XSLReader.java
index cf0c94fe22..483bd73572 100644
--- a/src/com/itmill/toolkit/terminal/web/XSLReader.java
+++ b/src/com/itmill/toolkit/terminal/web/XSLReader.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.terminal.web;
@@ -46,71 +46,84 @@ import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
-/**
+/**
* Class implementing XMLReader for the UIDLTransformer.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class XSLReader implements XMLReader, ContentHandler {
static protected final int XSLT_UNKNOWN = 0;
+
static protected final int XSLT_XALAN = 1;
+
static protected final int XSLT_SAXON6 = 2;
+
static protected final int XSLT_SAXON7 = 3;
+
static protected final int XSLT_RESIN = 4;
+
static protected final int XSLT_WEBLOGIC = 5;
+
static protected int xsltProcessor = XSLT_UNKNOWN;
static {
- String transformerName =
- UIDLTransformer.xsltFactory.getClass().getName();
+ String transformerName = UIDLTransformer.xsltFactory.getClass()
+ .getName();
// Saxon 7.x
if ("net.sf.saxon.TransformerFactoryImpl".equals(transformerName))
xsltProcessor = XSLT_SAXON7;
// Saxon 6.x
- else if (
- "com.icl.saxon.TransformerFactoryImpl".equals(transformerName))
+ else if ("com.icl.saxon.TransformerFactoryImpl".equals(transformerName))
xsltProcessor = XSLT_SAXON6;
// Xalan
- else if (
- "org.apache.xalan.processor.TransformerFactoryImpl".equals(
- transformerName) ||
- "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl".equals(
- transformerName))
+ else if ("org.apache.xalan.processor.TransformerFactoryImpl"
+ .equals(transformerName)
+ || "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"
+ .equals(transformerName))
xsltProcessor = XSLT_XALAN;
// Resin
else if ("com.caucho.xsl.Xsl".equals(transformerName))
xsltProcessor = XSLT_RESIN;
-
- else if ("weblogic.xml.jaxp.RegistrySAXTransformerFactory".equals(transformerName))
+
+ else if ("weblogic.xml.jaxp.RegistrySAXTransformerFactory"
+ .equals(transformerName))
xsltProcessor = XSLT_WEBLOGIC;
else {
throw new RuntimeException(
- "\nThis version of IT Mill Toolkit "
- + " does not support the selected XSLT-processer:\n "
- + transformerName
- + "\n"
- + "You can specify the used XSLT processor with JVM "
- + "parameter like: \n"
- + " -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl\n"
- + " -Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl\n");
+ "\nThis version of IT Mill Toolkit "
+ + " does not support the selected XSLT-processer:\n "
+ + transformerName
+ + "\n"
+ + "You can specify the used XSLT processor with JVM "
+ + "parameter like: \n"
+ + " -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl\n"
+ + " -Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl\n");
}
}
- private static final String[] JAVA_PREFIX = {"java://", "millstone://"};
+ private static final String[] JAVA_PREFIX = { "java://", "millstone://" };
+
private Collection streams;
+
private boolean startTagHandled = false;
+
private String xslNamespace = "";
+
private ContentHandler handler;
+
private XMLReader reader;
private XSLStreamLocator locator = null;
+
private Locator streamLocator = null;
+
private int streamStartLineNumber = 0;
public XSLReader(XMLReader reader, Collection streams) {
@@ -119,13 +132,14 @@ public class XSLReader implements XMLReader, ContentHandler {
this.streams = streams;
}
- /**
- * Parses all streams given for constructor parameter.
- * The input parameter is ignored.
+ /**
+ * Parses all streams given for constructor parameter. The input parameter
+ * is ignored.
+ *
* @see org.xml.sax.XMLReader#parse(InputSource)
*/
- public synchronized void parse(InputSource input)
- throws IOException, SAXException {
+ public synchronized void parse(InputSource input) throws IOException,
+ SAXException {
startTagHandled = false;
handler.startDocument();
@@ -134,7 +148,7 @@ public class XSLReader implements XMLReader, ContentHandler {
ThemeSource.XSLStream xslStream = (ThemeSource.XSLStream) i.next();
this.locator = new XSLStreamLocator(xslStream.getId());
InputStream in = (xslStream).getStream();
-
+
// Parse the stream
reader.parse(new InputSource(in));
@@ -142,14 +156,14 @@ public class XSLReader implements XMLReader, ContentHandler {
handler.endElement(xslNamespace, "stylesheet", "xsl:stylesheet");
handler.endDocument();
}
-
+
/**
* @see org.xml.sax.ContentHandler#endElement(String, String, String)
*/
public void endElement(String namespaceURI, String localName, String qName)
- throws SAXException {
+ throws SAXException {
if (localName.equals("stylesheet")) {
- return; //Skip
+ return; // Skip
}
handler.endElement(namespaceURI, localName, qName);
}
@@ -158,23 +172,20 @@ public class XSLReader implements XMLReader, ContentHandler {
* @see org.xml.sax.ContentHandler#processingInstruction(String, String)
*/
public void processingInstruction(String target, String data)
- throws SAXException {
+ throws SAXException {
handler.processingInstruction(target, data);
}
/**
- * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
+ * @see org.xml.sax.ContentHandler#startElement(String, String, String,
+ * Attributes)
*/
- public void startElement(
- String namespaceURI,
- String localName,
- String qName,
- Attributes atts)
- throws SAXException {
+ public void startElement(String namespaceURI, String localName,
+ String qName, Attributes atts) throws SAXException {
// Only the first stylesheet is used
if (startTagHandled && localName.equals("stylesheet"))
- return; //skip
+ return; // skip
// Get the namespace that will be used for closing the theme
if (localName.equals("stylesheet")) {
@@ -183,11 +194,8 @@ public class XSLReader implements XMLReader, ContentHandler {
// Manage calls to external functions in XSLT-processor independent
// way, but still using XSLT 1.0
- handler.startElement(
- namespaceURI,
- localName,
- qName,
- new AttributeMapper(atts));
+ handler.startElement(namespaceURI, localName, qName,
+ new AttributeMapper(atts));
} else
// Handle the element in superclass directly
@@ -198,7 +206,7 @@ public class XSLReader implements XMLReader, ContentHandler {
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
*/
public void characters(char[] ch, int start, int length)
- throws SAXException {
+ throws SAXException {
handler.characters(ch, start, length);
}
@@ -213,7 +221,7 @@ public class XSLReader implements XMLReader, ContentHandler {
* @see org.xml.sax.ContentHandler#endDocument()
*/
public void endDocument() throws SAXException {
- //Ignore document ends, but add previous line numbers
+ // Ignore document ends, but add previous line numbers
if (this.streamLocator != null) {
this.streamStartLineNumber += this.streamLocator.getLineNumber();
}
@@ -230,15 +238,15 @@ public class XSLReader implements XMLReader, ContentHandler {
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
*/
public void ignorableWhitespace(char[] ch, int start, int length)
- throws SAXException {
+ throws SAXException {
handler.ignorableWhitespace(ch, start, length);
}
/**
* @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
*/
- public void setDocumentLocator(Locator locator) {
- this.streamLocator = locator;
+ public void setDocumentLocator(Locator locator) {
+ this.streamLocator = locator;
// create new locator combined streams/files
if (!startTagHandled) {
handler.setDocumentLocator(this.locator);
@@ -256,26 +264,28 @@ public class XSLReader implements XMLReader, ContentHandler {
* @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
*/
public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
+ throws SAXException {
handler.startPrefixMapping(prefix, uri);
}
- /**
+ /**
* Overrides the default content handler.
+ *
* @see org.xml.sax.XMLReader#getContentHandler()
*/
public ContentHandler getContentHandler() {
return this.handler;
}
- /**
+ /**
* Overrides the default content handler.
+ *
* @see org.xml.sax.XMLReader#setContentHandler(ContentHandler)
*/
public void setContentHandler(ContentHandler handler) {
this.handler = handler;
}
-
+
/**
* @see org.xml.sax.XMLReader#getDTDHandler()
*/
@@ -300,21 +310,22 @@ public class XSLReader implements XMLReader, ContentHandler {
/**
* @see org.xml.sax.XMLReader#getFeature(String)
*/
- public boolean getFeature(String name)
- throws SAXNotRecognizedException, SAXNotSupportedException {
+ public boolean getFeature(String name) throws SAXNotRecognizedException,
+ SAXNotSupportedException {
return reader.getFeature(name);
}
/**
* @see org.xml.sax.XMLReader#getProperty(String)
*/
- public Object getProperty(String name)
- throws SAXNotRecognizedException, SAXNotSupportedException {
+ public Object getProperty(String name) throws SAXNotRecognizedException,
+ SAXNotSupportedException {
return reader.getProperty(name);
}
- /**
+ /**
* Overrides the parse.
+ *
* @see org.xml.sax.XMLReader#parse(String)
*/
public void parse(String systemId) throws IOException, SAXException {
@@ -346,7 +357,7 @@ public class XSLReader implements XMLReader, ContentHandler {
* @see org.xml.sax.XMLReader#setFeature(String, boolean)
*/
public void setFeature(String name, boolean value)
- throws SAXNotRecognizedException, SAXNotSupportedException {
+ throws SAXNotRecognizedException, SAXNotSupportedException {
reader.setFeature(name, value);
}
@@ -354,14 +365,14 @@ public class XSLReader implements XMLReader, ContentHandler {
* @see org.xml.sax.XMLReader#setProperty(String, Object)
*/
public void setProperty(String name, Object value)
- throws SAXNotRecognizedException, SAXNotSupportedException {
+ throws SAXNotRecognizedException, SAXNotSupportedException {
reader.setProperty(name, value);
}
public class AttributeMapper implements Attributes {
private Attributes original;
-
+
/**
*
* @param originalAttributes
@@ -432,34 +443,30 @@ public class XSLReader implements XMLReader, ContentHandler {
public String getURI(int index) {
String uri = original.getURI(index);
- for (int i=0; i<JAVA_PREFIX.length; i++)
- if (uri != null && uri.startsWith(JAVA_PREFIX[i])) {
+ for (int i = 0; i < JAVA_PREFIX.length; i++)
+ if (uri != null && uri.startsWith(JAVA_PREFIX[i])) {
- System.out.print("DEBUG " + uri + " --> ");
- switch (xsltProcessor) {
- case XSLT_SAXON6 :
- uri =
- "saxon://"
+ System.out.print("DEBUG " + uri + " --> ");
+ switch (xsltProcessor) {
+ case XSLT_SAXON6:
+ uri = "saxon://"
+ uri.substring(JAVA_PREFIX[i].length());
break;
- case XSLT_SAXON7 :
- uri =
- "saxon://"
+ case XSLT_SAXON7:
+ uri = "saxon://"
+ uri.substring(JAVA_PREFIX[i].length());
break;
- case XSLT_XALAN :
- uri =
- "xalan://"
+ case XSLT_XALAN:
+ uri = "xalan://"
+ uri.substring(JAVA_PREFIX[i].length());
break;
- default :
- uri =
- "xalan://"
+ default:
+ uri = "xalan://"
+ uri.substring(JAVA_PREFIX[i].length());
break;
+ }
+ System.out.println(uri);
}
- System.out.println(uri);
- }
return uri;
}
@@ -489,15 +496,15 @@ public class XSLReader implements XMLReader, ContentHandler {
public class XSLStreamLocator implements Locator {
private String id;
-
-/**
- *
- * @param id
- */
+
+ /**
+ *
+ * @param id
+ */
public XSLStreamLocator(String id) {
this.id = id;
}
-
+
/**
*
* @see org.xml.sax.Locator#getPublicId()
@@ -505,14 +512,15 @@ public class XSLReader implements XMLReader, ContentHandler {
public String getPublicId() {
return streamLocator.getPublicId();
}
-
+
/**
*
* @see org.xml.sax.Locator#getSystemId()
*/
public String getSystemId() {
- return streamLocator.getSystemId()+""+id;
+ return streamLocator.getSystemId() + "" + id;
}
+
/**
*
* @see org.xml.sax.Locator#getLineNumber()
@@ -520,20 +528,21 @@ public class XSLReader implements XMLReader, ContentHandler {
public int getLineNumber() {
return streamLocator.getLineNumber();
}
-
+
public int getCombinedLineNumber() {
- return streamLocator.getLineNumber()+streamStartLineNumber;
+ return streamLocator.getLineNumber() + streamStartLineNumber;
}
-
+
/**
* @see org.xml.sax.Locator#getColumnNumber()
*/
public int getColumnNumber() {
return streamLocator.getColumnNumber();
}
-
+
/**
* Gets the id.
+ *
* @return the id .
*/
public String getId() {
@@ -544,47 +553,38 @@ public class XSLReader implements XMLReader, ContentHandler {
public class SAXStreamErrorHandler implements ErrorHandler {
private ErrorHandler handler;
-
-/**
- *
- * @param origHandler
- */
+
+ /**
+ *
+ * @param origHandler
+ */
SAXStreamErrorHandler(ErrorHandler origHandler) {
this.handler = origHandler;
}
-
+
/**
* @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
*/
public void warning(SAXParseException exception) throws SAXException {
- handler.warning(
- new SAXParseException(
- "" + exception.getMessage()+" in "+locator.getId(),
- locator,
- exception));
+ handler.warning(new SAXParseException("" + exception.getMessage()
+ + " in " + locator.getId(), locator, exception));
}
-
+
/**
* @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
*/
public void error(SAXParseException exception) throws SAXException {
- handler.error(
- new SAXParseException(
- "" + exception.getMessage()+" in "+locator.getId(),
- locator,
- exception));
+ handler.error(new SAXParseException("" + exception.getMessage()
+ + " in " + locator.getId(), locator, exception));
}
-
+
/**
* @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
*/
- public void fatalError(SAXParseException exception)
- throws SAXException {
- handler.fatalError(
- new SAXParseException(
- "" + exception.getMessage()+" in "+locator.getId(),
- locator,
- exception));
+ public void fatalError(SAXParseException exception) throws SAXException {
+ handler.fatalError(new SAXParseException(""
+ + exception.getMessage() + " in " + locator.getId(),
+ locator, exception));
}
}
}
diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java
index a3a7390fca..6c453d0a57 100644
--- a/src/com/itmill/toolkit/ui/AbstractComponent.java
+++ b/src/com/itmill/toolkit/ui/AbstractComponent.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -41,159 +41,160 @@ import java.util.Set;
import java.util.HashSet;
import java.lang.reflect.Method;
-/**
+/**
* An abstract class that defines default implementation for the
- * {@link Component} interface. Basic UI components that are not derived
- * from an external component can inherit this class to easily qualify as a
- * IT Mill Toolkit component. Most components in the toolkit do
- * just that.
- *
+ * {@link Component} interface. Basic UI components that are not derived from an
+ * external component can inherit this class to easily qualify as a IT Mill
+ * Toolkit component. Most components in the toolkit do just that.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public abstract class AbstractComponent
- implements Component, MethodEventSource {
+public abstract class AbstractComponent implements Component, MethodEventSource {
/* Private members ************************************************* */
- /**
- * Look-and-feel style of the component.
+ /**
+ * Look-and-feel style of the component.
*/
private String style;
- /**
- * Caption text.
+ /**
+ * Caption text.
*/
private String caption;
-
- /**
- * Application specific data object.
- */
- private Object applicationData;
- /**
- * Icon to be shown together with caption.
+ /**
+ * Application specific data object.
+ */
+ private Object applicationData;
+
+ /**
+ * Icon to be shown together with caption.
*/
private Resource icon;
- /**
- * Is the component enable (its normal usage is allowed).
+ /**
+ * Is the component enable (its normal usage is allowed).
*/
private boolean enabled = true;
- /**
- * Is the component visible (it is rendered).
+ /**
+ * Is the component visible (it is rendered).
*/
private boolean visible = true;
- /**
- * Is the component read-only ?
+ /**
+ * Is the component read-only ?
*/
private boolean readOnly = false;
- /**
- * Description of the usage (XML).
+ /**
+ * Description of the usage (XML).
*/
private String description = null;
- /**
- * The container this component resides in.
+ /**
+ * The container this component resides in.
*/
private Component parent = null;
- /**
- * The EventRouter used for the event model.
+ /**
+ * The EventRouter used for the event model.
*/
private EventRouter eventRouter = null;
- /**
- * The internal error message of the component.
+ /**
+ * The internal error message of the component.
*/
private ErrorMessage componentError = null;
- /**
- * List of event variable change event handling dependencies.
+ /**
+ * List of event variable change event handling dependencies.
*/
private Set dependencies = null;
- /**
+ /**
* Immediate mode: if true, all variable changes are required to be sent
* from the terminal immediately.
*/
private boolean immediate = false;
- /**
- * Locale of this component.
+ /**
+ * Locale of this component.
*/
private Locale locale;
- /**
- * List of repaint request listeners or null if not listened at all.
+ /**
+ * List of repaint request listeners or null if not listened at all.
*/
private LinkedList repaintRequestListeners = null;
- /**
- * Are all the repaint listeners notified about recent changes ?
+ /**
+ * Are all the repaint listeners notified about recent changes ?
*/
private boolean repaintRequestListenersNotified = false;
/* Constructor ***************************************************** */
- /**
- * Constructs a new Component.
+ /**
+ * Constructs a new Component.
*/
public AbstractComponent() {
}
/* Get/Set component properties ************************************ */
- /**
+ /**
* Gets the UIDL tag corresponding to the component.
*
* @return the component's UIDL tag as <code>String</code>
*/
public abstract String getTag();
- /* Gets the component's style.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the component's style. Don't add a JavaDoc comment here, we use the
+ * default documentation from implemented interface.
*/
public String getStyle() {
return this.style;
}
- /* Sets the component's style.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Sets the component's style. Don't add a JavaDoc comment here, we use the
+ * default documentation from implemented interface.
*/
public void setStyle(String style) {
this.style = style;
requestRepaint();
}
- /* Get's the component's caption.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Get's the component's caption. Don't add a JavaDoc comment here, we use
+ * the default documentation from implemented interface.
*/
public String getCaption() {
return this.caption;
}
- /**
+ /**
* Sets the component's caption <code>String</code>. Caption is the
* visible name of the component. This method will trigger a
* {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
*
- * @param caption the new caption <code>String</code> for the component.
+ * @param caption
+ * the new caption <code>String</code> for the component.
*/
public void setCaption(String caption) {
this.caption = caption;
requestRepaint();
}
- /* Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Don't add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public Locale getLocale() {
if (this.locale != null)
@@ -206,44 +207,47 @@ public abstract class AbstractComponent
return null;
}
- /**
+ /**
* Sets the locale of this component.
- * @param locale the locale to become this component's locale.
+ *
+ * @param locale
+ * the locale to become this component's locale.
*/
public void setLocale(Locale locale) {
this.locale = locale;
}
- /* Gets the component's icon resource.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the component's icon resource. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
*/
public Resource getIcon() {
return this.icon;
}
- /**
- * Sets the component's icon. This method will trigger a
- *{@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
+ /**
+ * Sets the component's icon. This method will trigger a
+ * {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
*
- * @param icon the icon to be shown with the component's caption.
- */
+ * @param icon
+ * the icon to be shown with the component's caption.
+ */
public void setIcon(Resource icon) {
this.icon = icon;
requestRepaint();
}
- /* Tests if the component is enabled or not.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the component is enabled or not. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public boolean isEnabled() {
return this.enabled && isVisible();
}
- /* Enables or disables the component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Enables or disables the component. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
*/
public void setEnabled(boolean enabled) {
if (this.enabled != enabled) {
@@ -252,21 +256,23 @@ public abstract class AbstractComponent
}
}
- /* Tests if the component is in the immediate mode.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the component is in the immediate mode. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public boolean isImmediate() {
return immediate;
}
- /**
- * Sets the component's immediate mode to the specified status. This
- * method will trigger a
+ /**
+ * Sets the component's immediate mode to the specified status. This method
+ * will trigger a
* {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
*
- * @param immediate the boolean value specifying if the component should
- * be in the immediate mode after the call.
+ * @param immediate
+ * the boolean value specifying if the component should be in the
+ * immediate mode after the call.
* @see Component#isImmediate()
*/
public void setImmediate(boolean immediate) {
@@ -274,65 +280,83 @@ public abstract class AbstractComponent
requestRepaint();
}
- /* Tests if the component is visible.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the component is visible. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
*/
public boolean isVisible() {
return this.visible;
}
- /* Sets the components visibility.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Sets the components visibility. Don't add a JavaDoc comment here, we use
+ * the default documentation from implemented interface.
*/
public void setVisible(boolean visible) {
if (this.visible != visible) {
this.visible = visible;
- // Instead of requesting repaint normally we
- // fire the event directly to assure that the
+ // Instead of requesting repaint normally we
+ // fire the event directly to assure that the
// event goes through event in the component might
// now be invisible
fireRequestRepaintEvent(null);
}
}
- /**
+ /**
* <p>
- * Gets the component's description. The description can be used to
- * briefly describe the state of the component to the user. The
- * description string may contain certain XML tags:
+ * Gets the component's description. The description can be used to briefly
+ * describe the state of the component to the user. The description string
+ * may contain certain XML tags:
* </p>
*
- * <p><table border=1>
- * <tr><td width=120><b>Tag</b></td>
- * <td width=120><b>Description</b></td>
- * <td width=120><b>Example</b></td>
+ * <p>
+ * <table border=1>
+ * <tr>
+ * <td width=120><b>Tag</b></td>
+ * <td width=120><b>Description</b></td>
+ * <td width=120><b>Example</b></td>
* </tr>
- * <tr><td>&lt;b></td>
- * <td>bold</td>
- * <td><b>bold text</b></td>
+ * <tr>
+ * <td>&lt;b></td>
+ * <td>bold</td>
+ * <td><b>bold text</b></td>
* </tr>
- * <tr><td>&lt;i></td>
- * <td>italic</td>
- * <td><i>italic text</i></td>
+ * <tr>
+ * <td>&lt;i></td>
+ * <td>italic</td>
+ * <td><i>italic text</i></td>
* </tr>
- * <tr><td>&lt;u></td>
- * <td>underlined</td>
- * <td><u>underlined text</u></td>
+ * <tr>
+ * <td>&lt;u></td>
+ * <td>underlined</td>
+ * <td><u>underlined text</u></td>
* </tr>
- * <tr><td>&lt;br></td>
- * <td>linebreak</td>
- * <td>N/A</td>
+ * <tr>
+ * <td>&lt;br></td>
+ * <td>linebreak</td>
+ * <td>N/A</td>
* </tr>
- * <tr><td>&lt;ul><br>&lt;li>item1<br>&lt;li>item1<br>&lt;/ul></td>
- * <td>item list</td>
- * <td><ul><li>item1 <li>item2</ul></td>
+ * <tr>
+ * <td>&lt;ul><br>
+ * &lt;li>item1<br>
+ * &lt;li>item1<br>
+ * &lt;/ul></td>
+ * <td>item list</td>
+ * <td>
+ * <ul>
+ * <li>item1
+ * <li>item2
+ * </ul>
+ * </td>
* </tr>
- * </table></p>
+ * </table>
+ * </p>
*
- * <p>These tags may be nested.</p>
+ * <p>
+ * These tags may be nested.
+ * </p>
*
* @return component's description <code>String</code>
*/
@@ -340,29 +364,30 @@ public abstract class AbstractComponent
return this.description;
}
- /**
- * Sets the component's description. See {@link #getDescription()} for
- * more information on what the description is. This method will trigger
- * a {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
- *
- * @param description the new description string for the component.
+ /**
+ * Sets the component's description. See {@link #getDescription()} for more
+ * information on what the description is. This method will trigger a
+ * {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
+ *
+ * @param description
+ * the new description string for the component.
*/
public void setDescription(String description) {
this.description = description;
requestRepaint();
}
- /* Gets the component's parent component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the component's parent component. Don't add a JavaDoc comment here,
+ * we use the default documentation from implemented interface.
*/
public Component getParent() {
return this.parent;
}
- /* Sets the parent component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Sets the parent component. Don't add a JavaDoc comment here, we use the
+ * default documentation from implemented interface.
*/
public void setParent(Component parent) {
@@ -384,35 +409,38 @@ public abstract class AbstractComponent
attach();
}
- /**
+ /**
* Gets the error message for this component.
*
- * @return ErrorMessage containing the description of the error state
- * of the component or null, if the component contains no errors. Extending
- * classes should override this method if they support other error message
- * types such as validation errors or buffering errors. The returned error
- * message contains information about all the errors.
+ * @return ErrorMessage containing the description of the error state of the
+ * component or null, if the component contains no errors. Extending
+ * classes should override this method if they support other error
+ * message types such as validation errors or buffering errors. The
+ * returned error message contains information about all the errors.
*/
public ErrorMessage getErrorMessage() {
return this.componentError;
}
- /**
- * Gets the component's error message.
+ /**
+ * Gets the component's error message.
+ *
* @link Terminal.ErrorMessage#ErrorMessage(String, int)
- *
+ *
* @return the component's error message.
*/
public ErrorMessage getComponentError() {
return this.componentError;
}
- /**
- * Sets the component's error message. The message may contain certain
- * XML tags, for more information see
+ /**
+ * Sets the component's error message. The message may contain certain XML
+ * tags, for more information see
+ *
* @link Component.ErrorMessage#ErrorMessage(String, int)
*
- * @param componentError the new <code>ErrorMessage</code> of the component.
+ * @param componentError
+ * the new <code>ErrorMessage</code> of the component.
*/
public void setComponentError(ErrorMessage componentError) {
this.componentError = componentError;
@@ -420,26 +448,26 @@ public abstract class AbstractComponent
requestRepaint();
}
- /* Tests if the component is in read-only mode.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Tests if the component is in read-only mode. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public boolean isReadOnly() {
return readOnly;
}
- /* Sets the component's read-only mode.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Sets the component's read-only mode. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
*/
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
requestRepaint();
}
- /* Gets the parent window of the component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the parent window of the component. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public Window getWindow() {
if (parent == null)
@@ -448,23 +476,24 @@ public abstract class AbstractComponent
return parent.getWindow();
}
- /* Notify the component that it's attached to a window.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Notify the component that it's attached to a window. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public void attach() {
}
- /* Detach the component from application.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Detach the component from application. Don't add a JavaDoc comment here,
+ * we use the default documentation from implemented interface.
*/
public void detach() {
}
- /* Gets the parent application of the component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the parent application of the component. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public Application getApplication() {
if (parent == null)
@@ -480,9 +509,9 @@ public abstract class AbstractComponent
repaintRequestListenersNotified = false;
}
- /* Paints the component into a UIDL stream.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Paints the component into a UIDL stream. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public final void paint(PaintTarget target) throws PaintException {
@@ -523,15 +552,17 @@ public abstract class AbstractComponent
repaintRequestListenersNotified = false;
}
- /**
- * Paints any needed component-specific things to the given UIDL
- * stream. The more general {@link #paint(PaintTarget)} method handles
- * all general attributes common to all components, and it calls this
- * method to paint any component-specific attributes to the UIDL stream.
+ /**
+ * Paints any needed component-specific things to the given UIDL stream. The
+ * more general {@link #paint(PaintTarget)} method handles all general
+ * attributes common to all components, and it calls this method to paint
+ * any component-specific attributes to the UIDL stream.
*
- * @param target the target UIDL stream where the component should paint
- * itself to
- * @throws PaintException if the paint operation failed.
+ * @param target
+ * the target UIDL stream where the component should paint itself
+ * to
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
@@ -555,9 +586,10 @@ public abstract class AbstractComponent
fireRequestRepaintEvent(alreadyNotified);
}
- /**
+ /**
* Fires the repaint request event.
- * @param alreadyNotified
+ *
+ * @param alreadyNotified
*/
private void fireRequestRepaintEvent(Collection alreadyNotified) {
@@ -566,18 +598,15 @@ public abstract class AbstractComponent
// Notify the listeners
if (repaintRequestListeners != null
- && !repaintRequestListeners.isEmpty()) {
+ && !repaintRequestListeners.isEmpty()) {
Object[] listeners = repaintRequestListeners.toArray();
RepaintRequestEvent event = new RepaintRequestEvent(this);
for (int i = 0; i < listeners.length; i++) {
if (alreadyNotified == null)
alreadyNotified = new LinkedList();
if (!alreadyNotified.contains(listeners[i])) {
- (
- (
- RepaintRequestListener) listeners[i])
- .repaintRequested(
- event);
+ ((RepaintRequestListener) listeners[i])
+ .repaintRequested(event);
alreadyNotified.add(listeners[i]);
repaintRequestListenersNotified = true;
}
@@ -611,17 +640,19 @@ public abstract class AbstractComponent
/* Component variable changes ************************************** */
- /* Invoked when the value of a variable has changed.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Invoked when the value of a variable has changed. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public void changeVariables(Object source, Map variables) {
}
- /* Adds a variable-change dependency to this component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Adds a variable-change dependency to this component. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public void dependsOn(VariableOwner depended) {
@@ -634,9 +665,9 @@ public abstract class AbstractComponent
dependencies.add(depended);
}
- /* Removes a dependency from the component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Removes a dependency from the component. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
*/
public void removeDirectDependency(VariableOwner depended) {
@@ -645,9 +676,9 @@ public abstract class AbstractComponent
dependencies.remove(depended);
}
- /* Gets the set of depended components.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the set of depended components. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
*/
public Set getDirectDependencies() {
return dependencies;
@@ -659,10 +690,9 @@ public abstract class AbstractComponent
static {
try {
- COMPONENT_EVENT_METHOD =
- Component.Listener.class.getDeclaredMethod(
- "componentEvent",
- new Class[] { Component.Event.class });
+ COMPONENT_EVENT_METHOD = Component.Listener.class
+ .getDeclaredMethod("componentEvent",
+ new Class[] { Component.Event.class });
} catch (java.lang.NoSuchMethodException e) {
// This should never happen
e.printStackTrace();
@@ -670,24 +700,26 @@ public abstract class AbstractComponent
}
}
- /**
+ /**
* <p>
- * Registers a new listener with the specified activation method to
- * listen events generated by this component. If the activation method
- * does not have any arguments the event object will not be passed to it
- * when it's called.
+ * Registers a new listener with the specified activation method to listen
+ * events generated by this component. If the activation method does not
+ * have any arguments the event object will not be passed to it when it's
+ * called.
* </p>
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the type of the listened event. Events of this type or
- * its subclasses activate the listener.
- * @param object the object instance who owns the activation method.
- * @param method the activation method.
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param object
+ * the object instance who owns the activation method.
+ * @param method
+ * the activation method.
*/
public void addListener(Class eventType, Object object, Method method) {
if (eventRouter == null)
@@ -695,12 +727,12 @@ public abstract class AbstractComponent
eventRouter.addListener(eventType, object, method);
}
- /**
+ /**
* <p>
- * Registers a new listener with the specified activation method to
- * listen events generated by this component. If the activation method
- * does not have any arguments the event object will not be passed to it
- * when it's called.
+ * Registers a new listener with the specified activation method to listen
+ * events generated by this component. If the activation method does not
+ * have any arguments the event object will not be passed to it when it's
+ * called.
* </p>
*
* <p>
@@ -711,72 +743,76 @@ public abstract class AbstractComponent
* </p>
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the type of the listened event. Events of this type or
- * its subclasses activate the listener.
- * @param object the object instance who owns the activation method.
- * @param methodName the name of the activation method.
- */
- public void addListener(
- Class eventType,
- Object object,
- String methodName) {
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param object
+ * the object instance who owns the activation method.
+ * @param methodName
+ * the name of the activation method.
+ */
+ public void addListener(Class eventType, Object object, String methodName) {
if (eventRouter == null)
eventRouter = new EventRouter();
eventRouter.addListener(eventType, object, methodName);
}
- /**
- * Removes all registered listeners matching the given parameters.
- * Since this method receives the event type and the listener object as
+ /**
+ * Removes all registered listeners matching the given parameters. Since
+ * this method receives the event type and the listener object as
* parameters, it will unregister all <code>object</code>'s methods that
* are registered to listen to events of type <code>eventType</code>
* generated by this component.
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the exact event type the <code>object</code> listens to.
- * @param target the target object that has registered to listen to events
- * of type <code>eventType</code> with one or more methods.
+ * @param eventType
+ * the exact event type the <code>object</code> listens to.
+ * @param target
+ * the target object that has registered to listen to events of
+ * type <code>eventType</code> with one or more methods.
*/
public void removeListener(Class eventType, Object target) {
if (eventRouter != null)
eventRouter.removeListener(eventType, target);
}
- /**
- * Removes one registered listener method. The given method owned by
- * the given object will no longer be called when the specified events
- * are generated by this component.
+ /**
+ * Removes one registered listener method. The given method owned by the
+ * given object will no longer be called when the specified events are
+ * generated by this component.
*
- * <p>For more information on the inheritable event mechanism
- * see the
- * {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.</p>
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
+ * </p>
*
- * @param eventType the exact event type the <code>object</code> listens to.
- * @param target target object that has registered to listen to events
- * of type <code>eventType</code> with one or more methods.
- * @param method the method owned by <code>target</code> that's
- * registered to listen to events of type <code>eventType</code>.
+ * @param eventType
+ * the exact event type the <code>object</code> listens to.
+ * @param target
+ * target object that has registered to listen to events of type
+ * <code>eventType</code> with one or more methods.
+ * @param method
+ * the method owned by <code>target</code> that's registered to
+ * listen to events of type <code>eventType</code>.
*/
public void removeListener(Class eventType, Object target, Method method) {
if (eventRouter != null)
eventRouter.removeListener(eventType, target, method);
}
- /**
+ /**
* <p>
- * Removes one registered listener method. The given method owned by
- * the given object will no longer be called when the specified events
- * are generated by this component.
+ * Removes one registered listener method. The given method owned by the
+ * given object will no longer be called when the specified events are
+ * generated by this component.
* </p>
*
* <p>
@@ -787,28 +823,29 @@ public abstract class AbstractComponent
* </p>
*
* <p>
- * For more information on the inheritable event mechanism
- * see the
+ * For more information on the inheritable event mechanism see the
* {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
* </p>
*
- * @param eventType the exact event type the <code>object</code> listens to.
- * @param target the target object that has registered to listen to events
- * of type <code>eventType</code> with one or more methods.
- * @param methodName the name of the method owned by <code>target</code>
- * that's registered to listen to events of type <code>eventType</code>.
- */
- public void removeListener(
- Class eventType,
- Object target,
- String methodName) {
+ * @param eventType
+ * the exact event type the <code>object</code> listens to.
+ * @param target
+ * the target object that has registered to listen to events of
+ * type <code>eventType</code> with one or more methods.
+ * @param methodName
+ * the name of the method owned by <code>target</code> that's
+ * registered to listen to events of type <code>eventType</code>.
+ */
+ public void removeListener(Class eventType, Object target, String methodName) {
if (eventRouter != null)
eventRouter.removeListener(eventType, target, methodName);
}
- /**
+ /**
* Sends the event to all listeners.
- * @param event the Event to be sent to all listeners.
+ *
+ * @param event
+ * the Event to be sent to all listeners.
*/
protected void fireEvent(Component.Event event) {
@@ -819,69 +856,67 @@ public abstract class AbstractComponent
/* Component event framework *************************************** */
- /* Registers a new listener to listen events generated by this
- * component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Registers a new listener to listen events generated by this component.
+ * Don't add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public void addListener(Component.Listener listener) {
if (eventRouter == null)
eventRouter = new EventRouter();
- eventRouter.addListener(
- Component.Event.class,
- listener,
- COMPONENT_EVENT_METHOD);
+ eventRouter.addListener(Component.Event.class, listener,
+ COMPONENT_EVENT_METHOD);
}
- /* Removes a previously registered listener from this component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Removes a previously registered listener from this component. Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
*/
public void removeListener(Component.Listener listener) {
if (eventRouter != null) {
- eventRouter.removeListener(
- Component.Event.class,
- listener,
- COMPONENT_EVENT_METHOD);
+ eventRouter.removeListener(Component.Event.class, listener,
+ COMPONENT_EVENT_METHOD);
}
}
- /**
- * Emits the component event. It is transmitted to all registered
- * listeners interested in such events.
+ /**
+ * Emits the component event. It is transmitted to all registered listeners
+ * interested in such events.
*/
protected void fireComponentEvent() {
fireEvent(new Component.Event(this));
}
- /**
+ /**
* Emits the component error event. It is transmitted to all registered
* listeners interested in such events.
*/
protected void fireComponentErrorEvent() {
- fireEvent(new Component.ErrorEvent(this.getComponentError(),this));
+ fireEvent(new Component.ErrorEvent(this.getComponentError(), this));
}
- /**
+ /**
* Sets the application specific data object.
- *
- * @param data the Application specific data.
- * @since 3.1
- */
- public void setData(Object data) {
- this.applicationData = data;
- }
-
- /**
- * Gets the application specific data.
- *
- * @return the Application specific data set with setData function.
- * @since 3.1
- */
- public Object getData() {
- return this.applicationData;
- }
+ *
+ * @param data
+ * the Application specific data.
+ * @since 3.1
+ */
+ public void setData(Object data) {
+ this.applicationData = data;
+ }
+
+ /**
+ * Gets the application specific data.
+ *
+ * @return the Application specific data set with setData function.
+ * @since 3.1
+ */
+ public Object getData() {
+ return this.applicationData;
+ }
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java
index 6bed25c26d..c307930356 100644
--- a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java
+++ b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -32,101 +32,100 @@ import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.Iterator;
-/**
+/**
* Extension to {@link AbstractComponent} that defines the default
* implementation for the methods in {@link ComponentContainer}. Basic UI
- * components that need to contain other components inherit this class to
- * easily qualify as a component container.
+ * components that need to contain other components inherit this class to easily
+ * qualify as a component container.
*
- * @author IT Mill Ltd
- * @version @VERSION@
+ * @author IT Mill Ltd
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public abstract class AbstractComponentContainer
-extends AbstractComponent implements ComponentContainer {
+public abstract class AbstractComponentContainer extends AbstractComponent
+ implements ComponentContainer {
- /**
- * Constructs a new component container.
+ /**
+ * Constructs a new component container.
*/
public AbstractComponentContainer() {
super();
}
- /**
- * Removes all components from the container. This should probably be
- * reimplemented in extending classes for a more powerfull
- * implementation.
- */
- public void removeAllComponents() {
- LinkedList l = new LinkedList();
+ /**
+ * Removes all components from the container. This should probably be
+ * reimplemented in extending classes for a more powerfull implementation.
+ */
+ public void removeAllComponents() {
+ LinkedList l = new LinkedList();
// Adds all components
- for (Iterator i = getComponentIterator(); i.hasNext();)
- l.add(i.next());
-
- // Removes all component
- for (Iterator i = l.iterator(); i.hasNext();)
- removeComponent((Component)i.next());
- }
-
- /* Moves all components from an another container into this container.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ for (Iterator i = getComponentIterator(); i.hasNext();)
+ l.add(i.next());
+
+ // Removes all component
+ for (Iterator i = l.iterator(); i.hasNext();)
+ removeComponent((Component) i.next());
+ }
+
+ /*
+ * Moves all components from an another container into this container. Don't
+ * add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
*/
public void moveComponentsFrom(ComponentContainer source) {
LinkedList components = new LinkedList();
- for (Iterator i = source.getComponentIterator(); i.hasNext();)
+ for (Iterator i = source.getComponentIterator(); i.hasNext();)
components.add(i.next());
-
+
for (Iterator i = components.iterator(); i.hasNext();) {
Component c = (Component) i.next();
source.removeComponent(c);
addComponent(c);
}
- }
-
- /**
- * Notifies all contained components that the container is attached to
- * a window.
+ }
+
+ /**
+ * Notifies all contained components that the container is attached to a
+ * window.
*
* @see com.itmill.toolkit.ui.Component#attach()
*/
public void attach() {
super.attach();
-
+
for (Iterator i = getComponentIterator(); i.hasNext();)
- ((Component)i.next()).attach();
+ ((Component) i.next()).attach();
}
- /**
- * Notifies all contained components that the container is detached
- * from a window.
+ /**
+ * Notifies all contained components that the container is detached from a
+ * window.
*
* @see com.itmill.toolkit.ui.Component#detach()
*/
public void detach() {
super.detach();
-
+
for (Iterator i = getComponentIterator(); i.hasNext();)
- ((Component)i.next()).detach();
+ ((Component) i.next()).detach();
}
-
/* Events ************************************************************ */
private static final Method COMPONENT_ATTACHED_METHOD;
+
private static final Method COMPONENT_DETACHED_METHOD;
static {
try {
- COMPONENT_ATTACHED_METHOD =
- ComponentAttachListener.class.getDeclaredMethod(
- "componentAttachedToContainer",
- new Class[] { ComponentAttachEvent.class });
- COMPONENT_DETACHED_METHOD =
- ComponentDetachListener.class.getDeclaredMethod(
- "componentDetachedFromContainer",
- new Class[] { ComponentDetachEvent.class });
+ COMPONENT_ATTACHED_METHOD = ComponentAttachListener.class
+ .getDeclaredMethod("componentAttachedToContainer",
+ new Class[] { ComponentAttachEvent.class });
+ COMPONENT_DETACHED_METHOD = ComponentDetachListener.class
+ .getDeclaredMethod("componentDetachedFromContainer",
+ new Class[] { ComponentDetachEvent.class });
} catch (java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
@@ -135,46 +134,57 @@ extends AbstractComponent implements ComponentContainer {
/* documented in interface */
public void addListener(ComponentAttachListener listener) {
- addListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD);
+ addListener(ComponentContainer.ComponentAttachEvent.class, listener,
+ COMPONENT_ATTACHED_METHOD);
}
/* documented in interface */
public void addListener(ComponentDetachListener listener) {
- addListener(ComponentContainer.ComponentDetachEvent.class, listener, COMPONENT_DETACHED_METHOD);
+ addListener(ComponentContainer.ComponentDetachEvent.class, listener,
+ COMPONENT_DETACHED_METHOD);
}
/* documented in interface */
public void removeListener(ComponentAttachListener listener) {
- removeListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD);
+ removeListener(ComponentContainer.ComponentAttachEvent.class, listener,
+ COMPONENT_ATTACHED_METHOD);
}
/* documented in interface */
public void removeListener(ComponentDetachListener listener) {
- removeListener(ComponentContainer.ComponentDetachEvent.class, listener, COMPONENT_DETACHED_METHOD);
+ removeListener(ComponentContainer.ComponentDetachEvent.class, listener,
+ COMPONENT_DETACHED_METHOD);
}
- /**
- * Fires the component attached event. This should be called by the addComponent
- * methods after the component have been added to this container.
- * @param component the component that has been added to this container.
+ /**
+ * Fires the component attached event. This should be called by the
+ * addComponent methods after the component have been added to this
+ * container.
+ *
+ * @param component
+ * the component that has been added to this container.
*/
protected void fireComponentAttachEvent(Component component) {
- fireEvent(new ComponentAttachEvent(this,component));
+ fireEvent(new ComponentAttachEvent(this, component));
}
- /**
- * Fires the component detached event. This should be called by the removeComponent
- * methods after the component have been removed from this container.
- * @param component the component that has been removed from this container.
+ /**
+ * Fires the component detached event. This should be called by the
+ * removeComponent methods after the component have been removed from this
+ * container.
+ *
+ * @param component
+ * the component that has been removed from this container.
*/
protected void fireComponentDetachEvent(Component component) {
- fireEvent(new ComponentAttachEvent(this,component));
+ fireEvent(new ComponentAttachEvent(this, component));
}
-
- /**
+
+ /**
* This only implements the events and component parent calls. The extending
- * classes must implement component list maintenance and call this method
+ * classes must implement component list maintenance and call this method
* after component list maintenance.
+ *
* @see com.itmill.toolkit.ui.ComponentContainer#addComponent(Component)
*/
public void addComponent(Component c) {
@@ -182,10 +192,11 @@ extends AbstractComponent implements ComponentContainer {
fireComponentAttachEvent(c);
}
- /**
+ /**
* This only implements the events and component parent calls. The extending
- * classes must implement component list maintenance and call this method
+ * classes must implement component list maintenance and call this method
* before component list maintenance.
+ *
* @see com.itmill.toolkit.ui.ComponentContainer#removeComponent(Component)
*/
public void removeComponent(Component c) {
diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java
index 2e1f7983b6..2609cecc68 100644
--- a/src/com/itmill/toolkit/ui/AbstractField.java
+++ b/src/com/itmill/toolkit/ui/AbstractField.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -70,890 +70,900 @@ import com.itmill.toolkit.terminal.PaintTarget;
* @since 3.0
*/
public abstract class AbstractField extends AbstractComponent implements Field,
- Property.ReadOnlyStatusChangeNotifier {
-
- /* Private members ************************************************* */
-
- private boolean delayedFocus;
-
- /**
- * Value of the datafield.
- */
- private Object value;
-
- /**
- * Connected data-source.
- */
- private Property dataSource = null;
-
- /**
- * The list of validators.
- */
- private LinkedList validators = null;
-
- /**
- * Auto commit mode.
- */
- private boolean writeTroughMode = true;
-
- /**
- * Reads the value from data-source, when it is not modified.
- */
- private boolean readTroughMode = true;
-
- /**
- * Is the field modified but not committed.
- */
- private boolean modified = false;
-
- /**
- * Current source exception.
- */
- private Buffered.SourceException currentBufferedSourceException = null;
-
- /**
- * Are the invalid values alloved in fields ?
- */
- private boolean invalidAllowed = true;
-
- /**
- * Are the invalid values committed ?
- */
- private boolean invalidCommitted = false;
-
- /**
- * The tab order number of this field.
- */
- private int tabIndex = 0;
-
- /**
- * Unique focusable id.
- */
- private long focusableId = -1;
-
- /**
- * Required field.
- */
- private boolean required = false;
-
- /* Component basics ************************************************ */
-
- public AbstractField() {
- this.focusableId = Window.getNewFocusableId(this);
- }
-
- /*
- * Paints the field. Don't add a JavaDoc comment here, we use the default
- * documentation from the implemented interface.
- */
- public void paintContent(PaintTarget target) throws PaintException {
-
- // Focus control id
- if (this.focusableId > 0) {
- target.addAttribute("focusid", this.focusableId);
- }
-
- // The tab ordering number
- if (this.tabIndex > 0)
- target.addAttribute("tabindex", this.tabIndex);
-
- // If the field is modified, but not committed, set modified attribute
- if (isModified())
- target.addAttribute("modified", true);
-
- // Adds the required attribute
- if (isRequired())
- target.addAttribute("required", true);
-
- }
-
- /*
- * Gets the field type Don't add a JavaDoc comment here, we use the default
- * documentation from the implemented interface.
- */
- public abstract Class getType();
-
- /**
- * The abstract field is read only also if the data source is in readonly
- * mode.
- */
- public boolean isReadOnly() {
- return super.isReadOnly()
- || (dataSource != null && dataSource.isReadOnly());
- }
-
- /**
- * Changes the readonly state and throw read-only status change events.
- *
- * @see com.itmill.toolkit.ui.Component#setReadOnly(boolean)
- */
- public void setReadOnly(boolean readOnly) {
- super.setReadOnly(readOnly);
- fireReadOnlyStatusChange();
- }
-
- /**
- * Tests if the invalid data is committed to datasource.
- * @see com.itmill.toolkit.data.BufferedValidatable#isInvalidCommitted()
- */
- public boolean isInvalidCommitted() {
- return invalidCommitted;
- }
-
+ Property.ReadOnlyStatusChangeNotifier {
+
+ /* Private members ************************************************* */
+
+ private boolean delayedFocus;
+
+ /**
+ * Value of the datafield.
+ */
+ private Object value;
+
+ /**
+ * Connected data-source.
+ */
+ private Property dataSource = null;
+
+ /**
+ * The list of validators.
+ */
+ private LinkedList validators = null;
+
+ /**
+ * Auto commit mode.
+ */
+ private boolean writeTroughMode = true;
+
+ /**
+ * Reads the value from data-source, when it is not modified.
+ */
+ private boolean readTroughMode = true;
+
+ /**
+ * Is the field modified but not committed.
+ */
+ private boolean modified = false;
+
+ /**
+ * Current source exception.
+ */
+ private Buffered.SourceException currentBufferedSourceException = null;
+
+ /**
+ * Are the invalid values alloved in fields ?
+ */
+ private boolean invalidAllowed = true;
+
+ /**
+ * Are the invalid values committed ?
+ */
+ private boolean invalidCommitted = false;
+
+ /**
+ * The tab order number of this field.
+ */
+ private int tabIndex = 0;
+
+ /**
+ * Unique focusable id.
+ */
+ private long focusableId = -1;
+
+ /**
+ * Required field.
+ */
+ private boolean required = false;
+
+ /* Component basics ************************************************ */
+
+ public AbstractField() {
+ this.focusableId = Window.getNewFocusableId(this);
+ }
+
+ /*
+ * Paints the field. Don't add a JavaDoc comment here, we use the default
+ * documentation from the implemented interface.
+ */
+ public void paintContent(PaintTarget target) throws PaintException {
+
+ // Focus control id
+ if (this.focusableId > 0) {
+ target.addAttribute("focusid", this.focusableId);
+ }
+
+ // The tab ordering number
+ if (this.tabIndex > 0)
+ target.addAttribute("tabindex", this.tabIndex);
+
+ // If the field is modified, but not committed, set modified attribute
+ if (isModified())
+ target.addAttribute("modified", true);
+
+ // Adds the required attribute
+ if (isRequired())
+ target.addAttribute("required", true);
+
+ }
+
+ /*
+ * Gets the field type Don't add a JavaDoc comment here, we use the default
+ * documentation from the implemented interface.
+ */
+ public abstract Class getType();
+
+ /**
+ * The abstract field is read only also if the data source is in readonly
+ * mode.
+ */
+ public boolean isReadOnly() {
+ return super.isReadOnly()
+ || (dataSource != null && dataSource.isReadOnly());
+ }
+
+ /**
+ * Changes the readonly state and throw read-only status change events.
+ *
+ * @see com.itmill.toolkit.ui.Component#setReadOnly(boolean)
+ */
+ public void setReadOnly(boolean readOnly) {
+ super.setReadOnly(readOnly);
+ fireReadOnlyStatusChange();
+ }
+
+ /**
+ * Tests if the invalid data is committed to datasource.
+ *
+ * @see com.itmill.toolkit.data.BufferedValidatable#isInvalidCommitted()
+ */
+ public boolean isInvalidCommitted() {
+ return invalidCommitted;
+ }
+
/**
* Sets if the invalid data should be committed to datasource.
+ *
* @see com.itmill.toolkit.data.BufferedValidatable#setInvalidCommitted(boolean)
*/
- public void setInvalidCommitted(boolean isCommitted) {
- this.invalidCommitted = isCommitted;
- }
-
- /*
- * Saves the current value to the data source Don't add a JavaDoc comment
- * here, we use the default documentation from the implemented interface.
- */
- public void commit() throws Buffered.SourceException {
- if (dataSource != null && (isInvalidCommitted() || isValid())
- && !dataSource.isReadOnly()) {
- Object newValue = getValue();
- try {
-
- // Commits the value to datasource.
- dataSource.setValue(newValue);
-
- } catch (Throwable e) {
-
- // Sets the buffering state.
- currentBufferedSourceException = new Buffered.SourceException(
- this, e);
- requestRepaint();
-
- // Throws the source exception.
- throw currentBufferedSourceException;
- }
- }
-
- boolean repaintNeeded = false;
-
- // The abstract field is not modified anymore
- if (modified) {
- modified = false;
- repaintNeeded = true;
- }
-
- // If successful, remove set the buffering state to be ok
- if (currentBufferedSourceException != null) {
- currentBufferedSourceException = null;
- repaintNeeded = true;
- }
-
- if (repaintNeeded)
- requestRepaint();
- }
-
- /*
- * Updates the value from the data source. Don't add a JavaDoc comment here,
- * we use the default documentation from the implemented interface.
- */
- public void discard() throws Buffered.SourceException {
- if (dataSource != null) {
-
- // Gets the correct value from datasource
- Object newValue;
- try {
-
- // Discards buffer by overwriting from datasource
- newValue = dataSource.getValue();
-
- // If successful, remove set the buffering state to be ok
- if (currentBufferedSourceException != null) {
- currentBufferedSourceException = null;
- requestRepaint();
- }
- } catch (Throwable e) {
-
- // Sets the buffering state
- currentBufferedSourceException = new Buffered.SourceException(
- this, e);
- requestRepaint();
-
- // Throws the source exception
- throw currentBufferedSourceException;
- }
-
- boolean wasModified = isModified();
- modified = false;
-
- // If the new value differs from the previous one
- if ((newValue == null && value != null)
- || (newValue != null && !newValue.equals(value))) {
- setInternalValue(newValue);
- fireValueChange();
- }
-
- // If the value did not change, but the modification status did
- else if (wasModified) {
- requestRepaint();
- }
- }
- }
-
- /*
- * Has the field been modified since the last commit()? Don't add a JavaDoc
- * comment here, we use the default documentation from the implemented
- * interface.
- */
- public boolean isModified() {
- return modified;
- }
-
- /*
- * Tests if the field is in write-through mode. Don't add a JavaDoc comment
- * here, we use the default documentation from the implemented interface.
- */
- public boolean isWriteThrough() {
- return writeTroughMode;
- }
-
- /*
- * Sets the field's write-through mode to the specified status Don't add a
- * JavaDoc comment here, we use the default documentation from the
- * implemented interface.
- */
- public void setWriteThrough(boolean writeTrough)
- throws Buffered.SourceException {
- if (writeTroughMode == writeTrough)
- return;
- writeTroughMode = writeTrough;
- if (writeTroughMode)
- commit();
- }
-
- /*
- * Tests if the field is in read-through mode. Don't add a JavaDoc comment
- * here, we use the default documentation from the implemented interface.
- */
- public boolean isReadThrough() {
- return readTroughMode;
- }
-
- /*
- * Sets the field's read-through mode to the specified status Don't add a
- * JavaDoc comment here, we use the default documentation from the
- * implemented interface.
- */
- public void setReadThrough(boolean readTrough)
- throws Buffered.SourceException {
- if (readTroughMode == readTrough)
- return;
- readTroughMode = readTrough;
- if (!isModified() && readTroughMode && dataSource != null) {
- setInternalValue(dataSource.getValue());
- fireValueChange();
- }
- }
-
- /* Property interface implementation ******************************* */
-
- /**
- * Returns the value of the Property in human readable textual format.
- * @see java.lang.Object#toString()
- */
- public String toString() {
- Object value = getValue();
- if (value == null)
- return null;
- return getValue().toString();
- }
-
- /**
- * Gets the current value of the field. This is the visible, modified and
- * possible invalid value the user have entered to the field. In the
- * read-through mode, the abstract buffer is also updated and validation is
- * performed.
- *
- * @return the current value of the field.
- */
- public Object getValue() {
-
- // Give the value from abstract buffers if the field if possible
- if (dataSource == null || !isReadThrough() || isModified())
- return value;
-
- Object newValue = dataSource.getValue();
- if ((newValue == null && value != null)
- || (newValue != null && !newValue.equals(value))) {
- setInternalValue(newValue);
- fireValueChange();
- }
-
- return newValue;
- }
-
- /**
- * Sets the value of the field.
- *
- * @param newValue
- * the New value of the field.
- * @throws Property.ReadOnlyException
- * @throws Property.ConversionException
- */
- public void setValue(Object newValue) throws Property.ReadOnlyException,
- Property.ConversionException {
-
- if ((newValue == null && value != null)
- || (newValue != null && !newValue.equals(value))) {
-
- // Read only fields can not be changed
- if (isReadOnly())
- throw new Property.ReadOnlyException();
-
- // If invalid values are not allowed, the value must be checked
- if (!isInvalidAllowed()) {
- Collection v = getValidators();
- if (v != null)
- for (Iterator i = v.iterator(); i.hasNext();)
- ((Validator) i.next()).validate(newValue);
- }
-
- // Changes the value
- setInternalValue(newValue);
- modified = dataSource != null;
-
- // In write trough mode , try to commit
- if (isWriteThrough() && dataSource != null
- && (isInvalidCommitted() || isValid())) {
- try {
-
- // Commits the value to datasource
- dataSource.setValue(newValue);
-
- // The buffer is now unmodified
- modified = false;
-
- } catch (Throwable e) {
-
- // Sets the buffering state
- currentBufferedSourceException = new Buffered.SourceException(
- this, e);
- requestRepaint();
-
- // Throws the source exception
- throw currentBufferedSourceException;
- }
- }
-
- // If successful, remove set the buffering state to be ok
- if (currentBufferedSourceException != null) {
- currentBufferedSourceException = null;
- requestRepaint();
- }
-
- // Fires the value change
- fireValueChange();
- }
- }
-
- /* External data source ******************************************** */
-
- /**
- * Gets the current data source of the field, if any.
- *
- * @return the current data source as a Property, or <code>null</code> if
- * none defined.
- */
- public Property getPropertyDataSource() {
- return dataSource;
- }
-
- /**
- * <p>
- * Sets the specified Property as the data source for the field. All
- * uncommitted changes to the field are discarded and the value is refreshed
- * from the new data source.
- * </p>
- *
- * <p>
- * If the datasource has any validators, the same validators are added to
- * the field. Because the default behavior of the field is to allow invalid
- * values, but not to allow committing them, this only adds visual error
- * messages to fields and do not allow committing them as long as the value
- * is invalid. After the value is valid, the error message is not shown and
- * the commit can be done normally.
- * </p>
- *
- * @param newDataSource
- * the new data source Property.
- */
- public void setPropertyDataSource(Property newDataSource) {
-
- // Saves the old value
- Object oldValue = value;
-
- // Discards all changes to old datasource
- try {
- discard();
- } catch (Buffered.SourceException ignored) {
- }
-
- // Stops listening the old data source changes
- if (dataSource != null
- && Property.ValueChangeNotifier.class
- .isAssignableFrom(dataSource.getClass()))
- ((Property.ValueChangeNotifier) dataSource).removeListener(this);
-
- // Sets the new data source
- dataSource = newDataSource;
-
- // Gets the value from source
- try {
- if (dataSource != null)
- setInternalValue(dataSource.getValue());
- modified = false;
- } catch (Throwable e) {
- currentBufferedSourceException = new Buffered.SourceException(this,
- e);
- modified = true;
- }
-
- // Listens the new data source if possible
- if (dataSource instanceof Property.ValueChangeNotifier)
- ((Property.ValueChangeNotifier) dataSource).addListener(this);
-
- // Copy the validators from the data source
- if (dataSource instanceof Validatable) {
- Collection validators = ((Validatable) dataSource).getValidators();
- if (validators != null)
- for (Iterator i = validators.iterator(); i.hasNext();)
- addValidator((Validator) i.next());
- }
-
- // Fires value change if the value has changed
- if ((value != oldValue)
- && ((value != null && !value.equals(oldValue)) || value == null))
- fireValueChange();
- }
-
- /* Validation ****************************************************** */
-
- /**
- * Adds a new validator for the field's value. All validators added to a
- * field are checked each time the its value changes.
- *
- * @param validator
- * the new validator to be added.
- */
- public void addValidator(Validator validator) {
- if (validators == null)
- validators = new LinkedList();
- validators.add(validator);
- }
-
- /**
- * Gets the validators of the field.
- *
- * @return the Unmodifiable collection that holds all validators for the field.
- */
- public Collection getValidators() {
- if (validators == null || validators.isEmpty())
- return null;
- return Collections.unmodifiableCollection(validators);
- }
-
- /**
- * Removes the validator from the field.
- *
- * @param validator
- * the validator to remove.
- */
- public void removeValidator(Validator validator) {
- if (validators != null)
- validators.remove(validator);
- }
-
- /**
- * Tests the current value against all registered validators.
- *
- * @return <code>true</code> if all registered validators claim that the
- * current value is valid, <code>false</code> otherwise.
- */
- public boolean isValid() {
-
- if (validators == null)
- return true;
-
- Object value = getValue();
- for (Iterator i = validators.iterator(); i.hasNext();)
- if (!((Validator) i.next()).isValid(value))
- return false;
-
- return true;
- }
-
+ public void setInvalidCommitted(boolean isCommitted) {
+ this.invalidCommitted = isCommitted;
+ }
+
+ /*
+ * Saves the current value to the data source Don't add a JavaDoc comment
+ * here, we use the default documentation from the implemented interface.
+ */
+ public void commit() throws Buffered.SourceException {
+ if (dataSource != null && (isInvalidCommitted() || isValid())
+ && !dataSource.isReadOnly()) {
+ Object newValue = getValue();
+ try {
+
+ // Commits the value to datasource.
+ dataSource.setValue(newValue);
+
+ } catch (Throwable e) {
+
+ // Sets the buffering state.
+ currentBufferedSourceException = new Buffered.SourceException(
+ this, e);
+ requestRepaint();
+
+ // Throws the source exception.
+ throw currentBufferedSourceException;
+ }
+ }
+
+ boolean repaintNeeded = false;
+
+ // The abstract field is not modified anymore
+ if (modified) {
+ modified = false;
+ repaintNeeded = true;
+ }
+
+ // If successful, remove set the buffering state to be ok
+ if (currentBufferedSourceException != null) {
+ currentBufferedSourceException = null;
+ repaintNeeded = true;
+ }
+
+ if (repaintNeeded)
+ requestRepaint();
+ }
+
+ /*
+ * Updates the value from the data source. Don't add a JavaDoc comment here,
+ * we use the default documentation from the implemented interface.
+ */
+ public void discard() throws Buffered.SourceException {
+ if (dataSource != null) {
+
+ // Gets the correct value from datasource
+ Object newValue;
+ try {
+
+ // Discards buffer by overwriting from datasource
+ newValue = dataSource.getValue();
+
+ // If successful, remove set the buffering state to be ok
+ if (currentBufferedSourceException != null) {
+ currentBufferedSourceException = null;
+ requestRepaint();
+ }
+ } catch (Throwable e) {
+
+ // Sets the buffering state
+ currentBufferedSourceException = new Buffered.SourceException(
+ this, e);
+ requestRepaint();
+
+ // Throws the source exception
+ throw currentBufferedSourceException;
+ }
+
+ boolean wasModified = isModified();
+ modified = false;
+
+ // If the new value differs from the previous one
+ if ((newValue == null && value != null)
+ || (newValue != null && !newValue.equals(value))) {
+ setInternalValue(newValue);
+ fireValueChange();
+ }
+
+ // If the value did not change, but the modification status did
+ else if (wasModified) {
+ requestRepaint();
+ }
+ }
+ }
+
+ /*
+ * Has the field been modified since the last commit()? Don't add a JavaDoc
+ * comment here, we use the default documentation from the implemented
+ * interface.
+ */
+ public boolean isModified() {
+ return modified;
+ }
+
+ /*
+ * Tests if the field is in write-through mode. Don't add a JavaDoc comment
+ * here, we use the default documentation from the implemented interface.
+ */
+ public boolean isWriteThrough() {
+ return writeTroughMode;
+ }
+
+ /*
+ * Sets the field's write-through mode to the specified status Don't add a
+ * JavaDoc comment here, we use the default documentation from the
+ * implemented interface.
+ */
+ public void setWriteThrough(boolean writeTrough)
+ throws Buffered.SourceException {
+ if (writeTroughMode == writeTrough)
+ return;
+ writeTroughMode = writeTrough;
+ if (writeTroughMode)
+ commit();
+ }
+
+ /*
+ * Tests if the field is in read-through mode. Don't add a JavaDoc comment
+ * here, we use the default documentation from the implemented interface.
+ */
+ public boolean isReadThrough() {
+ return readTroughMode;
+ }
+
+ /*
+ * Sets the field's read-through mode to the specified status Don't add a
+ * JavaDoc comment here, we use the default documentation from the
+ * implemented interface.
+ */
+ public void setReadThrough(boolean readTrough)
+ throws Buffered.SourceException {
+ if (readTroughMode == readTrough)
+ return;
+ readTroughMode = readTrough;
+ if (!isModified() && readTroughMode && dataSource != null) {
+ setInternalValue(dataSource.getValue());
+ fireValueChange();
+ }
+ }
+
+ /* Property interface implementation ******************************* */
+
+ /**
+ * Returns the value of the Property in human readable textual format.
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ Object value = getValue();
+ if (value == null)
+ return null;
+ return getValue().toString();
+ }
+
+ /**
+ * Gets the current value of the field. This is the visible, modified and
+ * possible invalid value the user have entered to the field. In the
+ * read-through mode, the abstract buffer is also updated and validation is
+ * performed.
+ *
+ * @return the current value of the field.
+ */
+ public Object getValue() {
+
+ // Give the value from abstract buffers if the field if possible
+ if (dataSource == null || !isReadThrough() || isModified())
+ return value;
+
+ Object newValue = dataSource.getValue();
+ if ((newValue == null && value != null)
+ || (newValue != null && !newValue.equals(value))) {
+ setInternalValue(newValue);
+ fireValueChange();
+ }
+
+ return newValue;
+ }
+
+ /**
+ * Sets the value of the field.
+ *
+ * @param newValue
+ * the New value of the field.
+ * @throws Property.ReadOnlyException
+ * @throws Property.ConversionException
+ */
+ public void setValue(Object newValue) throws Property.ReadOnlyException,
+ Property.ConversionException {
+
+ if ((newValue == null && value != null)
+ || (newValue != null && !newValue.equals(value))) {
+
+ // Read only fields can not be changed
+ if (isReadOnly())
+ throw new Property.ReadOnlyException();
+
+ // If invalid values are not allowed, the value must be checked
+ if (!isInvalidAllowed()) {
+ Collection v = getValidators();
+ if (v != null)
+ for (Iterator i = v.iterator(); i.hasNext();)
+ ((Validator) i.next()).validate(newValue);
+ }
+
+ // Changes the value
+ setInternalValue(newValue);
+ modified = dataSource != null;
+
+ // In write trough mode , try to commit
+ if (isWriteThrough() && dataSource != null
+ && (isInvalidCommitted() || isValid())) {
+ try {
+
+ // Commits the value to datasource
+ dataSource.setValue(newValue);
+
+ // The buffer is now unmodified
+ modified = false;
+
+ } catch (Throwable e) {
+
+ // Sets the buffering state
+ currentBufferedSourceException = new Buffered.SourceException(
+ this, e);
+ requestRepaint();
+
+ // Throws the source exception
+ throw currentBufferedSourceException;
+ }
+ }
+
+ // If successful, remove set the buffering state to be ok
+ if (currentBufferedSourceException != null) {
+ currentBufferedSourceException = null;
+ requestRepaint();
+ }
+
+ // Fires the value change
+ fireValueChange();
+ }
+ }
+
+ /* External data source ******************************************** */
+
+ /**
+ * Gets the current data source of the field, if any.
+ *
+ * @return the current data source as a Property, or <code>null</code> if
+ * none defined.
+ */
+ public Property getPropertyDataSource() {
+ return dataSource;
+ }
+
+ /**
+ * <p>
+ * Sets the specified Property as the data source for the field. All
+ * uncommitted changes to the field are discarded and the value is refreshed
+ * from the new data source.
+ * </p>
+ *
+ * <p>
+ * If the datasource has any validators, the same validators are added to
+ * the field. Because the default behavior of the field is to allow invalid
+ * values, but not to allow committing them, this only adds visual error
+ * messages to fields and do not allow committing them as long as the value
+ * is invalid. After the value is valid, the error message is not shown and
+ * the commit can be done normally.
+ * </p>
+ *
+ * @param newDataSource
+ * the new data source Property.
+ */
+ public void setPropertyDataSource(Property newDataSource) {
+
+ // Saves the old value
+ Object oldValue = value;
+
+ // Discards all changes to old datasource
+ try {
+ discard();
+ } catch (Buffered.SourceException ignored) {
+ }
+
+ // Stops listening the old data source changes
+ if (dataSource != null
+ && Property.ValueChangeNotifier.class
+ .isAssignableFrom(dataSource.getClass()))
+ ((Property.ValueChangeNotifier) dataSource).removeListener(this);
+
+ // Sets the new data source
+ dataSource = newDataSource;
+
+ // Gets the value from source
+ try {
+ if (dataSource != null)
+ setInternalValue(dataSource.getValue());
+ modified = false;
+ } catch (Throwable e) {
+ currentBufferedSourceException = new Buffered.SourceException(this,
+ e);
+ modified = true;
+ }
+
+ // Listens the new data source if possible
+ if (dataSource instanceof Property.ValueChangeNotifier)
+ ((Property.ValueChangeNotifier) dataSource).addListener(this);
+
+ // Copy the validators from the data source
+ if (dataSource instanceof Validatable) {
+ Collection validators = ((Validatable) dataSource).getValidators();
+ if (validators != null)
+ for (Iterator i = validators.iterator(); i.hasNext();)
+ addValidator((Validator) i.next());
+ }
+
+ // Fires value change if the value has changed
+ if ((value != oldValue)
+ && ((value != null && !value.equals(oldValue)) || value == null))
+ fireValueChange();
+ }
+
+ /* Validation ****************************************************** */
+
+ /**
+ * Adds a new validator for the field's value. All validators added to a
+ * field are checked each time the its value changes.
+ *
+ * @param validator
+ * the new validator to be added.
+ */
+ public void addValidator(Validator validator) {
+ if (validators == null)
+ validators = new LinkedList();
+ validators.add(validator);
+ }
+
+ /**
+ * Gets the validators of the field.
+ *
+ * @return the Unmodifiable collection that holds all validators for the
+ * field.
+ */
+ public Collection getValidators() {
+ if (validators == null || validators.isEmpty())
+ return null;
+ return Collections.unmodifiableCollection(validators);
+ }
+
+ /**
+ * Removes the validator from the field.
+ *
+ * @param validator
+ * the validator to remove.
+ */
+ public void removeValidator(Validator validator) {
+ if (validators != null)
+ validators.remove(validator);
+ }
+
+ /**
+ * Tests the current value against all registered validators.
+ *
+ * @return <code>true</code> if all registered validators claim that the
+ * current value is valid, <code>false</code> otherwise.
+ */
+ public boolean isValid() {
+
+ if (validators == null)
+ return true;
+
+ Object value = getValue();
+ for (Iterator i = validators.iterator(); i.hasNext();)
+ if (!((Validator) i.next()).isValid(value))
+ return false;
+
+ return true;
+ }
+
/**
* Checks the validity of the validatable
+ *
* @see com.itmill.toolkit.data.Validatable#validate()
*/
- public void validate() throws Validator.InvalidValueException {
-
- // If there is no validator, there can not be any errors
- if (validators == null)
- return;
-
- // Initialize temps
- Validator.InvalidValueException firstError = null;
- LinkedList errors = null;
- Object value = getValue();
-
- // Gets all the validation errors
- for (Iterator i = validators.iterator(); i.hasNext();)
- try {
- ((Validator) i.next()).validate(value);
- } catch (Validator.InvalidValueException e) {
- if (firstError == null)
- firstError = e;
- else {
- if (errors == null) {
- errors = new LinkedList();
- errors.add(firstError);
- }
- errors.add(e);
- }
- }
-
- // If there were no error
- if (firstError == null)
- return;
-
- // If only one error occurred, throw it forwards
- if (errors == null)
- throw firstError;
-
- // Creates composite validator
- Validator.InvalidValueException[] exceptions = new Validator.InvalidValueException[errors
- .size()];
- int index = 0;
- for (Iterator i = errors.iterator(); i.hasNext();)
- exceptions[index++] = (Validator.InvalidValueException) i.next();
-
- throw new Validator.InvalidValueException(null, exceptions);
- }
-
- /**
- * Fields allow invalid values by default. In most cases this is wanted,
- * because the field otherwise visually forget the user input immediately.
- * @return true iff the invalid values are allowed.
- * @see com.itmill.toolkit.data.Validatable#isInvalidAllowed()
- */
- public boolean isInvalidAllowed() {
- return invalidAllowed;
- }
-
- /**
- * Fields allow invalid values by default. In most cases this is wanted,
- * because the field otherwise visually forget the user input immediately.
- * <p>
- * In common setting where the user wants to assure the correctness of the
- * datasource, but allow temporarily invalid contents in the field, the user
- * should add the validators to datasource, that should not allow invalid
- * values. The validators are automatically copied to the field when the
- * datasource is set.
- * </p>
- * @see com.itmill.toolkit.data.Validatable#setInvalidAllowed(boolean)
- */
- public void setInvalidAllowed(boolean invalidAllowed)
- throws UnsupportedOperationException {
- this.invalidAllowed = invalidAllowed;
- }
-
- /**
- * Error messages shown by the fields are composites of the error message
- * thrown by the superclasses (that is the component error message),
- * validation errors and buffered source errors.
- *
- * @see com.itmill.toolkit.ui.AbstractComponent#getErrorMessage()
- */
- public ErrorMessage getErrorMessage() {
- ErrorMessage superError = super.getErrorMessage();
- return superError;
- /*
- * TODO: Check the logic of this ErrorMessage validationError = null;
- * try { validate(); } catch (Validator.InvalidValueException e) {
- * validationError = e; }
- *
- * if (superError == null && validationError == null &&
- * currentBufferedSourceException == null) return null; // Throw
- * combination of the error types return new CompositeErrorMessage( new
- * ErrorMessage[] { superError, validationError,
- * currentBufferedSourceException });
- */
-
- }
-
- /* Value change events ****************************************** */
-
- private static final Method VALUE_CHANGE_METHOD;
-
- static {
- try {
- VALUE_CHANGE_METHOD = Property.ValueChangeListener.class
- .getDeclaredMethod("valueChange",
- new Class[] { Property.ValueChangeEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
- // This should never happen
- throw new java.lang.RuntimeException();
- }
- }
-
- /*
- * Adds a value change listener for the field. Don't add a JavaDoc comment
- * here, we use the default documentation from the implemented interface.
- */
- public void addListener(Property.ValueChangeListener listener) {
- addListener(AbstractField.ValueChangeEvent.class, listener,
- VALUE_CHANGE_METHOD);
- }
-
- /*
- * Removes a value change listener from the field. Don't add a JavaDoc
- * comment here, we use the default documentation from the implemented
- * interface.
- */
- public void removeListener(Property.ValueChangeListener listener) {
- removeListener(AbstractField.ValueChangeEvent.class, listener,
- VALUE_CHANGE_METHOD);
- }
-
- /**
- * Emits the value change event. The value contained in the field is validated
- * before the event is created.
- */
- protected void fireValueChange() {
- fireEvent(new AbstractField.ValueChangeEvent(this));
- requestRepaint();
- }
-
- /* Read-only status change events *************************************** */
-
- private static final Method READ_ONLY_STATUS_CHANGE_METHOD;
-
- static {
- try {
- READ_ONLY_STATUS_CHANGE_METHOD = Property.ReadOnlyStatusChangeListener.class
- .getDeclaredMethod(
- "readOnlyStatusChange",
- new Class[] { Property.ReadOnlyStatusChangeEvent.class });
- } catch (java.lang.NoSuchMethodException e) {
- // This should never happen
- throw new java.lang.RuntimeException();
- }
- }
-
- /**
- * An <code>Event</code> object specifying the Property whose read-only
- * status has changed.
- *
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
- public class ReadOnlyStatusChangeEvent extends Component.Event implements
- Property.ReadOnlyStatusChangeEvent {
-
- /**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3258688823264161846L;
-
- /**
- * New instance of text change event.
- *
- * @param source
- * the Source of the event.
- */
- public ReadOnlyStatusChangeEvent(AbstractField source) {
- super(source);
- }
-
- /**
- * Property where the event occurred.
- *
- * @return the Source of the event.
- */
- public Property getProperty() {
- return (Property) getSource();
- }
- }
-
- /*
- * Adds a read-only status change listener for the field. Don't add a JavaDoc
- * comment here, we use the default documentation from the implemented
- * interface.
- */
- public void addListener(Property.ReadOnlyStatusChangeListener listener) {
- addListener(Property.ReadOnlyStatusChangeEvent.class, listener,
- READ_ONLY_STATUS_CHANGE_METHOD);
- }
-
- /*
- * Removes a read-only status change listener from the field. Don't add a
- * JavaDoc comment here, we use the default documentation from the
- * implemented interface.
- */
- public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
- removeListener(Property.ReadOnlyStatusChangeEvent.class, listener,
- READ_ONLY_STATUS_CHANGE_METHOD);
- }
-
- /**
- * Emits the read-only status change event. The value contained in the field is
- * validated before the event is created.
- */
- protected void fireReadOnlyStatusChange() {
- fireEvent(new AbstractField.ReadOnlyStatusChangeEvent(this));
- }
-
- /**
- * This method listens to data source value changes and passes the changes
- * forwards.
- *
- * @param event
- * the value change event telling the data source contents have
- * changed.
- */
- public void valueChange(Property.ValueChangeEvent event) {
- if (isReadThrough() || !isModified())
- fireValueChange();
- }
-
- /**
- * Asks the terminal to place the cursor to this field.
- */
- public void focus() {
- Window w = getWindow();
- if (w != null) {
- w.setFocusedComponent(this);
- } else {
- this.delayedFocus = true;
- }
- }
-
- /**
- * Creates abstract field by the type of the property.
- *
- * <p>
- * This returns most suitable field type for editing property of given type.
- * </p>
- *
- * @param propertyType
- * the Type of the property, that needs to be edited.
- */
- public static AbstractField constructField(Class propertyType) {
-
- // Null typed properties can not be edited
- if (propertyType == null)
- return null;
-
- // Date field
- if (Date.class.isAssignableFrom(propertyType)) {
- return new DateField();
- }
-
- // Boolean field
- if (Boolean.class.isAssignableFrom(propertyType)) {
- Button button = new Button("");
- button.setSwitchMode(true);
- button.setImmediate(false);
- return button;
- }
-
- // Text field is used by default
- return new TextField();
- }
-
- /**
- * Gets the tab index of this field. The tab index property is used to
- * specify the natural tab ordering of fields.
- *
- * @return the Tab index of this field. Negative value means unspecified.
- */
- public int getTabIndex() {
- return tabIndex;
- }
-
- /**
- * Gets the tab index of this field. The tab index property is used to
- * specify the natural tab ordering of fields.
- *
- * @param tabIndex
- * the tab order of this component. Negative value means
- * unspecified.
- */
- public void setTabIndex(int tabIndex) {
- this.tabIndex = tabIndex;
- }
-
- /**
- * Sets the internal field value. This is purely used by AbstractField to
- * change the internal Field value. It does not trigger any events. It can
- * be overriden by the inheriting classes to update all dependent variables.
- *
- * @param newValue
- * the new value to be set.
- */
- protected void setInternalValue(Object newValue) {
- this.value = newValue;
- }
-
- /**
- * Gets the unique ID of focusable
- * @see com.itmill.toolkit.ui.Component.Focusable#getFocusableId()
- */
- public long getFocusableId() {
- return this.focusableId;
- }
-
- /**
- * Notifies the component that it is connected to an application.
- * @see com.itmill.toolkit.ui.Component#attach()
- */
- public void attach() {
- super.attach();
- if (this.delayedFocus) {
- this.delayedFocus = false;
- this.focus();
- }
- }
-
- /**
- * Is this field required.
- * Required fields must filled by the user.
- *
- * @return <code>true</code> if the field is required .otherwise <code>false</code>.
- */
- public boolean isRequired() {
- return required;
- }
-
- /**
- * Sets the field required. Required fields must filled by the user.
- *
- * @param required
- * Is the field required.
- */
- public void setRequired(boolean required) {
- this.required = required;
- }
-
- /**
- * Free used resources.
- * @see java.lang.Object#finalize()
- */
- public void finalize() throws Throwable {
- if (focusableId > -1) {
- Window.removeFocusableId(focusableId);
- }
- super.finalize();
- }
+ public void validate() throws Validator.InvalidValueException {
+
+ // If there is no validator, there can not be any errors
+ if (validators == null)
+ return;
+
+ // Initialize temps
+ Validator.InvalidValueException firstError = null;
+ LinkedList errors = null;
+ Object value = getValue();
+
+ // Gets all the validation errors
+ for (Iterator i = validators.iterator(); i.hasNext();)
+ try {
+ ((Validator) i.next()).validate(value);
+ } catch (Validator.InvalidValueException e) {
+ if (firstError == null)
+ firstError = e;
+ else {
+ if (errors == null) {
+ errors = new LinkedList();
+ errors.add(firstError);
+ }
+ errors.add(e);
+ }
+ }
+
+ // If there were no error
+ if (firstError == null)
+ return;
+
+ // If only one error occurred, throw it forwards
+ if (errors == null)
+ throw firstError;
+
+ // Creates composite validator
+ Validator.InvalidValueException[] exceptions = new Validator.InvalidValueException[errors
+ .size()];
+ int index = 0;
+ for (Iterator i = errors.iterator(); i.hasNext();)
+ exceptions[index++] = (Validator.InvalidValueException) i.next();
+
+ throw new Validator.InvalidValueException(null, exceptions);
+ }
+
+ /**
+ * Fields allow invalid values by default. In most cases this is wanted,
+ * because the field otherwise visually forget the user input immediately.
+ *
+ * @return true iff the invalid values are allowed.
+ * @see com.itmill.toolkit.data.Validatable#isInvalidAllowed()
+ */
+ public boolean isInvalidAllowed() {
+ return invalidAllowed;
+ }
+
+ /**
+ * Fields allow invalid values by default. In most cases this is wanted,
+ * because the field otherwise visually forget the user input immediately.
+ * <p>
+ * In common setting where the user wants to assure the correctness of the
+ * datasource, but allow temporarily invalid contents in the field, the user
+ * should add the validators to datasource, that should not allow invalid
+ * values. The validators are automatically copied to the field when the
+ * datasource is set.
+ * </p>
+ *
+ * @see com.itmill.toolkit.data.Validatable#setInvalidAllowed(boolean)
+ */
+ public void setInvalidAllowed(boolean invalidAllowed)
+ throws UnsupportedOperationException {
+ this.invalidAllowed = invalidAllowed;
+ }
+
+ /**
+ * Error messages shown by the fields are composites of the error message
+ * thrown by the superclasses (that is the component error message),
+ * validation errors and buffered source errors.
+ *
+ * @see com.itmill.toolkit.ui.AbstractComponent#getErrorMessage()
+ */
+ public ErrorMessage getErrorMessage() {
+ ErrorMessage superError = super.getErrorMessage();
+ return superError;
+ /*
+ * TODO: Check the logic of this ErrorMessage validationError = null;
+ * try { validate(); } catch (Validator.InvalidValueException e) {
+ * validationError = e; }
+ *
+ * if (superError == null && validationError == null &&
+ * currentBufferedSourceException == null) return null; // Throw
+ * combination of the error types return new CompositeErrorMessage( new
+ * ErrorMessage[] { superError, validationError,
+ * currentBufferedSourceException });
+ */
+
+ }
+
+ /* Value change events ****************************************** */
+
+ private static final Method VALUE_CHANGE_METHOD;
+
+ static {
+ try {
+ VALUE_CHANGE_METHOD = Property.ValueChangeListener.class
+ .getDeclaredMethod("valueChange",
+ new Class[] { Property.ValueChangeEvent.class });
+ } catch (java.lang.NoSuchMethodException e) {
+ // This should never happen
+ throw new java.lang.RuntimeException();
+ }
+ }
+
+ /*
+ * Adds a value change listener for the field. Don't add a JavaDoc comment
+ * here, we use the default documentation from the implemented interface.
+ */
+ public void addListener(Property.ValueChangeListener listener) {
+ addListener(AbstractField.ValueChangeEvent.class, listener,
+ VALUE_CHANGE_METHOD);
+ }
+
+ /*
+ * Removes a value change listener from the field. Don't add a JavaDoc
+ * comment here, we use the default documentation from the implemented
+ * interface.
+ */
+ public void removeListener(Property.ValueChangeListener listener) {
+ removeListener(AbstractField.ValueChangeEvent.class, listener,
+ VALUE_CHANGE_METHOD);
+ }
+
+ /**
+ * Emits the value change event. The value contained in the field is
+ * validated before the event is created.
+ */
+ protected void fireValueChange() {
+ fireEvent(new AbstractField.ValueChangeEvent(this));
+ requestRepaint();
+ }
+
+ /* Read-only status change events *************************************** */
+
+ private static final Method READ_ONLY_STATUS_CHANGE_METHOD;
+
+ static {
+ try {
+ READ_ONLY_STATUS_CHANGE_METHOD = Property.ReadOnlyStatusChangeListener.class
+ .getDeclaredMethod(
+ "readOnlyStatusChange",
+ new Class[] { Property.ReadOnlyStatusChangeEvent.class });
+ } catch (java.lang.NoSuchMethodException e) {
+ // This should never happen
+ throw new java.lang.RuntimeException();
+ }
+ }
+
+ /**
+ * An <code>Event</code> object specifying the Property whose read-only
+ * status has changed.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 3.0
+ */
+ public class ReadOnlyStatusChangeEvent extends Component.Event implements
+ Property.ReadOnlyStatusChangeEvent {
+
+ /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3258688823264161846L;
+
+ /**
+ * New instance of text change event.
+ *
+ * @param source
+ * the Source of the event.
+ */
+ public ReadOnlyStatusChangeEvent(AbstractField source) {
+ super(source);
+ }
+
+ /**
+ * Property where the event occurred.
+ *
+ * @return the Source of the event.
+ */
+ public Property getProperty() {
+ return (Property) getSource();
+ }
+ }
+
+ /*
+ * Adds a read-only status change listener for the field. Don't add a
+ * JavaDoc comment here, we use the default documentation from the
+ * implemented interface.
+ */
+ public void addListener(Property.ReadOnlyStatusChangeListener listener) {
+ addListener(Property.ReadOnlyStatusChangeEvent.class, listener,
+ READ_ONLY_STATUS_CHANGE_METHOD);
+ }
+
+ /*
+ * Removes a read-only status change listener from the field. Don't add a
+ * JavaDoc comment here, we use the default documentation from the
+ * implemented interface.
+ */
+ public void removeListener(Property.ReadOnlyStatusChangeListener listener) {
+ removeListener(Property.ReadOnlyStatusChangeEvent.class, listener,
+ READ_ONLY_STATUS_CHANGE_METHOD);
+ }
+
+ /**
+ * Emits the read-only status change event. The value contained in the field
+ * is validated before the event is created.
+ */
+ protected void fireReadOnlyStatusChange() {
+ fireEvent(new AbstractField.ReadOnlyStatusChangeEvent(this));
+ }
+
+ /**
+ * This method listens to data source value changes and passes the changes
+ * forwards.
+ *
+ * @param event
+ * the value change event telling the data source contents have
+ * changed.
+ */
+ public void valueChange(Property.ValueChangeEvent event) {
+ if (isReadThrough() || !isModified())
+ fireValueChange();
+ }
+
+ /**
+ * Asks the terminal to place the cursor to this field.
+ */
+ public void focus() {
+ Window w = getWindow();
+ if (w != null) {
+ w.setFocusedComponent(this);
+ } else {
+ this.delayedFocus = true;
+ }
+ }
+
+ /**
+ * Creates abstract field by the type of the property.
+ *
+ * <p>
+ * This returns most suitable field type for editing property of given type.
+ * </p>
+ *
+ * @param propertyType
+ * the Type of the property, that needs to be edited.
+ */
+ public static AbstractField constructField(Class propertyType) {
+
+ // Null typed properties can not be edited
+ if (propertyType == null)
+ return null;
+
+ // Date field
+ if (Date.class.isAssignableFrom(propertyType)) {
+ return new DateField();
+ }
+
+ // Boolean field
+ if (Boolean.class.isAssignableFrom(propertyType)) {
+ Button button = new Button("");
+ button.setSwitchMode(true);
+ button.setImmediate(false);
+ return button;
+ }
+
+ // Text field is used by default
+ return new TextField();
+ }
+
+ /**
+ * Gets the tab index of this field. The tab index property is used to
+ * specify the natural tab ordering of fields.
+ *
+ * @return the Tab index of this field. Negative value means unspecified.
+ */
+ public int getTabIndex() {
+ return tabIndex;
+ }
+
+ /**
+ * Gets the tab index of this field. The tab index property is used to
+ * specify the natural tab ordering of fields.
+ *
+ * @param tabIndex
+ * the tab order of this component. Negative value means
+ * unspecified.
+ */
+ public void setTabIndex(int tabIndex) {
+ this.tabIndex = tabIndex;
+ }
+
+ /**
+ * Sets the internal field value. This is purely used by AbstractField to
+ * change the internal Field value. It does not trigger any events. It can
+ * be overriden by the inheriting classes to update all dependent variables.
+ *
+ * @param newValue
+ * the new value to be set.
+ */
+ protected void setInternalValue(Object newValue) {
+ this.value = newValue;
+ }
+
+ /**
+ * Gets the unique ID of focusable
+ *
+ * @see com.itmill.toolkit.ui.Component.Focusable#getFocusableId()
+ */
+ public long getFocusableId() {
+ return this.focusableId;
+ }
+
+ /**
+ * Notifies the component that it is connected to an application.
+ *
+ * @see com.itmill.toolkit.ui.Component#attach()
+ */
+ public void attach() {
+ super.attach();
+ if (this.delayedFocus) {
+ this.delayedFocus = false;
+ this.focus();
+ }
+ }
+
+ /**
+ * Is this field required. Required fields must filled by the user.
+ *
+ * @return <code>true</code> if the field is required .otherwise
+ * <code>false</code>.
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * Sets the field required. Required fields must filled by the user.
+ *
+ * @param required
+ * Is the field required.
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ /**
+ * Free used resources.
+ *
+ * @see java.lang.Object#finalize()
+ */
+ public void finalize() throws Throwable {
+ if (focusableId > -1) {
+ Window.removeFocusableId(focusableId);
+ }
+ super.finalize();
+ }
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/ui/BaseFieldFactory.java b/src/com/itmill/toolkit/ui/BaseFieldFactory.java
index dba1c5cec2..c9881e6854 100644
--- a/src/com/itmill/toolkit/ui/BaseFieldFactory.java
+++ b/src/com/itmill/toolkit/ui/BaseFieldFactory.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -34,28 +34,30 @@ import com.itmill.toolkit.data.Container;
import com.itmill.toolkit.data.Item;
import com.itmill.toolkit.data.Property;
-/**
- * Default implementation of the
- * the following Field types are used by default:
+/**
+ * Default implementation of the the following Field types are used by default:
* <p>
- * <b>Boolean</b>: Button(switchMode:true).<br/>
- * <b>Date</b>: DateField(resolution: day).<br/>
- * <b>Item</b>: Form. <br/>
- * <b>default field type</b>: TextField.
+ * <b>Boolean</b>: Button(switchMode:true).<br/> <b>Date</b>:
+ * DateField(resolution: day).<br/> <b>Item</b>: Form. <br/> <b>default field
+ * type</b>: TextField.
* <p>
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.1
*/
public class BaseFieldFactory implements FieldFactory {
- /**
+ /**
* Creates the field based on type of data.
- *
- *
- * @param type the type of data presented in field.
- * @param uiContext the context where the Field is presented.
+ *
+ *
+ * @param type
+ * the type of data presented in field.
+ * @param uiContext
+ * the context where the Field is presented.
*
* @see com.itmill.toolkit.ui.FieldFactory#createField(Class, Component)
*/
@@ -69,7 +71,6 @@ public class BaseFieldFactory implements FieldFactory {
return new Form();
}
-
// Date field
if (Date.class.isAssignableFrom(type)) {
DateField df = new DateField();
@@ -89,43 +90,42 @@ public class BaseFieldFactory implements FieldFactory {
return new TextField();
}
- /**
+ /**
* Creates the field based on the datasource property.
*
* @see com.itmill.toolkit.ui.FieldFactory#createField(Property, Component)
*/
public Field createField(Property property, Component uiContext) {
if (property != null)
- return createField(property.getType(),uiContext);
+ return createField(property.getType(), uiContext);
else
return null;
}
- /**
+ /**
* Creates the field based on the item and property id.
*
- * @see com.itmill.toolkit.ui.FieldFactory#createField(Item, Object, Component)
+ * @see com.itmill.toolkit.ui.FieldFactory#createField(Item, Object,
+ * Component)
*/
public Field createField(Item item, Object propertyId, Component uiContext) {
- if (item != null && propertyId != null){
- Field f= createField(item.getItemProperty(propertyId),uiContext);
+ if (item != null && propertyId != null) {
+ Field f = createField(item.getItemProperty(propertyId), uiContext);
if (f instanceof AbstractComponent)
- ((AbstractComponent)f).setCaption(propertyId.toString());
+ ((AbstractComponent) f).setCaption(propertyId.toString());
return f;
- }
- else
+ } else
return null;
}
-
+
/**
- * @see com.itmill.toolkit.ui.FieldFactory#createField(com.itmill.toolkit.data.Container, java.lang.Object, java.lang.Object, com.itmill.toolkit.ui.Component)
+ * @see com.itmill.toolkit.ui.FieldFactory#createField(com.itmill.toolkit.data.Container,
+ * java.lang.Object, java.lang.Object, com.itmill.toolkit.ui.Component)
*/
- public Field createField(
- Container container,
- Object itemId,
- Object propertyId,
- Component uiContext) {
- return createField(container.getContainerProperty(itemId,propertyId),uiContext);
+ public Field createField(Container container, Object itemId,
+ Object propertyId, Component uiContext) {
+ return createField(container.getContainerProperty(itemId, propertyId),
+ uiContext);
}
-
+
}
diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java
index 2b278caa86..b15d3b2da3 100644
--- a/src/com/itmill/toolkit/ui/Button.java
+++ b/src/com/itmill/toolkit/ui/Button.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -44,11 +44,12 @@ import com.itmill.toolkit.terminal.KeyMapper;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-/**
+/**
* A generic button component.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Button extends AbstractField implements Action.Container {
@@ -56,63 +57,72 @@ public class Button extends AbstractField implements Action.Container {
/* Private members ************************************************* */
boolean switchMode = false;
-
+
/** List of action handlers */
private LinkedList actionHandlers = null;
/** Action mapper */
private KeyMapper actionMapper = null;
- /**
- * Creates a new push button.
- * The value of the push button is allways false and they are
- * immediate by default.
- *
+ /**
+ * Creates a new push button. The value of the push button is allways false
+ * and they are immediate by default.
+ *
*/
public Button() {
setSwitchMode(false);
}
- /**
+ /**
* Creates a new push button.
*
- * The value of the push button is allways false and they are
- * immediate by default.
+ * The value of the push button is allways false and they are immediate by
+ * default.
*
- * @param caption the Button caption.
+ * @param caption
+ * the Button caption.
*/
public Button(String caption) {
setCaption(caption);
setSwitchMode(false);
}
- /**
+ /**
* Creates a new push button with click listener.
- * @param caption the Button caption.
- * @param listener the Button click listener.
+ *
+ * @param caption
+ * the Button caption.
+ * @param listener
+ * the Button click listener.
*/
public Button(String caption, ClickListener listener) {
this(caption);
addListener(listener);
}
- /**
- * Creates a new push button with a method listening button clicks.
- * The method must have either no parameters, or only one parameter of
+ /**
+ * Creates a new push button with a method listening button clicks. The
+ * method must have either no parameters, or only one parameter of
* Button.ClickEvent type.
- * @param caption the Button caption.
- * @param target the Object having the method for listening button clicks.
- * @param methodName the name of the method in target object, that
- * receives button click events.
+ *
+ * @param caption
+ * the Button caption.
+ * @param target
+ * the Object having the method for listening button clicks.
+ * @param methodName
+ * the name of the method in target object, that receives button
+ * click events.
*/
public Button(String caption, Object target, String methodName) {
this(caption);
addListener(ClickEvent.class, target, methodName);
}
- /**
+ /**
* Creates a new switch button with initial value.
- * @param state the Initial state of the switch-button.
+ *
+ * @param state
+ * the Initial state of the switch-button.
* @param initialState
*/
public Button(String caption, boolean initialState) {
@@ -121,9 +131,11 @@ public class Button extends AbstractField implements Action.Container {
setSwitchMode(true);
}
- /**
+ /**
* Creates a new switch button that is connected to a boolean property.
- * @param state the Initial state of the switch-button.
+ *
+ * @param state
+ * the Initial state of the switch-button.
* @param dataSource
*/
public Button(String caption, Property dataSource) {
@@ -132,19 +144,24 @@ public class Button extends AbstractField implements Action.Container {
setPropertyDataSource(dataSource);
}
- /**
+ /**
* Gets component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "button";
}
- /**
+ /**
* Paints the content of this component.
- * @param event the PaintEvent.
- * @throws IOException if the writing failed due to input/output error.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param event
+ * the PaintEvent.
+ * @throws IOException
+ * if the writing failed due to input/output error.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
@@ -158,23 +175,19 @@ public class Button extends AbstractField implements Action.Container {
state = false;
}
target.addVariable(this, "state", state);
-
+
// Actions
if (actionHandlers != null) {
Set actionSet = new LinkedHashSet();
- for (Iterator ahi = actionHandlers.iterator();
- ahi.hasNext();
- ) {
- Action[] aa =
- ((Action.Handler) ahi.next()).getActions(
- this,
+ for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) {
+ Action[] aa = ((Action.Handler) ahi.next()).getActions(this,
this);
if (aa != null)
for (int ai = 0; ai < aa.length; ai++) {
actionSet.add(aa[ai]);
}
}
-
+
target.startTag("actions");
target.addVariable(this, "action", "");
for (Iterator i = actionSet.iterator(); i.hasNext();) {
@@ -187,15 +200,15 @@ public class Button extends AbstractField implements Action.Container {
target.addAttribute("icon", a.getIcon());
target.addAttribute("key", actionMapper.key(a));
target.addAttribute("keycode", a.getKeyCode());
- if(a.getModifiers() != null) {
+ if (a.getModifiers() != null) {
int[] modifiers = a.getModifiers();
target.addAttribute("modifiers", modifiers.length);
- for(int j = 0; j < modifiers.length; j++) {
+ for (int j = 0; j < modifiers.length; j++) {
target.addAttribute("modifier" + j, modifiers[j]);
}
}
target.endTag("action");
- } catch( Exception e ){
+ } catch (Exception e) {
// ignore non-shorcut actions for button
}
}
@@ -203,10 +216,11 @@ public class Button extends AbstractField implements Action.Container {
}
}
- /**
- * Invoked when the value of a variable has changed. Button
- * listeners are notified if the button is clicked.
- * @param source
+ /**
+ * Invoked when the value of a variable has changed. Button listeners are
+ * notified if the button is clicked.
+ *
+ * @param source
* @param variables
*/
public void changeVariables(Object source, Map variables) {
@@ -217,11 +231,10 @@ public class Button extends AbstractField implements Action.Container {
if (isSwitchMode()) {
- // For switch button, the event is only sent if the
+ // For switch button, the event is only sent if the
// switch state is changed
- if (newValue != null
- && !newValue.equals(oldValue)
- && !isReadOnly()) {
+ if (newValue != null && !newValue.equals(oldValue)
+ && !isReadOnly()) {
setValue(newValue);
fireClick();
}
@@ -240,19 +253,14 @@ public class Button extends AbstractField implements Action.Container {
// TODO this is pretty much copy-pasted from tree, may be simplified
if (variables.containsKey("action")) {
- StringTokenizer st =
- new StringTokenizer((String) variables.get("action"), ",");
+ StringTokenizer st = new StringTokenizer((String) variables
+ .get("action"), ",");
if (st.countTokens() == 2) {
Action action = (Action) actionMapper.get(st.nextToken());
- if (action != null
- && actionHandlers != null)
- for (Iterator i = actionHandlers.iterator();
- i.hasNext();
- )
- ((Action.Handler) i.next()).handleAction(
- action,
- this,
- this);
+ if (action != null && actionHandlers != null)
+ for (Iterator i = actionHandlers.iterator(); i.hasNext();)
+ ((Action.Handler) i.next()).handleAction(action, this,
+ this);
}
}
@@ -260,7 +268,9 @@ public class Button extends AbstractField implements Action.Container {
/**
* Checks if it is switchMode.
- * @return <code>true</code> if it is in Switch Mode, otherwise <code>false</code>.
+ *
+ * @return <code>true</code> if it is in Switch Mode, otherwise
+ * <code>false</code>.
*/
public boolean isSwitchMode() {
return switchMode;
@@ -268,7 +278,9 @@ public class Button extends AbstractField implements Action.Container {
/**
* Sets the switchMode.
- * @param switchMode The switchMode to set.
+ *
+ * @param switchMode
+ * The switchMode to set.
*/
public void setSwitchMode(boolean switchMode) {
this.switchMode = switchMode;
@@ -278,9 +290,9 @@ public class Button extends AbstractField implements Action.Container {
}
}
- /**
- * Sets immediate mode.
- * Push buttons can not be set in non-immediate mode.
+ /**
+ * Sets immediate mode. Push buttons can not be set in non-immediate mode.
+ *
* @see com.itmill.toolkit.ui.AbstractComponent#setImmediate(boolean)
*/
public void setImmediate(boolean immediate) {
@@ -288,8 +300,9 @@ public class Button extends AbstractField implements Action.Container {
super.setImmediate(!isSwitchMode() || immediate);
}
- /**
+ /**
* The type of the button as a property.
+ *
* @see com.itmill.toolkit.data.Property#getType()
*/
public Class getType() {
@@ -301,39 +314,42 @@ public class Button extends AbstractField implements Action.Container {
private static final Method BUTTON_CLICK_METHOD;
static {
try {
- BUTTON_CLICK_METHOD =
- ClickListener.class.getDeclaredMethod(
- "buttonClick",
- new Class[] { ClickEvent.class });
+ BUTTON_CLICK_METHOD = ClickListener.class.getDeclaredMethod(
+ "buttonClick", new Class[] { ClickEvent.class });
} catch (java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
}
- /**
- * Click event. This event is thrown, when the button is clicked.
+ /**
+ * Click event. This event is thrown, when the button is clicked.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class ClickEvent extends Component.Event {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3546647602931118393L;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3546647602931118393L;
- /**
- * New instance of text change event.
- * @param source the Source of the event.
+ /**
+ * New instance of text change event.
+ *
+ * @param source
+ * the Source of the event.
*/
public ClickEvent(Component source) {
super(source);
}
- /**
+ /**
* Gets the Button where the event occurred.
+ *
* @return the Source of the event.
*/
public Button getButton() {
@@ -341,45 +357,55 @@ public class Button extends AbstractField implements Action.Container {
}
}
- /**
+ /**
* Button click listener
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface ClickListener {
- /**
+ /**
* Button has been pressed.
- * @param event Button click event.
+ *
+ * @param event
+ * Button click event.
*/
public void buttonClick(ClickEvent event);
}
- /**
+ /**
* Adds the button click listener.
- * @param listener the Listener to be added.
+ *
+ * @param listener
+ * the Listener to be added.
*/
public void addListener(ClickListener listener) {
addListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD);
}
- /**
+ /**
* Removes the button click listener.
- * @param listener the Listener to be removed.
+ *
+ * @param listener
+ * the Listener to be removed.
*/
public void removeListener(ClickListener listener) {
removeListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD);
}
- /**
- * Emits the options change event.
+ /**
+ * Emits the options change event.
*/
protected void fireClick() {
fireEvent(new Button.ClickEvent(this));
}
- /** Adds an action handler.
+ /**
+ * Adds an action handler.
+ *
* @see com.itmill.toolkit.event.Action.Container#addActionHandler(Action.Handler)
*/
public void addActionHandler(Action.Handler actionHandler) {
@@ -391,28 +417,30 @@ public class Button extends AbstractField implements Action.Container {
actionMapper = new KeyMapper();
}
- if(!actionHandlers.contains(actionHandler)){
- actionHandlers.add(actionHandler);
- requestRepaint();
- }
+ if (!actionHandlers.contains(actionHandler)) {
+ actionHandlers.add(actionHandler);
+ requestRepaint();
+ }
}
}
- /** Removes an action handler.
+ /**
+ * Removes an action handler.
+ *
* @see com.itmill.toolkit.event.Action.Container#removeActionHandler(Action.Handler)
*/
public void removeActionHandler(Action.Handler actionHandler) {
if (actionHandlers != null && actionHandlers.contains(actionHandler)) {
-
- actionHandlers.remove(actionHandler);
-
- if (actionHandlers.isEmpty()) {
- actionHandlers = null;
- actionMapper = null;
- }
-
- requestRepaint();
+
+ actionHandlers.remove(actionHandler);
+
+ if (actionHandlers.isEmpty()) {
+ actionHandlers = null;
+ actionMapper = null;
+ }
+
+ requestRepaint();
}
}
}
diff --git a/src/com/itmill/toolkit/ui/Component.java b/src/com/itmill/toolkit/ui/Component.java
index d0dba99e37..dc686f5f05 100644
--- a/src/com/itmill/toolkit/ui/Component.java
+++ b/src/com/itmill/toolkit/ui/Component.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -39,128 +39,137 @@ import java.util.EventListener;
import java.util.EventObject;
import java.util.Locale;
-/**
- * The top-level component interface which must be implemented by all
- * UI components that use IT Mill Toolkit.
- *
+/**
+ * The top-level component interface which must be implemented by all UI
+ * components that use IT Mill Toolkit.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Component extends Paintable, VariableOwner {
- /**
+ /**
* Gets the look-and-feel style of the component.
*
* @return the component's styleValue of property style.
*/
public String getStyle();
- /**
- * Sets the look-and-feel style of the component. This method will
- * trigger a {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
+ /**
+ * Sets the look-and-feel style of the component. This method will trigger a
+ * {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
*
- * @param style the new style of the component.
+ * @param style
+ * the new style of the component.
*/
public void setStyle(String style);
- /**
+ /**
* <p>
- * Tests if the component is enabled or not. All the variable
- * change events are blocked from disabled components. Also the
- * component should visually indicate that it is disabled (by shading
- * the component for example).
- * All hidden (isVisible() == false) components must return false.
+ * Tests if the component is enabled or not. All the variable change events
+ * are blocked from disabled components. Also the component should visually
+ * indicate that it is disabled (by shading the component for example). All
+ * hidden (isVisible() == false) components must return false.
* </p>
*
- * <p>Components should be enabled by default.</p>
+ * <p>
+ * Components should be enabled by default.
+ * </p>
*
* @return <code>true</code> if the component is enabled,
- * <code>false</code> if not.
+ * <code>false</code> if not.
* @see VariableOwner#isEnabled()
*/
public boolean isEnabled();
- /**
- * Enables or disables the component. Being enabled means that the
- * component can be edited. This method will trigger a
+ /**
+ * Enables or disables the component. Being enabled means that the component
+ * can be edited. This method will trigger a
* {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
*
- * @param enabled the boolean value specifying if the component should be
- * enabled after the call or not
+ * @param enabled
+ * the boolean value specifying if the component should be
+ * enabled after the call or not
*/
public void setEnabled(boolean enabled);
- /**
+ /**
* Tests if the component is visible or not. Visibility defines if the
* component is shown in the UI or not. Default is <code>true</code>.
*
* @return <code>true</code> if the component is visible in the UI,
- * <code>false</code> if not
+ * <code>false</code> if not
*/
public boolean isVisible();
- /**
+ /**
* Sets the components visibility status. Visibility defines if the
* component is shown in the UI or not.
*
- * @param visible the Boolean value specifying if the component should be
- * visible after the call or not.
+ * @param visible
+ * the Boolean value specifying if the component should be
+ * visible after the call or not.
*/
public void setVisible(boolean visible);
- /**
- * Gets the visual parent of the component. The components can be
- * nested but one component can have only one parent.
+ /**
+ * Gets the visual parent of the component. The components can be nested but
+ * one component can have only one parent.
*
* @return the parent component.
*/
public Component getParent();
- /**
- * Sets the component's parent component.
+ /**
+ * Sets the component's parent component.
*
- * <p>This method calls
- * automatically {@link #attach()} if the parent is attached to a
- * window (or is itself a window}, and {@link #detach()} if
- * <code>parent</code> is set <code>null</code>, but the component
- * was in the application.</p>
+ * <p>
+ * This method calls automatically {@link #attach()} if the parent is
+ * attached to a window (or is itself a window}, and {@link #detach()} if
+ * <code>parent</code> is set <code>null</code>, but the component was
+ * in the application.
+ * </p>
*
- * <p>This method is rarely called directly. Instead the
- * {@link ComponentContainer#addComponent(Component)} method is used
- * to add components to container, which call this method implicitly.
+ * <p>
+ * This method is rarely called directly. Instead the
+ * {@link ComponentContainer#addComponent(Component)} method is used to add
+ * components to container, which call this method implicitly.
*
- * @param parent the new parent component.
+ * @param parent
+ * the new parent component.
*/
public void setParent(Component parent);
- /**
+ /**
* Tests if the component is in read-only mode.
*
* @return <code>true</code> if the component is in read-only mode,
- * <code>false</code> if not.
+ * <code>false</code> if not.
*/
public boolean isReadOnly();
- /**
+ /**
* Sets the component's to read-only mode to the specified state. This
- * method will trigger a
+ * method will trigger a
* {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
*
- * @param readOnly the boolean value specifying if the component should be
- * in read-only mode after the call or not.
+ * @param readOnly
+ * the boolean value specifying if the component should be in
+ * read-only mode after the call or not.
*/
public void setReadOnly(boolean readOnly);
- /**
- * Gets the caption of the component. Caption is the visible name of
- * the component.
+ /**
+ * Gets the caption of the component. Caption is the visible name of the
+ * component.
*
* @return the component's caption <code>String</code>.
*/
public String getCaption();
- /**
+ /**
* Gets the component's icon. A component may have a graphical icon
* associated with it, this method retrieves it if it is defined.
*
@@ -168,200 +177,222 @@ public interface Component extends Paintable, VariableOwner {
*/
public Resource getIcon();
- /**
- * Gets the component's parent window. If the component does not yet
- * belong to a window <code>null</code> is returned.
+ /**
+ * Gets the component's parent window. If the component does not yet belong
+ * to a window <code>null</code> is returned.
*
* @return the parent window of the component or <code>null</code>.
*/
public Window getWindow();
- /**
- * Gets the component's parent application. If the component does not
- * yet belong to a application <code>null</code> is returned.
+ /**
+ * Gets the component's parent application. If the component does not yet
+ * belong to a application <code>null</code> is returned.
*
* @return the parent application of the component or <code>null</code>.
*/
public Application getApplication();
- /**
+ /**
* <p>
* Notifies the component that it is connected to an application. This
- * method is always called before the component is first time painted
- * and is suitable to be extended. The <code>getApplication</code> and
- * <code>getWindow</code> methods might return <code>null</code>
- * before this method is called.</p>
+ * method is always called before the component is first time painted and is
+ * suitable to be extended. The <code>getApplication</code> and
+ * <code>getWindow</code> methods might return <code>null</code> before
+ * this method is called.
+ * </p>
*
- * <p>The caller of this method is {@link #setParent(Component)} if the
- * parent is already in the application. If the parent is not in the
- * application, it must call the {@link #attach()} for all its children
- * when it will be added to the application.</p>
+ * <p>
+ * The caller of this method is {@link #setParent(Component)} if the parent
+ * is already in the application. If the parent is not in the application,
+ * it must call the {@link #attach()} for all its children when it will be
+ * added to the application.
+ * </p>
*/
public void attach();
- /**
+ /**
* Notifies the component that it is detached from the application.
- * <p>The {@link #getApplication()} and {@link #getWindow()}
- * methods might return <code>null</code> after this method is
- * called.</p>
+ * <p>
+ * The {@link #getApplication()} and {@link #getWindow()} methods might
+ * return <code>null</code> after this method is called.
+ * </p>
*
- * <p>The caller of this method is {@link #setParent(Component)} if the
- * parent is in the application. When the parent is detached from the application
- * it is its response to call {@link #detach()} for all the children and
- * to detach itself from the terminal.</p>
+ * <p>
+ * The caller of this method is {@link #setParent(Component)} if the parent
+ * is in the application. When the parent is detached from the application
+ * it is its response to call {@link #detach()} for all the children and to
+ * detach itself from the terminal.
+ * </p>
*/
public void detach();
- /**
+ /**
* Gets the locale of this component.
*
- * @return This component's locale. If this component does not have a
- * locale, the locale of its parent is returned. Eventually locale
- * of application is returned. If application does not have its own
- * locale the locale is determined by <code>Locale.getDefautlt</code>. Returns
- * null if the component does not have its own locale and has not
- * yet been added to a containment hierarchy such that the locale
- * can be determined from the containing parent.
+ * @return This component's locale. If this component does not have a
+ * locale, the locale of its parent is returned. Eventually locale
+ * of application is returned. If application does not have its own
+ * locale the locale is determined by
+ * <code>Locale.getDefautlt</code>. Returns null if the component
+ * does not have its own locale and has not yet been added to a
+ * containment hierarchy such that the locale can be determined from
+ * the containing parent.
*/
public Locale getLocale();
- /**
- * The children must call this method when they need repainting. The call must be
- * made event in the case the children sent the repaint request themselves.
- * @param alreadyNotified the collection of repaint request listeners that have been
- * already notified by the child. This component should not renotify the listed
- * listeners again. The container given as parameter must be modifiable as the
- * component might modify it and pass it forwards. Null parameter is interpreted
- * as empty collection.
+ /**
+ * The children must call this method when they need repainting. The call
+ * must be made event in the case the children sent the repaint request
+ * themselves.
+ *
+ * @param alreadyNotified
+ * the collection of repaint request listeners that have been
+ * already notified by the child. This component should not
+ * renotify the listed listeners again. The container given as
+ * parameter must be modifiable as the component might modify it
+ * and pass it forwards. Null parameter is interpreted as empty
+ * collection.
*/
public void childRequestedRepaint(Collection alreadyNotified);
/* Component event framework *************************************** */
- /**
- * Superclass of all component originated <code>Event</code>s.
+ /**
+ * Superclass of all component originated <code>Event</code>s.
*/
public class Event extends EventObject {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 4048791277653274933L;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 4048791277653274933L;
- /**
- * Constructs a new event with a specified source component.
+ /**
+ * Constructs a new event with a specified source component.
*
- * @param source the source component of the event.
+ * @param source
+ * the source component of the event.
*/
public Event(Component source) {
super(source);
}
}
- /**
- * Listener interface for receiving <code>Component.Event</code>s.
+ /**
+ * Listener interface for receiving <code>Component.Event</code>s.
*/
public interface Listener extends EventListener {
- /**
+ /**
* Notifies the listener of a component event.
*
- * @param event the event that has occured.
+ * @param event
+ * the event that has occured.
*/
public void componentEvent(Component.Event event);
}
- /**
+ /**
* Registers a new component event listener for this component.
*
- * @param listener the new Listener to be registered.
+ * @param listener
+ * the new Listener to be registered.
*/
public void addListener(Component.Listener listener);
- /**
+ /**
* Removes a previously registered component event listener from this
* component.
*
- * @param listener the listener to be removed.
+ * @param listener
+ * the listener to be removed.
*/
public void removeListener(Component.Listener listener);
- /**
- * Class of all component originated <code>ErrorEvent</code>s.
+ /**
+ * Class of all component originated <code>ErrorEvent</code>s.
*/
public class ErrorEvent extends Event {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 4051323457293857333L;
-
- private ErrorMessage message;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 4051323457293857333L;
+
+ private ErrorMessage message;
/**
* Constructs a new event with a specified source component.
- * @param message the error message.
- * @param component the source component.
+ *
+ * @param message
+ * the error message.
+ * @param component
+ * the source component.
*/
- public ErrorEvent(
- ErrorMessage message,
- Component component) {
+ public ErrorEvent(ErrorMessage message, Component component) {
super(component);
this.message = message;
}
- /**
+ /**
* Gets the error message.
- * @return the error message.
+ *
+ * @return the error message.
*/
public ErrorMessage getErrorMessage() {
return this.message;
}
}
- /**
- * Listener interface for receiving <code>Component.Errors</code>s.
+ /**
+ * Listener interface for receiving <code>Component.Errors</code>s.
*/
public interface ErrorListener extends EventListener {
/**
* Notifies the listener of a component error.
- * @param event the event that has occured.
+ *
+ * @param event
+ * the event that has occured.
*/
public void componentError(Component.ErrorEvent event);
}
- /**
- * Interface implemented by components which can obtain input focus.
+ /**
+ * Interface implemented by components which can obtain input focus.
*/
public interface Focusable {
-
- /**
+
+ /**
* Sets the focus to this component.
*/
public void focus();
-
- /**
- * Gets the Tabulator index of this Focusable component.
- * @return the Positive tab order of this focusable. Negative of zero means
- * unspecified tab order.
+
+ /**
+ * Gets the Tabulator index of this Focusable component.
+ *
+ * @return the Positive tab order of this focusable. Negative of zero
+ * means unspecified tab order.
*/
public int getTabIndex();
-
- /**
+
+ /**
* Sets the Tabulator index of this Focusable component.
- * @param tabIndex the Positive tab order of this focusable. Negative of
- * zero means unspecified tab order.
+ *
+ * @param tabIndex
+ * the Positive tab order of this focusable. Negative of zero
+ * means unspecified tab order.
*/
public void setTabIndex(int tabIndex);
- /**
- * Gets the unique ID of focusable.
- * This will be used to move input focus directly to this
- * component.
+ /**
+ * Gets the unique ID of focusable. This will be used to move input
+ * focus directly to this component.
+ *
* @return the Unique id of focusable.
*/
public long getFocusableId();
-
+
}
}
diff --git a/src/com/itmill/toolkit/ui/ComponentContainer.java b/src/com/itmill/toolkit/ui/ComponentContainer.java
index 40be0a559f..5010becf10 100644
--- a/src/com/itmill/toolkit/ui/ComponentContainer.java
+++ b/src/com/itmill/toolkit/ui/ComponentContainer.java
@@ -1,218 +1,253 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
import java.util.Iterator;
-/**
- * Extension to the {@link Component} interface which adds to it the capacity
- * to contain other components. All UI elements that can have child elements
+/**
+ * Extension to the {@link Component} interface which adds to it the capacity to
+ * contain other components. All UI elements that can have child elements
* implement this interface.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface ComponentContainer extends Component {
- /**
- * Adds the component into this container.
- *
- * @param c the component to be added.
- */
- public void addComponent(Component c);
-
- /**
- * Removes the component from this container.
- *
- * @param c the component to be added.
- */
- public void removeComponent(Component c);
-
- /**
- * Removes all components from this container.
- */
- public void removeAllComponents();
-
- /**
- * Replaces the component in the container with another one without changing position.
+ /**
+ * Adds the component into this container.
*
- * <p>This method replaces component with another one is such way that the new component
- * overtakes the position of the old component. If the old component is not in the
- * container, the new component is added to the container. If the both component are
- * already in the container, their positions are swapped.
- * Component attach and detach events should be taken care as with add and remove.</p>
+ * @param c
+ * the component to be added.
+ */
+ public void addComponent(Component c);
+
+ /**
+ * Removes the component from this container.
*
- * @param oldComponent the old component that will be replaced.
- * @param newComponent the new component to be replaced.
+ * @param c
+ * the component to be added.
+ */
+ public void removeComponent(Component c);
+
+ /**
+ * Removes all components from this container.
+ */
+ public void removeAllComponents();
+
+ /**
+ * Replaces the component in the container with another one without changing
+ * position.
+ *
+ * <p>
+ * This method replaces component with another one is such way that the new
+ * component overtakes the position of the old component. If the old
+ * component is not in the container, the new component is added to the
+ * container. If the both component are already in the container, their
+ * positions are swapped. Component attach and detach events should be taken
+ * care as with add and remove.
+ * </p>
+ *
+ * @param oldComponent
+ * the old component that will be replaced.
+ * @param newComponent
+ * the new component to be replaced.
*/
public void replaceComponent(Component oldComponent, Component newComponent);
- /**
- * Gets an iterator to the collection of contained components. Using
- * this iterator it is possible to step through all components contained
- * in this container.
- *
- * @return the component iterator.
- */
- public Iterator getComponentIterator();
-
- /**
- * Moves all components from an another container into this container.
- * The components are removed from <code>source</code>.
- *
- * @param source the container which contains the components that are to
- * be moved to this container.
- */
- public void moveComponentsFrom(ComponentContainer source);
-
- /**
- * Listens the component attach events.
- * @param listener the listener to add.
- */
- public void addListener(ComponentAttachListener listener);
-
- /**
- * Stops the listening component attach events.
- * @param listener the listener to removed.
- */
- public void removeListener(ComponentAttachListener listener);
-
- /**
- * Listens the component detach events.
- */
- public void addListener(ComponentDetachListener listener);
-
- /**
- * Stops the listening component detach events.
- */
- public void removeListener(ComponentDetachListener listener);
-
- /**
- * Component attach listener interface.
+ /**
+ * Gets an iterator to the collection of contained components. Using this
+ * iterator it is possible to step through all components contained in this
+ * container.
+ *
+ * @return the component iterator.
+ */
+ public Iterator getComponentIterator();
+
+ /**
+ * Moves all components from an another container into this container. The
+ * components are removed from <code>source</code>.
+ *
+ * @param source
+ * the container which contains the components that are to be
+ * moved to this container.
+ */
+ public void moveComponentsFrom(ComponentContainer source);
+
+ /**
+ * Listens the component attach events.
+ *
+ * @param listener
+ * the listener to add.
+ */
+ public void addListener(ComponentAttachListener listener);
+
+ /**
+ * Stops the listening component attach events.
+ *
+ * @param listener
+ * the listener to removed.
+ */
+ public void removeListener(ComponentAttachListener listener);
+
+ /**
+ * Listens the component detach events.
+ */
+ public void addListener(ComponentDetachListener listener);
+
+ /**
+ * Stops the listening component detach events.
+ */
+ public void removeListener(ComponentDetachListener listener);
+
+ /**
+ * Component attach listener interface.
*/
public interface ComponentAttachListener {
/**
* A new component is attached to container.
- * @param event the component attach event.
- */
+ *
+ * @param event
+ * the component attach event.
+ */
public void componentAttachedToContainer(ComponentAttachEvent event);
- }
+ }
- /**
- * Component detach listener interface.
+ /**
+ * Component detach listener interface.
*/
public interface ComponentDetachListener {
- /**
+ /**
* A component has been detached from container.
- * @param event the component detach event.
- */
+ *
+ * @param event
+ * the component detach event.
+ */
public void componentDetachedFromContainer(ComponentDetachEvent event);
- }
+ }
- /**
- * Component attach event sent when a component is attached to container.
+ /**
+ * Component attach event sent when a component is attached to container.
*/
- public class ComponentAttachEvent extends Component.Event {
-
+ public class ComponentAttachEvent extends Component.Event {
+
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3257285812184692019L;
-
- private Component component;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3257285812184692019L;
+
+ private Component component;
- /**
+ /**
* Creates a new attach event.
- * @param container the component container the component has been detached to.
- * @param attachedComponent the component that has been attached.
+ *
+ * @param container
+ * the component container the component has been detached
+ * to.
+ * @param attachedComponent
+ * the component that has been attached.
*/
- public ComponentAttachEvent(ComponentContainer container, Component attachedComponent) {
+ public ComponentAttachEvent(ComponentContainer container,
+ Component attachedComponent) {
super(container);
- this.component = attachedComponent;
- }
-
- /**
+ this.component = attachedComponent;
+ }
+
+ /**
* Gets the component container.
- * @param the component container.
+ *
+ * @param the
+ * component container.
*/
public ComponentContainer getContainer() {
- return (ComponentContainer) getSource();
+ return (ComponentContainer) getSource();
}
-
- /**
+
+ /**
* Gets the attached component.
- * @param the attach component.
+ *
+ * @param the
+ * attach component.
*/
public Component getAttachedComponent() {
- return component;
+ return component;
}
}
- /**
- * Component detach event sent when a component is detached from container.
+ /**
+ * Component detach event sent when a component is detached from container.
*/
- public class ComponentDetachEvent extends Component.Event {
-
+ public class ComponentDetachEvent extends Component.Event {
+
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3618140052337930290L;
-
- private Component component;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3618140052337930290L;
+
+ private Component component;
- /**
+ /**
* Creates a new detach event.
- * @param container the component container the component has been detached from.
- * @param detachedComponent the component that has been detached.
+ *
+ * @param container
+ * the component container the component has been detached
+ * from.
+ * @param detachedComponent
+ * the component that has been detached.
*/
- public ComponentDetachEvent(ComponentContainer container, Component detachedComponent) {
+ public ComponentDetachEvent(ComponentContainer container,
+ Component detachedComponent) {
super(container);
- this.component = detachedComponent;
- }
-
- /**
+ this.component = detachedComponent;
+ }
+
+ /**
* Gets the component container.
- * @param the component container.
+ *
+ * @param the
+ * component container.
*/
public ComponentContainer getContainer() {
- return (ComponentContainer) getSource();
+ return (ComponentContainer) getSource();
}
-
- /**
+
+ /**
* Gets the detached component.
- * @return the detached component.
+ *
+ * @return the detached component.
*/
public Component getDetachedComponent() {
- return component;
+ return component;
}
}
diff --git a/src/com/itmill/toolkit/ui/CustomComponent.java b/src/com/itmill/toolkit/ui/CustomComponent.java
index 161b0dd64b..3aebcfeb6b 100644
--- a/src/com/itmill/toolkit/ui/CustomComponent.java
+++ b/src/com/itmill/toolkit/ui/CustomComponent.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -41,99 +41,103 @@ import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.Resource;
import com.itmill.toolkit.terminal.VariableOwner;
-/**
- * Custom component provides simple implementation of Component interface for
- * creation of new UI components by composition of existing components.
+/**
+ * Custom component provides simple implementation of Component interface for
+ * creation of new UI components by composition of existing components.
* <p>
* The component is used by inheriting the CustomComponent class and setting
- * composite root inside the Custom component. The composite root itself
- * can contain more components, but their interfaces are hidden from the
- * users.
+ * composite root inside the Custom component. The composite root itself can
+ * contain more components, but their interfaces are hidden from the users.
* </p>
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class CustomComponent implements Component {
- /**
- * The root component implementing the custom component.
+ /**
+ * The root component implementing the custom component.
*/
private Component root = null;
- /**
- * The visibility of the component.
+ /**
+ * The visibility of the component.
*/
private boolean visible = true;
- /**
- * The parent of the component.
+ /**
+ * The parent of the component.
*/
private Component parent = null;
- /**
- * Dependencies of the component, or null.
+ /**
+ * Dependencies of the component, or null.
*/
private HashSet dependencies = null;
- /**
- * Type of the component.
+ /**
+ * Type of the component.
*/
private String componentType = null;
- /**
- * List of repaint request listeners or null if not listened at all.
+ /**
+ * List of repaint request listeners or null if not listened at all.
*/
private LinkedList repaintRequestListeners = null;
- /**
- * Are all the repaint listeners notified about recent changes ?
+ /**
+ * Are all the repaint listeners notified about recent changes ?
*/
private boolean repaintRequestListenersNotified = false;
- /**
- * Constructs a new custom component.
+ /**
+ * Constructs a new custom component.
*
* <p>
- * The component is implemented by wrapping the methods of the
- * composition root component given as parameter. The composition
- * root must be set before the component can be used.
+ * The component is implemented by wrapping the methods of the composition
+ * root component given as parameter. The composition root must be set
+ * before the component can be used.
* </p>
*/
public CustomComponent() {
}
- /**
- * Constructs a new custom component.
+ /**
+ * Constructs a new custom component.
*
* <p>
- * The component is implemented by wrapping the methods of the
- * composition root component given as parameter. The composition
- * root must not be null and can not be changed after the composition.
+ * The component is implemented by wrapping the methods of the composition
+ * root component given as parameter. The composition root must not be null
+ * and can not be changed after the composition.
* </p>
*
- * @param compositionRoot the root of the composition component tree.
+ * @param compositionRoot
+ * the root of the composition component tree.
*/
public CustomComponent(Component compositionRoot) {
setCompositionRoot(compositionRoot);
}
- /**
+ /**
* Returns the composition root.
+ *
* @return the Component Composition root.
*/
protected final Component getCompositionRoot() {
return root;
}
- /**
- * Sets the compositions root.
+ /**
+ * Sets the compositions root.
* <p>
- * The composition root must be set to non-null value before the
- * component can be used. The composition root can only be set once.
+ * The composition root must be set to non-null value before the component
+ * can be used. The composition root can only be set once.
* </p>
- * @param compositionRoot the root of the composition component tree.
+ *
+ * @param compositionRoot
+ * the root of the composition component tree.
*/
protected final void setCompositionRoot(Component compositionRoot) {
if (compositionRoot != root && root != null)
@@ -144,27 +148,30 @@ public class CustomComponent implements Component {
}
/* Basic component features ------------------------------------------ */
-
+
/**
* Notifies the component that it is connected to an application.
+ *
* @see com.itmill.toolkit.ui.Component#attach()
*/
public void attach() {
if (root != null)
root.attach();
}
-
+
/**
* Notifies the component that it is detached from the application.
+ *
* @see com.itmill.toolkit.ui.Component#detach()
*/
public void detach() {
if (root != null)
root.detach();
}
-
+
/**
* Gets the component's parent application
+ *
* @see com.itmill.toolkit.ui.Component#getApplication()
*/
public Application getApplication() {
@@ -174,8 +181,9 @@ public class CustomComponent implements Component {
}
/**
- * The caption of the custom component is by default the
- * caption of the root component, or null if the root is not set.
+ * The caption of the custom component is by default the caption of the root
+ * component, or null if the root is not set.
+ *
* @see com.itmill.toolkit.ui.Component#getCaption()
*/
public String getCaption() {
@@ -185,8 +193,9 @@ public class CustomComponent implements Component {
}
/**
- * The icon of the custom component is by default the
- * icon of the root component, or null if the root is not set.
+ * The icon of the custom component is by default the icon of the root
+ * component, or null if the root is not set.
+ *
* @see com.itmill.toolkit.ui.Component#getIcon()
*/
public Resource getIcon() {
@@ -196,8 +205,9 @@ public class CustomComponent implements Component {
}
/**
- * The icon of the custom component is by default the
- * locale of the parent or null if the parent is not set.
+ * The icon of the custom component is by default the locale of the parent
+ * or null if the parent is not set.
+ *
* @see com.itmill.toolkit.ui.Component#getLocale()
*/
public Locale getLocale() {
@@ -205,9 +215,10 @@ public class CustomComponent implements Component {
return null;
return parent.getLocale();
}
-
+
/**
* Gets the visual parent of the component.
+ *
* @see com.itmill.toolkit.ui.Component#getParent()
*/
public Component getParent() {
@@ -215,16 +226,18 @@ public class CustomComponent implements Component {
}
/**
- * Custom component does not implement custom styles by default and
- * this function returns null.
+ * Custom component does not implement custom styles by default and this
+ * function returns null.
+ *
* @see com.itmill.toolkit.ui.Component#getStyle()
*/
public String getStyle() {
return null;
}
-
+
/**
* Gets the component's parent window.
+ *
* @see com.itmill.toolkit.ui.Component#getWindow()
*/
public Window getWindow() {
@@ -235,6 +248,7 @@ public class CustomComponent implements Component {
/**
* Custom component is allways enabled by default.
+ *
* @see com.itmill.toolkit.ui.Component#isEnabled()
*/
public boolean isEnabled() {
@@ -242,8 +256,10 @@ public class CustomComponent implements Component {
}
/**
- * Custom component is by default in the non-immediate mode. The immediateness
- * of the custom component is defined by the components it is composed of.
+ * Custom component is by default in the non-immediate mode. The
+ * immediateness of the custom component is defined by the components it is
+ * composed of.
+ *
* @see com.itmill.toolkit.terminal.VariableOwner#isImmediate()
*/
public boolean isImmediate() {
@@ -252,14 +268,16 @@ public class CustomComponent implements Component {
/**
* The custom components are not readonly by default.
+ *
* @see com.itmill.toolkit.ui.Component#isReadOnly()
*/
public boolean isReadOnly() {
return false;
}
-
+
/**
* Tests if the component is visible or not.
+ *
* @see com.itmill.toolkit.ui.Component#isVisible()
*/
public boolean isVisible() {
@@ -282,18 +300,15 @@ public class CustomComponent implements Component {
// Notify the listeners
if (repaintRequestListeners != null
- && !repaintRequestListeners.isEmpty()) {
+ && !repaintRequestListeners.isEmpty()) {
Object[] listeners = repaintRequestListeners.toArray();
RepaintRequestEvent event = new RepaintRequestEvent(this);
for (int i = 0; i < listeners.length; i++) {
if (alreadyNotified == null)
alreadyNotified = new LinkedList();
if (!alreadyNotified.contains(listeners[i])) {
- (
- (
- RepaintRequestListener) listeners[i])
- .repaintRequested(
- event);
+ ((RepaintRequestListener) listeners[i])
+ .repaintRequested(event);
alreadyNotified.add(listeners[i]);
}
}
@@ -327,14 +342,15 @@ public class CustomComponent implements Component {
}
}
- /**
- * The custom component is allways enabled by default.
+ /**
+ * The custom component is allways enabled by default.
*/
public void setEnabled(boolean enabled) {
}
-
+
/**
* Sets the component's parent component.
+ *
* @see com.itmill.toolkit.ui.Component#setParent(com.itmill.toolkit.ui.Component)
*/
public void setParent(Component parent) {
@@ -343,7 +359,8 @@ public class CustomComponent implements Component {
if (parent == this.parent)
return;
- // Sends the detach event if the component have been connected to a window
+ // Sends the detach event if the component have been connected to a
+ // window
if (getApplication() != null) {
detach();
this.parent = null;
@@ -359,6 +376,7 @@ public class CustomComponent implements Component {
/**
* Sets the component's to read-only mode to the specified state.
+ *
* @see com.itmill.toolkit.ui.Component#setReadOnly(boolean)
*/
public void setReadOnly(boolean readOnly) {
@@ -366,13 +384,15 @@ public class CustomComponent implements Component {
/**
* Sets the look-and-feel style of the component.
+ *
* @see com.itmill.toolkit.ui.Component#setStyle(java.lang.String)
*/
public void setStyle(String style) {
}
-
+
/**
* Sets the components visibility status.
+ *
* @see com.itmill.toolkit.ui.Component#setVisible(boolean)
*/
public void setVisible(boolean visible) {
@@ -387,9 +407,9 @@ public class CustomComponent implements Component {
/* Documented in super interface */
public void paint(PaintTarget target) throws PaintException {
if (root == null)
- throw new IllegalStateException(
- "Composition root must be set to"
- + " non-null value before the "+getClass().getName()+" can be painted");
+ throw new IllegalStateException("Composition root must be set to"
+ + " non-null value before the " + getClass().getName()
+ + " can be painted");
if (isVisible()) {
String type = getComponentType();
@@ -406,15 +426,19 @@ public class CustomComponent implements Component {
}
/**
- * Called when one or more variables handled by the implementing class
- * are changed.
- * @see com.itmill.toolkit.terminal.VariableOwner#changeVariables(java.lang.Object, java.util.Map)
+ * Called when one or more variables handled by the implementing class are
+ * changed.
+ *
+ * @see com.itmill.toolkit.terminal.VariableOwner#changeVariables(java.lang.Object,
+ * java.util.Map)
*/
public void changeVariables(Object source, Map variables) {
}
-
+
/**
- * Makes this <code>VariableOwner</code> depend on the given <code>VariableOwner</code>.
+ * Makes this <code>VariableOwner</code> depend on the given
+ * <code>VariableOwner</code>.
+ *
* @see com.itmill.toolkit.terminal.VariableOwner#dependsOn(com.itmill.toolkit.terminal.VariableOwner)
*/
public void dependsOn(VariableOwner depended) {
@@ -424,18 +448,20 @@ public class CustomComponent implements Component {
dependencies = new HashSet();
dependencies.add(depended);
}
-
+
/**
* Gets the variable change listeners this <code>VariableOwner</code>
* directly depends on.
+ *
* @see com.itmill.toolkit.terminal.VariableOwner#getDirectDependencies()
*/
public Set getDirectDependencies() {
return dependencies;
}
-
+
/**
* Removes the given component from this component's dependency list.
+ *
* @see com.itmill.toolkit.terminal.VariableOwner#removeDirectDependency(com.itmill.toolkit.terminal.VariableOwner)
*/
public void removeDirectDependency(VariableOwner depended) {
@@ -448,26 +474,31 @@ public class CustomComponent implements Component {
/* Event functions are not implemented by default -------------------- */
- /**
+ /**
* Custom component does not implement any component events by default.
- * @param listener the listener to add.
+ *
+ * @param listener
+ * the listener to add.
*/
public void addListener(Component.Listener listener) {
}
- /**
+ /**
* Custom component does not implement any component events by default.
- * @param listener the listener to remove.
+ *
+ * @param listener
+ * the listener to remove.
*/
public void removeListener(Component.Listener listener) {
}
- /**
+ /**
* Gets the component type.
*
- * The component type is textual type of the component. This is included
- * in the UIDL as component tag attribute. If the component type is null
+ * The component type is textual type of the component. This is included in
+ * the UIDL as component tag attribute. If the component type is null
* (default), the component tag is not included in the UIDL at all.
+ *
* @return the component type.
*/
public String getComponentType() {
@@ -476,12 +507,13 @@ public class CustomComponent implements Component {
/**
* Sets the component type.
- *
- * The component type is textual type of the component. This is included
- * in the UIDL as component tag attribute. If the component type is null
+ *
+ * The component type is textual type of the component. This is included in
+ * the UIDL as component tag attribute. If the component type is null
* (default), the component tag is not included in the UIDL at all.
*
- * @param componentType the componentType to set.
+ * @param componentType
+ * the componentType to set.
*/
public void setComponentType(String componentType) {
this.componentType = componentType;
diff --git a/src/com/itmill/toolkit/ui/CustomLayout.java b/src/com/itmill/toolkit/ui/CustomLayout.java
index 7302f20b71..06ec7f4f10 100644
--- a/src/com/itmill/toolkit/ui/CustomLayout.java
+++ b/src/com/itmill/toolkit/ui/CustomLayout.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -34,62 +34,66 @@ import com.itmill.toolkit.terminal.PaintTarget;
import java.util.Iterator;
import java.util.HashMap;
-/**
+/**
* <p>
- * A container component with freely designed layout and style. The
- * container consists of items with textually represented locations. Each
- * item contains one sub-component. The adapter and theme are resposible for
- * rendering the layout with given style by placing the items on the screen
- * in defined locations.
+ * A container component with freely designed layout and style. The container
+ * consists of items with textually represented locations. Each item contains
+ * one sub-component. The adapter and theme are resposible for rendering the
+ * layout with given style by placing the items on the screen in defined
+ * locations.
* </p>
- *
+ *
* <p>
- * The definition of locations is not fixed - the each style can define
- * its locations in a way that is suitable for it. One typical example would
- * be to create visual design for a website as a custom layout: the visual
- * design could define locations for "menu", "body" and "title" for example.
- * The layout would then be implemented as XLS-template with for given
- * style.
+ * The definition of locations is not fixed - the each style can define its
+ * locations in a way that is suitable for it. One typical example would be to
+ * create visual design for a website as a custom layout: the visual design
+ * could define locations for "menu", "body" and "title" for example. The layout
+ * would then be implemented as XLS-template with for given style.
* </p>
- *
+ *
* <p>
- * The default theme handles the styles that are not defined by just
- * drawing the subcomponents with flowlayout.
+ * The default theme handles the styles that are not defined by just drawing the
+ * subcomponents with flowlayout.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class CustomLayout extends AbstractComponentContainer implements Layout {
- /**
- * Custom layout slots containing the components.
+ /**
+ * Custom layout slots containing the components.
*/
private HashMap slots = new HashMap();
- /**
- * Constructor for custom layout with given style.
+ /**
+ * Constructor for custom layout with given style.
*/
public CustomLayout(String style) {
setStyle(style);
}
- /**
+ /**
* Gets the component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "customlayout";
}
- /**
+ /**
* Adds the component into this container to given location.
- * @param c the component to be added.
- * @param location the location of the component.
+ *
+ * @param c
+ * the component to be added.
+ * @param location
+ * the location of the component.
*/
public void addComponent(Component c, String location) {
- Component old = (Component)slots.get(location);
+ Component old = (Component) slots.get(location);
if (old != null) {
removeComponent(old);
}
@@ -99,61 +103,72 @@ public class CustomLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
+ /**
* Adds the component into this container. The component is added without
- * specifying the location (empty string is then used as location). Only
- * one component can be added to the default "" location and adding
- * more components into that location overwrites the old components.
- * @param c the component to be added.
+ * specifying the location (empty string is then used as location). Only one
+ * component can be added to the default "" location and adding more
+ * components into that location overwrites the old components.
+ *
+ * @param c
+ * the component to be added.
*/
public void addComponent(Component c) {
this.addComponent(c, "");
}
- /**
+ /**
* Removes the component from this container.
- * @param c the component to be removed.
+ *
+ * @param c
+ * the component to be removed.
*/
public void removeComponent(Component c) {
- if (c == null) return;
+ if (c == null)
+ return;
slots.values().remove(c);
c.setParent(null);
fireComponentDetachEvent(c);
requestRepaint();
}
- /**
+ /**
* Removes the component from this container from given location.
- * @param location the Location identifier of the component.
+ *
+ * @param location
+ * the Location identifier of the component.
*/
public void removeComponent(String location) {
this.removeComponent((Component) slots.get(location));
}
- /**
- * Gets the component container iterator for going trough all the components in
- * the container.
+ /**
+ * Gets the component container iterator for going trough all the components
+ * in the container.
+ *
* @return the Iterator of the components inside the container.
*/
public Iterator getComponentIterator() {
return slots.values().iterator();
}
- /**
+ /**
* Gets the child-component by its location.
*
- * @param location the name of the location where the requested
- * component resides.
+ * @param location
+ * the name of the location where the requested component
+ * resides.
* @return the Component in the given location or null if not found.
*/
public Component getComponent(String location) {
return (Component) slots.get(location);
}
- /**
+ /**
* Paints the content of this component.
- * @param target
- * @throws PaintException if the paint operation failed.
+ *
+ * @param target
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
@@ -171,30 +186,30 @@ public class CustomLayout extends AbstractComponentContainer implements Layout {
target.endTag("location");
}
}
-
+
/* Documented in superclass */
- public void replaceComponent(
- Component oldComponent,
- Component newComponent) {
+ public void replaceComponent(Component oldComponent, Component newComponent) {
- // Gets the locations
+ // Gets the locations
String oldLocation = null;
- String newLocation = null;
- for (Iterator i=slots.keySet().iterator(); i.hasNext();) {
+ String newLocation = null;
+ for (Iterator i = slots.keySet().iterator(); i.hasNext();) {
String location = (String) i.next();
Component component = (Component) slots.get(location);
- if (component == oldComponent) oldLocation = location;
- if (component == newComponent) newLocation = location;
- }
+ if (component == oldComponent)
+ oldLocation = location;
+ if (component == newComponent)
+ newLocation = location;
+ }
if (oldLocation == null)
addComponent(newComponent);
else if (newLocation == null) {
removeComponent(oldLocation);
- addComponent(newComponent,oldLocation);
+ addComponent(newComponent, oldLocation);
} else {
- slots.put(newLocation,oldComponent);
- slots.put(oldLocation,newComponent);
+ slots.put(newLocation, oldComponent);
+ slots.put(oldLocation, newComponent);
requestRepaint();
}
}
diff --git a/src/com/itmill/toolkit/ui/DateField.java b/src/com/itmill/toolkit/ui/DateField.java
index a8eefe4c86..17a10e2423 100644
--- a/src/com/itmill/toolkit/ui/DateField.java
+++ b/src/com/itmill/toolkit/ui/DateField.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -59,370 +59,372 @@ import com.itmill.toolkit.terminal.PaintTarget;
*/
public class DateField extends AbstractField {
- /* Private members ************************************************* */
-
- /**
- * Resolution identifier: milliseconds.
- */
- public static final int RESOLUTION_MSEC = 0;
-
- /**
- * Resolution identifier: seconds.
- */
- public static final int RESOLUTION_SEC = 1;
-
- /**
- * Resolution identifier: minutes.
- */
- public static final int RESOLUTION_MIN = 2;
-
- /**
- * Resolution identifier: hours.
- */
- public static final int RESOLUTION_HOUR = 3;
-
- /**
- * Resolution identifier: days.
- */
- public static final int RESOLUTION_DAY = 4;
-
- /**
- * Resolution identifier: months.
- */
- public static final int RESOLUTION_MONTH = 5;
-
- /**
- * Resolution identifier: years.
- */
- public static final int RESOLUTION_YEAR = 6;
-
- /**
- * Specified smallest modifiable unit.
- */
- private int resolution = RESOLUTION_MSEC;
-
- /**
- * Specified largest modifiable unit.
- */
- private static final int largestModifiable = RESOLUTION_YEAR;
-
- /**
- * The internal calendar to be used in java.utl.Date conversions.
- */
- private Calendar calendar;
-
- /* Constructors **************************************************** */
-
- /**
- * Constructs an empty <code>DateField</code> with no caption.
- */
- public DateField() {
- }
-
- /**
- * Constructs an empty <code>DateField</code> with caption.
- *
- * @param caption
- * the caption of the datefield.
- */
- public DateField(String caption) {
- setCaption(caption);
- }
-
- /**
- * Constructs a new <code>DateField</code> that's bound to the specified
- * <code>Property</code> and has the given caption <code>String</code>.
- *
- * @param caption
- * the caption <code>String</code> for the editor.
- * @param dataSource
- * the Property to be edited with this editor.
- */
- public DateField(String caption, Property dataSource) {
- this(dataSource);
- setCaption(caption);
- }
-
- /**
- * Constructs a new <code>DateField</code> that's bound to the specified
- * <code>Property</code> and has no caption.
- *
- * @param dataSource
- * the Property to be edited with this editor.
- */
- public DateField(Property dataSource) throws IllegalArgumentException {
- if (!Date.class.isAssignableFrom(dataSource.getType()))
- throw new IllegalArgumentException("Can't use "
- + dataSource.getType().getName()
- + " typed property as datasource");
-
- setPropertyDataSource(dataSource);
- }
-
- /**
- * Constructs a new <code>DateField</code> with the given caption and
- * initial text contents. The editor constructed this way will not be bound
- * to a Property unless
- * {@link com.itmill.toolkit.data.Property.Viewer#setPropertyDataSource(Property)}
- * is called to bind it.
- *
- * @param caption
- * the caption <code>String</code> for the editor.
- * @param value
- * the Date value.
- */
- public DateField(String caption, Date value) {
- setValue(value);
- setCaption(caption);
- }
-
- /* Component basic features ********************************************* */
-
- /*
- * Paints this component. Don't add a JavaDoc comment here, we use the
- * default documentation from implemented interface.
- */
- public void paintContent(PaintTarget target) throws PaintException {
- super.paintContent(target);
-
- // Adds the locale as attribute
- Locale l = getLocale();
- if (l != null) {
- target.addAttribute("locale",l.toString());
- }
-
- // Gets the calendar
- Calendar calendar = getCalendar();
- Date currentDate = (Date) getValue();
-
- for (int r = resolution; r <= largestModifiable; r++)
- switch (r) {
- case RESOLUTION_MSEC:
- target.addVariable(this, "msec", currentDate != null ? calendar
- .get(Calendar.MILLISECOND) : -1);
- break;
- case RESOLUTION_SEC:
- target.addVariable(this, "sec", currentDate != null ? calendar
- .get(Calendar.SECOND) : -1);
- break;
- case RESOLUTION_MIN:
- target.addVariable(this, "min", currentDate != null ? calendar
- .get(Calendar.MINUTE) : -1);
- break;
- case RESOLUTION_HOUR:
- target.addVariable(this, "hour", currentDate != null ? calendar
- .get(Calendar.HOUR_OF_DAY) : -1);
- break;
- case RESOLUTION_DAY:
- target.addVariable(this, "day", currentDate != null ? calendar
- .get(Calendar.DAY_OF_MONTH) : -1);
- break;
- case RESOLUTION_MONTH:
- target.addVariable(this, "month",
- currentDate != null ? calendar.get(Calendar.MONTH) + 1
- : -1);
- break;
- case RESOLUTION_YEAR:
- target.addVariable(this, "year", currentDate != null ? calendar
- .get(Calendar.YEAR) : -1);
- break;
- }
- }
-
- /*
- * Gets the components UIDL tag string. Don't add a JavaDoc comment here, we
- * use the default documentation from implemented interface.
- */
- public String getTag() {
- return "datefield";
- }
-
- /*
- * Invoked when a variable of the component changes. Don't add a JavaDoc
- * comment here, we use the default documentation from implemented
- * interface.
- */
- public void changeVariables(Object source, Map variables) {
-
- if (!isReadOnly()
- && (variables.containsKey("year")
- || variables.containsKey("month")
- || variables.containsKey("day")
- || variables.containsKey("hour")
- || variables.containsKey("min")
- || variables.containsKey("sec") || variables
- .containsKey("msec"))) {
-
- // Old and new dates
- Date oldDate = (Date) getValue();
- Date newDate = null;
-
- // Gets the new date in parts
- // Null values are converted to negative values.
- int year = variables.containsKey("year") ? (variables.get("year") == null ? -1
- : ((Integer) variables.get("year")).intValue())
- : -1;
- int month = variables.containsKey("month") ? (variables
- .get("month") == null ? -1 : ((Integer) variables
- .get("month")).intValue() - 1) : -1;
- int day = variables.containsKey("day") ? (variables.get("day") == null ? -1
- : ((Integer) variables.get("day")).intValue())
- : -1;
- int hour = variables.containsKey("hour") ? (variables.get("hour") == null ? -1
- : ((Integer) variables.get("hour")).intValue())
- : -1;
- int min = variables.containsKey("min") ? (variables.get("min") == null ? -1
- : ((Integer) variables.get("min")).intValue())
- : -1;
- int sec = variables.containsKey("sec") ? (variables.get("sec") == null ? -1
- : ((Integer) variables.get("sec")).intValue())
- : -1;
- int msec = variables.containsKey("msec") ? (variables.get("msec") == null ? -1
- : ((Integer) variables.get("msec")).intValue())
- : -1;
-
- // If all of the components is < 0 use the previous value
- if (year < 0 && month < 0 && day < 0 && hour < 0 && min < 0
- && sec < 0 && msec < 0)
- newDate = null;
- else {
-
- // Clone the calendar for date operation
- Calendar cal = (Calendar) getCalendar();
-
- // Make sure that meaningful values exists
- // Use the previous value if some of the variables
- // have not been changed.
- year = year < 0 ? cal.get(Calendar.YEAR) : year;
- month = month < 0 ? cal.get(Calendar.MONTH) : month;
- day = day < 0 ? cal.get(Calendar.DAY_OF_MONTH) : day;
- hour = hour < 0 ? cal.get(Calendar.HOUR_OF_DAY) : hour;
- min = min < 0 ? cal.get(Calendar.MINUTE) : min;
- sec = sec < 0 ? cal.get(Calendar.SECOND) : sec;
- msec = msec < 0 ? cal.get(Calendar.MILLISECOND) : msec;
-
- // Sets the calendar fields
- cal.set(Calendar.YEAR, year);
- cal.set(Calendar.MONTH, month);
- cal.set(Calendar.DAY_OF_MONTH, day);
- cal.set(Calendar.HOUR_OF_DAY, hour);
- cal.set(Calendar.MINUTE, min);
- cal.set(Calendar.SECOND, sec);
- cal.set(Calendar.MILLISECOND, msec);
-
- // Assigns the date
- newDate = cal.getTime();
- }
-
- if (newDate != oldDate
- && (newDate == null || !newDate.equals(oldDate)))
- setValue(newDate);
- }
- }
-
- /* Property features **************************************************** */
-
- /*
- * Gets the edited property's type. Don't add a JavaDoc comment here, we use
- * the default documentation from implemented interface.
- */
- public Class getType() {
- return Date.class;
- }
-
- /*
- * Returns the value of the property in human readable textual format. Don't
- * add a JavaDoc comment here, we use the default documentation from
- * implemented interface.
- */
- public String toString() {
- Date value = (Date) getValue();
- if (value != null)
- return value.toString();
- return null;
- }
-
- /*
- * Sets the value of the property. Don't add a JavaDoc comment here, we use
- * the default documentation from implemented interface.
- */
- public void setValue(Object newValue) throws Property.ReadOnlyException,
- Property.ConversionException {
-
- // Allows setting dates directly
- if (newValue == null || newValue instanceof Date)
- super.setValue(newValue);
- else {
-
- // Try to parse as string
- try {
- SimpleDateFormat parser = new SimpleDateFormat();
- Date val = parser.parse(newValue.toString());
- super.setValue(val);
- } catch (ParseException e) {
- throw new Property.ConversionException(e.getMessage());
- }
- }
- }
-
- /**
- * Sets the DateField datasource. Datasource type must assignable to Date.
- *
- * @see com.itmill.toolkit.data.Property.Viewer#setPropertyDataSource(Property)
- */
- public void setPropertyDataSource(Property newDataSource) {
- if (newDataSource == null
- || Date.class.isAssignableFrom(newDataSource.getType()))
- super.setPropertyDataSource(newDataSource);
- else
- throw new IllegalArgumentException(
- "DateField only supports Date properties");
- }
-
- /**
- * Gets the resolution.
- *
- * @return int
- */
- public int getResolution() {
- return resolution;
- }
-
- /**
- * Sets the resolution of the DateField.
- *
- * @param resolution
- * the resolution to set.
- */
- public void setResolution(int resolution) {
- this.resolution = resolution;
- }
-
- /**
- * Returns new instance calendar used in Date conversions.
- *
- * Returns new clone of the calendar object initialized using the the
- * current date (if available)
- *
- * If this is no calendar is assigned the <code>Calendar.getInstance</code> is used.
- * @return the Calendar.
- * @see #setCalendar(Calendar)
- */
- private Calendar getCalendar() {
-
- // Makes sure we have an calendar instance
- if (this.calendar == null) {
- this.calendar = Calendar.getInstance();
- }
-
- // Clone the instance
- Calendar newCal = (Calendar) this.calendar.clone();
-
- // Assigns the current time tom calendar.
- Date currentDate = (Date) getValue();
- if (currentDate != null)
- newCal.setTime(currentDate);
-
- return newCal;
- }
+ /* Private members ************************************************* */
+
+ /**
+ * Resolution identifier: milliseconds.
+ */
+ public static final int RESOLUTION_MSEC = 0;
+
+ /**
+ * Resolution identifier: seconds.
+ */
+ public static final int RESOLUTION_SEC = 1;
+
+ /**
+ * Resolution identifier: minutes.
+ */
+ public static final int RESOLUTION_MIN = 2;
+
+ /**
+ * Resolution identifier: hours.
+ */
+ public static final int RESOLUTION_HOUR = 3;
+
+ /**
+ * Resolution identifier: days.
+ */
+ public static final int RESOLUTION_DAY = 4;
+
+ /**
+ * Resolution identifier: months.
+ */
+ public static final int RESOLUTION_MONTH = 5;
+
+ /**
+ * Resolution identifier: years.
+ */
+ public static final int RESOLUTION_YEAR = 6;
+
+ /**
+ * Specified smallest modifiable unit.
+ */
+ private int resolution = RESOLUTION_MSEC;
+
+ /**
+ * Specified largest modifiable unit.
+ */
+ private static final int largestModifiable = RESOLUTION_YEAR;
+
+ /**
+ * The internal calendar to be used in java.utl.Date conversions.
+ */
+ private Calendar calendar;
+
+ /* Constructors **************************************************** */
+
+ /**
+ * Constructs an empty <code>DateField</code> with no caption.
+ */
+ public DateField() {
+ }
+
+ /**
+ * Constructs an empty <code>DateField</code> with caption.
+ *
+ * @param caption
+ * the caption of the datefield.
+ */
+ public DateField(String caption) {
+ setCaption(caption);
+ }
+
+ /**
+ * Constructs a new <code>DateField</code> that's bound to the specified
+ * <code>Property</code> and has the given caption <code>String</code>.
+ *
+ * @param caption
+ * the caption <code>String</code> for the editor.
+ * @param dataSource
+ * the Property to be edited with this editor.
+ */
+ public DateField(String caption, Property dataSource) {
+ this(dataSource);
+ setCaption(caption);
+ }
+
+ /**
+ * Constructs a new <code>DateField</code> that's bound to the specified
+ * <code>Property</code> and has no caption.
+ *
+ * @param dataSource
+ * the Property to be edited with this editor.
+ */
+ public DateField(Property dataSource) throws IllegalArgumentException {
+ if (!Date.class.isAssignableFrom(dataSource.getType()))
+ throw new IllegalArgumentException("Can't use "
+ + dataSource.getType().getName()
+ + " typed property as datasource");
+
+ setPropertyDataSource(dataSource);
+ }
+
+ /**
+ * Constructs a new <code>DateField</code> with the given caption and
+ * initial text contents. The editor constructed this way will not be bound
+ * to a Property unless
+ * {@link com.itmill.toolkit.data.Property.Viewer#setPropertyDataSource(Property)}
+ * is called to bind it.
+ *
+ * @param caption
+ * the caption <code>String</code> for the editor.
+ * @param value
+ * the Date value.
+ */
+ public DateField(String caption, Date value) {
+ setValue(value);
+ setCaption(caption);
+ }
+
+ /* Component basic features ********************************************* */
+
+ /*
+ * Paints this component. Don't add a JavaDoc comment here, we use the
+ * default documentation from implemented interface.
+ */
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+
+ // Adds the locale as attribute
+ Locale l = getLocale();
+ if (l != null) {
+ target.addAttribute("locale", l.toString());
+ }
+
+ // Gets the calendar
+ Calendar calendar = getCalendar();
+ Date currentDate = (Date) getValue();
+
+ for (int r = resolution; r <= largestModifiable; r++)
+ switch (r) {
+ case RESOLUTION_MSEC:
+ target.addVariable(this, "msec", currentDate != null ? calendar
+ .get(Calendar.MILLISECOND) : -1);
+ break;
+ case RESOLUTION_SEC:
+ target.addVariable(this, "sec", currentDate != null ? calendar
+ .get(Calendar.SECOND) : -1);
+ break;
+ case RESOLUTION_MIN:
+ target.addVariable(this, "min", currentDate != null ? calendar
+ .get(Calendar.MINUTE) : -1);
+ break;
+ case RESOLUTION_HOUR:
+ target.addVariable(this, "hour", currentDate != null ? calendar
+ .get(Calendar.HOUR_OF_DAY) : -1);
+ break;
+ case RESOLUTION_DAY:
+ target.addVariable(this, "day", currentDate != null ? calendar
+ .get(Calendar.DAY_OF_MONTH) : -1);
+ break;
+ case RESOLUTION_MONTH:
+ target.addVariable(this, "month",
+ currentDate != null ? calendar.get(Calendar.MONTH) + 1
+ : -1);
+ break;
+ case RESOLUTION_YEAR:
+ target.addVariable(this, "year", currentDate != null ? calendar
+ .get(Calendar.YEAR) : -1);
+ break;
+ }
+ }
+
+ /*
+ * Gets the components UIDL tag string. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
+ */
+ public String getTag() {
+ return "datefield";
+ }
+
+ /*
+ * Invoked when a variable of the component changes. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
+ */
+ public void changeVariables(Object source, Map variables) {
+
+ if (!isReadOnly()
+ && (variables.containsKey("year")
+ || variables.containsKey("month")
+ || variables.containsKey("day")
+ || variables.containsKey("hour")
+ || variables.containsKey("min")
+ || variables.containsKey("sec") || variables
+ .containsKey("msec"))) {
+
+ // Old and new dates
+ Date oldDate = (Date) getValue();
+ Date newDate = null;
+
+ // Gets the new date in parts
+ // Null values are converted to negative values.
+ int year = variables.containsKey("year") ? (variables.get("year") == null ? -1
+ : ((Integer) variables.get("year")).intValue())
+ : -1;
+ int month = variables.containsKey("month") ? (variables
+ .get("month") == null ? -1 : ((Integer) variables
+ .get("month")).intValue() - 1) : -1;
+ int day = variables.containsKey("day") ? (variables.get("day") == null ? -1
+ : ((Integer) variables.get("day")).intValue())
+ : -1;
+ int hour = variables.containsKey("hour") ? (variables.get("hour") == null ? -1
+ : ((Integer) variables.get("hour")).intValue())
+ : -1;
+ int min = variables.containsKey("min") ? (variables.get("min") == null ? -1
+ : ((Integer) variables.get("min")).intValue())
+ : -1;
+ int sec = variables.containsKey("sec") ? (variables.get("sec") == null ? -1
+ : ((Integer) variables.get("sec")).intValue())
+ : -1;
+ int msec = variables.containsKey("msec") ? (variables.get("msec") == null ? -1
+ : ((Integer) variables.get("msec")).intValue())
+ : -1;
+
+ // If all of the components is < 0 use the previous value
+ if (year < 0 && month < 0 && day < 0 && hour < 0 && min < 0
+ && sec < 0 && msec < 0)
+ newDate = null;
+ else {
+
+ // Clone the calendar for date operation
+ Calendar cal = (Calendar) getCalendar();
+
+ // Make sure that meaningful values exists
+ // Use the previous value if some of the variables
+ // have not been changed.
+ year = year < 0 ? cal.get(Calendar.YEAR) : year;
+ month = month < 0 ? cal.get(Calendar.MONTH) : month;
+ day = day < 0 ? cal.get(Calendar.DAY_OF_MONTH) : day;
+ hour = hour < 0 ? cal.get(Calendar.HOUR_OF_DAY) : hour;
+ min = min < 0 ? cal.get(Calendar.MINUTE) : min;
+ sec = sec < 0 ? cal.get(Calendar.SECOND) : sec;
+ msec = msec < 0 ? cal.get(Calendar.MILLISECOND) : msec;
+
+ // Sets the calendar fields
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.MONTH, month);
+ cal.set(Calendar.DAY_OF_MONTH, day);
+ cal.set(Calendar.HOUR_OF_DAY, hour);
+ cal.set(Calendar.MINUTE, min);
+ cal.set(Calendar.SECOND, sec);
+ cal.set(Calendar.MILLISECOND, msec);
+
+ // Assigns the date
+ newDate = cal.getTime();
+ }
+
+ if (newDate != oldDate
+ && (newDate == null || !newDate.equals(oldDate)))
+ setValue(newDate);
+ }
+ }
+
+ /* Property features **************************************************** */
+
+ /*
+ * Gets the edited property's type. Don't add a JavaDoc comment here, we use
+ * the default documentation from implemented interface.
+ */
+ public Class getType() {
+ return Date.class;
+ }
+
+ /*
+ * Returns the value of the property in human readable textual format. Don't
+ * add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
+ */
+ public String toString() {
+ Date value = (Date) getValue();
+ if (value != null)
+ return value.toString();
+ return null;
+ }
+
+ /*
+ * Sets the value of the property. Don't add a JavaDoc comment here, we use
+ * the default documentation from implemented interface.
+ */
+ public void setValue(Object newValue) throws Property.ReadOnlyException,
+ Property.ConversionException {
+
+ // Allows setting dates directly
+ if (newValue == null || newValue instanceof Date)
+ super.setValue(newValue);
+ else {
+
+ // Try to parse as string
+ try {
+ SimpleDateFormat parser = new SimpleDateFormat();
+ Date val = parser.parse(newValue.toString());
+ super.setValue(val);
+ } catch (ParseException e) {
+ throw new Property.ConversionException(e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Sets the DateField datasource. Datasource type must assignable to Date.
+ *
+ * @see com.itmill.toolkit.data.Property.Viewer#setPropertyDataSource(Property)
+ */
+ public void setPropertyDataSource(Property newDataSource) {
+ if (newDataSource == null
+ || Date.class.isAssignableFrom(newDataSource.getType()))
+ super.setPropertyDataSource(newDataSource);
+ else
+ throw new IllegalArgumentException(
+ "DateField only supports Date properties");
+ }
+
+ /**
+ * Gets the resolution.
+ *
+ * @return int
+ */
+ public int getResolution() {
+ return resolution;
+ }
+
+ /**
+ * Sets the resolution of the DateField.
+ *
+ * @param resolution
+ * the resolution to set.
+ */
+ public void setResolution(int resolution) {
+ this.resolution = resolution;
+ }
+
+ /**
+ * Returns new instance calendar used in Date conversions.
+ *
+ * Returns new clone of the calendar object initialized using the the
+ * current date (if available)
+ *
+ * If this is no calendar is assigned the <code>Calendar.getInstance</code>
+ * is used.
+ *
+ * @return the Calendar.
+ * @see #setCalendar(Calendar)
+ */
+ private Calendar getCalendar() {
+
+ // Makes sure we have an calendar instance
+ if (this.calendar == null) {
+ this.calendar = Calendar.getInstance();
+ }
+
+ // Clone the instance
+ Calendar newCal = (Calendar) this.calendar.clone();
+
+ // Assigns the current time tom calendar.
+ Date currentDate = (Date) getValue();
+ if (currentDate != null)
+ newCal.setTime(currentDate);
+
+ return newCal;
+ }
}
diff --git a/src/com/itmill/toolkit/ui/Embedded.java b/src/com/itmill/toolkit/ui/Embedded.java
index 18120e5e24..a3c7629e77 100644
--- a/src/com/itmill/toolkit/ui/Embedded.java
+++ b/src/com/itmill/toolkit/ui/Embedded.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -36,97 +36,110 @@ import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.Resource;
import com.itmill.toolkit.terminal.Sizeable;
-/**
+/**
* Component for embedding external objects.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Embedded extends AbstractComponent implements Sizeable {
- /**
- * General object type.
+ /**
+ * General object type.
*/
public static final int TYPE_OBJECT = 0;
- /**
- * Image types.
+ /**
+ * Image types.
*/
public static final int TYPE_IMAGE = 1;
- /**
- * Type of the object.
+ /**
+ * Type of the object.
*/
private int type = TYPE_OBJECT;
- /**
- * Source of the embedded object.
+ /**
+ * Source of the embedded object.
*/
private Resource source = null;
- /**
- * Dimensions of the object.
+ /**
+ * Dimensions of the object.
*/
private int width = -1;
+
private int height = -1;
+
private int widthUnits = Sizeable.UNITS_PIXELS;
+
private int heightUnits = Sizeable.UNITS_PIXELS;
- /**
- * Generic object attributes.
+ /**
+ * Generic object attributes.
*/
private String mimeType = null;
+
private String standby = null;
- /**
- * Hash of object parameteres.
+ /**
+ * Hash of object parameteres.
*/
private Hashtable parameters = new Hashtable();
- /**
- * Applet or other client side runnable properties.
+ /**
+ * Applet or other client side runnable properties.
*/
private String codebase = null;
+
private String codetype = null;
+
private String classId = null;
+
private String archive = null;
- /**
+ /**
* Creates a new empty Embedded object.
*/
public Embedded() {
}
- /**
+ /**
* Creates a new empty Embedded object with caption.
+ *
* @param caption
*/
public Embedded(String caption) {
setCaption(caption);
}
- /**
- * Creates a new Embedded object whose contents is loaded from given resource.
- * The dimensions are assumed if possible. The type is guessed from resource.
+ /**
+ * Creates a new Embedded object whose contents is loaded from given
+ * resource. The dimensions are assumed if possible. The type is guessed
+ * from resource.
+ *
* @param caption
- * @param source the Source of the embedded object.
+ * @param source
+ * the Source of the embedded object.
*/
public Embedded(String caption, Resource source) {
setCaption(caption);
setSource(source);
}
- /**
+ /**
* Gets the component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "embedded";
}
- /**
- * Invoked when the component state should be painted.
+ /**
+ * Invoked when the component state should be painted.
*/
public void paintContent(PaintTarget target) throws PaintException {
@@ -139,13 +152,11 @@ public class Embedded extends AbstractComponent implements Sizeable {
// Dimensions
if (width > 0)
- target.addAttribute(
- "width",
- "" + width + Sizeable.UNIT_SYMBOLS[this.widthUnits]);
+ target.addAttribute("width", "" + width
+ + Sizeable.UNIT_SYMBOLS[this.widthUnits]);
if (height > 0)
- target.addAttribute(
- "height",
- "" + height + Sizeable.UNIT_SYMBOLS[this.heightUnits]);
+ target.addAttribute("height", "" + height
+ + Sizeable.UNIT_SYMBOLS[this.heightUnits]);
if (mimeType != null && !"".equals(mimeType))
target.addAttribute("mimetype", mimeType);
if (classId != null && !"".equals(classId))
@@ -169,40 +180,47 @@ public class Embedded extends AbstractComponent implements Sizeable {
}
}
- /**
- * Sets an object parameter.
- * Parameters are optional information, and they are passed to the
- * instantiated object. Parameters are are stored as name value pairs.
- * This overrides the previous value assigned to this parameter.
- * @param name the name of the parameter.
- * @param value the value of the parameter.
+ /**
+ * Sets an object parameter. Parameters are optional information, and they
+ * are passed to the instantiated object. Parameters are are stored as name
+ * value pairs. This overrides the previous value assigned to this
+ * parameter.
+ *
+ * @param name
+ * the name of the parameter.
+ * @param value
+ * the value of the parameter.
*/
public void setParameter(String name, String value) {
parameters.put(name, value);
requestRepaint();
}
- /**
- * Gets the value of an object parameter.
- * Parameters are optional information, and they are passed to the
- * instantiated object. Parameters are are stored as name value pairs.
+ /**
+ * Gets the value of an object parameter. Parameters are optional
+ * information, and they are passed to the instantiated object. Parameters
+ * are are stored as name value pairs.
+ *
* @return the Value of parameter or null if not found.
*/
public String getParameter(String name) {
return (String) parameters.get(name);
}
- /**
+ /**
* Removes an object parameter from the list.
- * @param name the name of the parameter to remove.
+ *
+ * @param name
+ * the name of the parameter to remove.
*/
public void removeParameter(String name) {
parameters.remove(name);
requestRepaint();
}
- /**
+ /**
* Gets the embedded object parameter names.
+ *
* @return the Iterator of parameters names.
*/
public Iterator getParameterNames() {
@@ -210,7 +228,9 @@ public class Embedded extends AbstractComponent implements Sizeable {
}
/**
- * Gets the codebase, the root-path used to access resources with relative paths.
+ * Gets the codebase, the root-path used to access resources with relative
+ * paths.
+ *
* @return the code base.
*/
public String getCodebase() {
@@ -219,6 +239,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Gets the MIME-Type of the code.
+ *
* @return the MIME-Type of the code.
*/
public String getCodetype() {
@@ -227,6 +248,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Gets the MIME-Type of the object.
+ *
* @return the MIME-Type of the object.
*/
public String getMimeType() {
@@ -234,8 +256,8 @@ public class Embedded extends AbstractComponent implements Sizeable {
}
/**
- * Gets the standby text displayed when
- * the object is loading.
+ * Gets the standby text displayed when the object is loading.
+ *
* @return the standby text.
*/
public String getStandby() {
@@ -243,12 +265,15 @@ public class Embedded extends AbstractComponent implements Sizeable {
}
/**
- * Sets the codebase, the root-path used to access resources with relative paths.
- * @param codebase the codebase to set.
+ * Sets the codebase, the root-path used to access resources with relative
+ * paths.
+ *
+ * @param codebase
+ * the codebase to set.
*/
public void setCodebase(String codebase) {
if (codebase != this.codebase
- || (codebase != null && !codebase.equals(this.codebase))) {
+ || (codebase != null && !codebase.equals(this.codebase))) {
this.codebase = codebase;
requestRepaint();
}
@@ -256,11 +281,13 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Sets the codetype, the MIME-Type of the code.
- * @param codetype the codetype to set.
+ *
+ * @param codetype
+ * the codetype to set.
*/
public void setCodetype(String codetype) {
if (codetype != this.codetype
- || (codetype != null && !codetype.equals(this.codetype))) {
+ || (codetype != null && !codetype.equals(this.codetype))) {
this.codetype = codetype;
requestRepaint();
}
@@ -268,11 +295,13 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Sets the mimeType, the MIME-Type of the object.
- * @param mimeType the mimeType to set.
+ *
+ * @param mimeType
+ * the mimeType to set.
*/
public void setMimeType(String mimeType) {
if (mimeType != this.mimeType
- || (mimeType != null && !mimeType.equals(this.mimeType))) {
+ || (mimeType != null && !mimeType.equals(this.mimeType))) {
this.mimeType = mimeType;
requestRepaint();
}
@@ -280,19 +309,22 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Sets the standby, the text to display while loading the object.
- * @param standby the standby to set.
+ *
+ * @param standby
+ * the standby to set.
*/
public void setStandby(String standby) {
if (standby != this.standby
- || (standby != null && !standby.equals(this.standby))) {
+ || (standby != null && !standby.equals(this.standby))) {
this.standby = standby;
requestRepaint();
}
}
/**
- * Returns the visual height of the object.
- * Default height is -1, which is interpreted as "unspecified".
+ * Returns the visual height of the object. Default height is -1, which is
+ * interpreted as "unspecified".
+ *
* @return the height in units specified by heightUnits property.
*/
public int getHeight() {
@@ -300,18 +332,21 @@ public class Embedded extends AbstractComponent implements Sizeable {
}
/**
- * Returns the visual width of the object.
- * Default width is -1, which is interpreted as "unspecified".
+ * Returns the visual width of the object. Default width is -1, which is
+ * interpreted as "unspecified".
+ *
* @return the width in units specified by widthUnits property.
*/
public int getWidth() {
return width;
}
- /**
- * Sets the visual height of the object.
- * Default height is -1, which is interpreted as "unspecified".
- * @param height the height in units specified by heightUnits property.
+ /**
+ * Sets the visual height of the object. Default height is -1, which is
+ * interpreted as "unspecified".
+ *
+ * @param height
+ * the height in units specified by heightUnits property.
*/
public void setHeight(int height) {
if (this.height != height) {
@@ -320,10 +355,12 @@ public class Embedded extends AbstractComponent implements Sizeable {
}
}
- /**
- * Sets the visual width of the object.
- * Default width is -1, which is interpreted as "unspecified".
- * @param width the width in units specified by widthUnits property.
+ /**
+ * Sets the visual width of the object. Default width is -1, which is
+ * interpreted as "unspecified".
+ *
+ * @param width
+ * the width in units specified by widthUnits property.
*/
public void setWidth(int width) {
if (this.width != width) {
@@ -334,6 +371,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Gets the classId attribute.
+ *
* @return the class id.
*/
public String getClassId() {
@@ -342,42 +380,49 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Sets the classId attribute.
- * @param classId the classId to set.
+ *
+ * @param classId
+ * the classId to set.
*/
public void setClassId(String classId) {
if (classId != this.classId
- || (classId != null && !classId.equals(classId))) {
+ || (classId != null && !classId.equals(classId))) {
this.classId = classId;
requestRepaint();
}
}
- /**
+ /**
* Gets the resource contained in the embedded object.
+ *
* @return the Resource
*/
public Resource getSource() {
return source;
}
- /**
+ /**
* Gets the type of the embedded object.
- * <p>This can be one of the following:<ul>
+ * <p>
+ * This can be one of the following:
+ * <ul>
* <li>TYPE_OBJECT <i>(This is the default)</i>
* <li>TYPE_IMAGE
* </ul>
* </p>
+ *
* @return the type.
*/
public int getType() {
return type;
}
- /**
- * Sets the object source resource.
- * The dimensions are assumed if possible.
+ /**
+ * Sets the object source resource. The dimensions are assumed if possible.
* The type is guessed from resource.
- * @param source the source to set.
+ *
+ * @param source
+ * the source to set.
*/
public void setSource(Resource source) {
if (source != null && !source.equals(this.source)) {
@@ -392,14 +437,18 @@ public class Embedded extends AbstractComponent implements Sizeable {
}
}
- /**
+ /**
* Sets the object type.
- * <p>This can be one of the following:<ul>
+ * <p>
+ * This can be one of the following:
+ * <ul>
* <li>TYPE_OBJECT <i>(This is the default)</i>
* <li>TYPE_IMAGE
* </ul>
* </p>
- * @param type the type to set.
+ *
+ * @param type
+ * the type to set.
*/
public void setType(int type) {
if (type != TYPE_OBJECT && type != TYPE_IMAGE)
@@ -412,6 +461,7 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Gets the archive attribute.
+ *
* @return the archive attribute.
*/
public String getArchive() {
@@ -420,19 +470,22 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Sets the archive attribute.
- * @param archive the archive string to set.
+ *
+ * @param archive
+ * the archive string to set.
*/
public void setArchive(String archive) {
if (archive != this.archive
- || (archive != null && !archive.equals(this.archive))) {
+ || (archive != null && !archive.equals(this.archive))) {
this.archive = archive;
requestRepaint();
}
}
/**
- * Gets the height property units.
- * Default units are <code>Sizeable.UNITS_PIXELS</code>.
+ * Gets the height property units. Default units are
+ * <code>Sizeable.UNITS_PIXELS</code>.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
*/
public int getHeightUnits() {
@@ -440,8 +493,9 @@ public class Embedded extends AbstractComponent implements Sizeable {
}
/**
- * Gets the width property units.
- * Default units are <code>Sizeable.UNITS_PIXELS</code>.
+ * Gets the width property units. Default units are
+ * <code>Sizeable.UNITS_PIXELS</code>.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
*/
public int getWidthUnits() {
@@ -450,10 +504,12 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Sets the height property units.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
*/
public void setHeightUnits(int units) {
- if (units >= 0 && units <= Sizeable.UNITS_PERCENTAGE && this.heightUnits != units) {
+ if (units >= 0 && units <= Sizeable.UNITS_PERCENTAGE
+ && this.heightUnits != units) {
this.heightUnits = units;
requestRepaint();
}
@@ -461,10 +517,12 @@ public class Embedded extends AbstractComponent implements Sizeable {
/**
* Sets the width property units.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int)
*/
public void setWidthUnits(int units) {
- if (units >= 0 && units <= Sizeable.UNITS_PERCENTAGE && this.widthUnits != units) {
+ if (units >= 0 && units <= Sizeable.UNITS_PERCENTAGE
+ && this.widthUnits != units) {
this.widthUnits = units;
requestRepaint();
}
diff --git a/src/com/itmill/toolkit/ui/Field.java b/src/com/itmill/toolkit/ui/Field.java
index edbcedf55e..8b11f93b26 100644
--- a/src/com/itmill/toolkit/ui/Field.java
+++ b/src/com/itmill/toolkit/ui/Field.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -34,81 +34,78 @@ import com.itmill.toolkit.ui.Component.Focusable;
/**
* @author IT Mill Ltd.
- *
+ *
*/
-public interface Field
- extends
- Component,
- BufferedValidatable,
- Property,
- Property.ValueChangeNotifier,
- Property.ValueChangeListener,
- Property.Editor,
- Focusable {
-
+public interface Field extends Component, BufferedValidatable, Property,
+ Property.ValueChangeNotifier, Property.ValueChangeListener,
+ Property.Editor, Focusable {
+
/**
* Sets the Caption.
+ *
* @param caption
*/
void setCaption(String caption);
String getDescription();
-
+
/**
* Sets the Description.
+ *
* @param caption
*/
void setDescription(String caption);
- /**
+ /**
* Is this field required.
*
* Required fields must filled by the user.
*
- * @return <code>true</code> if the field is required,otherwise <code>false</code>.
- * @since 3.1
+ * @return <code>true</code> if the field is required,otherwise
+ * <code>false</code>.
+ * @since 3.1
*/
public boolean isRequired();
- /**
- * Sets the field required.
- * Required fields must filled by the user.
+ /**
+ * Sets the field required. Required fields must filled by the user.
*
- * @param required Is the field required.
- * @since 3.1
+ * @param required
+ * Is the field required.
+ * @since 3.1
*/
public void setRequired(boolean required);
- /**
- * An <code>Event</code> object specifying the Field whose value
- * has been changed.
+ /**
+ * An <code>Event</code> object specifying the Field whose value has been
+ * changed.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
- public class ValueChangeEvent
- extends Component.Event
- implements Property.ValueChangeEvent {
+ public class ValueChangeEvent extends Component.Event implements
+ Property.ValueChangeEvent {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3545803169444672816L;
-
- /**
- * Constructs a new event object with the specified source
- * field object.
- *
- * @param source the field that caused the event.
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3545803169444672816L;
+
+ /**
+ * Constructs a new event object with the specified source field object.
+ *
+ * @param source
+ * the field that caused the event.
*/
public ValueChangeEvent(Field source) {
super(source);
}
- /**
+ /**
* Gets the Property which triggered the event.
- *
+ *
* @return the Source Property of the event.
*/
public Property getProperty() {
diff --git a/src/com/itmill/toolkit/ui/FieldFactory.java b/src/com/itmill/toolkit/ui/FieldFactory.java
index da2e8ab39c..fb71c4c38e 100644
--- a/src/com/itmill/toolkit/ui/FieldFactory.java
+++ b/src/com/itmill/toolkit/ui/FieldFactory.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -32,55 +32,67 @@ import com.itmill.toolkit.data.Container;
import com.itmill.toolkit.data.Item;
import com.itmill.toolkit.data.Property;
-/**
- * Factory for creating new Field-instances based on type,
- * datasource and/or context.
- *
+/**
+ * Factory for creating new Field-instances based on type, datasource and/or
+ * context.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.1
*/
public interface FieldFactory {
-
- /**
+ /**
* Creates a field based on type of data.
- *
- * @param type the type of data presented in field.
- * @param uiContext the component where the field is presented.
+ *
+ * @param type
+ * the type of data presented in field.
+ * @param uiContext
+ * the component where the field is presented.
* @return Field the field suitable for editing the specified data.
- *
+ *
*/
Field createField(Class type, Component uiContext);
-
- /**
+
+ /**
* Creates a field based on the property datasource.
- *
- * @param property the property datasource.
- * @param uiContext the component where the field is presented.
+ *
+ * @param property
+ * the property datasource.
+ * @param uiContext
+ * the component where the field is presented.
* @return Field the field suitable for editing the specified data.
*/
Field createField(Property property, Component uiContext);
- /**
+ /**
* Creates a field based on the item and property id.
*
- * @param item the item where the property belongs to.
- * @param propertyId the Id of the property.
- * @param uiContext the component where the field is presented.
+ * @param item
+ * the item where the property belongs to.
+ * @param propertyId
+ * the Id of the property.
+ * @param uiContext
+ * the component where the field is presented.
* @return Field the field suitable for editing the specified data.
*/
Field createField(Item item, Object propertyId, Component uiContext);
- /**
+ /**
* Creates a field based on the container item id and property id.
- *
- * @param container the Container where the property belongs to.
- * @param itemId the item Id.
- * @param propertyId the Id of the property.
- * @param uiContext the component where the field is presented.
+ *
+ * @param container
+ * the Container where the property belongs to.
+ * @param itemId
+ * the item Id.
+ * @param propertyId
+ * the Id of the property.
+ * @param uiContext
+ * the component where the field is presented.
* @return Field the field suitable for editing the specified data.
*/
- Field createField(Container container, Object itemId, Object propertyId, Component uiContext);
+ Field createField(Container container, Object itemId, Object propertyId,
+ Component uiContext);
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/ui/Form.java b/src/com/itmill/toolkit/ui/Form.java
index f3d6c1b2b8..2cb3d523ea 100644
--- a/src/com/itmill/toolkit/ui/Form.java
+++ b/src/com/itmill/toolkit/ui/Form.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -40,120 +40,124 @@ import com.itmill.toolkit.data.util.BeanItem;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-/**
+/**
* Form component provides easy way of creating and managing sets fields.
*
* <p>
- * <code>Form</code> is a container for fields implementing {@link Field} interface. It
- * provides support for any layouts and provides buffering interface for easy
- * connection of commit and discard buttons. All the form fields can be
- * customized by adding validators, setting captions and icons, setting
- * immediateness, etc. Also direct mechanism for replacing existing fields with
- * selections is given.
+ * <code>Form</code> is a container for fields implementing {@link Field}
+ * interface. It provides support for any layouts and provides buffering
+ * interface for easy connection of commit and discard buttons. All the form
+ * fields can be customized by adding validators, setting captions and icons,
+ * setting immediateness, etc. Also direct mechanism for replacing existing
+ * fields with selections is given.
* </p>
*
* <p>
* <code>Form</code> provides customizable editor for classes implementing
* {@link com.itmill.toolkit.data.Item} interface. Also the form itself
- * implements this interface for easier connectivity to other items.
- * To use the form as editor for an item, just connect the item to
- * form with {@link Form#setItemDataSource(Item)}. If only a part of the
- * item needs to be edited, {@link Form#setItemDataSource(Item,Collection)}
- * can be used instead. After the item has been connected to the form,
- * the automatically created fields can be customized and new fields can
- * be added. If you need to connect a class that does not implement
- * {@link com.itmill.toolkit.data.Item} interface, most properties of any
- * class following bean pattern, can be accessed trough
- * {@link com.itmill.toolkit.data.util.BeanItem}.
+ * implements this interface for easier connectivity to other items. To use the
+ * form as editor for an item, just connect the item to form with
+ * {@link Form#setItemDataSource(Item)}. If only a part of the item needs to be
+ * edited, {@link Form#setItemDataSource(Item,Collection)} can be used instead.
+ * After the item has been connected to the form, the automatically created
+ * fields can be customized and new fields can be added. If you need to connect
+ * a class that does not implement {@link com.itmill.toolkit.data.Item}
+ * interface, most properties of any class following bean pattern, can be
+ * accessed trough {@link com.itmill.toolkit.data.util.BeanItem}.
* </p>
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class Form
- extends AbstractField
- implements Item.Editor, Buffered, Item, Validatable {
+public class Form extends AbstractField implements Item.Editor, Buffered, Item,
+ Validatable {
private Object propertyValue;
- /**
- * Layout of the form.
+ /**
+ * Layout of the form.
*/
private Layout layout;
- /**
- * Item connected to this form as datasource.
+ /**
+ * Item connected to this form as datasource.
*/
private Item itemDatasource;
- /**
- * Ordered list of property ids in this editor.
+ /**
+ * Ordered list of property ids in this editor.
*/
private LinkedList propertyIds = new LinkedList();
- /**
- * Current buffered source exception.
+ /**
+ * Current buffered source exception.
*/
private Buffered.SourceException currentBufferedSourceException = null;
- /**
- * Is the form in write trough mode.
+ /**
+ * Is the form in write trough mode.
*/
private boolean writeThrough = true;
- /**
- * Is the form in read trough mode.
+ /**
+ * Is the form in read trough mode.
*/
private boolean readThrough = true;
- /**
- * Mapping from propertyName to corresponding field.
+ /**
+ * Mapping from propertyName to corresponding field.
*/
private HashMap fields = new HashMap();
- /**
- * Field factory for this form.
+ /**
+ * Field factory for this form.
*/
private FieldFactory fieldFactory;
- /**
- * Registered Validators.
+ /**
+ * Registered Validators.
*/
private LinkedList validators;
- /**
- * Visible item properties.
+ /**
+ * Visible item properties.
*/
private Collection visibleItemProperties;
- /**
+ /**
* Contructs a new form with default layout.
*
* <p>
- * By default the form uses <code>OrderedLayout</code>
- * with <code>form</code>-style.
+ * By default the form uses <code>OrderedLayout</code> with
+ * <code>form</code>-style.
* </p>
- * @param formLayout the layout of the form.
+ *
+ * @param formLayout
+ * the layout of the form.
*/
public Form() {
this(null);
}
- /**
+ /**
* Contructs a new form with given layout.
*
- * @param formLayout the layout of the form.
+ * @param formLayout
+ * the layout of the form.
*/
public Form(Layout formLayout) {
this(formLayout, new BaseFieldFactory());
}
- /**
+ /**
* Contructs a new form with given layout and FieldFactory.
- *
- * @param formLayout the layout of the form.
- * @param fieldFactory the FieldFactory of the form.
+ *
+ * @param formLayout
+ * the layout of the form.
+ * @param fieldFactory
+ * the FieldFactory of the form.
*/
public Form(Layout formLayout, FieldFactory fieldFactory) {
super();
@@ -173,9 +177,9 @@ public class Form
}
- /* Commit changes to the data source
- * Don't add a JavaDoc comment here, we use the default one from the
- * interface.
+ /*
+ * Commit changes to the data source Don't add a JavaDoc comment here, we
+ * use the default one from the interface.
*/
public void commit() throws Buffered.SourceException {
@@ -185,7 +189,7 @@ public class Form
for (Iterator i = propertyIds.iterator(); i.hasNext();)
try {
Field f = ((Field) fields.get(i.next()));
- //Commit only non-readonly fields.
+ // Commit only non-readonly fields.
if (!f.isReadOnly()) {
f.commit();
}
@@ -215,9 +219,9 @@ public class Form
throw e;
}
- /* Discards local changes and refresh values from the data source
- * Don't add a JavaDoc comment here, we use the default one from the
- * interface.
+ /*
+ * Discards local changes and refresh values from the data source Don't add
+ * a JavaDoc comment here, we use the default one from the interface.
*/
public void discard() throws Buffered.SourceException {
@@ -242,7 +246,7 @@ public class Form
return;
}
- // Discards problems occurred
+ // Discards problems occurred
Throwable[] causes = new Throwable[problems.size()];
int index = 0;
for (Iterator i = problems.iterator(); i.hasNext();)
@@ -253,61 +257,61 @@ public class Form
throw e;
}
- /* Is the object modified but not committed?
- * Don't add a JavaDoc comment here, we use the default one from the
- * interface.
+ /*
+ * Is the object modified but not committed? Don't add a JavaDoc comment
+ * 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());
+ Field f = (Field) fields.get(i.next());
if (f != null && f.isModified())
return true;
-
+
}
return false;
}
- /* Is the editor in a read-through mode?
- * Don't add a JavaDoc comment here, we use the default one from the
- * interface.
+ /*
+ * Is the editor in a read-through mode? Don't add a JavaDoc comment here,
+ * we use the default one from the interface.
*/
public boolean isReadThrough() {
return readThrough;
}
- /* Is the editor in a write-through mode?
- * Don't add a JavaDoc comment here, we use the default one from the
- * interface.
+ /*
+ * Is the editor in a write-through mode? Don't add a JavaDoc comment here,
+ * we use the default one from the interface.
*/
public boolean isWriteThrough() {
return writeThrough;
}
- /* Sets the editor's read-through mode to the specified status.
- * Don't add a JavaDoc comment here, we use the default one from the
- * interface.
+ /*
+ * Sets the editor's read-through mode to the specified status. Don't add a
+ * JavaDoc comment here, we use the default one from the interface.
*/
public void setReadThrough(boolean readThrough) {
if (readThrough != this.readThrough) {
this.readThrough = readThrough;
for (Iterator i = propertyIds.iterator(); i.hasNext();)
- ((Field) fields.get(i.next())).setReadThrough(readThrough);
+ ((Field) fields.get(i.next())).setReadThrough(readThrough);
}
}
- /* Sets the editor's read-through mode to the specified status.
- * Don't add a JavaDoc comment here, we use the default one from the
- * interface.
+ /*
+ * Sets the editor's read-through mode to the specified status. Don't add a
+ * JavaDoc comment here, we use the default one from the interface.
*/
public void setWriteThrough(boolean writeThrough) {
if (writeThrough != this.writeThrough) {
this.writeThrough = writeThrough;
for (Iterator i = propertyIds.iterator(); i.hasNext();)
- ((Field) fields.get(i.next())).setWriteThrough(writeThrough);
+ ((Field) fields.get(i.next())).setWriteThrough(writeThrough);
}
}
- /**
+ /**
* Adds a new property to form and create corresponding field.
*
* @see com.itmill.toolkit.data.Item#addItemProperty(Object, Property)
@@ -334,9 +338,7 @@ public class Form
if (caption.length() > 50)
caption = caption.substring(0, 47) + "...";
if (caption.length() > 0)
- caption =
- ""
- + Character.toUpperCase(caption.charAt(0))
+ caption = "" + Character.toUpperCase(caption.charAt(0))
+ caption.substring(1, caption.length());
field.setCaption(caption);
} catch (Throwable ignored) {
@@ -348,21 +350,25 @@ public class Form
return true;
}
- /**
- * Adds the field to form.
+ /**
+ * Adds the field to form.
*
* <p>
- * The property id must not be already used in the form.
+ * The property id must not be already used in the form.
* </p>
*
- * <p>This field is added to the form layout in the default position
- * (the position used by {@link Layout#addComponent(Component)} method.
- * In the special case that the underlying layout is a custom layout,
- * string representation of the property id is used instead of the
- * default location.</p>
+ * <p>
+ * This field is added to the form layout in the default position (the
+ * position used by {@link Layout#addComponent(Component)} method. In the
+ * special case that the underlying layout is a custom layout, string
+ * representation of the property id is used instead of the default
+ * location.
+ * </p>
*
- * @param propertyId the Property id the the field.
- * @param field the New field added to the form.
+ * @param propertyId
+ * the Property id the the field.
+ * @param field
+ * the New field added to the form.
*/
public void addField(Object propertyId, Field field) {
@@ -375,9 +381,8 @@ public class Form
field.setWriteThrough(writeThrough);
if (layout instanceof CustomLayout)
- ((CustomLayout) layout).addComponent(
- field,
- propertyId.toString());
+ ((CustomLayout) layout).addComponent(field, propertyId
+ .toString());
else
layout.addComponent(field);
@@ -385,14 +390,13 @@ public class Form
}
}
- /**
+ /**
* The property identified by the property id.
*
* <p>
- * The property data source of the field specified with
- * property id is returned. If there is a (with specified property id)
- * having no data source,
- * the field is returned instead of the data source.
+ * The property data source of the field specified with property id is
+ * returned. If there is a (with specified property id) having no data
+ * source, the field is returned instead of the data source.
* </p>
*
* @see com.itmill.toolkit.data.Item#getItemProperty(Object)
@@ -409,9 +413,11 @@ public class Form
return field;
}
- /**
+ /**
* Gets the field identified by the propertyid.
- * @param propertyId the id of the property.
+ *
+ * @param propertyId
+ * the id of the property.
*/
public Field getField(Object propertyId) {
return (Field) fields.get(propertyId);
@@ -422,7 +428,7 @@ public class Form
return Collections.unmodifiableCollection(propertyIds);
}
- /**
+ /**
* Removes the property and corresponding field from the form.
*
* @see com.itmill.toolkit.data.Item#removeItemProperty(Object)
@@ -443,11 +449,11 @@ public class Form
return false;
}
- /**
+ /**
* Removes all properties and fields from the form.
*
- * @return the Success of the operation. Removal of all fields succeeded
- * if (and only if) the return value is <code>true</code>.
+ * @return the Success of the operation. Removal of all fields succeeded if
+ * (and only if) the return value is <code>true</code>.
*/
public boolean removeAllProperties() {
Object[] properties = propertyIds.toArray();
@@ -465,30 +471,29 @@ public class Form
return itemDatasource;
}
- /**
+ /**
* Sets the item datasource for the form.
*
* <p>
- * Setting item datasource clears any fields, the form might contain
- * and adds all the properties as fields to the form.
+ * Setting item datasource clears any fields, the form might contain and
+ * adds all the properties as fields to the form.
* </p>
*
* @see com.itmill.toolkit.data.Item.Viewer#setItemDataSource(Item)
*/
public void setItemDataSource(Item newDataSource) {
- setItemDataSource(
- newDataSource,
- newDataSource != null ? newDataSource.getItemPropertyIds() : null);
+ setItemDataSource(newDataSource, newDataSource != null ? newDataSource
+ .getItemPropertyIds() : null);
}
- /**
- * Set the item datasource for the form, but limit the form contents
- * to specified properties of the item.
+ /**
+ * Set the item datasource for the form, but limit the form contents to
+ * specified properties of the item.
*
* <p>
- * Setting item datasource clears any fields, the form might contain
- * and adds the specified the properties as fields to the form, in the
- * specified order.
+ * Setting item datasource clears any fields, the form might contain and
+ * adds the specified the properties as fields to the form, in the specified
+ * order.
* </p>
*
* @see com.itmill.toolkit.data.Item.Viewer#setItemDataSource(Item)
@@ -501,7 +506,7 @@ public class Form
// Sets the datasource
itemDatasource = newDataSource;
- //If the new datasource is null, just set null datasource
+ // If the new datasource is null, just set null datasource
if (itemDatasource == null)
return;
@@ -510,8 +515,8 @@ public class Form
Object id = i.next();
Property property = itemDatasource.getItemProperty(id);
if (id != null && property != null) {
- Field f =
- this.fieldFactory.createField(itemDatasource, id, this);
+ Field f = this.fieldFactory.createField(itemDatasource, id,
+ this);
if (f != null) {
f.setPropertyDataSource(property);
addField(id, f);
@@ -520,8 +525,8 @@ public class Form
}
}
- /**
- * Gets the layout of the form.
+ /**
+ * Gets the layout of the form.
*
* <p>
* By default form uses <code>OrderedLayout</code> with <code>form</code>-style.
@@ -533,14 +538,15 @@ public class Form
return layout;
}
- /**
+ /**
* Sets the layout of the form.
- *
+ *
* <p>
* By default form uses <code>OrderedLayout</code> with <code>form</code>-style.
* </p>
- *
- * @param newLayout the Layout of the form.
+ *
+ * @param newLayout
+ * the Layout of the form.
*/
public void setLayout(Layout newLayout) {
@@ -561,37 +567,36 @@ public class Form
this.layout = newLayout;
}
- /**
+ /**
* Sets the form field to be selectable from static list of changes.
*
* <p>
- * The list values and descriptions are given as array. The value-array must contain the
- * current value of the field and the lengths of the arrays must match. Null values are not
- * supported.
+ * The list values and descriptions are given as array. The value-array must
+ * contain the current value of the field and the lengths of the arrays must
+ * match. Null values are not supported.
* </p>
- * @param propertyId the id of the property.
+ *
+ * @param propertyId
+ * the id of the property.
* @param values
* @param descriptions
* @return the select property generated
*/
- public Select replaceWithSelect(
- Object propertyId,
- Object[] values,
- Object[] descriptions) {
+ public Select replaceWithSelect(Object propertyId, Object[] values,
+ Object[] descriptions) {
// Checks the parameters
if (propertyId == null || values == null || descriptions == null)
throw new NullPointerException("All parameters must be non-null");
if (values.length != descriptions.length)
- throw new IllegalArgumentException("Value and description list are of different size");
+ throw new IllegalArgumentException(
+ "Value and description list are of different size");
// Gets the old field
Field oldField = (Field) fields.get(propertyId);
if (oldField == null)
- throw new IllegalArgumentException(
- "Field with given propertyid '"
- + propertyId.toString()
- + "' can not be found.");
+ throw new IllegalArgumentException("Field with given propertyid '"
+ + propertyId.toString() + "' can not be found.");
Object value = oldField.getValue();
// Checks that the value exists and check if the select should
@@ -600,40 +605,36 @@ public class Form
boolean isMultiselect = false;
for (int i = 0; i < values.length && !found; i++)
if (values[i] == value
- || (value != null && value.equals(values[i])))
+ || (value != null && value.equals(values[i])))
found = true;
if (value != null && !found) {
if (value instanceof Collection) {
- for (Iterator it = ((Collection) value).iterator();
- it.hasNext();
- ) {
+ for (Iterator it = ((Collection) value).iterator(); it
+ .hasNext();) {
Object val = it.next();
found = false;
for (int i = 0; i < values.length && !found; i++)
if (values[i] == val
- || (val != null && val.equals(values[i])))
+ || (val != null && val.equals(values[i])))
found = true;
- if (!found)
- throw new IllegalArgumentException(
- "Currently selected value '"
- + val
- + "' of property '"
- + propertyId.toString()
- + "' was not found");
+ if (!found)
+ throw new IllegalArgumentException(
+ "Currently selected value '" + val
+ + "' of property '"
+ + propertyId.toString()
+ + "' was not found");
}
isMultiselect = true;
} else
- throw new IllegalArgumentException(
- "Current value '"
- + value
- + "' of property '"
- + propertyId.toString()
+ throw new IllegalArgumentException("Current value '" + value
+ + "' of property '" + propertyId.toString()
+ "' was not found");
}
// Creates the new field matching to old field parameters
Select newField = new Select();
- if (isMultiselect) newField.setMultiSelect(true);
+ if (isMultiselect)
+ newField.setMultiSelect(true);
newField.setCaption(oldField.getCaption());
newField.setReadOnly(oldField.isReadOnly());
newField.setReadThrough(oldField.isReadThrough());
@@ -651,7 +652,7 @@ public class Form
Item item = newField.addItem(id);
if (item != null)
item.getItemProperty("desc").setValue(
- descriptions[i].toString());
+ descriptions[i].toString());
}
// Sets the property data source
@@ -672,6 +673,7 @@ public class Form
/**
* Notifies the component that it is connected to an application
+ *
* @see com.itmill.toolkit.ui.Component#attach()
*/
public void attach() {
@@ -681,6 +683,7 @@ public class Form
/**
* Notifies the component that it is detached from the application.
+ *
* @see com.itmill.toolkit.ui.Component#detach()
*/
public void detach() {
@@ -690,6 +693,7 @@ public class Form
/**
* Adds a new validator for this object.
+ *
* @see com.itmill.toolkit.data.Validatable#addValidator(com.itmill.toolkit.data.Validator)
*/
public void addValidator(Validator validator) {
@@ -699,9 +703,10 @@ public class Form
}
this.validators.add(validator);
}
-
+
/**
* Removes a previously registered validator from the object.
+ *
* @see com.itmill.toolkit.data.Validatable#removeValidator(com.itmill.toolkit.data.Validator)
*/
public void removeValidator(Validator validator) {
@@ -709,9 +714,10 @@ public class Form
this.validators.remove(validator);
}
}
-
+
/**
* Gets the Lists all validators currently registered for the object.
+ *
* @see com.itmill.toolkit.data.Validatable#getValidators()
*/
public Collection getValidators() {
@@ -720,10 +726,10 @@ public class Form
}
return null;
}
-
+
/**
- * Tests the current value of the object against all registered
- * validators
+ * Tests the current value of the object against all registered validators
+ *
* @see com.itmill.toolkit.data.Validatable#isValid()
*/
public boolean isValid() {
@@ -732,50 +738,55 @@ public class Form
valid &= ((Field) fields.get(i.next())).isValid();
return valid;
}
-
+
/**
* Checks the validity of the validatable.
+ *
* @see com.itmill.toolkit.data.Validatable#validate()
*/
public void validate() throws InvalidValueException {
for (Iterator i = propertyIds.iterator(); i.hasNext();)
- ((Field) fields.get(i.next())).validate();
+ ((Field) fields.get(i.next())).validate();
}
/**
* Checks the validabtable object accept invalid values.
+ *
* @see com.itmill.toolkit.data.Validatable#isInvalidAllowed()
*/
public boolean isInvalidAllowed() {
return true;
}
-
+
/**
* Should the validabtable object accept invalid values.
+ *
* @see com.itmill.toolkit.data.Validatable#setInvalidAllowed(boolean)
*/
public void setInvalidAllowed(boolean invalidValueAllowed)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
-
+
/**
* Sets the component's to read-only mode to the specified state.
+ *
* @see com.itmill.toolkit.ui.Component#setReadOnly(boolean)
*/
public void setReadOnly(boolean readOnly) {
super.setReadOnly(readOnly);
for (Iterator i = propertyIds.iterator(); i.hasNext();)
- ((Field) fields.get(i.next())).setReadOnly(readOnly);
+ ((Field) fields.get(i.next())).setReadOnly(readOnly);
}
- /**
+ /**
* Sets the field factory of Form.
- *
+ *
* <code>FieldFactory</code> is used to create fields for form properties.
* By default the form uses BaseFieldFactory to create Field instances.
- *
- * @param fieldFactory the New factory used to create the fields.
+ *
+ * @param fieldFactory
+ * the New factory used to create the fields.
* @see Field
* @see FieldFactory
*/
@@ -783,9 +794,9 @@ public class Form
this.fieldFactory = fieldFactory;
}
- /**
+ /**
* Get the field factory of the form.
- *
+ *
* @return the FieldFactory Factory used to create the fields.
*/
public FieldFactory getFieldFactory() {
@@ -794,6 +805,7 @@ public class Form
/**
* Gets the field type.
+ *
* @see com.itmill.toolkit.ui.AbstractField#getType()
*/
public Class getType() {
@@ -802,16 +814,17 @@ public class Form
return Object.class;
}
- /**
+ /**
* Sets the internal value.
*
* This is relevant when the Form is used as Field.
+ *
* @see com.itmill.toolkit.ui.AbstractField#setInternalValue(java.lang.Object)
*/
protected void setInternalValue(Object newValue) {
// Stores the old value
Object oldValue = this.propertyValue;
-
+
// Sets the current Value
super.setInternalValue(newValue);
this.propertyValue = newValue;
@@ -824,6 +837,7 @@ public class Form
/**
* Gets the first field in form.
+ *
* @return the Field.
*/
private Field getFirstField() {
@@ -836,10 +850,11 @@ public class Form
return null;
}
- /**
+ /**
* Updates the internal form datasource.
*
* Method setFormDataSource.
+ *
* @param data
* @param properties
*/
@@ -865,6 +880,7 @@ public class Form
/**
* Returns the visibleProperties.
+ *
* @return the Collection of visible Item properites.
*/
public Collection getVisibleItemProperties() {
@@ -873,7 +889,9 @@ public class Form
/**
* Sets the visibleProperties.
- * @param visibleProperties the visibleProperties to set.
+ *
+ * @param visibleProperties
+ * the visibleProperties to set.
*/
public void setVisibleItemProperties(Collection visibleProperties) {
this.visibleItemProperties = visibleProperties;
@@ -881,8 +899,9 @@ public class Form
setFormDataSource(value, getVisibleItemProperties());
}
- /**
+ /**
* Focuses the first field in the form.
+ *
* @see com.itmill.toolkit.ui.Component.Focusable#focus()
*/
public void focus() {
@@ -894,11 +913,12 @@ public class Form
/**
* Sets the Tabulator index of this Focusable component.
+ *
* @see com.itmill.toolkit.ui.Component.Focusable#setTabIndex(int)
*/
public void setTabIndex(int tabIndex) {
super.setTabIndex(tabIndex);
for (Iterator i = this.getItemPropertyIds().iterator(); i.hasNext();)
- (this.getField(i.next())).setTabIndex(tabIndex);
+ (this.getField(i.next())).setTabIndex(tabIndex);
}
}
diff --git a/src/com/itmill/toolkit/ui/FrameWindow.java b/src/com/itmill/toolkit/ui/FrameWindow.java
index 6717fad004..e9b18d9e76 100644
--- a/src/com/itmill/toolkit/ui/FrameWindow.java
+++ b/src/com/itmill/toolkit/ui/FrameWindow.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -39,44 +39,46 @@ import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.Resource;
-/**
+/**
* <p>
- * An application frame window component. This component implements a
- * window that contains a hierarchical set of frames. Each frame can contain
- * a web-page, window or a set of frames that divides the space horizontally
- * or vertically.
+ * An application frame window component. This component implements a window
+ * that contains a hierarchical set of frames. Each frame can contain a
+ * web-page, window or a set of frames that divides the space horizontally or
+ * vertically.
* </p>
*
* <p>
- * A <code>FrameWindow</code> can't contain any components directly (as
- * it contains only a set of frames) and thus the container interface
- * methods do nothing.
+ * A <code>FrameWindow</code> can't contain any components directly (as it
+ * contains only a set of frames) and thus the container interface methods do
+ * nothing.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class FrameWindow extends Window {
private Frameset frameset = new Frameset();
- /**
+ /**
* Constructs a new frame window.
*/
public FrameWindow() {
}
-
- /**
- * Constructs a new frame window.
- * @param caption th etitle of the window.
+ /**
+ * Constructs a new frame window.
+ *
+ * @param caption
+ * th etitle of the window.
*/
public FrameWindow(String caption) {
super(caption);
}
- /**
+ /**
* Gets the window's UIDL tag.
*
* @return the window's UIDL tag as <code>String</code>.
@@ -85,10 +87,10 @@ public class FrameWindow extends Window {
return "framewindow";
}
- /**
- * Gets the main frameset of the window. This set contains all the
- * top-level frames of the window. New contents are added by adding
- * frames to this frameset.
+ /**
+ * Gets the main frameset of the window. This set contains all the top-level
+ * frames of the window. New contents are added by adding frames to this
+ * frameset.
*
* @return the top-level frame set of this frame window.
*/
@@ -96,11 +98,13 @@ public class FrameWindow extends Window {
return frameset;
}
- /**
+ /**
* Paints the window contents.
*
- * @param target the paint target event.
- * @throws PaintException if the paint operation fails.
+ * @param target
+ * the paint target event.
+ * @throws PaintException
+ * if the paint operation fails.
*
* @see com.itmill.toolkit.ui.AbstractComponent#paintContent(PaintTarget)
*/
@@ -112,121 +116,133 @@ public class FrameWindow extends Window {
getFrameset().paint(target);
}
- /**
- * An individual frame that contains either a window or the contents of the
- * url set to frame.
+ /**
+ * An individual frame that contains either a window or the contents of the
+ * url set to frame.
*
* <p>
- * The frames can be only created to framesets using the
+ * The frames can be only created to framesets using the
* <code>newFrame</code> method of the frameset.
* </p>
- */
+ */
public class Frame {
- /**
- * URL of the frame contents.
+ /**
+ * URL of the frame contents.
*/
private URL url;
- /**
- * Name of the frame.
+ /**
+ * Name of the frame.
*/
private String name;
- /**
- * Window connected to frame or null.
+ /**
+ * Window connected to frame or null.
*/
private Window window;
- /**
- * Window connected to frame or null.
+ /**
+ * Window connected to frame or null.
*/
private Resource resource;
- /**
- * String representation of the width.
+ /**
+ * String representation of the width.
*/
private String width = "*";
- /**
- * Parent frameset.
+ /**
+ * Parent frameset.
*/
protected Frameset parentFrameset;
- /**
- * Gets the URL of the frame.
- * @return the URl.
+ /**
+ * Gets the URL of the frame.
+ *
+ * @return the URl.
*/
public URL getURL() {
return window == null ? url : window.getURL();
}
- /**
- * Gets the parent frameset.
+ /**
+ * Gets the parent frameset.
+ *
* @return the parent frameset.
*/
public Frameset getParentFrameset() {
return parentFrameset;
}
- /**
- * Gets the Name of the frame.
+ /**
+ * Gets the Name of the frame.
+ *
* @return the Name.
*/
public String getName() {
return window == null ? name : window.getName();
}
- /**
+ /**
* Gets the Window connected to frame.
- * @return the window.
+ *
+ * @return the window.
*/
public Window getWindow() {
return window;
}
- /**
- * Gets the Resource connected to frame.
+ /**
+ * Gets the Resource connected to frame.
+ *
* @return the resource.
*/
public Resource getResource() {
return resource;
}
- /**
+ /**
* Sets the Absolute width/height of the frame in pixels.
- * @param widthInPixel the width in Pixel.
+ *
+ * @param widthInPixel
+ * the width in Pixel.
*/
public void setAbsoluteSize(int widthInPixels) {
width = String.valueOf(widthInPixels);
requestRepaint();
}
- /**
- * Sets the frame size to be freely specified by the terminal.
+ /**
+ * Sets the frame size to be freely specified by the terminal.
*/
public void setFreeSize() {
width = "*";
requestRepaint();
}
- /**
- * Sets the frame width/height as a percentage of the containing
- * frameset size.
- * @param widthInPercents the frame width in percent.
+ /**
+ * Sets the frame width/height as a percentage of the containing
+ * frameset size.
+ *
+ * @param widthInPercents
+ * the frame width in percent.
*/
public void setRelativeSize(int widthInPercents) {
if (widthInPercents < 0 || widthInPercents > 100)
- throw new IllegalArgumentException(
- "Relative width must " + "be between 0% and 100%");
+ throw new IllegalArgumentException("Relative width must "
+ + "be between 0% and 100%");
width = String.valueOf(widthInPercents) + "%";
requestRepaint();
}
- /**
- * Paints the frame.
- * @param target the paint target.
- * @throws PaintException if the paint operation fails.
+ /**
+ * Paints the frame.
+ *
+ * @param target
+ * the paint target.
+ * @throws PaintException
+ * if the paint operation fails.
*/
private void paint(PaintTarget target) throws PaintException {
target.startTag("frame");
@@ -239,23 +255,23 @@ public class FrameWindow extends Window {
}
}
- /**
- * Vertical or horizontal set of frames.
+ /**
+ * Vertical or horizontal set of frames.
*/
public class Frameset extends Frame {
- /**
+ /**
* List of frames ordered from left to right or from top to bottom.
*/
private LinkedList frames = new LinkedList();
- /**
- * <code>true</code> if the frames are on top of each other. If <code>false</code> the frames
- * are side by side.
+ /**
+ * <code>true</code> if the frames are on top of each other. If
+ * <code>false</code> the frames are side by side.
*/
private boolean vertical = false;
- /**
+ /**
* Gets the list of frames.
*
* @return the unmodifiable list of frames.
@@ -264,30 +280,34 @@ public class FrameWindow extends Window {
return Collections.unmodifiableList(frames);
}
- /**
+ /**
* Creates the new frame containing a window.
*
* <p>
* The new frame will be in the end of the frames list.
* </p>
- * @param window the window connected to the frame.
+ *
+ * @param window
+ * the window connected to the frame.
* @return the new Frame.
*/
public Frame newFrame(Window window) {
return newFrame(window, size());
}
- /**
+ /**
* Creates the new frame containing a window.
*
* <p>
- * The new frame will be put before the frame identified
- * by the given index. The indexes of the frame previously in the
- * given position and all the positions after it are incremented
- * by one.
+ * The new frame will be put before the frame identified by the given
+ * index. The indexes of the frame previously in the given position and
+ * all the positions after it are incremented by one.
* </p>
- * @param window the window connected to the frame.
- * @param index the given index.
+ *
+ * @param window
+ * the window connected to the frame.
+ * @param index
+ * the given index.
*/
public Frame newFrame(Window window, int index) {
Frame f = new Frame();
@@ -300,46 +320,55 @@ public class FrameWindow extends Window {
return f;
}
- /**
+ /**
* Creates the new frame containing a url.
*
* <p>
* The new frame will be put in the end of the frames list.
* </p>
- * @param url the URL of the frame contents.
- * @param name the Name of the frame.
+ *
+ * @param url
+ * the URL of the frame contents.
+ * @param name
+ * the Name of the frame.
* @return the new frame.
*/
public Frame newFrame(URL url, String name) {
return newFrame(url, name, size());
}
- /**
+ /**
* Creates the new frame containing a resource.
*
* <p>
* The new frame will be put in the end of the frames list.
* </p>
- * @param resource the resource.
- * @param name the Name of the frame.
+ *
+ * @param resource
+ * the resource.
+ * @param name
+ * the Name of the frame.
* @return the new frame.
*/
public Frame newFrame(Resource resource, String name) {
return newFrame(resource, name, size());
}
- /**
+ /**
* Creates the new frame containing a url.
*
* <p>
- * The new frame will be put before the frame identified
- * by the given index. The indexes of the frame previously in the
- * given position and all the positions after it are incremented
- * by one.
+ * The new frame will be put before the frame identified by the given
+ * index. The indexes of the frame previously in the given position and
+ * all the positions after it are incremented by one.
* </p>
- * @param url the URL of the frame contents.
- * @param name the Name of the frame.
- * @param index the given index.
+ *
+ * @param url
+ * the URL of the frame contents.
+ * @param name
+ * the Name of the frame.
+ * @param index
+ * the given index.
* @return the new frame.
*/
public Frame newFrame(URL url, String name, int index) {
@@ -352,18 +381,21 @@ public class FrameWindow extends Window {
return f;
}
- /**
+ /**
* Creates the new frame containing a resource.
*
* <p>
- * The new frame will be put before the frame identified
- * by the given index. The indexes of the frame previously in the
- * given position and all the positions after it are incremented
- * by one.
+ * The new frame will be put before the frame identified by the given
+ * index. The indexes of the frame previously in the given position and
+ * all the positions after it are incremented by one.
* </p>
- * @param resource the resource.
- * @param name the Name of the frame.
- * @param index the given index.
+ *
+ * @param resource
+ * the resource.
+ * @param name
+ * the Name of the frame.
+ * @param index
+ * the given index.
* @return the new frame.
*/
public Frame newFrame(Resource resource, String name, int index) {
@@ -376,17 +408,19 @@ public class FrameWindow extends Window {
return f;
}
- /**
+ /**
* Creates the new frameset.
*
* <p>
- * The new frame will be put before the frame identified
- * by the given index. The indexes of the frame previously in the
- * given position and all the positions after it are incremented
- * by one.
+ * The new frame will be put before the frame identified by the given
+ * index. The indexes of the frame previously in the given position and
+ * all the positions after it are incremented by one.
* </p>
- * @param isVertical is the frames are on top of each other.
- * @param index the given index.
+ *
+ * @param isVertical
+ * is the frames are on top of each other.
+ * @param index
+ * the given index.
* @return the new frameset.
*/
public Frameset newFrameset(boolean isVertical, int index) {
@@ -398,9 +432,11 @@ public class FrameWindow extends Window {
return f;
}
- /**
- * Removes the frame from this frameset.
- * @param frame the frame to remove.
+ /**
+ * Removes the frame from this frameset.
+ *
+ * @param frame
+ * the frame to remove.
*/
public void removeFrame(Frame frame) {
frames.remove(frame);
@@ -408,58 +444,65 @@ public class FrameWindow extends Window {
requestRepaint();
}
- /**
- * Removes all frames from this frameset.
+ /**
+ * Removes all frames from this frameset.
*/
public void removeAllFrames() {
for (Iterator i = frames.iterator(); i.hasNext();)
- ((Frame) i.next()).parentFrameset = null;
+ ((Frame) i.next()).parentFrameset = null;
frames.clear();
requestRepaint();
}
- /**
- * Number of frames in this frameset.
+ /**
+ * Number of frames in this frameset.
+ *
* @return the size.
*/
public int size() {
return frames.size();
}
- /**
- * Sets the framaset to be vertical.
+ /**
+ * Sets the framaset to be vertical.
*
* <p>
- * By setting this true, the frames will be ordered on top
- * of each other from top to bottom. Setting this false, the
- * frames will be ordered side by side from left to right.
+ * By setting this true, the frames will be ordered on top of each other
+ * from top to bottom. Setting this false, the frames will be ordered
+ * side by side from left to right.
* </p>
- * @param isVertical is the frames are on top of each other.
+ *
+ * @param isVertical
+ * is the frames are on top of each other.
*/
public void setVertical(boolean isVertical) {
this.vertical = isVertical;
requestRepaint();
}
- /**
- * Checks if the frameset is vertical.
+ /**
+ * Checks if the frameset is vertical.
*
* <p>
- * If this is true, the frames will be ordered on top
- * of each other from top to bottom, otherwise the
- * frames will be ordered side by side from left to right.
+ * If this is true, the frames will be ordered on top of each other from
+ * top to bottom, otherwise the frames will be ordered side by side from
+ * left to right.
* </p>
- * @return <code>true</code> if the frameset is Vertical, otherwise <code>false</code>.
+ *
+ * @return <code>true</code> if the frameset is Vertical, otherwise
+ * <code>false</code>.
*/
public boolean isVertical() {
return vertical;
}
- /**
+ /**
* Gets the frame by name.
- * @param name the Name of the frame.
- * @return the Frame having the given name or null if the frame is
- * not found.
+ *
+ * @param name
+ * the Name of the frame.
+ * @return the Frame having the given name or null if the frame is not
+ * found.
*/
public Frame getFrame(String name) {
if (name == null)
@@ -472,11 +515,13 @@ public class FrameWindow extends Window {
return null;
}
- /**
+ /**
* Gets the frame by index.
- * @param index the given index.
- * @return the Frame having the given index or null if the frame is
- * not found
+ *
+ * @param index
+ * the given index.
+ * @return the Frame having the given index or null if the frame is not
+ * found
*/
public Frame getFrame(int index) {
if (index >= 0 && index < frames.size())
@@ -484,10 +529,13 @@ public class FrameWindow extends Window {
return null;
}
- /**
+ /**
* Paints the frameset.
- * @param target the Paint Target.
- * @throws PaintException if the Paint operation fails.
+ *
+ * @param target
+ * the Paint Target.
+ * @throws PaintException
+ * if the Paint operation fails.
*/
private void paint(PaintTarget target) throws PaintException {
target.startTag("frameset");
@@ -508,7 +556,7 @@ public class FrameWindow extends Window {
for (Iterator i = frames.iterator(); i.hasNext();) {
Frame f = (Frame) i.next();
if (Frameset.class.isAssignableFrom(f.getClass()))
- ((Frameset) f).paint(target);
+ ((Frameset) f).paint(target);
else
f.paint(target);
}
@@ -516,20 +564,19 @@ public class FrameWindow extends Window {
target.endTag("frameset");
}
- /**
+ /**
* Sets the application for all the frames in this frameset.
+ *
* @param fromApplication
- * @param toApplication
+ * @param toApplication
*/
- private void setApplication(
- Application fromApplication,
- Application toApplication) {
+ private void setApplication(Application fromApplication,
+ Application toApplication) {
for (Iterator i = frames.iterator(); i.hasNext();) {
Frame f = (Frame) i.next();
if (f instanceof Frameset)
- ((Frameset) f).setApplication(
- fromApplication,
- toApplication);
+ ((Frameset) f).setApplication(fromApplication,
+ toApplication);
else if (f.window != null) {
if (toApplication == null) {
fromApplication.removeWindow(f.window);
@@ -540,9 +587,10 @@ public class FrameWindow extends Window {
}
}
- /**
- * Setting the application for frame window also sets the application
- * for all the frames.
+ /**
+ * Setting the application for frame window also sets the application for
+ * all the frames.
+ *
* @see com.itmill.toolkit.ui.Window#setApplication(Application)
*/
public void setApplication(Application application) {
@@ -553,51 +601,54 @@ public class FrameWindow extends Window {
fs.setApplication(fromApplication, application);
}
- /**
+ /**
* Frame windows does not support scrolling.
- * @return <code>true</code> if it is scrollable,otherwise <code>false</code>.
+ *
+ * @return <code>true</code> if it is scrollable,otherwise
+ * <code>false</code>.
*/
public boolean isScrollable() {
return false;
}
- /**
+ /**
* Enables or disables scrolling.
- *
+ *
* @see com.itmill.toolkit.terminal.Scrollable#setScrollable(boolean)
*/
public void setScrollable(boolean isScrollingEnabled) {
}
- /**
+ /**
* Sets the scroll X offset.
- *
+ *
* @see com.itmill.toolkit.terminal.Scrollable#setScrollOffsetX(int)
*/
public void setScrollOffsetX(int pixelsScrolledLeft) {
}
- /**
+ /**
* Gets the scroll Y offset.
- *
+ *
* @see com.itmill.toolkit.terminal.Scrollable#setScrollOffsetY(int)
*/
public void setScrollOffsetY(int pixelsScrolledDown) {
}
- /**
+ /**
* Frame window does not support adding components directly.
*
* <p>
- * To add component to frame window, normal window must be
- * first created and then attached to frame window as a frame.
+ * To add component to frame window, normal window must be first created and
+ * then attached to frame window as a frame.
* </p>
- * @param c the component to be added.
+ *
+ * @param c
+ * the component to be added.
* @see com.itmill.toolkit.ui.ComponentContainer#addComponent(Component)
*
*/
- public void addComponent(Component c)
- throws UnsupportedOperationException {
+ public void addComponent(Component c) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
diff --git a/src/com/itmill/toolkit/ui/GridLayout.java b/src/com/itmill/toolkit/ui/GridLayout.java
index 3e2b7521ec..f0b957a11a 100644
--- a/src/com/itmill/toolkit/ui/GridLayout.java
+++ b/src/com/itmill/toolkit/ui/GridLayout.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -36,127 +36,134 @@ import java.util.LinkedList;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-/**
+/**
* <p>
- * A container that consists of components with certain coordinates on a
- * grid. It also maintains cursor for adding component in left to right,
- * top to bottom order.
+ * A container that consists of components with certain coordinates on a grid.
+ * It also maintains cursor for adding component in left to right, top to bottom
+ * order.
* </p>
*
* <p>
* Each component in a <code>GridLayout</code> uses a certain
- * {@link GridLayout.Area area} (x1,y1,x2,y2) from the grid. One should not
- * add components that would overlap with the existing components because in
- * such case an {@link OverlapsException} is thrown. Adding component with
- * cursor automatically extends the grid by increasing the grid height.
+ * {@link GridLayout.Area area} (x1,y1,x2,y2) from the grid. One should not add
+ * components that would overlap with the existing components because in such
+ * case an {@link OverlapsException} is thrown. Adding component with cursor
+ * automatically extends the grid by increasing the grid height.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class GridLayout extends AbstractComponentContainer implements Layout {
- /**
- * Initial grid x size.
+ /**
+ * Initial grid x size.
*/
private int width = 0;
- /**
- * Initial grid y size.
+ /**
+ * Initial grid y size.
*/
private int height = 0;
- /**
- * Cursor X position: this is where the next component with
- * unspecified x,y is inserted
+ /**
+ * Cursor X position: this is where the next component with unspecified x,y
+ * is inserted
*/
private int cursorX = 0;
- /**
- * Cursor Y position: this is where the next component with
- * unspecified x,y is inserted
+ /**
+ * Cursor Y position: this is where the next component with unspecified x,y
+ * is inserted
*/
private int cursorY = 0;
- /**
- * Contains all items that are placed on the grid.
- * These are components with grid area definition.
+ /**
+ * Contains all items that are placed on the grid. These are components with
+ * grid area definition.
*/
private LinkedList areas = new LinkedList();
- /**
- * Mapping from components to threir respective areas.
+ /**
+ * Mapping from components to threir respective areas.
*/
private LinkedList components = new LinkedList();
- /**
- * Constructor for grid of given size.
- * Note that grid's final size depends on the items that are added into the grid.
- * Grid grows if you add components outside the grid's area.
- * @param width the Width of the grid.
- * @param height the Height of the grid.
+ /**
+ * Constructor for grid of given size. Note that grid's final size depends
+ * on the items that are added into the grid. Grid grows if you add
+ * components outside the grid's area.
+ *
+ * @param width
+ * the Width of the grid.
+ * @param height
+ * the Height of the grid.
*/
public GridLayout(int width, int height) {
setWidth(width);
setHeight(height);
}
- /**
- * Constructs an empty grid layout that is extended as needed.
+ /**
+ * Constructs an empty grid layout that is extended as needed.
*/
public GridLayout() {
this(1, 1);
}
- /**
+ /**
* <p>
- * Adds a component with a specified area to the grid. The area the
- * new component should take is defined by specifying the upper left
- * corner (x1, y1) and the lower right corner (x2, y2) of the area.
+ * Adds a component with a specified area to the grid. The area the new
+ * component should take is defined by specifying the upper left corner (x1,
+ * y1) and the lower right corner (x2, y2) of the area.
* </p>
*
* <p>
- * If the new component overlaps with any of the existing components
- * already present in the grid the operation will fail and an
+ * If the new component overlaps with any of the existing components already
+ * present in the grid the operation will fail and an
* {@link OverlapsException} is thrown.
* </p>
*
- * @param c the component to be added.
- * @param x1 the X-coordinate of the upper left corner of the area
- * <code>c</code> is supposed to occupy.
- * @param y1 the Y-coordinate of the upper left corner of the area
- * <code>c</code> is supposed to occupy.
- * @param x2 the X-coordinate of the lower right corner of the area
- * <code>c</code> is supposed to occupy.
- * @param y2 the Y-coordinate of the lower right corner of the area
- * <code>c</code> is supposed to occupy.
- * @throws OverlapsException if the new component overlaps with any
- * of the components already in the grid.
- * @throws OutOfBoundsException if the coordinates are outside of the
- * grid area.
+ * @param c
+ * the component to be added.
+ * @param x1
+ * the X-coordinate of the upper left corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param y1
+ * the Y-coordinate of the upper left corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param x2
+ * the X-coordinate of the lower right corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param y2
+ * the Y-coordinate of the lower right corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @throws OverlapsException
+ * if the new component overlaps with any of the components
+ * already in the grid.
+ * @throws OutOfBoundsException
+ * if the coordinates are outside of the grid area.
*/
- public void addComponent(
- Component component,
- int x1,
- int y1,
- int x2,
- int y2)
- throws OverlapsException, OutOfBoundsException {
+ public void addComponent(Component component, int x1, int y1, int x2, int y2)
+ throws OverlapsException, OutOfBoundsException {
if (component == null)
throw new NullPointerException("Component must not be null");
// Checks that the component does not already exist in the container
if (components.contains(component))
- throw new IllegalArgumentException("Component is already in the container");
+ throw new IllegalArgumentException(
+ "Component is already in the container");
// Creates the area
Area area = new Area(component, x1, y1, x2, y2);
// Checks the validity of the coordinates
if (x2 < x1 || y2 < y2)
- throw new IllegalArgumentException("Illegal coordinates for the component");
+ throw new IllegalArgumentException(
+ "Illegal coordinates for the component");
if (x1 < 0 || y1 < 0 || x2 >= width || y2 >= height)
throw new OutOfBoundsException(area);
@@ -172,7 +179,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
while (!done && i.hasNext()) {
Area existingArea = (Area) i.next();
if ((existingArea.y1 >= y1 && existingArea.x1 > x1)
- || existingArea.y1 > y1) {
+ || existingArea.y1 > y1) {
areas.add(index, area);
components.add(index, component);
done = true;
@@ -188,13 +195,14 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
- * Tests if the given area overlaps with any of the items already on
- * the grid.
+ /**
+ * Tests if the given area overlaps with any of the items already on the
+ * grid.
*
- * @param area the Area to be checked for overlapping.
- * @throws OverlapsException if <code>area</code> overlaps with
- * any existing area.
+ * @param area
+ * the Area to be checked for overlapping.
+ * @throws OverlapsException
+ * if <code>area</code> overlaps with any existing area.
*/
private void checkExistingOverlaps(Area area) throws OverlapsException {
for (Iterator i = areas.iterator(); i.hasNext();) {
@@ -206,19 +214,23 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * Adds the component into this container to coordinates x1,y1 (NortWest corner of the area.)
- * End coordinates (SouthEast corner of the area) are the same as x1,y1. Component width
- * and height is 1.
- * @param c the component to be added.
- * @param x the X-coordinate.
- * @param y the Y-coordinate.
+ /**
+ * Adds the component into this container to coordinates x1,y1 (NortWest
+ * corner of the area.) End coordinates (SouthEast corner of the area) are
+ * the same as x1,y1. Component width and height is 1.
+ *
+ * @param c
+ * the component to be added.
+ * @param x
+ * the X-coordinate.
+ * @param y
+ * the Y-coordinate.
*/
public void addComponent(Component c, int x, int y) {
this.addComponent(c, x, y, x, y);
}
- /**
+ /**
* Force the next component to be added to the beginning of the next line.
* By calling this function user can ensure that no more components are
* added to the right of the previous component.
@@ -230,9 +242,9 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
cursorY++;
}
- /**
- * Moves the cursor forwards by one. If the cursor goes out of the right grid border,
- * move it to next line.
+ /**
+ * Moves the cursor forwards by one. If the cursor goes out of the right
+ * grid border, move it to next line.
*
* @see #newLine()
*/
@@ -244,12 +256,14 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * Adds the component into this container to the cursor position.
- * If the cursor position is already occupied, the cursor is
- * moved forwards to find free position. If the cursor goes out
- * from the bottom of the grid, the grid is automaticly extended.
- * @param c the component to be added.
+ /**
+ * Adds the component into this container to the cursor position. If the
+ * cursor position is already occupied, the cursor is moved forwards to find
+ * free position. If the cursor goes out from the bottom of the grid, the
+ * grid is automaticly extended.
+ *
+ * @param c
+ * the component to be added.
*/
public void addComponent(Component component) {
@@ -272,11 +286,11 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
addComponent(component, cursorX, cursorY);
}
- /**
- * Removes the given component from this
- * container.
+ /**
+ * Removes the given component from this container.
*
- * @param c the component to be removed.
+ * @param c
+ * the component to be removed.
*/
public void removeComponent(Component component) {
@@ -300,12 +314,14 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
+ /**
* Removes the component specified with it's top-left corner coordinates
* from this grid.
*
- * @param x the Component's top-left corner's X-coordinate.
- * @param y the Component's top-left corner's Y-coordinate.
+ * @param x
+ * the Component's top-left corner's X-coordinate.
+ * @param y
+ * the Component's top-left corner's Y-coordinate.
*/
public void removeComponent(int x, int y) {
@@ -319,9 +335,9 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * Gets an Iterator to the component container contents. Using the
- * Iterator it's possible to step through the contents of the container.
+ /**
+ * Gets an Iterator to the component container contents. Using the Iterator
+ * it's possible to step through the contents of the container.
*
* @return the Iterator of the components inside the container.
*/
@@ -329,11 +345,13 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
return Collections.unmodifiableCollection(components).iterator();
}
- /**
+ /**
* Paints the contents of this component.
*
- * @param target the Paint Event.
- * @throws PaintException if the paint operation failed.
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
@@ -381,7 +399,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
target.addAttribute("x", curx);
target.addAttribute("y", cury);
-
+
if (cols > 1) {
target.addAttribute("w", cols);
}
@@ -403,9 +421,8 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
if (rows > 1) {
int spannedx = curx;
for (int j = 1; j <= cols; j++) {
- cellUsed.put(
- new Integer(spannedx),
- new Integer(cury + rows - 1));
+ cellUsed.put(new Integer(spannedx), new Integer(
+ cury + rows - 1));
spannedx++;
}
}
@@ -422,9 +439,8 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
// Current column contains already an item,
// check if rowspan affects at current x,y position
- int rowspanDepth =
- ((Integer) cellUsed.get(new Integer(curx)))
- .intValue();
+ int rowspanDepth = ((Integer) cellUsed.get(new Integer(
+ curx))).intValue();
if (rowspanDepth >= cury) {
@@ -446,7 +462,8 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
// empty cell is needed
emptyCells++;
- // Removes the cellUsed key as it has become obsolete
+ // Removes the cellUsed key as it has become
+ // obsolete
cellUsed.remove(new Integer(curx));
}
} else {
@@ -479,7 +496,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
// Last row handled
}
- /**
+ /**
* Gets the components UIDL tag.
*
* @return the Component UIDL tag as string.
@@ -489,39 +506,40 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
return "gridlayout";
}
- /**
+ /**
* This class defines an area on a grid. An Area is defined by the
* coordinates of its upper left corner (x1,y1) and lower right corner
* (x2,y2).
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Area {
- /**
- * X-coordinate of the upper left corner of the area.
+ /**
+ * X-coordinate of the upper left corner of the area.
*/
private int x1;
- /**
- * Y-coordinate of the upper left corner of the area.
+ /**
+ * Y-coordinate of the upper left corner of the area.
*/
private int y1;
- /**
- * X-coordinate of the lower right corner of the area.
+ /**
+ * X-coordinate of the lower right corner of the area.
*/
private int x2;
- /**
- * Y-coordinate of the lower right corner of the area.
+ /**
+ * Y-coordinate of the lower right corner of the area.
*/
private int y2;
- /**
- * Component painted on the area.
+ /**
+ * Component painted on the area.
*/
private Component component;
@@ -529,17 +547,24 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
* <p>
* Construct a new area on a grid.
* </p>
- * @param component the component connected to the area.
- * @param x1 the X-coordinate of the upper left corner of the area
- * <code>c</code> is supposed to occupy.
- * @param y1 the Y-coordinate of the upper left corner of the area
- * <code>c</code> is supposed to occupy.
- * @param x2 the X-coordinate of the lower right corner of the area
- * <code>c</code> is supposed to occupy.
- * @param y2 the Y-coordinate of the lower right corner of the area
- * <code>c</code> is supposed to occupy.
- * @throws OverlapsException if the new component overlaps with any
- * of the components already in the grid
+ *
+ * @param component
+ * the component connected to the area.
+ * @param x1
+ * the X-coordinate of the upper left corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param y1
+ * the Y-coordinate of the upper left corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param x2
+ * the X-coordinate of the lower right corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param y2
+ * the Y-coordinate of the lower right corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @throws OverlapsException
+ * if the new component overlaps with any of the components
+ * already in the grid
*/
public Area(Component component, int x1, int y1, int x2, int y2) {
this.x1 = x1;
@@ -549,44 +574,48 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
this.component = component;
}
- /**
+ /**
* Tests if the given Area overlaps with an another Area.
*
- * @param other the Another Area that's to be tested for overlap with
- * this area.
+ * @param other
+ * the Another Area that's to be tested for overlap with this
+ * area.
* @return <code>true</code> if <code>other</code> overlaps with
- * this area, <code>false</code> if it doesn't.
+ * this area, <code>false</code> if it doesn't.
*/
public boolean overlaps(Area other) {
- return x1 <= other.getX2()
- && y1 <= other.getY2()
- && x2 >= other.getX1()
- && y2 >= other.getY1();
+ return x1 <= other.getX2() && y1 <= other.getY2()
+ && x2 >= other.getX1() && y2 >= other.getY1();
}
- /**
+ /**
* Gets the component connected to the area.
+ *
* @return the Component.
*/
public Component getComponent() {
return component;
}
- /**
+ /**
* Sets the component connected to the area.
*
- * <p>This function only sets the value in the datastructure and does not
- * send any events or set parents.</p>
+ * <p>
+ * This function only sets the value in the datastructure and does not
+ * send any events or set parents.
+ * </p>
*
- * @param newComponent the new connected overriding the existing one.
+ * @param newComponent
+ * the new connected overriding the existing one.
*/
protected void setComponent(Component newComponent) {
- component= newComponent;
+ component = newComponent;
}
- /**
+ /**
* Gets the top-left corner x-coordinate.
+ *
* @return the top-left corner of x-coordinate.
*/
public int getX1() {
@@ -595,6 +624,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
/**
* Gets the bottom-right corner x-coordinate.
+ *
* @return the x-coordinate.
*/
public int getX2() {
@@ -603,6 +633,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
/**
* Gets the top-left corner y-coordinate.
+ *
* @return the y-coordinate.
*/
public int getY1() {
@@ -611,6 +642,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
/**
* Returns the bottom-right corner y-coordinate.
+ *
* @return the y-coordinate.
*/
public int getY2() {
@@ -619,33 +651,36 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
- /**
- * An <code>Exception</code> object which is thrown when two Items
- * occupy the same space on a grid.
+ /**
+ * An <code>Exception</code> object which is thrown when two Items occupy
+ * the same space on a grid.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class OverlapsException extends java.lang.RuntimeException {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3978144339870101561L;
-
- private Area existingArea;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3978144339870101561L;
+
+ private Area existingArea;
- /**
+ /**
* Constructs an <code>OverlapsException</code>.
- * @param existingArea
+ *
+ * @param existingArea
*/
public OverlapsException(Area existingArea) {
this.existingArea = existingArea;
}
- /**
+ /**
* Gets the area .
+ *
* @return the existing area.
*/
public Area getArea() {
@@ -653,35 +688,37 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * An <code>Exception</code> object which is thrown when an area exceeds the
- * bounds of the grid.
+ /**
+ * An <code>Exception</code> object which is thrown when an area exceeds
+ * the bounds of the grid.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class OutOfBoundsException extends java.lang.RuntimeException {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3618985589664592694L;
-
- private Area areaOutOfBounds;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3618985589664592694L;
+
+ private Area areaOutOfBounds;
- /**
+ /**
* Constructs an <code>OoutOfBoundsException</code> with the specified
* detail message.
*
- * @param areaOutOfBounds
+ * @param areaOutOfBounds
*/
public OutOfBoundsException(Area areaOutOfBounds) {
this.areaOutOfBounds = areaOutOfBounds;
}
- /**
- * Gets the area that is out of bounds.
+ /**
+ * Gets the area that is out of bounds.
+ *
* @return the area out of Bound.
*/
public Area getArea() {
@@ -689,16 +726,19 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * Sets the width of the grid. The width can not be reduced if there are
- * any areas that would be outside of the shrunk grid.
- * @param width the New width of the grid.
+ /**
+ * Sets the width of the grid. The width can not be reduced if there are any
+ * areas that would be outside of the shrunk grid.
+ *
+ * @param width
+ * the New width of the grid.
*/
public void setWidth(int width) {
// The the param
if (width < 1)
- throw new IllegalArgumentException("The grid width and height must be at least 1");
+ throw new IllegalArgumentException(
+ "The grid width and height must be at least 1");
// In case of no change
if (this.width == width)
@@ -717,24 +757,28 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
+ /**
* Get the width of the grids.
+ *
* @return the width of the grid.
*/
public final int getWidth() {
return this.width;
}
- /**
+ /**
* Sets the height of the grid. The width can not be reduced if there are
* any areas that would be outside of the shrunk grid.
- * @param height the height of the grid.
+ *
+ * @param height
+ * the height of the grid.
*/
public void setHeight(int height) {
// The the param
if (height < 1)
- throw new IllegalArgumentException("The grid width and height must be at least 1");
+ throw new IllegalArgumentException(
+ "The grid width and height must be at least 1");
// In case of no change
if (this.height == height)
@@ -753,67 +797,71 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
+ /**
* Gets the height of the grid.
+ *
* @return int - how many cells high the grid is.
*/
public final int getHeight() {
return this.height;
}
- /**
- * Gets the current cursor x-position.
- * The cursor position points the position for the next component
- * that is added without specifying its coordinates. When the
- * cursor position is occupied, the next component will be added
- * to first free position after the cursor.
+ /**
+ * Gets the current cursor x-position. The cursor position points the
+ * position for the next component that is added without specifying its
+ * coordinates. When the cursor position is occupied, the next component
+ * will be added to first free position after the cursor.
+ *
* @return the Cursor x-coordinate.
*/
public int getCursorX() {
return cursorX;
}
- /**
- * Gets the current cursor y-position.
- * The cursor position points the position for the next component
- * that is added without specifying its coordinates. When the
- * cursor position is occupied, the next component will be added
- * to first free position after the cursor.
+ /**
+ * Gets the current cursor y-position. The cursor position points the
+ * position for the next component that is added without specifying its
+ * coordinates. When the cursor position is occupied, the next component
+ * will be added to first free position after the cursor.
+ *
* @return the Cursor y-coordinate.
*/
public int getCursorY() {
return cursorY;
}
-
+
/* Documented in superclass */
- public void replaceComponent(
- Component oldComponent,
- Component newComponent) {
+ public void replaceComponent(Component oldComponent, Component newComponent) {
- // Gets the locations
+ // Gets the locations
Area oldLocation = null;
- Area newLocation = null;
- for (Iterator i=areas.iterator(); i.hasNext();) {
+ Area newLocation = null;
+ for (Iterator i = areas.iterator(); i.hasNext();) {
Area location = (Area) i.next();
Component component = (Component) location.getComponent();
- if (component == oldComponent) oldLocation = location;
- if (component == newComponent) newLocation = location;
- }
+ if (component == oldComponent)
+ oldLocation = location;
+ if (component == newComponent)
+ newLocation = location;
+ }
if (oldLocation == null)
addComponent(newComponent);
else if (newLocation == null) {
removeComponent(oldComponent);
- addComponent(newComponent,oldLocation.getX1(),oldLocation.getY1(),oldLocation.getX2(),oldLocation.getY2());
+ addComponent(newComponent, oldLocation.getX1(),
+ oldLocation.getY1(), oldLocation.getX2(), oldLocation
+ .getY2());
} else {
oldLocation.setComponent(newComponent);
newLocation.setComponent(oldComponent);
requestRepaint();
}
}
-
+
/*
* Removes all components from this container.
+ *
* @see com.itmill.toolkit.ui.ComponentContainer#removeAllComponents()
*/
public void removeAllComponents() {
diff --git a/src/com/itmill/toolkit/ui/Label.java b/src/com/itmill/toolkit/ui/Label.java
index 9126beb31b..d360e208e3 100644
--- a/src/com/itmill/toolkit/ui/Label.java
+++ b/src/com/itmill/toolkit/ui/Label.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -35,108 +35,112 @@ import com.itmill.toolkit.data.util.ObjectProperty;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-/**
+/**
* Label component for showing non-editable short texts.
- *
+ *
* The label content can be set to the modes specified by the final members
* CONTENT_*
*
- * <p>The contents of the label may contain simple
- * formatting:
+ * <p>
+ * The contents of the label may contain simple formatting:
* <ul>
* <li> <b>&lt;b></b> Bold
* <li> <b>&lt;i></b> Italic
* <li> <b>&lt;u></b> Underlined
* <li> <b>&lt;br/></b> Linebreak
- * <li> <b>&lt;ul>&lt;li>item 1&lt;/li>&lt;li>item 2&lt;/li>&lt;/ul></b> List of items
+ * <li> <b>&lt;ul>&lt;li>item 1&lt;/li>&lt;li>item 2&lt;/li>&lt;/ul></b> List
+ * of items
* </ul>
* The <b>b</b>,<b>i</b>,<b>u</b> and <b>li</b> tags can contain all the
* tags in the list recursively.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class Label
- extends AbstractComponent
- implements
- Property,
- Property.Viewer,
- Property.ValueChangeListener,
+public class Label extends AbstractComponent implements Property,
+ Property.Viewer, Property.ValueChangeListener,
Property.ValueChangeNotifier, Comparable {
- /**
+ /**
* Content mode, where the label contains only plain text. The getValue()
- * result is coded to XML when painting.
+ * result is coded to XML when painting.
*/
public static final int CONTENT_TEXT = 0;
- /**
+ /**
* Content mode, where the label contains preformatted text.
*/
public static final int CONTENT_PREFORMATTED = 1;
- /**
- * Formatted content mode, where the contents is XML restricted to the
- * UIDL 1.0 formatting markups.
+ /**
+ * Formatted content mode, where the contents is XML restricted to the UIDL
+ * 1.0 formatting markups.
*/
public static final int CONTENT_UIDL = 2;
- /**
- * Content mode, where the label contains XHTML. Contents is then enclosed in
- * DIV elements having namespace of "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".
+ /**
+ * Content mode, where the label contains XHTML. Contents is then enclosed
+ * in DIV elements having namespace of
+ * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".
*/
public static final int CONTENT_XHTML = 3;
- /**
- * Content mode, where the label contains well-formed or well-balanced XML.
+ /**
+ * Content mode, where the label contains well-formed or well-balanced XML.
* Each of the root elements must have their default namespace specified.
*/
public static final int CONTENT_XML = 4;
- /**
- * Content mode, where the label contains RAW output. Output is not
- * required to comply to with XML. In Web Adapter output is inserted inside
- * the resulting HTML document as-is. This is useful for some specific
- * purposes where possibly broken HTML content needs to be shown, but in
- * most cases XHTML mode should be preferred.
+ /**
+ * Content mode, where the label contains RAW output. Output is not required
+ * to comply to with XML. In Web Adapter output is inserted inside the
+ * resulting HTML document as-is. This is useful for some specific purposes
+ * where possibly broken HTML content needs to be shown, but in most cases
+ * XHTML mode should be preferred.
*/
public static final int CONTENT_RAW = 5;
- /**
- * The default content mode is plain text.
+ /**
+ * The default content mode is plain text.
*/
public static final int CONTENT_DEFAULT = CONTENT_TEXT;
private Property dataSource;
+
private int contentMode = CONTENT_DEFAULT;
- /**
- * Creates an empty Label.
+ /**
+ * Creates an empty Label.
*/
public Label() {
setPropertyDataSource(new ObjectProperty("", String.class));
}
- /**
+ /**
* Creates a new instance of Label with text-contents.
- * @param content
+ *
+ * @param content
*/
public Label(String content) {
setPropertyDataSource(new ObjectProperty(content, String.class));
}
- /**
- * Creates a new instance of Label with text-contents read from given datasource.
- * @param contentSource
+ /**
+ * Creates a new instance of Label with text-contents read from given
+ * datasource.
+ *
+ * @param contentSource
*/
public Label(Property contentSource) {
setPropertyDataSource(contentSource);
}
- /**
- * Creates a new instance of Label with text-contents.
+ /**
+ * Creates a new instance of Label with text-contents.
+ *
* @param content
* @param contentMode
*/
@@ -145,28 +149,32 @@ public class Label
setContentMode(contentMode);
}
- /**
- * Creates a new instance of Label with text-contents read from given datasource.
+ /**
+ * Creates a new instance of Label with text-contents read from given
+ * datasource.
+ *
* @param contentSource
- * @param contentMode
+ * @param contentMode
*/
public Label(Property contentSource, int contentMode) {
setPropertyDataSource(contentSource);
setContentMode(contentMode);
}
- /**
+ /**
* Get the component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "label";
}
- /**
- * Set the component to read-only.
- * Readonly is not used in label.
- * @param readOnly True to enable read-only mode, False to disable it.
+ /**
+ * Set the component to read-only. Readonly is not used in label.
+ *
+ * @param readOnly
+ * True to enable read-only mode, False to disable it.
*/
public void setReadOnly(boolean readOnly) {
if (dataSource == null)
@@ -174,9 +182,10 @@ public class Label
dataSource.setReadOnly(readOnly);
}
- /**
- * Is the component read-only ?
- * Readonly is not used in label - this returns allways false.
+ /**
+ * Is the component read-only ? Readonly is not used in label - this returns
+ * allways false.
+ *
* @return <code>true</code> if the component is in read only mode.
*/
public boolean isReadOnly() {
@@ -185,10 +194,13 @@ public class Label
return dataSource.isReadOnly();
}
- /**
+ /**
* Paints the content of this component.
- * @param target the Paint Event.
- * @throws PaintException if the Paint Operation fails.
+ *
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the Paint Operation fails.
*/
public void paintContent(PaintTarget target) throws PaintException {
if (contentMode == CONTENT_TEXT)
@@ -197,10 +209,8 @@ public class Label
target.addUIDL(toString());
else if (contentMode == CONTENT_XHTML) {
target.startTag("data");
- target.addXMLSection(
- "div",
- toString(),
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
+ target.addXMLSection("div", toString(),
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
target.endTag("data");
} else if (contentMode == CONTENT_PREFORMATTED) {
target.startTag("pre");
@@ -210,16 +220,17 @@ public class Label
target.addXMLSection("data", toString(), null);
} else if (contentMode == CONTENT_RAW) {
target.startTag("data");
- target.addAttribute("escape",false);
+ target.addAttribute("escape", false);
target.addCharacterData(toString());
target.endTag("data");
}
}
- /**
- * Gets the value of the label.
- * Value of the label is the XML contents of the label.
+ /**
+ * Gets the value of the label. Value of the label is the XML contents of
+ * the label.
+ *
* @return the Value of the label.
*/
public Object getValue() {
@@ -228,17 +239,19 @@ public class Label
return dataSource.getValue();
}
- /**
- * Set the value of the label.
- * Value of the label is the XML contents of the label.
- * @param newValue the New value of the label.
+ /**
+ * Set the value of the label. Value of the label is the XML contents of the
+ * label.
+ *
+ * @param newValue
+ * the New value of the label.
*/
public void setValue(Object newValue) {
if (dataSource == null)
throw new IllegalStateException("Datasource must be se");
this.dataSource.setValue(newValue);
}
-
+
/**
* @see java.lang.Object#toString()
*/
@@ -247,9 +260,10 @@ public class Label
throw new IllegalStateException("Datasource must be se");
return dataSource.toString();
}
-
+
/**
* Gets the type of the Property.
+ *
* @see com.itmill.toolkit.data.Property#getType()
*/
public Class getType() {
@@ -259,8 +273,9 @@ public class Label
}
/**
- * Gets the viewing data-source property.
- * @return the data source property.
+ * Gets the viewing data-source property.
+ *
+ * @return the data source property.
* @see com.itmill.toolkit.data.Property.Viewer#getPropertyDataSource()
*/
public Property getPropertyDataSource() {
@@ -268,56 +283,54 @@ public class Label
}
/**
- * Sets the property as data-source for viewing.
- * @param newDataSource the new data source Property
+ * Sets the property as data-source for viewing.
+ *
+ * @param newDataSource
+ * the new data source Property
* @see com.itmill.toolkit.data.Property.Viewer#setPropertyDataSource(com.itmill.toolkit.data.Property)
*/
public void setPropertyDataSource(Property newDataSource) {
// Stops listening the old data source changes
if (dataSource != null
- && Property.ValueChangeNotifier.class.isAssignableFrom(
- dataSource.getClass()))
- ((Property.ValueChangeNotifier) dataSource).removeListener(this);
+ && Property.ValueChangeNotifier.class
+ .isAssignableFrom(dataSource.getClass()))
+ ((Property.ValueChangeNotifier) dataSource).removeListener(this);
// Sets the new data source
dataSource = newDataSource;
// Listens the new data source if possible
if (dataSource != null
- && Property.ValueChangeNotifier.class.isAssignableFrom(
- dataSource.getClass()))
- ((Property.ValueChangeNotifier) dataSource).addListener(this);
+ && Property.ValueChangeNotifier.class
+ .isAssignableFrom(dataSource.getClass()))
+ ((Property.ValueChangeNotifier) dataSource).addListener(this);
}
- /**
+ /**
* Gets the content mode of the Label.
*
- * <p>Possible content modes include:
- * <ul>
- * <li><b>CONTENT_TEXT</b>
- * Content mode, where the label contains only plain text. The
- * getValue() result is coded to XML when painting.</li>
- * <li><b>CONTENT_PREFORMATTED</b>
- * Content mode, where the label contains preformatted text.</li>
- * <li><b>CONTENT_UIDL</b>
- * Formatted content mode, where the contents is XML restricted to
- * the UIDL 1.0 formatting markups.</li>
- * <li><b>CONTENT_XHTML</b>
- * Content mode, where the label contains XHTML. Contents is then
- * enclosed in DIV elements having namespace of
- * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".</li>
- * <li><b>CONTENT_XML</b>
- * Content mode, where the label contains well-formed or
- * well-balanced XML. Each of the root elements must have their
- * default namespace specified.</li>
- * <li><b>CONTENT_RAW</b>
- * Content mode, where the label contains RAW output. Output is not
- * required to comply to with XML. In Web Adapter output is
- * inserted inside the resulting HTML document as-is. This is
- * useful for some specific purposes where possibly broken HTML
- * content needs to be shown, but in most cases XHTML mode should
- * be preferred.</li>
- * </ul></p>
+ * <p>
+ * Possible content modes include:
+ * <ul>
+ * <li><b>CONTENT_TEXT</b> Content mode, where the label contains only
+ * plain text. The getValue() result is coded to XML when painting.</li>
+ * <li><b>CONTENT_PREFORMATTED</b> Content mode, where the label contains
+ * preformatted text.</li>
+ * <li><b>CONTENT_UIDL</b> Formatted content mode, where the contents is
+ * XML restricted to the UIDL 1.0 formatting markups.</li>
+ * <li><b>CONTENT_XHTML</b> Content mode, where the label contains XHTML.
+ * Contents is then enclosed in DIV elements having namespace of
+ * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".</li>
+ * <li><b>CONTENT_XML</b> Content mode, where the label contains
+ * well-formed or well-balanced XML. Each of the root elements must have
+ * their default namespace specified.</li>
+ * <li><b>CONTENT_RAW</b> Content mode, where the label contains RAW
+ * output. Output is not required to comply to with XML. In Web Adapter
+ * output is inserted inside the resulting HTML document as-is. This is
+ * useful for some specific purposes where possibly broken HTML content
+ * needs to be shown, but in most cases XHTML mode should be preferred.</li>
+ * </ul>
+ * </p>
*
* @return the Content mode of the label.
*/
@@ -325,37 +338,34 @@ public class Label
return contentMode;
}
- /**
+ /**
* Sets the content mode of the Label.
*
- * <p>Possible content modes include:
- * <ul>
- * <li><b>CONTENT_TEXT</b>
- * Content mode, where the label contains only plain text. The
- * getValue() result is coded to XML when painting.</li>
- * <li><b>CONTENT_PREFORMATTED</b>
- * Content mode, where the label contains preformatted text.</li>
- * <li><b>CONTENT_UIDL</b>
- * Formatted content mode, where the contents is XML restricted to
- * the UIDL 1.0 formatting markups.</li>
- * <li><b>CONTENT_XHTML</b>
- * Content mode, where the label contains XHTML. Contents is then
- * enclosed in DIV elements having namespace of
- * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".</li>
- * <li><b>CONTENT_XML</b>
- * Content mode, where the label contains well-formed or
- * well-balanced XML. Each of the root elements must have their
- * default namespace specified.</li>
- * <li><b>CONTENT_RAW</b>
- * Content mode, where the label contains RAW output. Output is not
- * required to comply to with XML. In Web Adapter output is
- * inserted inside the resulting HTML document as-is. This is
- * useful for some specific purposes where possibly broken HTML
- * content needs to be shown, but in most cases XHTML mode should
- * be preferred.</li>
- * </ul></p>
+ * <p>
+ * Possible content modes include:
+ * <ul>
+ * <li><b>CONTENT_TEXT</b> Content mode, where the label contains only
+ * plain text. The getValue() result is coded to XML when painting.</li>
+ * <li><b>CONTENT_PREFORMATTED</b> Content mode, where the label contains
+ * preformatted text.</li>
+ * <li><b>CONTENT_UIDL</b> Formatted content mode, where the contents is
+ * XML restricted to the UIDL 1.0 formatting markups.</li>
+ * <li><b>CONTENT_XHTML</b> Content mode, where the label contains XHTML.
+ * Contents is then enclosed in DIV elements having namespace of
+ * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".</li>
+ * <li><b>CONTENT_XML</b> Content mode, where the label contains
+ * well-formed or well-balanced XML. Each of the root elements must have
+ * their default namespace specified.</li>
+ * <li><b>CONTENT_RAW</b> Content mode, where the label contains RAW
+ * output. Output is not required to comply to with XML. In Web Adapter
+ * output is inserted inside the resulting HTML document as-is. This is
+ * useful for some specific purposes where possibly broken HTML content
+ * needs to be shown, but in most cases XHTML mode should be preferred.</li>
+ * </ul>
+ * </p>
*
- * @param contentMode the New content mode of the label.
+ * @param contentMode
+ * the New content mode of the label.
*/
public void setContentMode(int contentMode) {
if (contentMode >= CONTENT_TEXT && contentMode <= CONTENT_RAW)
@@ -368,34 +378,36 @@ public class Label
static {
try {
- VALUE_CHANGE_METHOD =
- Property.ValueChangeListener.class.getDeclaredMethod(
- "valueChange",
- new Class[] { Property.ValueChangeEvent.class });
+ VALUE_CHANGE_METHOD = Property.ValueChangeListener.class
+ .getDeclaredMethod("valueChange",
+ new Class[] { Property.ValueChangeEvent.class });
} catch (java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
}
- /**
- * Value change event
+ /**
+ * Value change event
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
- public class ValueChangeEvent
- extends Component.Event
- implements Property.ValueChangeEvent {
+ public class ValueChangeEvent extends Component.Event implements
+ Property.ValueChangeEvent {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3906084563938586935L;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3906084563938586935L;
- /**
- * New instance of text change event
- * @param source the Source of the event.
+ /**
+ * New instance of text change event
+ *
+ * @param source
+ * the Source of the event.
*/
public ValueChangeEvent(Label source) {
super(source);
@@ -403,6 +415,7 @@ public class Label
/**
* Gets the Property that has been modified.
+ *
* @see com.itmill.toolkit.data.Property.ValueChangeEvent#getProperty()
*/
public Property getProperty() {
@@ -410,32 +423,31 @@ public class Label
}
}
- /**
+ /**
* Adds the value change listener.
- * @param listener the Listener to be added.
+ *
+ * @param listener
+ * the Listener to be added.
* @see com.itmill.toolkit.data.Property.ValueChangeNotifier#addListener(com.itmill.toolkit.data.Property.ValueChangeListener)
*/
public void addListener(Property.ValueChangeListener listener) {
- addListener(
- Label.ValueChangeEvent.class,
- listener,
- VALUE_CHANGE_METHOD);
+ addListener(Label.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD);
}
/**
* Removes the value change listener.
- * @param listener the Listener to be removed.
+ *
+ * @param listener
+ * the Listener to be removed.
* @see com.itmill.toolkit.data.Property.ValueChangeNotifier#removeListener(com.itmill.toolkit.data.Property.ValueChangeListener)
*/
public void removeListener(Property.ValueChangeListener listener) {
- removeListener(
- Label.ValueChangeEvent.class,
- listener,
- VALUE_CHANGE_METHOD);
+ removeListener(Label.ValueChangeEvent.class, listener,
+ VALUE_CHANGE_METHOD);
}
- /**
- * Emits the options change event.
+ /**
+ * Emits the options change event.
*/
protected void fireValueChange() {
// Set the error message
@@ -443,73 +455,84 @@ public class Label
requestRepaint();
}
- /**
+ /**
* Listens the value change events from data source.
+ *
* @see com.itmill.toolkit.data.Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
*/
public void valueChange(Property.ValueChangeEvent event) {
fireValueChange();
}
- /**
- * Compares the Label to other objects.
+ /**
+ * Compares the Label to other objects.
*
- * <p>Labels can be compared to other labels for sorting label contents.
- * This is especially handy for sorting table columns.</p>
+ * <p>
+ * Labels can be compared to other labels for sorting label contents. This
+ * is especially handy for sorting table columns.
+ * </p>
*
- * <p>In RAW, PREFORMATTED and TEXT modes, the label contents are
- * compared as is. In XML, UIDL and XHTML modes, only CDATA is compared and
- * tags ignored. If the other object is not a Label, its toString() return
- * value is used in comparison.</p>
- * @param other the Other object to compare to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object.
+ * <p>
+ * In RAW, PREFORMATTED and TEXT modes, the label contents are compared as
+ * is. In XML, UIDL and XHTML modes, only CDATA is compared and tags
+ * ignored. If the other object is not a Label, its toString() return value
+ * is used in comparison.
+ * </p>
+ *
+ * @param other
+ * the Other object to compare to.
+ * @return a negative integer, zero, or a positive integer as this object is
+ * less than, equal to, or greater than the specified object.
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(Object other) {
-
+
String thisValue;
String otherValue;
-
- if (contentMode == CONTENT_XML || contentMode == CONTENT_UIDL || contentMode == CONTENT_XHTML)
+
+ if (contentMode == CONTENT_XML || contentMode == CONTENT_UIDL
+ || contentMode == CONTENT_XHTML)
thisValue = stripTags(toString());
- else
+ else
thisValue = toString();
-
- if (other instanceof Label && (((Label)other).getContentMode() == CONTENT_XML ||
- ((Label)other).getContentMode() == CONTENT_UIDL ||
- ((Label)other).getContentMode() == CONTENT_XHTML))
+
+ if (other instanceof Label
+ && (((Label) other).getContentMode() == CONTENT_XML
+ || ((Label) other).getContentMode() == CONTENT_UIDL || ((Label) other)
+ .getContentMode() == CONTENT_XHTML))
otherValue = stripTags(other.toString());
- else
+ else
otherValue = other.toString();
-
+
return thisValue.compareTo(otherValue);
}
- /**
+ /**
* Strips the tags from the XML.
*
- * @param xml the String containing a XML snippet.
+ * @param xml
+ * the String containing a XML snippet.
* @return the original XML without tags.
*/
private String stripTags(String xml) {
-
+
StringBuffer res = new StringBuffer();
int processed = 0;
int xmlLen = xml.length();
while (processed < xmlLen) {
- int next = xml.indexOf('<',processed);
- if (next < 0)
+ int next = xml.indexOf('<', processed);
+ if (next < 0)
next = xmlLen;
- res.append(xml.substring(processed,next));
+ res.append(xml.substring(processed, next));
if (processed < xmlLen) {
- next = xml.indexOf('>',processed);
- if (next < 0) next = xmlLen;
- processed = next+1;
+ next = xml.indexOf('>', processed);
+ if (next < 0)
+ next = xmlLen;
+ processed = next + 1;
}
}
-
+
return res.toString();
}
diff --git a/src/com/itmill/toolkit/ui/Layout.java b/src/com/itmill/toolkit/ui/Layout.java
index a92185bf52..810fac86d2 100644
--- a/src/com/itmill/toolkit/ui/Layout.java
+++ b/src/com/itmill/toolkit/ui/Layout.java
@@ -1,41 +1,42 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
-/**
+/**
* Extension to the {@link ComponentContainer} interface which adds the
- * layouting control to the elements in the container. This is
- * required by the various layout components to enable them to place other
- * components in specific locations in the UI.
- *
+ * layouting control to the elements in the container. This is required by the
+ * various layout components to enable them to place other components in
+ * specific locations in the UI.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Layout extends ComponentContainer {
diff --git a/src/com/itmill/toolkit/ui/Link.java b/src/com/itmill/toolkit/ui/Link.java
index 962cf9a55e..03f02a20c7 100644
--- a/src/com/itmill/toolkit/ui/Link.java
+++ b/src/com/itmill/toolkit/ui/Link.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -32,42 +32,50 @@ import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.Resource;
-/**
+/**
* Link is used to create external or internal URL links.
- *
- * Internal links can be used to create action items, which
- * change the state to application to one of the predefined states.
- * For example, a link can be created for existing MenuTree items.
- *
+ *
+ * Internal links can be used to create action items, which change the state to
+ * application to one of the predefined states. For example, a link can be
+ * created for existing MenuTree items.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Link extends AbstractComponent {
/* Target window border type constant: No window border */
public static final int TARGET_BORDER_NONE = Window.BORDER_NONE;
+
/* Target window border type constant: Minimal window border */
public static final int TARGET_BORDER_MINIMAL = Window.BORDER_MINIMAL;
+
/* Target window border type constant: Default window border */
public static final int TARGET_BORDER_DEFAULT = Window.BORDER_DEFAULT;
private Resource resource = null;
+
private Window window = null;
+
private String targetName;
+
private int targetBorder = TARGET_BORDER_DEFAULT;
+
private int targetWidth = -1;
+
private int targetHeight = -1;
- /**
- * Creates a new link.
+ /**
+ * Creates a new link.
*/
public Link() {
-
+
}
-
- /**
- * Creates a new link to a window.
+
+ /**
+ * Creates a new link to a window.
*/
public Link(Window window) {
@@ -83,36 +91,37 @@ public class Link extends AbstractComponent {
setTargetBorder(window.getBorder());
}
- /**
- * Creates a new instance of Link.
+ /**
+ * Creates a new instance of Link.
+ *
* @param caption
- * @param resource
+ * @param resource
*/
public Link(String caption, Resource resource) {
setCaption(caption);
this.resource = resource;
}
- /**
- * Creates a new instance of Link that opens a new window.
+ /**
+ * Creates a new instance of Link that opens a new window.
*
*
- * @param caption the Link text.
- * @param targetName the name of the target window where the link
- * opens to. Empty name of null implies that
- * the target is opened to the window containing the link.
- * @param width the Width of the target window.
- * @param height the Height of the target window.
- * @param border the Border style of the target window.
+ * @param caption
+ * the Link text.
+ * @param targetName
+ * the name of the target window where the link opens to. Empty
+ * name of null implies that the target is opened to the window
+ * containing the link.
+ * @param width
+ * the Width of the target window.
+ * @param height
+ * the Height of the target window.
+ * @param border
+ * the Border style of the target window.
*
*/
- public Link(
- String caption,
- Resource resource,
- String targetName,
- int width,
- int height,
- int border) {
+ public Link(String caption, Resource resource, String targetName,
+ int width, int height, int border) {
setCaption(caption);
this.resource = resource;
setTargetName(targetName);
@@ -121,18 +130,22 @@ public class Link extends AbstractComponent {
setTargetBorder(border);
}
- /**
+ /**
* Gets the component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "link";
}
- /**
+ /**
* Paints the content of this component.
- * @param target the Paint Event.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
@@ -142,10 +155,10 @@ public class Link extends AbstractComponent {
target.addAttribute("src", resource);
else
return;
-
+
// Target window name
String name = getTargetName();
- if (name != null && name.length()>0)
+ if (name != null && name.length() > 0)
target.addAttribute("name", name);
// Target window size
@@ -153,109 +166,126 @@ public class Link extends AbstractComponent {
target.addAttribute("width", getTargetWidth());
if (getTargetHeight() >= 0)
target.addAttribute("height", getTargetHeight());
-
+
// Target window border
switch (getTargetBorder()) {
- case TARGET_BORDER_MINIMAL :
- target.addAttribute("border", "minimal");
- break;
- case TARGET_BORDER_NONE :
- target.addAttribute("border", "none");
- break;
+ case TARGET_BORDER_MINIMAL:
+ target.addAttribute("border", "minimal");
+ break;
+ case TARGET_BORDER_NONE:
+ target.addAttribute("border", "none");
+ break;
}
}
- /**
+ /**
* Returns the target window border.
+ *
* @return the target window border.
*/
public int getTargetBorder() {
return targetBorder;
}
- /**
+ /**
* Returns the target window height or -1 if not set.
+ *
* @return the target window height.
*/
public int getTargetHeight() {
return targetHeight < 0 ? -1 : targetHeight;
}
- /**
- * Returns the target window name. Empty name of null implies that
- * the target is opened to the window containing the link.
+ /**
+ * Returns the target window name. Empty name of null implies that the
+ * target is opened to the window containing the link.
+ *
* @return the target window name.
*/
public String getTargetName() {
return targetName;
}
- /**
+ /**
* Returns the target window width or -1 if not set.
+ *
* @return the target window width.
*/
public int getTargetWidth() {
return targetWidth < 0 ? -1 : targetWidth;
}
- /**
+ /**
* Sets the border of the target window.
- * @param targetBorder the targetBorder to set.
+ *
+ * @param targetBorder
+ * the targetBorder to set.
*/
public void setTargetBorder(int targetBorder) {
if (targetBorder == TARGET_BORDER_DEFAULT
- || targetBorder == TARGET_BORDER_MINIMAL
- || targetBorder == TARGET_BORDER_NONE) {
+ || targetBorder == TARGET_BORDER_MINIMAL
+ || targetBorder == TARGET_BORDER_NONE) {
this.targetBorder = targetBorder;
requestRepaint();
}
}
- /**
+ /**
* Sets the target window height.
- * @param targetHeight the targetHeight to set.
+ *
+ * @param targetHeight
+ * the targetHeight to set.
*/
public void setTargetHeight(int targetHeight) {
this.targetHeight = targetHeight;
requestRepaint();
}
- /**
+ /**
* Sets the target window name.
- * @param targetName the targetName to set.
+ *
+ * @param targetName
+ * the targetName to set.
*/
public void setTargetName(String targetName) {
this.targetName = targetName;
requestRepaint();
}
- /**
+ /**
* Sets the target window width.
- * @param targetWidth the targetWidth to set.
+ *
+ * @param targetWidth
+ * the targetWidth to set.
*/
public void setTargetWidth(int targetWidth) {
this.targetWidth = targetWidth;
requestRepaint();
}
- /**
+
+ /**
* Returns the resource this link opens.
+ *
* @return the Resource.
*/
public Resource getResource() {
return resource;
}
- /**
+ /**
* Returns the window this link opens.
+ *
* @return the Window.
*/
public Window getWindow() {
return window;
}
- /**
+ /**
* Sets the resource this link opens.
- * @param resource the resource to set.
+ *
+ * @param resource
+ * the resource to set.
*/
public void setResource(Resource resource) {
this.resource = resource;
@@ -265,9 +295,11 @@ public class Link extends AbstractComponent {
requestRepaint();
}
- /**
+ /**
* Sets the window this link opens.
- * @param window the window to set.
+ *
+ * @param window
+ * the window to set.
*/
public void setWindow(Window window) {
this.window = window;
diff --git a/src/com/itmill/toolkit/ui/OrderedLayout.java b/src/com/itmill/toolkit/ui/OrderedLayout.java
index 959dfd8762..cea7a18de0 100644
--- a/src/com/itmill/toolkit/ui/OrderedLayout.java
+++ b/src/com/itmill/toolkit/ui/OrderedLayout.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -34,70 +34,75 @@ import com.itmill.toolkit.terminal.PaintTarget;
import java.util.Iterator;
import java.util.LinkedList;
-/** Ordered layout.
- *
- * <code>OrderedLayout</code> is a component container, which shows the subcomponents in the
- * order of their addition in specified orientation.
- *
+/**
+ * Ordered layout.
+ *
+ * <code>OrderedLayout</code> is a component container, which shows the
+ * subcomponents in the order of their addition in specified orientation.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class OrderedLayout
- extends AbstractComponentContainer
- implements Layout {
+public class OrderedLayout extends AbstractComponentContainer implements Layout {
/* Predefined orientations ***************************************** */
- /**
- * Components are to be layed out vertically.
+ /**
+ * Components are to be layed out vertically.
*/
public static int ORIENTATION_VERTICAL = 0;
- /**
- * Components are to be layed out horizontally.
+
+ /**
+ * Components are to be layed out horizontally.
*/
public static int ORIENTATION_HORIZONTAL = 1;
- /**
- * Custom layout slots containing the components.
+ /**
+ * Custom layout slots containing the components.
*/
private LinkedList components = new LinkedList();
- /**
- * Orientation of the layout.
+ /**
+ * Orientation of the layout.
*/
private int orientation;
- /**
- * Creates a new ordered layout.
- * The order of the layout is <code>ORIENTATION_VERTICAL</code>.
+ /**
+ * Creates a new ordered layout. The order of the layout is
+ * <code>ORIENTATION_VERTICAL</code>.
*/
public OrderedLayout() {
orientation = ORIENTATION_VERTICAL;
}
- /**
- * Create a new ordered layout.
- * The orientation of the layout is given as parameters.
- *
- * @param orientation the Orientation of the layout.
+ /**
+ * Create a new ordered layout. The orientation of the layout is given as
+ * parameters.
+ *
+ * @param orientation
+ * the Orientation of the layout.
*/
public OrderedLayout(int orientation) {
this.orientation = orientation;
}
- /**
+ /**
* Gets the component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "orderedlayout";
}
- /**
- * Add a component into this container. The component is added to the
- * right or under the previous component.
- * @param c the component to be added.
+ /**
+ * Add a component into this container. The component is added to the right
+ * or under the previous component.
+ *
+ * @param c
+ * the component to be added.
*/
public void addComponent(Component c) {
components.add(c);
@@ -105,10 +110,12 @@ public class OrderedLayout
requestRepaint();
}
- /**
- * Adds a component into this container. The component is added to the
- * left or on top of the other components.
- * @param c the component to be added.
+ /**
+ * Adds a component into this container. The component is added to the left
+ * or on top of the other components.
+ *
+ * @param c
+ * the component to be added.
*/
public void addComponentAsFirst(Component c) {
components.addFirst(c);
@@ -116,11 +123,14 @@ public class OrderedLayout
requestRepaint();
}
- /**
- * Adds a component into indexed position in this container.
- * @param c the component to be added.
- * @param index the Index of the component position.
- * The components currently in and after the position are shifted forwards.
+ /**
+ * Adds a component into indexed position in this container.
+ *
+ * @param c
+ * the component to be added.
+ * @param index
+ * the Index of the component position. The components currently
+ * in and after the position are shifted forwards.
*/
public void addComponent(Component c, int index) {
components.add(index, c);
@@ -128,9 +138,11 @@ public class OrderedLayout
requestRepaint();
}
- /**
+ /**
* Removes the component from this container.
- * @param c the component to be removed.
+ *
+ * @param c
+ * the component to be removed.
*/
public void removeComponent(Component c) {
super.removeComponent(c);
@@ -138,23 +150,27 @@ public class OrderedLayout
requestRepaint();
}
- /**
- * Gets the component container iterator for going trough all the components in
- * the container.
+ /**
+ * Gets the component container iterator for going trough all the components
+ * in the container.
+ *
* @return the Iterator of the components inside the container.
*/
public Iterator getComponentIterator() {
return components.iterator();
}
- /**
+ /**
* Paints the content of this component.
- * @param target the Paint Event.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
- // Adds the attributes: orientation
+ // Adds the attributes: orientation
// note that the default values (b/vertival) are omitted
if (orientation == ORIENTATION_HORIZONTAL)
target.addAttribute("orientation", "horizontal");
@@ -168,34 +184,35 @@ public class OrderedLayout
}
}
- /**
+ /**
* Gets the orientation of the container.
+ *
* @return the Value of property orientation.
*/
public int getOrientation() {
return this.orientation;
}
- /**
+ /**
* Set the orientation of the container.
- * @param orientation the New value of property orientation.
+ *
+ * @param orientation
+ * the New value of property orientation.
*/
public void setOrientation(int orientation) {
// Checks the validity of the argument
if (orientation < ORIENTATION_VERTICAL
- || orientation > ORIENTATION_HORIZONTAL)
+ || orientation > ORIENTATION_HORIZONTAL)
throw new IllegalArgumentException();
this.orientation = orientation;
}
/* Documented in superclass */
- public void replaceComponent(
- Component oldComponent,
- Component newComponent) {
+ public void replaceComponent(Component oldComponent, Component newComponent) {
- // Gets the locations
+ // Gets the locations
int oldLocation = -1;
int newLocation = -1;
int location = 0;
diff --git a/src/com/itmill/toolkit/ui/Panel.java b/src/com/itmill/toolkit/ui/Panel.java
index d1afdcc5ab..6d0321f10b 100644
--- a/src/com/itmill/toolkit/ui/Panel.java
+++ b/src/com/itmill/toolkit/ui/Panel.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -36,112 +36,112 @@ import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.Scrollable;
import com.itmill.toolkit.terminal.Sizeable;
-/**
+/**
* Panel - a simple single component container.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class Panel
- extends AbstractComponentContainer
- implements
- Sizeable,
- Scrollable,
- ComponentContainer.ComponentAttachListener,
+public class Panel extends AbstractComponentContainer implements Sizeable,
+ Scrollable, ComponentContainer.ComponentAttachListener,
ComponentContainer.ComponentDetachListener {
- /**
- * Layout of the panel.
+ /**
+ * Layout of the panel.
*/
private Layout layout;
- /**
- * Width of the panel or -1 if unspecified.
+ /**
+ * Width of the panel or -1 if unspecified.
*/
private int width = -1;
- /**
- * Height of the panel or -1 if unspecified.
+ /**
+ * Height of the panel or -1 if unspecified.
*/
private int height = -1;
- /**
- * Width unit.
+ /**
+ * Width unit.
*/
private int widthUnit = Sizeable.UNITS_PIXELS;
- /**
- * Height unit.
+ /**
+ * Height unit.
*/
private int heightUnit = Sizeable.UNITS_PIXELS;
- /**
- * Scroll X position.
+ /**
+ * Scroll X position.
*/
private int scrollOffsetX = 0;
- /**
- * Scroll Y position.
+ /**
+ * Scroll Y position.
*/
private int scrollOffsetY = 0;
- /**
- * Scrolling mode.
+ /**
+ * Scrolling mode.
*/
private boolean scrollable = false;
- /**
- * Creates a new empty panel.
- * Ordered layout is used.
+ /**
+ * Creates a new empty panel. Ordered layout is used.
*/
public Panel() {
this(new OrderedLayout());
}
- /**
- * Creates a new empty panel with given layout.
- * Layout must be non-null.
- *
- * @param layout the layout used in the panel.
+ /**
+ * Creates a new empty panel with given layout. Layout must be non-null.
+ *
+ * @param layout
+ * the layout used in the panel.
*/
public Panel(Layout layout) {
setLayout(layout);
}
- /**
- * Creates a new empty panel with caption.
- * Ordered layout is used.
- *
- * @param caption the caption used in the panel.
+ /**
+ * Creates a new empty panel with caption. Ordered layout is used.
+ *
+ * @param caption
+ * the caption used in the panel.
*/
public Panel(String caption) {
this(caption, new OrderedLayout());
}
- /**
+ /**
* Creates a new empty panel with caption.
- *
- * @param caption the caption of the panel.
- * @param layout the layout used in the panel.
+ *
+ * @param caption
+ * the caption of the panel.
+ * @param layout
+ * the layout used in the panel.
*/
public Panel(String caption, Layout layout) {
this(layout);
setCaption(caption);
}
- /**
+ /**
* Gets the current layout of the panel.
+ *
* @return the Current layout of the panel.
*/
public Layout getLayout() {
return this.layout;
}
- /**
- * Sets the layout of the panel.
- * All the components are moved to new layout.
- *
- * @param layout the New layout of the panel.
+ /**
+ * Sets the layout of the panel. All the components are moved to new layout.
+ *
+ * @param layout
+ * the New layout of the panel.
*/
public void setLayout(Layout layout) {
@@ -160,25 +160,30 @@ public class Panel
removeDirectDependency(this.layout);
this.layout.setParent(null);
}
-
+
// Removes the event listeners from the old layout
if (this.layout != null) {
- this.layout.removeListener((ComponentContainer.ComponentAttachListener) this);
- this.layout.removeListener((ComponentContainer.ComponentDetachListener) this);
+ this.layout
+ .removeListener((ComponentContainer.ComponentAttachListener) this);
+ this.layout
+ .removeListener((ComponentContainer.ComponentDetachListener) this);
}
// Sets the new layout
this.layout = layout;
// Adds the event listeners for new layout
- layout.addListener((ComponentContainer.ComponentAttachListener) this);
- layout.addListener((ComponentContainer.ComponentDetachListener) this);
+ layout.addListener((ComponentContainer.ComponentAttachListener) this);
+ layout.addListener((ComponentContainer.ComponentDetachListener) this);
}
- /**
+ /**
* Paints the content of this component.
- * @param target the Paint Event.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
layout.paint(target);
@@ -190,38 +195,45 @@ public class Panel
}
}
- /**
+ /**
* Gets the component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "panel";
}
- /**
+ /**
* Adds the component into this container.
- * @param c the component to be added.
+ *
+ * @param c
+ * the component to be added.
* @see com.itmill.toolkit.ui.AbstractComponentContainer#addComponent(com.itmill.toolkit.ui.Component)
*/
public void addComponent(Component c) {
layout.addComponent(c);
- // No repaint request is made as we except the underlaying container to
+ // No repaint request is made as we except the underlaying container to
// request repaints
}
/**
* Removes the component from this container.
- * @param c The component to be added.
+ *
+ * @param c
+ * The component to be added.
* @see com.itmill.toolkit.ui.AbstractComponentContainer#removeComponent(com.itmill.toolkit.ui.Component)
*/
public void removeComponent(Component c) {
layout.removeComponent(c);
- // No repaint request is made as we except the underlaying container to
+ // No repaint request is made as we except the underlaying container to
// request repaints
}
- /**
- * Gets the component container iterator for going trough all the components in the container.
+ /**
+ * Gets the component container iterator for going trough all the components
+ * in the container.
+ *
* @return the Iterator of the components inside the container.
* @see com.itmill.toolkit.ui.ComponentContainer#getComponentIterator()
*/
@@ -231,7 +243,8 @@ public class Panel
/**
* Gets the height in pixels.
- * @return The height in pixels or negative value if not assigned.
+ *
+ * @return The height in pixels or negative value if not assigned.
* @see com.itmill.toolkit.terminal.Sizeable#getHeight()
*/
public int getHeight() {
@@ -240,7 +253,8 @@ public class Panel
/**
* Gets the Width in pixel.
- * @return The width in pixels or negative value if not assigned.
+ *
+ * @return The width in pixels or negative value if not assigned.
* @see com.itmill.toolkit.terminal.Sizeable#getWidth()
*/
public int getWidth() {
@@ -248,9 +262,11 @@ public class Panel
}
/**
- * Sets the height in pixels.
- * Use negative value to let the client decide the height.
- * @param height the height to set.
+ * Sets the height in pixels. Use negative value to let the client decide
+ * the height.
+ *
+ * @param height
+ * the height to set.
* @see com.itmill.toolkit.terminal.Sizeable#setHeight(int)
*/
public void setHeight(int height) {
@@ -259,9 +275,11 @@ public class Panel
}
/**
- * Sets the width in pixels.
- * Use negative value to allow the client decide the width.
- * @param width the width to set.
+ * Sets the width in pixels. Use negative value to allow the client decide
+ * the width.
+ *
+ * @param width
+ * the width to set.
* @see com.itmill.toolkit.terminal.Sizeable#setWidth(int)
*/
public void setWidth(int width) {
@@ -270,14 +288,16 @@ public class Panel
}
/**
- * Called when one or more variables handled by the implementing class
- * are changed.
- * @see com.itmill.toolkit.terminal.VariableOwner#changeVariables(Object, Map)
+ * Called when one or more variables handled by the implementing class are
+ * changed.
+ *
+ * @see com.itmill.toolkit.terminal.VariableOwner#changeVariables(Object,
+ * Map)
*/
public void changeVariables(Object source, Map variables) {
super.changeVariables(source, variables);
- // Get new size
+ // Get new size
Integer newWidth = (Integer) variables.get("width");
Integer newHeight = (Integer) variables.get("height");
if (newWidth != null && newWidth.intValue() != getWidth())
@@ -296,6 +316,7 @@ public class Panel
/**
* Gets the height property units.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
*/
public int getHeightUnits() {
@@ -303,25 +324,28 @@ public class Panel
}
/**
- * Gets the width property units.
+ * Gets the width property units.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
*/
public int getWidthUnits() {
return widthUnit;
}
- /**
- * Sets the height units.
- * Panel supports only Sizeable.UNITS_PIXELS and this is ignored.
+ /**
+ * Sets the height units. Panel supports only Sizeable.UNITS_PIXELS and this
+ * is ignored.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
*/
public void setHeightUnits(int units) {
// Ignored
}
- /**
- * Sets the width units.
- * Panel supports only Sizeable.UNITS_PIXELS, and this is ignored.
+ /**
+ * Sets the width units. Panel supports only Sizeable.UNITS_PIXELS, and this
+ * is ignored.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int)
*/
public void setWidthUnits(int units) {
@@ -356,7 +380,8 @@ public class Panel
/* Documented in interface */
public void setScrollOffsetX(int pixelsScrolledLeft) {
if (pixelsScrolledLeft < 0)
- throw new IllegalArgumentException("Scroll offset must be at least 0");
+ throw new IllegalArgumentException(
+ "Scroll offset must be at least 0");
if (this.scrollOffsetX != pixelsScrolledLeft) {
scrollOffsetX = pixelsScrolledLeft;
requestRepaint();
@@ -366,7 +391,8 @@ public class Panel
/* Documented in interface */
public void setScrollOffsetY(int pixelsScrolledDown) {
if (pixelsScrolledDown < 0)
- throw new IllegalArgumentException("Scroll offset must be at least 0");
+ throw new IllegalArgumentException(
+ "Scroll offset must be at least 0");
if (this.scrollOffsetY != pixelsScrolledDown) {
scrollOffsetY = pixelsScrolledDown;
requestRepaint();
@@ -374,15 +400,14 @@ public class Panel
}
/* Documented in superclass */
- public void replaceComponent(
- Component oldComponent,
- Component newComponent) {
+ public void replaceComponent(Component oldComponent, Component newComponent) {
layout.replaceComponent(oldComponent, newComponent);
}
- /**
+ /**
* A new component is attached to container.
+ *
* @see com.itmill.toolkit.ui.ComponentContainer.ComponentAttachListener#componentAttachedToContainer(com.itmill.toolkit.ui.ComponentContainer.ComponentAttachEvent)
*/
public void componentAttachedToContainer(ComponentAttachEvent event) {
@@ -390,8 +415,9 @@ public class Panel
fireComponentAttachEvent(event.getAttachedComponent());
}
- /**
+ /**
* A component has been detached from container.
+ *
* @see com.itmill.toolkit.ui.ComponentContainer.ComponentDetachListener#componentDetachedFromContainer(com.itmill.toolkit.ui.ComponentContainer.ComponentDetachEvent)
*/
public void componentDetachedFromContainer(ComponentDetachEvent event) {
@@ -401,22 +427,27 @@ public class Panel
/**
* Notifies the component that it is connected to an application.
+ *
* @see com.itmill.toolkit.ui.Component#attach()
*/
public void attach() {
- if (layout != null) layout.attach();
+ if (layout != null)
+ layout.attach();
}
/**
* Notifies the component that it is detached from the application.
+ *
* @see com.itmill.toolkit.ui.Component#detach()
*/
public void detach() {
- if (layout != null) layout.detach();
+ if (layout != null)
+ layout.detach();
}
-
+
/**
- * Removes all components from this container.
+ * Removes all components from this container.
+ *
* @see com.itmill.toolkit.ui.ComponentContainer#removeAllComponents()
*/
public void removeAllComponents() {
diff --git a/src/com/itmill/toolkit/ui/ProgressIndicator.java b/src/com/itmill/toolkit/ui/ProgressIndicator.java
index de0e54c94b..8f90d33ae2 100644
--- a/src/com/itmill/toolkit/ui/ProgressIndicator.java
+++ b/src/com/itmill/toolkit/ui/ProgressIndicator.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -33,78 +33,81 @@ import com.itmill.toolkit.data.util.ObjectProperty;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-/**
- * <code>ProgressIndicator</code> is component that shows user state of a process
- * (like long computing or file upload)
- *
- * <code>ProgressIndicator</code> has two mainmodes. One for indeterminate processes and
- * other (default) for processes which progress can be measured
- *
+/**
+ * <code>ProgressIndicator</code> is component that shows user state of a
+ * process (like long computing or file upload)
+ *
+ * <code>ProgressIndicator</code> has two mainmodes. One for indeterminate
+ * processes and other (default) for processes which progress can be measured
+ *
* May view an other property that indicates progress 0...1
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.1
*/
-public class ProgressIndicator
- extends AbstractField
- implements
- Property,
- Property.Viewer,
- Property.ValueChangeListener {
-
- /**
+public class ProgressIndicator extends AbstractField implements Property,
+ Property.Viewer, Property.ValueChangeListener {
+
+ /**
* Content mode, where the label contains only plain text. The getValue()
- * result is coded to XML when painting.
+ * result is coded to XML when painting.
*/
public static final int CONTENT_TEXT = 0;
- /**
+ /**
* Content mode, where the label contains preformatted text.
*/
public static final int CONTENT_PREFORMATTED = 1;
-
+
private boolean indeterminate = false;
private Property dataSource;
private int pollingInterval = 1000;
- /**
- * Creates an a new ProgressIndicator.
+ /**
+ * Creates an a new ProgressIndicator.
*/
public ProgressIndicator() {
setPropertyDataSource(new ObjectProperty(new Float(0), Float.class));
}
- /**
+ /**
* Creates a new instance of ProgressIndicator with given state.
- * @param value
+ *
+ * @param value
*/
public ProgressIndicator(Float value) {
setPropertyDataSource(new ObjectProperty(value, Float.class));
}
- /**
- * Creates a new instance of ProgressIndicator with stae read from given datasource.
+ /**
+ * Creates a new instance of ProgressIndicator with stae read from given
+ * datasource.
+ *
* @param contentSource
*/
public ProgressIndicator(Property contentSource) {
setPropertyDataSource(contentSource);
}
- /**
+ /**
* Gets the component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "progressindicator";
}
- /**
- * Sets the component to read-only.
- * Readonly is not used in ProgressIndicator.
- * @param readOnly True to enable read-only mode, False to disable it.
+ /**
+ * Sets the component to read-only. Readonly is not used in
+ * ProgressIndicator.
+ *
+ * @param readOnly
+ * True to enable read-only mode, False to disable it.
*/
public void setReadOnly(boolean readOnly) {
if (dataSource == null)
@@ -112,9 +115,10 @@ public class ProgressIndicator
dataSource.setReadOnly(readOnly);
}
- /**
- * Is the component read-only ?
- * Readonly is not used in ProgressIndicator - this returns allways false.
+ /**
+ * Is the component read-only ? Readonly is not used in ProgressIndicator -
+ * this returns allways false.
+ *
* @return True if the component is in read only mode.
*/
public boolean isReadOnly() {
@@ -123,10 +127,13 @@ public class ProgressIndicator
return dataSource.isReadOnly();
}
- /**
+ /**
* Paints the content of this component.
- * @param target the Paint Event.
- * @throws PaintException if the Paint Operation fails.
+ *
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the Paint Operation fails.
*/
public void paintContent(PaintTarget target) throws PaintException {
target.addAttribute("indeterminate", indeterminate);
@@ -134,9 +141,10 @@ public class ProgressIndicator
target.addAttribute("state", this.getValue().toString());
}
- /**
- * Gets the value of the ProgressIndicator.
- * Value of the ProgressIndicator is Float between 0 and 1.
+ /**
+ * Gets the value of the ProgressIndicator. Value of the ProgressIndicator
+ * is Float between 0 and 1.
+ *
* @return the Value of the ProgressIndicator.
* @see com.itmill.toolkit.ui.AbstractField#getValue()
*/
@@ -147,9 +155,11 @@ public class ProgressIndicator
}
/**
- * Sets the value of the ProgressIndicator.
- * Value of the ProgressIndicator is the Float between 0 and 1.
- * @param newValue the New value of the ProgressIndicator.
+ * Sets the value of the ProgressIndicator. Value of the ProgressIndicator
+ * is the Float between 0 and 1.
+ *
+ * @param newValue
+ * the New value of the ProgressIndicator.
* @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object)
*/
public void setValue(Object newValue) {
@@ -157,7 +167,7 @@ public class ProgressIndicator
throw new IllegalStateException("Datasource must be se");
this.dataSource.setValue(newValue);
}
-
+
/**
* @see com.itmill.toolkit.ui.AbstractField#toString()
*/
@@ -166,7 +176,7 @@ public class ProgressIndicator
throw new IllegalStateException("Datasource must be se");
return dataSource.toString();
}
-
+
/**
* @see com.itmill.toolkit.ui.AbstractField#getType()
*/
@@ -178,7 +188,8 @@ public class ProgressIndicator
/**
* Gets the viewing data-source property.
- * @return the datasource.
+ *
+ * @return the datasource.
* @see com.itmill.toolkit.ui.AbstractField#getPropertyDataSource()
*/
public Property getPropertyDataSource() {
@@ -187,27 +198,29 @@ public class ProgressIndicator
/**
* Sets the property as data-source for viewing.
- * @param newDataSource the new data source.
+ *
+ * @param newDataSource
+ * the new data source.
* @see com.itmill.toolkit.ui.AbstractField#setPropertyDataSource(com.itmill.toolkit.data.Property)
*/
public void setPropertyDataSource(Property newDataSource) {
// Stops listening the old data source changes
if (dataSource != null
- && Property.ValueChangeNotifier.class.isAssignableFrom(
- dataSource.getClass()))
- ((Property.ValueChangeNotifier) dataSource).removeListener(this);
+ && Property.ValueChangeNotifier.class
+ .isAssignableFrom(dataSource.getClass()))
+ ((Property.ValueChangeNotifier) dataSource).removeListener(this);
// Sets the new data source
dataSource = newDataSource;
// Listens the new data source if possible
if (dataSource != null
- && Property.ValueChangeNotifier.class.isAssignableFrom(
- dataSource.getClass()))
- ((Property.ValueChangeNotifier) dataSource).addListener(this);
+ && Property.ValueChangeNotifier.class
+ .isAssignableFrom(dataSource.getClass()))
+ ((Property.ValueChangeNotifier) dataSource).addListener(this);
}
- /**
+ /**
* Gets the mode of ProgressIndicator.
*
* @return true if in indeterminate mode.
@@ -215,26 +228,30 @@ public class ProgressIndicator
public boolean getContentMode() {
return indeterminate;
}
-
+
/**
* Sets the ProgressIndicator to indeterminate mode.
*
- * @param newValue true to set to indeterminate mode.
+ * @param newValue
+ * true to set to indeterminate mode.
*/
public void setIndeterminate(boolean newValue) {
indeterminate = newValue;
}
-
+
/**
* Sets the interval that component checks for progress.
- * @param newValue the interval in milliseconds.
+ *
+ * @param newValue
+ * the interval in milliseconds.
*/
public void setPollingInterval(int newValue) {
pollingInterval = newValue;
}
-
+
/**
* Gets the interval that component checks for progress.
+ *
* @return the interval in milliseconds.
*/
public int getPollingInterval() {
diff --git a/src/com/itmill/toolkit/ui/Select.java b/src/com/itmill/toolkit/ui/Select.java
index 7f0e14f17b..2070153d5b 100644
--- a/src/com/itmill/toolkit/ui/Select.java
+++ b/src/com/itmill/toolkit/ui/Select.java
@@ -124,58 +124,58 @@ public class Select extends AbstractField implements Container,
*/
public static final int ITEM_CAPTION_MODE_PROPERTY = 6;
- /**
- * Is the select in multiselect mode?
+ /**
+ * Is the select in multiselect mode?
*/
private boolean multiSelect = false;
- /**
- * Select options.
+ /**
+ * Select options.
*/
protected Container items;
- /**
- * Is the user allowed to add new options?
+ /**
+ * Is the user allowed to add new options?
*/
private boolean allowNewOptions;
- /**
- * Keymapper used to map key values.
+ /**
+ * Keymapper used to map key values.
*/
protected KeyMapper itemIdMapper = new KeyMapper();
- /**
- * Item icons.
+ /**
+ * Item icons.
*/
private HashMap itemIcons = new HashMap();
- /**
- * Item captions.
+ /**
+ * Item captions.
*/
private HashMap itemCaptions = new HashMap();
- /**
- * Item caption mode.
+ /**
+ * Item caption mode.
*/
private int itemCaptionMode = ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID;
- /**
- * Item caption source property id.
+ /**
+ * Item caption source property id.
*/
private Object itemCaptionPropertyId = null;
- /**
- * Item icon source property id.
+ /**
+ * Item icon source property id.
*/
private Object itemIconPropertyId = null;
- /**
- * List of property set change event listeners.
+ /**
+ * List of property set change event listeners.
*/
private LinkedList propertySetEventListeners = null;
- /**
- * List of item set change event listeners.
+ /**
+ * List of item set change event listeners.
*/
private LinkedList itemSetEventListeners = null;
@@ -190,12 +190,12 @@ public class Select extends AbstractField implements Container,
*/
private Object nullSelectionItemId = null;
- /**
+ /**
* Mechanism for streaming select options outside of the UIDL.
*
- * By default streaming is not enabled and this is null. Streaming can
- * be enabled with setOptionsLoadingLazy(true).
- *
+ * By default streaming is not enabled and this is null. Streaming can be
+ * enabled with setOptionsLoadingLazy(true).
+ *
*/
private OptionsStream optionsStream = null;
@@ -218,6 +218,7 @@ public class Select extends AbstractField implements Container,
/**
* Creates a new select wthat is connected to a data-source.
+ *
* @param caption
* the Caption of the component.
* @param dataSource
@@ -276,10 +277,11 @@ public class Select extends AbstractField implements Container,
else
selectedKeys = new String[(getValue() == null
&& getNullSelectionItemId() == null ? 0 : 1)];
-
+
// Paints the options and create array of selected id keys
target.startTag("options");
- // TODO Also use conventional rendering if lazy loading is not supported by terminal
+ // TODO Also use conventional rendering if lazy loading is not supported
+ // by terminal
if (!isLazyLoading()) {
int keyIndex = 0;
@@ -334,13 +336,17 @@ public class Select extends AbstractField implements Container,
} else {
// Lazy options loading
- if(getApplication() != null) {
- target.addAttribute("loadfrom", getApplication().getURL().toString()
+ if (getApplication() != null) {
+ target.addAttribute("loadfrom", getApplication().getURL()
+ .toString()
+ optionsStream.uri);
- target.addAttribute("total", (getItemIds() != null) ? getItemIds()
- .size() : 0);
- target.addAttribute("initial", optionsStream.getJSON(20,0,""));
- target.addAttribute("selectedValue", toString() == null ? "" : toString());
+ target.addAttribute("total",
+ (getItemIds() != null) ? getItemIds().size() : 0);
+ target
+ .addAttribute("initial", optionsStream.getJSON(20, 0,
+ ""));
+ target.addAttribute("selectedValue", toString() == null ? ""
+ : toString());
}
}
target.endTag("options");
@@ -353,7 +359,9 @@ public class Select extends AbstractField implements Container,
/**
* Invoked when the value of a variable has changed.
- * @see com.itmill.toolkit.ui.AbstractComponent#changeVariables(java.lang.Object, java.util.Map)
+ *
+ * @see com.itmill.toolkit.ui.AbstractComponent#changeVariables(java.lang.Object,
+ * java.util.Map)
*/
public void changeVariables(Object source, Map variables) {
@@ -461,10 +469,10 @@ public class Select extends AbstractField implements Container,
/* Property methods ***************************************************** */
/**
- * Returns the type of the property. <code>getValue</code> and <code>setValue</code> methods must be
- * compatible with this type: one can safely cast <code>getValue</code> to given type
- * and pass any variable assignable to this type as a parameter to
- * <code>setValue</code>.
+ * Returns the type of the property. <code>getValue</code> and
+ * <code>setValue</code> methods must be compatible with this type: one
+ * can safely cast <code>getValue</code> to given type and pass any
+ * variable assignable to this type as a parameter to <code>setValue</code>.
*
* @return the Type of the property.
*/
@@ -474,9 +482,10 @@ public class Select extends AbstractField implements Container,
else
return Object.class;
}
-
+
/**
* Gets the selected item id or in multiselect mode a set of selected ids.
+ *
* @see com.itmill.toolkit.ui.AbstractField#getValue()
*/
public Object getValue() {
@@ -532,7 +541,9 @@ public class Select extends AbstractField implements Container,
/**
* Gets the item from the container with given id. If the container does not
* contain the requested item, null is returned.
- * @param itemId the item id.
+ *
+ * @param itemId
+ * the item id.
* @return the item from the container.
*/
public Item getItem(Object itemId) {
@@ -572,6 +583,7 @@ public class Select extends AbstractField implements Container,
* Gets the number of items in the container.
*
* @return the Number of items in the container.
+ *
* @see com.itmill.toolkit.data.Container#size()
*/
public int size() {
@@ -593,7 +605,8 @@ public class Select extends AbstractField implements Container,
/**
* Gets the Property identified by the given itemId and propertyId from the
- * Container
+ * Container
+ *
* @see com.itmill.toolkit.data.Container#getContainerProperty(Object,
* Object)
*/
@@ -601,17 +614,18 @@ public class Select extends AbstractField implements Container,
return items.getContainerProperty(itemId, propertyId);
}
- /* Container.Managed methods ******************************************** */
+ /* Container.Managed methods ******************************************** */
/**
- * Adds the new property to all items. Adds a property with given id, type and
- * default value to all items in the container.
+ * Adds the new property to all items. Adds a property with given id, type
+ * and default value to all items in the container.
*
* This functionality is optional. If the function is unsupported, it always
* returns false.
*
* @return True if the operation succeeded.
- * @see com.itmill.toolkit.data.Container#addContainerProperty(java.lang.Object, java.lang.Class, java.lang.Object)
+ * @see com.itmill.toolkit.data.Container#addContainerProperty(java.lang.Object,
+ * java.lang.Class, java.lang.Object)
*/
public boolean addContainerProperty(Object propertyId, Class type,
Object defaultValue) throws UnsupportedOperationException {
@@ -646,8 +660,8 @@ public class Select extends AbstractField implements Container,
}
/**
- * Creates a new item into container with container managed id. The id of the
- * created new item is returned. The item can be fetched with getItem()
+ * Creates a new item into container with container managed id. The id of
+ * the created new item is returned. The item can be fetched with getItem()
* method. if the creation fails, null is returned.
*
* @return the Id of the created item or null in case of failure.
@@ -686,8 +700,8 @@ public class Select extends AbstractField implements Container,
}
/**
- * Removes the item identified by Id from the container. This functionality is
- * optional. If the function is not implemented, the functions allways
+ * Removes the item identified by Id from the container. This functionality
+ * is optional. If the function is not implemented, the functions allways
* returns false.
*
* @return True if the operation succeeded.
@@ -705,8 +719,8 @@ public class Select extends AbstractField implements Container,
}
/**
- * Removes the property from all items. Removes a property with given id from all
- * the items in the container.
+ * Removes the property from all items. Removes a property with given id
+ * from all the items in the container.
*
* This functionality is optional. If the function is unsupported, it always
* returns false.
@@ -725,9 +739,11 @@ public class Select extends AbstractField implements Container,
/* Container.Viewer methods ********************************************* */
- /**
- * Sets the container as data-source for viewing.
- * @param newDataSource the new data source.
+ /**
+ * Sets the container as data-source for viewing.
+ *
+ * @param newDataSource
+ * the new data source.
*/
public void setContainerDataSource(Container newDataSource) {
if (newDataSource == null)
@@ -778,7 +794,8 @@ public class Select extends AbstractField implements Container,
}
/**
- * Gets the viewing data-source container.
+ * Gets the viewing data-source container.
+ *
* @see com.itmill.toolkit.data.Container.Viewer#getContainerDataSource()
*/
public Container getContainerDataSource() {
@@ -989,8 +1006,8 @@ public class Select extends AbstractField implements Container,
* The mode can be one of the following ones:
* <ul>
* <li><code>ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID</code> : Items
- * Id-objects <code>toString</code> is used as item caption. If caption
- * is explicitly specified, it overrides the id-caption.
+ * Id-objects <code>toString</code> is used as item caption. If caption is
+ * explicitly specified, it overrides the id-caption.
* <li><code>ITEM_CAPTION_MODE_ID</code> : Items Id-objects
* <code>toString</code> is used as item caption.</li>
* <li><code>ITEM_CAPTION_MODE_ITEM</code> : Item-objects
@@ -1025,8 +1042,8 @@ public class Select extends AbstractField implements Container,
* The mode can be one of the following ones:
* <ul>
* <li><code>ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID</code> : Items
- * Id-objects <code>toString</code> is used as item caption. If caption
- * is explicitly specified, it overrides the id-caption.
+ * Id-objects <code>toString</code> is used as item caption. If caption is
+ * explicitly specified, it overrides the id-caption.
* <li><code>ITEM_CAPTION_MODE_ID</code> : Items Id-objects
* <code>toString</code> is used as item caption.</li>
* <li><code>ITEM_CAPTION_MODE_ITEM</code> : Item-objects
@@ -1065,7 +1082,9 @@ public class Select extends AbstractField implements Container,
* Setting the property id to null disables this feature. The id is null by
* default
* </p>.
- * @param propertyId the id of the property.
+ *
+ * @param propertyId
+ * the id of the property.
*
*/
public void setItemCaptionPropertyId(Object propertyId) {
@@ -1154,6 +1173,7 @@ public class Select extends AbstractField implements Container,
* {@link #getNullSelectionItemId()} returns true if the value of the
* property is null.
* </p>
+ *
* @param itemId
* the Id the of the item to be tested.
* @see #getNullSelectionItemId()
@@ -1179,6 +1199,7 @@ public class Select extends AbstractField implements Container,
* In single select mode selecting item identified by
* {@link #getNullSelectionItemId()} sets the value of the property to null.
* </p>
+ *
* @param itemId
* the tem to be selected.
* @see #getNullSelectionItemId()
@@ -1200,6 +1221,7 @@ public class Select extends AbstractField implements Container,
/**
* Unselects an item.
+ *
* @param itemId
* the Item to be unselected.
* @see #getNullSelectionItemId()
@@ -1219,6 +1241,7 @@ public class Select extends AbstractField implements Container,
/**
* Notifies this listener that the Containers contents has changed.
+ *
* @see com.itmill.toolkit.data.Container.PropertySetChangeListener#containerPropertySetChange(com.itmill.toolkit.data.Container.PropertySetChangeEvent)
*/
public void containerPropertySetChange(
@@ -1228,6 +1251,7 @@ public class Select extends AbstractField implements Container,
/**
* Adds a new Property set change listener for this Container.
+ *
* @see com.itmill.toolkit.data.Container.PropertySetChangeNotifier#addListener(com.itmill.toolkit.data.Container.PropertySetChangeListener)
*/
public void addListener(Container.PropertySetChangeListener listener) {
@@ -1238,6 +1262,7 @@ public class Select extends AbstractField implements Container,
/**
* Removes a previously registered Property set change listener.
+ *
* @see com.itmill.toolkit.data.Container.PropertySetChangeNotifier#removeListener(com.itmill.toolkit.data.Container.PropertySetChangeListener)
*/
public void removeListener(Container.PropertySetChangeListener listener) {
@@ -1250,6 +1275,7 @@ public class Select extends AbstractField implements Container,
/**
* Adds an Item set change listener for the object.
+ *
* @see com.itmill.toolkit.data.Container.ItemSetChangeNotifier#addListener(com.itmill.toolkit.data.Container.ItemSetChangeListener)
*/
public void addListener(Container.ItemSetChangeListener listener) {
@@ -1260,6 +1286,7 @@ public class Select extends AbstractField implements Container,
/**
* Removes the Item set change listener from the object.
+ *
* @see com.itmill.toolkit.data.Container.ItemSetChangeNotifier#removeListener(com.itmill.toolkit.data.Container.ItemSetChangeListener)
*/
public void removeListener(Container.ItemSetChangeListener listener) {
@@ -1272,6 +1299,7 @@ public class Select extends AbstractField implements Container,
/**
* Lets the listener know a Containers Item set has changed.
+ *
* @see com.itmill.toolkit.data.Container.ItemSetChangeListener#containerItemSetChange(com.itmill.toolkit.data.Container.ItemSetChangeEvent)
*/
public void containerItemSetChange(Container.ItemSetChangeEvent event) {
@@ -1282,7 +1310,7 @@ public class Select extends AbstractField implements Container,
fireItemSetChange();
}
- /**
+ /**
* Fires the property set change event.
*/
protected void firePropertySetChange() {
@@ -1297,8 +1325,8 @@ public class Select extends AbstractField implements Container,
requestRepaint();
}
- /**
- * Fires the item set change event.
+ /**
+ * Fires the item set change event.
*/
protected void fireItemSetChange() {
if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) {
@@ -1311,13 +1339,14 @@ public class Select extends AbstractField implements Container,
requestRepaint();
}
- /**
- * Implementation of item set change event.
+ /**
+ * Implementation of item set change event.
*/
private class ItemSetChangeEvent implements Container.ItemSetChangeEvent {
/**
* Gets the Property where the event occurred.
+ *
* @see com.itmill.toolkit.data.Container.ItemSetChangeEvent#getContainer()
*/
public Container getContainer() {
@@ -1326,14 +1355,15 @@ public class Select extends AbstractField implements Container,
}
- /**
- * Implementation of property set change event.
+ /**
+ * Implementation of property set change event.
*/
private class PropertySetChangeEvent implements
Container.PropertySetChangeEvent {
/**
* Retrieves the Container whose contents have been modified.
+ *
* @see com.itmill.toolkit.data.Container.PropertySetChangeEvent#getContainer()
*/
public Container getContainer() {
@@ -1405,16 +1435,18 @@ public class Select extends AbstractField implements Container,
/**
* Notifies the component that it is connected to an application.
+ *
* @see com.itmill.toolkit.ui.AbstractField#attach()
*/
public void attach() {
super.attach();
- if (optionsStream != null)
+ if (optionsStream != null)
getWindow().addURIHandler(optionsStream);
}
/**
* Detaches the component from application.
+ *
* @see com.itmill.toolkit.ui.AbstractComponent#detach()
*/
public void detach() {
@@ -1422,18 +1454,18 @@ public class Select extends AbstractField implements Container,
getWindow().removeURIHandler(optionsStream);
super.detach();
}
-
+
public void setOptionFilter(OptionFilter of) {
- if(this.optionsStream != null) {
+ if (this.optionsStream != null) {
this.optionsStream.setOptionFilter(of);
}
}
-
+
/**
* @return
*/
public OptionFilter getOptionFilter() {
- if(this.optionsStream != null) {
+ if (this.optionsStream != null) {
return this.optionsStream.getOptionFilter();
}
return null;
@@ -1444,7 +1476,7 @@ public class Select extends AbstractField implements Container,
private String currentFilter = "";
private ArrayList filteredItemsBuffer = null;
-
+
private OptionFilter of = null;
private String uri = "selectOptionsStream"
@@ -1453,7 +1485,7 @@ public class Select extends AbstractField implements Container,
OptionsStream(Select s) {
of = new StartsWithFilter(s);
}
-
+
public OptionFilter getOptionFilter() {
return of;
}
@@ -1464,7 +1496,9 @@ public class Select extends AbstractField implements Container,
/**
* Handles the given relative URI.
- * @see com.itmill.toolkit.terminal.URIHandler#handleURI(java.net.URL, java.lang.String)
+ *
+ * @see com.itmill.toolkit.terminal.URIHandler#handleURI(java.net.URL,
+ * java.lang.String)
*/
public DownloadStream handleURI(URL context, String relativeUri) {
@@ -1482,7 +1516,7 @@ public class Select extends AbstractField implements Container,
// ignore
}
// TODO Req size
- ds = createDownloadStream(13,i,"");
+ ds = createDownloadStream(13, i, "");
return ds;
} else if (relativeUri.indexOf(uri) != -1) {
@@ -1492,7 +1526,7 @@ public class Select extends AbstractField implements Container,
String prefix = relativeUri.substring(relativeUri
.lastIndexOf("/") + 1);
// TODO Req size
- ds = createDownloadStream(13,0,prefix.trim());
+ ds = createDownloadStream(13, 0, prefix.trim());
return ds;
}
}
@@ -1508,14 +1542,15 @@ public class Select extends AbstractField implements Container,
* @param filter
* @return the new DownloadStream.
*/
- public DownloadStream createDownloadStream(int size, int first, String filter) {
+ public DownloadStream createDownloadStream(int size, int first,
+ String filter) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os, Charset
.forName("utf-8"));
// JSONObject json = createJSONObject(visibleitems);
- String json = getJSON( size, first, filter);
+ String json = getJSON(size, first, filter);
try {
osw.write(json);
osw.flush();
@@ -1544,20 +1579,21 @@ public class Select extends AbstractField implements Container,
json.append((i > 0 ? "," : "") + '"' + values.get(i).toString()
+ '"');
}
-
+
private String getJSON(int size, int first, String filter) {
// Refilter options, if needed
if (!currentFilter.equals(filter) || filteredItemsBuffer == null) {
filteredItemsBuffer = filterContent(filter);
currentFilter = filter;
- }
+ }
// Creates list of shown options
ArrayList keys = new ArrayList();
ArrayList values = new ArrayList();
- for (int i=first; i<first+size && i<filteredItemsBuffer.size(); i++) {
+ for (int i = first; i < first + size
+ && i < filteredItemsBuffer.size(); i++) {
Object id = filteredItemsBuffer.get(i);
Item item = getItem(id);
keys.add(Select.this.itemIdMapper.key(id));
diff --git a/src/com/itmill/toolkit/ui/TabSheet.java b/src/com/itmill/toolkit/ui/TabSheet.java
index bcfb359f43..c1edd1b65c 100644
--- a/src/com/itmill/toolkit/ui/TabSheet.java
+++ b/src/com/itmill/toolkit/ui/TabSheet.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -36,61 +36,66 @@ import java.util.Map;
import com.itmill.toolkit.terminal.*;
-/**
- * Tabsheet component.
- *
+/**
+ * Tabsheet component.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class TabSheet extends AbstractComponentContainer {
- /**
- * Linked list of component tabs.
+ /**
+ * Linked list of component tabs.
*/
private LinkedList tabs = new LinkedList();
- /**
- * Tab -> caption mapping.
+ /**
+ * Tab -> caption mapping.
*/
private Hashtable tabCaptions = new Hashtable();
- /**
+ /**
* Tab -> icon mapping .
*/
private Hashtable tabIcons = new Hashtable();
- /**
- * Selected tab.
+ /**
+ * Selected tab.
*/
private Component selected = null;
+
private KeyMapper keyMapper = new KeyMapper();
- /**
- * Holds the value of property tabsHIdden.
+ /**
+ * Holds the value of property tabsHIdden.
*/
private boolean tabsHidden;
- /**
- * Constructs a new Tabsheet.
- * Tabsheet is immediate by default.
+ /**
+ * Constructs a new Tabsheet. Tabsheet is immediate by default.
*/
public TabSheet() {
super();
setImmediate(true);
}
- /**
- * Gets the component container iterator for going trough all the components in the container.
+ /**
+ * Gets the component container iterator for going trough all the components
+ * in the container.
+ *
* @return the Iterator of the components inside the container.
*/
public Iterator getComponentIterator() {
return java.util.Collections.unmodifiableList(tabs).iterator();
}
- /**
+ /**
* Removes the component from this container.
- * @param c the component to be removed.
+ *
+ * @param c
+ * the component to be removed.
*/
public void removeComponent(Component c) {
if (c != null && tabs.contains(c)) {
@@ -110,21 +115,26 @@ public class TabSheet extends AbstractComponentContainer {
}
}
- /**
- * Adds the component into this container.
- * The component is added as a tab where its default tab-caption is
- * the caption of the component.
- * @param c the component to be added.
+ /**
+ * Adds the component into this container. The component is added as a tab
+ * where its default tab-caption is the caption of the component.
+ *
+ * @param c
+ * the component to be added.
*/
public void addComponent(Component c) {
addTab(c, c.getCaption(), getIcon());
}
- /**
+ /**
* Adds the new tab into TabSheet.
- * @param c the component to be added onto tab.
- * @param caption the caption of the tab.
- * @param icon the Set the icon of the tab.
+ *
+ * @param c
+ * the component to be added onto tab.
+ * @param caption
+ * the caption of the tab.
+ * @param icon
+ * the Set the icon of the tab.
*/
public void addTab(Component c, String caption, Resource icon) {
if (c != null) {
@@ -141,18 +151,21 @@ public class TabSheet extends AbstractComponentContainer {
}
}
- /**
+ /**
* Gets the component UIDL tag.
+ *
* @return the Component UIDL tag as string.
*/
public String getTag() {
return "tabsheet";
}
- /**
- * Moves all components from another container to this container.
- * The components are removed from the other container.
- * @param source the container components are removed from.
+ /**
+ * Moves all components from another container to this container. The
+ * components are removed from the other container.
+ *
+ * @param source
+ * the container components are removed from.
*/
public void moveComponentsFrom(ComponentContainer source) {
for (Iterator i = source.getComponentIterator(); i.hasNext();) {
@@ -169,10 +182,13 @@ public class TabSheet extends AbstractComponentContainer {
}
}
- /**
+ /**
* Paints the content of this component.
- * @param event the Paint Event.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param event
+ * the Paint Event.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
@@ -183,17 +199,17 @@ public class TabSheet extends AbstractComponentContainer {
for (Iterator i = getComponentIterator(); i.hasNext();) {
Component c = (Component) i.next();
- if (!c.isVisible())
- continue;
+ if (!c.isVisible())
+ continue;
target.startTag("tab");
Resource icon = getTabIcon(c);
if (icon != null)
target.addAttribute("icon", icon);
String caption = getTabCaption(c);
if (!c.isEnabled()) {
- target.addAttribute("disabled", true);
+ target.addAttribute("disabled", true);
}
-
+
if (caption != null && caption.length() > 0)
target.addAttribute("caption", caption);
target.addAttribute("key", keyMapper.key(c));
@@ -210,26 +226,31 @@ public class TabSheet extends AbstractComponentContainer {
target.addVariable(this, "selected", keyMapper.key(selected));
}
- /**
+ /**
* Are tabs hidden.
+ *
* @return the Property visibility.
*/
public boolean areTabsHidden() {
return this.tabsHidden;
}
- /**
+ /**
* Setter for property tabsHidden.
- * @param tabsHidden True if the tabs should be hidden.
+ *
+ * @param tabsHidden
+ * True if the tabs should be hidden.
*/
public void hideTabs(boolean tabsHidden) {
this.tabsHidden = tabsHidden;
requestRepaint();
}
- /**
+ /**
* Gets the caption for a component.
- * @param c the component.
+ *
+ * @param c
+ * the component.
*/
public String getTabCaption(Component c) {
String caption = (String) tabCaptions.get(c);
@@ -238,28 +259,34 @@ public class TabSheet extends AbstractComponentContainer {
return caption;
}
- /**
+ /**
* Sets the caption for a component.
- * @param c the component.
- * @param caption the caption to set.
+ *
+ * @param c
+ * the component.
+ * @param caption
+ * the caption to set.
*/
public void setTabCaption(Component c, String caption) {
tabCaptions.put(c, caption);
requestRepaint();
}
- /**
- * Gets the icon for a component.
- * @param c the component.
+ /**
+ * Gets the icon for a component.
+ *
+ * @param c
+ * the component.
*/
public Resource getTabIcon(Component c) {
return (Resource) tabIcons.get(c);
}
- /** ]
- * Sets the icon for a component.
+ /**
+ * ] Sets the icon for a component.
+ *
* @param c
- * @param icon
+ * @param icon
*/
public void setTabIcon(Component c, Resource icon) {
if (icon == null)
@@ -269,9 +296,10 @@ public class TabSheet extends AbstractComponentContainer {
requestRepaint();
}
- /**
- * Sets the selected tab.
- * @param c
+ /**
+ * Sets the selected tab.
+ *
+ * @param c
*/
public void setSelectedTab(Component c) {
if (c != null && tabs.contains(c) && !selected.equals(c)) {
@@ -281,9 +309,10 @@ public class TabSheet extends AbstractComponentContainer {
}
}
- /**
+ /**
* Gets the selected tab.
- * @return the selected tab.
+ *
+ * @return the selected tab.
*/
public Component getSelectedTab() {
return selected;
@@ -291,18 +320,18 @@ public class TabSheet extends AbstractComponentContainer {
/**
* Invoked when the value of a variable has changed.
- * @see com.itmill.toolkit.ui.AbstractComponent#changeVariables(java.lang.Object, java.util.Map)
+ *
+ * @see com.itmill.toolkit.ui.AbstractComponent#changeVariables(java.lang.Object,
+ * java.util.Map)
*/
public void changeVariables(Object source, Map variables) {
if (variables.containsKey("selected"))
- setSelectedTab(
- (Component) keyMapper.get((String) variables.get("selected")));
+ setSelectedTab((Component) keyMapper.get((String) variables
+ .get("selected")));
}
/* Documented in superclass */
- public void replaceComponent(
- Component oldComponent,
- Component newComponent) {
+ public void replaceComponent(Component oldComponent, Component newComponent) {
// Gets the captions
String oldCaption = getTabCaption(oldComponent);
@@ -310,7 +339,7 @@ public class TabSheet extends AbstractComponentContainer {
String newCaption = getTabCaption(newComponent);
Resource newIcon = getTabIcon(newComponent);
- // Gets the locations
+ // Gets the locations
int oldLocation = -1;
int newLocation = -1;
int location = 0;
@@ -361,41 +390,44 @@ public class TabSheet extends AbstractComponentContainer {
private static final Method SELECTED_TAB_CHANGE_METHOD;
static {
try {
- SELECTED_TAB_CHANGE_METHOD =
- SelectedTabChangeListener.class.getDeclaredMethod(
- "selectedTabChange",
- new Class[] { SelectedTabChangeEvent.class });
+ SELECTED_TAB_CHANGE_METHOD = SelectedTabChangeListener.class
+ .getDeclaredMethod("selectedTabChange",
+ new Class[] { SelectedTabChangeEvent.class });
} catch (java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
}
- /**
- * Selected Tab Change event. This event is thrown, when the selected tab
- * in the tab sheet is changed.
+ /**
+ * Selected Tab Change event. This event is thrown, when the selected tab in
+ * the tab sheet is changed.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class SelectedTabChangeEvent extends Component.Event {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3258129141914940469L;
-
- /**
- * New instance of selected tab change event
- * @param source the Source of the event.
- */
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3258129141914940469L;
+
+ /**
+ * New instance of selected tab change event
+ *
+ * @param source
+ * the Source of the event.
+ */
public SelectedTabChangeEvent(Component source) {
super(source);
}
- /**
+ /**
* Select where the event occurred
+ *
* @return the Source of the event.
*/
public Select getSelect() {
@@ -403,46 +435,50 @@ public class TabSheet extends AbstractComponentContainer {
}
}
- /**
+ /**
* Selected Tab Change Event listener
+ *
* @author IT Mill Ltd.
*
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface SelectedTabChangeListener {
/**
* Visible tab in tab sheet has has been changed.
- * @param event the Selected tab change event.
+ *
+ * @param event
+ * the Selected tab change event.
*/
public void selectedTabChange(SelectedTabChangeEvent event);
}
- /**
+ /**
* Adds the selected tab change listener
- * @param listener the Listener to be added.
+ *
+ * @param listener
+ * the Listener to be added.
*/
public void addListener(SelectedTabChangeListener listener) {
- addListener(
- SelectedTabChangeEvent.class,
- listener,
- SELECTED_TAB_CHANGE_METHOD);
+ addListener(SelectedTabChangeEvent.class, listener,
+ SELECTED_TAB_CHANGE_METHOD);
}
- /**
+ /**
* Removes the selected tab change listener
- * @param listener the Listener to be removed.
+ *
+ * @param listener
+ * the Listener to be removed.
*/
public void removeListener(SelectedTabChangeListener listener) {
- removeListener(
- SelectedTabChangeEvent.class,
- listener,
- SELECTED_TAB_CHANGE_METHOD);
+ removeListener(SelectedTabChangeEvent.class, listener,
+ SELECTED_TAB_CHANGE_METHOD);
}
- /**
- * Emits the options change event.
+ /**
+ * Emits the options change event.
*/
protected void fireSelectedTabChange() {
fireEvent(new SelectedTabChangeEvent(this));
diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java
index 9dbff353d8..ba40c43574 100644
--- a/src/com/itmill/toolkit/ui/Table.java
+++ b/src/com/itmill/toolkit/ui/Table.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -51,2231 +51,2278 @@ import com.itmill.toolkit.terminal.Resource;
import com.itmill.toolkit.terminal.Sizeable;
/**
- * <code>TableComponent</code> is used for representing data or components in pageable and
- * selectable table.
+ * <code>TableComponent</code> is used for representing data or components in
+ * pageable and selectable table.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Table extends Select implements Action.Container,
- Container.Ordered, Container.Sortable, Sizeable {
+ Container.Ordered, Container.Sortable, Sizeable {
private static final int CELL_KEY = 0;
- private static final int CELL_HEADER = 1;
+ private static final int CELL_HEADER = 1;
+
+ private static final int CELL_ICON = 2;
- private static final int CELL_ICON = 2;
+ private static final int CELL_ITEMID = 3;
- private static final int CELL_ITEMID = 3;
+ private static final int CELL_FIRSTCOL = 4;
- private static final int CELL_FIRSTCOL = 4;
-
- /**
- * Width of the table or -1 if unspecified.
+ /**
+ * Width of the table or -1 if unspecified.
*/
private int width = -1;
- /**
- * Height of the table or -1 if unspecified.
+ /**
+ * Height of the table or -1 if unspecified.
*/
private int height = -1;
- /**
- * Width unit.
+ /**
+ * Width unit.
*/
private int widthUnit = Sizeable.UNITS_PIXELS;
- /**
- * Height unit.
+ /**
+ * Height unit.
*/
private int heightUnit = Sizeable.UNITS_PIXELS;
- /**
- * Left column alignment. <b>This is the default behaviour. </b>
- */
- public static final String ALIGN_LEFT = "b";
-
- /**
- * Center column alignment.
- */
- public static final String ALIGN_CENTER = "c";
-
- /**
- * Right column alignment.
- */
- public static final String ALIGN_RIGHT = "e";
-
- /**
- * Column header mode: Column headers are hidden. <b>This is the default
- * behaviour. </b>
- */
- public static final int COLUMN_HEADER_MODE_HIDDEN = -1;
-
- /**
- * Column header mode: Property ID:s are used as column headers.
- */
- public static final int COLUMN_HEADER_MODE_ID = 0;
-
- /**
- * Column header mode: Column headers are explicitly specified with
- * <code>setColumnHeaders</code>.
- */
- public static final int COLUMN_HEADER_MODE_EXPLICIT = 1;
-
- /**
- * Column header mode: Column headers are explicitly specified with
- * <code>setColumnHeaders</code>
- */
- public static final int COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID = 2;
-
- /**
- * Row caption mode: The row headers are hidden. <b>This is the default
- * mode. </b>
- */
- public static final int ROW_HEADER_MODE_HIDDEN = -1;
-
- /**
- * Row caption mode: Items Id-objects toString is used as row caption.
- */
- public static final int ROW_HEADER_MODE_ID = Select.ITEM_CAPTION_MODE_ID;
-
- /**
- * Row caption mode: Item-objects toString is used as row caption.
- */
- public static final int ROW_HEADER_MODE_ITEM = Select.ITEM_CAPTION_MODE_ITEM;
-
- /**
- * Row caption mode: Index of the item is used as item caption.
- * The index mode can only be used with the containers implementing
- * Container.Indexed interface.
- */
- public static final int ROW_HEADER_MODE_INDEX = Select.ITEM_CAPTION_MODE_INDEX;
-
- /**
- * Row caption mode: Item captions are explicitly specified.
- */
- public static final int ROW_HEADER_MODE_EXPLICIT = Select.ITEM_CAPTION_MODE_EXPLICIT;
-
- /**
- * Row caption mode: Item captions are read from property specified with
- * <code>setItemCaptionPropertyId</code>.
- */
- public static final int ROW_HEADER_MODE_PROPERTY = Select.ITEM_CAPTION_MODE_PROPERTY;
-
- /**
- * Row caption mode: Only icons are shown, the captions are hidden.
- */
- public static final int ROW_HEADER_MODE_ICON_ONLY = Select.ITEM_CAPTION_MODE_ICON_ONLY;
-
- /**
- * Row caption mode: Item captions are explicitly specified, but if the
- * caption is missing, the item id objects <code>toString()</code> is used
- * instead.
- */
- public static final int ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID = Select.ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID;
-
- /* Private table extensions to Select *********************************** */
-
- /**
- * True if column collapsing is allowed.
- */
- private boolean columnCollapsingAllowed = false;
-
- /**
- * True if reordering of columns is allowed on the client side.
- */
- private boolean columnReorderingAllowed = false;
-
- /**
- * Keymapper for column ids.
- */
- private KeyMapper columnIdMap = new KeyMapper();
-
- /**
- * Holds visible column propertyIds - in order.
- */
- private LinkedList visibleColumns = new LinkedList();
-
- /**
- * Holds propertyIds of currently collapsed columns.
- */
- private HashSet collapsedColumns = new HashSet();
-
- /**
- * Holds headers for visible columns (by propertyId).
- */
- private HashMap columnHeaders = new HashMap();
-
- /**
- * Holds icons for visible columns (by propertyId).
- */
- private HashMap columnIcons = new HashMap();
-
- /**
- * Holds alignments for visible columns (by propertyId).
- */
- private HashMap columnAlignments = new HashMap();
-
- /**
- * Holds value of property pageLength. 0 disables paging.
- */
- private int pageLength = 15;
-
- /**
- * Id the first item on the current page.
- */
- private Object currentPageFirstItemId = null;
-
- /**
- * Index of the first item on the current page.
- */
- private int currentPageFirstItemIndex = 0;
-
- /**
- * Holds value of property pageBuffering.
- */
- private boolean pageBuffering = false;
-
- /**
- * Holds value of property selectable.
- */
- private boolean selectable = false;
-
- /**
- * Holds value of property columnHeaderMode.
- */
- private int columnHeaderMode = COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID;
-
- /**
- * True iff the row captions are hidden.
- */
- private boolean rowCaptionsAreHidden = true;
-
- /**
- * Page contents buffer used in buffered mode.
- */
- private Object[][] pageBuffer = null;
-
- /**
- * List of properties listened - the list is kept to release the listeners
- * later.
- */
- private LinkedList listenedProperties = null;
-
- /**
- * List of visible components - the is used for needsRepaint calculation.
- */
- private LinkedList visibleComponents = null;
-
- /**
- * List of action handlers.
- */
- private LinkedList actionHandlers = null;
-
- /**
- * Action mapper.
- */
- private KeyMapper actionMapper = null;
-
- /**
- * Table cell editor factory.
- */
- private FieldFactory fieldFactory = new BaseFieldFactory();
-
- /**
- * Is table editable.
- */
- private boolean editable = false;
-
- /**
- * Current sorting direction.
- */
- private boolean sortAscending = true;
-
- /**
- * Currently table is sorted on this propertyId.
- */
- private Object sortContainerPropertyId = null;
-
- /**
- * Is table sorting disabled alltogether; even if some of the properties would be
- * sortable.
- */
- private boolean sortDisabled = false;
-
- /**
- * Number of rows explicitly requested by the client to be painted on next paint.
- * This is -1 if no request by the client is made. Painting the component will automatically
- * reset this to -1.
- */
- private int reqRowsToPaint = -1;
-
- /**
- * Index of the first rows explicitly requested by the client to be painted.
- * This is -1 if no request by the client is made. Painting the component will automatically
- * reset this to -1.
- */
- private int reqFirstRowToPaint = -1;
-
- /* Table constructors *************************************************** */
-
- /**
- * Creates a new empty table.
- */
- public Table() {
- setRowHeaderMode(ROW_HEADER_MODE_HIDDEN);
- }
-
- /**
- * Creates a new empty table with caption.
- * @param caption
- */
- public Table(String caption) {
- this();
- setCaption(caption);
- }
-
- /**
- * Creates a new table with caption and connect it to a Container.
- * @param caption
- * @param dataSource
- */
- public Table(String caption, Container dataSource) {
- this();
- setCaption(caption);
- setContainerDataSource(dataSource);
- }
-
- /* Table functionality ************************************************** */
-
- /**
- * Gets the array of visible column property id:s.
- *
- * <p>
- * The columns are show in the order of their appearance in this array.
- * </p>
- *
- * @return the Value of property availableColumns.
- */
- public Object[] getVisibleColumns() {
- if (this.visibleColumns == null) {
- return null;
- }
- return this.visibleColumns.toArray();
- }
-
- /**
- * Sets the array of visible column property id:s.
- *
- * <p>
- * The columns are show in the order of their appearance in this array.
- * </p>
- *
- * @param visibleColumns
- * the Array of shown property id:s.
- */
- public void setVisibleColumns(Object[] visibleColumns) {
-
- // Visible columns must exist
- if (visibleColumns == null)
- throw new NullPointerException(
- "Can not set visible columns to null value");
-
- // Checks that the new visible columns contains no nulls and properties
- // exist
- Collection properties = getContainerPropertyIds();
- for (int i = 0; i < visibleColumns.length; i++) {
- if (visibleColumns[i] == null)
- throw new NullPointerException("Properties must be non-nulls");
- else if (!properties.contains(visibleColumns[i]))
- throw new IllegalArgumentException(
- "Properties must exist in the Container, missing property: "
- + visibleColumns[i]);
- }
-
- // If this is called befor the constructor is finished, it might be
- // uninitialized
- 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();
- if (!newVC.contains(col)) {
- setColumnHeader(col, null);
- setColumnAlignment(col, null);
- setColumnIcon(col, null);
- }
- }
-
- this.visibleColumns = newVC;
-
- // Assures visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Gets the headers of the columns.
- *
- * <p>
- * The headers match the property id:s given my the set visible column
- * headers. The table must be set in either
- * <code>ROW_HEADER_MODE_EXPLICIT</code> or
- * <code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code> mode to show the
- * headers. In the defaults mode any nulls in the headers array are replaced
- * with id.toString() outputs when rendering.
- * </p>
- *
- * @return the Array of column headers.
- */
- public String[] getColumnHeaders() {
- if (this.columnHeaders == null) {
- return null;
- }
- String[] headers = new String[this.visibleColumns.size()];
- int i = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); i++) {
- headers[i] = (String) this.columnHeaders.get(it.next());
- }
- return headers;
- }
-
- /**
- * Sets the headers of the columns.
- *
- * <p>
- * The headers match the property id:s given my the set visible column
- * headers. The table must be set in either
- * <code>ROW_HEADER_MODE_EXPLICIT</code> or
- * <code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code> mode to show the
- * headers. In the defaults mode any nulls in the headers array are replaced
- * with id.toString() outputs when rendering.
- * </p>
- *
- * @param columnHeaders
- * the Array of column headers that match the
- * <code>getVisibleColumns</code> method.
- */
- public void setColumnHeaders(String[] columnHeaders) {
-
- if (columnHeaders.length != this.visibleColumns.size())
- throw new IllegalArgumentException(
- "The length of the headers array must match the number of visible columns");
-
- this.columnHeaders.clear();
- int i = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
- && i < columnHeaders.length; i++) {
- this.columnHeaders.put(it.next(), columnHeaders[i]);
- }
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Gets the icons of the columns.
- *
- * <p>
- * The icons in headers match the property id:s given my the set visible
- * column headers. The table must be set in either
- * <code>ROW_HEADER_MODE_EXPLICIT</code> or
- * <code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code> mode to show the
- * headers with icons.
- * </p>
- *
- * @return the Array of icons that match the <code>getVisibleColumns</code>.
- */
- public Resource[] getColumnIcons() {
- if (this.columnIcons == null) {
- return null;
- }
- Resource[] icons = new Resource[this.visibleColumns.size()];
- int i = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); i++) {
- icons[i] = (Resource) this.columnIcons.get(it.next());
- }
-
- return icons;
- }
-
- /**
- * Sets the icons of the columns.
- *
- * <p>
- * The icons in headers match the property id:s given my the set visible
- * column headers. The table must be set in either
- * <code>ROW_HEADER_MODE_EXPLICIT</code> or
- * <code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code> mode to show the
- * headers with icons.
- * </p>
- *
- * @param columnIcons
- * the Array of icons that match the <code>getVisibleColumns</code>.
- */
- public void setColumnIcons(Resource[] columnIcons) {
-
- if (columnIcons.length != this.visibleColumns.size())
- throw new IllegalArgumentException(
- "The length of the icons array must match the number of visible columns");
-
- this.columnIcons.clear();
- int i = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
- && i < columnIcons.length; i++) {
- this.columnIcons.put(it.next(), columnIcons[i]);
- }
-
- // Assure visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Gets the array of column alignments.
- *
- * <p>
- * The items in the array must match the properties identified by
- * <code>getVisibleColumns()</code>. The possible values for the
- * alignments include:
- * <ul>
- * <li><code>ALIGN_LEFT</code>: Left alignment</li>
- * <li><code>ALIGN_CENTER</code>: Centered</li>
- * <li><code>ALIGN_RIGHT</code>: Right alignment</li>
- * </ul>
- * The alignments default to <code>ALIGN_LEFT</code>: any null values are
- * rendered as align lefts.
- * </p>
- *
- * @return the Column alignments array.
- */
- public String[] getColumnAlignments() {
- if (this.columnAlignments == null) {
- return null;
- }
- String[] alignments = new String[this.visibleColumns.size()];
- int i = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); i++) {
- alignments[i++] = getColumnAlignment(it.next());
- }
-
- return alignments;
- }
-
- /**
- * Sets the column alignments.
- *
- * <p>
- * The items in the array must match the properties identified by
- * <code>getVisibleColumns()</code>. The possible values for the
- * alignments include:
- * <ul>
- * <li><code>ALIGN_LEFT</code>: Left alignment</li>
- * <li><code>ALIGN_CENTER</code>: Centered</li>
- * <li><code>ALIGN_RIGHT</code>: Right alignment</li>
- * </ul>
- * The alignments default to <code>ALIGN_LEFT</code>
- * </p>
- *
- * @param columnAlignments
- * the Column alignments array.
- */
- public void setColumnAlignments(String[] columnAlignments) {
-
- if (columnAlignments.length != this.visibleColumns.size())
- throw new IllegalArgumentException(
- "The length of the alignments array must match the number of visible columns");
-
- // Checks all alignments
- for (int i = 0; i < columnAlignments.length; i++) {
- String a = columnAlignments[i];
- if (a != null && !a.equals(ALIGN_LEFT) && !a.equals(ALIGN_CENTER)
- && !a.equals(ALIGN_RIGHT))
- throw new IllegalArgumentException("Column " + i
- + " aligment '" + a + "' is invalid");
- }
-
- // Resets the alignments
- HashMap newCA = new HashMap();
- int i = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
- && i < columnAlignments.length; i++) {
- newCA.put(it.next(), columnAlignments[i]);
- }
- this.columnAlignments = newCA;
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Gets the page length.
- *
- * <p>
- * Setting page length 0 disables paging.
- * </p>
- *
- * @return the Length of one page.
- */
- public int getPageLength() {
- return this.pageLength;
- }
-
- /**
- * Sets the page length.
- *
- * <p>
- * Setting page length 0 disables paging. The page length defaults to 15.
- * </p>
- *
- * @param pageLength the Length of one page.
- */
- public void setPageLength(int pageLength) {
- if (pageLength >= 0 && this.pageLength != pageLength) {
- this.pageLength = pageLength;
- // "scroll" to first row
- this.setCurrentPageFirstItemIndex(0);
- // Assures the visual refresh
- refreshCurrentPage();
- }
- }
-
- /**
- * Getter for property currentPageFirstItem.
- *
- * @return the Value of property currentPageFirstItem.
- */
- public Object getCurrentPageFirstItemId() {
-
- // Priorise index over id if indexes are supported
- if (items instanceof Container.Indexed) {
- int index = getCurrentPageFirstItemIndex();
- Object id = null;
- if (index >= 0 && index < size())
- id = ((Container.Indexed) items).getIdByIndex(index);
- if (id != null && !id.equals(currentPageFirstItemId))
- currentPageFirstItemId = id;
- }
-
- // If there is no item id at all, use the first one
- if (currentPageFirstItemId == null)
- currentPageFirstItemId = ((Container.Ordered) items).firstItemId();
-
- return currentPageFirstItemId;
- }
-
- /**
- * Setter for property currentPageFirstItemId.
- *
- * @param currentPageFirstItemId
- * the New value of property currentPageFirstItemId.
- */
- public void setCurrentPageFirstItemId(Object currentPageFirstItemId) {
-
- // Gets the corresponding index
- int index = -1;
- try {
- index = ((Container.Indexed) items)
- .indexOfId(currentPageFirstItemId);
- } catch (ClassCastException e) {
-
- // If the table item container does not have index, we have to
- // calculates the index by hand
- Object id = ((Container.Ordered) items).firstItemId();
- while (id != null && !id.equals(currentPageFirstItemId)) {
- index++;
- id = ((Container.Ordered) items).nextItemId(id);
- }
- if (id == null)
- index = -1;
- }
-
- // If the search for item index was successfull
- if (index >= 0) {
- this.currentPageFirstItemId = currentPageFirstItemId;
- this.currentPageFirstItemIndex = index;
- }
-
- // Assures the visual refresh
- refreshCurrentPage();
-
- }
-
- /**
- * Gets the icon Resource for the specified column.
- *
- * @param propertyId
- * the propertyId indentifying the column.
- * @return the icon for the specified column; null if the column has no icon
- * set, or if the column is not visible.
- */
- public Resource getColumnIcon(Object propertyId) {
- return (Resource) this.columnIcons.get(propertyId);
- }
-
- /**
- * Sets the icon Resource for the specified column.
- * <p>
- * Throws IllegalArgumentException if the specified column is not visible.
- * </p>
- *
- * @param propertyId
- * the propertyId identifying the column.
- * @param icon
- * the icon Resource to set.
- */
- public void setColumnIcon(Object propertyId, Resource icon) {
-
- if (icon == null)
- this.columnIcons.remove(propertyId);
- else
- this.columnIcons.put(propertyId, icon);
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Gets the header for the specified column.
- *
- * @param propertyId
- * the propertyId indentifying the column.
- * @return the header for the specifed column if it has one.
- */
- public String getColumnHeader(Object propertyId) {
- if (getColumnHeaderMode() == COLUMN_HEADER_MODE_HIDDEN)
- return null;
-
- String header = (String) this.columnHeaders.get(propertyId);
- if ((header == null && this.getColumnHeaderMode() == COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID)
- || this.getColumnHeaderMode() == COLUMN_HEADER_MODE_ID) {
- header = propertyId.toString();
- }
-
- return header;
- }
-
- /**
- * Sets the column header for the specified column;
- *
- * @param propertyId
- * the propertyId indentifying the column.
- * @param header
- * the header to set.
- */
- public void setColumnHeader(Object propertyId, String header) {
-
- if (header == null) {
- this.columnHeaders.remove(propertyId);
- return;
- }
- this.columnHeaders.put(propertyId, header);
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Gets the specified column's alignment.
- *
- * @param propertyId
- * the propertyID identifying the column.
- * @return the specified column's alignment if it as one; null otherwise.
- */
- public String getColumnAlignment(Object propertyId) {
- String a = (String) this.columnAlignments.get(propertyId);
- return a == null ? ALIGN_LEFT : a;
- }
-
- /**
- * Sets the specified column's alignment.
- *
- * <p>
- * Throws IllegalArgumentException if the alignment is not one of the
- * following: ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT
- * </p>
- *
- * @param propertyId
- * the propertyID identifying the column.
- * @param alignment
- * the desired alignment.
- */
- public void setColumnAlignment(Object propertyId, String alignment) {
-
- // Checks for valid alignments
- if (alignment != null && !alignment.equals(ALIGN_LEFT)
- && !alignment.equals(ALIGN_CENTER)
- && !alignment.equals(ALIGN_RIGHT))
- throw new IllegalArgumentException("Column alignment '" + alignment
- + "' is not supported.");
-
- if (alignment == null || alignment.equals(ALIGN_LEFT)) {
- this.columnAlignments.remove(propertyId);
- return;
- }
-
- this.columnAlignments.put(propertyId, alignment);
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Checks if the specified column is collapsed.
- *
- * @param propertyId
- * the propertyID identifying the column.
- * @return true if the column is collapsed; false otherwise;
- */
- public boolean isColumnCollapsed(Object propertyId) {
- return collapsedColumns != null
- && collapsedColumns.contains(propertyId);
- }
-
- /**
- * Sets whether the specified column is collapsed or not.
- *
- *
- * @param propertyId
- * the propertyID identifying the column.
- * @param collapsed
- * the desired collapsedness.
- * @throws IllegalAccessException
- */
- public void setColumnCollapsed(Object propertyId, boolean collapsed)
- throws IllegalAccessException {
- if (!this.isColumnCollapsingAllowed()) {
- throw new IllegalAccessException("Column collapsing not allowed!");
- }
-
- if (collapsed)
- this.collapsedColumns.add(propertyId);
- else
- this.collapsedColumns.remove(propertyId);
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Checks if column collapsing is allowed.
- *
- * @return true if columns can be collapsed; false otherwise.
- */
- public boolean isColumnCollapsingAllowed() {
- return this.columnCollapsingAllowed;
- }
-
- /**
- * Sets whether column collapsing is allowed or not.
- *
- * @param collapsingAllowed
- * specifies whether column collapsing is allowed.
- */
- public void setColumnCollapsingAllowed(boolean collapsingAllowed) {
- this.columnCollapsingAllowed = collapsingAllowed;
-
- if (!collapsingAllowed)
- collapsedColumns.clear();
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Checks if column reordering is allowed.
- *
- * @return true if columns can be reordered; false otherwise.
- */
- public boolean isColumnReorderingAllowed() {
- return this.columnReorderingAllowed;
- }
-
- /**
- * Sets whether column reordering is allowed or not.
- *
- * @param reorderingAllowed
- * specifies whether column reordering is allowed.
- */
- public void setColumnReorderingAllowed(boolean reorderingAllowed) {
- this.columnReorderingAllowed = reorderingAllowed;
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /*
- * Arranges visible columns according to given columnOrder. Silently ignores
- * colimnId:s that are not visible columns, and keeps the internal order of
- * visible columns left out of the ordering (trailing). Silently does
- * nothing if columnReordering is not allowed.
- */
- private void setColumnOrder(Object[] columnOrder) {
- if (columnOrder == null || !this.isColumnReorderingAllowed()) {
- return;
- }
- LinkedList newOrder = new LinkedList();
- for (int i = 0; i < columnOrder.length; i++) {
- if (columnOrder[i] != null
- && this.visibleColumns.contains(columnOrder[i])) {
- this.visibleColumns.remove(columnOrder[i]);
- newOrder.add(columnOrder[i]);
- }
- }
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext();) {
- Object columnId = it.next();
- if (!newOrder.contains(columnId))
- newOrder.add(columnId);
- }
- this.visibleColumns = newOrder;
-
- // Assure visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Getter for property currentPageFirstItem.
- *
- * @return the Value of property currentPageFirstItem.
- */
- public int getCurrentPageFirstItemIndex() {
- return this.currentPageFirstItemIndex;
- }
-
- /**
- * Setter for property currentPageFirstItem.
- *
- * @param newIndex
- * the New value of property currentPageFirstItem.
- */
- public void setCurrentPageFirstItemIndex(int newIndex) {
-
- // Ensures that the new value is valid
- if (newIndex < 0)
- newIndex = 0;
- if (newIndex >= size())
- newIndex = size() - 1;
-
- // Refresh first item id
- if (items instanceof Container.Indexed) {
- try {
- currentPageFirstItemId = ((Container.Indexed) items)
- .getIdByIndex(newIndex);
- } catch (IndexOutOfBoundsException e) {
- currentPageFirstItemId = null;
- }
- this.currentPageFirstItemIndex = newIndex;
- } else {
-
- // For containers not supporting indexes, we must iterate the
- // container forwards / backwards
- // next available item forward or backward
-
- this.currentPageFirstItemId = ((Container.Ordered) items).firstItemId();
-
- // Go forwards in the middle of the list (respect borders)
- while (this.currentPageFirstItemIndex < newIndex
- && !((Container.Ordered) items)
- .isLastId(currentPageFirstItemId)) {
- this.currentPageFirstItemIndex++;
- currentPageFirstItemId = ((Container.Ordered) items)
- .nextItemId(currentPageFirstItemId);
- }
-
- // If we did hit the border
- if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) {
- this.currentPageFirstItemIndex = size() - 1;
- }
-
- // Go backwards in the middle of the list (respect borders)
- while (this.currentPageFirstItemIndex > newIndex
- && !((Container.Ordered) items)
- .isFirstId(currentPageFirstItemId)) {
- this.currentPageFirstItemIndex--;
- currentPageFirstItemId = ((Container.Ordered) items)
- .prevItemId(currentPageFirstItemId);
- }
-
- // If we did hit the border
- if (((Container.Ordered) items).isFirstId(currentPageFirstItemId)) {
- this.currentPageFirstItemIndex = 0;
- }
-
- // Go forwards once more
- while (this.currentPageFirstItemIndex < newIndex
- && !((Container.Ordered) items)
- .isLastId(currentPageFirstItemId)) {
- this.currentPageFirstItemIndex++;
- currentPageFirstItemId = ((Container.Ordered) items)
- .nextItemId(currentPageFirstItemId);
- }
-
- // If for some reason we do hit border again, override
- // the user index request
- if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) {
- newIndex = this.currentPageFirstItemIndex = size() - 1;
- }
- }
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Getter for property pageBuffering.
- *
- * @return the Value of property pageBuffering.
- */
- public boolean isPageBufferingEnabled() {
- return this.pageBuffering;
- }
-
- /**
- * Setter for property pageBuffering.
- *
- * @param pageBuffering
- * the New value of property pageBuffering.
- */
- public void setPageBufferingEnabled(boolean pageBuffering) {
-
- this.pageBuffering = pageBuffering;
-
- // If page buffering is disabled, clear the buffer
- if (!pageBuffering)
- pageBuffer = null;
- }
-
- /**
- * Getter for property selectable.
- *
- * <p>
- * The table is not selectable by default.
- * </p>
- *
- * @return the Value of property selectable.
- */
- public boolean isSelectable() {
- return this.selectable;
- }
-
- /**
- * Setter for property selectable.
- *
- * <p>
- * The table is not selectable by default.
- * </p>
- *
- * @param selectable
- * the New value of property selectable.
- */
- public void setSelectable(boolean selectable) {
- if (this.selectable != selectable) {
- this.selectable = selectable;
- requestRepaint();
- }
- }
-
- /**
- * Getter for property columnHeaderMode.
- *
- * @return the Value of property columnHeaderMode.
- */
- public int getColumnHeaderMode() {
- return this.columnHeaderMode;
- }
-
- /**
- * Setter for property columnHeaderMode.
- *
- * @param columnHeaderMode
- * the New value of property columnHeaderMode.
- */
- public void setColumnHeaderMode(int columnHeaderMode) {
- if (columnHeaderMode >= COLUMN_HEADER_MODE_HIDDEN
- && columnHeaderMode <= COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID)
- this.columnHeaderMode = columnHeaderMode;
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Refreshes the current page contents. If the page buffering is turned off,
- * it is not necessary to call this explicitely.
- */
- public void refreshCurrentPage() {
-
- // Clear page buffer and notify about the change
- pageBuffer = null;
- requestRepaint();
- }
-
- /**
- * Sets the row header mode.
- * <p>
- * The mode can be one of the following ones:
- * <ul>
- * <li><code>ROW_HEADER_MODE_HIDDEN</code>: The row captions are hidden.
- * </li>
- * <li><code>ROW_HEADER_MODE_ID</code>: Items Id-objects
- * <code>toString()</code> is used as row caption.
- * <li><code>ROW_HEADER_MODE_ITEM</code>: Item-objects
- * <code>toString()</code> is used as row caption.
- * <li><code>ROW_HEADER_MODE_PROPERTY</code>: Property set with
- * <code>setItemCaptionPropertyId()</code> is used as row header.
- * <li><code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code>: Items
- * Id-objects <code>toString()</code> is used as row header. If caption is
- * explicitly specified, it overrides the id-caption.
- * <li><code>ROW_HEADER_MODE_EXPLICIT</code>: The row headers must be
- * explicitly specified.</li>
- * <li><code>ROW_HEADER_MODE_INDEX</code>: The index of the item is used
- * as row caption. The index mode can only be used with the containers
- * implementing <code>Container.Indexed</code> interface.</li>
- * </ul>
- * The default value is <code>ROW_HEADER_MODE_HIDDEN</code>
- * </p>
- *
- * @param mode
- * the One of the modes listed above.
- */
- public void setRowHeaderMode(int mode) {
- if (ROW_HEADER_MODE_HIDDEN == mode)
- rowCaptionsAreHidden = true;
- else {
- rowCaptionsAreHidden = false;
- setItemCaptionMode(mode);
- }
-
- // Assure visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Gets the row header mode.
- *
- * @return the Row header mode.
- * @see #setRowHeaderMode(int)
- */
- public int getRowHeaderMode() {
- return rowCaptionsAreHidden ? ROW_HEADER_MODE_HIDDEN
- : getItemCaptionMode();
- }
-
- /**
- * Adds the new row to table and fill the visible cells with given values.
- *
- * @param cells
- * the Object array that is used for filling the visible cells new
- * row. The types must be settable to visible column property
- * types.
- * @param itemId
- * the Id the new row. If null, a new id is automatically assigned.
- * If given, the table cant already have a item with given id.
- * @return Returns item id for the new row. Returns null if operation fails.
- */
- public Object addItem(Object[] cells, Object itemId)
- throws UnsupportedOperationException {
-
- Object[] cols = getVisibleColumns();
-
- // Checks that a correct number of cells are given
- if (cells.length != cols.length)
- return null;
-
- // Creates new item
- Item item;
- if (itemId == null) {
- itemId = items.addItem();
- if (itemId == null)
- return null;
- item = items.getItem(itemId);
- } else
- item = items.addItem(itemId);
- if (item == null)
- return null;
-
- // Fills the item properties
- for (int i = 0; i < cols.length; i++)
- item.getItemProperty(cols[i]).setValue(cells[i]);
-
- return itemId;
- }
-
- /* Overriding select behavior******************************************** */
-
- /**
- * Sets the Container that serves as the data source of the viewer.
- * @see com.itmill.toolkit.data.Container.Viewer#setContainerDataSource(Container)
- */
- public void setContainerDataSource(Container newDataSource) {
-
- if (newDataSource == null)
- newDataSource = new IndexedContainer();
-
- // Assures that the data source is ordered by making unordered
- // containers ordered by wrapping them
- if (newDataSource instanceof Container.Ordered)
- super.setContainerDataSource(newDataSource);
- else
- super.setContainerDataSource(new ContainerOrderedWrapper(
- newDataSource));
-
- // Resets page position
- currentPageFirstItemId = null;
- currentPageFirstItemIndex = 0;
-
- // Resets column properties
- if (this.collapsedColumns != null)
- this.collapsedColumns.clear();
- setVisibleColumns(getContainerPropertyIds().toArray());
-
- // Assure visual refresh
- refreshCurrentPage();
- }
-
- /* Component basics ***************************************************** */
-
- /**
- * Invoked when the value of a variable has changed.
- * @see com.itmill.toolkit.ui.Select#changeVariables(java.lang.Object, java.util.Map)
- */
- public void changeVariables(Object source, Map variables) {
-
- super.changeVariables(source, variables);
-
- // Page start index
- if (variables.containsKey("firstvisible")) {
- Integer value = (Integer) variables.get("firstvisible");
- if (value != null)
- setCurrentPageFirstItemIndex(value.intValue() - 1);
- }
-
- // Sets requested firstrow and rows for the next paint
- if (variables.containsKey("reqfirstrow") || variables.containsKey("reqrows")) {
- Integer value = (Integer) variables.get("reqfirstrow");
- if (value != null)
- reqFirstRowToPaint = value.intValue() -1;
- value = (Integer) variables.get("reqrows");
- if (value != null)
- reqRowsToPaint = value.intValue();
- pageBuffer = null;
- requestRepaint();
- }
-
- // Actions
- if (variables.containsKey("action")) {
- 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());
- if (action != null && containsId(itemId)
- && actionHandlers != null)
- for (Iterator i = actionHandlers.iterator(); i.hasNext();)
- ((Action.Handler) i.next()).handleAction(action, this,
- itemId);
- }
- }
-
- // Sorting
- boolean doSort = false;
- if (variables.containsKey("sortcolumn")) {
- String colId = (String) variables.get("sortcolumn");
- if (colId != null && !"".equals(colId) && !"null".equals(colId)) {
- Object id = this.columnIdMap.get(colId);
- setSortContainerPropertyId(id);
- doSort = true;
- }
- }
- if (variables.containsKey("sortascending")) {
- boolean state = ((Boolean) variables.get("sortascending"))
- .booleanValue();
- if (state != this.sortAscending) {
- setSortAscending(state);
- doSort = true;
- }
- }
- if (doSort)
- this.sort();
-
- // Dynamic column hide/show and order
- // Update visible columns
- if (this.isColumnCollapsingAllowed()) {
- if (variables.containsKey("collapsedcolumns")) {
- try {
- Object[] ids = (Object[]) variables.get("collapsedcolumns");
- for (Iterator it = this.visibleColumns.iterator(); it
- .hasNext();) {
- this.setColumnCollapsed(it.next(), false);
- }
- for (int i = 0; i < ids.length; i++) {
- this.setColumnCollapsed(columnIdMap.get(ids[i]
- .toString()), true);
- }
- } catch (Exception ignored) {
- }
- }
- }
- if (this.isColumnReorderingAllowed()) {
- if (variables.containsKey("columnorder")) {
- try {
- Object[] ids = (Object[]) variables.get("columnorder");
- for (int i = 0; i < ids.length; i++) {
- ids[i] = columnIdMap.get(ids[i].toString());
- }
- this.setColumnOrder(ids);
- } catch (Exception ignored) {
- }
- }
- }
- }
-
- /**
- * Paints the content of this component.
- *
- * @param target
- * the Paint target.
- * @throws PaintException
- * if the paint operation failed.
- */
- public void paintContent(PaintTarget target) throws PaintException {
-
- // Focus control id
- if (this.getFocusableId() > 0) {
- target.addAttribute("focusid", this.getFocusableId());
- }
-
- // The tab ordering number
- if (this.getTabIndex() > 0)
- target.addAttribute("tabindex", this.getTabIndex());
-
- // Size
- if (getHeight() >= 0)
- target.addAttribute("height", "" + getHeight() + Sizeable.UNIT_SYMBOLS[getHeightUnits()]);
- if (getWidth() >= 0)
- target.addAttribute("width", "" + getWidth()+ Sizeable.UNIT_SYMBOLS[getWidthUnits()]);
-
-
- // Initialize temps
- Object[] colids = getVisibleColumns();
- int cols = colids.length;
- 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 = this.isEditable();
-
- // selection support
- String[] selectedKeys;
- if (isMultiSelect())
- selectedKeys = new String[((Set) getValue()).size()];
- else
- selectedKeys = new String[(getValue() == null
- && getNullSelectionItemId() == null ? 0 : 1)];
- int keyIndex = 0;
-
- // Table attributes
- if (isSelectable())
- target.addAttribute("selectmode", (isMultiSelect() ? "multi"
- : "single"));
- else
- target.addAttribute("selectmode", "none");
- target.addAttribute("cols", cols);
- target.addAttribute("rows", cells[0].length);
- target.addAttribute("firstrow", (reqFirstRowToPaint >= 0 ? reqFirstRowToPaint : first) + 1);
- target.addAttribute("totalrows", total);
- if (pagelen != 0)
- target.addAttribute("pagelength", pagelen);
- if (colheads)
- target.addAttribute("colheaders", true);
- if (rowheads)
- target.addAttribute("rowheaders", true);
-
- // Columns
- target.startTag("cols");
- Collection sortables = getSortableContainerPropertyIds();
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext();) {
- Object columnId = it.next();
- if (!isColumnCollapsed(columnId)) {
- target.startTag("ch");
- if (colheads) {
- if (this.getColumnIcon(columnId) != null)
- target.addAttribute("icon", this
- .getColumnIcon(columnId));
- if (sortables.contains(columnId))
- target.addAttribute("sortable", true);
- String header = (String) this.getColumnHeader(columnId);
- target.addAttribute("caption", (header != null ? header
- : ""));
- }
- target.addAttribute("cid", this.columnIdMap.key(columnId));
- if (!ALIGN_LEFT.equals(this.getColumnAlignment(columnId)))
- target.addAttribute("align", this
- .getColumnAlignment(columnId));
- target.endTag("ch");
- }
- }
- target.endTag("cols");
-
- // Rows
- Set actionSet = new LinkedHashSet();
- boolean selectable = isSelectable();
- boolean[] iscomponent = new boolean[this.visibleColumns.size()];
- int iscomponentIndex = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
- && iscomponentIndex < iscomponent.length;) {
- Object columnId = it.next();
- Class colType = getType(columnId);
- iscomponent[iscomponentIndex++] = colType != null
- && Component.class.isAssignableFrom(colType);
- }
- target.startTag("rows");
- for (int i = 0; i < cells[0].length; i++) {
- target.startTag("tr");
- Object itemId = cells[CELL_ITEMID][i];
-
- // tr attributes
- if (rowheads) {
- if (cells[CELL_ICON][i] != null)
- target.addAttribute("icon", (Resource) cells[CELL_ICON][i]);
- if (cells[CELL_HEADER][i] != null)
- target.addAttribute("caption",
- (String) cells[CELL_HEADER][i]);
- }
- if (actionHandlers != null || isSelectable()) {
- target.addAttribute("key", (String) cells[CELL_KEY][i]);
- if (isSelected(itemId) && keyIndex < selectedKeys.length) {
- target.addAttribute("selected", true);
- selectedKeys[keyIndex++] = (String) cells[CELL_KEY][i];
- }
- }
-
- // Actions
- if (actionHandlers != null) {
- target.startTag("al");
- for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) {
- 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]);
- actionSet.add(aa[ai]);
- target.addSection("ak", key);
- }
- }
- target.endTag("al");
- }
-
- // cells
- int currentColumn = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); currentColumn++) {
- Object columnId = it.next();
- if (columnId == null || this.isColumnCollapsed(columnId))
- continue;
- if ((iscomponent[currentColumn] || iseditable)
- && Component.class.isInstance(cells[CELL_FIRSTCOL
- + currentColumn][i])) {
- Component c = (Component) cells[CELL_FIRSTCOL
- + currentColumn][i];
- if (c == null)
- target.addSection("label", "");
- else
- c.paint(target);
- } else
- target.addSection("label", (String) cells[CELL_FIRSTCOL
- + currentColumn][i]);
- }
-
- target.endTag("tr");
- }
- target.endTag("rows");
-
- // The select variable is only enabled if selectable
- if (selectable)
- target.addVariable(this, "selected", selectedKeys);
-
- // The cursors are only shown on pageable table
- if (first != 0 || getPageLength() > 0)
- target.addVariable(this, "firstvisible", first + 1);
-
- // Sorting
- if (getContainerDataSource() instanceof Container.Sortable) {
- target.addVariable(this, "sortcolumn", this.columnIdMap.key(this.sortContainerPropertyId));
- target.addVariable(this, "sortascending", this.sortAscending);
- }
-
- // Resets and paints "to be painted next" variables. Also reset pageBuffer
- reqFirstRowToPaint = -1;
- reqRowsToPaint = -1;
- pageBuffer = null;
- target.addVariable(this, "reqrows", reqRowsToPaint);
- target.addVariable(this, "reqfirstrow", reqFirstRowToPaint);
-
- // Actions
- if (!actionSet.isEmpty()) {
- target.startTag("actions");
- target.addVariable(this, "action", "");
- for (Iterator it = actionSet.iterator(); it.hasNext();) {
- Action a = (Action) it.next();
- target.startTag("action");
- if (a.getCaption() != null)
- target.addAttribute("caption", a.getCaption());
- if (a.getIcon() != null)
- target.addAttribute("icon", a.getIcon());
- target.addAttribute("key", actionMapper.key(a));
- target.endTag("action");
- }
- target.endTag("actions");
- }
- if (this.columnReorderingAllowed) {
- String[] colorder = new String[this.visibleColumns.size()];
- int i = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
- && i < colorder.length;) {
- colorder[i++] = this.columnIdMap.key(it.next());
- }
- target.addVariable(this, "columnorder", colorder);
- }
- // Available columns
- if (this.columnCollapsingAllowed) {
- HashSet ccs = new HashSet();
- for (Iterator i = visibleColumns.iterator(); i.hasNext();) {
- Object o = i.next();
- if (isColumnCollapsed(o))
- ccs.add(o);
- }
- String[] collapsedkeys = new String[ccs.size()];
- int nextColumn = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
- && nextColumn < collapsedkeys.length;) {
- Object columnId = it.next();
- if (this.isColumnCollapsed(columnId)) {
- collapsedkeys[nextColumn++] = this.columnIdMap
- .key(columnId);
- }
- }
- target.addVariable(this, "collapsedcolumns", collapsedkeys);
- target.startTag("visiblecolumns");
- int i = 0;
- for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); i++) {
- Object columnId = it.next();
- if (columnId != null) {
- target.startTag("column");
- target.addAttribute("cid", this.columnIdMap.key(columnId));
- String head = getColumnHeader(columnId);
- target.addAttribute("caption", (head != null ? head : ""));
- if (this.isColumnCollapsed(columnId)) {
- target.addAttribute("collapsed", true);
- }
- target.endTag("column");
- }
- }
- target.endTag("visiblecolumns");
- }
- }
-
- /**
- * Gets the UIDL tag corresponding to component.
- *
- * @return the UIDL tag as string.
- */
- public String getTag() {
- return "table";
- }
-
- /**
- * Gets the cached visible table contents.
- * @return the cahced visible table conetents.
- */
- private Object[][] getVisibleCells() {
-
- // Returns a buffered value if possible
- if (pageBuffer != null && isPageBufferingEnabled())
- return pageBuffer;
-
- // Stops listening the old properties and initialise the list
- if (listenedProperties == null)
- listenedProperties = new LinkedList();
- else
- for (Iterator i = listenedProperties.iterator(); i.hasNext();) {
- ((Property.ValueChangeNotifier) i.next()).removeListener(this);
- }
-
- // Detach old visible component from the table
- if (visibleComponents == null)
- visibleComponents = new LinkedList();
- else
- for (Iterator i = visibleComponents.iterator(); i.hasNext();) {
- ((Component) i.next()).setParent(null);
- }
-
- // Collects the basic facts about the table page
- Object[] colids = getVisibleColumns();
- int cols = colids.length;
- int pagelen = getPageLength();
- int firstIndex = getCurrentPageFirstItemIndex();
- int rows = size();
- if (rows > 0 && firstIndex >= 0)
- rows -= firstIndex;
- if (pagelen > 0 && pagelen < rows)
- rows = pagelen;
-
- // If "to be painted next" variables are set, use them
- if (reqRowsToPaint >= 0) rows = reqRowsToPaint;
- Object id;
- if (reqFirstRowToPaint >= 0 && reqFirstRowToPaint < size())
- firstIndex = reqFirstRowToPaint;
- if(size() > 0) {
- if (rows + firstIndex > size()) rows = size() - firstIndex;
- } else {
- rows = 0;
- }
-
- Object[][] cells = new Object[cols + CELL_FIRSTCOL][rows];
- if (rows == 0)
- return cells;
-
- // Gets the first item id
- if (items instanceof Container.Indexed)
- id = ((Container.Indexed) items).getIdByIndex(firstIndex);
- else {
- id = ((Container.Ordered) items).firstItemId();
- for (int i=0; i<firstIndex; i++) id = ((Container.Ordered) items).nextItemId(id);
- }
-
- int headmode = getRowHeaderMode();
- boolean[] iscomponent = new boolean[cols];
- for (int i = 0; i < cols; i++)
- iscomponent[i] = Component.class
- .isAssignableFrom(getType(colids[i]));
-
- // Creates the page contents
- int filledRows = 0;
- for (int i = 0; i < rows && id != null; i++) {
- cells[CELL_ITEMID][i] = id;
- cells[CELL_KEY][i] = itemIdMapper.key(id);
- if (headmode != ROW_HEADER_MODE_HIDDEN) {
- switch (headmode) {
- case ROW_HEADER_MODE_INDEX:
- cells[CELL_HEADER][i] = String.valueOf(i + firstIndex + 1);
- break;
- default:
- cells[CELL_HEADER][i] = getItemCaption(id);
- }
- cells[CELL_ICON][i] = getItemIcon(id);
- }
- if (cols > 0) {
- for (int j = 0; j < cols; j++) {
- Object value = null;
- Property p = getContainerProperty(id, colids[j]);
- if (p != null) {
- if (p instanceof Property.ValueChangeNotifier) {
- ((Property.ValueChangeNotifier) p)
- .addListener(this);
- listenedProperties.add(p);
- }
- if (iscomponent[j]) {
- value = p.getValue();
- } else if (p != null) {
- value = getPropertyValue(id, colids[j], p);
- } else {
- value = getPropertyValue(id, colids[j], null);
- }
- } else {
- value = "";
- }
-
- if (value instanceof Component) {
- ((Component) value).setParent(this);
- visibleComponents.add((Component) value);
- }
- cells[CELL_FIRSTCOL + j][i] = value;
-
- }
- }
- id = ((Container.Ordered) items).nextItemId(id);
-
- filledRows++;
- }
-
- // Assures that all the rows of the cell-buffer are valid
- if (filledRows != cells[0].length) {
- 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];
- cells = temp;
- }
-
- // Saves the results to internal buffer iff in buffering mode
- // to possible conserve memory from large non-buffered pages
- if (isPageBufferingEnabled())
- pageBuffer = cells;
-
- return cells;
- }
-
- /**
- * Gets the value of property.
- *
- * By default if the table is editable the fieldFactory is used to create
- * editors for table cells. Otherwise formatPropertyValue is used to format
- * the value representation.
- *
- * @param rowId
- * the Id of the row (same as item Id).
- * @param colId
- * the Id of the column.
- * @param property
- * the Property to be presented.
- * @return Object Either formatted value or Component for field.
- * @see #setFieldFactory(FieldFactory)
- */
- protected Object getPropertyValue(Object rowId, Object colId,
- Property property) {
- if (this.isEditable() && this.fieldFactory != null) {
- Field f = this.fieldFactory.createField(getContainerDataSource(),
- rowId, colId, this);
- if (f != null) {
- f.setPropertyDataSource(property);
- return f;
- }
- }
-
- return formatPropertyValue(rowId, colId, property);
- }
-
- /**
- * Formats table cell property values. By default the property.toString()
- * and return a empty string for null properties.
- *
- * @param rowId the Id of the row (same as item Id).
- * @param colId the Id of the column.
- * @param property
- * the Property to be formatted.
- * @return the String representation of property and its value.
- * @since 3.1
- */
- protected String formatPropertyValue(Object rowId, Object colId,
- Property property) {
- if (property == null) {
- return "";
- }
- return property.toString();
- }
-
- /* Action container *************************************************** */
-
- /**
- * Registers a new action handler for this container
- * @see com.itmill.toolkit.event.Action.Container#addActionHandler(Action.Handler)
- */
- public void addActionHandler(Action.Handler actionHandler) {
-
- if (actionHandler != null) {
-
- if (actionHandlers == null) {
- actionHandlers = new LinkedList();
- actionMapper = new KeyMapper();
- }
-
- if(!actionHandlers.contains(actionHandler)){
- actionHandlers.add(actionHandler);
- requestRepaint();
- }
-
- }
- }
-
- /**
- * Removes a previously registered action handler for the contents
- * of this container.
- * @see com.itmill.toolkit.event.Action.Container#removeActionHandler(Action.Handler)
- */
- public void removeActionHandler(Action.Handler actionHandler) {
-
- if (actionHandlers != null && actionHandlers.contains(actionHandler)) {
-
- actionHandlers.remove(actionHandler);
-
- if (actionHandlers.isEmpty()) {
- actionHandlers = null;
- actionMapper = null;
- }
-
- requestRepaint();
- }
- }
-
- /* Property value change listening support **************************** */
-
- /**
- * Notifies this listener that the Property's value has changed.
- * @see com.itmill.toolkit.data.Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
- */
- public void valueChange(Property.ValueChangeEvent event) {
- super.valueChange(event);
- requestRepaint();
- }
-
- /**
- * Notifies the component that it is connected to an application.
- * @see com.itmill.toolkit.ui.Component#attach()
- */
- public void attach() {
- super.attach();
-
- if (visibleComponents != null)
- for (Iterator i = visibleComponents.iterator(); i.hasNext();)
- ((Component) i.next()).attach();
- }
-
- /**
- * Notifies the component that it is detached from the application
- * @see com.itmill.toolkit.ui.Component#detach()
- */
- public void detach() {
- super.detach();
-
- if (visibleComponents != null)
- for (Iterator i = visibleComponents.iterator(); i.hasNext();)
- ((Component) i.next()).detach();
- }
-
- /**
- * Removes all Items from the Container.
- * @see com.itmill.toolkit.data.Container#removeAllItems()
- */
- public boolean removeAllItems() {
- this.currentPageFirstItemId = null;
- this.currentPageFirstItemIndex = 0;
- return super.removeAllItems();
- }
-
- /**
- * Removes the Item identified by <code>ItemId</code> from the Container.
- * @see com.itmill.toolkit.data.Container#removeItem(Object)
- */
- public boolean removeItem(Object itemId) {
- Object nextItemId = ((Container.Ordered) items).nextItemId(itemId);
- boolean ret = super.removeItem(itemId);
- if (ret && (itemId != null)
- && (itemId.equals(this.currentPageFirstItemId))) {
- this.currentPageFirstItemId = nextItemId;
- }
- return ret;
- }
-
- /**
- * Removes a Property specified by the given Property ID from the Container.
- * @see com.itmill.toolkit.data.Container#removeContainerProperty(Object)
- */
- public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
-
- // If a visible property is removed, remove the corresponding column
- this.visibleColumns.remove(propertyId);
- this.columnAlignments.remove(propertyId);
- this.columnIcons.remove(propertyId);
- this.columnHeaders.remove(propertyId);
-
- return super.removeContainerProperty(propertyId);
- }
-
- /**
- * Adds a new property to the table and show it as a visible column.
- * @param propertyId
- * the Id of the proprty.
- * @param type
- * the class of the property.
- * @param defaultValue
- * the default value given for all existing items.
- * @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
- * Class, Object)
- */
- public boolean addContainerProperty(Object propertyId, Class type,
- Object defaultValue) throws UnsupportedOperationException {
- if (!super.addContainerProperty(propertyId, type, defaultValue))
- return false;
- if (!this.visibleColumns.contains(propertyId))
- this.visibleColumns.add(propertyId);
- return true;
- }
-
- /**
- * Adds a new property to the table and show it as a visible column.
- *
- * @param propertyId
- * the Id of the proprty
- * @param type
- * the class of the property
- * @param defaultValue
- * the default value given for all existing items
- * @param columnHeader
- * the Explicit header of the column. If explicit header is not
- * needed, this should be set null.
- * @param columnIcon
- * the Icon of the column. If icon is not needed, this should be set
- * null.
- * @param columnAlignment
- * the Alignment of the column. Null implies align left.
- * @throws UnsupportedOperationException if the operation is not supported.
- * @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
- * Class, Object)
- */
- public boolean addContainerProperty(Object propertyId, Class type,
- Object defaultValue, String columnHeader, Resource columnIcon,
- String columnAlignment) throws UnsupportedOperationException {
- if (!this.addContainerProperty(propertyId, type, defaultValue))
- return false;
- this.setColumnAlignment(propertyId, columnAlignment);
- this.setColumnHeader(propertyId, columnHeader);
- this.setColumnIcon(propertyId, columnIcon);
- return true;
- }
-
- /**
- * Returns the list of items on the current page
- *
- * @see com.itmill.toolkit.ui.Select#getVisibleItemIds()
- */
- public Collection getVisibleItemIds() {
-
- LinkedList visible = new LinkedList();
-
- Object[][] cells = getVisibleCells();
- for (int i = 0; i < cells[CELL_ITEMID].length; i++)
- visible.add(cells[CELL_ITEMID][i]);
-
- return visible;
- }
-
- /**
- * Container datasource item set change. Table must flush its buffers on
- * change.
- *
- * @see com.itmill.toolkit.data.Container.ItemSetChangeListener#containerItemSetChange(com.itmill.toolkit.data.Container.ItemSetChangeEvent)
- */
- public void containerItemSetChange(Container.ItemSetChangeEvent event) {
- pageBuffer = null;
- super.containerItemSetChange(event);
- setCurrentPageFirstItemIndex(this.getCurrentPageFirstItemIndex());
- }
-
- /**
- * Container datasource property set change. Table must flush its buffers on
- * change.
- *
- * @see com.itmill.toolkit.data.Container.PropertySetChangeListener#containerPropertySetChange(com.itmill.toolkit.data.Container.PropertySetChangeEvent)
- */
- public void containerPropertySetChange(
- Container.PropertySetChangeEvent event) {
- pageBuffer = null;
- super.containerPropertySetChange(event);
- }
-
- /**
- * Adding new items is not supported.
- * @throws UnsupportedOperationException
- * if set to true.
- * @see com.itmill.toolkit.ui.Select#setNewItemsAllowed(boolean)
- */
- public void setNewItemsAllowed(boolean allowNewOptions)
- throws UnsupportedOperationException {
- if (allowNewOptions)
- throw new UnsupportedOperationException();
- }
-
- /**
- * Focusing to this component is not supported.
- * @throws UnsupportedOperationException
- * if invoked.
- * @see com.itmill.toolkit.ui.AbstractField#focus()
- */
- public void focus() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Gets the ID of the Item following the Item that corresponds to
- * itemId.
- * @see com.itmill.toolkit.data.Container.Ordered#nextItemId(java.lang.Object)
- */
- public Object nextItemId(Object itemId) {
- return ((Container.Ordered) items).nextItemId(itemId);
- }
-
- /**
- * Gets the ID of the Item preceding the Item that corresponds to
- * the itemId.
- * @see com.itmill.toolkit.data.Container.Ordered#prevItemId(java.lang.Object)
- */
- public Object prevItemId(Object itemId) {
- return ((Container.Ordered) items).prevItemId(itemId);
- }
-
- /**
- * Gets the ID of the first Item in the Container.
- * @see com.itmill.toolkit.data.Container.Ordered#firstItemId()
- */
- public Object firstItemId() {
- return ((Container.Ordered) items).firstItemId();
- }
-
- /**
- * Gets the ID of the last Item in the Container.
- * @see com.itmill.toolkit.data.Container.Ordered#lastItemId()
- */
- public Object lastItemId() {
- return ((Container.Ordered) items).lastItemId();
- }
-
- /**
- * Tests if the Item corresponding to the given Item ID is the first
- * Item in the Container.
- * @see com.itmill.toolkit.data.Container.Ordered#isFirstId(java.lang.Object)
- */
- public boolean isFirstId(Object itemId) {
- return ((Container.Ordered) items).isFirstId(itemId);
- }
-
- /**
- * Tests if the Item corresponding to the given Item ID is the last Item
- * in the Container.
- * @see com.itmill.toolkit.data.Container.Ordered#isLastId(java.lang.Object)
- */
- public boolean isLastId(Object itemId) {
- return ((Container.Ordered) items).isLastId(itemId);
- }
-
- /**
- * Adds new item after the given item.
- * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(java.lang.Object)
- */
- public Object addItemAfter(Object previousItemId)
- throws UnsupportedOperationException {
- return ((Container.Ordered) items).addItemAfter(previousItemId);
- }
-
- /**
- * Adds new item after the given item.
- * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(java.lang.Object,
- * java.lang.Object)
- */
- public Item addItemAfter(Object previousItemId, Object newItemId)
- throws UnsupportedOperationException {
- return ((Container.Ordered) items).addItemAfter(previousItemId,
- newItemId);
- }
-
- /**
- * Gets the FieldFactory that is used to create editor for table cells.
- *
- * The FieldFactory is only used if the Table is editable.
- * @return FieldFactory used to create the Field instances.
- * @see #isEditable
- */
- public FieldFactory getFieldFactory() {
- return fieldFactory;
- }
-
- /**
- * Sets the FieldFactory that is used to create editor for table cells.
- *
- * The FieldFactory is only used if the Table is editable. By default the
- * BaseFieldFactory is used.
- * @param fieldFactory
- * the field factory to set.
- * @see #isEditable
- * @see BaseFieldFactory
-
- */
- public void setFieldFactory(FieldFactory fieldFactory) {
- this.fieldFactory = fieldFactory;
-
- // Assure visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Is table editable.
- *
- * If table is editable a editor of type Field is created for each table
- * cell. The assigned FieldFactory is used to create the instances.
- *
- * To provide custom editors for table cells create a class implementins the
- * FieldFactory interface, and assign it to table, and set the editable
- * property to true.
- * @return true if table is editable, false oterwise.
- * @see Field
- * @see FieldFactory
- *
- */
- public boolean isEditable() {
- return editable;
- }
-
- /**
- * Sets the editable property.
- *
- * If table is editable a editor of type Field is created for each table
- * cell. The assigned FieldFactory is used to create the instances.
- *
- * To provide custom editors for table cells create a class implementins the
- * FieldFactory interface, and assign it to table, and set the editable
- * property to true.
- * @param editable
- * true if table should be editable by user.
- * @see Field
- * @see FieldFactory
- *
- */
- public void setEditable(boolean editable) {
- this.editable = editable;
-
- // Assure visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Sorts the table.
- * @throws UnsupportedOperationException
- * if the container data source does not implement
- * Container.Sortable
- * @see com.itmill.toolkit.data.Container.Sortable#sort(java.lang.Object[],
- * boolean[])
- *
- */
- public void sort(Object[] propertyId, boolean[] ascending)
- throws UnsupportedOperationException {
- Container c = getContainerDataSource();
- if (c instanceof Container.Sortable) {
- int pageIndex = this.getCurrentPageFirstItemIndex();
- ((Container.Sortable) c).sort(propertyId, ascending);
- setCurrentPageFirstItemIndex(pageIndex);
- } else if (c != null) {
- throw new UnsupportedOperationException(
- "Underlying Data does not allow sorting");
- }
- }
-
- /**
- * Sorts the table by currently selected sorting column.
- *
- * @throws UnsupportedOperationException
- * if the container data source does not implement
- * Container.Sortable
- */
- public void sort() {
- if (getSortContainerPropertyId() == null)
- return;
- sort(new Object[] { this.sortContainerPropertyId },
- new boolean[] { this.sortAscending });
- }
-
- /**
- * Gets the container property IDs, which can be used to sort the item.
- *
- * @see com.itmill.toolkit.data.Container.Sortable#getSortableContainerPropertyIds()
- */
- public Collection getSortableContainerPropertyIds() {
- Container c = getContainerDataSource();
- if (c instanceof Container.Sortable && !isSortDisabled()) {
- return ((Container.Sortable) c).getSortableContainerPropertyIds();
- } else {
- return new LinkedList();
- }
- }
-
- /**
- * Gets the currently sorted column property ID.
- *
- * @return the Container property id of the currently sorted column.
- */
- public Object getSortContainerPropertyId() {
- return this.sortContainerPropertyId;
- }
-
- /**
- * Sets the currently sorted column property id.
- *
- * @param propertyId
- * the Container property id of the currently sorted column.
- */
- public void setSortContainerPropertyId(Object propertyId) {
- if ((this.sortContainerPropertyId != null && !this.sortContainerPropertyId
- .equals(propertyId))
- || (this.sortContainerPropertyId == null && propertyId != null)) {
- this.sortContainerPropertyId = propertyId;
- sort();
- }
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Is the table currently sorted in ascending order.
- *
- * @return <code>true</code> if ascending, <code>false</code> if
- * descending.
- */
- public boolean isSortAscending() {
- return this.sortAscending;
- }
-
- /**
- * Sets the table in ascending order.
- *
- * @param ascending
- * <code>true</code> if ascending, <code>false</code> if
- * descending.
- */
- public void setSortAscending(boolean ascending) {
- if (this.sortAscending != ascending) {
- this.sortAscending = ascending;
- sort();
- }
-
- // Assures the visual refresh
- refreshCurrentPage();
- }
-
- /**
- * Is sorting disabled alltogether.
- *
- * True iff no sortable columns are given even in the case where datasource would support this.
- *
- * @return True iff sorting is disabled.
- */
- public boolean isSortDisabled() {
- return sortDisabled;
- }
-
-
- /**
- * Disables the sorting alltogether.
- *
- * To disable sorting alltogether, set to true. In this case no
- * sortable columns are given even in the case where datasource would support this.
- *
- * @param sortDisabled True iff sorting is disabled.
- */
- public void setSortDisabled(boolean sortDisabled) {
- if (this.sortDisabled != sortDisabled) {
- this.sortDisabled = sortDisabled;
- refreshCurrentPage();
- }
- }
+ /**
+ * Left column alignment. <b>This is the default behaviour. </b>
+ */
+ public static final String ALIGN_LEFT = "b";
+
+ /**
+ * Center column alignment.
+ */
+ public static final String ALIGN_CENTER = "c";
+
+ /**
+ * Right column alignment.
+ */
+ public static final String ALIGN_RIGHT = "e";
+
+ /**
+ * Column header mode: Column headers are hidden. <b>This is the default
+ * behaviour. </b>
+ */
+ public static final int COLUMN_HEADER_MODE_HIDDEN = -1;
+
+ /**
+ * Column header mode: Property ID:s are used as column headers.
+ */
+ public static final int COLUMN_HEADER_MODE_ID = 0;
+
+ /**
+ * Column header mode: Column headers are explicitly specified with
+ * <code>setColumnHeaders</code>.
+ */
+ public static final int COLUMN_HEADER_MODE_EXPLICIT = 1;
+
+ /**
+ * Column header mode: Column headers are explicitly specified with
+ * <code>setColumnHeaders</code>
+ */
+ public static final int COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID = 2;
+
+ /**
+ * Row caption mode: The row headers are hidden. <b>This is the default
+ * mode. </b>
+ */
+ public static final int ROW_HEADER_MODE_HIDDEN = -1;
+
+ /**
+ * Row caption mode: Items Id-objects toString is used as row caption.
+ */
+ public static final int ROW_HEADER_MODE_ID = Select.ITEM_CAPTION_MODE_ID;
+
+ /**
+ * Row caption mode: Item-objects toString is used as row caption.
+ */
+ public static final int ROW_HEADER_MODE_ITEM = Select.ITEM_CAPTION_MODE_ITEM;
+
+ /**
+ * Row caption mode: Index of the item is used as item caption. The index
+ * mode can only be used with the containers implementing Container.Indexed
+ * interface.
+ */
+ public static final int ROW_HEADER_MODE_INDEX = Select.ITEM_CAPTION_MODE_INDEX;
+
+ /**
+ * Row caption mode: Item captions are explicitly specified.
+ */
+ public static final int ROW_HEADER_MODE_EXPLICIT = Select.ITEM_CAPTION_MODE_EXPLICIT;
+
+ /**
+ * Row caption mode: Item captions are read from property specified with
+ * <code>setItemCaptionPropertyId</code>.
+ */
+ public static final int ROW_HEADER_MODE_PROPERTY = Select.ITEM_CAPTION_MODE_PROPERTY;
+
+ /**
+ * Row caption mode: Only icons are shown, the captions are hidden.
+ */
+ public static final int ROW_HEADER_MODE_ICON_ONLY = Select.ITEM_CAPTION_MODE_ICON_ONLY;
+
+ /**
+ * Row caption mode: Item captions are explicitly specified, but if the
+ * caption is missing, the item id objects <code>toString()</code> is used
+ * instead.
+ */
+ public static final int ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID = Select.ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID;
+
+ /* Private table extensions to Select *********************************** */
+
+ /**
+ * True if column collapsing is allowed.
+ */
+ private boolean columnCollapsingAllowed = false;
+
+ /**
+ * True if reordering of columns is allowed on the client side.
+ */
+ private boolean columnReorderingAllowed = false;
+
+ /**
+ * Keymapper for column ids.
+ */
+ private KeyMapper columnIdMap = new KeyMapper();
+
+ /**
+ * Holds visible column propertyIds - in order.
+ */
+ private LinkedList visibleColumns = new LinkedList();
+
+ /**
+ * Holds propertyIds of currently collapsed columns.
+ */
+ private HashSet collapsedColumns = new HashSet();
+
+ /**
+ * Holds headers for visible columns (by propertyId).
+ */
+ private HashMap columnHeaders = new HashMap();
+
+ /**
+ * Holds icons for visible columns (by propertyId).
+ */
+ private HashMap columnIcons = new HashMap();
+
+ /**
+ * Holds alignments for visible columns (by propertyId).
+ */
+ private HashMap columnAlignments = new HashMap();
+
+ /**
+ * Holds value of property pageLength. 0 disables paging.
+ */
+ private int pageLength = 15;
+
+ /**
+ * Id the first item on the current page.
+ */
+ private Object currentPageFirstItemId = null;
+
+ /**
+ * Index of the first item on the current page.
+ */
+ private int currentPageFirstItemIndex = 0;
+
+ /**
+ * Holds value of property pageBuffering.
+ */
+ private boolean pageBuffering = false;
+
+ /**
+ * Holds value of property selectable.
+ */
+ private boolean selectable = false;
+
+ /**
+ * Holds value of property columnHeaderMode.
+ */
+ private int columnHeaderMode = COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID;
+
+ /**
+ * True iff the row captions are hidden.
+ */
+ private boolean rowCaptionsAreHidden = true;
+
+ /**
+ * Page contents buffer used in buffered mode.
+ */
+ private Object[][] pageBuffer = null;
+
+ /**
+ * List of properties listened - the list is kept to release the listeners
+ * later.
+ */
+ private LinkedList listenedProperties = null;
+
+ /**
+ * List of visible components - the is used for needsRepaint calculation.
+ */
+ private LinkedList visibleComponents = null;
+
+ /**
+ * List of action handlers.
+ */
+ private LinkedList actionHandlers = null;
+
+ /**
+ * Action mapper.
+ */
+ private KeyMapper actionMapper = null;
+
+ /**
+ * Table cell editor factory.
+ */
+ private FieldFactory fieldFactory = new BaseFieldFactory();
+
+ /**
+ * Is table editable.
+ */
+ private boolean editable = false;
+
+ /**
+ * Current sorting direction.
+ */
+ private boolean sortAscending = true;
+
+ /**
+ * Currently table is sorted on this propertyId.
+ */
+ private Object sortContainerPropertyId = null;
+
+ /**
+ * Is table sorting disabled alltogether; even if some of the properties
+ * would be sortable.
+ */
+ private boolean sortDisabled = false;
+
+ /**
+ * Number of rows explicitly requested by the client to be painted on next
+ * paint. This is -1 if no request by the client is made. Painting the
+ * component will automatically reset this to -1.
+ */
+ private int reqRowsToPaint = -1;
+
+ /**
+ * Index of the first rows explicitly requested by the client to be painted.
+ * This is -1 if no request by the client is made. Painting the component
+ * will automatically reset this to -1.
+ */
+ private int reqFirstRowToPaint = -1;
+
+ /* Table constructors *************************************************** */
+
+ /**
+ * Creates a new empty table.
+ */
+ public Table() {
+ setRowHeaderMode(ROW_HEADER_MODE_HIDDEN);
+ }
+
+ /**
+ * Creates a new empty table with caption.
+ *
+ * @param caption
+ */
+ public Table(String caption) {
+ this();
+ setCaption(caption);
+ }
+
+ /**
+ * Creates a new table with caption and connect it to a Container.
+ *
+ * @param caption
+ * @param dataSource
+ */
+ public Table(String caption, Container dataSource) {
+ this();
+ setCaption(caption);
+ setContainerDataSource(dataSource);
+ }
+
+ /* Table functionality ************************************************** */
+
+ /**
+ * Gets the array of visible column property id:s.
+ *
+ * <p>
+ * The columns are show in the order of their appearance in this array.
+ * </p>
+ *
+ * @return the Value of property availableColumns.
+ */
+ public Object[] getVisibleColumns() {
+ if (this.visibleColumns == null) {
+ return null;
+ }
+ return this.visibleColumns.toArray();
+ }
+
+ /**
+ * Sets the array of visible column property id:s.
+ *
+ * <p>
+ * The columns are show in the order of their appearance in this array.
+ * </p>
+ *
+ * @param visibleColumns
+ * the Array of shown property id:s.
+ */
+ public void setVisibleColumns(Object[] visibleColumns) {
+
+ // Visible columns must exist
+ if (visibleColumns == null)
+ throw new NullPointerException(
+ "Can not set visible columns to null value");
+
+ // Checks that the new visible columns contains no nulls and properties
+ // exist
+ Collection properties = getContainerPropertyIds();
+ for (int i = 0; i < visibleColumns.length; i++) {
+ if (visibleColumns[i] == null)
+ throw new NullPointerException("Properties must be non-nulls");
+ else if (!properties.contains(visibleColumns[i]))
+ throw new IllegalArgumentException(
+ "Properties must exist in the Container, missing property: "
+ + visibleColumns[i]);
+ }
+
+ // If this is called befor the constructor is finished, it might be
+ // uninitialized
+ 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();
+ if (!newVC.contains(col)) {
+ setColumnHeader(col, null);
+ setColumnAlignment(col, null);
+ setColumnIcon(col, null);
+ }
+ }
+
+ this.visibleColumns = newVC;
+
+ // Assures visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Gets the headers of the columns.
+ *
+ * <p>
+ * The headers match the property id:s given my the set visible column
+ * headers. The table must be set in either
+ * <code>ROW_HEADER_MODE_EXPLICIT</code> or
+ * <code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code> mode to show the
+ * headers. In the defaults mode any nulls in the headers array are replaced
+ * with id.toString() outputs when rendering.
+ * </p>
+ *
+ * @return the Array of column headers.
+ */
+ public String[] getColumnHeaders() {
+ if (this.columnHeaders == null) {
+ return null;
+ }
+ String[] headers = new String[this.visibleColumns.size()];
+ int i = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); i++) {
+ headers[i] = (String) this.columnHeaders.get(it.next());
+ }
+ return headers;
+ }
+
+ /**
+ * Sets the headers of the columns.
+ *
+ * <p>
+ * The headers match the property id:s given my the set visible column
+ * headers. The table must be set in either
+ * <code>ROW_HEADER_MODE_EXPLICIT</code> or
+ * <code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code> mode to show the
+ * headers. In the defaults mode any nulls in the headers array are replaced
+ * with id.toString() outputs when rendering.
+ * </p>
+ *
+ * @param columnHeaders
+ * the Array of column headers that match the
+ * <code>getVisibleColumns</code> method.
+ */
+ public void setColumnHeaders(String[] columnHeaders) {
+
+ if (columnHeaders.length != this.visibleColumns.size())
+ throw new IllegalArgumentException(
+ "The length of the headers array must match the number of visible columns");
+
+ this.columnHeaders.clear();
+ int i = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
+ && i < columnHeaders.length; i++) {
+ this.columnHeaders.put(it.next(), columnHeaders[i]);
+ }
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Gets the icons of the columns.
+ *
+ * <p>
+ * The icons in headers match the property id:s given my the set visible
+ * column headers. The table must be set in either
+ * <code>ROW_HEADER_MODE_EXPLICIT</code> or
+ * <code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code> mode to show the
+ * headers with icons.
+ * </p>
+ *
+ * @return the Array of icons that match the <code>getVisibleColumns</code>.
+ */
+ public Resource[] getColumnIcons() {
+ if (this.columnIcons == null) {
+ return null;
+ }
+ Resource[] icons = new Resource[this.visibleColumns.size()];
+ int i = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); i++) {
+ icons[i] = (Resource) this.columnIcons.get(it.next());
+ }
+
+ return icons;
+ }
+
+ /**
+ * Sets the icons of the columns.
+ *
+ * <p>
+ * The icons in headers match the property id:s given my the set visible
+ * column headers. The table must be set in either
+ * <code>ROW_HEADER_MODE_EXPLICIT</code> or
+ * <code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code> mode to show the
+ * headers with icons.
+ * </p>
+ *
+ * @param columnIcons
+ * the Array of icons that match the
+ * <code>getVisibleColumns</code>.
+ */
+ public void setColumnIcons(Resource[] columnIcons) {
+
+ if (columnIcons.length != this.visibleColumns.size())
+ throw new IllegalArgumentException(
+ "The length of the icons array must match the number of visible columns");
+
+ this.columnIcons.clear();
+ int i = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
+ && i < columnIcons.length; i++) {
+ this.columnIcons.put(it.next(), columnIcons[i]);
+ }
+
+ // Assure visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Gets the array of column alignments.
+ *
+ * <p>
+ * The items in the array must match the properties identified by
+ * <code>getVisibleColumns()</code>. The possible values for the
+ * alignments include:
+ * <ul>
+ * <li><code>ALIGN_LEFT</code>: Left alignment</li>
+ * <li><code>ALIGN_CENTER</code>: Centered</li>
+ * <li><code>ALIGN_RIGHT</code>: Right alignment</li>
+ * </ul>
+ * The alignments default to <code>ALIGN_LEFT</code>: any null values are
+ * rendered as align lefts.
+ * </p>
+ *
+ * @return the Column alignments array.
+ */
+ public String[] getColumnAlignments() {
+ if (this.columnAlignments == null) {
+ return null;
+ }
+ String[] alignments = new String[this.visibleColumns.size()];
+ int i = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); i++) {
+ alignments[i++] = getColumnAlignment(it.next());
+ }
+
+ return alignments;
+ }
+
+ /**
+ * Sets the column alignments.
+ *
+ * <p>
+ * The items in the array must match the properties identified by
+ * <code>getVisibleColumns()</code>. The possible values for the
+ * alignments include:
+ * <ul>
+ * <li><code>ALIGN_LEFT</code>: Left alignment</li>
+ * <li><code>ALIGN_CENTER</code>: Centered</li>
+ * <li><code>ALIGN_RIGHT</code>: Right alignment</li>
+ * </ul>
+ * The alignments default to <code>ALIGN_LEFT</code>
+ * </p>
+ *
+ * @param columnAlignments
+ * the Column alignments array.
+ */
+ public void setColumnAlignments(String[] columnAlignments) {
+
+ if (columnAlignments.length != this.visibleColumns.size())
+ throw new IllegalArgumentException(
+ "The length of the alignments array must match the number of visible columns");
+
+ // Checks all alignments
+ for (int i = 0; i < columnAlignments.length; i++) {
+ String a = columnAlignments[i];
+ if (a != null && !a.equals(ALIGN_LEFT) && !a.equals(ALIGN_CENTER)
+ && !a.equals(ALIGN_RIGHT))
+ throw new IllegalArgumentException("Column " + i
+ + " aligment '" + a + "' is invalid");
+ }
+
+ // Resets the alignments
+ HashMap newCA = new HashMap();
+ int i = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
+ && i < columnAlignments.length; i++) {
+ newCA.put(it.next(), columnAlignments[i]);
+ }
+ this.columnAlignments = newCA;
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Gets the page length.
+ *
+ * <p>
+ * Setting page length 0 disables paging.
+ * </p>
+ *
+ * @return the Length of one page.
+ */
+ public int getPageLength() {
+ return this.pageLength;
+ }
+
+ /**
+ * Sets the page length.
+ *
+ * <p>
+ * Setting page length 0 disables paging. The page length defaults to 15.
+ * </p>
+ *
+ * @param pageLength
+ * the Length of one page.
+ */
+ public void setPageLength(int pageLength) {
+ if (pageLength >= 0 && this.pageLength != pageLength) {
+ this.pageLength = pageLength;
+ // "scroll" to first row
+ this.setCurrentPageFirstItemIndex(0);
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+ }
+
+ /**
+ * Getter for property currentPageFirstItem.
+ *
+ * @return the Value of property currentPageFirstItem.
+ */
+ public Object getCurrentPageFirstItemId() {
+
+ // Priorise index over id if indexes are supported
+ if (items instanceof Container.Indexed) {
+ int index = getCurrentPageFirstItemIndex();
+ Object id = null;
+ if (index >= 0 && index < size())
+ id = ((Container.Indexed) items).getIdByIndex(index);
+ if (id != null && !id.equals(currentPageFirstItemId))
+ currentPageFirstItemId = id;
+ }
+
+ // If there is no item id at all, use the first one
+ if (currentPageFirstItemId == null)
+ currentPageFirstItemId = ((Container.Ordered) items).firstItemId();
+
+ return currentPageFirstItemId;
+ }
+
+ /**
+ * Setter for property currentPageFirstItemId.
+ *
+ * @param currentPageFirstItemId
+ * the New value of property currentPageFirstItemId.
+ */
+ public void setCurrentPageFirstItemId(Object currentPageFirstItemId) {
+
+ // Gets the corresponding index
+ int index = -1;
+ try {
+ index = ((Container.Indexed) items)
+ .indexOfId(currentPageFirstItemId);
+ } catch (ClassCastException e) {
+
+ // If the table item container does not have index, we have to
+ // calculates the index by hand
+ Object id = ((Container.Ordered) items).firstItemId();
+ while (id != null && !id.equals(currentPageFirstItemId)) {
+ index++;
+ id = ((Container.Ordered) items).nextItemId(id);
+ }
+ if (id == null)
+ index = -1;
+ }
+
+ // If the search for item index was successfull
+ if (index >= 0) {
+ this.currentPageFirstItemId = currentPageFirstItemId;
+ this.currentPageFirstItemIndex = index;
+ }
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+
+ }
+
+ /**
+ * Gets the icon Resource for the specified column.
+ *
+ * @param propertyId
+ * the propertyId indentifying the column.
+ * @return the icon for the specified column; null if the column has no icon
+ * set, or if the column is not visible.
+ */
+ public Resource getColumnIcon(Object propertyId) {
+ return (Resource) this.columnIcons.get(propertyId);
+ }
+
+ /**
+ * Sets the icon Resource for the specified column.
+ * <p>
+ * Throws IllegalArgumentException if the specified column is not visible.
+ * </p>
+ *
+ * @param propertyId
+ * the propertyId identifying the column.
+ * @param icon
+ * the icon Resource to set.
+ */
+ public void setColumnIcon(Object propertyId, Resource icon) {
+
+ if (icon == null)
+ this.columnIcons.remove(propertyId);
+ else
+ this.columnIcons.put(propertyId, icon);
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Gets the header for the specified column.
+ *
+ * @param propertyId
+ * the propertyId indentifying the column.
+ * @return the header for the specifed column if it has one.
+ */
+ public String getColumnHeader(Object propertyId) {
+ if (getColumnHeaderMode() == COLUMN_HEADER_MODE_HIDDEN)
+ return null;
+
+ String header = (String) this.columnHeaders.get(propertyId);
+ if ((header == null && this.getColumnHeaderMode() == COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID)
+ || this.getColumnHeaderMode() == COLUMN_HEADER_MODE_ID) {
+ header = propertyId.toString();
+ }
+
+ return header;
+ }
+
+ /**
+ * Sets the column header for the specified column;
+ *
+ * @param propertyId
+ * the propertyId indentifying the column.
+ * @param header
+ * the header to set.
+ */
+ public void setColumnHeader(Object propertyId, String header) {
+
+ if (header == null) {
+ this.columnHeaders.remove(propertyId);
+ return;
+ }
+ this.columnHeaders.put(propertyId, header);
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Gets the specified column's alignment.
+ *
+ * @param propertyId
+ * the propertyID identifying the column.
+ * @return the specified column's alignment if it as one; null otherwise.
+ */
+ public String getColumnAlignment(Object propertyId) {
+ String a = (String) this.columnAlignments.get(propertyId);
+ return a == null ? ALIGN_LEFT : a;
+ }
+
+ /**
+ * Sets the specified column's alignment.
+ *
+ * <p>
+ * Throws IllegalArgumentException if the alignment is not one of the
+ * following: ALIGN_LEFT, ALIGN_CENTER or ALIGN_RIGHT
+ * </p>
+ *
+ * @param propertyId
+ * the propertyID identifying the column.
+ * @param alignment
+ * the desired alignment.
+ */
+ public void setColumnAlignment(Object propertyId, String alignment) {
+
+ // Checks for valid alignments
+ if (alignment != null && !alignment.equals(ALIGN_LEFT)
+ && !alignment.equals(ALIGN_CENTER)
+ && !alignment.equals(ALIGN_RIGHT))
+ throw new IllegalArgumentException("Column alignment '" + alignment
+ + "' is not supported.");
+
+ if (alignment == null || alignment.equals(ALIGN_LEFT)) {
+ this.columnAlignments.remove(propertyId);
+ return;
+ }
+
+ this.columnAlignments.put(propertyId, alignment);
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Checks if the specified column is collapsed.
+ *
+ * @param propertyId
+ * the propertyID identifying the column.
+ * @return true if the column is collapsed; false otherwise;
+ */
+ public boolean isColumnCollapsed(Object propertyId) {
+ return collapsedColumns != null
+ && collapsedColumns.contains(propertyId);
+ }
+
+ /**
+ * Sets whether the specified column is collapsed or not.
+ *
+ *
+ * @param propertyId
+ * the propertyID identifying the column.
+ * @param collapsed
+ * the desired collapsedness.
+ * @throws IllegalAccessException
+ */
+ public void setColumnCollapsed(Object propertyId, boolean collapsed)
+ throws IllegalAccessException {
+ if (!this.isColumnCollapsingAllowed()) {
+ throw new IllegalAccessException("Column collapsing not allowed!");
+ }
+
+ if (collapsed)
+ this.collapsedColumns.add(propertyId);
+ else
+ this.collapsedColumns.remove(propertyId);
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Checks if column collapsing is allowed.
+ *
+ * @return true if columns can be collapsed; false otherwise.
+ */
+ public boolean isColumnCollapsingAllowed() {
+ return this.columnCollapsingAllowed;
+ }
+
+ /**
+ * Sets whether column collapsing is allowed or not.
+ *
+ * @param collapsingAllowed
+ * specifies whether column collapsing is allowed.
+ */
+ public void setColumnCollapsingAllowed(boolean collapsingAllowed) {
+ this.columnCollapsingAllowed = collapsingAllowed;
+
+ if (!collapsingAllowed)
+ collapsedColumns.clear();
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Checks if column reordering is allowed.
+ *
+ * @return true if columns can be reordered; false otherwise.
+ */
+ public boolean isColumnReorderingAllowed() {
+ return this.columnReorderingAllowed;
+ }
+
+ /**
+ * Sets whether column reordering is allowed or not.
+ *
+ * @param reorderingAllowed
+ * specifies whether column reordering is allowed.
+ */
+ public void setColumnReorderingAllowed(boolean reorderingAllowed) {
+ this.columnReorderingAllowed = reorderingAllowed;
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /*
+ * Arranges visible columns according to given columnOrder. Silently ignores
+ * colimnId:s that are not visible columns, and keeps the internal order of
+ * visible columns left out of the ordering (trailing). Silently does
+ * nothing if columnReordering is not allowed.
+ */
+ private void setColumnOrder(Object[] columnOrder) {
+ if (columnOrder == null || !this.isColumnReorderingAllowed()) {
+ return;
+ }
+ LinkedList newOrder = new LinkedList();
+ for (int i = 0; i < columnOrder.length; i++) {
+ if (columnOrder[i] != null
+ && this.visibleColumns.contains(columnOrder[i])) {
+ this.visibleColumns.remove(columnOrder[i]);
+ newOrder.add(columnOrder[i]);
+ }
+ }
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext();) {
+ Object columnId = it.next();
+ if (!newOrder.contains(columnId))
+ newOrder.add(columnId);
+ }
+ this.visibleColumns = newOrder;
+
+ // Assure visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Getter for property currentPageFirstItem.
+ *
+ * @return the Value of property currentPageFirstItem.
+ */
+ public int getCurrentPageFirstItemIndex() {
+ return this.currentPageFirstItemIndex;
+ }
+
+ /**
+ * Setter for property currentPageFirstItem.
+ *
+ * @param newIndex
+ * the New value of property currentPageFirstItem.
+ */
+ public void setCurrentPageFirstItemIndex(int newIndex) {
+
+ // Ensures that the new value is valid
+ if (newIndex < 0)
+ newIndex = 0;
+ if (newIndex >= size())
+ newIndex = size() - 1;
+
+ // Refresh first item id
+ if (items instanceof Container.Indexed) {
+ try {
+ currentPageFirstItemId = ((Container.Indexed) items)
+ .getIdByIndex(newIndex);
+ } catch (IndexOutOfBoundsException e) {
+ currentPageFirstItemId = null;
+ }
+ this.currentPageFirstItemIndex = newIndex;
+ } else {
+
+ // For containers not supporting indexes, we must iterate the
+ // container forwards / backwards
+ // next available item forward or backward
+
+ this.currentPageFirstItemId = ((Container.Ordered) items)
+ .firstItemId();
+
+ // Go forwards in the middle of the list (respect borders)
+ while (this.currentPageFirstItemIndex < newIndex
+ && !((Container.Ordered) items)
+ .isLastId(currentPageFirstItemId)) {
+ this.currentPageFirstItemIndex++;
+ currentPageFirstItemId = ((Container.Ordered) items)
+ .nextItemId(currentPageFirstItemId);
+ }
+
+ // If we did hit the border
+ if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) {
+ this.currentPageFirstItemIndex = size() - 1;
+ }
+
+ // Go backwards in the middle of the list (respect borders)
+ while (this.currentPageFirstItemIndex > newIndex
+ && !((Container.Ordered) items)
+ .isFirstId(currentPageFirstItemId)) {
+ this.currentPageFirstItemIndex--;
+ currentPageFirstItemId = ((Container.Ordered) items)
+ .prevItemId(currentPageFirstItemId);
+ }
+
+ // If we did hit the border
+ if (((Container.Ordered) items).isFirstId(currentPageFirstItemId)) {
+ this.currentPageFirstItemIndex = 0;
+ }
+
+ // Go forwards once more
+ while (this.currentPageFirstItemIndex < newIndex
+ && !((Container.Ordered) items)
+ .isLastId(currentPageFirstItemId)) {
+ this.currentPageFirstItemIndex++;
+ currentPageFirstItemId = ((Container.Ordered) items)
+ .nextItemId(currentPageFirstItemId);
+ }
+
+ // If for some reason we do hit border again, override
+ // the user index request
+ if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) {
+ newIndex = this.currentPageFirstItemIndex = size() - 1;
+ }
+ }
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Getter for property pageBuffering.
+ *
+ * @return the Value of property pageBuffering.
+ */
+ public boolean isPageBufferingEnabled() {
+ return this.pageBuffering;
+ }
+
+ /**
+ * Setter for property pageBuffering.
+ *
+ * @param pageBuffering
+ * the New value of property pageBuffering.
+ */
+ public void setPageBufferingEnabled(boolean pageBuffering) {
+
+ this.pageBuffering = pageBuffering;
+
+ // If page buffering is disabled, clear the buffer
+ if (!pageBuffering)
+ pageBuffer = null;
+ }
+
+ /**
+ * Getter for property selectable.
+ *
+ * <p>
+ * The table is not selectable by default.
+ * </p>
+ *
+ * @return the Value of property selectable.
+ */
+ public boolean isSelectable() {
+ return this.selectable;
+ }
+
+ /**
+ * Setter for property selectable.
+ *
+ * <p>
+ * The table is not selectable by default.
+ * </p>
+ *
+ * @param selectable
+ * the New value of property selectable.
+ */
+ public void setSelectable(boolean selectable) {
+ if (this.selectable != selectable) {
+ this.selectable = selectable;
+ requestRepaint();
+ }
+ }
+
+ /**
+ * Getter for property columnHeaderMode.
+ *
+ * @return the Value of property columnHeaderMode.
+ */
+ public int getColumnHeaderMode() {
+ return this.columnHeaderMode;
+ }
+
+ /**
+ * Setter for property columnHeaderMode.
+ *
+ * @param columnHeaderMode
+ * the New value of property columnHeaderMode.
+ */
+ public void setColumnHeaderMode(int columnHeaderMode) {
+ if (columnHeaderMode >= COLUMN_HEADER_MODE_HIDDEN
+ && columnHeaderMode <= COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID)
+ this.columnHeaderMode = columnHeaderMode;
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Refreshes the current page contents. If the page buffering is turned off,
+ * it is not necessary to call this explicitely.
+ */
+ public void refreshCurrentPage() {
+
+ // Clear page buffer and notify about the change
+ pageBuffer = null;
+ requestRepaint();
+ }
+
+ /**
+ * Sets the row header mode.
+ * <p>
+ * The mode can be one of the following ones:
+ * <ul>
+ * <li><code>ROW_HEADER_MODE_HIDDEN</code>: The row captions are hidden.
+ * </li>
+ * <li><code>ROW_HEADER_MODE_ID</code>: Items Id-objects
+ * <code>toString()</code> is used as row caption.
+ * <li><code>ROW_HEADER_MODE_ITEM</code>: Item-objects
+ * <code>toString()</code> is used as row caption.
+ * <li><code>ROW_HEADER_MODE_PROPERTY</code>: Property set with
+ * <code>setItemCaptionPropertyId()</code> is used as row header.
+ * <li><code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code>: Items
+ * Id-objects <code>toString()</code> is used as row header. If caption is
+ * explicitly specified, it overrides the id-caption.
+ * <li><code>ROW_HEADER_MODE_EXPLICIT</code>: The row headers must be
+ * explicitly specified.</li>
+ * <li><code>ROW_HEADER_MODE_INDEX</code>: The index of the item is used
+ * as row caption. The index mode can only be used with the containers
+ * implementing <code>Container.Indexed</code> interface.</li>
+ * </ul>
+ * The default value is <code>ROW_HEADER_MODE_HIDDEN</code>
+ * </p>
+ *
+ * @param mode
+ * the One of the modes listed above.
+ */
+ public void setRowHeaderMode(int mode) {
+ if (ROW_HEADER_MODE_HIDDEN == mode)
+ rowCaptionsAreHidden = true;
+ else {
+ rowCaptionsAreHidden = false;
+ setItemCaptionMode(mode);
+ }
+
+ // Assure visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Gets the row header mode.
+ *
+ * @return the Row header mode.
+ * @see #setRowHeaderMode(int)
+ */
+ public int getRowHeaderMode() {
+ return rowCaptionsAreHidden ? ROW_HEADER_MODE_HIDDEN
+ : getItemCaptionMode();
+ }
+
+ /**
+ * Adds the new row to table and fill the visible cells with given values.
+ *
+ * @param cells
+ * the Object array that is used for filling the visible cells
+ * new row. The types must be settable to visible column property
+ * types.
+ * @param itemId
+ * the Id the new row. If null, a new id is automatically
+ * assigned. If given, the table cant already have a item with
+ * given id.
+ * @return Returns item id for the new row. Returns null if operation fails.
+ */
+ public Object addItem(Object[] cells, Object itemId)
+ throws UnsupportedOperationException {
+
+ Object[] cols = getVisibleColumns();
+
+ // Checks that a correct number of cells are given
+ if (cells.length != cols.length)
+ return null;
+
+ // Creates new item
+ Item item;
+ if (itemId == null) {
+ itemId = items.addItem();
+ if (itemId == null)
+ return null;
+ item = items.getItem(itemId);
+ } else
+ item = items.addItem(itemId);
+ if (item == null)
+ return null;
+
+ // Fills the item properties
+ for (int i = 0; i < cols.length; i++)
+ item.getItemProperty(cols[i]).setValue(cells[i]);
+
+ return itemId;
+ }
+
+ /* Overriding select behavior******************************************** */
+
+ /**
+ * Sets the Container that serves as the data source of the viewer.
+ *
+ * @see com.itmill.toolkit.data.Container.Viewer#setContainerDataSource(Container)
+ */
+ public void setContainerDataSource(Container newDataSource) {
+
+ if (newDataSource == null)
+ newDataSource = new IndexedContainer();
+
+ // Assures that the data source is ordered by making unordered
+ // containers ordered by wrapping them
+ if (newDataSource instanceof Container.Ordered)
+ super.setContainerDataSource(newDataSource);
+ else
+ super.setContainerDataSource(new ContainerOrderedWrapper(
+ newDataSource));
+
+ // Resets page position
+ currentPageFirstItemId = null;
+ currentPageFirstItemIndex = 0;
+
+ // Resets column properties
+ if (this.collapsedColumns != null)
+ this.collapsedColumns.clear();
+ setVisibleColumns(getContainerPropertyIds().toArray());
+
+ // Assure visual refresh
+ refreshCurrentPage();
+ }
+
+ /* Component basics ***************************************************** */
+
+ /**
+ * Invoked when the value of a variable has changed.
+ *
+ * @see com.itmill.toolkit.ui.Select#changeVariables(java.lang.Object,
+ * java.util.Map)
+ */
+ public void changeVariables(Object source, Map variables) {
+
+ super.changeVariables(source, variables);
+
+ // Page start index
+ if (variables.containsKey("firstvisible")) {
+ Integer value = (Integer) variables.get("firstvisible");
+ if (value != null)
+ setCurrentPageFirstItemIndex(value.intValue() - 1);
+ }
+
+ // Sets requested firstrow and rows for the next paint
+ if (variables.containsKey("reqfirstrow")
+ || variables.containsKey("reqrows")) {
+ Integer value = (Integer) variables.get("reqfirstrow");
+ if (value != null)
+ reqFirstRowToPaint = value.intValue() - 1;
+ value = (Integer) variables.get("reqrows");
+ if (value != null)
+ reqRowsToPaint = value.intValue();
+ pageBuffer = null;
+ requestRepaint();
+ }
+
+ // Actions
+ if (variables.containsKey("action")) {
+ 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());
+ if (action != null && containsId(itemId)
+ && actionHandlers != null)
+ for (Iterator i = actionHandlers.iterator(); i.hasNext();)
+ ((Action.Handler) i.next()).handleAction(action, this,
+ itemId);
+ }
+ }
+
+ // Sorting
+ boolean doSort = false;
+ if (variables.containsKey("sortcolumn")) {
+ String colId = (String) variables.get("sortcolumn");
+ if (colId != null && !"".equals(colId) && !"null".equals(colId)) {
+ Object id = this.columnIdMap.get(colId);
+ setSortContainerPropertyId(id);
+ doSort = true;
+ }
+ }
+ if (variables.containsKey("sortascending")) {
+ boolean state = ((Boolean) variables.get("sortascending"))
+ .booleanValue();
+ if (state != this.sortAscending) {
+ setSortAscending(state);
+ doSort = true;
+ }
+ }
+ if (doSort)
+ this.sort();
+
+ // Dynamic column hide/show and order
+ // Update visible columns
+ if (this.isColumnCollapsingAllowed()) {
+ if (variables.containsKey("collapsedcolumns")) {
+ try {
+ Object[] ids = (Object[]) variables.get("collapsedcolumns");
+ for (Iterator it = this.visibleColumns.iterator(); it
+ .hasNext();) {
+ this.setColumnCollapsed(it.next(), false);
+ }
+ for (int i = 0; i < ids.length; i++) {
+ this.setColumnCollapsed(columnIdMap.get(ids[i]
+ .toString()), true);
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ if (this.isColumnReorderingAllowed()) {
+ if (variables.containsKey("columnorder")) {
+ try {
+ Object[] ids = (Object[]) variables.get("columnorder");
+ for (int i = 0; i < ids.length; i++) {
+ ids[i] = columnIdMap.get(ids[i].toString());
+ }
+ this.setColumnOrder(ids);
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+
+ /**
+ * Paints the content of this component.
+ *
+ * @param target
+ * the Paint target.
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void paintContent(PaintTarget target) throws PaintException {
+
+ // Focus control id
+ if (this.getFocusableId() > 0) {
+ target.addAttribute("focusid", this.getFocusableId());
+ }
+
+ // The tab ordering number
+ if (this.getTabIndex() > 0)
+ target.addAttribute("tabindex", this.getTabIndex());
+
+ // Size
+ if (getHeight() >= 0)
+ target.addAttribute("height", "" + getHeight()
+ + Sizeable.UNIT_SYMBOLS[getHeightUnits()]);
+ if (getWidth() >= 0)
+ target.addAttribute("width", "" + getWidth()
+ + Sizeable.UNIT_SYMBOLS[getWidthUnits()]);
+
+ // Initialize temps
+ Object[] colids = getVisibleColumns();
+ int cols = colids.length;
+ 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 = this.isEditable();
+
+ // selection support
+ String[] selectedKeys;
+ if (isMultiSelect())
+ selectedKeys = new String[((Set) getValue()).size()];
+ else
+ selectedKeys = new String[(getValue() == null
+ && getNullSelectionItemId() == null ? 0 : 1)];
+ int keyIndex = 0;
+
+ // Table attributes
+ if (isSelectable())
+ target.addAttribute("selectmode", (isMultiSelect() ? "multi"
+ : "single"));
+ else
+ target.addAttribute("selectmode", "none");
+ target.addAttribute("cols", cols);
+ target.addAttribute("rows", cells[0].length);
+ target.addAttribute("firstrow",
+ (reqFirstRowToPaint >= 0 ? reqFirstRowToPaint : first) + 1);
+ target.addAttribute("totalrows", total);
+ if (pagelen != 0)
+ target.addAttribute("pagelength", pagelen);
+ if (colheads)
+ target.addAttribute("colheaders", true);
+ if (rowheads)
+ target.addAttribute("rowheaders", true);
+
+ // Columns
+ target.startTag("cols");
+ Collection sortables = getSortableContainerPropertyIds();
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext();) {
+ Object columnId = it.next();
+ if (!isColumnCollapsed(columnId)) {
+ target.startTag("ch");
+ if (colheads) {
+ if (this.getColumnIcon(columnId) != null)
+ target.addAttribute("icon", this
+ .getColumnIcon(columnId));
+ if (sortables.contains(columnId))
+ target.addAttribute("sortable", true);
+ String header = (String) this.getColumnHeader(columnId);
+ target.addAttribute("caption", (header != null ? header
+ : ""));
+ }
+ target.addAttribute("cid", this.columnIdMap.key(columnId));
+ if (!ALIGN_LEFT.equals(this.getColumnAlignment(columnId)))
+ target.addAttribute("align", this
+ .getColumnAlignment(columnId));
+ target.endTag("ch");
+ }
+ }
+ target.endTag("cols");
+
+ // Rows
+ Set actionSet = new LinkedHashSet();
+ boolean selectable = isSelectable();
+ boolean[] iscomponent = new boolean[this.visibleColumns.size()];
+ int iscomponentIndex = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
+ && iscomponentIndex < iscomponent.length;) {
+ Object columnId = it.next();
+ Class colType = getType(columnId);
+ iscomponent[iscomponentIndex++] = colType != null
+ && Component.class.isAssignableFrom(colType);
+ }
+ target.startTag("rows");
+ for (int i = 0; i < cells[0].length; i++) {
+ target.startTag("tr");
+ Object itemId = cells[CELL_ITEMID][i];
+
+ // tr attributes
+ if (rowheads) {
+ if (cells[CELL_ICON][i] != null)
+ target.addAttribute("icon", (Resource) cells[CELL_ICON][i]);
+ if (cells[CELL_HEADER][i] != null)
+ target.addAttribute("caption",
+ (String) cells[CELL_HEADER][i]);
+ }
+ if (actionHandlers != null || isSelectable()) {
+ target.addAttribute("key", (String) cells[CELL_KEY][i]);
+ if (isSelected(itemId) && keyIndex < selectedKeys.length) {
+ target.addAttribute("selected", true);
+ selectedKeys[keyIndex++] = (String) cells[CELL_KEY][i];
+ }
+ }
+
+ // Actions
+ if (actionHandlers != null) {
+ target.startTag("al");
+ for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) {
+ 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]);
+ actionSet.add(aa[ai]);
+ target.addSection("ak", key);
+ }
+ }
+ target.endTag("al");
+ }
+
+ // cells
+ int currentColumn = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); currentColumn++) {
+ Object columnId = it.next();
+ if (columnId == null || this.isColumnCollapsed(columnId))
+ continue;
+ if ((iscomponent[currentColumn] || iseditable)
+ && Component.class.isInstance(cells[CELL_FIRSTCOL
+ + currentColumn][i])) {
+ Component c = (Component) cells[CELL_FIRSTCOL
+ + currentColumn][i];
+ if (c == null)
+ target.addSection("label", "");
+ else
+ c.paint(target);
+ } else
+ target.addSection("label", (String) cells[CELL_FIRSTCOL
+ + currentColumn][i]);
+ }
+
+ target.endTag("tr");
+ }
+ target.endTag("rows");
+
+ // The select variable is only enabled if selectable
+ if (selectable)
+ target.addVariable(this, "selected", selectedKeys);
+
+ // The cursors are only shown on pageable table
+ if (first != 0 || getPageLength() > 0)
+ target.addVariable(this, "firstvisible", first + 1);
+
+ // Sorting
+ if (getContainerDataSource() instanceof Container.Sortable) {
+ target.addVariable(this, "sortcolumn", this.columnIdMap
+ .key(this.sortContainerPropertyId));
+ target.addVariable(this, "sortascending", this.sortAscending);
+ }
+
+ // Resets and paints "to be painted next" variables. Also reset
+ // pageBuffer
+ reqFirstRowToPaint = -1;
+ reqRowsToPaint = -1;
+ pageBuffer = null;
+ target.addVariable(this, "reqrows", reqRowsToPaint);
+ target.addVariable(this, "reqfirstrow", reqFirstRowToPaint);
+
+ // Actions
+ if (!actionSet.isEmpty()) {
+ target.startTag("actions");
+ target.addVariable(this, "action", "");
+ for (Iterator it = actionSet.iterator(); it.hasNext();) {
+ Action a = (Action) it.next();
+ target.startTag("action");
+ if (a.getCaption() != null)
+ target.addAttribute("caption", a.getCaption());
+ if (a.getIcon() != null)
+ target.addAttribute("icon", a.getIcon());
+ target.addAttribute("key", actionMapper.key(a));
+ target.endTag("action");
+ }
+ target.endTag("actions");
+ }
+ if (this.columnReorderingAllowed) {
+ String[] colorder = new String[this.visibleColumns.size()];
+ int i = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
+ && i < colorder.length;) {
+ colorder[i++] = this.columnIdMap.key(it.next());
+ }
+ target.addVariable(this, "columnorder", colorder);
+ }
+ // Available columns
+ if (this.columnCollapsingAllowed) {
+ HashSet ccs = new HashSet();
+ for (Iterator i = visibleColumns.iterator(); i.hasNext();) {
+ Object o = i.next();
+ if (isColumnCollapsed(o))
+ ccs.add(o);
+ }
+ String[] collapsedkeys = new String[ccs.size()];
+ int nextColumn = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext()
+ && nextColumn < collapsedkeys.length;) {
+ Object columnId = it.next();
+ if (this.isColumnCollapsed(columnId)) {
+ collapsedkeys[nextColumn++] = this.columnIdMap
+ .key(columnId);
+ }
+ }
+ target.addVariable(this, "collapsedcolumns", collapsedkeys);
+ target.startTag("visiblecolumns");
+ int i = 0;
+ for (Iterator it = this.visibleColumns.iterator(); it.hasNext(); i++) {
+ Object columnId = it.next();
+ if (columnId != null) {
+ target.startTag("column");
+ target.addAttribute("cid", this.columnIdMap.key(columnId));
+ String head = getColumnHeader(columnId);
+ target.addAttribute("caption", (head != null ? head : ""));
+ if (this.isColumnCollapsed(columnId)) {
+ target.addAttribute("collapsed", true);
+ }
+ target.endTag("column");
+ }
+ }
+ target.endTag("visiblecolumns");
+ }
+ }
+
+ /**
+ * Gets the UIDL tag corresponding to component.
+ *
+ * @return the UIDL tag as string.
+ */
+ public String getTag() {
+ return "table";
+ }
+
+ /**
+ * Gets the cached visible table contents.
+ *
+ * @return the cahced visible table conetents.
+ */
+ private Object[][] getVisibleCells() {
+
+ // Returns a buffered value if possible
+ if (pageBuffer != null && isPageBufferingEnabled())
+ return pageBuffer;
+
+ // Stops listening the old properties and initialise the list
+ if (listenedProperties == null)
+ listenedProperties = new LinkedList();
+ else
+ for (Iterator i = listenedProperties.iterator(); i.hasNext();) {
+ ((Property.ValueChangeNotifier) i.next()).removeListener(this);
+ }
+
+ // Detach old visible component from the table
+ if (visibleComponents == null)
+ visibleComponents = new LinkedList();
+ else
+ for (Iterator i = visibleComponents.iterator(); i.hasNext();) {
+ ((Component) i.next()).setParent(null);
+ }
+
+ // Collects the basic facts about the table page
+ Object[] colids = getVisibleColumns();
+ int cols = colids.length;
+ int pagelen = getPageLength();
+ int firstIndex = getCurrentPageFirstItemIndex();
+ int rows = size();
+ if (rows > 0 && firstIndex >= 0)
+ rows -= firstIndex;
+ if (pagelen > 0 && pagelen < rows)
+ rows = pagelen;
+
+ // If "to be painted next" variables are set, use them
+ if (reqRowsToPaint >= 0)
+ rows = reqRowsToPaint;
+ Object id;
+ if (reqFirstRowToPaint >= 0 && reqFirstRowToPaint < size())
+ firstIndex = reqFirstRowToPaint;
+ if (size() > 0) {
+ if (rows + firstIndex > size())
+ rows = size() - firstIndex;
+ } else {
+ rows = 0;
+ }
+
+ Object[][] cells = new Object[cols + CELL_FIRSTCOL][rows];
+ if (rows == 0)
+ return cells;
+
+ // Gets the first item id
+ if (items instanceof Container.Indexed)
+ id = ((Container.Indexed) items).getIdByIndex(firstIndex);
+ else {
+ id = ((Container.Ordered) items).firstItemId();
+ for (int i = 0; i < firstIndex; i++)
+ id = ((Container.Ordered) items).nextItemId(id);
+ }
+
+ int headmode = getRowHeaderMode();
+ boolean[] iscomponent = new boolean[cols];
+ for (int i = 0; i < cols; i++)
+ iscomponent[i] = Component.class
+ .isAssignableFrom(getType(colids[i]));
+
+ // Creates the page contents
+ int filledRows = 0;
+ for (int i = 0; i < rows && id != null; i++) {
+ cells[CELL_ITEMID][i] = id;
+ cells[CELL_KEY][i] = itemIdMapper.key(id);
+ if (headmode != ROW_HEADER_MODE_HIDDEN) {
+ switch (headmode) {
+ case ROW_HEADER_MODE_INDEX:
+ cells[CELL_HEADER][i] = String.valueOf(i + firstIndex + 1);
+ break;
+ default:
+ cells[CELL_HEADER][i] = getItemCaption(id);
+ }
+ cells[CELL_ICON][i] = getItemIcon(id);
+ }
+ if (cols > 0) {
+ for (int j = 0; j < cols; j++) {
+ Object value = null;
+ Property p = getContainerProperty(id, colids[j]);
+ if (p != null) {
+ if (p instanceof Property.ValueChangeNotifier) {
+ ((Property.ValueChangeNotifier) p)
+ .addListener(this);
+ listenedProperties.add(p);
+ }
+ if (iscomponent[j]) {
+ value = p.getValue();
+ } else if (p != null) {
+ value = getPropertyValue(id, colids[j], p);
+ } else {
+ value = getPropertyValue(id, colids[j], null);
+ }
+ } else {
+ value = "";
+ }
+
+ if (value instanceof Component) {
+ ((Component) value).setParent(this);
+ visibleComponents.add((Component) value);
+ }
+ cells[CELL_FIRSTCOL + j][i] = value;
+
+ }
+ }
+ id = ((Container.Ordered) items).nextItemId(id);
+
+ filledRows++;
+ }
+
+ // Assures that all the rows of the cell-buffer are valid
+ if (filledRows != cells[0].length) {
+ 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];
+ cells = temp;
+ }
+
+ // Saves the results to internal buffer iff in buffering mode
+ // to possible conserve memory from large non-buffered pages
+ if (isPageBufferingEnabled())
+ pageBuffer = cells;
+
+ return cells;
+ }
+
+ /**
+ * Gets the value of property.
+ *
+ * By default if the table is editable the fieldFactory is used to create
+ * editors for table cells. Otherwise formatPropertyValue is used to format
+ * the value representation.
+ *
+ * @param rowId
+ * the Id of the row (same as item Id).
+ * @param colId
+ * the Id of the column.
+ * @param property
+ * the Property to be presented.
+ * @return Object Either formatted value or Component for field.
+ * @see #setFieldFactory(FieldFactory)
+ */
+ protected Object getPropertyValue(Object rowId, Object colId,
+ Property property) {
+ if (this.isEditable() && this.fieldFactory != null) {
+ Field f = this.fieldFactory.createField(getContainerDataSource(),
+ rowId, colId, this);
+ if (f != null) {
+ f.setPropertyDataSource(property);
+ return f;
+ }
+ }
+
+ return formatPropertyValue(rowId, colId, property);
+ }
+
+ /**
+ * Formats table cell property values. By default the property.toString()
+ * and return a empty string for null properties.
+ *
+ * @param rowId
+ * the Id of the row (same as item Id).
+ * @param colId
+ * the Id of the column.
+ * @param property
+ * the Property to be formatted.
+ * @return the String representation of property and its value.
+ * @since 3.1
+ */
+ protected String formatPropertyValue(Object rowId, Object colId,
+ Property property) {
+ if (property == null) {
+ return "";
+ }
+ return property.toString();
+ }
+
+ /* Action container *************************************************** */
+
+ /**
+ * Registers a new action handler for this container
+ *
+ * @see com.itmill.toolkit.event.Action.Container#addActionHandler(Action.Handler)
+ */
+ public void addActionHandler(Action.Handler actionHandler) {
+
+ if (actionHandler != null) {
+
+ if (actionHandlers == null) {
+ actionHandlers = new LinkedList();
+ actionMapper = new KeyMapper();
+ }
+
+ if (!actionHandlers.contains(actionHandler)) {
+ actionHandlers.add(actionHandler);
+ requestRepaint();
+ }
+
+ }
+ }
+
+ /**
+ * Removes a previously registered action handler for the contents of this
+ * container.
+ *
+ * @see com.itmill.toolkit.event.Action.Container#removeActionHandler(Action.Handler)
+ */
+ public void removeActionHandler(Action.Handler actionHandler) {
+
+ if (actionHandlers != null && actionHandlers.contains(actionHandler)) {
+
+ actionHandlers.remove(actionHandler);
+
+ if (actionHandlers.isEmpty()) {
+ actionHandlers = null;
+ actionMapper = null;
+ }
+
+ requestRepaint();
+ }
+ }
+
+ /* Property value change listening support **************************** */
+
+ /**
+ * Notifies this listener that the Property's value has changed.
+ *
+ * @see com.itmill.toolkit.data.Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ */
+ public void valueChange(Property.ValueChangeEvent event) {
+ super.valueChange(event);
+ requestRepaint();
+ }
+
+ /**
+ * Notifies the component that it is connected to an application.
+ *
+ * @see com.itmill.toolkit.ui.Component#attach()
+ */
+ public void attach() {
+ super.attach();
+
+ if (visibleComponents != null)
+ for (Iterator i = visibleComponents.iterator(); i.hasNext();)
+ ((Component) i.next()).attach();
+ }
+
+ /**
+ * Notifies the component that it is detached from the application
+ *
+ * @see com.itmill.toolkit.ui.Component#detach()
+ */
+ public void detach() {
+ super.detach();
+
+ if (visibleComponents != null)
+ for (Iterator i = visibleComponents.iterator(); i.hasNext();)
+ ((Component) i.next()).detach();
+ }
+
+ /**
+ * Removes all Items from the Container.
+ *
+ * @see com.itmill.toolkit.data.Container#removeAllItems()
+ */
+ public boolean removeAllItems() {
+ this.currentPageFirstItemId = null;
+ this.currentPageFirstItemIndex = 0;
+ return super.removeAllItems();
+ }
+
+ /**
+ * Removes the Item identified by <code>ItemId</code> from the Container.
+ *
+ * @see com.itmill.toolkit.data.Container#removeItem(Object)
+ */
+ public boolean removeItem(Object itemId) {
+ Object nextItemId = ((Container.Ordered) items).nextItemId(itemId);
+ boolean ret = super.removeItem(itemId);
+ if (ret && (itemId != null)
+ && (itemId.equals(this.currentPageFirstItemId))) {
+ this.currentPageFirstItemId = nextItemId;
+ }
+ return ret;
+ }
+
+ /**
+ * Removes a Property specified by the given Property ID from the Container.
+ *
+ * @see com.itmill.toolkit.data.Container#removeContainerProperty(Object)
+ */
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+
+ // If a visible property is removed, remove the corresponding column
+ this.visibleColumns.remove(propertyId);
+ this.columnAlignments.remove(propertyId);
+ this.columnIcons.remove(propertyId);
+ this.columnHeaders.remove(propertyId);
+
+ return super.removeContainerProperty(propertyId);
+ }
+
+ /**
+ * Adds a new property to the table and show it as a visible column.
+ *
+ * @param propertyId
+ * the Id of the proprty.
+ * @param type
+ * the class of the property.
+ * @param defaultValue
+ * the default value given for all existing items.
+ * @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
+ * Class, Object)
+ */
+ public boolean addContainerProperty(Object propertyId, Class type,
+ Object defaultValue) throws UnsupportedOperationException {
+ if (!super.addContainerProperty(propertyId, type, defaultValue))
+ return false;
+ if (!this.visibleColumns.contains(propertyId))
+ this.visibleColumns.add(propertyId);
+ return true;
+ }
+
+ /**
+ * Adds a new property to the table and show it as a visible column.
+ *
+ * @param propertyId
+ * the Id of the proprty
+ * @param type
+ * the class of the property
+ * @param defaultValue
+ * the default value given for all existing items
+ * @param columnHeader
+ * the Explicit header of the column. If explicit header is not
+ * needed, this should be set null.
+ * @param columnIcon
+ * the Icon of the column. If icon is not needed, this should be
+ * set null.
+ * @param columnAlignment
+ * the Alignment of the column. Null implies align left.
+ * @throws UnsupportedOperationException
+ * if the operation is not supported.
+ * @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
+ * Class, Object)
+ */
+ public boolean addContainerProperty(Object propertyId, Class type,
+ Object defaultValue, String columnHeader, Resource columnIcon,
+ String columnAlignment) throws UnsupportedOperationException {
+ if (!this.addContainerProperty(propertyId, type, defaultValue))
+ return false;
+ this.setColumnAlignment(propertyId, columnAlignment);
+ this.setColumnHeader(propertyId, columnHeader);
+ this.setColumnIcon(propertyId, columnIcon);
+ return true;
+ }
+
+ /**
+ * Returns the list of items on the current page
+ *
+ * @see com.itmill.toolkit.ui.Select#getVisibleItemIds()
+ */
+ public Collection getVisibleItemIds() {
+
+ LinkedList visible = new LinkedList();
+
+ Object[][] cells = getVisibleCells();
+ for (int i = 0; i < cells[CELL_ITEMID].length; i++)
+ visible.add(cells[CELL_ITEMID][i]);
+
+ return visible;
+ }
+
+ /**
+ * Container datasource item set change. Table must flush its buffers on
+ * change.
+ *
+ * @see com.itmill.toolkit.data.Container.ItemSetChangeListener#containerItemSetChange(com.itmill.toolkit.data.Container.ItemSetChangeEvent)
+ */
+ public void containerItemSetChange(Container.ItemSetChangeEvent event) {
+ pageBuffer = null;
+ super.containerItemSetChange(event);
+ setCurrentPageFirstItemIndex(this.getCurrentPageFirstItemIndex());
+ }
+
+ /**
+ * Container datasource property set change. Table must flush its buffers on
+ * change.
+ *
+ * @see com.itmill.toolkit.data.Container.PropertySetChangeListener#containerPropertySetChange(com.itmill.toolkit.data.Container.PropertySetChangeEvent)
+ */
+ public void containerPropertySetChange(
+ Container.PropertySetChangeEvent event) {
+ pageBuffer = null;
+ super.containerPropertySetChange(event);
+ }
+
+ /**
+ * Adding new items is not supported.
+ *
+ * @throws UnsupportedOperationException
+ * if set to true.
+ * @see com.itmill.toolkit.ui.Select#setNewItemsAllowed(boolean)
+ */
+ public void setNewItemsAllowed(boolean allowNewOptions)
+ throws UnsupportedOperationException {
+ if (allowNewOptions)
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Focusing to this component is not supported.
+ *
+ * @throws UnsupportedOperationException
+ * if invoked.
+ * @see com.itmill.toolkit.ui.AbstractField#focus()
+ */
+ public void focus() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Gets the ID of the Item following the Item that corresponds to itemId.
+ *
+ * @see com.itmill.toolkit.data.Container.Ordered#nextItemId(java.lang.Object)
+ */
+ public Object nextItemId(Object itemId) {
+ return ((Container.Ordered) items).nextItemId(itemId);
+ }
+
+ /**
+ * Gets the ID of the Item preceding the Item that corresponds to the
+ * itemId.
+ *
+ * @see com.itmill.toolkit.data.Container.Ordered#prevItemId(java.lang.Object)
+ */
+ public Object prevItemId(Object itemId) {
+ return ((Container.Ordered) items).prevItemId(itemId);
+ }
+
+ /**
+ * Gets the ID of the first Item in the Container.
+ *
+ * @see com.itmill.toolkit.data.Container.Ordered#firstItemId()
+ */
+ public Object firstItemId() {
+ return ((Container.Ordered) items).firstItemId();
+ }
+
+ /**
+ * Gets the ID of the last Item in the Container.
+ *
+ * @see com.itmill.toolkit.data.Container.Ordered#lastItemId()
+ */
+ public Object lastItemId() {
+ return ((Container.Ordered) items).lastItemId();
+ }
+
+ /**
+ * Tests if the Item corresponding to the given Item ID is the first Item in
+ * the Container.
+ *
+ * @see com.itmill.toolkit.data.Container.Ordered#isFirstId(java.lang.Object)
+ */
+ public boolean isFirstId(Object itemId) {
+ return ((Container.Ordered) items).isFirstId(itemId);
+ }
+
+ /**
+ * Tests if the Item corresponding to the given Item ID is the last Item in
+ * the Container.
+ *
+ * @see com.itmill.toolkit.data.Container.Ordered#isLastId(java.lang.Object)
+ */
+ public boolean isLastId(Object itemId) {
+ return ((Container.Ordered) items).isLastId(itemId);
+ }
+
+ /**
+ * Adds new item after the given item.
+ *
+ * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(java.lang.Object)
+ */
+ public Object addItemAfter(Object previousItemId)
+ throws UnsupportedOperationException {
+ return ((Container.Ordered) items).addItemAfter(previousItemId);
+ }
+
+ /**
+ * Adds new item after the given item.
+ *
+ * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(java.lang.Object,
+ * java.lang.Object)
+ */
+ public Item addItemAfter(Object previousItemId, Object newItemId)
+ throws UnsupportedOperationException {
+ return ((Container.Ordered) items).addItemAfter(previousItemId,
+ newItemId);
+ }
+
+ /**
+ * Gets the FieldFactory that is used to create editor for table cells.
+ *
+ * The FieldFactory is only used if the Table is editable.
+ *
+ * @return FieldFactory used to create the Field instances.
+ * @see #isEditable
+ */
+ public FieldFactory getFieldFactory() {
+ return fieldFactory;
+ }
+
+ /**
+ * Sets the FieldFactory that is used to create editor for table cells.
+ *
+ * The FieldFactory is only used if the Table is editable. By default the
+ * BaseFieldFactory is used.
+ *
+ * @param fieldFactory
+ * the field factory to set.
+ * @see #isEditable
+ * @see BaseFieldFactory
+ *
+ */
+ public void setFieldFactory(FieldFactory fieldFactory) {
+ this.fieldFactory = fieldFactory;
+
+ // Assure visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Is table editable.
+ *
+ * If table is editable a editor of type Field is created for each table
+ * cell. The assigned FieldFactory is used to create the instances.
+ *
+ * To provide custom editors for table cells create a class implementins the
+ * FieldFactory interface, and assign it to table, and set the editable
+ * property to true.
+ *
+ * @return true if table is editable, false oterwise.
+ * @see Field
+ * @see FieldFactory
+ *
+ */
+ public boolean isEditable() {
+ return editable;
+ }
+
+ /**
+ * Sets the editable property.
+ *
+ * If table is editable a editor of type Field is created for each table
+ * cell. The assigned FieldFactory is used to create the instances.
+ *
+ * To provide custom editors for table cells create a class implementins the
+ * FieldFactory interface, and assign it to table, and set the editable
+ * property to true.
+ *
+ * @param editable
+ * true if table should be editable by user.
+ * @see Field
+ * @see FieldFactory
+ *
+ */
+ public void setEditable(boolean editable) {
+ this.editable = editable;
+
+ // Assure visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Sorts the table.
+ *
+ * @throws UnsupportedOperationException
+ * if the container data source does not implement
+ * Container.Sortable
+ * @see com.itmill.toolkit.data.Container.Sortable#sort(java.lang.Object[],
+ * boolean[])
+ *
+ */
+ public void sort(Object[] propertyId, boolean[] ascending)
+ throws UnsupportedOperationException {
+ Container c = getContainerDataSource();
+ if (c instanceof Container.Sortable) {
+ int pageIndex = this.getCurrentPageFirstItemIndex();
+ ((Container.Sortable) c).sort(propertyId, ascending);
+ setCurrentPageFirstItemIndex(pageIndex);
+ } else if (c != null) {
+ throw new UnsupportedOperationException(
+ "Underlying Data does not allow sorting");
+ }
+ }
+
+ /**
+ * Sorts the table by currently selected sorting column.
+ *
+ * @throws UnsupportedOperationException
+ * if the container data source does not implement
+ * Container.Sortable
+ */
+ public void sort() {
+ if (getSortContainerPropertyId() == null)
+ return;
+ sort(new Object[] { this.sortContainerPropertyId },
+ new boolean[] { this.sortAscending });
+ }
+
+ /**
+ * Gets the container property IDs, which can be used to sort the item.
+ *
+ * @see com.itmill.toolkit.data.Container.Sortable#getSortableContainerPropertyIds()
+ */
+ public Collection getSortableContainerPropertyIds() {
+ Container c = getContainerDataSource();
+ if (c instanceof Container.Sortable && !isSortDisabled()) {
+ return ((Container.Sortable) c).getSortableContainerPropertyIds();
+ } else {
+ return new LinkedList();
+ }
+ }
+
+ /**
+ * Gets the currently sorted column property ID.
+ *
+ * @return the Container property id of the currently sorted column.
+ */
+ public Object getSortContainerPropertyId() {
+ return this.sortContainerPropertyId;
+ }
+
+ /**
+ * Sets the currently sorted column property id.
+ *
+ * @param propertyId
+ * the Container property id of the currently sorted column.
+ */
+ public void setSortContainerPropertyId(Object propertyId) {
+ if ((this.sortContainerPropertyId != null && !this.sortContainerPropertyId
+ .equals(propertyId))
+ || (this.sortContainerPropertyId == null && propertyId != null)) {
+ this.sortContainerPropertyId = propertyId;
+ sort();
+ }
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Is the table currently sorted in ascending order.
+ *
+ * @return <code>true</code> if ascending, <code>false</code> if
+ * descending.
+ */
+ public boolean isSortAscending() {
+ return this.sortAscending;
+ }
+
+ /**
+ * Sets the table in ascending order.
+ *
+ * @param ascending
+ * <code>true</code> if ascending, <code>false</code> if
+ * descending.
+ */
+ public void setSortAscending(boolean ascending) {
+ if (this.sortAscending != ascending) {
+ this.sortAscending = ascending;
+ sort();
+ }
+
+ // Assures the visual refresh
+ refreshCurrentPage();
+ }
+
+ /**
+ * Is sorting disabled alltogether.
+ *
+ * True iff no sortable columns are given even in the case where datasource
+ * would support this.
+ *
+ * @return True iff sorting is disabled.
+ */
+ public boolean isSortDisabled() {
+ return sortDisabled;
+ }
+
+ /**
+ * Disables the sorting alltogether.
+ *
+ * To disable sorting alltogether, set to true. In this case no sortable
+ * columns are given even in the case where datasource would support this.
+ *
+ * @param sortDisabled
+ * True iff sorting is disabled.
+ */
+ public void setSortDisabled(boolean sortDisabled) {
+ if (this.sortDisabled != sortDisabled) {
+ this.sortDisabled = sortDisabled;
+ refreshCurrentPage();
+ }
+ }
/**
* Gets the height property units.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
*/
public int getHeightUnits() {
@@ -2284,16 +2331,17 @@ public class Table extends Select implements Action.Container,
/**
* Gets the width property units.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
*/
public int getWidthUnits() {
return widthUnit;
}
- /**
- * Sets the height units.
- * Table supports only Sizeable.UNITS_PIXELS. Setting to any other throws
- * IllegalArgumentException.
+ /**
+ * Sets the height units. Table supports only Sizeable.UNITS_PIXELS. Setting
+ * to any other throws IllegalArgumentException.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
*/
public void setHeightUnits(int units) {
@@ -2302,21 +2350,24 @@ public class Table extends Select implements Action.Container,
this.heightUnit = units;
}
- /**
- * Sets the width units.
- * Tabel supports only Sizeable.UNITS_PIXELS and Sizeable.UNITS_PERCENTAGE. Setting to any other throws
+ /**
+ * Sets the width units. Tabel supports only Sizeable.UNITS_PIXELS and
+ * Sizeable.UNITS_PERCENTAGE. Setting to any other throws
* IllegalArgumentException.
+ *
* @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int)
*/
public void setWidthUnits(int units) {
- if (units != Sizeable.UNITS_PIXELS && units != Sizeable.UNITS_PERCENTAGE)
+ if (units != Sizeable.UNITS_PIXELS
+ && units != Sizeable.UNITS_PERCENTAGE)
throw new IllegalArgumentException();
this.widthUnit = units;
}
-
+
/**
* Gets the height in pixels.
- * @return the height in pixels or negative value if not assigned.
+ *
+ * @return the height in pixels or negative value if not assigned.
* @see com.itmill.toolkit.terminal.Sizeable#getHeight()
*/
public int getHeight() {
@@ -2325,27 +2376,32 @@ public class Table extends Select implements Action.Container,
/**
* Gets the width in pixels.
- * @return the width in pixels or negative value if not assigned.
+ *
+ * @return the width in pixels or negative value if not assigned.
* @see com.itmill.toolkit.terminal.Sizeable#getWidth()
*/
public int getWidth() {
return width;
}
- /**
- * Sets the height in pixels.
- * Use negative value to let the client decide the height.
- * @param height the height to set.
+ /**
+ * Sets the height in pixels. Use negative value to let the client decide
+ * the height.
+ *
+ * @param height
+ * the height to set.
*/
public void setHeight(int height) {
this.height = height;
requestRepaint();
}
- /**
- * Sets the width in pixels.
- * Use negative value to allow the client decide the width.
- * @param width the width to set.
+ /**
+ * Sets the width in pixels. Use negative value to allow the client decide
+ * the width.
+ *
+ * @param width
+ * the width to set.
*/
public void setWidth(int width) {
this.width = width;
@@ -2353,14 +2409,15 @@ public class Table extends Select implements Action.Container,
}
/**
- * Table does not support lazy options loading mode.
- * Setting this true will throw UnsupportedOperationException.
+ * Table does not support lazy options loading mode. Setting this true will
+ * throw UnsupportedOperationException.
+ *
* @see com.itmill.toolkit.ui.Select#setLazyLoading(boolean)
*/
- public void setLazyLoading(boolean useLazyLoading) {
- if (useLazyLoading)
- throw new UnsupportedOperationException("Lazy options loading is not supported by Table.");
+ public void setLazyLoading(boolean useLazyLoading) {
+ if (useLazyLoading)
+ throw new UnsupportedOperationException(
+ "Lazy options loading is not supported by Table.");
}
-
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/ui/TextField.java b/src/com/itmill/toolkit/ui/TextField.java
index b377c657ad..8ea08f5405 100644
--- a/src/com/itmill/toolkit/ui/TextField.java
+++ b/src/com/itmill/toolkit/ui/TextField.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -35,117 +35,124 @@ import com.itmill.toolkit.data.Property;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-/**
+/**
* <p>
- * A text editor component that can be bound to any bindable Property.
- * The text editor supports both multiline and single line modes, default
- * is one-line mode.
+ * A text editor component that can be bound to any bindable Property. The text
+ * editor supports both multiline and single line modes, default is one-line
+ * mode.
* </p>
- *
+ *
* <p>
* Since <code>TextField</code> extends <code>AbstractField</code> it
* implements the {@link com.itmill.toolkit.data.Buffered} interface. A
* <code>TextField</code> is in write-through mode by default, so
- * {@link com.itmill.toolkit.ui.AbstractField#setWriteThrough(boolean)}
- * must be called to enable buffering.
+ * {@link com.itmill.toolkit.ui.AbstractField#setWriteThrough(boolean)} must be
+ * called to enable buffering.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class TextField extends AbstractField {
/* Private members ************************************************* */
- /**
+ /**
* Value formatter used to format the string contents.
*/
private Format format;
- /**
- * Number of visible columns in the TextField.
+ /**
+ * Number of visible columns in the TextField.
*/
private int columns = 0;
- /**
+ /**
* Number of visible rows in a multiline TextField. Value 0 implies a
* single-line text-editor.
*/
private int rows = 0;
- /**
- * Tells if word-wrapping should be used in multiline mode.
+ /**
+ * Tells if word-wrapping should be used in multiline mode.
*/
private boolean wordwrap = true;
- /**
- * Tells if input is used to enter sensitive information that is
- * not echoed to display. Typically passwords.
+ /**
+ * Tells if input is used to enter sensitive information that is not echoed
+ * to display. Typically passwords.
*/
private boolean secret = false;
- /**
- * Null representation.
+ /**
+ * Null representation.
*/
private String nullRepresentation = "null";
- /**
- * Is setting to null from non-null value allowed by setting with
- * null representation .
+ /**
+ * Is setting to null from non-null value allowed by setting with null
+ * representation .
*/
private boolean nullSettingAllowed = false;
/* Constructors **************************************************** */
- /**
- * Constructs an empty <code>TextField</code> with no caption.
+ /**
+ * Constructs an empty <code>TextField</code> with no caption.
*/
public TextField() {
setValue("");
}
- /**
+ /**
* Constructs an empty <code>TextField</code> with given caption.
- * @param caption the caption <code>String</code> for the editor.
+ *
+ * @param caption
+ * the caption <code>String</code> for the editor.
*/
public TextField(String caption) {
setValue("");
setCaption(caption);
}
- /**
- * Constructs a new <code>TextField</code> that's bound to the
- * specified <code>Property</code> and has no caption.
+ /**
+ * Constructs a new <code>TextField</code> that's bound to the specified
+ * <code>Property</code> and has no caption.
*
- * @param dataSource the Property to be edited with this editor.
+ * @param dataSource
+ * the Property to be edited with this editor.
*/
public TextField(Property dataSource) {
setPropertyDataSource(dataSource);
}
- /**
- * Constructs a new <code>TextField</code> that's bound to the
- * specified <code>Property</code> and has the given caption
- * <code>String</code>.
+ /**
+ * Constructs a new <code>TextField</code> that's bound to the specified
+ * <code>Property</code> and has the given caption <code>String</code>.
*
- * @param caption the caption <code>String</code> for the editor.
- * @param dataSource the Property to be edited with this editor.
+ * @param caption
+ * the caption <code>String</code> for the editor.
+ * @param dataSource
+ * the Property to be edited with this editor.
*/
public TextField(String caption, Property dataSource) {
this(dataSource);
setCaption(caption);
}
- /**
+ /**
* Constructs a new <code>TextField</code> with the given caption and
- * initial text contents. The editor constructed this way will not be
- * bound to a Property unless
+ * initial text contents. The editor constructed this way will not be bound
+ * to a Property unless
* {@link com.itmill.toolkit.data.Property.Viewer#setPropertyDataSource(Property)}
* is called to bind it.
*
- * @param caption the caption <code>String</code> for the editor.
- * @param text the initial text content of the editor.
+ * @param caption
+ * the caption <code>String</code> for the editor.
+ * @param text
+ * the initial text content of the editor.
*/
public TextField(String caption, String value) {
setValue(value);
@@ -154,9 +161,9 @@ public class TextField extends AbstractField {
/* Component basic features ********************************************* */
- /* Paints this component.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Paints this component. Don't add a JavaDoc comment here, we use the
+ * default documentation from implemented interface.
*/
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
@@ -182,13 +189,14 @@ public class TextField extends AbstractField {
if (value == null)
value = getNullRepresentation();
if (value == null)
- throw new IllegalStateException("Null values are not allowed if the null-representation is null");
+ throw new IllegalStateException(
+ "Null values are not allowed if the null-representation is null");
target.addVariable(this, "text", value);
}
- /**
- * Gets the formatted dtring value.
- * Sets the field value by using the assigned Format.
+ /**
+ * Gets the formatted dtring value. Sets the field value by using the
+ * assigned Format.
*
* @return the Formatted value.
* @see #setFormat(Format)
@@ -207,17 +215,18 @@ public class TextField extends AbstractField {
return null;
}
- /* Gets the components UIDL tag string.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the components UIDL tag string. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
*/
public String getTag() {
return "textfield";
}
- /* Invoked when a variable of the component changes.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Invoked when a variable of the component changes. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
*/
public void changeVariables(Object source, Map variables) {
@@ -229,11 +238,11 @@ public class TextField extends AbstractField {
String newValue = (String) variables.get("text");
String oldValue = getFormattedValue();
if (newValue != null
- && (oldValue == null || isNullSettingAllowed())
- && newValue.equals(getNullRepresentation()))
+ && (oldValue == null || isNullSettingAllowed())
+ && newValue.equals(getNullRepresentation()))
newValue = null;
if (newValue != oldValue
- && (newValue == null || !newValue.equals(oldValue)))
+ && (newValue == null || !newValue.equals(oldValue)))
setValue(newValue);
}
@@ -241,10 +250,10 @@ public class TextField extends AbstractField {
/* Text field configuration ********************************************* */
- /**
- * Gets the number of columns in the editor. If the number of columns
- * is set 0, the actual number of displayed columns is determined
- * implicitly by the adapter.
+ /**
+ * Gets the number of columns in the editor. If the number of columns is set
+ * 0, the actual number of displayed columns is determined implicitly by the
+ * adapter.
*
* @return the number of columns in the editor.
*/
@@ -252,12 +261,13 @@ public class TextField extends AbstractField {
return this.columns;
}
- /**
- * Sets the number of columns in the editor. If the number of columns
- * is set 0, the actual number of displayed columns is determined
- * implicitly by the adapter.
+ /**
+ * Sets the number of columns in the editor. If the number of columns is set
+ * 0, the actual number of displayed columns is determined implicitly by the
+ * adapter.
*
- * @param columns the number of columns to set.
+ * @param columns
+ * the number of columns to set.
*/
public void setColumns(int columns) {
if (columns < 0)
@@ -266,10 +276,10 @@ public class TextField extends AbstractField {
requestRepaint();
}
- /**
- * Gets the number of rows in the editor. If the number of rows is set
- * to 0, the actual number of displayed rows is determined implicitly by
- * the adapter.
+ /**
+ * Gets the number of rows in the editor. If the number of rows is set to 0,
+ * the actual number of displayed rows is determined implicitly by the
+ * adapter.
*
* @return number of explicitly set rows.
*/
@@ -277,12 +287,13 @@ public class TextField extends AbstractField {
return this.rows;
}
- /**
- * Sets the number of rows in the editor. If the number of rows is set
- * to 0, the actual number of displayed rows is determined implicitly by
- * the adapter.
+ /**
+ * Sets the number of rows in the editor. If the number of rows is set to 0,
+ * the actual number of displayed rows is determined implicitly by the
+ * adapter.
*
- * @param rows the number of rows for this editor.
+ * @param rows
+ * the number of rows for this editor.
*/
public void setRows(int rows) {
if (rows < 0)
@@ -291,21 +302,22 @@ public class TextField extends AbstractField {
requestRepaint();
}
- /**
+ /**
* Tests if the editor is in word-wrap mode.
*
* @return <code>true</code> if the component is in the word-wrap mode,
- * <code>false</code> if not.
+ * <code>false</code> if not.
*/
public boolean isWordwrap() {
return this.wordwrap;
}
- /**
- * Sets the editor's word-wrap mode on or off.
+ /**
+ * Sets the editor's word-wrap mode on or off.
*
- * @param wordwrap the boolean value specifying if the editor should be in
- * word-wrap mode after the call or not.
+ * @param wordwrap
+ * the boolean value specifying if the editor should be in
+ * word-wrap mode after the call or not.
*/
public void setWordwrap(boolean wordwrap) {
this.wordwrap = wordwrap;
@@ -313,41 +325,50 @@ public class TextField extends AbstractField {
/* Property features **************************************************** */
- /* Gets the edited property's type.
- * Don't add a JavaDoc comment here, we use the default documentation
- * from implemented interface.
+ /*
+ * Gets the edited property's type. Don't add a JavaDoc comment here, we use
+ * the default documentation from implemented interface.
*/
public Class getType() {
return String.class;
}
- /**
- * Gets the secret property on and off.
- * If a field is used to enter secretinformation
- * the information is not echoed to display.
- * @return <code>true</code> if the field is used to enter secret information, <code>false</code> otherwise.
+
+ /**
+ * Gets the secret property on and off. If a field is used to enter
+ * secretinformation the information is not echoed to display.
+ *
+ * @return <code>true</code> if the field is used to enter secret
+ * information, <code>false</code> otherwise.
*/
public boolean isSecret() {
return secret;
}
- /**
- * Sets the secret property on and off.
- * If a field is used to enter secretinformation
- * the information is not echoed to display.
- * @param secret the value specifying if the field is used to enter secret information.
+ /**
+ * Sets the secret property on and off. If a field is used to enter
+ * secretinformation the information is not echoed to display.
+ *
+ * @param secret
+ * the value specifying if the field is used to enter secret
+ * information.
*/
public void setSecret(boolean secret) {
this.secret = secret;
}
- /**
+ /**
* Gets the null-string representation.
*
- * <p>The null-valued strings are represented on the user interface by replacing the
- * null value with this string. If the null representation is set null (not 'null' string),
- * painting null value throws exception.</p>
+ * <p>
+ * The null-valued strings are represented on the user interface by
+ * replacing the null value with this string. If the null representation is
+ * set null (not 'null' string), painting null value throws exception.
+ * </p>
+ *
+ * <p>
+ * The default value is string 'null'.
+ * </p>
*
- * <p>The default value is string 'null'.</p>
* @return the String Textual representation for null strings.
* @see TextField#isNullSettingAllowed()
*/
@@ -355,64 +376,77 @@ public class TextField extends AbstractField {
return nullRepresentation;
}
- /**
+ /**
* Is setting nulls with null-string representation allowed.
*
* <p>
- * If this property is true, writing null-representation string to text
- * field allways sets the field value to real null. If this property is
- * false, null setting is not made, but the null values are maintained.
+ * If this property is true, writing null-representation string to text
+ * field allways sets the field value to real null. If this property is
+ * false, null setting is not made, but the null values are maintained.
* Maintenance of null-values is made by only converting the textfield
- * contents to real null, if the text field matches the null-string
+ * contents to real null, if the text field matches the null-string
* representation and the current value of the field is null.
* </p>
*
- * <p>By default this setting is false</p>
+ * <p>
+ * By default this setting is false
+ * </p>
*
- * @return boolean Should the null-string represenation be allways
- * converted to null-values.
+ * @return boolean Should the null-string represenation be allways converted
+ * to null-values.
* @see TextField#getNullRepresentation()
*/
public boolean isNullSettingAllowed() {
return nullSettingAllowed;
}
- /**
+ /**
* Sets the null-string representation.
*
- * <p>The null-valued strings are represented on the user interface by replacing the
- * null value with this string. If the null representation is set null (not 'null' string),
- * painting null value throws exception.</p>
+ * <p>
+ * The null-valued strings are represented on the user interface by
+ * replacing the null value with this string. If the null representation is
+ * set null (not 'null' string), painting null value throws exception.
+ * </p>
+ *
+ * <p>
+ * The default value is string 'null'
+ * </p>
*
- * <p>The default value is string 'null'</p>
- * @param nullRepresentation Textual representation for null strings.
+ * @param nullRepresentation
+ * Textual representation for null strings.
* @see TextField#setNullSettingAllowed(boolean)
*/
public void setNullRepresentation(String nullRepresentation) {
this.nullRepresentation = nullRepresentation;
}
- /**
+ /**
* Sets the null conversion mode.
*
- * <p>If this property is true, writing null-representation string to text
- * field allways sets the field value to real null. If this property is
- * false, null setting is not made, but the null values are maintained.
+ * <p>
+ * If this property is true, writing null-representation string to text
+ * field allways sets the field value to real null. If this property is
+ * false, null setting is not made, but the null values are maintained.
* Maintenance of null-values is made by only converting the textfield
- * contents to real null, if the text field matches the null-string
- * representation and the current value of the field is null.</p>
+ * contents to real null, if the text field matches the null-string
+ * representation and the current value of the field is null.
+ * </p>
*
- * <p>By default this setting is false.</p>
+ * <p>
+ * By default this setting is false.
+ * </p>
*
- * @param nullSettingAllowed Should the null-string represenation be allways
- * converted to null-values.
+ * @param nullSettingAllowed
+ * Should the null-string represenation be allways converted to
+ * null-values.
* @see TextField#getNullRepresentation()
*/
public void setNullSettingAllowed(boolean nullSettingAllowed) {
this.nullSettingAllowed = nullSettingAllowed;
}
- /**
+ /**
* Gets the value formatter of TextField.
*
* @return the Format used to format the value.
@@ -421,10 +455,12 @@ public class TextField extends AbstractField {
return format;
}
- /**
+ /**
* Gets the value formatter of TextField.
*
- * @param format the Format used to format the value. Null disables the formatting.
+ * @param format
+ * the Format used to format the value. Null disables the
+ * formatting.
*/
public void setFormat(Format format) {
this.format = format;
diff --git a/src/com/itmill/toolkit/ui/Tree.java b/src/com/itmill/toolkit/ui/Tree.java
index 8d396e244f..1d3f303aa3 100644
--- a/src/com/itmill/toolkit/ui/Tree.java
+++ b/src/com/itmill/toolkit/ui/Tree.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -47,81 +47,81 @@ import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.Resource;
-/**
- * MenuTree component.
- * MenuTree can be used to select an item (or multiple items)
- * from a hierarchical set of items.
- *
+/**
+ * MenuTree component. MenuTree can be used to select an item (or multiple
+ * items) from a hierarchical set of items.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
-public class Tree extends Select implements Container.Hierarchical, Action.Container {
+public class Tree extends Select implements Container.Hierarchical,
+ Action.Container {
/* Static members ***************************************************** */
private static final Method EXPAND_METHOD;
+
private static final Method COLLAPSE_METHOD;
static {
try {
- EXPAND_METHOD =
- ExpandListener.class.getDeclaredMethod(
- "nodeExpand",
- new Class[] { ExpandEvent.class });
- COLLAPSE_METHOD =
- CollapseListener.class.getDeclaredMethod(
- "nodeCollapse",
- new Class[] { CollapseEvent.class });
+ EXPAND_METHOD = ExpandListener.class.getDeclaredMethod(
+ "nodeExpand", new Class[] { ExpandEvent.class });
+ COLLAPSE_METHOD = CollapseListener.class.getDeclaredMethod(
+ "nodeCollapse", new Class[] { CollapseEvent.class });
} catch (java.lang.NoSuchMethodException e) {
// This should never happen
e.printStackTrace();
throw new java.lang.RuntimeException(
- "Internal error, please report");
+ "Internal error, please report");
}
}
/* Private members **************************************************** */
- /**
- * Set of expanded nodes.
+ /**
+ * Set of expanded nodes.
*/
private HashSet expanded = new HashSet();
- /**
- * List of action handlers.
+ /**
+ * List of action handlers.
*/
private LinkedList actionHandlers = null;
- /**
- * Action mapper.
+ /**
+ * Action mapper.
*/
private KeyMapper actionMapper = null;
- /**
+ /**
* Is the tree selectable .
*/
private boolean selectable = true;
/* Tree constructors ************************************************** */
- /**
- * Creates a new empty tree.
+ /**
+ * Creates a new empty tree.
*/
public Tree() {
}
- /**
+ /**
* Creates a new empty tree with caption.
- * @param caption
+ *
+ * @param caption
*/
public Tree(String caption) {
setCaption(caption);
}
- /**
- * Creates a new tree with caption and connect it to a Container.
- * @param caption
+ /**
+ * Creates a new tree with caption and connect it to a Container.
+ *
+ * @param caption
* @param dataSource
*/
public Tree(String caption, Container dataSource) {
@@ -131,18 +131,22 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/* Expanding and collapsing ******************************************* */
- /**
+ /**
* Check is an item is expanded
- * @param itemId the item id.
+ *
+ * @param itemId
+ * the item id.
* @return true iff the item is expanded.
*/
public boolean isExpanded(Object itemId) {
return expanded.contains(itemId);
}
- /**
+ /**
* Expands an item.
- * @param itemId the item id.
+ *
+ * @param itemId
+ * the item id.
* @return True iff the expand operation succeeded
*/
public boolean expandItem(Object itemId) {
@@ -163,11 +167,12 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
return true;
}
- /**
+ /**
* Expands the items recursively
*
- * Expands all the children recursively starting from an item.
- * Operation succeeds only if all expandable items are expanded.
+ * Expands all the children recursively starting from an item. Operation
+ * succeeds only if all expandable items are expanded.
+ *
* @param startItemId
* @return True iff the expand operation succeeded
*/
@@ -193,9 +198,11 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
return result;
}
- /**
+ /**
* Collapses an item.
- * @param itemId the item id.
+ *
+ * @param itemId
+ * the item id.
* @return True iff the collapse operation succeeded
*/
public boolean collapseItem(Object itemId) {
@@ -212,11 +219,12 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
return true;
}
- /**
+ /**
* Collapses the items recursively.
*
- * Collapse all the children recursively starting from an item.
- * Operation succeeds only if all expandable items are collapsed.
+ * Collapse all the children recursively starting from an item. Operation
+ * succeeds only if all expandable items are collapsed.
+ *
* @param startItemId
* @return True iff the collapse operation succeeded
*/
@@ -242,10 +250,12 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
return result;
}
- /**
+ /**
* Getter for property selectable.
*
- * <p>The tree is selectable by default.</p>
+ * <p>
+ * The tree is selectable by default.
+ * </p>
*
* @return the Value of property selectable.
*/
@@ -256,9 +266,12 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Setter for property selectable.
*
- * <p>The tree is selectable by default.</p>
+ * <p>
+ * The tree is selectable by default.
+ * </p>
*
- * @param selectable the New value of property selectable.
+ * @param selectable
+ * the New value of property selectable.
*/
public void setSelectable(boolean selectable) {
if (this.selectable != selectable) {
@@ -271,6 +284,7 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Gets the UIDL tag corresponding to the component.
+ *
* @see com.itmill.toolkit.ui.AbstractComponent#getTag()
*/
public String getTag() {
@@ -278,60 +292,57 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
}
/**
- * Called when one or more variables handled by the implementing class
- * are changed.
- * @see com.itmill.toolkit.terminal.VariableOwner#changeVariables(Object source, Map variables)
+ * Called when one or more variables handled by the implementing class are
+ * changed.
+ *
+ * @see com.itmill.toolkit.terminal.VariableOwner#changeVariables(Object
+ * source, Map variables)
*/
public void changeVariables(Object source, Map variables) {
- // Collapses the nodes
- if (variables.containsKey("collapse")) {
- String[] keys = (String[]) variables.get("collapse");
- for (int i = 0; i < keys.length; i++) {
- Object id = itemIdMapper.get(keys[i]);
- if (id != null)
- collapseItem(id);
- }
+ // Collapses the nodes
+ if (variables.containsKey("collapse")) {
+ String[] keys = (String[]) variables.get("collapse");
+ for (int i = 0; i < keys.length; i++) {
+ Object id = itemIdMapper.get(keys[i]);
+ if (id != null)
+ collapseItem(id);
}
+ }
- // Expands the nodes
- if (variables.containsKey("expand")) {
- String[] keys = (String[]) variables.get("expand");
- for (int i = 0; i < keys.length; i++) {
- Object id = itemIdMapper.get(keys[i]);
- if (id != null)
- expandItem(id);
- }
+ // Expands the nodes
+ if (variables.containsKey("expand")) {
+ String[] keys = (String[]) variables.get("expand");
+ for (int i = 0; i < keys.length; i++) {
+ Object id = itemIdMapper.get(keys[i]);
+ if (id != null)
+ expandItem(id);
}
+ }
- // Selections are handled by the select component
- super.changeVariables(source, variables);
-
- // Actions
- if (variables.containsKey("action")) {
+ // Selections are handled by the select component
+ super.changeVariables(source, variables);
- 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());
- if (action != null
- && containsId(itemId)
+ // Actions
+ if (variables.containsKey("action")) {
+
+ 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());
+ if (action != null && containsId(itemId)
&& actionHandlers != null)
- for (Iterator i = actionHandlers.iterator();
- i.hasNext();
- )
- ((Action.Handler) i.next()).handleAction(
- action,
- this,
+ for (Iterator i = actionHandlers.iterator(); i.hasNext();)
+ ((Action.Handler) i.next()).handleAction(action, this,
itemId);
- }
}
+ }
}
/**
- * Paints any needed component-specific things to the given UIDL
- * stream.
+ * Paints any needed component-specific things to the given UIDL stream.
+ *
* @see com.itmill.toolkit.ui.AbstractComponent#paintContent(PaintTarget)
*/
public void paintContent(PaintTarget target) throws PaintException {
@@ -345,12 +356,10 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
if (this.getTabIndex() > 0)
target.addAttribute("tabindex", this.getTabIndex());
-
// Paint tree attributes
if (isSelectable())
- target.addAttribute(
- "selectmode",
- (isMultiSelect() ? "multi" : "single"));
+ target.addAttribute("selectmode", (isMultiSelect() ? "multi"
+ : "single"));
else
target.addAttribute("selectmode", "none");
if (isNewItemsAllowed())
@@ -417,13 +426,10 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
// Actions
if (actionHandlers != null) {
target.startTag("al");
- for (Iterator ahi = actionHandlers.iterator();
- ahi.hasNext();
- ) {
- Action[] aa =
- ((Action.Handler) ahi.next()).getActions(
- itemId,
- this);
+ for (Iterator ahi = actionHandlers.iterator(); ahi
+ .hasNext();) {
+ 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]);
@@ -435,8 +441,8 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
}
// Adds the children if expanded, or close the tag
- if (isExpanded(itemId) && hasChildren(itemId)
- && areChildrenAllowed(itemId)) {
+ if (isExpanded(itemId) && hasChildren(itemId)
+ && areChildrenAllowed(itemId)) {
iteratorStack.push(getChildren(itemId).iterator());
} else {
if (isNode)
@@ -468,20 +474,18 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
target.addVariable(this, "selected", selectedKeys);
// Expand and collapse
- target.addVariable(this, "expand", new String[] {
- });
- target.addVariable(this, "collapse", new String[] {
- });
+ target.addVariable(this, "expand", new String[] {});
+ target.addVariable(this, "collapse", new String[] {});
// New items
- target.addVariable(this, "newitem", new String[] {
- });
+ target.addVariable(this, "newitem", new String[] {});
}
/* Container.Hierarchical API ***************************************** */
/**
* Tests if the Item with given ID can have any children.
+ *
* @see com.itmill.toolkit.data.Container.Hierarchical#areChildrenAllowed(Object)
*/
public boolean areChildrenAllowed(Object itemId) {
@@ -490,6 +494,7 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Gets the IDs of all Items that are children of the specified Item.
+ *
* @see com.itmill.toolkit.data.Container.Hierarchical#getChildren(Object)
*/
public Collection getChildren(Object itemId) {
@@ -498,6 +503,7 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Gets the ID of the parent Item of the specified Item.
+ *
* @see com.itmill.toolkit.data.Container.Hierarchical#getParent(Object)
*/
public Object getParent(Object itemId) {
@@ -506,7 +512,8 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Tests if the Item specified with <code>itemId</code> has any child
- * Items, that is, is it a leaf Item.
+ * Items, that is, is it a leaf Item.
+ *
* @see com.itmill.toolkit.data.Container.Hierarchical#hasChildren(Object)
*/
public boolean hasChildren(Object itemId) {
@@ -514,8 +521,8 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
}
/**
- * Tests if the Item specified with <code>itemId</code> is a root
- * Item.
+ * Tests if the Item specified with <code>itemId</code> is a root Item.
+ *
* @see com.itmill.toolkit.data.Container.Hierarchical#isRoot(Object)
*/
public boolean isRoot(Object itemId) {
@@ -524,6 +531,7 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Gets the IDs of all Items in the container that don't have a parent.
+ *
* @see com.itmill.toolkit.data.Container.Hierarchical#rootItemIds()
*/
public Collection rootItemIds() {
@@ -532,15 +540,13 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Sets the given Item's capability to have children.
- * @see com.itmill.toolkit.data.Container.Hierarchical#setChildrenAllowed(Object, boolean)
- */
- public boolean setChildrenAllowed(
- Object itemId,
- boolean areChildrenAllowed) {
- boolean success =
- ((Container.Hierarchical) items).setChildrenAllowed(
- itemId,
- areChildrenAllowed);
+ *
+ * @see com.itmill.toolkit.data.Container.Hierarchical#setChildrenAllowed(Object,
+ * boolean)
+ */
+ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) {
+ boolean success = ((Container.Hierarchical) items).setChildrenAllowed(
+ itemId, areChildrenAllowed);
if (success)
fireValueChange();
return success;
@@ -548,11 +554,13 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Sets the parent of an Item.
- * @see com.itmill.toolkit.data.Container.Hierarchical#setParent(Object, Object)
+ *
+ * @see com.itmill.toolkit.data.Container.Hierarchical#setParent(Object,
+ * Object)
*/
public boolean setParent(Object itemId, Object newParentId) {
- boolean success =
- ((Container.Hierarchical) items).setParent(itemId, newParentId);
+ boolean success = ((Container.Hierarchical) items).setParent(itemId,
+ newParentId);
if (success)
requestRepaint();
return success;
@@ -562,45 +570,47 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/**
* Sets the Container that serves as the data source of the viewer.
+ *
* @see com.itmill.toolkit.data.Container.Viewer#setContainerDataSource(Container)
*/
public void setContainerDataSource(Container newDataSource) {
- // Assure that the data source is ordered by making unordered
+ // Assure that the data source is ordered by making unordered
// containers ordered by wrapping them
- if (Container
- .Hierarchical
- .class
- .isAssignableFrom(newDataSource.getClass()))
+ if (Container.Hierarchical.class.isAssignableFrom(newDataSource
+ .getClass()))
super.setContainerDataSource(newDataSource);
else
- super.setContainerDataSource(
- new ContainerHierarchicalWrapper(newDataSource));
+ super.setContainerDataSource(new ContainerHierarchicalWrapper(
+ newDataSource));
}
/* Expand event and listener ****************************************** */
/**
- * Event to fired when a node is expanded.
- * ExapandEvent is fired when a node is to be expanded.
- * it can me used to dynamically fill the sub-nodes of the
- * node.
+ * Event to fired when a node is expanded. ExapandEvent is fired when a node
+ * is to be expanded. it can me used to dynamically fill the sub-nodes of
+ * the node.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class ExpandEvent extends Component.Event {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3832624001804481075L;
- private Object expandedItemId;
-
- /**
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3832624001804481075L;
+
+ private Object expandedItemId;
+
+ /**
* New instance of options change event
- * @param source the Source of the event.
+ *
+ * @param source
+ * the Source of the event.
* @param expandedItemId
*/
public ExpandEvent(Component source, Object expandedItemId) {
@@ -608,8 +618,9 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
this.expandedItemId = expandedItemId;
}
- /**
+ /**
* Node where the event occurred.
+ *
* @return the Source of the event.
*/
public Object getItemId() {
@@ -617,67 +628,79 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
}
}
- /**
+ /**
* Expand event listener.
*
* @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
+ * @version
+ * @VERSION@
+ * @since 3.0
*/
public interface ExpandListener {
- /**
+ /**
* A node has been expanded.
- * @param event the Expand event.
+ *
+ * @param event
+ * the Expand event.
*/
public void nodeExpand(ExpandEvent event);
}
- /**
+ /**
* Adds the expand listener.
- * @param listener the Listener to be added.
+ *
+ * @param listener
+ * the Listener to be added.
*/
public void addListener(ExpandListener listener) {
addListener(ExpandEvent.class, listener, EXPAND_METHOD);
}
- /**
+ /**
* Removes the expand listener.
- * @param listener the Listener to be removed.
+ *
+ * @param listener
+ * the Listener to be removed.
*/
public void removeListener(ExpandListener listener) {
removeListener(ExpandEvent.class, listener, EXPAND_METHOD);
}
- /**
- * Emits the expand event.
- * @param itemId the item id.
+ /**
+ * Emits the expand event.
+ *
+ * @param itemId
+ * the item id.
*/
protected void fireExpandEvent(Object itemId) {
fireEvent(new ExpandEvent(this, itemId));
}
- /* Collapse event ****************************************** */
+ /* Collapse event ****************************************** */
- /**
- * Collapse event
+ /**
+ * Collapse event
*
* @author IT Mill Ltd.
- * @version @VERSION@
- * @since 3.0
+ * @version
+ * @VERSION@
+ * @since 3.0
*/
public class CollapseEvent extends Component.Event {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3257009834783290160L;
-
- private Object collapsedItemId;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3257009834783290160L;
+
+ private Object collapsedItemId;
- /**
+ /**
* New instance of options change event.
- * @param source the Source of the event.
+ *
+ * @param source
+ * the Source of the event.
* @param collapsedItemId
*/
public CollapseEvent(Component source, Object collapsedItemId) {
@@ -685,8 +708,9 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
this.collapsedItemId = collapsedItemId;
}
- /**
+ /**
* Gets tge Collapsed Item id.
+ *
* @return the collapsed item id.
*/
public Object getItemId() {
@@ -694,41 +718,50 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
}
}
- /**
+ /**
* Collapse event listener.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface CollapseListener {
- /**
+ /**
* A node has been collapsed.
- * @param event the Collapse event.
+ *
+ * @param event
+ * the Collapse event.
*/
public void nodeCollapse(CollapseEvent event);
}
- /**
+ /**
* Adds the collapse listener.
- * @param listener the Listener to be added.
+ *
+ * @param listener
+ * the Listener to be added.
*/
public void addListener(CollapseListener listener) {
addListener(CollapseEvent.class, listener, COLLAPSE_METHOD);
}
- /**
+ /**
* Removes the collapse listener.
- * @param listener the Listener to be removed.
+ *
+ * @param listener
+ * the Listener to be removed.
*/
public void removeListener(CollapseListener listener) {
removeListener(CollapseEvent.class, listener, COLLAPSE_METHOD);
}
- /**
- * Emits collapse event.
- * @param itemId the item id.
+ /**
+ * Emits collapse event.
+ *
+ * @param itemId
+ * the item id.
*/
protected void fireCollapseEvent(Object itemId) {
fireEvent(new CollapseEvent(this, itemId));
@@ -736,8 +769,9 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
/* Action container *************************************************** */
- /**
+ /**
* Adds an action handler.
+ *
* @see com.itmill.toolkit.event.Action.Container#addActionHandler(Action.Handler)
*/
public void addActionHandler(Action.Handler actionHandler) {
@@ -749,34 +783,36 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
actionMapper = new KeyMapper();
}
- if(!actionHandlers.contains(actionHandler)){
- actionHandlers.add(actionHandler);
- requestRepaint();
- }
+ if (!actionHandlers.contains(actionHandler)) {
+ actionHandlers.add(actionHandler);
+ requestRepaint();
+ }
}
}
- /**
+ /**
* Removes an action handler.
+ *
* @see com.itmill.toolkit.event.Action.Container#removeActionHandler(Action.Handler)
*/
public void removeActionHandler(Action.Handler actionHandler) {
if (actionHandlers != null && actionHandlers.contains(actionHandler)) {
-
- actionHandlers.remove(actionHandler);
-
- if (actionHandlers.isEmpty()) {
- actionHandlers = null;
- actionMapper = null;
- }
-
- requestRepaint();
+
+ actionHandlers.remove(actionHandler);
+
+ if (actionHandlers.isEmpty()) {
+ actionHandlers = null;
+ actionMapper = null;
+ }
+
+ requestRepaint();
}
}
-
+
/**
* Gets the visible item ids.
+ *
* @see com.itmill.toolkit.ui.Select#getVisibleItemIds()
*/
public Collection getVisibleItemIds() {
@@ -816,35 +852,40 @@ public class Tree extends Select implements Container.Hierarchical, Action.Conta
return visible;
}
- /**
- * Adding new items is not supported.
- * @throws UnsupportedOperationException if set to true.
+ /**
+ * Adding new items is not supported.
+ *
+ * @throws UnsupportedOperationException
+ * if set to true.
* @see com.itmill.toolkit.ui.Select#setNewItemsAllowed(boolean)
*/
public void setNewItemsAllowed(boolean allowNewOptions)
- throws UnsupportedOperationException {
+ throws UnsupportedOperationException {
if (allowNewOptions)
throw new UnsupportedOperationException();
}
- /**
+ /**
* Focusing to this component is not supported.
- * @throws UnsupportedOperationException if invoked.
+ *
+ * @throws UnsupportedOperationException
+ * if invoked.
* @see com.itmill.toolkit.ui.AbstractField#focus()
*/
public void focus() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
-
+
/**
- * Tree does not support lazy options loading mode.
- * Setting this true will throw UnsupportedOperationException.
+ * Tree does not support lazy options loading mode. Setting this true will
+ * throw UnsupportedOperationException.
+ *
* @see com.itmill.toolkit.ui.Select#setLazyLoading(boolean)
*/
- public void setLazyLoading(boolean useLazyLoading) {
- if (useLazyLoading)
- throw new UnsupportedOperationException("Lazy options loading is not supported by Tree.");
+ public void setLazyLoading(boolean useLazyLoading) {
+ if (useLazyLoading)
+ throw new UnsupportedOperationException(
+ "Lazy options loading is not supported by Tree.");
}
-
}
diff --git a/src/com/itmill/toolkit/ui/Upload.java b/src/com/itmill/toolkit/ui/Upload.java
index 95da0bf7d1..68276eab7a 100644
--- a/src/com/itmill/toolkit/ui/Upload.java
+++ b/src/com/itmill/toolkit/ui/Upload.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -39,42 +39,44 @@ import com.itmill.toolkit.terminal.UploadStream;
import java.io.IOException;
import java.io.OutputStream;
-/**
+/**
* Component for client file uploading.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Upload extends AbstractComponent implements Component.Focusable {
- /**
- * Upload buffer size.
+ /**
+ * Upload buffer size.
*/
private static final int BUFFER_SIZE = 64 * 1024; // 64k
- /**
- * Should the field be focused on next repaint?
+ /**
+ * Should the field be focused on next repaint?
*/
private boolean focus = false;
- /**
- * The tab order number of this field.
+ /**
+ * The tab order number of this field.
*/
private int tabIndex = 0;
- /**
- * The output of the upload is redirected to this receiver.
+ /**
+ * The output of the upload is redirected to this receiver.
*/
private Receiver receiver;
-
+
private long focusableId = -1;
- /* TODO: Add a default constructor, receive to temp file. */
-
- /**
- * Creates a new instance of Upload that redirects the
- * uploaded data to given stream.
+ /* TODO: Add a default constructor, receive to temp file. */
+
+ /**
+ * Creates a new instance of Upload that redirects the uploaded data to
+ * given stream.
+ *
* @param caption
* @param uploadReceiver
*/
@@ -84,8 +86,9 @@ public class Upload extends AbstractComponent implements Component.Focusable {
receiver = uploadReceiver;
}
- /**
+ /**
* Gets the component type.
+ *
* @return Component type as string.
*/
public String getTag() {
@@ -93,8 +96,10 @@ public class Upload extends AbstractComponent implements Component.Focusable {
}
/**
- * Invoked when the value of a variable has changed.
- * @see com.itmill.toolkit.ui.AbstractComponent#changeVariables(java.lang.Object, java.util.Map)
+ * Invoked when the value of a variable has changed.
+ *
+ * @see com.itmill.toolkit.ui.AbstractComponent#changeVariables(java.lang.Object,
+ * java.util.Map)
*/
public void changeVariables(Object source, Map variables) {
@@ -102,7 +107,7 @@ public class Upload extends AbstractComponent implements Component.Focusable {
if (!variables.containsKey("stream"))
return;
- // Gets the upload stream
+ // Gets the upload stream
UploadStream upload = (UploadStream) variables.get("stream");
// Gets file properties
@@ -112,11 +117,12 @@ public class Upload extends AbstractComponent implements Component.Focusable {
// Gets the output target stream
OutputStream out = receiver.receiveUpload(filename, type);
if (out == null)
- throw new RuntimeException("Error getting outputstream from upload receiver");
+ throw new RuntimeException(
+ "Error getting outputstream from upload receiver");
InputStream in = upload.getStream();
- if (null==in) {
- // No file, for instance non-existent filename in html upload
+ if (null == in) {
+ // No file, for instance non-existent filename in html upload
fireUploadInterrupted(filename, type, 0);
return;
}
@@ -133,7 +139,7 @@ public class Upload extends AbstractComponent implements Component.Focusable {
out.close();
fireUploadSuccess(filename, type, totalBytes);
requestRepaint();
-
+
} catch (IOException e) {
// Download interrupted
@@ -141,10 +147,13 @@ public class Upload extends AbstractComponent implements Component.Focusable {
}
}
- /**
+ /**
* Paints the content of this component.
- * @param target Target to paint the content on.
- * @throws PaintException if the paint operation failed.
+ *
+ * @param target
+ * Target to paint the content on.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
// The field should be focused
@@ -154,23 +163,28 @@ public class Upload extends AbstractComponent implements Component.Focusable {
// The tab ordering number
if (this.tabIndex >= 0)
target.addAttribute("tabindex", this.tabIndex);
-
+
target.addUploadStreamVariable(this, "stream");
}
- /**
+ /**
* Interface that must be implemented by the upload receivers.
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface Receiver {
- /**
- * Invoked when a new upload arrives.
- * @param filename the desired filename of the upload, usually as specified by the client.
- * @param MIMEType the MIME type of the uploaded file.
+ /**
+ * Invoked when a new upload arrives.
+ *
+ * @param filename
+ * the desired filename of the upload, usually as specified
+ * by the client.
+ * @param MIMEType
+ * the MIME type of the uploaded file.
* @return Stream to which the uploaded file should be written.
*/
public OutputStream receiveUpload(String filename, String MIMEType);
@@ -179,86 +193,88 @@ public class Upload extends AbstractComponent implements Component.Focusable {
/* Upload events ************************************************ */
private static final Method UPLOAD_FINISHED_METHOD;
+
private static final Method UPLOAD_FAILED_METHOD;
+
private static final Method UPLOAD_SUCCEEDED_METHOD;
static {
try {
- UPLOAD_FINISHED_METHOD =
- FinishedListener.class.getDeclaredMethod(
- "uploadFinished",
- new Class[] { FinishedEvent.class });
- UPLOAD_FAILED_METHOD =
- FailedListener.class.getDeclaredMethod(
- "uploadFailed",
- new Class[] { FailedEvent.class });
- UPLOAD_SUCCEEDED_METHOD =
- SucceededListener.class.getDeclaredMethod(
- "uploadSucceeded",
- new Class[] { SucceededEvent.class });
+ UPLOAD_FINISHED_METHOD = FinishedListener.class.getDeclaredMethod(
+ "uploadFinished", new Class[] { FinishedEvent.class });
+ UPLOAD_FAILED_METHOD = FailedListener.class.getDeclaredMethod(
+ "uploadFailed", new Class[] { FailedEvent.class });
+ UPLOAD_SUCCEEDED_METHOD = SucceededListener.class
+ .getDeclaredMethod("uploadSucceeded",
+ new Class[] { SucceededEvent.class });
} catch (java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException("Internal error");
}
}
- /**
- * Upload.Received event is sent when the upload receives a file,
- * regardless if the receival was successfull.
+ /**
+ * Upload.Received event is sent when the upload receives a file, regardless
+ * if the receival was successfull.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class FinishedEvent extends Component.Event {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3257288015385670969L;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3257288015385670969L;
- /**
- * Length of the received file.
- */
+ /**
+ * Length of the received file.
+ */
private long length;
- /**
- * MIME type of the received file.
+ /**
+ * MIME type of the received file.
*/
private String type;
- /**
- * Received file name.
+ /**
+ * Received file name.
*/
private String filename;
-
+
/**
*
- * @param source the source of the file.
- * @param filename the received file name.
- * @param MIMEType the MIME type of the received file.
- * @param length the length of the received file.
+ * @param source
+ * the source of the file.
+ * @param filename
+ * the received file name.
+ * @param MIMEType
+ * the MIME type of the received file.
+ * @param length
+ * the length of the received file.
*/
- public FinishedEvent(
- Upload source,
- String filename,
- String MIMEType,
- long length) {
+ public FinishedEvent(Upload source, String filename, String MIMEType,
+ long length) {
super(source);
this.type = MIMEType;
this.filename = filename;
this.length = length;
}
- /**
+ /**
* Uploads where the event occurred.
+ *
* @return the Source of the event.
*/
public Upload getUpload() {
return (Upload) getSource();
}
+
/**
* Gets the file name.
+ *
* @return the filename.
*/
public String getFilename() {
@@ -267,6 +283,7 @@ public class Upload extends AbstractComponent implements Component.Focusable {
/**
* Gets the length of the file.
+ *
* @return the length.
*/
public long getLength() {
@@ -275,6 +292,7 @@ public class Upload extends AbstractComponent implements Component.Focusable {
/**
* Gets the MIME Type of the file.
+ *
* @return the MIME type.
*/
public String getMIMEType() {
@@ -283,21 +301,22 @@ public class Upload extends AbstractComponent implements Component.Focusable {
}
- /**
+ /**
* Upload.Interrupted event is sent when the upload is received, but the
* reception is interrupted for some reason.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class FailedEvent extends FinishedEvent {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3833746590157386293L;
-
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3833746590157386293L;
+
/**
*
* @param source
@@ -305,30 +324,28 @@ public class Upload extends AbstractComponent implements Component.Focusable {
* @param MIMEType
* @param length
*/
- public FailedEvent(
- Upload source,
- String filename,
- String MIMEType,
- long length) {
+ public FailedEvent(Upload source, String filename, String MIMEType,
+ long length) {
super(source, filename, MIMEType, length);
}
}
- /**
+ /**
* Upload.Success event is sent when the upload is received successfully.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class SucceededEvent extends FinishedEvent {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3256445798169524023L;
-
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3256445798169524023L;
+
/**
*
* @param source
@@ -336,168 +353,189 @@ public class Upload extends AbstractComponent implements Component.Focusable {
* @param MIMEType
* @param length
*/
- public SucceededEvent(
- Upload source,
- String filename,
- String MIMEType,
- long length) {
+ public SucceededEvent(Upload source, String filename, String MIMEType,
+ long length) {
super(source, filename, MIMEType, length);
}
}
- /**
+ /**
* Receives the events when the uploads are ready.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface FinishedListener {
- /**
+ /**
* Upload has finished.
- * @param event the Upload finished event.
+ *
+ * @param event
+ * the Upload finished event.
*/
public void uploadFinished(FinishedEvent event);
}
- /**
+ /**
* Receives events when the uploads are finished, but unsuccessful.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface FailedListener {
- /**
+ /**
* Upload has finished unsuccessfully.
- * @param event the Upload failed event.
+ *
+ * @param event
+ * the Upload failed event.
*/
public void uploadFailed(FailedEvent event);
}
- /**
+ /**
* Receives events when the uploads are successfully finished.
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public interface SucceededListener {
- /**
+ /**
* Upload successfull..
- * @param event the Upload successfull event.
+ *
+ * @param event
+ * the Upload successfull event.
*/
public void uploadSucceeded(SucceededEvent event);
}
- /**
+ /**
* Adds the upload received event listener.
- * @param listener the Listener to be added.
+ *
+ * @param listener
+ * the Listener to be added.
*/
public void addListener(FinishedListener listener) {
addListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD);
}
- /**
+ /**
* Removes the upload received event listener.
- * @param listener the Listener to be removed.
+ *
+ * @param listener
+ * the Listener to be removed.
*/
public void removeListener(FinishedListener listener) {
removeListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD);
}
- /**
+ /**
* Adds the upload interrupted event listener.
- * @param listener the Listener to be added.
+ *
+ * @param listener
+ * the Listener to be added.
*/
public void addListener(FailedListener listener) {
addListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD);
}
- /**
+ /**
* Removes the upload interrupted event listener.
- * @param listener the Listener to be removed.
+ *
+ * @param listener
+ * the Listener to be removed.
*/
public void removeListener(FailedListener listener) {
removeListener(FinishedEvent.class, listener, UPLOAD_FAILED_METHOD);
}
- /**
+ /**
* Adds the upload success event listener.
- * @param listener the Listener to be added.
+ *
+ * @param listener
+ * the Listener to be added.
*/
public void addListener(SucceededListener listener) {
addListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD);
}
- /**
+ /**
* Removes the upload success event listener.
- * @param listener the Listener to be removed.
+ *
+ * @param listener
+ * the Listener to be removed.
*/
public void removeListener(SucceededListener listener) {
removeListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD);
}
- /**
+ /**
* Emit upload received event.
+ *
* @param filename
- * @param MIMEType
- * @param length
+ * @param MIMEType
+ * @param length
*/
- protected void fireUploadReceived(
- String filename,
- String MIMEType,
- long length) {
+ protected void fireUploadReceived(String filename, String MIMEType,
+ long length) {
fireEvent(new Upload.FinishedEvent(this, filename, MIMEType, length));
}
- /**
+ /**
* Emits the upload interrupted event.
+ *
* @param filename
* @param MIMEType
- * @param length
+ * @param length
*/
- protected void fireUploadInterrupted(
- String filename,
- String MIMEType,
- long length) {
+ protected void fireUploadInterrupted(String filename, String MIMEType,
+ long length) {
fireEvent(new Upload.FailedEvent(this, filename, MIMEType, length));
}
- /**
+ /**
* Emits the upload success event.
+ *
* @param filename
* @param MIMEType
* @param length
- *
+ *
*/
- protected void fireUploadSuccess(
- String filename,
- String MIMEType,
- long length) {
+ protected void fireUploadSuccess(String filename, String MIMEType,
+ long length) {
fireEvent(new Upload.SucceededEvent(this, filename, MIMEType, length));
}
- /**
+
+ /**
* Returns the current receiver.
+ *
* @return the Receiver.
*/
public Receiver getReceiver() {
return receiver;
}
- /**
+ /**
* Sets the receiver.
- * @param receiver the receiver to set.
+ *
+ * @param receiver
+ * the receiver to set.
*/
public void setReceiver(Receiver receiver) {
this.receiver = receiver;
}
-
+
/**
* Sets the focus to this component.
+ *
* @see com.itmill.toolkit.ui.Component.Focusable#focus()
*/
public void focus() {
@@ -506,25 +544,28 @@ public class Upload extends AbstractComponent implements Component.Focusable {
w.setFocusedComponent(this);
}
}
-
+
/**
* Gets the Tabulator index of this Focusable component.
+ *
* @see com.itmill.toolkit.ui.Component.Focusable#getTabIndex()
*/
public int getTabIndex() {
return this.tabIndex;
}
-
+
/**
* Sets the Tabulator index of this Focusable component.
+ *
* @see com.itmill.toolkit.ui.Component.Focusable#setTabIndex(int)
*/
public void setTabIndex(int tabIndex) {
this.tabIndex = tabIndex;
}
-
+
/**
* Gets the unique ID of focusable.
+ *
* @see com.itmill.toolkit.ui.Component.Focusable#getFocusableId()
*/
public long getFocusableId() {
diff --git a/src/com/itmill/toolkit/ui/Window.java b/src/com/itmill/toolkit/ui/Window.java
index 1cdebe2b7d..8f85fee1eb 100644
--- a/src/com/itmill/toolkit/ui/Window.java
+++ b/src/com/itmill/toolkit/ui/Window.java
@@ -57,38 +57,38 @@ import java.util.Iterator;
*/
public class Window extends Panel implements URIHandler, ParameterHandler {
- /**
- * Window with no border.
+ /**
+ * Window with no border.
*/
public static final int BORDER_NONE = 0;
- /**
- * Window with only minimal border.
+ /**
+ * Window with only minimal border.
*/
public static final int BORDER_MINIMAL = 1;
- /**
- * Window with default borders.
+ /**
+ * Window with default borders.
*/
public static final int BORDER_DEFAULT = 2;
- /**
- * The terminal this window is attached to.
+ /**
+ * The terminal this window is attached to.
*/
private Terminal terminal = null;
- /**
- * The applicaiton this window is attached to.
+ /**
+ * The applicaiton this window is attached to.
*/
private Application application = null;
- /**
- * List of URI handlers for this window.
+ /**
+ * List of URI handlers for this window.
*/
private LinkedList uriHandlerList = null;
- /**
- * List of parameter handlers for this window.
+ /**
+ * List of parameter handlers for this window.
*/
private LinkedList parameterHandlerList = null;
@@ -98,39 +98,38 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
*/
private String theme = null;
- /**
- * Resources to be opened automatically on next repaint.
+ /**
+ * Resources to be opened automatically on next repaint.
*/
private LinkedList openList = new LinkedList();
- /**
- * The name of the window.
+ /**
+ * The name of the window.
*/
private String name = null;
- /**
- * Window border mode.
+ /**
+ * Window border mode.
*/
private int border = BORDER_DEFAULT;
- /**
- * Focused component.
+ /**
+ * Focused component.
*/
private Focusable focusedComponent;
-
- /**
- * Distance of Window top border in pixels from top border of the
- * containing (main window) or -1 if unspecified.
+
+ /**
+ * Distance of Window top border in pixels from top border of the containing
+ * (main window) or -1 if unspecified.
*/
private int positionY = -1;
- /**
- * Distance of Window left border in pixels from left border of the
+ /**
+ * Distance of Window left border in pixels from left border of the
* containing (main window) or -1 if unspecified .
*/
private int positionX = -1;
-
/* ********************************************************************* */
/**
@@ -216,9 +215,9 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
}
/**
- * Gets the application instance of the component. Returns the application where
- * this component belongs to. If the component does not yet belong to a
- * application the returns null.
+ * Gets the application instance of the component. Returns the application
+ * where this component belongs to. If the component does not yet belong to
+ * a application the returns null.
*
* @return the parent application of the component.
*/
@@ -259,9 +258,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
/* ********************************************************************* */
- /**
+ /**
* Adds the new URI handler to this window.
- * @param handler the URI handler to add.
+ *
+ * @param handler
+ * the URI handler to add.
*/
public void addURIHandler(URIHandler handler) {
if (uriHandlerList == null)
@@ -272,9 +273,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
}
}
- /**
+ /**
* Removes the given URI handler from this window.
- * @param handler the URI handler to remove.
+ *
+ * @param handler
+ * the URI handler to remove.
*/
public void removeURIHandler(URIHandler handler) {
if (handler == null || uriHandlerList == null)
@@ -288,6 +291,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
/**
* Handles uri recursively.
+ *
* @param context
* @param relativeUri
*/
@@ -315,9 +319,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
/* ********************************************************************* */
- /**
+ /**
* Adds the new parameter handler to this window.
- * @param handler the parameter handler to add.
+ *
+ * @param handler
+ * the parameter handler to add.
*/
public void addParameterHandler(ParameterHandler handler) {
if (parameterHandlerList == null)
@@ -328,9 +334,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
}
}
- /**
+ /**
* Removes the given URI handler from this window.
- * @param handler the parameter handler to remove.
+ *
+ * @param handler
+ * the parameter handler to remove.
*/
public void removeParameterHandler(ParameterHandler handler) {
if (handler == null || parameterHandlerList == null)
@@ -423,7 +431,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
// Window position
target.addVariable(this, "positionx", getPositionX());
target.addVariable(this, "positiony", getPositionY());
-
+
// Window closing
target.addVariable(this, "close", false);
@@ -440,7 +448,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
/**
* Opens the given resource in this window.
- * @param resource
+ *
+ * @param resource
*/
public void open(Resource resource) {
synchronized (openList) {
@@ -457,8 +466,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
* Opens the given resource in named terminal window. Empty or
* <code>null</code> window name results the resource to be opened in this
* window.
- * @param resource the resource.
- * @param windowName the name of the window.
+ *
+ * @param resource
+ * the resource.
+ * @param windowName
+ * the name of the window.
*/
public void open(Resource resource, String windowName) {
synchronized (openList) {
@@ -475,11 +487,12 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
* Opens the given resource in named terminal window with given size and
* border properties. Empty or <code>null</code> window name results the
* resource to be opened in this window.
- * @param resource
+ *
+ * @param resource
* @param windowName
* @param width
* @param height
- * @param border
+ * @param border
*/
public void open(Resource resource, String windowName, int width,
int height, int border) {
@@ -616,8 +629,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
}
/**
- * Sets the terminal type. The terminal type is set by the the terminal adapter
- * and may change from time to time.
+ * Sets the terminal type. The terminal type is set by the the terminal
+ * adapter and may change from time to time.
*
* @param type
* the terminal type to set.
@@ -646,8 +659,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
throw new IllegalArgumentException("Only pixels are supported");
}
- /**
- * Private data structure for storing opening window properties.
+ /**
+ * Private data structure for storing opening window properties.
*/
private class OpenResource {
@@ -661,13 +674,14 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
private int border;
- /**
+ /**
* Creates a new open resource.
+ *
* @param resource
* @param name
* @param width
* @param height
- * @param border
+ * @param border
*/
private OpenResource(Resource resource, String name, int width,
int height, int border) {
@@ -678,10 +692,13 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
this.border = border;
}
- /**
+ /**
* Paints the open-tag inside the window.
- * @param target the Paint Event.
- * @throws PaintException if the Paint Operation fails.
+ *
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the Paint Operation fails.
*/
private void paintContent(PaintTarget target) throws PaintException {
target.startTag("open");
@@ -706,8 +723,9 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
}
/**
- * Called when one or more variables handled by the implementing class
- * are changed.
+ * Called when one or more variables handled by the implementing class are
+ * changed.
+ *
* @see com.itmill.toolkit.terminal.VariableOwner#changeVariables(java.lang.Object,
* java.util.Map)
*/
@@ -724,19 +742,19 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
// We ignore invalid focusable ids
}
}
-
+
// Positioning
Integer positionx = (Integer) variables.get("positionx");
if (positionx != null) {
int x = positionx.intValue();
- setPositionX(x<0?-1:x);
+ setPositionX(x < 0 ? -1 : x);
}
Integer positiony = (Integer) variables.get("positiony");
if (positiony != null) {
int y = positiony.intValue();
- setPositionY(y<0?-1:y);
+ setPositionY(y < 0 ? -1 : y);
}
-
+
// Closing
Boolean close = (Boolean) variables.get("close");
if (close != null && close.booleanValue()) {
@@ -771,9 +789,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
private static Map focusableComponents = new HashMap();
- /**
+ /**
* Gets an id for focusable component.
- * @param focusable the focused component.
+ *
+ * @param focusable
+ * the focused component.
*/
public static long getNewFocusableId(Component.Focusable focusable) {
long newId = ++lastUsedFocusableId;
@@ -782,9 +802,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
return newId;
}
- /**
+ /**
* Maps the focusable id back to focusable component.
- * @param focusableId the Focused Id.
+ *
+ * @param focusableId
+ * the Focused Id.
* @return the focusable Id.
*/
public static Component.Focusable getFocusableById(long focusableId) {
@@ -799,9 +821,11 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
return null;
}
- /**
+ /**
* Releases the focusable component id when not used anymore.
- * @param focusableId the focusable Id to remove.
+ *
+ * @param focusableId
+ * the focusable Id to remove.
*/
public static void removeFocusableId(long focusableId) {
Long id = new Long(focusableId);
@@ -810,33 +834,37 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
focusableComponents.remove(id);
}
- /**
- * Gets the distance of Window left border in pixels from left
- * border of the containing (main window).
- * @return the Distance of Window left border in pixels from left
- * border of the containing (main window). or -1 if unspecified.
- * @since 4.0.0
+ /**
+ * Gets the distance of Window left border in pixels from left border of the
+ * containing (main window).
+ *
+ * @return the Distance of Window left border in pixels from left border of
+ * the containing (main window). or -1 if unspecified.
+ * @since 4.0.0
*/
public int getPositionX() {
return positionX;
}
- /**
- * Sets the distance of Window left border in pixels from left border
- * of the containing (main window).
- * @param positionX the Distance of Window left border in pixels from left
- * border of the containing (main window). or -1 if unspecified.
- * @since 4.0.0
- */
+ /**
+ * Sets the distance of Window left border in pixels from left border of the
+ * containing (main window).
+ *
+ * @param positionX
+ * the Distance of Window left border in pixels from left border
+ * of the containing (main window). or -1 if unspecified.
+ * @since 4.0.0
+ */
public void setPositionX(int positionX) {
this.positionX = positionX;
}
- /**
- * Gets the distance of Window top border in pixels from top border of
- * the containing (main window).
+ /**
+ * Gets the distance of Window top border in pixels from top border of the
+ * containing (main window).
+ *
* @return Distance of Window top border in pixels from top border of the
- * containing (main window). or -1 if unspecified .
+ * containing (main window). or -1 if unspecified .
*
* @since 4.0.0
*/
@@ -844,37 +872,38 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
return positionY;
}
- /**
- * Sets the distance of Window top border in pixels from top border of the containing (main window).
- * @param positionY the Distance of Window top border in pixels from top border of the containing (main window). or -1 if unspecified
+ /**
+ * Sets the distance of Window top border in pixels from top border of the
+ * containing (main window).
+ *
+ * @param positionY
+ * the Distance of Window top border in pixels from top border of
+ * the containing (main window). or -1 if unspecified
*
* @since 4.0.0
*/
public void setPositionY(int positionY) {
this.positionY = positionY;
}
-
+
private static final Method WINDOW_CLOSE_METHOD;
static {
try {
- WINDOW_CLOSE_METHOD =
- CloseListener.class.getDeclaredMethod(
- "windowClose",
- new Class[] { CloseEvent.class });
+ WINDOW_CLOSE_METHOD = CloseListener.class.getDeclaredMethod(
+ "windowClose", new Class[] { CloseEvent.class });
} catch (java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException();
}
}
-
public class CloseEvent extends Component.Event {
-
+
/**
- * Serial generated by eclipse.
+ * Serial generated by eclipse.
*/
private static final long serialVersionUID = -7235770057344367327L;
-
+
/**
*
* @param source
@@ -882,23 +911,26 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
public CloseEvent(Component source) {
super(source);
}
-
+
/**
* Gets the Window.
+ *
* @return the window.
*/
public Window getWindow() {
return (Window) getSource();
}
}
-
+
public interface CloseListener {
public void windowClose(CloseEvent e);
}
-
+
/**
* Adds the listener.
- * @param listener the listener to add.
+ *
+ * @param listener
+ * the listener to add.
*/
public void addListener(CloseListener listener) {
addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
@@ -906,7 +938,9 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
/**
* Removes the listener.
- * @param listener the listener to remove.
+ *
+ * @param listener
+ * the listener to remove.
*/
public void removeListener(CloseListener listener) {
addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
diff --git a/src/com/itmill/toolkit/ui/select/ContainsFilter.java b/src/com/itmill/toolkit/ui/select/ContainsFilter.java
index c03542de67..788c821043 100644
--- a/src/com/itmill/toolkit/ui/select/ContainsFilter.java
+++ b/src/com/itmill/toolkit/ui/select/ContainsFilter.java
@@ -8,26 +8,24 @@ import com.itmill.toolkit.ui.Select;
public class ContainsFilter implements OptionFilter {
private Select s;
-
+
private ArrayList filteredItemsBuffer;
public ContainsFilter(Select s) {
this.s = s;
}
-
public ArrayList filter(String filterstring) {
// prefix MUST be in lowercase
if ("".equals(filterstring)) {
this.filteredItemsBuffer = new ArrayList(s.getItemIds());
return this.filteredItemsBuffer;
- } else if (s.getContainerDataSource() != null) {
+ } else if (s.getContainerDataSource() != null) {
// all items will be iterated and tested.
// SLOW when there are lot of items.
this.filteredItemsBuffer = new ArrayList();
- for (Iterator iter = s.getItemIds().iterator(); iter
- .hasNext();) {
+ for (Iterator iter = s.getItemIds().iterator(); iter.hasNext();) {
Object id = iter.next();
Item item = s.getItem(id);
@@ -43,6 +41,6 @@ public class ContainsFilter implements OptionFilter {
}
}
}
- return this.filteredItemsBuffer;
+ return this.filteredItemsBuffer;
}
}
diff --git a/src/com/itmill/toolkit/ui/select/StartsWithFilter.java b/src/com/itmill/toolkit/ui/select/StartsWithFilter.java
index 62b0ad0e28..753b85ecb5 100644
--- a/src/com/itmill/toolkit/ui/select/StartsWithFilter.java
+++ b/src/com/itmill/toolkit/ui/select/StartsWithFilter.java
@@ -8,7 +8,7 @@ import com.itmill.toolkit.ui.Select;
public class StartsWithFilter implements OptionFilter {
private Select s;
-
+
public StartsWithFilter(Select s) {
this.s = s;
}
@@ -21,12 +21,11 @@ public class StartsWithFilter implements OptionFilter {
this.filteredItemsBuffer = new ArrayList(s.getItemIds());
return this.filteredItemsBuffer;
- } else if (s.getContainerDataSource() != null) {
+ } else if (s.getContainerDataSource() != null) {
// all items will be iterated and tested.
// SLOW when there are lot of items.
this.filteredItemsBuffer = new ArrayList();
- for (Iterator iter = s.getItemIds().iterator(); iter
- .hasNext();) {
+ for (Iterator iter = s.getItemIds().iterator(); iter.hasNext();) {
Object id = iter.next();
Item item = s.getItem(id);
@@ -42,6 +41,6 @@ public class StartsWithFilter implements OptionFilter {
}
}
}
- return this.filteredItemsBuffer;
+ return this.filteredItemsBuffer;
}
}