From b3a85cbe273719e3f0775f30c47563df9285f5bd Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 28 Aug 2008 06:03:32 +0000 Subject: Fixed for #2006 - updated error handling svn changeset:5281/svn branch:trunk --- src/com/itmill/toolkit/Application.java | 164 ++++++----- .../toolkit/data/util/FilesystemContainer.java | 104 +++---- src/com/itmill/toolkit/event/EventRouter.java | 38 +-- src/com/itmill/toolkit/event/ListenerMethod.java | 198 ++++++------- .../terminal/gwt/client/ApplicationConnection.java | 34 +-- .../toolkit/terminal/gwt/client/BrowserInfo.java | 3 +- .../gwt/client/ClientExceptionHandler.java | 27 ++ .../terminal/gwt/client/DateTimeService.java | 29 +- .../itmill/toolkit/terminal/gwt/client/UIDL.java | 2 +- .../toolkit/terminal/gwt/client/ui/IDateField.java | 9 +- .../toolkit/terminal/gwt/client/ui/IPopupView.java | 22 +- .../terminal/gwt/client/ui/ITextualDate.java | 7 +- .../terminal/gwt/server/ApplicationServlet.java | 318 ++++++++++----------- .../terminal/gwt/server/CommunicationManager.java | 40 +-- .../gwt/server/SystemMessageException.java | 57 ++++ .../terminal/gwt/server/WebApplicationContext.java | 10 +- src/com/itmill/toolkit/ui/AbstractComponent.java | 8 +- .../toolkit/ui/AbstractComponentContainer.java | 9 +- src/com/itmill/toolkit/ui/AbstractField.java | 46 +-- src/com/itmill/toolkit/ui/AbstractSelect.java | 166 ++++++----- src/com/itmill/toolkit/ui/Button.java | 47 ++- src/com/itmill/toolkit/ui/Form.java | 46 +-- src/com/itmill/toolkit/ui/GridLayout.java | 105 +++---- src/com/itmill/toolkit/ui/Label.java | 91 +++--- src/com/itmill/toolkit/ui/LoginForm.java | 3 +- src/com/itmill/toolkit/ui/Slider.java | 97 ++++--- src/com/itmill/toolkit/ui/TabSheet.java | 45 +-- src/com/itmill/toolkit/ui/Table.java | 211 +++++++------- src/com/itmill/toolkit/ui/TextField.java | 52 ++-- src/com/itmill/toolkit/ui/Tree.java | 65 +++-- src/com/itmill/toolkit/ui/Upload.java | 71 +++-- src/com/itmill/toolkit/ui/Window.java | 156 +++++----- 32 files changed, 1180 insertions(+), 1100 deletions(-) create mode 100644 src/com/itmill/toolkit/terminal/gwt/client/ClientExceptionHandler.java create mode 100644 src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java (limited to 'src') diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java index d2067b32ff..6296319498 100644 --- a/src/com/itmill/toolkit/Application.java +++ b/src/com/itmill/toolkit/Application.java @@ -38,9 +38,8 @@ import com.itmill.toolkit.ui.Component.Focusable; *

* Base class required for all IT Mill Toolkit applications. This class provides * all the basic services required by the toolkit. These services allow external - * discovery and manipulation of the user, - * {@link com.itmill.toolkit.ui.Window windows} and themes, and starting and - * stopping the application. + * discovery and manipulation of the user, {@link com.itmill.toolkit.ui.Window + * windows} and themes, and starting and stopping the application. *

* *

@@ -63,8 +62,8 @@ import com.itmill.toolkit.ui.Component.Focusable; *

* *

- * Window access. Application provides methods - * to list, add and remove the windows it contains. + * Window access. Application provides methods to + * list, add and remove the windows it contains. *

* *

@@ -194,8 +193,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* Since version 5.0 all windows can be referenced by their names in url * http://host:port/foo/bar/ where - * http://host:port/foo/ is the application url as returned - * by getURL() and bar is the name of the window. + * http://host:port/foo/ is the application url as returned by + * getURL() and bar is the name of the window. *

* *

@@ -207,10 +206,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* The method should return null if the window does not exists (and is not * created as a side-effect) or if the application is not running anymore - *

. + *

+ * . * * @param name - * the name of the window. + * the name of the window. * @return the window associated with the given URI or null */ public Window getWindow(String name) { @@ -237,22 +237,22 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* Note that all application-level windows can be accessed by their names in * url http://host:port/foo/bar/ where - * http://host:port/foo/ is the application url as returned - * by getURL() and bar is the name of the window. Also note - * that not all windows should be added to application - one can also add - * windows inside other windows - these windows show as smaller windows - * inside those windows. + * http://host:port/foo/ is the application url as returned by + * getURL() and bar is the name of the window. Also note that + * not all windows should be added to application - one can also add windows + * inside other windows - these windows show as smaller windows inside those + * windows. *

* * @param window - * the new Window to add. If the name of the - * window is null, an unique name is - * automatically given for the window. + * the new Window to add. If the name of the window + * is null, an unique name is automatically given + * for the window. * @throws IllegalArgumentException - * if a window with the same name as the new window already - * exists in the application. + * if a window with the same name as the new window already + * exists in the application. * @throws NullPointerException - * if the given Window is null. + * if the given Window is null. */ public void addWindow(Window window) throws IllegalArgumentException, NullPointerException { @@ -327,7 +327,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Removes the specified window from the application. * * @param window - * the window to be removed. + * the window to be removed. */ public void removeWindow(Window window) { if (window != null && windows.contains(window)) { @@ -382,7 +382,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* * @param user - * the new user. + * the new user. */ public void setUser(Object user) { final Object prevUser = this.user; @@ -428,12 +428,12 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * {@link javax.servlet.ServletContext}. * * @param applicationUrl - * the URL the application should respond to. + * the URL the application should respond to. * @param applicationProperties - * the Application properties as specified by the servlet - * configuration. + * the Application properties as specified by the servlet + * configuration. * @param context - * the context application will be running in. + * the context application will be running in. * */ public void start(URL applicationUrl, Properties applicationProperties, @@ -494,7 +494,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* * @param theme - * the new theme for this application. + * the new theme for this application. */ public void setTheme(String theme) { @@ -537,7 +537,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* * @param mainWindow - * the mainWindow to set. + * the mainWindow to set. */ public void setMainWindow(Window mainWindow) { @@ -567,7 +567,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * are defined. * * @param name - * the name of the property. + * the name of the property. * @return the value in this property list with the specified key value. */ public String getProperty(String name) { @@ -579,7 +579,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * user of the application. * * @param resource - * the resource to add. + * the resource to add. */ public void addResource(ApplicationResource resource) { @@ -600,7 +600,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Removes the resource from the application. * * @param resource - * the resource to remove. + * the resource to remove. */ public void removeResource(ApplicationResource resource) { final Object key = resourceKeyMap.get(resource); @@ -614,7 +614,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Gets the relative uri of the resource. * * @param resource - * the resource to get relative location. + * the resource to get relative location. * @return the relative uri of the resource. */ public String getRelativeLocation(ApplicationResource resource) { @@ -692,6 +692,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener : ""; return window.handleURI(windowContext, windowUri); } catch (final MalformedURLException e) { + terminalError(new ApplicationError(e)); return null; } } @@ -722,7 +723,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Sets the default locale for this application. * * @param locale - * the Locale object. + * the Locale object. * */ public void setLocale(Locale locale) { @@ -761,11 +762,11 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Constructor for user change event. * * @param source - * the application source. + * the application source. * @param newUser - * the new User. + * the new User. * @param prevUser - * the previous User. + * the previous User. */ public UserChangeEvent(Application source, Object newUser, Object prevUser) { @@ -818,7 +819,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * application user has changed. * * @param event - * the change event. + * the change event. */ public void applicationUserChanged(Application.UserChangeEvent event); } @@ -827,7 +828,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * 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) { @@ -840,7 +841,7 @@ 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) { @@ -868,7 +869,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Creates a event. * * @param window - * the Detached window. + * the Detached window. */ public WindowDetachEvent(Window window) { super(Application.this); @@ -910,7 +911,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Creates a event. * * @param window - * the Attached window. + * the Attached window. */ public WindowAttachEvent(Window window) { super(Application.this); @@ -945,7 +946,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Window attached * * @param event - * the window attach event. + * the window attach event. */ public void windowAttached(WindowAttachEvent event); } @@ -959,7 +960,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Window detached. * * @param event - * the window detach event. + * the window detach event. */ public void windowDetached(WindowDetachEvent event); } @@ -968,7 +969,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Adds the window attach listener. * * @param listener - * the window attach listener to add. + * the window attach listener to add. */ public void addListener(WindowAttachListener listener) { if (windowAttachListeners == null) { @@ -981,7 +982,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Adds the window detach listener. * * @param listener - * the window detach listener to add. + * the window detach listener to add. */ public void addListener(WindowDetachListener listener) { if (windowDetachListeners == null) { @@ -994,7 +995,7 @@ 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) { @@ -1009,7 +1010,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Removes the window detach listener. * * @param listener - * the window detach listener to remove. + * the window detach listener to remove. */ public void removeListener(WindowDetachListener listener) { if (windowDetachListeners != null) { @@ -1022,8 +1023,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * Returns the URL user is redirected to on application close. If the URL is - * null, the application is closed normally as defined by - * the application running environment. + * null, the application is closed normally as defined by the + * application running environment. *

* Desktop application just closes the application window and * web-application redirects the browser to application main URL. @@ -1037,13 +1038,13 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * Sets the URL user is redirected to on application close. If the URL is - * null, the application is closed normally as defined by - * the application running environment: Desktop application just closes the + * null, the application is closed normally as defined by the + * application running environment: Desktop application just closes the * application window and web-application redirects the browser to * application main URL. * * @param logoutURL - * the logoutURL to set. + * the logoutURL to set. */ public void setLogoutURL(String logoutURL) { this.logoutURL = logoutURL; @@ -1068,9 +1069,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* Invoked by the terminal on any exception that occurs in application and * is thrown by the setVariable to the terminal. The default - * implementation sets the exceptions as ComponentErrors to - * the component that initiated the exception and prints stack trace to - * standard error stream. + * implementation sets the exceptions as ComponentErrors to the + * component that initiated the exception and prints stack trace to standard + * error stream. *

*

* You can safely override this method in your application in order to @@ -1078,7 +1079,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* * @param event - * the change event. + * the change event. * @see com.itmill.toolkit.terminal.Terminal.ErrorListener#terminalError(com.itmill.toolkit.terminal.Terminal.ErrorEvent) */ public void terminalError(Terminal.ErrorEvent event) { @@ -1324,18 +1325,18 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* The default behavior is to show a notification, and restart the * application the the user clicks the message.
Instead of restarting - * the application, you can set a specific URL that the user is taken to.
- * Setting both caption and message to null will restart the application (or - * go to the specified URL) without displaying a notification. - * set*NotificationEnabled(false) will achieve the same thing. + * the application, you can set a specific URL that the user is taken + * to.
Setting both caption and message to null will restart the + * application (or go to the specified URL) without displaying a + * notification. set*NotificationEnabled(false) will achieve the same thing. *

*

* The situations are: - *

  • Session expired: the user session has expired, usually due to + *
  • Session expired: the user session has expired, usually due to * inactivity.
  • - *
  • Internal error: unhandled critical server error (e.g out of memory, + *
  • Internal error: unhandled critical server error (e.g out of memory, * database crash) - *
  • Out of sync: the client is not in sync with the server. E.g the user + *
  • Out of sync: the client is not in sync with the server. E.g the user * opens two windows showing the same application, and makes changes in one * of the windows - the other window is no longer in sync, and (for * instance) pressing a button that is no longer present in the UI will @@ -1351,7 +1352,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Sets the URL to go to when the session has expired. * * @param sessionExpiredURL - * the URL to go to, or null to reload current + * the URL to go to, or null to reload current */ public void setSessionExpiredURL(String sessionExpiredURL) { this.sessionExpiredURL = sessionExpiredURL; @@ -1362,7 +1363,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * current) is loaded directly. * * @param sessionExpiredNotificationEnabled - * true = enabled, false = disabled + * true = enabled, false = disabled */ public void setSessionExpiredNotificationEnabled( boolean sessionExpiredNotificationEnabled) { @@ -1374,7 +1375,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * both caption and message is null, the notification is disabled; * * @param sessionExpiredCaption - * the caption + * the caption */ public void setSessionExpiredCaption(String sessionExpiredCaption) { this.sessionExpiredCaption = sessionExpiredCaption; @@ -1385,7 +1386,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * both caption and message is null, the notification is disabled; * * @param sessionExpiredMessage - * the message + * the message */ public void setSessionExpiredMessage(String sessionExpiredMessage) { this.sessionExpiredMessage = sessionExpiredMessage; @@ -1395,7 +1396,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Sets the URL to go to when an internal error occurs. * * @param internalErrorURL - * the URL to go to, or null to reload current + * the URL to go to, or null to reload current */ public void setInternalErrorURL(String internalErrorURL) { this.internalErrorURL = internalErrorURL; @@ -1406,7 +1407,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * current) is loaded directly. * * @param internalErrorNotificationEnabled - * true = enabled, false = disabled + * true = enabled, false = disabled */ public void setInternalErrorNotificationEnabled( boolean internalErrorNotificationEnabled) { @@ -1418,7 +1419,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * both caption and message is null, the notification is disabled; * * @param internalErrorCaption - * the caption + * the caption */ public void setInternalErrorCaption(String internalErrorCaption) { this.internalErrorCaption = internalErrorCaption; @@ -1429,7 +1430,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * both caption and message is null, the notification is disabled; * * @param internalErrorMessage - * the message + * the message */ public void setInternalErrorMessage(String internalErrorMessage) { this.internalErrorMessage = internalErrorMessage; @@ -1439,7 +1440,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * Sets the URL to go to when the client is out-of-sync. * * @param outOfSyncURL - * the URL to go to, or null to reload current + * the URL to go to, or null to reload current */ public void setOutOfSyncURL(String outOfSyncURL) { this.outOfSyncURL = outOfSyncURL; @@ -1450,7 +1451,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * current) is loaded directly. * * @param outOfSyncNotificationEnabled - * true = enabled, false = disabled + * true = enabled, false = disabled */ public void setOutOfSyncNotificationEnabled( boolean outOfSyncNotificationEnabled) { @@ -1462,7 +1463,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * both caption and message is null, the notification is disabled; * * @param outOfSyncCaption - * the caption + * the caption */ public void setOutOfSyncCaption(String outOfSyncCaption) { this.outOfSyncCaption = outOfSyncCaption; @@ -1473,7 +1474,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * both caption and message is null, the notification is disabled; * * @param outOfSyncMessage - * the message + * the message */ public void setOutOfSyncMessage(String outOfSyncMessage) { this.outOfSyncMessage = outOfSyncMessage; @@ -1481,4 +1482,17 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener } + public class ApplicationError implements Terminal.ErrorEvent { + + private Throwable throwable; + + public ApplicationError(Throwable throwable) { + this.throwable = throwable; + } + + public Throwable getThrowable() { + return throwable; + } + + } } \ No newline at end of file diff --git a/src/com/itmill/toolkit/data/util/FilesystemContainer.java b/src/com/itmill/toolkit/data/util/FilesystemContainer.java index b19cefa743..5ede26cc4f 100644 --- a/src/com/itmill/toolkit/data/util/FilesystemContainer.java +++ b/src/com/itmill/toolkit/data/util/FilesystemContainer.java @@ -85,7 +85,8 @@ public class FilesystemContainer implements Container.Hierarchical { FILEITEM_ICON = FileItem.class.getMethod("getIcon", new Class[] {}); FILEITEM_SIZE = FileItem.class.getMethod("getSize", new Class[] {}); } catch (final NoSuchMethodException e) { - + throw new RuntimeException( + "Internal error finding methods in FilesystemContainer"); } } @@ -96,12 +97,12 @@ public class FilesystemContainer implements Container.Hierarchical { private boolean recursive = true; /** - * Constructs a new FileSystemContainer with the specified - * file as the root of the filesystem. The files are included recursively. + * Constructs a new FileSystemContainer 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. + * the root file for the new file-system container. Null values + * are ignored. */ public FilesystemContainer(File root) { if (root != null) { @@ -110,13 +111,13 @@ public class FilesystemContainer implements Container.Hierarchical { } /** - * Constructs a new FileSystemContainer with the specified - * file as the root of the filesystem. The files are included recursively. + * Constructs a new FileSystemContainer 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. + * the root file for the new file-system container. * @param recursive - * should the container recursively contain subdirectories. + * should the container recursively contain subdirectories. */ public FilesystemContainer(File root, boolean recursive) { this(root); @@ -124,16 +125,16 @@ public class FilesystemContainer implements Container.Hierarchical { } /** - * Constructs a new FileSystemContainer with the specified - * file as the root of the filesystem. + * Constructs a new FileSystemContainer with the specified file + * as the root of the filesystem. * * @param root - * the root file for the new file-system container. + * the root file for the new file-system container. * @param extension - * the Filename extension (w/o separator) to limit the files - * in container. + * the Filename extension (w/o separator) to limit the files in + * container. * @param recursive - * should the container recursively contain subdirectories. + * should the container recursively contain subdirectories. */ public FilesystemContainer(File root, String extension, boolean recursive) { this(root); @@ -142,15 +143,15 @@ public class FilesystemContainer implements Container.Hierarchical { } /** - * Constructs a new FileSystemContainer with the specified - * root and recursivity status. + * Constructs a new FileSystemContainer with the specified root + * and recursivity status. * * @param root - * the root file for the new file-system container. + * the root file for the new file-system container. * @param filter - * the Filename filter to limit the files in container. + * the Filename filter to limit the files in container. * @param recursive - * should the container recursively contain subdirectories. + * should the container recursively contain subdirectories. */ public FilesystemContainer(File root, FilenameFilter filter, boolean recursive) { @@ -164,8 +165,8 @@ public class FilesystemContainer implements Container.Hierarchical { * directory in the FilesystemContainer. * * @param root - * the File to be added as root directory. Null values are - * ignored. + * the File to be added as root directory. Null values are + * ignored. */ public void addRoot(File root) { if (root != null) { @@ -184,7 +185,7 @@ public class FilesystemContainer implements Container.Hierarchical { * method returns true for directory Items only. * * @param itemId - * the id of the item. + * the id of the item. * @return true if the specified Item is a directory, * false otherwise. */ @@ -303,14 +304,14 @@ public class FilesystemContainer implements Container.Hierarchical { * not supported. * * @param itemId - * the ID of the item. + * the ID of the item. * @param areChildrenAllowed - * the boolean value specifying if the Item can have children - * or not. + * the boolean value specifying if the Item can have children or + * not. * @return true if the operaton is successful otherwise * false. * @throws UnsupportedOperationException - * if the setChildrenAllowed is not supported. + * if the setChildrenAllowed is not supported. */ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException { @@ -320,18 +321,18 @@ public class FilesystemContainer implements Container.Hierarchical { } /** - * Returns false when moving files around in the filesystem - * is not supported. + * Returns false when moving files around in the filesystem is + * not supported. * * @param itemId - * the ID of the item. + * 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. + * the ID of the Item that's to be the new parent of the Item + * identified with itemId. * @return true if the operation is successful otherwise * false. * @throws UnsupportedOperationException - * if the setParent is not supported. + * if the setParent is not supported. */ public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException { @@ -385,9 +386,9 @@ public class FilesystemContainer implements Container.Hierarchical { * to the collection. * * @param col - * the collection where the found items are added + * the collection where the found items are added * @param f - * the root file where to start adding files + * the root file where to start adding files */ private void addItemIds(Collection col, File f) { File[] l; @@ -450,9 +451,9 @@ public class FilesystemContainer implements Container.Hierarchical { * not one of those, null is returned. * * @param itemId - * the ID of the file whose property is requested. + * the ID of the file whose property is requested. * @param propertyId - * the property's ID. + * the property's ID. * @return the requested property's value, or null */ public Property getContainerProperty(Object itemId, Object propertyId) { @@ -495,11 +496,11 @@ public class FilesystemContainer implements Container.Hierarchical { /** * Gets the specified property's data type. "Name" is a String, - * "Size" is a Long, "Last Modified" is a Date. - * If propertyId is not one of those, null is returned. + * "Size" is a Long, "Last Modified" is a Date. If + * propertyId is not one of those, null is returned. * * @param propertyId - * the ID of the property whose type is requested. + * the ID of the property whose type is requested. * @return data type of the requested property, or null */ public Class getType(Object propertyId) { @@ -524,7 +525,7 @@ public class FilesystemContainer implements Container.Hierarchical { * directory. * * @param f - * the root to start counting from. + * the root to start counting from. */ private int getFileCounts(File f) { File[] l; @@ -636,7 +637,7 @@ public class FilesystemContainer implements Container.Hierarchical { * Properties got from an Item with the same ID are equal. * * @param obj - * an object to compare with this object. + * an object to compare with this object. * @return true if the given object is the same as this * object, false if not */ @@ -745,7 +746,7 @@ public class FilesystemContainer implements Container.Hierarchical { * Constructs a new FileExtensionFilter using given extension. * * @param fileExtension - * the File extension without the separator (dot). + * the File extension without the separator (dot). */ public FileExtensionFilter(String fileExtension) { filter = "." + fileExtension; @@ -778,7 +779,7 @@ public class FilesystemContainer implements Container.Hierarchical { * Sets the file filter used to limit the files in this container. * * @param filter - * The filter to set. null disables filtering. + * The filter to set. null disables filtering. */ public void setFilter(FilenameFilter filter) { this.filter = filter; @@ -788,8 +789,8 @@ 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. + * the Filename extension (w/o separator) to limit the files in + * container. */ public void setFilter(String extension) { filter = new FileExtensionFilter(extension); @@ -813,7 +814,7 @@ public class FilesystemContainer implements Container.Hierarchical { *

    * * @param recursive - * the New value for recursive property. + * the New value for recursive property. */ public void setRecursive(boolean recursive) { this.recursive = recursive; @@ -822,8 +823,9 @@ public class FilesystemContainer implements Container.Hierarchical { /* * (non-Javadoc) * - * @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 { @@ -875,7 +877,9 @@ public class FilesystemContainer implements Container.Hierarchical { /* * (non-Javadoc) * - * @see com.itmill.toolkit.data.Container#removeContainerProperty(java.lang.Object) + * @see + * com.itmill.toolkit.data.Container#removeContainerProperty(java.lang.Object + * ) */ public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException { diff --git a/src/com/itmill/toolkit/event/EventRouter.java b/src/com/itmill/toolkit/event/EventRouter.java index a66cbb7fb3..8ccd9b47d0 100644 --- a/src/com/itmill/toolkit/event/EventRouter.java +++ b/src/com/itmill/toolkit/event/EventRouter.java @@ -60,14 +60,10 @@ public class EventRouter implements MethodEventSource { if (listenerList != null) { final Iterator i = listenerList.iterator(); while (i.hasNext()) { - try { - final ListenerMethod lm = (ListenerMethod) i.next(); - if (lm.matches(eventType, target)) { - i.remove(); - return; - } - } catch (final java.lang.ClassCastException e) { - // Class cast exceptions are ignored + final ListenerMethod lm = (ListenerMethod) i.next(); + if (lm.matches(eventType, target)) { + i.remove(); + return; } } } @@ -82,14 +78,10 @@ public class EventRouter implements MethodEventSource { if (listenerList != null) { final Iterator i = listenerList.iterator(); while (i.hasNext()) { - try { - final ListenerMethod lm = (ListenerMethod) i.next(); - if (lm.matches(eventType, target, method)) { - i.remove(); - return; - } - } catch (final java.lang.ClassCastException e) { - // Class cast exceptions are ignored + final ListenerMethod lm = (ListenerMethod) i.next(); + if (lm.matches(eventType, target, method)) { + i.remove(); + return; } } } @@ -118,14 +110,10 @@ public class EventRouter implements MethodEventSource { if (listenerList != null) { final Iterator i = listenerList.iterator(); while (i.hasNext()) { - try { - final ListenerMethod lm = (ListenerMethod) i.next(); - if (lm.matches(eventType, target, method)) { - i.remove(); - return; - } - } catch (final java.lang.ClassCastException e) { - // Class cast exceptions are ignored + final ListenerMethod lm = (ListenerMethod) i.next(); + if (lm.matches(eventType, target, method)) { + i.remove(); + return; } } } @@ -144,7 +132,7 @@ public class EventRouter implements MethodEventSource { * the activation method should be called or not. * * @param event - * the Event to be sent to all listeners. + * 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 diff --git a/src/com/itmill/toolkit/event/ListenerMethod.java b/src/com/itmill/toolkit/event/ListenerMethod.java index 49be2017f1..689028a342 100644 --- a/src/com/itmill/toolkit/event/ListenerMethod.java +++ b/src/com/itmill/toolkit/event/ListenerMethod.java @@ -60,9 +60,9 @@ public class ListenerMethod implements EventListener { private Object[] arguments; /** - * Optional index to arguments that point out which one - * should be replaced with the triggering event object and thus be passed to - * the trigger method. + * Optional index to arguments that point out which one should + * be replaced with the triggering event object and thus be passed to the + * trigger method. */ private int eventArgumentIndex; @@ -79,25 +79,24 @@ public class ListenerMethod implements EventListener { *

    * * @param eventType - * the event type that is listener listens to. All events of - * this kind (or its subclasses) result in calling the - * trigger method. + * 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 + * the object instance that contains the trigger method * @param method - * the trigger method + * the trigger method * @param arguments - * the arguments to be passed to the trigger method + * 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. + * 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 method is not a member of - * object. + * if method is not a member of object + * . */ public ListenerMethod(Class eventType, Object object, Method method, Object[] arguments, int eventArgumentIndex) @@ -132,34 +131,31 @@ public class ListenerMethod implements EventListener { * 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 - * object, and - * java.lang.IllegalArgumentException is thrown unless - * exactly one match is found. + * object, and java.lang.IllegalArgumentException + * is thrown unless exactly one match is found. *

    * * @param eventType - * the event type that is listener listens to. All events of - * this kind (or its subclasses) result in calling the - * trigger method. + * 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. + * 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 java.lang.IllegalArgumentException - * is thrown. + * the name of the trigger method. If the object does not contain + * the method or it contains more than one matching methods + * java.lang.IllegalArgumentException is thrown. * @param arguments - * the arguments to be passed to the trigger method. + * 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. + * 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 methodName is - * found in object. + * unless exactly one match methodName is found in + * object. */ public ListenerMethod(Class eventType, Object object, String methodName, Object[] arguments, int eventArgumentIndex) @@ -210,18 +206,17 @@ public class ListenerMethod implements EventListener { *

    * * @param eventType - * the event type that is listener listens to. All events of - * this kind (or its subclasses) result in calling the - * trigger method. + * 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. + * the object instance that contains the trigger method. * @param method - * the trigger method. + * the trigger method. * @param arguments - * the arguments to be passed to the trigger method. + * the arguments to be passed to the trigger method. * @throws java.lang.IllegalArgumentException - * if method is not a member of - * object. + * if method is not a member of object + * . */ public ListenerMethod(Class eventType, Object object, Method method, Object[] arguments) throws java.lang.IllegalArgumentException { @@ -248,26 +243,24 @@ public class ListenerMethod implements EventListener { * *

    * The actual trigger method is reflected from object, and - * java.lang.IllegalArgumentException is thrown unless - * exactly one match is found. + * java.lang.IllegalArgumentException is thrown unless exactly + * one match is found. *

    * * @param eventType - * the event type that is listener listens to. All events of - * this kind (or its subclasses) result in calling the - * trigger method. + * 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. + * 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 java.lang.IllegalArgumentException - * is thrown. + * the name of the trigger method. If the object does not contain + * the method or it contains more than one matching methods + * java.lang.IllegalArgumentException is thrown. * @param arguments - * the arguments to be passed to the trigger method. + * the arguments to be passed to the trigger method. * @throws java.lang.IllegalArgumentException - * unless exactly one match methodName is - * found in object. + * unless exactly one match methodName is found in + * object. */ public ListenerMethod(Class eventType, Object object, String methodName, Object[] arguments) throws java.lang.IllegalArgumentException { @@ -304,16 +297,15 @@ public class ListenerMethod implements EventListener { *

    * * @param eventType - * the event type that is listener listens to. All events of - * this kind (or its subclasses) result in calling the - * trigger method. + * 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. + * the object instance that contains the trigger method. * @param method - * the trigger method. + * the trigger method. * @throws java.lang.IllegalArgumentException - * if method is not a member of - * object. + * if method is not a member of object + * . */ public ListenerMethod(Class eventType, Object object, Method method) throws java.lang.IllegalArgumentException { @@ -349,24 +341,22 @@ public class ListenerMethod implements EventListener { * *

    * The actual trigger method is reflected from object, and - * java.lang.IllegalArgumentException is thrown unless - * exactly one match is found. + * java.lang.IllegalArgumentException is thrown unless exactly + * one match is found. *

    * * @param eventType - * the event type that is listener listens to. All events of - * this kind (or its subclasses) result in calling the - * trigger method. + * 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. + * 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 java.lang.IllegalArgumentException - * is thrown. + * the name of the trigger method. If the object does not contain + * the method or it contains more than one matching methods + * java.lang.IllegalArgumentException is thrown. * @throws java.lang.IllegalArgumentException - * unless exactly one match methodName is - * found in object. + * unless exactly one match methodName is found in + * object. */ public ListenerMethod(Class eventType, Object object, String methodName) throws java.lang.IllegalArgumentException { @@ -407,9 +397,9 @@ public class ListenerMethod implements EventListener { * 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. + * 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) { // Only send events supported by the method @@ -432,13 +422,11 @@ public class ListenerMethod implements EventListener { } catch (final java.lang.IllegalAccessException e) { // This should never happen - e.printStackTrace(); throw new java.lang.RuntimeException( - "Internal error - please report: " + e.toString()); + "Internal error - please report",e); } catch (final java.lang.reflect.InvocationTargetException e) { // This should never happen - e.printStackTrace(); - throw new MethodException("Invocation if method " + method + throw new MethodException("Invocation of method " + method + " failed.", e.getTargetException()); } } @@ -449,14 +437,14 @@ public class ListenerMethod implements EventListener { * listener. * * @param target - * the object to be matched against the object stored by this - * listener. + * 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 true if target is the same object - * as the one stored in this object and eventType - * equals the event type stored in this object. * + * the type to be tested for equality against the type stored by + * this listener. + * @return true if target is the same object as + * the one stored in this object and eventType equals + * the event type stored in this object. * */ public boolean matches(Class eventType, Object target) { return (target == object) && (eventType.equals(this.eventType)); @@ -467,17 +455,17 @@ public class ListenerMethod implements EventListener { * in this listener. * * @param target - * the object to be matched against the object stored by this - * listener. + * 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. + * 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 true if target is the same object - * as the one stored in this object, eventType equals - * with the event type stored in this object and method + * the method to be tested for equality against the method stored + * by this listener. + * @return true if target is the same object as + * the one stored in this object, eventType equals with + * the event type stored in this object and method * equals with the method stored in this object */ public boolean matches(Class eventType, Object target, Method method) { @@ -499,12 +487,14 @@ public class ListenerMethod implements EventListener { public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; + } // return false if obj is a subclass (do not use instanceof check) - if ((obj == null) || (obj.getClass() != this.getClass())) + if ((obj == null) || (obj.getClass() != getClass())) { return false; + } // obj is of same class, test it further ListenerMethod t = (ListenerMethod) obj; @@ -551,8 +541,8 @@ public class ListenerMethod implements EventListener { * Retrieves the cause of this throwable or null if the * cause does not exist or not known. * - * @return the cause of this throwable or null if the - * cause is nonexistent or unknown. + * @return the cause of this throwable or null if the cause + * is nonexistent or unknown. * @see java.lang.Throwable#getCause() */ public Throwable getCause() { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java index 192e934a27..c68f4d073b 100755 --- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java @@ -257,8 +257,7 @@ public class ApplicationConnection { }); } catch (final RequestException e) { - // TODO Better reporting to user - console.error(e.getMessage()); + ClientExceptionHandler.displayError(e); endRequest(); } } @@ -455,7 +454,7 @@ public class ApplicationConnection { try { console.dirUIDL(change); } catch (final Exception e) { - console.log(e.getMessage()); + ClientExceptionHandler.displayError(e); // TODO: dir doesn't work in any browser although it should // work (works in hosted mode) // it partially did at some part but now broken. @@ -466,16 +465,17 @@ public class ApplicationConnection { paintable.updateFromUIDL(uidl, this); } else { if (!uidl.getTag().equals("window")) { - System.out.println("Received update for " - + uidl.getTag() - + ", but there is no such paintable (" - + uidl.getId() + ") rendered."); + ClientExceptionHandler + .displayError("Received update for " + + uidl.getTag() + + ", but there is no such paintable (" + + uidl.getId() + ") rendered."); } else { view.updateFromUIDL(uidl, this); } } } catch (final Throwable e) { - e.printStackTrace(); + ClientExceptionHandler.displayError(e); } } @@ -572,7 +572,7 @@ public class ApplicationConnection { * Returns Paintable element by its id * * @param id - * Paintable ID + * Paintable ID */ public Paintable getPaintable(String id) { return (Paintable) idToPaintable.get(id); @@ -715,13 +715,13 @@ public class ApplicationConnection { * when needed. * * @param component - * Widget to be updated, expected to implement an instance of - * Paintable + * Widget to be updated, expected to implement an instance of + * Paintable * @param uidl - * UIDL to be painted + * UIDL to be painted * @param manageCaption - * True if you want to delegate caption, icon, description - * and error message management to parent. + * True if you want to delegate caption, icon, description and + * error message management to parent. * * @return Returns true iff no further painting is needed by caller */ @@ -857,7 +857,7 @@ public class ApplicationConnection { * parent. * * @param uidl - * UIDL to create Paintable from. + * UIDL to create Paintable from. * @return Either existing or new Paintable corresponding to UIDL. */ public Paintable getPaintable(UIDL uidl) { @@ -897,7 +897,7 @@ public class ApplicationConnection { * to browser due URI's in UIDL may contain custom protocols like theme://. * * @param toolkitUri - * toolkit URI from uidl + * toolkit URI from uidl * @return translated URI ready for browser */ public String translateToolkitUri(String toolkitUri) { @@ -977,7 +977,7 @@ public class ApplicationConnection { * Adds PNG-fix conditionally (only for IE6) to the specified IMG -element. * * @param el - * the IMG element to fix + * the IMG element to fix */ public void addPngFix(Element el) { BrowserInfo b = BrowserInfo.get(); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java b/src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java index d62a4a6571..18dad0c9eb 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java @@ -68,8 +68,7 @@ public class BrowserInfo { ieVersion = Float.parseFloat(ieVersionString); } } catch (Exception e) { - e.printStackTrace(); - ApplicationConnection.getConsole().error(e.getMessage()); + ClientExceptionHandler.displayError(e); } } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ClientExceptionHandler.java b/src/com/itmill/toolkit/terminal/gwt/client/ClientExceptionHandler.java new file mode 100644 index 0000000000..10167b7466 --- /dev/null +++ b/src/com/itmill/toolkit/terminal/gwt/client/ClientExceptionHandler.java @@ -0,0 +1,27 @@ +package com.itmill.toolkit.terminal.gwt.client; + +public class ClientExceptionHandler { + + public static void displayError(Throwable e) { + displayError(e.getMessage()); + e.printStackTrace(); + } + + public static void displayError(String msg) { + + Console console = ApplicationConnection.getConsole(); + + if (console != null) { + console.error(msg); + // } else { + // System.err.println(msg); + } + } + + public static void displayError(String msg, Throwable e) { + displayError(msg); + displayError(e); + + } + +} diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java b/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java index aaa3ebc9b6..49f1bde027 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java @@ -38,7 +38,7 @@ public class DateTimeService { * Creates a new date time service with a given locale. * * @param locale - * e.g. fi, en etc. + * e.g. fi, en etc. * @throws LocaleNotLoadedException */ public DateTimeService(String locale) throws LocaleNotLoadedException { @@ -61,8 +61,7 @@ public class DateTimeService { try { return LocaleService.getMonthNames(currentLocale)[month]; } catch (final LocaleNotLoadedException e) { - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } return null; } @@ -71,8 +70,7 @@ public class DateTimeService { try { return LocaleService.getShortMonthNames(currentLocale)[month]; } catch (final LocaleNotLoadedException e) { - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } return null; } @@ -81,8 +79,7 @@ public class DateTimeService { try { return LocaleService.getDayNames(currentLocale)[day]; } catch (final LocaleNotLoadedException e) { - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } return null; } @@ -91,8 +88,7 @@ public class DateTimeService { try { return LocaleService.getShortDayNames(currentLocale)[day]; } catch (final LocaleNotLoadedException e) { - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } return null; } @@ -101,8 +97,7 @@ public class DateTimeService { try { return LocaleService.getFirstDayOfWeek(currentLocale); } catch (final LocaleNotLoadedException e) { - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } return 0; } @@ -111,8 +106,7 @@ public class DateTimeService { try { return LocaleService.isTwelveHourClock(currentLocale); } catch (final LocaleNotLoadedException e) { - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } return false; } @@ -121,8 +115,7 @@ public class DateTimeService { try { return LocaleService.getClockDelimiter(currentLocale); } catch (final LocaleNotLoadedException e) { - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } return ":"; } @@ -131,8 +124,7 @@ public class DateTimeService { try { return LocaleService.getAmPmStrings(currentLocale); } catch (final LocaleNotLoadedException e) { - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } final String[] temp = new String[2]; temp[0] = "AM"; @@ -148,8 +140,7 @@ public class DateTimeService { firstDay = LocaleService.getFirstDayOfWeek(currentLocale); } catch (final LocaleNotLoadedException e) { firstDay = 0; - // TODO redirect to console - System.out.println(e + ":" + e.getMessage()); + ClientExceptionHandler.displayError(e); } int start = dateForFirstOfThisMonth.getDay() - firstDay; if (start < 0) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java index 0b8d319e72..b534a675e7 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java @@ -316,7 +316,7 @@ public class UIDL { item.addItem(tmp); } } catch (final Exception e) { - // Ingonered, no variables + // Ignored, no variables } final Iterator i = getChildIterator(); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java index 123ded4515..b5b7f031f1 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java @@ -9,6 +9,7 @@ import java.util.Date; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.FlowPanel; import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; +import com.itmill.toolkit.terminal.gwt.client.ClientExceptionHandler; import com.itmill.toolkit.terminal.gwt.client.DateTimeService; import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException; import com.itmill.toolkit.terminal.gwt.client.Paintable; @@ -81,10 +82,10 @@ public class IDateField extends FlowPanel implements Paintable, Field { currentLocale = locale; } catch (final LocaleNotLoadedException e) { currentLocale = dts.getLocale(); - // TODO redirect this to console - System.out.println("Tried to use an unloaded locale \"" - + locale + "\". Using default locale (" + currentLocale - + ")."); + ClientExceptionHandler.displayError( + "Tried to use an unloaded locale \"" + locale + + "\". Using default locale (" + currentLocale + + ").", e); } } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java index 303767faa1..750af5c2a2 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java @@ -55,11 +55,11 @@ public class IPopupView extends HTML implements Paintable, Container { setStyleName(CLASSNAME); popup.setStylePrimaryName(CLASSNAME + "-popup"); - this.setHTML("PopupPanel"); + setHTML("PopupPanel"); popup.setWidget(loading); // When we click to open the popup... - this.addClickListener(new ClickListener() { + addClickListener(new ClickListener() { public void onClick(Widget sender) { updateState(true); } @@ -94,10 +94,10 @@ public class IPopupView extends HTML implements Paintable, Container { updateWindowSize(); hostPopupVisible = uidl.getBooleanAttribute("popupVisible"); - this.setHTML(uidl.getStringAttribute("html")); + setHTML(uidl.getStringAttribute("html")); if (uidl.hasAttribute("description")) { - this.setTitle(uidl.getStringAttribute("description")); + setTitle(uidl.getStringAttribute("description")); } // Render the popup if visible and show it. The component inside can @@ -175,7 +175,7 @@ public class IPopupView extends HTML implements Paintable, Container { popup.hide(); if (popup != null) { - client.unregisterPaintable((Paintable) popup); + client.unregisterPaintable(popup); } popup = (CustomPopup) newComponent; @@ -191,10 +191,10 @@ public class IPopupView extends HTML implements Paintable, Container { } public static native void nativeBlur(Element e) /*-{ - if(e.focus) { - e.blur(); - } - }-*/; + if(e.focus) { + e.blur(); + } + }-*/; private class CustomPopup extends ToolkitOverlay implements Container { @@ -277,12 +277,12 @@ public class IPopupView extends HTML implements Paintable, Container { public void replaceChildComponent(Widget oldComponent, Widget newComponent) { - System.out.println("CustomPopup replacechildcomponent"); + // System.out.println("CustomPopup replacechildcomponent"); if (oldComponent != null) { client.unregisterPaintable((Paintable) oldComponent); } - popupComponentWidget = (Widget) newComponent; + popupComponentWidget = newComponent; setWidget(popupComponentWidget); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java index 688e0c960d..46ae202986 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java @@ -13,6 +13,7 @@ import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.Widget; import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; +import com.itmill.toolkit.terminal.gwt.client.ClientExceptionHandler; import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener; import com.itmill.toolkit.terminal.gwt.client.Focusable; import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException; @@ -98,8 +99,7 @@ public class ITextualDate extends IDateField implements Paintable, Field, formatStr = frmString; } catch (LocaleNotLoadedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + ClientExceptionHandler.displayError(e); } } } @@ -139,7 +139,8 @@ public class ITextualDate extends IDateField implements Paintable, Field, // remove possibly added invalid value indication removeStyleName(PARSE_ERROR_CLASSNAME); } catch (final Exception e) { - ApplicationConnection.getConsole().log(e.getMessage()); + ClientExceptionHandler.displayError(e.getMessage()); + addStyleName(PARSE_ERROR_CLASSNAME); client.updateVariable(id, "lastInvalidDateString", text .getText(), false); diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java index 829989793c..b5ca02cb00 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java @@ -167,11 +167,11 @@ public class ApplicationServlet extends HttpServlet { * is being placed into service. * * @param servletConfig - * the object containing the servlet's configuration and - * initialization parameters + * the object containing the servlet's configuration and + * initialization parameters * @throws javax.servlet.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. */ public void init(javax.servlet.ServletConfig servletConfig) throws javax.servlet.ServletException { @@ -244,9 +244,9 @@ public class ApplicationServlet extends HttpServlet { classLoader = (ClassLoader) c .newInstance(new Object[] { getClass().getClassLoader() }); } catch (final Exception e) { - System.err.println("Could not find specified class loader: " - + classLoaderName); - throw new ServletException(e); + throw new ServletException( + "Could not find specified class loader: " + + classLoaderName, e); } } this.classLoader = classLoader; @@ -278,9 +278,9 @@ public class ApplicationServlet extends HttpServlet { * Gets an application or system property value. * * @param parameterName - * the Name or the parameter. + * the Name or the parameter. * @param defaultValue - * the Default to be used. + * the Default to be used. * @return String value or default if not found */ private String getApplicationOrSystemProperty(String parameterName, @@ -328,16 +328,16 @@ public class ApplicationServlet extends HttpServlet { * dispatches them. * * @param request - * the object that contains the request the client made of - * the servlet. + * 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. + * if an input or output error occurs while the servlet is + * handling the TRACE request. * @throws IOException - * if the request for the TRACE cannot be handled. + * if the request for the TRACE cannot be handled. */ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -508,20 +508,24 @@ public class ApplicationServlet extends HttpServlet { } catch (final SessionExpired e) { // Session has expired, notify user - Application.SystemMessages ci = getSystemMessages(); - if (!UIDLrequest) { - // 'plain' http req - e.g. browser reload; - // just go ahead redirect the browser - response.sendRedirect(ci.getSessionExpiredURL()); - } else { - // send uidl redirect - criticalNotification(request, response, ci - .getSessionExpiredCaption(), ci - .getSessionExpiredMessage(), ci.getSessionExpiredURL()); + try { + Application.SystemMessages ci = getSystemMessages(); + if (!UIDLrequest) { + // 'plain' http req - e.g. browser reload; + // just go ahead redirect the browser + response.sendRedirect(ci.getSessionExpiredURL()); + } else { + // send uidl redirect + criticalNotification(request, response, ci + .getSessionExpiredCaption(), ci + .getSessionExpiredMessage(), ci + .getSessionExpiredURL()); + } + } catch (SystemMessageException ee) { + throw new ServletException(ee); } } catch (final Throwable e) { - e.printStackTrace(); // if this was an UIDL request, response UIDL back to client if (UIDLrequest) { Application.SystemMessages ci = getSystemMessages(); @@ -553,23 +557,21 @@ public class ApplicationServlet extends HttpServlet { return (Application.SystemMessages) m.invoke(null, null); } catch (ClassNotFoundException e) { // This should never happen - e.printStackTrace(); + throw new SystemMessageException(e); } catch (SecurityException e) { - e.printStackTrace(); - System.out - .print("Error: getSystemMessage() should be static public"); + throw new SystemMessageException( + "Application.getSystemMessage() should be static public", e); } catch (NoSuchMethodException e) { // This is completely ok and should be silently ignored } catch (IllegalArgumentException e) { // This should never happen - e.printStackTrace(); + throw new SystemMessageException(e); } catch (IllegalAccessException e) { - e.printStackTrace(); - System.out - .print("Error: getSystemMessage() should be static public"); + throw new SystemMessageException( + "Application.getSystemMessage() should be static public", e); } catch (InvocationTargetException e) { // This should never happen - e.printStackTrace(); + throw new SystemMessageException(e); } return Application.getSystemMessages(); } @@ -588,13 +590,11 @@ public class ApplicationServlet extends HttpServlet { InputStream is = sc.getResourceAsStream(filename); if (is == null) { // try if requested file is found from classloader - try { - // strip leading "/" otherwise stream from JAR wont work - filename = filename.substring(1); - is = classLoader.getResourceAsStream(filename); - } catch (final Exception e) { - e.printStackTrace(); - } + + // strip leading "/" otherwise stream from JAR wont work + filename = filename.substring(1); + is = classLoader.getResourceAsStream(filename); + if (is == null) { // cannot serve requested file System.err @@ -624,17 +624,17 @@ public class ApplicationServlet extends HttpServlet { * no knowledge of what application client refers to. * * @param request - * the HTTP request instance. + * the HTTP request instance. * @param response - * the HTTP response to write to. + * the HTTP response to write to. * @param caption - * for the notification + * for the notification * @param message - * for the notification + * for the notification * @param url - * url to load after message, null for current page + * url to load after message, null for current page * @throws IOException - * if the writing failed due to input/output error. + * if the writing failed due to input/output error. */ void criticalNotification(HttpServletRequest request, HttpServletResponse response, String caption, String message, @@ -676,8 +676,10 @@ public class ApplicationServlet extends HttpServlet { * @param request * @return string array consisting of application url first and then * widgetset url. + * @throws MalformedURLException */ - private String[] getAppAndWidgetUrl(HttpServletRequest request) { + private String[] getAppAndWidgetUrl(HttpServletRequest request) + throws MalformedURLException { // don't use server and port in uri. It may cause problems with some // virtual server configurations which lose the server name String appUrl = null; @@ -691,32 +693,28 @@ public class ApplicationServlet extends HttpServlet { appUrl = URIparts[1]; } else { String[] urlParts; - try { - urlParts = getApplicationUrl(request).toString().split("\\/"); - appUrl = ""; - widgetsetUrl = ""; - // if context is specified add it to widgetsetUrl - String ctxPath = request.getContextPath(); - if (ctxPath.length() == 0 - && request - .getAttribute("javax.servlet.include.context_path") != null) { - // include request (e.g portlet), get contex path from - // attribute - ctxPath = (String) request - .getAttribute("javax.servlet.include.context_path"); - } - if (urlParts.length > 3 - && urlParts[3].equals(ctxPath.replaceAll("\\/", ""))) { - widgetsetUrl += "/" + urlParts[3]; - } - for (int i = 3; i < urlParts.length; i++) { - appUrl += "/" + urlParts[i]; - } - if (appUrl.endsWith("/")) { - appUrl = appUrl.substring(0, appUrl.length() - 1); - } - } catch (final MalformedURLException e) { - e.printStackTrace(); + urlParts = getApplicationUrl(request).toString().split("\\/"); + appUrl = ""; + widgetsetUrl = ""; + // if context is specified add it to widgetsetUrl + String ctxPath = request.getContextPath(); + if (ctxPath.length() == 0 + && request + .getAttribute("javax.servlet.include.context_path") != null) { + // include request (e.g portlet), get contex path from + // attribute + ctxPath = (String) request + .getAttribute("javax.servlet.include.context_path"); + } + if (urlParts.length > 3 + && urlParts[3].equals(ctxPath.replaceAll("\\/", ""))) { + widgetsetUrl += "/" + urlParts[3]; + } + for (int i = 3; i < urlParts.length; i++) { + appUrl += "/" + urlParts[i]; + } + if (appUrl.endsWith("/")) { + appUrl = appUrl.substring(0, appUrl.length() - 1); } } @@ -726,19 +724,19 @@ public class ApplicationServlet extends HttpServlet { /** * * @param request - * the HTTP request. + * the HTTP request. * @param response - * the HTTP response to write to. + * 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. + * 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. + * if the application is denied access the persistent data store + * represented by the given URL. */ private void writeAjaxPage(HttpServletRequest request, HttpServletResponse response, Window window, String themeName, @@ -763,8 +761,9 @@ public class ApplicationServlet extends HttpServlet { try { widgetset = (String) reqParam; } catch (Exception e) { - System.err.println("Warning: request param " + REQUEST_WIDGETSET - + " could not be used (not a String?)" + e); + // FIXME: Handle exception + System.err.println("Warning: request param '" + REQUEST_WIDGETSET + + "' could not be used (is not a String)" + e); } if (widgetset == null) { widgetset = applicationProperties.getProperty(PARAMETER_WIDGETSET); @@ -987,14 +986,13 @@ public class ApplicationServlet extends HttpServlet { * it is sent to the client. * * @param application - * the Application owning the URI. + * the Application owning the URI. * @param request - * the HTTP request instance. + * the HTTP request instance. * @param response - * the HTTP response to write to. - * @return boolean true if the request was handled and - * further processing should be suppressed, false - * otherwise. + * the HTTP response to write to. + * @return boolean true if the request was handled and further + * processing should be suppressed, false otherwise. * @see com.itmill.toolkit.terminal.URIHandler */ private DownloadStream handleURI(Application application, @@ -1035,17 +1033,19 @@ public class ApplicationServlet extends HttpServlet { * it is sent to the client. * * @param stream - * the download stream. + * the download stream. * * @param request - * the HTTP request instance. + * the HTTP request instance. * @param response - * the HTTP response to write to. + * the HTTP response to write to. + * @throws IOException * * @see com.itmill.toolkit.terminal.URIHandler */ private void handleDownload(DownloadStream stream, - HttpServletRequest request, HttpServletResponse response) { + HttpServletRequest request, HttpServletResponse response) + throws IOException { if (stream.getParameter("Location") != null) { response.setStatus(HttpServletResponse.SC_FOUND); @@ -1093,19 +1093,13 @@ public class ApplicationServlet extends HttpServlet { final byte[] buffer = new byte[bufferSize]; int bytesRead = 0; - try { - final OutputStream out = response.getOutputStream(); + final OutputStream out = response.getOutputStream(); - while ((bytesRead = data.read(buffer)) > 0) { - out.write(buffer, 0, bytesRead); - out.flush(); - } - out.close(); - } catch (final IOException ignored) { - System.err - .println("Warning: ApplicationServlet.handleDownload()" - + " threw IOException."); + while ((bytesRead = data.read(buffer)) > 0) { + out.write(buffer, 0, bytesRead); + out.flush(); } + out.close(); } @@ -1116,15 +1110,14 @@ public class ApplicationServlet extends HttpServlet { * are provided by the WebAdapterServlet. * * @param request - * the HTTP request. + * the HTTP request. * @param response - * the HTTP response. - * @return boolean true if the request was handled and - * further processing should be suppressed, false - * otherwise. + * the HTTP response. + * @return boolean true if the request was handled and further + * processing should be suppressed, false otherwise. * @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 boolean handleResourceRequest(HttpServletRequest request, HttpServletResponse response, String themeName) @@ -1154,6 +1147,7 @@ public class ApplicationServlet extends HttpServlet { data = getServletContext().getResourceAsStream( THEME_DIRECTORY_PATH + themeName + "/" + resourceId); } catch (final Exception e) { + // FIXME: Handle exception e.printStackTrace(); data = null; } @@ -1187,6 +1181,7 @@ public class ApplicationServlet extends HttpServlet { } } catch (final java.io.IOException e) { + // FIXME: Handle exception System.err.println("Resource transfer failed: " + request.getRequestURI() + ". (" + e.getMessage() + ")"); } @@ -1198,46 +1193,40 @@ public class ApplicationServlet extends HttpServlet { * Gets the current application URL from request. * * @param request - * the HTTP request. + * the HTTP request. * @throws MalformedURLException - * if the application is denied access to the persistent - * data store represented by the given URL. + * if the application is denied access to the persistent data + * store represented by the given URL. */ private URL getApplicationUrl(HttpServletRequest request) throws MalformedURLException { URL applicationUrl; - try { - final URL reqURL = new URL( - (request.isSecure() ? "https://" : "http://") - + request.getServerName() - + ((request.isSecure() && request.getServerPort() == 443) - || (!request.isSecure() && request - .getServerPort() == 80) ? "" : ":" - + request.getServerPort()) - + request.getRequestURI()); - String servletPath = ""; - if (request.getAttribute("javax.servlet.include.servlet_path") != null) { - // this is an include request - servletPath = request.getAttribute( - "javax.servlet.include.context_path").toString() - + request - .getAttribute("javax.servlet.include.servlet_path"); - } else { - servletPath = request.getContextPath() - + request.getServletPath(); - } - if (servletPath.length() == 0 - || servletPath.charAt(servletPath.length() - 1) != '/') { - servletPath = servletPath + "/"; - } - applicationUrl = new URL(reqURL, servletPath); - } catch (final MalformedURLException e) { - System.err.println("Error constructing application url " - + request.getRequestURI() + " (" + e + ")"); - throw e; + final URL reqURL = new URL( + (request.isSecure() ? "https://" : "http://") + + request.getServerName() + + ((request.isSecure() && request.getServerPort() == 443) + || (!request.isSecure() && request + .getServerPort() == 80) ? "" : ":" + + request.getServerPort()) + + request.getRequestURI()); + String servletPath = ""; + if (request.getAttribute("javax.servlet.include.servlet_path") != null) { + // this is an include request + servletPath = request.getAttribute( + "javax.servlet.include.context_path").toString() + + request + .getAttribute("javax.servlet.include.servlet_path"); + + } else { + servletPath = request.getContextPath() + request.getServletPath(); + } + if (servletPath.length() == 0 + || servletPath.charAt(servletPath.length() - 1) != '/') { + servletPath = servletPath + "/"; } + applicationUrl = new URL(reqURL, servletPath); return applicationUrl; } @@ -1287,13 +1276,13 @@ public class ApplicationServlet extends HttpServlet { * instance for given request based on the requested URL. * * @param request - * the HTTP request. + * the HTTP request. * @param response * @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. + * if the application is denied access to the persistent data + * store represented by the given URL. * @throws SAXException * @throws IllegalAccessException * @throws InstantiationException @@ -1345,13 +1334,13 @@ public class ApplicationServlet extends HttpServlet { * Creates new application for given request. * * @param request - * the HTTP request. + * the HTTP request. * @param response * @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. + * if the application is denied access to the persistent data + * store represented by the given URL. * @throws SAXException * @throws IllegalAccessException * @throws InstantiationException @@ -1396,12 +1385,8 @@ public class ApplicationServlet extends HttpServlet { return application; } catch (final IllegalAccessException e) { - System.err.println("Illegal access to application class " - + applicationClass.getName()); throw e; } catch (final InstantiationException e) { - System.err.println("Failed to instantiate application class: " - + applicationClass.getName()); throw e; } } @@ -1410,13 +1395,13 @@ public class ApplicationServlet extends HttpServlet { * Ends the application. * * @param request - * the HTTP request. + * the HTTP request. * @param response - * the HTTP response to write to. + * the HTTP response to write to. * @param application - * the application to end. + * the application to end. * @throws IOException - * if the writing failed due to input/output error. + * if the writing failed due to input/output error. */ private void endApplication(HttpServletRequest request, HttpServletResponse response, Application application) @@ -1441,13 +1426,13 @@ public class ApplicationServlet extends HttpServlet { * application based on the requested URI. * * @param request - * the HTTP Request. + * the HTTP Request. * @param application - * the Application to query for window. + * the Application to query for window. * @return Window matching the given URI or null if not found. * @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 Window getApplicationWindow(HttpServletRequest request, Application application) throws ServletException { @@ -1494,9 +1479,9 @@ public class ApplicationServlet extends HttpServlet { * Gets relative location of a theme resource. * * @param theme - * the Theme name. + * the Theme name. * @param resource - * the Theme resource. + * the Theme resource. * @return External URI specifying the resource */ public String getResourceLocation(String theme, ThemeResource resource) { @@ -1512,8 +1497,8 @@ public class ApplicationServlet extends HttpServlet { * when debug mode is enabled. * * @param parameters - * @return true if the web adapter is in debug mode. - * otherwise false. + * @return true if the web adapter is in debug mode. otherwise + * false. */ public boolean isDebugMode(Map parameters) { if (parameters != null) { @@ -1621,7 +1606,7 @@ public class ApplicationServlet extends HttpServlet { * * @param servletContext * @param path - * the resource path. + * the resource path. * @return the resource path. */ protected static String getResourcePath(ServletContext servletContext, @@ -1635,6 +1620,7 @@ public class ApplicationServlet extends HttpServlet { final URL url = servletContext.getResource(path); resultPath = url.getFile(); } catch (final Exception e) { + // FIXME: Handle exception e.printStackTrace(); } } diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index 3b6c7882f4..559dda6e81 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -103,9 +103,11 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { * @param request * @param response * @throws IOException + * @throws FileUploadException */ public void handleFileUpload(HttpServletRequest request, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException, + FileUploadException { // Create a new file upload handler final ServletFileUpload upload = new ServletFileUpload(); @@ -174,7 +176,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { } } } catch (final FileUploadException e) { - e.printStackTrace(); + throw e; } // Send short response to acknowledge client that request was done @@ -240,6 +242,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { "getSystemMessages", null); ci = (Application.SystemMessages) m.invoke(null, null); } catch (Exception e2) { + // FIXME: Handle exception // Not critical, but something is still wrong; print // stacktrace e2.printStackTrace(); @@ -433,6 +436,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { + ApplicationServlet.THEME_DIRECTORY_PATH + themeName + "/" + resource); } catch (final Exception e) { + // FIXME: Handle exception e.printStackTrace(); } if (is != null) { @@ -450,6 +454,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { } r.close(); } catch (final java.io.IOException e) { + // FIXME: Handle exception System.err.println("Resource transfer failed: " + request.getRequestURI() + ". (" + e.getMessage() + ")"); @@ -458,6 +463,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { + JsonPaintTarget.escapeJSON(layout.toString()) + "\""); } else { + // FIXME: Handle exception System.err.println("CustomLayout " + "/" + ApplicationServlet.THEME_DIRECTORY_PATH + themeName + "/" + resource + " not found!"); @@ -736,12 +742,12 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { /* * Time formatting (24 or 12 hour clock and AM/PM suffixes) */ - final String timeformat = df.substring(timeStart, df.length()); // Doesn't - // return - // second - // or - // milliseconds - // We use timeformat to determine 12/24-hour clock + final String timeformat = df.substring(timeStart, df.length()); + /* + * Doesn't return second or milliseconds. + * + * We use timeformat to determine 12/24-hour clock + */ final boolean twelve_hour_clock = timeformat.indexOf("a") > -1; // TODO there are other possibilities as well, like 'h' in french // (ignore them, too complicated) @@ -771,13 +777,13 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { * application based on the requested URI. * * @param request - * the HTTP 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. + * if an exception has occurred that interferes with the + * servlet's normal operation. */ private Window getApplicationWindow(HttpServletRequest request, Application application) throws ServletException { @@ -821,13 +827,13 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { * Ends the Application. * * @param request - * the HTTP request instance. + * the HTTP request instance. * @param response - * the HTTP response to write to. + * the HTTP response to write to. * @param application - * the Application to end. + * the Application to end. * @throws IOException - * if the writing failed due to input/output error. + * if the writing failed due to input/output error. */ private void endApplication(HttpServletRequest request, HttpServletResponse response, Application application) @@ -883,7 +889,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { /** * @param w - * root window for which dirty components is to be fetched + * root window for which dirty components is to be fetched * @return */ private ArrayList getDirtyComponents(Window w) { diff --git a/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java b/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java new file mode 100644 index 0000000000..4eda3a4d05 --- /dev/null +++ b/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java @@ -0,0 +1,57 @@ +package com.itmill.toolkit.terminal.gwt.server; + +public class SystemMessageException extends RuntimeException { + + /** + * Serial generated by eclipse. + */ + private static final long serialVersionUID = -8249486543123286960L; + + /** + * Cause of the method exception + */ + private Throwable cause; + + /** + * Constructs a new SystemMessageException with the specified + * detail message. + * + * @param msg + * the detail message. + */ + public SystemMessageException(String msg) { + super(msg); + } + + /** + * Constructs a new SystemMessageException with the specified + * detail message and cause. + * + * @param msg + * the detail message. + * @param cause + * the cause of the exception. + */ + public SystemMessageException(String msg, Throwable cause) { + super(msg, cause); + } + + /** + * Constructs a new SystemMessageException from another + * exception. + * + * @param cause + * the cause of the exception. + */ + public SystemMessageException(Throwable cause) { + this.cause = cause; + } + + /** + * @see java.lang.Throwable#getCause() + */ + public Throwable getCause() { + return cause; + } + +} \ No newline at end of file diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java index 65587890ab..fe2c000764 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java @@ -21,6 +21,7 @@ import javax.servlet.http.HttpSessionBindingListener; import com.itmill.toolkit.Application; import com.itmill.toolkit.service.ApplicationContext; +import com.itmill.toolkit.terminal.gwt.client.ClientExceptionHandler; /** * Web application context for the IT Mill Toolkit applications. @@ -85,7 +86,7 @@ public class WebApplicationContext implements ApplicationContext, * Gets the application context for HttpSession. * * @param session - * the HTTP session. + * the HTTP session. * @return the application context for HttpSession. */ static public WebApplicationContext getApplicationContext( @@ -108,7 +109,7 @@ public class WebApplicationContext implements ApplicationContext, * boolean value as this object. * * @param obj - * the object to compare with. + * the object to compare with. * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { @@ -153,7 +154,7 @@ public class WebApplicationContext implements ApplicationContext, * * @param application * @param request - * the HTTP request. + * the HTTP request. */ protected void startTransaction(Application application, HttpServletRequest request) { @@ -171,7 +172,7 @@ public class WebApplicationContext implements ApplicationContext, * * @param application * @param request - * the HTTP request. + * the HTTP request. */ protected void endTransaction(Application application, HttpServletRequest request) { @@ -244,6 +245,7 @@ public class WebApplicationContext implements ApplicationContext, // thread doing HTTP socket write and another thread trying to // remove same application here. Possible if you got e.g. session // lifetime 1 min but socket write may take longer than 1 min. + // FIXME: Handle exception System.err.println("Could not remove application, leaking memory."); e.printStackTrace(); } diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 0aa9d74fdf..56c06765f0 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.java @@ -331,7 +331,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource * actual enabled state of the component. * * @param disabledByContainer - * Should the component be disabled + * Should the component be disabled */ public void setDisabledByContainer(boolean disabledByContainer) { if (disabledByContainer != this.disabledByContainer) { @@ -776,8 +776,8 @@ public abstract class AbstractComponent implements Component, MethodEventSource new Class[] { Component.Event.class }); } catch (final java.lang.NoSuchMethodException e) { // This should never happen - e.printStackTrace(); - throw new java.lang.RuntimeException(); + throw new java.lang.RuntimeException( + "Internal error finding methods in AbstractComponent"); } } @@ -1228,7 +1228,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource * handle the exception. * * @param errorHandler - * AbstractField specific error handler + * AbstractField specific error handler */ public void setErrorHandler(ComponentErrorHandler errorHandler) { this.errorHandler = errorHandler; diff --git a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java index bce552e3d9..56febe3815 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java +++ b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java @@ -93,7 +93,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent } } - /* Events ************************************************************ */ + /* Events */ private static final Method COMPONENT_ATTACHED_METHOD; @@ -109,7 +109,8 @@ public abstract class AbstractComponentContainer extends AbstractComponent new Class[] { ComponentDetachEvent.class }); } catch (final java.lang.NoSuchMethodException e) { // This should never happen - throw new java.lang.RuntimeException(); + throw new java.lang.RuntimeException( + "Internal error finding methods in AbstractComponentContainer"); } } @@ -143,7 +144,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * container. * * @param component - * the component that has been added to this container. + * the component that has been added to this container. */ protected void fireComponentAttachEvent(Component component) { fireEvent(new ComponentAttachEvent(this, component)); @@ -155,7 +156,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * container. * * @param component - * the component that has been removed from this container. + * the component that has been removed from this container. */ protected void fireComponentDetachEvent(Component component) { fireEvent(new ComponentDetachEvent(this, component)); diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java index 98a001dd57..a421597197 100644 --- a/src/com/itmill/toolkit/ui/AbstractField.java +++ b/src/com/itmill/toolkit/ui/AbstractField.java @@ -51,7 +51,7 @@ import com.itmill.toolkit.terminal.PaintTarget; public abstract class AbstractField extends AbstractComponent implements Field, Property.ReadOnlyStatusChangeNotifier { - /* Private members ************************************************* */ + /* Private members */ private boolean delayedFocus; @@ -121,7 +121,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, */ private boolean validationVisible = true; - /* Component basics ************************************************ */ + /* Component basics */ /* * Paints the field. Don't add a JavaDoc comment here, we use the default @@ -337,7 +337,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, } } - /* Property interface implementation ******************************* */ + /* Property interface implementation */ /** * Returns the value of the Property in human readable textual format. @@ -381,7 +381,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * Sets the value of the field. * * @param newValue - * the New value of the field. + * the New value of the field. * @throws Property.ReadOnlyException * @throws Property.ConversionException */ @@ -394,9 +394,9 @@ public abstract class AbstractField extends AbstractComponent implements Field, * Sets the value of the field. * * @param newValue - * the New value of the field. + * the New value of the field. * @param repaintIsNotNeeded - * True iff caller is sure that repaint is not needed. + * True iff caller is sure that repaint is not needed. * @throws Property.ReadOnlyException * @throws Property.ConversionException */ @@ -459,7 +459,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, } } - /* External data source ******************************************** */ + /* External data source */ /** * Gets the current data source of the field, if any. @@ -488,7 +488,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, *

    * * @param newDataSource - * the new data source Property. + * the new data source Property. */ public void setPropertyDataSource(Property newDataSource) { @@ -546,14 +546,14 @@ public abstract class AbstractField extends AbstractComponent implements Field, } } - /* Validation ****************************************************** */ + /* 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. + * the new validator to be added. */ public void addValidator(Validator validator) { if (validators == null) { @@ -580,7 +580,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * Removes the validator from the field. * * @param validator - * the validator to remove. + * the validator to remove. */ public void removeValidator(Validator validator) { if (validators != null) { @@ -750,7 +750,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, } - /* Value change events ****************************************** */ + /* Value change events */ private static final Method VALUE_CHANGE_METHOD; @@ -761,7 +761,8 @@ public abstract class AbstractField extends AbstractComponent implements Field, new Class[] { Property.ValueChangeEvent.class }); } catch (final java.lang.NoSuchMethodException e) { // This should never happen - throw new java.lang.RuntimeException(); + throw new java.lang.RuntimeException( + "Internal error finding methods in AbstractField"); } } @@ -795,7 +796,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, } } - /* Read-only status change events *************************************** */ + /* Read-only status change events */ private static final Method READ_ONLY_STATUS_CHANGE_METHOD; @@ -807,7 +808,8 @@ public abstract class AbstractField extends AbstractComponent implements Field, new Class[] { Property.ReadOnlyStatusChangeEvent.class }); } catch (final java.lang.NoSuchMethodException e) { // This should never happen - throw new java.lang.RuntimeException(); + throw new java.lang.RuntimeException( + "Internal error finding methods in AbstractField"); } } @@ -832,7 +834,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * New instance of text change event. * * @param source - * the Source of the event. + * the Source of the event. */ public ReadOnlyStatusChangeEvent(AbstractField source) { super(source); @@ -881,8 +883,8 @@ public abstract class AbstractField extends AbstractComponent implements Field, * forwards. * * @param event - * the value change event telling the data source contents - * have changed. + * the value change event telling the data source contents have + * changed. */ public void valueChange(Property.ValueChangeEvent event) { if (isReadThrough() || !isModified()) { @@ -915,7 +917,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, *

    * * @param propertyType - * the Type of the property, that needs to be edited. + * the Type of the property, that needs to be edited. */ public static AbstractField constructField(Class propertyType) { @@ -966,7 +968,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * variables. * * @param newValue - * the new value to be set. + * the new value to be set. */ protected void setInternalValue(Object newValue) { value = newValue; @@ -1022,7 +1024,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * field isEmpty() regardless of any attached validators. * * @param required - * Is the field required. + * Is the field required. */ public void setRequired(boolean required) { this.required = required; @@ -1073,7 +1075,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * validation in their own code. * * @param validateAutomatically - * True, if automatic validation is enabled. + * True, if automatic validation is enabled. */ public void setValidationVisible(boolean validateAutomatically) { if (validationVisible != validateAutomatically) { diff --git a/src/com/itmill/toolkit/ui/AbstractSelect.java b/src/com/itmill/toolkit/ui/AbstractSelect.java index b368f755a4..9f9fbc7b0a 100644 --- a/src/com/itmill/toolkit/ui/AbstractSelect.java +++ b/src/com/itmill/toolkit/ui/AbstractSelect.java @@ -47,8 +47,8 @@ public abstract class AbstractSelect extends AbstractField implements Container.ItemSetChangeListener { /** - * Item caption mode: Item's ID's String representation is - * used as caption. + * Item caption mode: Item's ID's String representation is used + * as caption. */ public static final int ITEM_CAPTION_MODE_ID = 0; /** @@ -87,8 +87,8 @@ public abstract class AbstractSelect extends AbstractField implements * entered value. The value is matched to the item caption. * FILTERINGMODE_OFF (0) turns the filtering off. * FILTERINGMODE_STARTSWITH (1) matches from the start of the - * caption. FILTERINGMODE_CONTAINS (1) matches anywhere in - * the caption. + * caption. FILTERINGMODE_CONTAINS (1) matches anywhere in the + * caption. */ public interface Filtering { public static final int FILTERINGMODE_OFF = 0; @@ -99,7 +99,7 @@ public abstract class AbstractSelect extends AbstractField implements * Sets the option filtering mode. * * @param filteringMode - * the filtering mode to use + * the filtering mode to use */ public void setFilteringMode(int filteringMode); @@ -185,7 +185,7 @@ public abstract class AbstractSelect extends AbstractField implements // Caption (Item / Property) change listeners CaptionChangeListener captionChangeListener; - /* Constructors ********************************************************* */ + /* Constructors */ /** * Creates an empty Select. The caption is not used. @@ -206,10 +206,9 @@ public abstract class AbstractSelect extends AbstractField implements * Creates a new select that is connected to a data-source. * * @param caption - * the Caption of the component. + * the Caption of the component. * @param dataSource - * the Container datasource to be selected from by this - * select. + * the Container datasource to be selected from by this select. */ public AbstractSelect(String caption, Container dataSource) { setCaption(caption); @@ -220,9 +219,9 @@ public abstract class AbstractSelect extends AbstractField implements * Creates a new select that is filled from a collection of option values. * * @param caption - * the Caption of this field. + * the Caption of this field. * @param options - * the Collection containing the options. + * the Collection containing the options. */ public AbstractSelect(String caption, Collection options) { @@ -238,15 +237,15 @@ public abstract class AbstractSelect extends AbstractField implements setContainerDataSource(c); } - /* Component methods **************************************************** */ + /* Component methods */ /** * Paints the content of this component. * * @param target - * the Paint Event. + * the Paint Event. * @throws PaintException - * if the paint operation failed. + * if the paint operation failed. */ public void paintContent(PaintTarget target) throws PaintException { @@ -489,9 +488,10 @@ public abstract class AbstractSelect extends AbstractField implements getItemCaptionPropertyId()).setValue( newItemCaption); } catch (final Property.ConversionException ignored) { - // The conversion exception is safely ignored, the - // caption is - // just missing + /* + * The conversion exception is safely ignored, the + * caption is just missing + */ } } if (isMultiSelect()) { @@ -526,13 +526,13 @@ public abstract class AbstractSelect extends AbstractField implements return null; } - /* Property methods ***************************************************** */ + /* Property methods */ /** * Returns the type of the property. getValue and - * setValue methods must be compatible with this type: one - * can safely cast getValue to given type and pass any - * variable assignable to this type as a parameter to setValue. + * setValue methods must be compatible with this type: one can + * safely cast getValue to given type and pass any variable + * assignable to this type as a parameter to setValue. * * @return the Type of the property. */ @@ -585,7 +585,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param newValue - * the New selected item or collection of selected items. + * the New selected item or collection of selected items. * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object) */ public void setValue(Object newValue) throws Property.ReadOnlyException, @@ -607,9 +607,9 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param newValue - * the New selected item or collection of selected items. + * the New selected item or collection of selected items. * @param repaintIsNotNeeded - * True if caller is sure that repaint is not needed. + * True if caller is sure that repaint is not needed. * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object, * java.lang.Boolean) */ @@ -628,14 +628,14 @@ public abstract class AbstractSelect extends AbstractField implements } } - /* Container methods **************************************************** */ + /* Container methods */ /** * 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. + * the item id. * @return the item from the container. */ public Item getItem(Object itemId) { @@ -664,7 +664,7 @@ public abstract class AbstractSelect extends AbstractField implements * Gets the property type. * * @param propertyId - * the Id identifying the property. + * the Id identifying the property. * @see com.itmill.toolkit.data.Container#getType(java.lang.Object) */ public Class getType(Object propertyId) { @@ -686,7 +686,7 @@ public abstract class AbstractSelect extends AbstractField implements * Tests, if the collection contains an item with given id. * * @param itemId - * the Id the of item to be tested. + * the Id the of item to be tested. */ public boolean containsId(Object itemId) { if (itemId != null) { @@ -779,7 +779,7 @@ public abstract class AbstractSelect extends AbstractField implements * returns null. * * @param itemId - * the Identification of the item to be created. + * the Identification of the item to be created. * @return the Created item with the given id, or null in case of failure. * @see com.itmill.toolkit.data.Container#addItem(java.lang.Object) */ @@ -833,13 +833,13 @@ public abstract class AbstractSelect extends AbstractField implements return retval; } - /* Container.Viewer methods ********************************************* */ + /* Container.Viewer methods */ /** * Sets the container as data-source for viewing. * * @param newDataSource - * the new data source. + * the new data source. */ public void setContainerDataSource(Container newDataSource) { if (newDataSource == null) { @@ -852,17 +852,13 @@ public abstract class AbstractSelect extends AbstractField implements // Removes listeners from the old datasource if (items != null) { - try { + if (items instanceof Container.ItemSetChangeListener) { ((Container.ItemSetChangeNotifier) items) .removeListener(this); - } catch (final ClassCastException ignored) { - // Ignored } - try { + if (items instanceof Container.PropertySetChangeNotifier) { ((Container.PropertySetChangeNotifier) items) .removeListener(this); - } catch (final ClassCastException ignored) { - // Ignored } } @@ -874,16 +870,12 @@ public abstract class AbstractSelect extends AbstractField implements // Adds listeners if (items != null) { - try { + if (items instanceof Container.ItemSetChangeListener) { ((Container.ItemSetChangeNotifier) items).addListener(this); - } catch (final ClassCastException ignored) { - // Ignored } - try { + if (items instanceof Container.PropertySetChangeNotifier) { ((Container.PropertySetChangeNotifier) items) .addListener(this); - } catch (final ClassCastException ignored) { - // Ignored } } @@ -901,7 +893,7 @@ public abstract class AbstractSelect extends AbstractField implements return items; } - /* Select attributes **************************************************** */ + /* Select attributes */ /** * Is the select in multiselect mode? In multiselect mode @@ -918,7 +910,7 @@ public abstract class AbstractSelect extends AbstractField implements * selected items, only one of the selected items is kept as selected. * * @param multiSelect - * the New value of property multiSelect. + * the New value of property multiSelect. */ public void setMultiSelect(boolean multiSelect) { if (multiSelect && getNullSelectionItemId() != null) { @@ -970,7 +962,7 @@ public abstract class AbstractSelect extends AbstractField implements * Enables or disables possibility to add new options by the user. * * @param allowNewOptions - * the New value of property allowNewOptions. + * the New value of property allowNewOptions. */ public void setNewItemsAllowed(boolean allowNewOptions) { @@ -988,9 +980,9 @@ public abstract class AbstractSelect extends AbstractField implements * item and index captions. * * @param itemId - * the id of the item to be recaptioned. + * the id of the item to be recaptioned. * @param caption - * the New caption. + * the New caption. */ public void setItemCaption(Object itemId, String caption) { if (itemId != null) { @@ -1005,7 +997,7 @@ public abstract class AbstractSelect extends AbstractField implements * details. * * @param itemId - * the id of the item to be queried. + * the id of the item to be queried. * @return the caption for specified item. */ public String getItemCaption(Object itemId) { @@ -1024,10 +1016,11 @@ public abstract class AbstractSelect extends AbstractField implements break; case ITEM_CAPTION_MODE_INDEX: - try { + if (items instanceof Container.Indexed) { caption = String.valueOf(((Container.Indexed) items) .indexOfId(itemId)); - } catch (final ClassCastException ignored) { + } else { + caption = "ERROR: Container is not indexed"; } break; @@ -1066,9 +1059,9 @@ public abstract class AbstractSelect extends AbstractField implements * Sets the icon for an item. * * @param itemId - * the id of the item to be assigned an icon. + * the id of the item to be assigned an icon. * @param icon - * the New icon. + * the New icon. */ public void setItemIcon(Object itemId, Resource icon) { if (itemId != null) { @@ -1085,7 +1078,7 @@ public abstract class AbstractSelect extends AbstractField implements * Gets the item icon. * * @param itemId - * the id of the item to be assigned an icon. + * the id of the item to be assigned an icon. * @return the Icon for the item or null, if not specified. */ public Resource getItemIcon(Object itemId) { @@ -1124,13 +1117,13 @@ public abstract class AbstractSelect extends AbstractField implements * toString is used as item caption.
  • *
  • ITEM_CAPTION_MODE_ITEM : Item-objects * toString is used as item caption.
  • - *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is - * used as item caption. The index mode can only be used with the containers + *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is used + * as item caption. The index mode can only be used with the containers * implementing Container.Indexed interface.
  • - *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must - * be explicitly specified.
  • - *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are - * read from property, that must be specified with + *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must be + * explicitly specified.
  • + *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are read + * from property, that must be specified with * setItemCaptionPropertyId.
  • * * The ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID is the default @@ -1138,7 +1131,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param mode - * the One of the modes listed above. + * the One of the modes listed above. */ public void setItemCaptionMode(int mode) { if (ITEM_CAPTION_MODE_ID <= mode && mode <= ITEM_CAPTION_MODE_PROPERTY) { @@ -1160,13 +1153,13 @@ public abstract class AbstractSelect extends AbstractField implements * toString is used as item caption. *
  • ITEM_CAPTION_MODE_ITEM : Item-objects * toString is used as item caption.
  • - *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is - * used as item caption. The index mode can only be used with the containers + *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is used + * as item caption. The index mode can only be used with the containers * implementing Container.Indexed interface.
  • - *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must - * be explicitly specified.
  • - *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are - * read from property, that must be specified with + *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must be + * explicitly specified.
  • + *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are read + * from property, that must be specified with * setItemCaptionPropertyId.
  • * * The ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID is the default @@ -1185,18 +1178,19 @@ public abstract class AbstractSelect extends AbstractField implements *

    * Setting the id to a existing property implicitly sets the item caption * mode to ITEM_CAPTION_MODE_PROPERTY. If the object is in - * ITEM_CAPTION_MODE_PROPERTY mode, setting caption property - * id null resets the item caption mode to + * ITEM_CAPTION_MODE_PROPERTY mode, setting caption property id + * null resets the item caption mode to * ITEM_CAPTION_EXPLICIT_DEFAULTS_ID. *

    * *

    * Setting the property id to null disables this feature. The id is null by * default - *

    . + *

    + * . * * @param propertyId - * the id of the property. + * the id of the property. * */ public void setItemCaptionPropertyId(Object propertyId) { @@ -1232,17 +1226,18 @@ public abstract class AbstractSelect extends AbstractField implements *

    * *

    - * Note : The icons set with setItemIcon function override - * the icons from the property. + * Note : The icons set with setItemIcon function override the + * icons from the property. *

    * *

    * Setting the property id to null disables this feature. The id is null by * default - *

    . + *

    + * . * * @param propertyId - * the Id of the property that specifies icons for items. + * the Id of the property that specifies icons for items. */ public void setItemIconPropertyId(Object propertyId) { if ((propertyId != null) @@ -1264,14 +1259,15 @@ public abstract class AbstractSelect extends AbstractField implements *

    * *

    - * Note : The icons set with setItemIcon function override - * the icons from the property. + * Note : The icons set with setItemIcon function override the + * icons from the property. *

    * *

    * Setting the property id to null disables this feature. The id is null by * default - *

    . + *

    + * . * * @return the Id of the property containing the item icons. */ @@ -1289,7 +1285,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param itemId - * the Id the of the item to be tested. + * the Id the of the item to be tested. * @see #getNullSelectionItemId() * @see #setNullSelectionItemId(Object) * @@ -1316,7 +1312,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param itemId - * the tem to be selected. + * the tem to be selected. * @see #getNullSelectionItemId() * @see #setNullSelectionItemId(Object) * @@ -1336,7 +1332,7 @@ public abstract class AbstractSelect extends AbstractField implements * Unselects an item. * * @param itemId - * the Item to be unselected. + * the Item to be unselected. * @see #getNullSelectionItemId() * @see #setNullSelectionItemId(Object) * @@ -1495,11 +1491,11 @@ public abstract class AbstractSelect extends AbstractField implements /** * Allow of disallow empty selection. If the select is in single-select * mode, you can make an item represent the empty selection by calling - * setNullSelectionItemId(). This way you can for instance - * set an icon and caption for the null selection item. + * setNullSelectionItemId(). This way you can for instance set + * an icon and caption for the null selection item. * * @param nullSelectionAllowed - * whether or not to allow empty selection + * whether or not to allow empty selection * @see #setNullSelectionItemId(Object) * @see #isNullSelectionAllowed() */ @@ -1546,7 +1542,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param nullSelectionItemId - * the nullSelectionItemId to set. + * the nullSelectionItemId to set. * @see #getNullSelectionItemId() * @see #isSelected(Object) * @see #select(Object) diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java index f24a9ee63c..9e51b81576 100644 --- a/src/com/itmill/toolkit/ui/Button.java +++ b/src/com/itmill/toolkit/ui/Button.java @@ -22,7 +22,7 @@ import com.itmill.toolkit.terminal.PaintTarget; */ public class Button extends AbstractField { - /* Private members ************************************************* */ + /* Private members */ boolean switchMode = false; @@ -42,7 +42,7 @@ public class Button extends AbstractField { * default. * * @param caption - * the Button caption. + * the Button caption. */ public Button(String caption) { setCaption(caption); @@ -53,9 +53,9 @@ public class Button extends AbstractField { * Creates a new push button with click listener. * * @param caption - * the Button caption. + * the Button caption. * @param listener - * the Button click listener. + * the Button click listener. */ public Button(String caption, ClickListener listener) { this(caption); @@ -71,12 +71,12 @@ public class Button extends AbstractField { * of Button.ClickEvent type. * * @param caption - * the Button caption. + * the Button caption. * @param target - * the Object having the method for listening button clicks. + * the Object having the method for listening button clicks. * @param methodName - * the name of the method in target object, that receives - * button click events. + * the name of the method in target object, that receives button + * click events. */ public Button(String caption, Object target, String methodName) { this(caption); @@ -87,7 +87,7 @@ public class Button extends AbstractField { * Creates a new switch button with initial value. * * @param state - * the Initial state of the switch-button. + * the Initial state of the switch-button. * @param initialState */ public Button(String caption, boolean initialState) { @@ -100,7 +100,7 @@ public class Button extends AbstractField { * Creates a new switch button that is connected to a boolean property. * * @param state - * the Initial state of the switch-button. + * the Initial state of the switch-button. * @param dataSource */ public Button(String caption, Property dataSource) { @@ -122,11 +122,11 @@ public class Button extends AbstractField { * Paints the content of this component. * * @param event - * the PaintEvent. + * the PaintEvent. * @throws IOException - * if the writing failed due to input/output error. + * if the writing failed due to input/output error. * @throws PaintException - * if the paint operation failed. + * if the paint operation failed. */ public void paintContent(PaintTarget target) throws PaintException { super.paintContent(target); @@ -153,10 +153,8 @@ public class Button extends AbstractField { */ public void changeVariables(Object source, Map variables) { super.changeVariables(source, variables); - if (isReadOnly()) { - System.err.println("Button: ignoring variable change for" - + " read-only component, caption=" + getCaption()); - } else if (variables.containsKey("state")) { + + if (!isReadOnly() && variables.containsKey("state")) { // Gets the new and old button states final Boolean newValue = (Boolean) variables.get("state"); final Boolean oldValue = (Boolean) getValue(); @@ -199,7 +197,7 @@ public class Button extends AbstractField { * Sets the switchMode. * * @param switchMode - * The switchMode to set. + * The switchMode to set. */ public void setSwitchMode(boolean switchMode) { this.switchMode = switchMode; @@ -237,7 +235,7 @@ public class Button extends AbstractField { return Boolean.class; } - /* Click event ************************************************ */ + /* Click event */ private static final Method BUTTON_CLICK_METHOD; @@ -250,7 +248,8 @@ public class Button extends AbstractField { "buttonClick", new Class[] { ClickEvent.class }); } catch (final java.lang.NoSuchMethodException e) { // This should never happen - throw new java.lang.RuntimeException(); + throw new java.lang.RuntimeException( + "Internal error finding methods in Button"); } } @@ -273,7 +272,7 @@ public class Button extends AbstractField { * New instance of text change event. * * @param source - * the Source of the event. + * the Source of the event. */ public ClickEvent(Component source) { super(source); @@ -303,7 +302,7 @@ public class Button extends AbstractField { * Button has been pressed. * * @param event - * Button click event. + * Button click event. */ public void buttonClick(ClickEvent event); } @@ -312,7 +311,7 @@ public class Button extends AbstractField { * Adds the button click listener. * * @param listener - * the Listener to be added. + * the Listener to be added. */ public void addListener(ClickListener listener) { addListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD); @@ -322,7 +321,7 @@ public class Button extends AbstractField { * Removes the button click listener. * * @param listener - * the Listener to be removed. + * the Listener to be removed. */ public void removeListener(ClickListener listener) { removeListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD); diff --git a/src/com/itmill/toolkit/ui/Form.java b/src/com/itmill/toolkit/ui/Form.java index 6926916325..d9f452a0e6 100644 --- a/src/com/itmill/toolkit/ui/Form.java +++ b/src/com/itmill/toolkit/ui/Form.java @@ -130,7 +130,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, *

    * * @param formLayout - * the layout of the form. + * the layout of the form. */ public Form() { this(null); @@ -141,7 +141,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * Contructs a new form with given layout. * * @param formLayout - * the layout of the form. + * the layout of the form. */ public Form(Layout formLayout) { this(formLayout, new BaseFieldFactory()); @@ -151,9 +151,9 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * Contructs a new form with given layout and FieldFactory. * * @param formLayout - * the layout of the form. + * the layout of the form. * @param fieldFactory - * the FieldFactory of the form. + * the FieldFactory of the form. */ public Form(Layout formLayout, FieldFactory fieldFactory) { super(); @@ -194,9 +194,10 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, ErrorMessage validationError = null; if (isValidationVisible()) { for (final Iterator i = propertyIds.iterator(); i.hasNext();) { - try { - AbstractComponent field = (AbstractComponent) fields.get(i - .next()); + Object f = fields.get(i.next()); + if (f instanceof AbstractComponent) { + AbstractComponent field = (AbstractComponent) f; + validationError = field.getErrorMessage(); if (validationError != null) { // Skip empty errors @@ -205,7 +206,6 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } break; } - } catch (ClassCastException ignored) { } } } @@ -234,9 +234,8 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * the implicit setting by setting this property as false. * * @param makeVisible - * If true (default), validation is made visible when - * commit() is called. If false, the visibility is left as it - * is. + * If true (default), validation is made visible when commit() is + * called. If false, the visibility is left as it is. */ public void setValidationVisibleOnCommit(boolean makeVisible) { validationVisibleOnCommit = makeVisible; @@ -263,8 +262,9 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, // Only commit on valid state if so requested if (!isInvalidCommitted() && !isValid()) { - if (validationVisibleOnCommit) + if (validationVisibleOnCommit) { setValidationVisible(true); + } return; } @@ -465,9 +465,9 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, *

    * * @param propertyId - * the Property id the the field. + * the Property id the the field. * @param field - * the New field added to the form. + * the New field added to the form. */ public void addField(Object propertyId, Field field) { @@ -520,7 +520,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * Gets the field identified by the propertyid. * * @param propertyId - * the id of the property. + * the id of the property. */ public Field getField(Object propertyId) { return (Field) fields.get(propertyId); @@ -634,7 +634,8 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * Gets the layout of the form. * *

    - * By default form uses OrderedLayout with form-style. + * By default form uses OrderedLayout with form + * -style. *

    * * @return the Layout of the form. @@ -647,11 +648,12 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * Sets the layout of the form. * *

    - * By default form uses OrderedLayout with form-style. + * By default form uses OrderedLayout with form + * -style. *

    * * @param newLayout - * the Layout of the form. + * the Layout of the form. */ public void setLayout(Layout newLayout) { @@ -681,7 +683,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, *

    * * @param propertyId - * the id of the property. + * the id of the property. * @param values * @param descriptions * @return the select property generated @@ -867,7 +869,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * By default the form uses BaseFieldFactory to create Field instances. * * @param fieldFactory - * the New factory used to create the fields. + * the New factory used to create the fields. * @see Field * @see FieldFactory */ @@ -974,7 +976,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * Sets the visibleProperties. * * @param visibleProperties - * the visibleProperties to set. + * the visibleProperties to set. */ public void setVisibleItemProperties(Collection visibleProperties) { visibleItemProperties = visibleProperties; @@ -1065,7 +1067,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * Sets the layout that is rendered below normal form contens. * * @param newFormFooter - * the new Layout + * the new Layout */ public void setFooter(Layout newFormFooter) { if (formFooter != null) { diff --git a/src/com/itmill/toolkit/ui/GridLayout.java b/src/com/itmill/toolkit/ui/GridLayout.java index 92082fd546..31f7428af1 100644 --- a/src/com/itmill/toolkit/ui/GridLayout.java +++ b/src/com/itmill/toolkit/ui/GridLayout.java @@ -93,9 +93,9 @@ public class GridLayout extends AbstractLayout implements * if you add components outside the grid's area. * * @param columns - * Number of columns in the grid. + * Number of columns in the grid. * @param rows - * Number of rows in the grid. + * Number of rows in the grid. */ public GridLayout(int columns, int rows) { setColumns(columns); @@ -123,24 +123,24 @@ public class GridLayout extends AbstractLayout implements *

    * * @param c - * the component to be added. + * the component to be added. * @param column1 - * the column of the upper left corner of the area - * c is supposed to occupy. + * the column of the upper left corner of the area c + * is supposed to occupy. * @param row1 - * the row of the upper left corner of the area - * c is supposed to occupy. + * the row of the upper left corner of the area c is + * supposed to occupy. * @param column2 - * the column of the lower right corner of the area - * c is supposed to occupy. + * the column of the lower right corner of the area + * c is supposed to occupy. * @param row2 - * the row of the lower right corner of the area - * c is supposed to occupy. + * the row of the lower right corner of the area c + * is supposed to occupy. * @throws OverlapsException - * if the new component overlaps with any of the components - * already in the grid. + * if the new component overlaps with any of the components + * already in the grid. * @throws OutOfBoundsException - * if the cells are outside of the grid area. + * if the cells are outside of the grid area. */ public void addComponent(Component component, int column1, int row1, int column2, int row2) throws OverlapsException, @@ -216,9 +216,9 @@ public class GridLayout extends AbstractLayout implements * grid. * * @param area - * the Area to be checked for overlapping. + * the Area to be checked for overlapping. * @throws OverlapsException - * if area overlaps with any existing area. + * if area overlaps with any existing area. */ private void checkExistingOverlaps(Area area) throws OverlapsException { for (final Iterator i = areas.iterator(); i.hasNext();) { @@ -236,11 +236,11 @@ public class GridLayout extends AbstractLayout implements * the same as column1,row1. Component width and height is 1. * * @param c - * the component to be added. + * the component to be added. * @param column - * the column index. + * the column index. * @param row - * the row index. + * the row index. */ public void addComponent(Component c, int column, int row) { this.addComponent(c, column, row, column, row); @@ -279,7 +279,7 @@ public class GridLayout extends AbstractLayout implements * grid is automatically extended. * * @param c - * the component to be added. + * the component to be added. */ public void addComponent(Component component) { @@ -291,7 +291,7 @@ public class GridLayout extends AbstractLayout implements area = new Area(component, cursorX, cursorY, cursorX, cursorY); checkExistingOverlaps(area); done = true; - } catch (final OverlapsException ignored) { + } catch (final OverlapsException e) { space(); } } @@ -307,7 +307,7 @@ public class GridLayout extends AbstractLayout implements * Removes the given component from this container. * * @param c - * the component to be removed. + * the component to be removed. */ public void removeComponent(Component component) { @@ -340,9 +340,9 @@ public class GridLayout extends AbstractLayout implements * Removes the component specified with it's cell index. * * @param column - * the Component's column. + * the Component's column. * @param row - * the Component's row. + * the Component's row. */ public void removeComponent(int column, int row) { @@ -370,9 +370,9 @@ public class GridLayout extends AbstractLayout implements * Paints the contents of this component. * * @param target - * the Paint Event. + * the Paint Event. * @throws PaintException - * if the paint operation failed. + * if the paint operation failed. */ public void paintContent(PaintTarget target) throws PaintException { @@ -541,7 +541,9 @@ public class GridLayout extends AbstractLayout implements /* * (non-Javadoc) * - * @see com.itmill.toolkit.ui.Layout.AlignmentHandler#getComponentAlignment(com.itmill.toolkit.ui.Component) + * @see + * com.itmill.toolkit.ui.Layout.AlignmentHandler#getComponentAlignment(com + * .itmill.toolkit.ui.Component) */ public int getComponentAlignment(Component childComponent) { final Integer bitMask = (Integer) componentToAlignment @@ -606,22 +608,22 @@ public class GridLayout extends AbstractLayout implements *

    * * @param component - * the component connected to the area. + * the component connected to the area. * @param column1 - * The column of the upper left corner cell of the area - * c is supposed to occupy. + * The column of the upper left corner cell of the area + * c is supposed to occupy. * @param row1 - * The row of the upper left corner cell of the area - * c is supposed to occupy. + * The row of the upper left corner cell of the area + * c is supposed to occupy. * @param column2 - * The column of the lower right corner cell of the area - * c is supposed to occupy. + * The column of the lower right corner cell of the area + * c is supposed to occupy. * @param row2 - * The row of the lower right corner cell of the area - * c is supposed to occupy. + * The row of the lower right corner cell of the area + * c is supposed to occupy. * @throws OverlapsException - * if the new component overlaps with any of the - * components already in the grid + * if the new component overlaps with any of the components + * already in the grid */ public Area(Component component, int column1, int row1, int column2, int row2) { @@ -636,10 +638,10 @@ public class GridLayout extends AbstractLayout implements * 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. - * @return true if other overlaps with - * this area, false if it doesn't. + * the Another Area that's to be tested for overlap with this + * area. + * @return true if other overlaps with this + * area, false if it doesn't. */ public boolean overlaps(Area other) { return column1 <= other.getColumn2() && row1 <= other.getRow2() @@ -665,7 +667,7 @@ public class GridLayout extends AbstractLayout implements *

    * * @param newComponent - * the new connected overriding the existing one. + * the new connected overriding the existing one. */ protected void setComponent(Component newComponent) { component = newComponent; @@ -783,8 +785,8 @@ public class GridLayout extends AbstractLayout implements } /** - * An Exception object which is thrown when an area exceeds - * the bounds of the grid. + * An Exception object which is thrown when an area exceeds the + * bounds of the grid. * * @author IT Mill Ltd. * @version @@ -825,7 +827,7 @@ public class GridLayout extends AbstractLayout implements * reduced if there are any areas that would be outside of the shrunk grid. * * @param columns - * the new number of columns in the grid. + * the new number of columns in the grid. */ public void setColumns(int columns) { @@ -869,7 +871,7 @@ public class GridLayout extends AbstractLayout implements * reduced if there are any areas that would be outside of the shrunk grid. * * @param rows - * the new number of rows in the grid. + * the new number of rows in the grid. */ public void setRows(int rows) { @@ -977,8 +979,9 @@ public class GridLayout extends AbstractLayout implements /* * (non-Javadoc) * - * @see com.itmill.toolkit.ui.Layout.AlignmentHandler#setComponentAlignment(com.itmill.toolkit.ui.Component, - * int, int) + * @see + * com.itmill.toolkit.ui.Layout.AlignmentHandler#setComponentAlignment(com + * .itmill.toolkit.ui.Component, int, int) */ public void setComponentAlignment(Component childComponent, int horizontalAlignment, int verticalAlignment) { @@ -1010,7 +1013,7 @@ public class GridLayout extends AbstractLayout implements * Inserts an empty row at the chosen position in the grid. * * @param row - * Number of the row the new row will be inserted before + * Number of the row the new row will be inserted before */ public void insertRow(int row) { if (row > rows) { @@ -1047,7 +1050,7 @@ public class GridLayout extends AbstractLayout implements * row. * * @param row - * The row number to remove + * The row number to remove */ public void removeRow(int row) { if (row >= rows) { diff --git a/src/com/itmill/toolkit/ui/Label.java b/src/com/itmill/toolkit/ui/Label.java index af5b2a0685..a7fbbdba77 100644 --- a/src/com/itmill/toolkit/ui/Label.java +++ b/src/com/itmill/toolkit/ui/Label.java @@ -20,15 +20,15 @@ import com.itmill.toolkit.terminal.PaintTarget; *

    * The contents of the label may contain simple formatting: *

    - * The b,i,u and li tags can contain all the - * tags in the list recursively. + * The b,i,u and li tags can contain all the tags in + * the list recursively. *

    * * @author IT Mill Ltd. @@ -154,7 +154,7 @@ public class Label extends AbstractComponent implements Property, * Set the component to read-only. Readonly is not used in label. * * @param readOnly - * True to enable read-only mode, False to disable it. + * True to enable read-only mode, False to disable it. */ public void setReadOnly(boolean readOnly) { if (dataSource == null) { @@ -180,9 +180,9 @@ public class Label extends AbstractComponent implements Property, * Paints the content of this component. * * @param target - * the Paint Event. + * the Paint Event. * @throws PaintException - * if the Paint Operation fails. + * if the Paint Operation fails. */ public void paintContent(PaintTarget target) throws PaintException { if (contentMode != CONTENT_TEXT) { @@ -230,7 +230,7 @@ public class Label extends AbstractComponent implements Property, * label. * * @param newValue - * the New value of the label. + * the New value of the label. */ public void setValue(Object newValue) { if (dataSource == null) { @@ -275,7 +275,7 @@ public class Label extends AbstractComponent implements Property, * Sets the property as data-source for viewing. * * @param newDataSource - * the new data source Property + * the new data source Property * @see com.itmill.toolkit.data.Property.Viewer#setPropertyDataSource(com.itmill.toolkit.data.Property) */ public void setPropertyDataSource(Property newDataSource) { @@ -303,23 +303,23 @@ public class Label extends AbstractComponent implements Property, *

    * Possible content modes include: *

    *

    * @@ -335,28 +335,28 @@ public class Label extends AbstractComponent implements Property, *

    * Possible content modes include: *

    *

    * * @param contentMode - * the New content mode of the label. + * the New content mode of the label. */ public void setContentMode(int contentMode) { if (contentMode >= CONTENT_TEXT && contentMode <= CONTENT_RAW) { @@ -364,7 +364,7 @@ public class Label extends AbstractComponent implements Property, } } - /* Value change events ****************************************** */ + /* Value change events */ private static final Method VALUE_CHANGE_METHOD; @@ -375,7 +375,8 @@ public class Label extends AbstractComponent implements Property, new Class[] { Property.ValueChangeEvent.class }); } catch (final java.lang.NoSuchMethodException e) { // This should never happen - throw new java.lang.RuntimeException(); + throw new java.lang.RuntimeException( + "Internal error finding methods in Label"); } } @@ -399,7 +400,7 @@ public class Label extends AbstractComponent implements Property, * New instance of text change event * * @param source - * the Source of the event. + * the Source of the event. */ public ValueChangeEvent(Label source) { super(source); @@ -419,7 +420,7 @@ public class Label extends AbstractComponent implements Property, * Adds the value change listener. * * @param listener - * the Listener to be added. + * 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) { @@ -430,7 +431,7 @@ public class Label extends AbstractComponent implements Property, * Removes the value change listener. * * @param listener - * the Listener to be removed. + * 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) { @@ -472,7 +473,7 @@ public class Label extends AbstractComponent implements Property, *

    * * @param other - * the Other object to compare to. + * 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) @@ -505,7 +506,7 @@ public class Label extends AbstractComponent implements Property, * Strips the tags from the XML. * * @param xml - * the String containing a XML snippet. + * the String containing a XML snippet. * @return the original XML without tags. */ private String stripTags(String xml) { diff --git a/src/com/itmill/toolkit/ui/LoginForm.java b/src/com/itmill/toolkit/ui/LoginForm.java index 34aea8ad2c..12c7fdb455 100644 --- a/src/com/itmill/toolkit/ui/LoginForm.java +++ b/src/com/itmill/toolkit/ui/LoginForm.java @@ -216,7 +216,8 @@ public class LoginForm extends CustomComponent { new Class[] { LoginEvent.class }); } catch (final java.lang.NoSuchMethodException e) { // This should never happen - throw new java.lang.RuntimeException(); + throw new java.lang.RuntimeException( + "Internal error finding methods in LoginForm"); } } diff --git a/src/com/itmill/toolkit/ui/Slider.java b/src/com/itmill/toolkit/ui/Slider.java index ebef0017f0..854430e852 100644 --- a/src/com/itmill/toolkit/ui/Slider.java +++ b/src/com/itmill/toolkit/ui/Slider.java @@ -14,31 +14,31 @@ import com.itmill.toolkit.terminal.PaintTarget; * * Example code: * class MyPlayer extends CustomComponent implements ValueChangeListener { - * - * Label volumeIndicator = new Label(); - * Slider slider; - * - * public MyPlayer() { - * OrderedLayout ol = new OrderedLayout(); - * setCompositionRoot(ol); - * slider = new Slider("Volume", 0, 100); - * slider.setImmediate(true); - * ol.addComponent(slider); - * ol.addComponent(volumeIndicator); - * volumeIndicator.setValue(new Double(50)); - * slider.addListener(this); - * - * } - * - * public void setVolume(double d) { - * volumeIndicator.setValue("Current volume : " + d); - * } - * - * public void valueChange(ValueChangeEvent event) { - * Double d = (Double) event.getProperty().getValue(); - * setVolume(d.doubleValue()); - * } - * } + * + * Label volumeIndicator = new Label(); + * Slider slider; + * + * public MyPlayer() { + * OrderedLayout ol = new OrderedLayout(); + * setCompositionRoot(ol); + * slider = new Slider("Volume", 0, 100); + * slider.setImmediate(true); + * ol.addComponent(slider); + * ol.addComponent(volumeIndicator); + * volumeIndicator.setValue(new Double(50)); + * slider.addListener(this); + * + * } + * + * public void setVolume(double d) { + * volumeIndicator.setValue("Current volume : " + d); + * } + * + * public void valueChange(ValueChangeEvent event) { + * Double d = (Double) event.getProperty().getValue(); + * setVolume(d.doubleValue()); + * } + * } * * * @@ -113,7 +113,7 @@ public class Slider extends AbstractField { * values set to defaults. * * @param caption - * The caption for this Slider (e.g. "Volume"). + * The caption for this Slider (e.g. "Volume"). */ public Slider(String caption) { this(); @@ -173,7 +173,7 @@ public class Slider extends AbstractField { * is out of new bounds, the value is set to new minimum. * * @param max - * New maximum value of the Slider. + * New maximum value of the Slider. */ public void setMax(double max) { this.max = max; @@ -182,6 +182,11 @@ public class Slider extends AbstractField { super.setValue(new Double(max)); } } catch (final ClassCastException e) { + // FIXME: Handle exception + /* + * Where does ClassCastException come from? Can't see any casts + * above + */ super.setValue(new Double(max)); } requestRepaint(); @@ -201,7 +206,7 @@ public class Slider extends AbstractField { * is out of new bounds, the value is set to new minimum. * * @param min - * New minimum value of the Slider. + * New minimum value of the Slider. */ public void setMin(double min) { this.min = min; @@ -210,6 +215,11 @@ public class Slider extends AbstractField { super.setValue(new Double(min)); } } catch (final ClassCastException e) { + // FIXME: Handle exception + /* + * Where does ClassCastException come from? Can't see any casts + * above + */ super.setValue(new Double(min)); } requestRepaint(); @@ -227,8 +237,7 @@ public class Slider extends AbstractField { /** * Set the orientation of the Slider. * - * @param int - * new orientation + * @param int new orientation */ public void setOrientation(int orientation) { this.orientation = orientation; @@ -261,10 +270,10 @@ public class Slider extends AbstractField { * Set the value of this Slider. * * @param value - * New value of Slider. Must be within Sliders range (min - - * max), otherwise throws an exception. + * New value of Slider. Must be within Sliders range (min - max), + * otherwise throws an exception. * @param repaintIsNotNeeded - * If true, client-side is not requested to repaint itself. + * If true, client-side is not requested to repaint itself. * @throws ValueOutOfBoundsException */ public void setValue(Double value, boolean repaintIsNotNeeded) @@ -291,8 +300,8 @@ public class Slider extends AbstractField { * Set the value of this Slider. * * @param value - * New value of Slider. Must be within Sliders range (min - - * max), otherwise throws an exception. + * New value of Slider. Must be within Sliders range (min - max), + * otherwise throws an exception. * @throws ValueOutOfBoundsException */ public void setValue(Double value) throws ValueOutOfBoundsException { @@ -303,8 +312,8 @@ public class Slider extends AbstractField { * Set the value of this Slider. * * @param value - * New value of Slider. Must be within Sliders range (min - - * max), otherwise throws an exception. + * New value of Slider. Must be within Sliders range (min - max), + * otherwise throws an exception. * @throws ValueOutOfBoundsException */ public void setValue(double value) throws ValueOutOfBoundsException { @@ -325,7 +334,7 @@ public class Slider extends AbstractField { * Set the size for this Slider. * * @param size - * in pixels, or -1 auto sizing. + * in pixels, or -1 auto sizing. * @deprecated use standard setWidth/setHeight instead */ public void setSize(int size) { @@ -356,7 +365,7 @@ public class Slider extends AbstractField { * Set the handle size of this Slider. * * @param handleSize - * in percentages relative to slider base size. + * in percentages relative to slider base size. */ public void setHandleSize(int handleSize) { if (handleSize < 0) { @@ -376,17 +385,17 @@ public class Slider extends AbstractField { * * @param visible *//* - * public void setArrows(boolean visible) { arrows = visible; - * requestRepaint(); } - */ + * public void setArrows(boolean visible) { arrows = visible; + * requestRepaint(); } + */ /* * Does the slider have arrows? * * @return arrows visible *//* - * public boolean isArrowsVisible() { return arrows; } - */ + * public boolean isArrowsVisible() { return arrows; } + */ public String getTag() { return "slider"; diff --git a/src/com/itmill/toolkit/ui/TabSheet.java b/src/com/itmill/toolkit/ui/TabSheet.java index 80cbb7a97d..37bd512d2e 100644 --- a/src/com/itmill/toolkit/ui/TabSheet.java +++ b/src/com/itmill/toolkit/ui/TabSheet.java @@ -67,7 +67,7 @@ public class TabSheet extends AbstractComponentContainer implements * Removes the component from this container. * * @param c - * the component to be removed. + * the component to be removed. */ public void removeComponent(Component c) { if (c != null && tabs.contains(c)) { @@ -91,7 +91,7 @@ public class TabSheet extends AbstractComponentContainer implements * into tab. * * @param c - * the component to be added. + * the component to be added. */ public void addComponent(Component c) { addTab(c); @@ -101,13 +101,13 @@ public class TabSheet extends AbstractComponentContainer implements * Adds a new tab into TabSheet. * * @param c - * the component to be added onto tab. + * the component to be added onto tab. * @param caption - * the caption to be set for the component and used rendered - * in tab bar + * the caption to be set for the component and used rendered in + * tab bar * @param icon - * the icon to be set for the component and used rendered in - * tab bar + * the icon to be set for the component and used rendered in tab + * bar */ public void addTab(Component c, String caption, Resource icon) { if (c != null) { @@ -126,7 +126,7 @@ public class TabSheet extends AbstractComponentContainer implements * into tab. * * @param c - * the component to be added onto tab. + * the component to be added onto tab. */ public void addTab(Component c) { if (c != null) { @@ -154,7 +154,7 @@ public class TabSheet extends AbstractComponentContainer implements * components are removed from the other container. * * @param source - * the container components are removed from. + * the container components are removed from. */ public void moveComponentsFrom(ComponentContainer source) { for (final Iterator i = source.getComponentIterator(); i.hasNext();) { @@ -175,9 +175,9 @@ public class TabSheet extends AbstractComponentContainer implements * Paints the content of this component. * * @param event - * the Paint Event. + * the Paint Event. * @throws PaintException - * if the paint operation failed. + * if the paint operation failed. */ public void paintContent(PaintTarget target) throws PaintException { @@ -248,7 +248,7 @@ public class TabSheet extends AbstractComponentContainer implements * Setter for property tabsHidden. * * @param tabsHidden - * True if the tabs should be hidden. + * True if the tabs should be hidden. */ public void hideTabs(boolean tabsHidden) { this.tabsHidden = tabsHidden; @@ -259,7 +259,7 @@ public class TabSheet extends AbstractComponentContainer implements * Gets the caption for a component. * * @param c - * the component. + * the component. */ public String getTabCaption(Component c) { if (c.getCaption() == null) { @@ -273,9 +273,9 @@ public class TabSheet extends AbstractComponentContainer implements * Sets tabs captions. * * @param c - * the component. + * the component. * @param caption - * the caption to set. + * the caption to set. */ public void setTabCaption(Component c, String caption) { if (tabs.contains(c)) { @@ -287,7 +287,7 @@ public class TabSheet extends AbstractComponentContainer implements * Gets the icon for a component. * * @param c - * the component. + * the component. */ public Resource getTabIcon(Component c) { return c.getIcon(); @@ -405,7 +405,7 @@ public class TabSheet extends AbstractComponentContainer implements } - /* Click event ************************************************ */ + /* Click event */ private static final Method SELECTED_TAB_CHANGE_METHOD; static { @@ -415,7 +415,8 @@ public class TabSheet extends AbstractComponentContainer implements new Class[] { SelectedTabChangeEvent.class }); } catch (final java.lang.NoSuchMethodException e) { // This should never happen - throw new java.lang.RuntimeException(); + throw new java.lang.RuntimeException( + "Internal error finding methods in TabSheet"); } } @@ -439,7 +440,7 @@ public class TabSheet extends AbstractComponentContainer implements * New instance of selected tab change event * * @param source - * the Source of the event. + * the Source of the event. */ public SelectedTabChangeEvent(Component source) { super(source); @@ -470,7 +471,7 @@ public class TabSheet extends AbstractComponentContainer implements * Visible tab in tab sheet has has been changed. * * @param event - * the Selected tab change event. + * the Selected tab change event. */ public void selectedTabChange(SelectedTabChangeEvent event); } @@ -479,7 +480,7 @@ public class TabSheet extends AbstractComponentContainer implements * Adds the selected tab change listener * * @param listener - * the Listener to be added. + * the Listener to be added. */ public void addListener(SelectedTabChangeListener listener) { addListener(SelectedTabChangeEvent.class, listener, @@ -490,7 +491,7 @@ public class TabSheet extends AbstractComponentContainer implements * Removes the selected tab change listener * * @param listener - * the Listener to be removed. + * the Listener to be removed. */ public void removeListener(SelectedTabChangeListener listener) { removeListener(SelectedTabChangeEvent.class, listener, diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 7910f5b74b..a8b660554f 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -140,7 +140,7 @@ public class Table extends AbstractSelect implements Action.Container, */ public static final int ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID = AbstractSelect.ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID; - /* Private table extensions to Select *********************************** */ + /* Private table extensions to Select */ /** * True if column collapsing is allowed. @@ -306,7 +306,7 @@ public class Table extends AbstractSelect implements Action.Container, */ private CellStyleGenerator cellStyleGenerator = null; - /* Table constructors *************************************************** */ + /* Table constructors */ /** * Creates a new empty table. @@ -337,7 +337,7 @@ public class Table extends AbstractSelect implements Action.Container, setContainerDataSource(dataSource); } - /* Table functionality ************************************************** */ + /* Table functionality */ /** * Gets the array of visible column id:s, including generated columns. @@ -364,7 +364,7 @@ public class Table extends AbstractSelect implements Action.Container, *

    * * @param visibleColumns - * the Array of shown property id:s. + * the Array of shown property id:s. */ public void setVisibleColumns(Object[] visibleColumns) { @@ -461,8 +461,8 @@ public class Table extends AbstractSelect implements Action.Container, *

    * * @param columnHeaders - * the Array of column headers that match the - * getVisibleColumns method. + * the Array of column headers that match the + * getVisibleColumns method. */ public void setColumnHeaders(String[] columnHeaders) { @@ -521,8 +521,8 @@ public class Table extends AbstractSelect implements Action.Container, *

    * * @param columnIcons - * the Array of icons that match the - * getVisibleColumns. + * the Array of icons that match the + * getVisibleColumns. */ public void setColumnIcons(Resource[] columnIcons) { @@ -548,8 +548,8 @@ public class Table extends AbstractSelect implements Action.Container, * *

    * The items in the array must match the properties identified by - * getVisibleColumns(). The possible values for the - * alignments include: + * getVisibleColumns(). The possible values for the alignments + * include: *