Kaynağa Gözat

Fixed for #2006 - updated error handling

svn changeset:5281/svn branch:trunk
tags/6.7.0.beta1
Artur Signell 16 yıl önce
ebeveyn
işleme
b3a85cbe27
32 değiştirilmiş dosya ile 1180 ekleme ve 1100 silme
  1. 89
    75
      src/com/itmill/toolkit/Application.java
  2. 54
    50
      src/com/itmill/toolkit/data/util/FilesystemContainer.java
  3. 13
    25
      src/com/itmill/toolkit/event/EventRouter.java
  4. 94
    104
      src/com/itmill/toolkit/event/ListenerMethod.java
  5. 17
    17
      src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
  6. 1
    2
      src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java
  7. 27
    0
      src/com/itmill/toolkit/terminal/gwt/client/ClientExceptionHandler.java
  8. 10
    19
      src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java
  9. 1
    1
      src/com/itmill/toolkit/terminal/gwt/client/UIDL.java
  10. 5
    4
      src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
  11. 11
    11
      src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java
  12. 4
    3
      src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
  13. 152
    166
      src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
  14. 23
    17
      src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
  15. 57
    0
      src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java
  16. 6
    4
      src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java
  17. 4
    4
      src/com/itmill/toolkit/ui/AbstractComponent.java
  18. 5
    4
      src/com/itmill/toolkit/ui/AbstractComponentContainer.java
  19. 24
    22
      src/com/itmill/toolkit/ui/AbstractField.java
  20. 81
    85
      src/com/itmill/toolkit/ui/AbstractSelect.java
  21. 23
    24
      src/com/itmill/toolkit/ui/Button.java
  22. 24
    22
      src/com/itmill/toolkit/ui/Form.java
  23. 54
    51
      src/com/itmill/toolkit/ui/GridLayout.java
  24. 46
    45
      src/com/itmill/toolkit/ui/Label.java
  25. 2
    1
      src/com/itmill/toolkit/ui/LoginForm.java
  26. 53
    44
      src/com/itmill/toolkit/ui/Slider.java
  27. 23
    22
      src/com/itmill/toolkit/ui/TabSheet.java
  28. 107
    104
      src/com/itmill/toolkit/ui/Table.java
  29. 26
    26
      src/com/itmill/toolkit/ui/TextField.java
  30. 32
    33
      src/com/itmill/toolkit/ui/Tree.java
  31. 35
    36
      src/com/itmill/toolkit/ui/Upload.java
  32. 77
    79
      src/com/itmill/toolkit/ui/Window.java

+ 89
- 75
src/com/itmill/toolkit/Application.java Dosyayı Görüntüle

* <p> * <p>
* Base class required for all IT Mill Toolkit applications. This class provides * Base class required for all IT Mill Toolkit applications. This class provides
* all the basic services required by the toolkit. These services allow external * 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.
* </p> * </p>
* *
* <p> * <p>
* </p> * </p>
* *
* <p> * <p>
* <strong>Window access.</strong> <code>Application</code> provides methods
* to list, add and remove the windows it contains.
* <strong>Window access.</strong> <code>Application</code> provides methods to
* list, add and remove the windows it contains.
* </p> * </p>
* *
* <p> * <p>
* <p> * <p>
* Since version 5.0 all windows can be referenced by their names in url * Since version 5.0 all windows can be referenced by their names in url
* <code>http://host:port/foo/bar/</code> where * <code>http://host:port/foo/bar/</code> where
* <code>http://host:port/foo/</code> is the application url as returned
* by getURL() and <code>bar</code> is the name of the window.
* <code>http://host:port/foo/</code> is the application url as returned by
* getURL() and <code>bar</code> is the name of the window.
* </p> * </p>
* *
* <p> * <p>
* <p> * <p>
* The method should return null if the window does not exists (and is not * 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 * created as a side-effect) or if the application is not running anymore
* </p>.
* </p>
* .
* *
* @param name * @param name
* the name of the window.
* the name of the window.
* @return the window associated with the given URI or <code>null</code> * @return the window associated with the given URI or <code>null</code>
*/ */
public Window getWindow(String name) { public Window getWindow(String name) {
* <p> * <p>
* Note that all application-level windows can be accessed by their names in * Note that all application-level windows can be accessed by their names in
* url <code>http://host:port/foo/bar/</code> where * url <code>http://host:port/foo/bar/</code> where
* <code>http://host:port/foo/</code> is the application url as returned
* by getURL() and <code>bar</code> 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.
* <code>http://host:port/foo/</code> is the application url as returned by
* getURL() and <code>bar</code> 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.
* </p> * </p>
* *
* @param window * @param window
* the new <code>Window</code> to add. If the name of the
* window is <code>null</code>, an unique name is
* automatically given for the window.
* the new <code>Window</code> to add. If the name of the window
* is <code>null</code>, an unique name is automatically given
* for the window.
* @throws IllegalArgumentException * @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 * @throws NullPointerException
* if the given <code>Window</code> is <code>null</code>.
* if the given <code>Window</code> is <code>null</code>.
*/ */
public void addWindow(Window window) throws IllegalArgumentException, public void addWindow(Window window) throws IllegalArgumentException,
NullPointerException { NullPointerException {
* Removes the specified window from the application. * Removes the specified window from the application.
* *
* @param window * @param window
* the window to be removed.
* the window to be removed.
*/ */
public void removeWindow(Window window) { public void removeWindow(Window window) {
if (window != null && windows.contains(window)) { if (window != null && windows.contains(window)) {
* </p> * </p>
* *
* @param user * @param user
* the new user.
* the new user.
*/ */
public void setUser(Object user) { public void setUser(Object user) {
final Object prevUser = this.user; final Object prevUser = this.user;
* {@link javax.servlet.ServletContext}. * {@link javax.servlet.ServletContext}.
* *
* @param applicationUrl * @param applicationUrl
* the URL the application should respond to.
* the URL the application should respond to.
* @param applicationProperties * @param applicationProperties
* the Application properties as specified by the servlet
* configuration.
* the Application properties as specified by the servlet
* configuration.
* @param context * @param context
* the context application will be running in.
* the context application will be running in.
* *
*/ */
public void start(URL applicationUrl, Properties applicationProperties, public void start(URL applicationUrl, Properties applicationProperties,
* </p> * </p>
* *
* @param theme * @param theme
* the new theme for this application.
* the new theme for this application.
*/ */
public void setTheme(String theme) { public void setTheme(String theme) {


* </p> * </p>
* *
* @param mainWindow * @param mainWindow
* the mainWindow to set.
* the mainWindow to set.
*/ */
public void setMainWindow(Window mainWindow) { public void setMainWindow(Window mainWindow) {


* are defined. * are defined.
* *
* @param name * @param name
* the name of the property.
* the name of the property.
* @return the value in this property list with the specified key value. * @return the value in this property list with the specified key value.
*/ */
public String getProperty(String name) { public String getProperty(String name) {
* user of the application. * user of the application.
* *
* @param resource * @param resource
* the resource to add.
* the resource to add.
*/ */
public void addResource(ApplicationResource resource) { public void addResource(ApplicationResource resource) {


* Removes the resource from the application. * Removes the resource from the application.
* *
* @param resource * @param resource
* the resource to remove.
* the resource to remove.
*/ */
public void removeResource(ApplicationResource resource) { public void removeResource(ApplicationResource resource) {
final Object key = resourceKeyMap.get(resource); final Object key = resourceKeyMap.get(resource);
* Gets the relative uri of the resource. * Gets the relative uri of the resource.
* *
* @param resource * @param resource
* the resource to get relative location.
* the resource to get relative location.
* @return the relative uri of the resource. * @return the relative uri of the resource.
*/ */
public String getRelativeLocation(ApplicationResource resource) { public String getRelativeLocation(ApplicationResource resource) {
: ""; : "";
return window.handleURI(windowContext, windowUri); return window.handleURI(windowContext, windowUri);
} catch (final MalformedURLException e) { } catch (final MalformedURLException e) {
terminalError(new ApplicationError(e));
return null; return null;
} }
} }
* Sets the default locale for this application. * Sets the default locale for this application.
* *
* @param locale * @param locale
* the Locale object.
* the Locale object.
* *
*/ */
public void setLocale(Locale locale) { public void setLocale(Locale locale) {
* Constructor for user change event. * Constructor for user change event.
* *
* @param source * @param source
* the application source.
* the application source.
* @param newUser * @param newUser
* the new User.
* the new User.
* @param prevUser * @param prevUser
* the previous User.
* the previous User.
*/ */
public UserChangeEvent(Application source, Object newUser, public UserChangeEvent(Application source, Object newUser,
Object prevUser) { Object prevUser) {
* application user has changed. * application user has changed.
* *
* @param event * @param event
* the change event.
* the change event.
*/ */
public void applicationUserChanged(Application.UserChangeEvent event); public void applicationUserChanged(Application.UserChangeEvent event);
} }
* Adds the user change listener. * Adds the user change listener.
* *
* @param listener * @param listener
* the user change listener to add.
* the user change listener to add.
*/ */
public void addListener(UserChangeListener listener) { public void addListener(UserChangeListener listener) {
if (userChangeListeners == null) { if (userChangeListeners == null) {
* Removes the user change listener. * Removes the user change listener.
* *
* @param listener * @param listener
* the user change listener to remove.
* the user change listener to remove.
*/ */
public void removeListener(UserChangeListener listener) { public void removeListener(UserChangeListener listener) {
if (userChangeListeners == null) { if (userChangeListeners == null) {
* Creates a event. * Creates a event.
* *
* @param window * @param window
* the Detached window.
* the Detached window.
*/ */
public WindowDetachEvent(Window window) { public WindowDetachEvent(Window window) {
super(Application.this); super(Application.this);
* Creates a event. * Creates a event.
* *
* @param window * @param window
* the Attached window.
* the Attached window.
*/ */
public WindowAttachEvent(Window window) { public WindowAttachEvent(Window window) {
super(Application.this); super(Application.this);
* Window attached * Window attached
* *
* @param event * @param event
* the window attach event.
* the window attach event.
*/ */
public void windowAttached(WindowAttachEvent event); public void windowAttached(WindowAttachEvent event);
} }
* Window detached. * Window detached.
* *
* @param event * @param event
* the window detach event.
* the window detach event.
*/ */
public void windowDetached(WindowDetachEvent event); public void windowDetached(WindowDetachEvent event);
} }
* Adds the window attach listener. * Adds the window attach listener.
* *
* @param listener * @param listener
* the window attach listener to add.
* the window attach listener to add.
*/ */
public void addListener(WindowAttachListener listener) { public void addListener(WindowAttachListener listener) {
if (windowAttachListeners == null) { if (windowAttachListeners == null) {
* Adds the window detach listener. * Adds the window detach listener.
* *
* @param listener * @param listener
* the window detach listener to add.
* the window detach listener to add.
*/ */
public void addListener(WindowDetachListener listener) { public void addListener(WindowDetachListener listener) {
if (windowDetachListeners == null) { if (windowDetachListeners == null) {
* Removes the window attach listener. * Removes the window attach listener.
* *
* @param listener * @param listener
* the window attach listener to remove.
* the window attach listener to remove.
*/ */
public void removeListener(WindowAttachListener listener) { public void removeListener(WindowAttachListener listener) {
if (windowAttachListeners != null) { if (windowAttachListeners != null) {
* Removes the window detach listener. * Removes the window detach listener.
* *
* @param listener * @param listener
* the window detach listener to remove.
* the window detach listener to remove.
*/ */
public void removeListener(WindowDetachListener listener) { public void removeListener(WindowDetachListener listener) {
if (windowDetachListeners != null) { if (windowDetachListeners != null) {


/** /**
* Returns the URL user is redirected to on application close. If the URL is * Returns the URL user is redirected to on application close. If the URL is
* <code>null</code>, the application is closed normally as defined by
* the application running environment.
* <code>null</code>, the application is closed normally as defined by the
* application running environment.
* <p> * <p>
* Desktop application just closes the application window and * Desktop application just closes the application window and
* web-application redirects the browser to application main URL. * web-application redirects the browser to application main URL.


/** /**
* Sets the URL user is redirected to on application close. If the URL is * Sets the URL user is redirected to on application close. If the URL is
* <code>null</code>, the application is closed normally as defined by
* the application running environment: Desktop application just closes the
* <code>null</code>, 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 window and web-application redirects the browser to
* application main URL. * application main URL.
* *
* @param logoutURL * @param logoutURL
* the logoutURL to set.
* the logoutURL to set.
*/ */
public void setLogoutURL(String logoutURL) { public void setLogoutURL(String logoutURL) {
this.logoutURL = logoutURL; this.logoutURL = logoutURL;
* <p> * <p>
* Invoked by the terminal on any exception that occurs in application and * Invoked by the terminal on any exception that occurs in application and
* is thrown by the <code>setVariable</code> to the terminal. The default * is thrown by the <code>setVariable</code> to the terminal. The default
* implementation sets the exceptions as <code>ComponentErrors</code> to
* the component that initiated the exception and prints stack trace to
* standard error stream.
* implementation sets the exceptions as <code>ComponentErrors</code> to the
* component that initiated the exception and prints stack trace to standard
* error stream.
* </p> * </p>
* <p> * <p>
* You can safely override this method in your application in order to * You can safely override this method in your application in order to
* </p> * </p>
* *
* @param event * @param event
* the change event.
* the change event.
* @see com.itmill.toolkit.terminal.Terminal.ErrorListener#terminalError(com.itmill.toolkit.terminal.Terminal.ErrorEvent) * @see com.itmill.toolkit.terminal.Terminal.ErrorListener#terminalError(com.itmill.toolkit.terminal.Terminal.ErrorEvent)
*/ */
public void terminalError(Terminal.ErrorEvent event) { public void terminalError(Terminal.ErrorEvent event) {
* <p> * <p>
* The default behavior is to show a notification, and restart the * The default behavior is to show a notification, and restart the
* application the the user clicks the message. <br/> Instead of restarting * application the the user clicks the message. <br/> Instead of restarting
* the application, you can set a specific URL that the user is taken to.<br/>
* 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.<br/> 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.
* </p> * </p>
* <p> * <p>
* The situations are: * The situations are:
* <li> Session expired: the user session has expired, usually due to
* <li>Session expired: the user session has expired, usually due to
* inactivity.</li> * inactivity.</li>
* <li> Internal error: unhandled critical server error (e.g out of memory,
* <li>Internal error: unhandled critical server error (e.g out of memory,
* database crash) * database crash)
* <li> Out of sync: the client is not in sync with the server. E.g the user
* <li>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 * 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 * 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 * instance) pressing a button that is no longer present in the UI will
* Sets the URL to go to when the session has expired. * Sets the URL to go to when the session has expired.
* *
* @param sessionExpiredURL * @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) { public void setSessionExpiredURL(String sessionExpiredURL) {
this.sessionExpiredURL = sessionExpiredURL; this.sessionExpiredURL = sessionExpiredURL;
* current) is loaded directly. * current) is loaded directly.
* *
* @param sessionExpiredNotificationEnabled * @param sessionExpiredNotificationEnabled
* true = enabled, false = disabled
* true = enabled, false = disabled
*/ */
public void setSessionExpiredNotificationEnabled( public void setSessionExpiredNotificationEnabled(
boolean sessionExpiredNotificationEnabled) { boolean sessionExpiredNotificationEnabled) {
* both caption and message is null, the notification is disabled; * both caption and message is null, the notification is disabled;
* *
* @param sessionExpiredCaption * @param sessionExpiredCaption
* the caption
* the caption
*/ */
public void setSessionExpiredCaption(String sessionExpiredCaption) { public void setSessionExpiredCaption(String sessionExpiredCaption) {
this.sessionExpiredCaption = sessionExpiredCaption; this.sessionExpiredCaption = sessionExpiredCaption;
* both caption and message is null, the notification is disabled; * both caption and message is null, the notification is disabled;
* *
* @param sessionExpiredMessage * @param sessionExpiredMessage
* the message
* the message
*/ */
public void setSessionExpiredMessage(String sessionExpiredMessage) { public void setSessionExpiredMessage(String sessionExpiredMessage) {
this.sessionExpiredMessage = sessionExpiredMessage; this.sessionExpiredMessage = sessionExpiredMessage;
* Sets the URL to go to when an internal error occurs. * Sets the URL to go to when an internal error occurs.
* *
* @param internalErrorURL * @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) { public void setInternalErrorURL(String internalErrorURL) {
this.internalErrorURL = internalErrorURL; this.internalErrorURL = internalErrorURL;
* current) is loaded directly. * current) is loaded directly.
* *
* @param internalErrorNotificationEnabled * @param internalErrorNotificationEnabled
* true = enabled, false = disabled
* true = enabled, false = disabled
*/ */
public void setInternalErrorNotificationEnabled( public void setInternalErrorNotificationEnabled(
boolean internalErrorNotificationEnabled) { boolean internalErrorNotificationEnabled) {
* both caption and message is null, the notification is disabled; * both caption and message is null, the notification is disabled;
* *
* @param internalErrorCaption * @param internalErrorCaption
* the caption
* the caption
*/ */
public void setInternalErrorCaption(String internalErrorCaption) { public void setInternalErrorCaption(String internalErrorCaption) {
this.internalErrorCaption = internalErrorCaption; this.internalErrorCaption = internalErrorCaption;
* both caption and message is null, the notification is disabled; * both caption and message is null, the notification is disabled;
* *
* @param internalErrorMessage * @param internalErrorMessage
* the message
* the message
*/ */
public void setInternalErrorMessage(String internalErrorMessage) { public void setInternalErrorMessage(String internalErrorMessage) {
this.internalErrorMessage = internalErrorMessage; this.internalErrorMessage = internalErrorMessage;
* Sets the URL to go to when the client is out-of-sync. * Sets the URL to go to when the client is out-of-sync.
* *
* @param outOfSyncURL * @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) { public void setOutOfSyncURL(String outOfSyncURL) {
this.outOfSyncURL = outOfSyncURL; this.outOfSyncURL = outOfSyncURL;
* current) is loaded directly. * current) is loaded directly.
* *
* @param outOfSyncNotificationEnabled * @param outOfSyncNotificationEnabled
* true = enabled, false = disabled
* true = enabled, false = disabled
*/ */
public void setOutOfSyncNotificationEnabled( public void setOutOfSyncNotificationEnabled(
boolean outOfSyncNotificationEnabled) { boolean outOfSyncNotificationEnabled) {
* both caption and message is null, the notification is disabled; * both caption and message is null, the notification is disabled;
* *
* @param outOfSyncCaption * @param outOfSyncCaption
* the caption
* the caption
*/ */
public void setOutOfSyncCaption(String outOfSyncCaption) { public void setOutOfSyncCaption(String outOfSyncCaption) {
this.outOfSyncCaption = outOfSyncCaption; this.outOfSyncCaption = outOfSyncCaption;
* both caption and message is null, the notification is disabled; * both caption and message is null, the notification is disabled;
* *
* @param outOfSyncMessage * @param outOfSyncMessage
* the message
* the message
*/ */
public void setOutOfSyncMessage(String outOfSyncMessage) { public void setOutOfSyncMessage(String outOfSyncMessage) {
this.outOfSyncMessage = outOfSyncMessage; this.outOfSyncMessage = outOfSyncMessage;


} }


public class ApplicationError implements Terminal.ErrorEvent {

private Throwable throwable;

public ApplicationError(Throwable throwable) {
this.throwable = throwable;
}

public Throwable getThrowable() {
return throwable;
}

}
} }

+ 54
- 50
src/com/itmill/toolkit/data/util/FilesystemContainer.java Dosyayı Görüntüle

FILEITEM_ICON = FileItem.class.getMethod("getIcon", new Class[] {}); FILEITEM_ICON = FileItem.class.getMethod("getIcon", new Class[] {});
FILEITEM_SIZE = FileItem.class.getMethod("getSize", new Class[] {}); FILEITEM_SIZE = FileItem.class.getMethod("getSize", new Class[] {});
} catch (final NoSuchMethodException e) { } catch (final NoSuchMethodException e) {

throw new RuntimeException(
"Internal error finding methods in FilesystemContainer");
} }
} }


private boolean recursive = true; private boolean recursive = true;


/** /**
* Constructs a new <code>FileSystemContainer</code> with the specified
* file as the root of the filesystem. The files are included recursively.
* Constructs a new <code>FileSystemContainer</code> with the specified file
* as the root of the filesystem. The files are included recursively.
* *
* @param root * @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) { public FilesystemContainer(File root) {
if (root != null) { if (root != null) {
} }


/** /**
* Constructs a new <code>FileSystemContainer</code> with the specified
* file as the root of the filesystem. The files are included recursively.
* Constructs a new <code>FileSystemContainer</code> with the specified file
* as the root of the filesystem. The files are included recursively.
* *
* @param root * @param root
* the root file for the new file-system container.
* the root file for the new file-system container.
* @param recursive * @param recursive
* should the container recursively contain subdirectories.
* should the container recursively contain subdirectories.
*/ */
public FilesystemContainer(File root, boolean recursive) { public FilesystemContainer(File root, boolean recursive) {
this(root); this(root);
} }


/** /**
* Constructs a new <code>FileSystemContainer</code> with the specified
* file as the root of the filesystem.
* Constructs a new <code>FileSystemContainer</code> with the specified file
* as the root of the filesystem.
* *
* @param root * @param root
* the root file for the new file-system container.
* the root file for the new file-system container.
* @param extension * @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 * @param recursive
* should the container recursively contain subdirectories.
* should the container recursively contain subdirectories.
*/ */
public FilesystemContainer(File root, String extension, boolean recursive) { public FilesystemContainer(File root, String extension, boolean recursive) {
this(root); this(root);
} }


/** /**
* Constructs a new <code>FileSystemContainer</code> with the specified
* root and recursivity status.
* Constructs a new <code>FileSystemContainer</code> with the specified root
* and recursivity status.
* *
* @param root * @param root
* the root file for the new file-system container.
* the root file for the new file-system container.
* @param filter * @param filter
* the Filename filter to limit the files in container.
* the Filename filter to limit the files in container.
* @param recursive * @param recursive
* should the container recursively contain subdirectories.
* should the container recursively contain subdirectories.
*/ */
public FilesystemContainer(File root, FilenameFilter filter, public FilesystemContainer(File root, FilenameFilter filter,
boolean recursive) { boolean recursive) {
* directory in the <code>FilesystemContainer</code>. * directory in the <code>FilesystemContainer</code>.
* *
* @param root * @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) { public void addRoot(File root) {
if (root != null) { if (root != null) {
* method returns <code>true</code> for directory Items only. * method returns <code>true</code> for directory Items only.
* *
* @param itemId * @param itemId
* the id of the item.
* the id of the item.
* @return <code>true</code> if the specified Item is a directory, * @return <code>true</code> if the specified Item is a directory,
* <code>false</code> otherwise. * <code>false</code> otherwise.
*/ */
* not supported. * not supported.
* *
* @param itemId * @param itemId
* the ID of the item.
* the ID of the item.
* @param areChildrenAllowed * @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 <code>true</code> if the operaton is successful otherwise * @return <code>true</code> if the operaton is successful otherwise
* <code>false</code>. * <code>false</code>.
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if the setChildrenAllowed is not supported.
* if the setChildrenAllowed is not supported.
*/ */
public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed)
throws UnsupportedOperationException { throws UnsupportedOperationException {
} }


/** /**
* Returns <code>false</code> when moving files around in the filesystem
* is not supported.
* Returns <code>false</code> when moving files around in the filesystem is
* not supported.
* *
* @param itemId * @param itemId
* the ID of the item.
* the ID of the item.
* @param newParentId * @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 <code>true</code> if the operation is successful otherwise * @return <code>true</code> if the operation is successful otherwise
* <code>false</code>. * <code>false</code>.
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if the setParent is not supported.
* if the setParent is not supported.
*/ */
public boolean setParent(Object itemId, Object newParentId) public boolean setParent(Object itemId, Object newParentId)
throws UnsupportedOperationException { throws UnsupportedOperationException {
* to the collection. * to the collection.
* *
* @param col * @param col
* the collection where the found items are added
* the collection where the found items are added
* @param f * @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) { private void addItemIds(Collection col, File f) {
File[] l; File[] l;
* not one of those, <code>null</code> is returned. * not one of those, <code>null</code> is returned.
* *
* @param itemId * @param itemId
* the ID of the file whose property is requested.
* the ID of the file whose property is requested.
* @param propertyId * @param propertyId
* the property's ID.
* the property's ID.
* @return the requested property's value, or <code>null</code> * @return the requested property's value, or <code>null</code>
*/ */
public Property getContainerProperty(Object itemId, Object propertyId) { public Property getContainerProperty(Object itemId, Object propertyId) {


/** /**
* Gets the specified property's data type. "Name" is a <code>String</code>, * Gets the specified property's data type. "Name" is a <code>String</code>,
* "Size" is a <code>Long</code>, "Last Modified" is a <code>Date</code>.
* If propertyId is not one of those, <code>null</code> is returned.
* "Size" is a <code>Long</code>, "Last Modified" is a <code>Date</code>. If
* propertyId is not one of those, <code>null</code> is returned.
* *
* @param propertyId * @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 <code>null</code> * @return data type of the requested property, or <code>null</code>
*/ */
public Class getType(Object propertyId) { public Class getType(Object propertyId) {
* directory. * directory.
* *
* @param f * @param f
* the root to start counting from.
* the root to start counting from.
*/ */
private int getFileCounts(File f) { private int getFileCounts(File f) {
File[] l; File[] l;
* Properties got from an Item with the same ID are equal. * Properties got from an Item with the same ID are equal.
* *
* @param obj * @param obj
* an object to compare with this object.
* an object to compare with this object.
* @return <code>true</code> if the given object is the same as this * @return <code>true</code> if the given object is the same as this
* object, <code>false</code> if not * object, <code>false</code> if not
*/ */
* Constructs a new FileExtensionFilter using given extension. * Constructs a new FileExtensionFilter using given extension.
* *
* @param fileExtension * @param fileExtension
* the File extension without the separator (dot).
* the File extension without the separator (dot).
*/ */
public FileExtensionFilter(String fileExtension) { public FileExtensionFilter(String fileExtension) {
filter = "." + fileExtension; filter = "." + fileExtension;
* Sets the file filter used to limit the files in this container. * Sets the file filter used to limit the files in this container.
* *
* @param filter * @param filter
* The filter to set. <code>null</code> disables filtering.
* The filter to set. <code>null</code> disables filtering.
*/ */
public void setFilter(FilenameFilter filter) { public void setFilter(FilenameFilter filter) {
this.filter = filter; this.filter = filter;
* Sets the file filter used to limit the files in this container. * Sets the file filter used to limit the files in this container.
* *
* @param extension * @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) { public void setFilter(String extension) {
filter = new FileExtensionFilter(extension); filter = new FileExtensionFilter(extension);
* </p> * </p>
* *
* @param recursive * @param recursive
* the New value for recursive property.
* the New value for recursive property.
*/ */
public void setRecursive(boolean recursive) { public void setRecursive(boolean recursive) {
this.recursive = recursive; this.recursive = recursive;
/* /*
* (non-Javadoc) * (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, public boolean addContainerProperty(Object propertyId, Class type,
Object defaultValue) throws UnsupportedOperationException { Object defaultValue) throws UnsupportedOperationException {
/* /*
* (non-Javadoc) * (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) public boolean removeContainerProperty(Object propertyId)
throws UnsupportedOperationException { throws UnsupportedOperationException {

+ 13
- 25
src/com/itmill/toolkit/event/EventRouter.java Dosyayı Görüntüle

if (listenerList != null) { if (listenerList != null) {
final Iterator i = listenerList.iterator(); final Iterator i = listenerList.iterator();
while (i.hasNext()) { 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;
} }
} }
} }
if (listenerList != null) { if (listenerList != null) {
final Iterator i = listenerList.iterator(); final Iterator i = listenerList.iterator();
while (i.hasNext()) { 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;
} }
} }
} }
if (listenerList != null) { if (listenerList != null) {
final Iterator i = listenerList.iterator(); final Iterator i = listenerList.iterator();
while (i.hasNext()) { 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;
} }
} }
} }
* the activation method should be called or not. * the activation method should be called or not.
* *
* @param event * @param event
* the Event to be sent to all listeners.
* the Event to be sent to all listeners.
*/ */
public void fireEvent(EventObject event) { public void fireEvent(EventObject event) {
// It is not necessary to send any events if there are no listeners // It is not necessary to send any events if there are no listeners

+ 94
- 104
src/com/itmill/toolkit/event/ListenerMethod.java Dosyayı Görüntüle

private Object[] arguments; private Object[] arguments;


/** /**
* Optional index to <code>arguments</code> that point out which one
* should be replaced with the triggering event object and thus be passed to
* the trigger method.
* Optional index to <code>arguments</code> that point out which one should
* be replaced with the triggering event object and thus be passed to the
* trigger method.
*/ */
private int eventArgumentIndex; private int eventArgumentIndex;


* </p> * </p>
* *
* @param eventType * @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 * @param object
* the object instance that contains the trigger method
* the object instance that contains the trigger method
* @param method * @param method
* the trigger method
* the trigger method
* @param arguments * @param arguments
* the arguments to be passed to the trigger method
* the arguments to be passed to the trigger method
* @param eventArgumentIndex * @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 * @throws java.lang.IllegalArgumentException
* if <code>method</code> is not a member of
* <code>object</code>.
* if <code>method</code> is not a member of <code>object</code>
* .
*/ */
public ListenerMethod(Class eventType, Object object, Method method, public ListenerMethod(Class eventType, Object object, Method method,
Object[] arguments, int eventArgumentIndex) Object[] arguments, int eventArgumentIndex)
* Constructs a new event listener from a trigger method name, it's * Constructs a new event listener from a trigger method name, it's
* arguments and the argument index specifying which one is replaced with * arguments and the argument index specifying which one is replaced with
* the event object. The actual trigger method is reflected from * the event object. The actual trigger method is reflected from
* <code>object</code>, and
* <code>java.lang.IllegalArgumentException</code> is thrown unless
* exactly one match is found.
* <code>object</code>, and <code>java.lang.IllegalArgumentException</code>
* is thrown unless exactly one match is found.
* </p> * </p>
* *
* @param eventType * @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 * @param object
* the object instance that contains the trigger method.
* the object instance that contains the trigger method.
* @param methodName * @param methodName
* the name of the trigger method. If the object does not
* contain the method or it contains more than one matching
* methods <code>java.lang.IllegalArgumentException</code>
* is thrown.
* the name of the trigger method. If the object does not contain
* the method or it contains more than one matching methods
* <code>java.lang.IllegalArgumentException</code> is thrown.
* @param arguments * @param arguments
* the arguments to be passed to the trigger method.
* the arguments to be passed to the trigger method.
* @param eventArgumentIndex * @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 * @throws java.lang.IllegalArgumentException
* unless exactly one match <code>methodName</code> is
* found in <code>object</code>.
* unless exactly one match <code>methodName</code> is found in
* <code>object</code>.
*/ */
public ListenerMethod(Class eventType, Object object, String methodName, public ListenerMethod(Class eventType, Object object, String methodName,
Object[] arguments, int eventArgumentIndex) Object[] arguments, int eventArgumentIndex)
* </p> * </p>
* *
* @param eventType * @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 * @param object
* the object instance that contains the trigger method.
* the object instance that contains the trigger method.
* @param method * @param method
* the trigger method.
* the trigger method.
* @param arguments * @param arguments
* the arguments to be passed to the trigger method.
* the arguments to be passed to the trigger method.
* @throws java.lang.IllegalArgumentException * @throws java.lang.IllegalArgumentException
* if <code>method</code> is not a member of
* <code>object</code>.
* if <code>method</code> is not a member of <code>object</code>
* .
*/ */
public ListenerMethod(Class eventType, Object object, Method method, public ListenerMethod(Class eventType, Object object, Method method,
Object[] arguments) throws java.lang.IllegalArgumentException { Object[] arguments) throws java.lang.IllegalArgumentException {
* *
* <p> * <p>
* The actual trigger method is reflected from <code>object</code>, and * The actual trigger method is reflected from <code>object</code>, and
* <code>java.lang.IllegalArgumentException</code> is thrown unless
* exactly one match is found.
* <code>java.lang.IllegalArgumentException</code> is thrown unless exactly
* one match is found.
* </p> * </p>
* *
* @param eventType * @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 * @param object
* the object instance that contains the trigger method.
* the object instance that contains the trigger method.
* @param methodName * @param methodName
* the name of the trigger method. If the object does not
* contain the method or it contains more than one matching
* methods <code>java.lang.IllegalArgumentException</code>
* is thrown.
* the name of the trigger method. If the object does not contain
* the method or it contains more than one matching methods
* <code>java.lang.IllegalArgumentException</code> is thrown.
* @param arguments * @param arguments
* the arguments to be passed to the trigger method.
* the arguments to be passed to the trigger method.
* @throws java.lang.IllegalArgumentException * @throws java.lang.IllegalArgumentException
* unless exactly one match <code>methodName</code> is
* found in <code>object</code>.
* unless exactly one match <code>methodName</code> is found in
* <code>object</code>.
*/ */
public ListenerMethod(Class eventType, Object object, String methodName, public ListenerMethod(Class eventType, Object object, String methodName,
Object[] arguments) throws java.lang.IllegalArgumentException { Object[] arguments) throws java.lang.IllegalArgumentException {
* </p> * </p>
* *
* @param eventType * @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 * @param object
* the object instance that contains the trigger method.
* the object instance that contains the trigger method.
* @param method * @param method
* the trigger method.
* the trigger method.
* @throws java.lang.IllegalArgumentException * @throws java.lang.IllegalArgumentException
* if <code>method</code> is not a member of
* <code>object</code>.
* if <code>method</code> is not a member of <code>object</code>
* .
*/ */
public ListenerMethod(Class eventType, Object object, Method method) public ListenerMethod(Class eventType, Object object, Method method)
throws java.lang.IllegalArgumentException { throws java.lang.IllegalArgumentException {
* *
* <p> * <p>
* The actual trigger method is reflected from <code>object</code>, and * The actual trigger method is reflected from <code>object</code>, and
* <code>java.lang.IllegalArgumentException</code> is thrown unless
* exactly one match is found.
* <code>java.lang.IllegalArgumentException</code> is thrown unless exactly
* one match is found.
* </p> * </p>
* *
* @param eventType * @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 * @param object
* the object instance that contains the trigger method.
* the object instance that contains the trigger method.
* @param methodName * @param methodName
* the name of the trigger method. If the object does not
* contain the method or it contains more than one matching
* methods <code>java.lang.IllegalArgumentException</code>
* is thrown.
* the name of the trigger method. If the object does not contain
* the method or it contains more than one matching methods
* <code>java.lang.IllegalArgumentException</code> is thrown.
* @throws java.lang.IllegalArgumentException * @throws java.lang.IllegalArgumentException
* unless exactly one match <code>methodName</code> is
* found in <code>object</code>.
* unless exactly one match <code>methodName</code> is found in
* <code>object</code>.
*/ */
public ListenerMethod(Class eventType, Object object, String methodName) public ListenerMethod(Class eventType, Object object, String methodName)
throws java.lang.IllegalArgumentException { throws java.lang.IllegalArgumentException {
* result in the trigger method to be called. * result in the trigger method to be called.
* *
* @param event * @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) { public void receiveEvent(EventObject event) {
// Only send events supported by the method // Only send events supported by the method


} catch (final java.lang.IllegalAccessException e) { } catch (final java.lang.IllegalAccessException e) {
// This should never happen // This should never happen
e.printStackTrace();
throw new java.lang.RuntimeException( throw new java.lang.RuntimeException(
"Internal error - please report: " + e.toString());
"Internal error - please report",e);
} catch (final java.lang.reflect.InvocationTargetException e) { } catch (final java.lang.reflect.InvocationTargetException e) {
// This should never happen // This should never happen
e.printStackTrace();
throw new MethodException("Invocation if method " + method
throw new MethodException("Invocation of method " + method
+ " failed.", e.getTargetException()); + " failed.", e.getTargetException());
} }
} }
* listener. * listener.
* *
* @param target * @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 * @param eventType
* the type to be tested for equality against the type stored
* by this listener.
* @return <code>true</code> if <code>target</code> is the same object
* as the one stored in this object and <code>eventType</code>
* equals the event type stored in this object. *
* the type to be tested for equality against the type stored by
* this listener.
* @return <code>true</code> if <code>target</code> is the same object as
* the one stored in this object and <code>eventType</code> equals
* the event type stored in this object. *
*/ */
public boolean matches(Class eventType, Object target) { public boolean matches(Class eventType, Object target) {
return (target == object) && (eventType.equals(this.eventType)); return (target == object) && (eventType.equals(this.eventType));
* in this listener. * in this listener.
* *
* @param target * @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 * @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 * @param method
* the method to be tested for equality against the method
* stored by this listener.
* @return <code>true</code> if <code>target</code> is the same object
* as the one stored in this object, <code>eventType</code> equals
* with the event type stored in this object and <code>method</code>
* the method to be tested for equality against the method stored
* by this listener.
* @return <code>true</code> if <code>target</code> is the same object as
* the one stored in this object, <code>eventType</code> equals with
* the event type stored in this object and <code>method</code>
* equals with the method stored in this object * equals with the method stored in this object
*/ */
public boolean matches(Class eventType, Object target, Method method) { public boolean matches(Class eventType, Object target, Method method) {


public boolean equals(Object obj) { public boolean equals(Object obj) {


if (this == obj)
if (this == obj) {
return true; return true;
}


// return false if obj is a subclass (do not use instanceof check) // 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; return false;
}


// obj is of same class, test it further // obj is of same class, test it further
ListenerMethod t = (ListenerMethod) obj; ListenerMethod t = (ListenerMethod) obj;
* Retrieves the cause of this throwable or <code>null</code> if the * Retrieves the cause of this throwable or <code>null</code> if the
* cause does not exist or not known. * cause does not exist or not known.
* *
* @return the cause of this throwable or <code>null</code> if the
* cause is nonexistent or unknown.
* @return the cause of this throwable or <code>null</code> if the cause
* is nonexistent or unknown.
* @see java.lang.Throwable#getCause() * @see java.lang.Throwable#getCause()
*/ */
public Throwable getCause() { public Throwable getCause() {

+ 17
- 17
src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java Dosyayı Görüntüle

}); });


} catch (final RequestException e) { } catch (final RequestException e) {
// TODO Better reporting to user
console.error(e.getMessage());
ClientExceptionHandler.displayError(e);
endRequest(); endRequest();
} }
} }
try { try {
console.dirUIDL(change); console.dirUIDL(change);
} catch (final Exception e) { } catch (final Exception e) {
console.log(e.getMessage());
ClientExceptionHandler.displayError(e);
// TODO: dir doesn't work in any browser although it should // TODO: dir doesn't work in any browser although it should
// work (works in hosted mode) // work (works in hosted mode)
// it partially did at some part but now broken. // it partially did at some part but now broken.
paintable.updateFromUIDL(uidl, this); paintable.updateFromUIDL(uidl, this);
} else { } else {
if (!uidl.getTag().equals("window")) { 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 { } else {
view.updateFromUIDL(uidl, this); view.updateFromUIDL(uidl, this);
} }
} }
} catch (final Throwable e) { } catch (final Throwable e) {
e.printStackTrace();
ClientExceptionHandler.displayError(e);
} }
} }


* Returns Paintable element by its id * Returns Paintable element by its id
* *
* @param id * @param id
* Paintable ID
* Paintable ID
*/ */
public Paintable getPaintable(String id) { public Paintable getPaintable(String id) {
return (Paintable) idToPaintable.get(id); return (Paintable) idToPaintable.get(id);
* when needed. * when needed.
* *
* @param component * @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 * @param uidl
* UIDL to be painted
* UIDL to be painted
* @param manageCaption * @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 * @return Returns true iff no further painting is needed by caller
*/ */
* parent. * parent.
* *
* @param uidl * @param uidl
* UIDL to create Paintable from.
* UIDL to create Paintable from.
* @return Either existing or new Paintable corresponding to UIDL. * @return Either existing or new Paintable corresponding to UIDL.
*/ */
public Paintable getPaintable(UIDL uidl) { public Paintable getPaintable(UIDL uidl) {
* to browser due URI's in UIDL may contain custom protocols like theme://. * to browser due URI's in UIDL may contain custom protocols like theme://.
* *
* @param toolkitUri * @param toolkitUri
* toolkit URI from uidl
* toolkit URI from uidl
* @return translated URI ready for browser * @return translated URI ready for browser
*/ */
public String translateToolkitUri(String toolkitUri) { public String translateToolkitUri(String toolkitUri) {
* Adds PNG-fix conditionally (only for IE6) to the specified IMG -element. * Adds PNG-fix conditionally (only for IE6) to the specified IMG -element.
* *
* @param el * @param el
* the IMG element to fix
* the IMG element to fix
*/ */
public void addPngFix(Element el) { public void addPngFix(Element el) {
BrowserInfo b = BrowserInfo.get(); BrowserInfo b = BrowserInfo.get();

+ 1
- 2
src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java Dosyayı Görüntüle

ieVersion = Float.parseFloat(ieVersionString); ieVersion = Float.parseFloat(ieVersionString);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
ApplicationConnection.getConsole().error(e.getMessage());
ClientExceptionHandler.displayError(e);
} }
} }



+ 27
- 0
src/com/itmill/toolkit/terminal/gwt/client/ClientExceptionHandler.java Dosyayı Görüntüle

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);
}
}

+ 10
- 19
src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java Dosyayı Görüntüle

* Creates a new date time service with a given locale. * Creates a new date time service with a given locale.
* *
* @param locale * @param locale
* e.g. fi, en etc.
* e.g. fi, en etc.
* @throws LocaleNotLoadedException * @throws LocaleNotLoadedException
*/ */
public DateTimeService(String locale) throws LocaleNotLoadedException { public DateTimeService(String locale) throws LocaleNotLoadedException {
try { try {
return LocaleService.getMonthNames(currentLocale)[month]; return LocaleService.getMonthNames(currentLocale)[month];
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
return null; return null;
} }
try { try {
return LocaleService.getShortMonthNames(currentLocale)[month]; return LocaleService.getShortMonthNames(currentLocale)[month];
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
return null; return null;
} }
try { try {
return LocaleService.getDayNames(currentLocale)[day]; return LocaleService.getDayNames(currentLocale)[day];
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
return null; return null;
} }
try { try {
return LocaleService.getShortDayNames(currentLocale)[day]; return LocaleService.getShortDayNames(currentLocale)[day];
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
return null; return null;
} }
try { try {
return LocaleService.getFirstDayOfWeek(currentLocale); return LocaleService.getFirstDayOfWeek(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
return 0; return 0;
} }
try { try {
return LocaleService.isTwelveHourClock(currentLocale); return LocaleService.isTwelveHourClock(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
return false; return false;
} }
try { try {
return LocaleService.getClockDelimiter(currentLocale); return LocaleService.getClockDelimiter(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
return ":"; return ":";
} }
try { try {
return LocaleService.getAmPmStrings(currentLocale); return LocaleService.getAmPmStrings(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
final String[] temp = new String[2]; final String[] temp = new String[2];
temp[0] = "AM"; temp[0] = "AM";
firstDay = LocaleService.getFirstDayOfWeek(currentLocale); firstDay = LocaleService.getFirstDayOfWeek(currentLocale);
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
firstDay = 0; firstDay = 0;
// TODO redirect to console
System.out.println(e + ":" + e.getMessage());
ClientExceptionHandler.displayError(e);
} }
int start = dateForFirstOfThisMonth.getDay() - firstDay; int start = dateForFirstOfThisMonth.getDay() - firstDay;
if (start < 0) { if (start < 0) {

+ 1
- 1
src/com/itmill/toolkit/terminal/gwt/client/UIDL.java Dosyayı Görüntüle

item.addItem(tmp); item.addItem(tmp);
} }
} catch (final Exception e) { } catch (final Exception e) {
// Ingonered, no variables
// Ignored, no variables
} }


final Iterator i = getChildIterator(); final Iterator i = getChildIterator();

+ 5
- 4
src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java Dosyayı Görüntüle

import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; 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.DateTimeService;
import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException; import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException;
import com.itmill.toolkit.terminal.gwt.client.Paintable; import com.itmill.toolkit.terminal.gwt.client.Paintable;
currentLocale = locale; currentLocale = locale;
} catch (final LocaleNotLoadedException e) { } catch (final LocaleNotLoadedException e) {
currentLocale = dts.getLocale(); 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);
} }
} }

+ 11
- 11
src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java Dosyayı Görüntüle

setStyleName(CLASSNAME); setStyleName(CLASSNAME);
popup.setStylePrimaryName(CLASSNAME + "-popup"); popup.setStylePrimaryName(CLASSNAME + "-popup");


this.setHTML("PopupPanel");
setHTML("PopupPanel");
popup.setWidget(loading); popup.setWidget(loading);


// When we click to open the popup... // When we click to open the popup...
this.addClickListener(new ClickListener() {
addClickListener(new ClickListener() {
public void onClick(Widget sender) { public void onClick(Widget sender) {
updateState(true); updateState(true);
} }
updateWindowSize(); updateWindowSize();


hostPopupVisible = uidl.getBooleanAttribute("popupVisible"); hostPopupVisible = uidl.getBooleanAttribute("popupVisible");
this.setHTML(uidl.getStringAttribute("html"));
setHTML(uidl.getStringAttribute("html"));


if (uidl.hasAttribute("description")) { 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 // Render the popup if visible and show it. The component inside can
popup.hide(); popup.hide();


if (popup != null) { if (popup != null) {
client.unregisterPaintable((Paintable) popup);
client.unregisterPaintable(popup);
} }
popup = (CustomPopup) newComponent; popup = (CustomPopup) newComponent;


} }


public static native void nativeBlur(Element e) /*-{ public static native void nativeBlur(Element e) /*-{
if(e.focus) {
e.blur();
}
}-*/;
if(e.focus) {
e.blur();
}
}-*/;


private class CustomPopup extends ToolkitOverlay implements Container { private class CustomPopup extends ToolkitOverlay implements Container {




public void replaceChildComponent(Widget oldComponent, public void replaceChildComponent(Widget oldComponent,
Widget newComponent) { Widget newComponent) {
System.out.println("CustomPopup replacechildcomponent");
// System.out.println("CustomPopup replacechildcomponent");
if (oldComponent != null) { if (oldComponent != null) {
client.unregisterPaintable((Paintable) oldComponent); client.unregisterPaintable((Paintable) oldComponent);
} }


popupComponentWidget = (Widget) newComponent;
popupComponentWidget = newComponent;


setWidget(popupComponentWidget); setWidget(popupComponentWidget);
} }

+ 4
- 3
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java Dosyayı Görüntüle

import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; 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.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.Focusable; import com.itmill.toolkit.terminal.gwt.client.Focusable;
import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException; import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException;
formatStr = frmString; formatStr = frmString;
} catch (LocaleNotLoadedException e) { } catch (LocaleNotLoadedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ClientExceptionHandler.displayError(e);
} }
} }
} }
// remove possibly added invalid value indication // remove possibly added invalid value indication
removeStyleName(PARSE_ERROR_CLASSNAME); removeStyleName(PARSE_ERROR_CLASSNAME);
} catch (final Exception e) { } catch (final Exception e) {
ApplicationConnection.getConsole().log(e.getMessage());
ClientExceptionHandler.displayError(e.getMessage());
addStyleName(PARSE_ERROR_CLASSNAME); addStyleName(PARSE_ERROR_CLASSNAME);
client.updateVariable(id, "lastInvalidDateString", text client.updateVariable(id, "lastInvalidDateString", text
.getText(), false); .getText(), false);

+ 152
- 166
src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java Dosyayı Görüntüle

* is being placed into service. * is being placed into service.
* *
* @param servletConfig * @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 * @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) public void init(javax.servlet.ServletConfig servletConfig)
throws javax.servlet.ServletException { throws javax.servlet.ServletException {
classLoader = (ClassLoader) c classLoader = (ClassLoader) c
.newInstance(new Object[] { getClass().getClassLoader() }); .newInstance(new Object[] { getClass().getClassLoader() });
} catch (final Exception e) { } 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; this.classLoader = classLoader;
* Gets an application or system property value. * Gets an application or system property value.
* *
* @param parameterName * @param parameterName
* the Name or the parameter.
* the Name or the parameter.
* @param defaultValue * @param defaultValue
* the Default to be used.
* the Default to be used.
* @return String value or default if not found * @return String value or default if not found
*/ */
private String getApplicationOrSystemProperty(String parameterName, private String getApplicationOrSystemProperty(String parameterName,
* dispatches them. * dispatches them.
* *
* @param request * @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 * @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 * @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 * @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, protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException { HttpServletResponse response) throws ServletException, IOException {


} catch (final SessionExpired e) { } catch (final SessionExpired e) {
// Session has expired, notify user // 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) { } catch (final Throwable e) {
e.printStackTrace();
// if this was an UIDL request, response UIDL back to client // if this was an UIDL request, response UIDL back to client
if (UIDLrequest) { if (UIDLrequest) {
Application.SystemMessages ci = getSystemMessages(); Application.SystemMessages ci = getSystemMessages();
return (Application.SystemMessages) m.invoke(null, null); return (Application.SystemMessages) m.invoke(null, null);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// This should never happen // This should never happen
e.printStackTrace();
throw new SystemMessageException(e);
} catch (SecurityException 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) { } catch (NoSuchMethodException e) {
// This is completely ok and should be silently ignored // This is completely ok and should be silently ignored
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// This should never happen // This should never happen
e.printStackTrace();
throw new SystemMessageException(e);
} catch (IllegalAccessException 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) { } catch (InvocationTargetException e) {
// This should never happen // This should never happen
e.printStackTrace();
throw new SystemMessageException(e);
} }
return Application.getSystemMessages(); return Application.getSystemMessages();
} }
InputStream is = sc.getResourceAsStream(filename); InputStream is = sc.getResourceAsStream(filename);
if (is == null) { if (is == null) {
// try if requested file is found from classloader // 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) { if (is == null) {
// cannot serve requested file // cannot serve requested file
System.err System.err
* no knowledge of what application client refers to. * no knowledge of what application client refers to.
* *
* @param request * @param request
* the HTTP request instance.
* the HTTP request instance.
* @param response * @param response
* the HTTP response to write to.
* the HTTP response to write to.
* @param caption * @param caption
* for the notification
* for the notification
* @param message * @param message
* for the notification
* for the notification
* @param url * @param url
* url to load after message, null for current page
* url to load after message, null for current page
* @throws IOException * @throws IOException
* if the writing failed due to input/output error.
* if the writing failed due to input/output error.
*/ */
void criticalNotification(HttpServletRequest request, void criticalNotification(HttpServletRequest request,
HttpServletResponse response, String caption, String message, HttpServletResponse response, String caption, String message,
* @param request * @param request
* @return string array consisting of application url first and then * @return string array consisting of application url first and then
* widgetset url. * 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 // don't use server and port in uri. It may cause problems with some
// virtual server configurations which lose the server name // virtual server configurations which lose the server name
String appUrl = null; String appUrl = null;
appUrl = URIparts[1]; appUrl = URIparts[1];
} else { } else {
String[] urlParts; 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);
} }


} }
/** /**
* *
* @param request * @param request
* the HTTP request.
* the HTTP request.
* @param response * @param response
* the HTTP response to write to.
* the HTTP response to write to.
* @param out * @param out
* @param unhandledParameters * @param unhandledParameters
* @param window * @param window
* @param terminalType * @param terminalType
* @param theme * @param theme
* @throws IOException * @throws IOException
* if the writing failed due to input/output error.
* if the writing failed due to input/output error.
* @throws MalformedURLException * @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, private void writeAjaxPage(HttpServletRequest request,
HttpServletResponse response, Window window, String themeName, HttpServletResponse response, Window window, String themeName,
try { try {
widgetset = (String) reqParam; widgetset = (String) reqParam;
} catch (Exception e) { } 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) { if (widgetset == null) {
widgetset = applicationProperties.getProperty(PARAMETER_WIDGETSET); widgetset = applicationProperties.getProperty(PARAMETER_WIDGETSET);
* it is sent to the client. * it is sent to the client.
* *
* @param application * @param application
* the Application owning the URI.
* the Application owning the URI.
* @param request * @param request
* the HTTP request instance.
* the HTTP request instance.
* @param response * @param response
* the HTTP response to write to.
* @return boolean <code>true</code> if the request was handled and
* further processing should be suppressed, <code>false</code>
* otherwise.
* the HTTP response to write to.
* @return boolean <code>true</code> if the request was handled and further
* processing should be suppressed, <code>false</code> otherwise.
* @see com.itmill.toolkit.terminal.URIHandler * @see com.itmill.toolkit.terminal.URIHandler
*/ */
private DownloadStream handleURI(Application application, private DownloadStream handleURI(Application application,
* it is sent to the client. * it is sent to the client.
* *
* @param stream * @param stream
* the download stream.
* the download stream.
* *
* @param request * @param request
* the HTTP request instance.
* the HTTP request instance.
* @param response * @param response
* the HTTP response to write to.
* the HTTP response to write to.
* @throws IOException
* *
* @see com.itmill.toolkit.terminal.URIHandler * @see com.itmill.toolkit.terminal.URIHandler
*/ */
private void handleDownload(DownloadStream stream, private void handleDownload(DownloadStream stream,
HttpServletRequest request, HttpServletResponse response) {
HttpServletRequest request, HttpServletResponse response)
throws IOException {


if (stream.getParameter("Location") != null) { if (stream.getParameter("Location") != null) {
response.setStatus(HttpServletResponse.SC_FOUND); response.setStatus(HttpServletResponse.SC_FOUND);
final byte[] buffer = new byte[bufferSize]; final byte[] buffer = new byte[bufferSize];
int bytesRead = 0; 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();


} }


* are provided by the WebAdapterServlet. * are provided by the WebAdapterServlet.
* *
* @param request * @param request
* the HTTP request.
* the HTTP request.
* @param response * @param response
* the HTTP response.
* @return boolean <code>true</code> if the request was handled and
* further processing should be suppressed, <code>false</code>
* otherwise.
* the HTTP response.
* @return boolean <code>true</code> if the request was handled and further
* processing should be suppressed, <code>false</code> otherwise.
* @throws ServletException * @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, private boolean handleResourceRequest(HttpServletRequest request,
HttpServletResponse response, String themeName) HttpServletResponse response, String themeName)
data = getServletContext().getResourceAsStream( data = getServletContext().getResourceAsStream(
THEME_DIRECTORY_PATH + themeName + "/" + resourceId); THEME_DIRECTORY_PATH + themeName + "/" + resourceId);
} catch (final Exception e) { } catch (final Exception e) {
// FIXME: Handle exception
e.printStackTrace(); e.printStackTrace();
data = null; data = null;
} }
} }


} catch (final java.io.IOException e) { } catch (final java.io.IOException e) {
// FIXME: Handle exception
System.err.println("Resource transfer failed: " System.err.println("Resource transfer failed: "
+ request.getRequestURI() + ". (" + e.getMessage() + ")"); + request.getRequestURI() + ". (" + e.getMessage() + ")");
} }
* Gets the current application URL from request. * Gets the current application URL from request.
* *
* @param request * @param request
* the HTTP request.
* the HTTP request.
* @throws MalformedURLException * @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) private URL getApplicationUrl(HttpServletRequest request)
throws MalformedURLException { throws MalformedURLException {


URL applicationUrl; 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; return applicationUrl;
} }
* instance for given request based on the requested URL. * instance for given request based on the requested URL.
* *
* @param request * @param request
* the HTTP request.
* the HTTP request.
* @param response * @param response
* @return Application instance, or null if the URL does not map to valid * @return Application instance, or null if the URL does not map to valid
* application. * application.
* @throws MalformedURLException * @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 SAXException
* @throws IllegalAccessException * @throws IllegalAccessException
* @throws InstantiationException * @throws InstantiationException
* Creates new application for given request. * Creates new application for given request.
* *
* @param request * @param request
* the HTTP request.
* the HTTP request.
* @param response * @param response
* @return Application instance, or null if the URL does not map to valid * @return Application instance, or null if the URL does not map to valid
* application. * application.
* @throws MalformedURLException * @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 SAXException
* @throws IllegalAccessException * @throws IllegalAccessException
* @throws InstantiationException * @throws InstantiationException
return application; return application;


} catch (final IllegalAccessException e) { } catch (final IllegalAccessException e) {
System.err.println("Illegal access to application class "
+ applicationClass.getName());
throw e; throw e;
} catch (final InstantiationException e) { } catch (final InstantiationException e) {
System.err.println("Failed to instantiate application class: "
+ applicationClass.getName());
throw e; throw e;
} }
} }
* Ends the application. * Ends the application.
* *
* @param request * @param request
* the HTTP request.
* the HTTP request.
* @param response * @param response
* the HTTP response to write to.
* the HTTP response to write to.
* @param application * @param application
* the application to end.
* the application to end.
* @throws IOException * @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, private void endApplication(HttpServletRequest request,
HttpServletResponse response, Application application) HttpServletResponse response, Application application)
* application based on the requested URI. * application based on the requested URI.
* *
* @param request * @param request
* the HTTP Request.
* the HTTP Request.
* @param application * @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. * @return Window matching the given URI or null if not found.
* @throws ServletException * @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, private Window getApplicationWindow(HttpServletRequest request,
Application application) throws ServletException { Application application) throws ServletException {
* Gets relative location of a theme resource. * Gets relative location of a theme resource.
* *
* @param theme * @param theme
* the Theme name.
* the Theme name.
* @param resource * @param resource
* the Theme resource.
* the Theme resource.
* @return External URI specifying the resource * @return External URI specifying the resource
*/ */
public String getResourceLocation(String theme, ThemeResource resource) { public String getResourceLocation(String theme, ThemeResource resource) {
* when debug mode is enabled. * when debug mode is enabled.
* *
* @param parameters * @param parameters
* @return <code>true</code> if the web adapter is in debug mode.
* otherwise <code>false</code>.
* @return <code>true</code> if the web adapter is in debug mode. otherwise
* <code>false</code>.
*/ */
public boolean isDebugMode(Map parameters) { public boolean isDebugMode(Map parameters) {
if (parameters != null) { if (parameters != null) {
* *
* @param servletContext * @param servletContext
* @param path * @param path
* the resource path.
* the resource path.
* @return the resource path. * @return the resource path.
*/ */
protected static String getResourcePath(ServletContext servletContext, protected static String getResourcePath(ServletContext servletContext,
final URL url = servletContext.getResource(path); final URL url = servletContext.getResource(path);
resultPath = url.getFile(); resultPath = url.getFile();
} catch (final Exception e) { } catch (final Exception e) {
// FIXME: Handle exception
e.printStackTrace(); e.printStackTrace();
} }
} }

+ 23
- 17
src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java Dosyayı Görüntüle

* @param request * @param request
* @param response * @param response
* @throws IOException * @throws IOException
* @throws FileUploadException
*/ */
public void handleFileUpload(HttpServletRequest request, public void handleFileUpload(HttpServletRequest request,
HttpServletResponse response) throws IOException {
HttpServletResponse response) throws IOException,
FileUploadException {
// Create a new file upload handler // Create a new file upload handler
final ServletFileUpload upload = new ServletFileUpload(); final ServletFileUpload upload = new ServletFileUpload();


} }
} }
} catch (final FileUploadException e) { } catch (final FileUploadException e) {
e.printStackTrace();
throw e;
} }


// Send short response to acknowledge client that request was done // Send short response to acknowledge client that request was done
"getSystemMessages", null); "getSystemMessages", null);
ci = (Application.SystemMessages) m.invoke(null, null); ci = (Application.SystemMessages) m.invoke(null, null);
} catch (Exception e2) { } catch (Exception e2) {
// FIXME: Handle exception
// Not critical, but something is still wrong; print // Not critical, but something is still wrong; print
// stacktrace // stacktrace
e2.printStackTrace(); e2.printStackTrace();
+ ApplicationServlet.THEME_DIRECTORY_PATH + ApplicationServlet.THEME_DIRECTORY_PATH
+ themeName + "/" + resource); + themeName + "/" + resource);
} catch (final Exception e) { } catch (final Exception e) {
// FIXME: Handle exception
e.printStackTrace(); e.printStackTrace();
} }
if (is != null) { if (is != null) {
} }
r.close(); r.close();
} catch (final java.io.IOException e) { } catch (final java.io.IOException e) {
// FIXME: Handle exception
System.err.println("Resource transfer failed: " System.err.println("Resource transfer failed: "
+ request.getRequestURI() + ". (" + request.getRequestURI() + ". ("
+ e.getMessage() + ")"); + e.getMessage() + ")");
+ JsonPaintTarget.escapeJSON(layout.toString()) + JsonPaintTarget.escapeJSON(layout.toString())
+ "\""); + "\"");
} else { } else {
// FIXME: Handle exception
System.err.println("CustomLayout " + "/" System.err.println("CustomLayout " + "/"
+ ApplicationServlet.THEME_DIRECTORY_PATH + ApplicationServlet.THEME_DIRECTORY_PATH
+ themeName + "/" + resource + " not found!"); + themeName + "/" + resource + " not found!");
/* /*
* Time formatting (24 or 12 hour clock and AM/PM suffixes) * 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; final boolean twelve_hour_clock = timeformat.indexOf("a") > -1;
// TODO there are other possibilities as well, like 'h' in french // TODO there are other possibilities as well, like 'h' in french
// (ignore them, too complicated) // (ignore them, too complicated)
* application based on the requested URI. * application based on the requested URI.
* *
* @param request * @param request
* the HTTP Request.
* the HTTP Request.
* @param application * @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. * @return Window mathing the given URI or null if not found.
* @throws ServletException * @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, private Window getApplicationWindow(HttpServletRequest request,
Application application) throws ServletException { Application application) throws ServletException {
* Ends the Application. * Ends the Application.
* *
* @param request * @param request
* the HTTP request instance.
* the HTTP request instance.
* @param response * @param response
* the HTTP response to write to.
* the HTTP response to write to.
* @param application * @param application
* the Application to end.
* the Application to end.
* @throws IOException * @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, private void endApplication(HttpServletRequest request,
HttpServletResponse response, Application application) HttpServletResponse response, Application application)


/** /**
* @param w * @param w
* root window for which dirty components is to be fetched
* root window for which dirty components is to be fetched
* @return * @return
*/ */
private ArrayList getDirtyComponents(Window w) { private ArrayList getDirtyComponents(Window w) {

+ 57
- 0
src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java Dosyayı Görüntüle

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 <code>SystemMessageException</code> with the specified
* detail message.
*
* @param msg
* the detail message.
*/
public SystemMessageException(String msg) {
super(msg);
}
/**
* Constructs a new <code>SystemMessageException</code> 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 <code>SystemMessageException</code> 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;
}
}

+ 6
- 4
src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java Dosyayı Görüntüle



import com.itmill.toolkit.Application; import com.itmill.toolkit.Application;
import com.itmill.toolkit.service.ApplicationContext; import com.itmill.toolkit.service.ApplicationContext;
import com.itmill.toolkit.terminal.gwt.client.ClientExceptionHandler;


/** /**
* Web application context for the IT Mill Toolkit applications. * Web application context for the IT Mill Toolkit applications.
* Gets the application context for HttpSession. * Gets the application context for HttpSession.
* *
* @param session * @param session
* the HTTP session.
* the HTTP session.
* @return the application context for HttpSession. * @return the application context for HttpSession.
*/ */
static public WebApplicationContext getApplicationContext( static public WebApplicationContext getApplicationContext(
* boolean value as this object. * boolean value as this object.
* *
* @param obj * @param obj
* the object to compare with.
* the object to compare with.
* @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#equals(java.lang.Object)
*/ */
public boolean equals(Object obj) { public boolean equals(Object obj) {
* *
* @param application * @param application
* @param request * @param request
* the HTTP request.
* the HTTP request.
*/ */
protected void startTransaction(Application application, protected void startTransaction(Application application,
HttpServletRequest request) { HttpServletRequest request) {
* *
* @param application * @param application
* @param request * @param request
* the HTTP request.
* the HTTP request.
*/ */
protected void endTransaction(Application application, protected void endTransaction(Application application,
HttpServletRequest request) { HttpServletRequest request) {
// thread doing HTTP socket write and another thread trying to // thread doing HTTP socket write and another thread trying to
// remove same application here. Possible if you got e.g. session // remove same application here. Possible if you got e.g. session
// lifetime 1 min but socket write may take longer than 1 min. // lifetime 1 min but socket write may take longer than 1 min.
// FIXME: Handle exception
System.err.println("Could not remove application, leaking memory."); System.err.println("Could not remove application, leaking memory.");
e.printStackTrace(); e.printStackTrace();
} }

+ 4
- 4
src/com/itmill/toolkit/ui/AbstractComponent.java Dosyayı Görüntüle

* actual enabled state of the component. * actual enabled state of the component.
* *
* @param disabledByContainer * @param disabledByContainer
* Should the component be disabled
* Should the component be disabled
*/ */
public void setDisabledByContainer(boolean disabledByContainer) { public void setDisabledByContainer(boolean disabledByContainer) {
if (disabledByContainer != this.disabledByContainer) { if (disabledByContainer != this.disabledByContainer) {
new Class[] { Component.Event.class }); new Class[] { Component.Event.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
e.printStackTrace();
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error finding methods in AbstractComponent");
} }
} }


* handle the exception. * handle the exception.
* *
* @param errorHandler * @param errorHandler
* AbstractField specific error handler
* AbstractField specific error handler
*/ */
public void setErrorHandler(ComponentErrorHandler errorHandler) { public void setErrorHandler(ComponentErrorHandler errorHandler) {
this.errorHandler = errorHandler; this.errorHandler = errorHandler;

+ 5
- 4
src/com/itmill/toolkit/ui/AbstractComponentContainer.java Dosyayı Görüntüle

} }
} }


/* Events ************************************************************ */
/* Events */


private static final Method COMPONENT_ATTACHED_METHOD; private static final Method COMPONENT_ATTACHED_METHOD;


new Class[] { ComponentDetachEvent.class }); new Class[] { ComponentDetachEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error finding methods in AbstractComponentContainer");
} }
} }


* container. * container.
* *
* @param component * @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) { protected void fireComponentAttachEvent(Component component) {
fireEvent(new ComponentAttachEvent(this, component)); fireEvent(new ComponentAttachEvent(this, component));
* container. * container.
* *
* @param component * @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) { protected void fireComponentDetachEvent(Component component) {
fireEvent(new ComponentDetachEvent(this, component)); fireEvent(new ComponentDetachEvent(this, component));

+ 24
- 22
src/com/itmill/toolkit/ui/AbstractField.java Dosyayı Görüntüle

public abstract class AbstractField extends AbstractComponent implements Field, public abstract class AbstractField extends AbstractComponent implements Field,
Property.ReadOnlyStatusChangeNotifier { Property.ReadOnlyStatusChangeNotifier {


/* Private members ************************************************* */
/* Private members */


private boolean delayedFocus; private boolean delayedFocus;


*/ */
private boolean validationVisible = true; private boolean validationVisible = true;


/* Component basics ************************************************ */
/* Component basics */


/* /*
* Paints the field. Don't add a JavaDoc comment here, we use the default * Paints the field. Don't add a JavaDoc comment here, we use the default
} }
} }


/* Property interface implementation ******************************* */
/* Property interface implementation */


/** /**
* Returns the value of the Property in human readable textual format. * Returns the value of the Property in human readable textual format.
* Sets the value of the field. * Sets the value of the field.
* *
* @param newValue * @param newValue
* the New value of the field.
* the New value of the field.
* @throws Property.ReadOnlyException * @throws Property.ReadOnlyException
* @throws Property.ConversionException * @throws Property.ConversionException
*/ */
* Sets the value of the field. * Sets the value of the field.
* *
* @param newValue * @param newValue
* the New value of the field.
* the New value of the field.
* @param repaintIsNotNeeded * @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.ReadOnlyException
* @throws Property.ConversionException * @throws Property.ConversionException
*/ */
} }
} }


/* External data source ******************************************** */
/* External data source */


/** /**
* Gets the current data source of the field, if any. * Gets the current data source of the field, if any.
* </p> * </p>
* *
* @param newDataSource * @param newDataSource
* the new data source Property.
* the new data source Property.
*/ */
public void setPropertyDataSource(Property newDataSource) { public void setPropertyDataSource(Property newDataSource) {


} }
} }


/* Validation ****************************************************** */
/* Validation */


/** /**
* Adds a new validator for the field's value. All validators added to a * Adds a new validator for the field's value. All validators added to a
* field are checked each time the its value changes. * field are checked each time the its value changes.
* *
* @param validator * @param validator
* the new validator to be added.
* the new validator to be added.
*/ */
public void addValidator(Validator validator) { public void addValidator(Validator validator) {
if (validators == null) { if (validators == null) {
* Removes the validator from the field. * Removes the validator from the field.
* *
* @param validator * @param validator
* the validator to remove.
* the validator to remove.
*/ */
public void removeValidator(Validator validator) { public void removeValidator(Validator validator) {
if (validators != null) { if (validators != null) {


} }


/* Value change events ****************************************** */
/* Value change events */


private static final Method VALUE_CHANGE_METHOD; private static final Method VALUE_CHANGE_METHOD;


new Class[] { Property.ValueChangeEvent.class }); new Class[] { Property.ValueChangeEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error finding methods in AbstractField");
} }
} }


} }
} }


/* Read-only status change events *************************************** */
/* Read-only status change events */


private static final Method READ_ONLY_STATUS_CHANGE_METHOD; private static final Method READ_ONLY_STATUS_CHANGE_METHOD;


new Class[] { Property.ReadOnlyStatusChangeEvent.class }); new Class[] { Property.ReadOnlyStatusChangeEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error finding methods in AbstractField");
} }
} }


* New instance of text change event. * New instance of text change event.
* *
* @param source * @param source
* the Source of the event.
* the Source of the event.
*/ */
public ReadOnlyStatusChangeEvent(AbstractField source) { public ReadOnlyStatusChangeEvent(AbstractField source) {
super(source); super(source);
* forwards. * forwards.
* *
* @param event * @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) { public void valueChange(Property.ValueChangeEvent event) {
if (isReadThrough() || !isModified()) { if (isReadThrough() || !isModified()) {
* </p> * </p>
* *
* @param propertyType * @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) { public static AbstractField constructField(Class propertyType) {


* variables. * variables.
* *
* @param newValue * @param newValue
* the new value to be set.
* the new value to be set.
*/ */
protected void setInternalValue(Object newValue) { protected void setInternalValue(Object newValue) {
value = newValue; value = newValue;
* field isEmpty() regardless of any attached validators. * field isEmpty() regardless of any attached validators.
* *
* @param required * @param required
* Is the field required.
* Is the field required.
*/ */
public void setRequired(boolean required) { public void setRequired(boolean required) {
this.required = required; this.required = required;
* validation in their own code. * validation in their own code.
* *
* @param validateAutomatically * @param validateAutomatically
* True, if automatic validation is enabled.
* True, if automatic validation is enabled.
*/ */
public void setValidationVisible(boolean validateAutomatically) { public void setValidationVisible(boolean validateAutomatically) {
if (validationVisible != validateAutomatically) { if (validationVisible != validateAutomatically) {

+ 81
- 85
src/com/itmill/toolkit/ui/AbstractSelect.java Dosyayı Görüntüle

Container.ItemSetChangeListener { Container.ItemSetChangeListener {


/** /**
* Item caption mode: Item's ID's <code>String</code> representation is
* used as caption.
* Item caption mode: Item's ID's <code>String</code> representation is used
* as caption.
*/ */
public static final int ITEM_CAPTION_MODE_ID = 0; public static final int ITEM_CAPTION_MODE_ID = 0;
/** /**
* entered value. The value is matched to the item caption. * entered value. The value is matched to the item caption.
* <code>FILTERINGMODE_OFF</code> (0) turns the filtering off. * <code>FILTERINGMODE_OFF</code> (0) turns the filtering off.
* <code>FILTERINGMODE_STARTSWITH</code> (1) matches from the start of the * <code>FILTERINGMODE_STARTSWITH</code> (1) matches from the start of the
* caption. <code>FILTERINGMODE_CONTAINS</code> (1) matches anywhere in
* the caption.
* caption. <code>FILTERINGMODE_CONTAINS</code> (1) matches anywhere in the
* caption.
*/ */
public interface Filtering { public interface Filtering {
public static final int FILTERINGMODE_OFF = 0; public static final int FILTERINGMODE_OFF = 0;
* Sets the option filtering mode. * Sets the option filtering mode.
* *
* @param filteringMode * @param filteringMode
* the filtering mode to use
* the filtering mode to use
*/ */
public void setFilteringMode(int filteringMode); public void setFilteringMode(int filteringMode);


// Caption (Item / Property) change listeners // Caption (Item / Property) change listeners
CaptionChangeListener captionChangeListener; CaptionChangeListener captionChangeListener;


/* Constructors ********************************************************* */
/* Constructors */


/** /**
* Creates an empty Select. The caption is not used. * Creates an empty Select. The caption is not used.
* Creates a new select that is connected to a data-source. * Creates a new select that is connected to a data-source.
* *
* @param caption * @param caption
* the Caption of the component.
* the Caption of the component.
* @param dataSource * @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) { public AbstractSelect(String caption, Container dataSource) {
setCaption(caption); setCaption(caption);
* Creates a new select that is filled from a collection of option values. * Creates a new select that is filled from a collection of option values.
* *
* @param caption * @param caption
* the Caption of this field.
* the Caption of this field.
* @param options * @param options
* the Collection containing the options.
* the Collection containing the options.
*/ */
public AbstractSelect(String caption, Collection options) { public AbstractSelect(String caption, Collection options) {


setContainerDataSource(c); setContainerDataSource(c);
} }


/* Component methods **************************************************** */
/* Component methods */


/** /**
* Paints the content of this component. * Paints the content of this component.
* *
* @param target * @param target
* the Paint Event.
* the Paint Event.
* @throws PaintException * @throws PaintException
* if the paint operation failed.
* if the paint operation failed.
*/ */
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {


getItemCaptionPropertyId()).setValue( getItemCaptionPropertyId()).setValue(
newItemCaption); newItemCaption);
} catch (final Property.ConversionException ignored) { } 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()) { if (isMultiSelect()) {
return null; return null;
} }


/* Property methods ***************************************************** */
/* Property methods */


/** /**
* Returns the type of the property. <code>getValue</code> and * Returns the type of the property. <code>getValue</code> and
* <code>setValue</code> methods must be compatible with this type: one
* can safely cast <code>getValue</code> to given type and pass any
* variable assignable to this type as a parameter to <code>setValue</code>.
* <code>setValue</code> methods must be compatible with this type: one can
* safely cast <code>getValue</code> to given type and pass any variable
* assignable to this type as a parameter to <code>setValue</code>.
* *
* @return the Type of the property. * @return the Type of the property.
*/ */
* </p> * </p>
* *
* @param newValue * @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) * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object)
*/ */
public void setValue(Object newValue) throws Property.ReadOnlyException, public void setValue(Object newValue) throws Property.ReadOnlyException,
* </p> * </p>
* *
* @param newValue * @param newValue
* the New selected item or collection of selected items.
* the New selected item or collection of selected items.
* @param repaintIsNotNeeded * @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, * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object,
* java.lang.Boolean) * java.lang.Boolean)
*/ */
} }
} }


/* Container methods **************************************************** */
/* Container methods */


/** /**
* Gets the item from the container with given id. If the container does not * Gets the item from the container with given id. If the container does not
* contain the requested item, null is returned. * contain the requested item, null is returned.
* *
* @param itemId * @param itemId
* the item id.
* the item id.
* @return the item from the container. * @return the item from the container.
*/ */
public Item getItem(Object itemId) { public Item getItem(Object itemId) {
* Gets the property type. * Gets the property type.
* *
* @param propertyId * @param propertyId
* the Id identifying the property.
* the Id identifying the property.
* @see com.itmill.toolkit.data.Container#getType(java.lang.Object) * @see com.itmill.toolkit.data.Container#getType(java.lang.Object)
*/ */
public Class getType(Object propertyId) { public Class getType(Object propertyId) {
* Tests, if the collection contains an item with given id. * Tests, if the collection contains an item with given id.
* *
* @param itemId * @param itemId
* the Id the of item to be tested.
* the Id the of item to be tested.
*/ */
public boolean containsId(Object itemId) { public boolean containsId(Object itemId) {
if (itemId != null) { if (itemId != null) {
* returns null. * returns null.
* *
* @param itemId * @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. * @return the Created item with the given id, or null in case of failure.
* @see com.itmill.toolkit.data.Container#addItem(java.lang.Object) * @see com.itmill.toolkit.data.Container#addItem(java.lang.Object)
*/ */
return retval; return retval;
} }


/* Container.Viewer methods ********************************************* */
/* Container.Viewer methods */


/** /**
* Sets the container as data-source for viewing. * Sets the container as data-source for viewing.
* *
* @param newDataSource * @param newDataSource
* the new data source.
* the new data source.
*/ */
public void setContainerDataSource(Container newDataSource) { public void setContainerDataSource(Container newDataSource) {
if (newDataSource == null) { if (newDataSource == null) {


// Removes listeners from the old datasource // Removes listeners from the old datasource
if (items != null) { if (items != null) {
try {
if (items instanceof Container.ItemSetChangeListener) {
((Container.ItemSetChangeNotifier) items) ((Container.ItemSetChangeNotifier) items)
.removeListener(this); .removeListener(this);
} catch (final ClassCastException ignored) {
// Ignored
} }
try {
if (items instanceof Container.PropertySetChangeNotifier) {
((Container.PropertySetChangeNotifier) items) ((Container.PropertySetChangeNotifier) items)
.removeListener(this); .removeListener(this);
} catch (final ClassCastException ignored) {
// Ignored
} }
} }




// Adds listeners // Adds listeners
if (items != null) { if (items != null) {
try {
if (items instanceof Container.ItemSetChangeListener) {
((Container.ItemSetChangeNotifier) items).addListener(this); ((Container.ItemSetChangeNotifier) items).addListener(this);
} catch (final ClassCastException ignored) {
// Ignored
} }
try {
if (items instanceof Container.PropertySetChangeNotifier) {
((Container.PropertySetChangeNotifier) items) ((Container.PropertySetChangeNotifier) items)
.addListener(this); .addListener(this);
} catch (final ClassCastException ignored) {
// Ignored
} }
} }


return items; return items;
} }


/* Select attributes **************************************************** */
/* Select attributes */


/** /**
* Is the select in multiselect mode? In multiselect mode * Is the select in multiselect mode? In multiselect mode
* selected items, only one of the selected items is kept as selected. * selected items, only one of the selected items is kept as selected.
* *
* @param multiSelect * @param multiSelect
* the New value of property multiSelect.
* the New value of property multiSelect.
*/ */
public void setMultiSelect(boolean multiSelect) { public void setMultiSelect(boolean multiSelect) {
if (multiSelect && getNullSelectionItemId() != null) { if (multiSelect && getNullSelectionItemId() != null) {
* Enables or disables possibility to add new options by the user. * Enables or disables possibility to add new options by the user.
* *
* @param allowNewOptions * @param allowNewOptions
* the New value of property allowNewOptions.
* the New value of property allowNewOptions.
*/ */
public void setNewItemsAllowed(boolean allowNewOptions) { public void setNewItemsAllowed(boolean allowNewOptions) {


* item and index captions. * item and index captions.
* *
* @param itemId * @param itemId
* the id of the item to be recaptioned.
* the id of the item to be recaptioned.
* @param caption * @param caption
* the New caption.
* the New caption.
*/ */
public void setItemCaption(Object itemId, String caption) { public void setItemCaption(Object itemId, String caption) {
if (itemId != null) { if (itemId != null) {
* details. * details.
* *
* @param itemId * @param itemId
* the id of the item to be queried.
* the id of the item to be queried.
* @return the caption for specified item. * @return the caption for specified item.
*/ */
public String getItemCaption(Object itemId) { public String getItemCaption(Object itemId) {
break; break;


case ITEM_CAPTION_MODE_INDEX: case ITEM_CAPTION_MODE_INDEX:
try {
if (items instanceof Container.Indexed) {
caption = String.valueOf(((Container.Indexed) items) caption = String.valueOf(((Container.Indexed) items)
.indexOfId(itemId)); .indexOfId(itemId));
} catch (final ClassCastException ignored) {
} else {
caption = "ERROR: Container is not indexed";
} }
break; break;


* Sets the icon for an item. * Sets the icon for an item.
* *
* @param itemId * @param itemId
* the id of the item to be assigned an icon.
* the id of the item to be assigned an icon.
* @param icon * @param icon
* the New icon.
* the New icon.
*/ */
public void setItemIcon(Object itemId, Resource icon) { public void setItemIcon(Object itemId, Resource icon) {
if (itemId != null) { if (itemId != null) {
* Gets the item icon. * Gets the item icon.
* *
* @param itemId * @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. * @return the Icon for the item or null, if not specified.
*/ */
public Resource getItemIcon(Object itemId) { public Resource getItemIcon(Object itemId) {
* <code>toString</code> is used as item caption.</li> * <code>toString</code> is used as item caption.</li>
* <li><code>ITEM_CAPTION_MODE_ITEM</code> : Item-objects * <li><code>ITEM_CAPTION_MODE_ITEM</code> : Item-objects
* <code>toString</code> is used as item caption.</li> * <code>toString</code> is used as item caption.</li>
* <li><code>ITEM_CAPTION_MODE_INDEX</code> : The index of the item is
* used as item caption. The index mode can only be used with the containers
* <li><code>ITEM_CAPTION_MODE_INDEX</code> : The index of the item is used
* as item caption. The index mode can only be used with the containers
* implementing <code>Container.Indexed</code> interface.</li> * implementing <code>Container.Indexed</code> interface.</li>
* <li><code>ITEM_CAPTION_MODE_EXPLICIT</code> : The item captions must
* be explicitly specified.</li>
* <li><code>ITEM_CAPTION_MODE_PROPERTY</code> : The item captions are
* read from property, that must be specified with
* <li><code>ITEM_CAPTION_MODE_EXPLICIT</code> : The item captions must be
* explicitly specified.</li>
* <li><code>ITEM_CAPTION_MODE_PROPERTY</code> : The item captions are read
* from property, that must be specified with
* <code>setItemCaptionPropertyId</code>.</li> * <code>setItemCaptionPropertyId</code>.</li>
* </ul> * </ul>
* The <code>ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID</code> is the default * The <code>ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID</code> is the default
* </p> * </p>
* *
* @param mode * @param mode
* the One of the modes listed above.
* the One of the modes listed above.
*/ */
public void setItemCaptionMode(int mode) { public void setItemCaptionMode(int mode) {
if (ITEM_CAPTION_MODE_ID <= mode && mode <= ITEM_CAPTION_MODE_PROPERTY) { if (ITEM_CAPTION_MODE_ID <= mode && mode <= ITEM_CAPTION_MODE_PROPERTY) {
* <code>toString</code> is used as item caption.</li> * <code>toString</code> is used as item caption.</li>
* <li><code>ITEM_CAPTION_MODE_ITEM</code> : Item-objects * <li><code>ITEM_CAPTION_MODE_ITEM</code> : Item-objects
* <code>toString</code> is used as item caption.</li> * <code>toString</code> is used as item caption.</li>
* <li><code>ITEM_CAPTION_MODE_INDEX</code> : The index of the item is
* used as item caption. The index mode can only be used with the containers
* <li><code>ITEM_CAPTION_MODE_INDEX</code> : The index of the item is used
* as item caption. The index mode can only be used with the containers
* implementing <code>Container.Indexed</code> interface.</li> * implementing <code>Container.Indexed</code> interface.</li>
* <li><code>ITEM_CAPTION_MODE_EXPLICIT</code> : The item captions must
* be explicitly specified.</li>
* <li><code>ITEM_CAPTION_MODE_PROPERTY</code> : The item captions are
* read from property, that must be specified with
* <li><code>ITEM_CAPTION_MODE_EXPLICIT</code> : The item captions must be
* explicitly specified.</li>
* <li><code>ITEM_CAPTION_MODE_PROPERTY</code> : The item captions are read
* from property, that must be specified with
* <code>setItemCaptionPropertyId</code>.</li> * <code>setItemCaptionPropertyId</code>.</li>
* </ul> * </ul>
* The <code>ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID</code> is the default * The <code>ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID</code> is the default
* <p> * <p>
* Setting the id to a existing property implicitly sets the item caption * Setting the id to a existing property implicitly sets the item caption
* mode to <code>ITEM_CAPTION_MODE_PROPERTY</code>. If the object is in * mode to <code>ITEM_CAPTION_MODE_PROPERTY</code>. If the object is in
* <code>ITEM_CAPTION_MODE_PROPERTY</code> mode, setting caption property
* id null resets the item caption mode to
* <code>ITEM_CAPTION_MODE_PROPERTY</code> mode, setting caption property id
* null resets the item caption mode to
* <code>ITEM_CAPTION_EXPLICIT_DEFAULTS_ID</code>. * <code>ITEM_CAPTION_EXPLICIT_DEFAULTS_ID</code>.
* </p> * </p>
* *
* <p> * <p>
* Setting the property id to null disables this feature. The id is null by * Setting the property id to null disables this feature. The id is null by
* default * default
* </p>.
* </p>
* .
* *
* @param propertyId * @param propertyId
* the id of the property.
* the id of the property.
* *
*/ */
public void setItemCaptionPropertyId(Object propertyId) { public void setItemCaptionPropertyId(Object propertyId) {
* </p> * </p>
* *
* <p> * <p>
* Note : The icons set with <code>setItemIcon</code> function override
* the icons from the property.
* Note : The icons set with <code>setItemIcon</code> function override the
* icons from the property.
* </p> * </p>
* *
* <p> * <p>
* Setting the property id to null disables this feature. The id is null by * Setting the property id to null disables this feature. The id is null by
* default * default
* </p>.
* </p>
* .
* *
* @param propertyId * @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) { public void setItemIconPropertyId(Object propertyId) {
if ((propertyId != null) if ((propertyId != null)
* </p> * </p>
* *
* <p> * <p>
* Note : The icons set with <code>setItemIcon</code> function override
* the icons from the property.
* Note : The icons set with <code>setItemIcon</code> function override the
* icons from the property.
* </p> * </p>
* *
* <p> * <p>
* Setting the property id to null disables this feature. The id is null by * Setting the property id to null disables this feature. The id is null by
* default * default
* </p>.
* </p>
* .
* *
* @return the Id of the property containing the item icons. * @return the Id of the property containing the item icons.
*/ */
* </p> * </p>
* *
* @param itemId * @param itemId
* the Id the of the item to be tested.
* the Id the of the item to be tested.
* @see #getNullSelectionItemId() * @see #getNullSelectionItemId()
* @see #setNullSelectionItemId(Object) * @see #setNullSelectionItemId(Object)
* *
* </p> * </p>
* *
* @param itemId * @param itemId
* the tem to be selected.
* the tem to be selected.
* @see #getNullSelectionItemId() * @see #getNullSelectionItemId()
* @see #setNullSelectionItemId(Object) * @see #setNullSelectionItemId(Object)
* *
* Unselects an item. * Unselects an item.
* *
* @param itemId * @param itemId
* the Item to be unselected.
* the Item to be unselected.
* @see #getNullSelectionItemId() * @see #getNullSelectionItemId()
* @see #setNullSelectionItemId(Object) * @see #setNullSelectionItemId(Object)
* *
/** /**
* Allow of disallow empty selection. If the select is in single-select * Allow of disallow empty selection. If the select is in single-select
* mode, you can make an item represent the empty selection by calling * mode, you can make an item represent the empty selection by calling
* <code>setNullSelectionItemId()</code>. This way you can for instance
* set an icon and caption for the null selection item.
* <code>setNullSelectionItemId()</code>. This way you can for instance set
* an icon and caption for the null selection item.
* *
* @param nullSelectionAllowed * @param nullSelectionAllowed
* whether or not to allow empty selection
* whether or not to allow empty selection
* @see #setNullSelectionItemId(Object) * @see #setNullSelectionItemId(Object)
* @see #isNullSelectionAllowed() * @see #isNullSelectionAllowed()
*/ */
* </p> * </p>
* *
* @param nullSelectionItemId * @param nullSelectionItemId
* the nullSelectionItemId to set.
* the nullSelectionItemId to set.
* @see #getNullSelectionItemId() * @see #getNullSelectionItemId()
* @see #isSelected(Object) * @see #isSelected(Object)
* @see #select(Object) * @see #select(Object)

+ 23
- 24
src/com/itmill/toolkit/ui/Button.java Dosyayı Görüntüle

*/ */
public class Button extends AbstractField { public class Button extends AbstractField {


/* Private members ************************************************* */
/* Private members */


boolean switchMode = false; boolean switchMode = false;


* default. * default.
* *
* @param caption * @param caption
* the Button caption.
* the Button caption.
*/ */
public Button(String caption) { public Button(String caption) {
setCaption(caption); setCaption(caption);
* Creates a new push button with click listener. * Creates a new push button with click listener.
* *
* @param caption * @param caption
* the Button caption.
* the Button caption.
* @param listener * @param listener
* the Button click listener.
* the Button click listener.
*/ */
public Button(String caption, ClickListener listener) { public Button(String caption, ClickListener listener) {
this(caption); this(caption);
* of Button.ClickEvent type. * of Button.ClickEvent type.
* *
* @param caption * @param caption
* the Button caption.
* the Button caption.
* @param target * @param target
* the Object having the method for listening button clicks.
* the Object having the method for listening button clicks.
* @param methodName * @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) { public Button(String caption, Object target, String methodName) {
this(caption); this(caption);
* Creates a new switch button with initial value. * Creates a new switch button with initial value.
* *
* @param state * @param state
* the Initial state of the switch-button.
* the Initial state of the switch-button.
* @param initialState * @param initialState
*/ */
public Button(String caption, boolean initialState) { public Button(String caption, boolean initialState) {
* Creates a new switch button that is connected to a boolean property. * Creates a new switch button that is connected to a boolean property.
* *
* @param state * @param state
* the Initial state of the switch-button.
* the Initial state of the switch-button.
* @param dataSource * @param dataSource
*/ */
public Button(String caption, Property dataSource) { public Button(String caption, Property dataSource) {
* Paints the content of this component. * Paints the content of this component.
* *
* @param event * @param event
* the PaintEvent.
* the PaintEvent.
* @throws IOException * @throws IOException
* if the writing failed due to input/output error.
* if the writing failed due to input/output error.
* @throws PaintException * @throws PaintException
* if the paint operation failed.
* if the paint operation failed.
*/ */
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target); super.paintContent(target);
*/ */
public void changeVariables(Object source, Map variables) { public void changeVariables(Object source, Map variables) {
super.changeVariables(source, 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 // Gets the new and old button states
final Boolean newValue = (Boolean) variables.get("state"); final Boolean newValue = (Boolean) variables.get("state");
final Boolean oldValue = (Boolean) getValue(); final Boolean oldValue = (Boolean) getValue();
* Sets the switchMode. * Sets the switchMode.
* *
* @param switchMode * @param switchMode
* The switchMode to set.
* The switchMode to set.
*/ */
public void setSwitchMode(boolean switchMode) { public void setSwitchMode(boolean switchMode) {
this.switchMode = switchMode; this.switchMode = switchMode;
return Boolean.class; return Boolean.class;
} }


/* Click event ************************************************ */
/* Click event */


private static final Method BUTTON_CLICK_METHOD; private static final Method BUTTON_CLICK_METHOD;


"buttonClick", new Class[] { ClickEvent.class }); "buttonClick", new Class[] { ClickEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error finding methods in Button");
} }
} }


* New instance of text change event. * New instance of text change event.
* *
* @param source * @param source
* the Source of the event.
* the Source of the event.
*/ */
public ClickEvent(Component source) { public ClickEvent(Component source) {
super(source); super(source);
* Button has been pressed. * Button has been pressed.
* *
* @param event * @param event
* Button click event.
* Button click event.
*/ */
public void buttonClick(ClickEvent event); public void buttonClick(ClickEvent event);
} }
* Adds the button click listener. * Adds the button click listener.
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(ClickListener listener) { public void addListener(ClickListener listener) {
addListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD); addListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD);
* Removes the button click listener. * Removes the button click listener.
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(ClickListener listener) { public void removeListener(ClickListener listener) {
removeListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD); removeListener(ClickEvent.class, listener, BUTTON_CLICK_METHOD);

+ 24
- 22
src/com/itmill/toolkit/ui/Form.java Dosyayı Görüntüle

* </p> * </p>
* *
* @param formLayout * @param formLayout
* the layout of the form.
* the layout of the form.
*/ */
public Form() { public Form() {
this(null); this(null);
* Contructs a new form with given layout. * Contructs a new form with given layout.
* *
* @param formLayout * @param formLayout
* the layout of the form.
* the layout of the form.
*/ */
public Form(Layout formLayout) { public Form(Layout formLayout) {
this(formLayout, new BaseFieldFactory()); this(formLayout, new BaseFieldFactory());
* Contructs a new form with given layout and FieldFactory. * Contructs a new form with given layout and FieldFactory.
* *
* @param formLayout * @param formLayout
* the layout of the form.
* the layout of the form.
* @param fieldFactory * @param fieldFactory
* the FieldFactory of the form.
* the FieldFactory of the form.
*/ */
public Form(Layout formLayout, FieldFactory fieldFactory) { public Form(Layout formLayout, FieldFactory fieldFactory) {
super(); super();
ErrorMessage validationError = null; ErrorMessage validationError = null;
if (isValidationVisible()) { if (isValidationVisible()) {
for (final Iterator i = propertyIds.iterator(); i.hasNext();) { 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(); validationError = field.getErrorMessage();
if (validationError != null) { if (validationError != null) {
// Skip empty errors // Skip empty errors
} }
break; break;
} }
} catch (ClassCastException ignored) {
} }
} }
} }
* the implicit setting by setting this property as false. * the implicit setting by setting this property as false.
* *
* @param makeVisible * @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) { public void setValidationVisibleOnCommit(boolean makeVisible) {
validationVisibleOnCommit = makeVisible; validationVisibleOnCommit = makeVisible;


// Only commit on valid state if so requested // Only commit on valid state if so requested
if (!isInvalidCommitted() && !isValid()) { if (!isInvalidCommitted() && !isValid()) {
if (validationVisibleOnCommit)
if (validationVisibleOnCommit) {
setValidationVisible(true); setValidationVisible(true);
}
return; return;
} }


* </p> * </p>
* *
* @param propertyId * @param propertyId
* the Property id the the field.
* the Property id the the field.
* @param field * @param field
* the New field added to the form.
* the New field added to the form.
*/ */
public void addField(Object propertyId, Field field) { public void addField(Object propertyId, Field field) {


* Gets the field identified by the propertyid. * Gets the field identified by the propertyid.
* *
* @param propertyId * @param propertyId
* the id of the property.
* the id of the property.
*/ */
public Field getField(Object propertyId) { public Field getField(Object propertyId) {
return (Field) fields.get(propertyId); return (Field) fields.get(propertyId);
* Gets the layout of the form. * Gets the layout of the form.
* *
* <p> * <p>
* By default form uses <code>OrderedLayout</code> with <code>form</code>-style.
* By default form uses <code>OrderedLayout</code> with <code>form</code>
* -style.
* </p> * </p>
* *
* @return the Layout of the form. * @return the Layout of the form.
* Sets the layout of the form. * Sets the layout of the form.
* *
* <p> * <p>
* By default form uses <code>OrderedLayout</code> with <code>form</code>-style.
* By default form uses <code>OrderedLayout</code> with <code>form</code>
* -style.
* </p> * </p>
* *
* @param newLayout * @param newLayout
* the Layout of the form.
* the Layout of the form.
*/ */
public void setLayout(Layout newLayout) { public void setLayout(Layout newLayout) {


* </p> * </p>
* *
* @param propertyId * @param propertyId
* the id of the property.
* the id of the property.
* @param values * @param values
* @param descriptions * @param descriptions
* @return the select property generated * @return the select property generated
* By default the form uses BaseFieldFactory to create Field instances. * By default the form uses BaseFieldFactory to create Field instances.
* *
* @param fieldFactory * @param fieldFactory
* the New factory used to create the fields.
* the New factory used to create the fields.
* @see Field * @see Field
* @see FieldFactory * @see FieldFactory
*/ */
* Sets the visibleProperties. * Sets the visibleProperties.
* *
* @param visibleProperties * @param visibleProperties
* the visibleProperties to set.
* the visibleProperties to set.
*/ */
public void setVisibleItemProperties(Collection visibleProperties) { public void setVisibleItemProperties(Collection visibleProperties) {
visibleItemProperties = visibleProperties; visibleItemProperties = visibleProperties;
* Sets the layout that is rendered below normal form contens. * Sets the layout that is rendered below normal form contens.
* *
* @param newFormFooter * @param newFormFooter
* the new Layout
* the new Layout
*/ */
public void setFooter(Layout newFormFooter) { public void setFooter(Layout newFormFooter) {
if (formFooter != null) { if (formFooter != null) {

+ 54
- 51
src/com/itmill/toolkit/ui/GridLayout.java Dosyayı Görüntüle

* if you add components outside the grid's area. * if you add components outside the grid's area.
* *
* @param columns * @param columns
* Number of columns in the grid.
* Number of columns in the grid.
* @param rows * @param rows
* Number of rows in the grid.
* Number of rows in the grid.
*/ */
public GridLayout(int columns, int rows) { public GridLayout(int columns, int rows) {
setColumns(columns); setColumns(columns);
* </p> * </p>
* *
* @param c * @param c
* the component to be added.
* the component to be added.
* @param column1 * @param column1
* the column of the upper left corner of the area
* <code>c</code> is supposed to occupy.
* the column of the upper left corner of the area <code>c</code>
* is supposed to occupy.
* @param row1 * @param row1
* the row of the upper left corner of the area
* <code>c</code> is supposed to occupy.
* the row of the upper left corner of the area <code>c</code> is
* supposed to occupy.
* @param column2 * @param column2
* the column of the lower right corner of the area
* <code>c</code> is supposed to occupy.
* the column of the lower right corner of the area
* <code>c</code> is supposed to occupy.
* @param row2 * @param row2
* the row of the lower right corner of the area
* <code>c</code> is supposed to occupy.
* the row of the lower right corner of the area <code>c</code>
* is supposed to occupy.
* @throws OverlapsException * @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 * @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, public void addComponent(Component component, int column1, int row1,
int column2, int row2) throws OverlapsException, int column2, int row2) throws OverlapsException,
* grid. * grid.
* *
* @param area * @param area
* the Area to be checked for overlapping.
* the Area to be checked for overlapping.
* @throws OverlapsException * @throws OverlapsException
* if <code>area</code> overlaps with any existing area.
* if <code>area</code> overlaps with any existing area.
*/ */
private void checkExistingOverlaps(Area area) throws OverlapsException { private void checkExistingOverlaps(Area area) throws OverlapsException {
for (final Iterator i = areas.iterator(); i.hasNext();) { for (final Iterator i = areas.iterator(); i.hasNext();) {
* the same as column1,row1. Component width and height is 1. * the same as column1,row1. Component width and height is 1.
* *
* @param c * @param c
* the component to be added.
* the component to be added.
* @param column * @param column
* the column index.
* the column index.
* @param row * @param row
* the row index.
* the row index.
*/ */
public void addComponent(Component c, int column, int row) { public void addComponent(Component c, int column, int row) {
this.addComponent(c, column, row, column, row); this.addComponent(c, column, row, column, row);
* grid is automatically extended. * grid is automatically extended.
* *
* @param c * @param c
* the component to be added.
* the component to be added.
*/ */
public void addComponent(Component component) { public void addComponent(Component component) {


area = new Area(component, cursorX, cursorY, cursorX, cursorY); area = new Area(component, cursorX, cursorY, cursorX, cursorY);
checkExistingOverlaps(area); checkExistingOverlaps(area);
done = true; done = true;
} catch (final OverlapsException ignored) {
} catch (final OverlapsException e) {
space(); space();
} }
} }
* Removes the given component from this container. * Removes the given component from this container.
* *
* @param c * @param c
* the component to be removed.
* the component to be removed.
*/ */
public void removeComponent(Component component) { public void removeComponent(Component component) {


* Removes the component specified with it's cell index. * Removes the component specified with it's cell index.
* *
* @param column * @param column
* the Component's column.
* the Component's column.
* @param row * @param row
* the Component's row.
* the Component's row.
*/ */
public void removeComponent(int column, int row) { public void removeComponent(int column, int row) {


* Paints the contents of this component. * Paints the contents of this component.
* *
* @param target * @param target
* the Paint Event.
* the Paint Event.
* @throws PaintException * @throws PaintException
* if the paint operation failed.
* if the paint operation failed.
*/ */
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {


/* /*
* (non-Javadoc) * (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) { public int getComponentAlignment(Component childComponent) {
final Integer bitMask = (Integer) componentToAlignment final Integer bitMask = (Integer) componentToAlignment
* </p> * </p>
* *
* @param component * @param component
* the component connected to the area.
* the component connected to the area.
* @param column1 * @param column1
* The column of the upper left corner cell of the area
* <code>c</code> is supposed to occupy.
* The column of the upper left corner cell of the area
* <code>c</code> is supposed to occupy.
* @param row1 * @param row1
* The row of the upper left corner cell of the area
* <code>c</code> is supposed to occupy.
* The row of the upper left corner cell of the area
* <code>c</code> is supposed to occupy.
* @param column2 * @param column2
* The column of the lower right corner cell of the area
* <code>c</code> is supposed to occupy.
* The column of the lower right corner cell of the area
* <code>c</code> is supposed to occupy.
* @param row2 * @param row2
* The row of the lower right corner cell of the area
* <code>c</code> is supposed to occupy.
* The row of the lower right corner cell of the area
* <code>c</code> is supposed to occupy.
* @throws OverlapsException * @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, public Area(Component component, int column1, int row1, int column2,
int row2) { int row2) {
* Tests if the given Area overlaps with an another Area. * Tests if the given Area overlaps with an another Area.
* *
* @param other * @param other
* the Another Area that's to be tested for overlap with
* this area.
* @return <code>true</code> if <code>other</code> overlaps with
* this area, <code>false</code> if it doesn't.
* the Another Area that's to be tested for overlap with this
* area.
* @return <code>true</code> if <code>other</code> overlaps with this
* area, <code>false</code> if it doesn't.
*/ */
public boolean overlaps(Area other) { public boolean overlaps(Area other) {
return column1 <= other.getColumn2() && row1 <= other.getRow2() return column1 <= other.getColumn2() && row1 <= other.getRow2()
* </p> * </p>
* *
* @param newComponent * @param newComponent
* the new connected overriding the existing one.
* the new connected overriding the existing one.
*/ */
protected void setComponent(Component newComponent) { protected void setComponent(Component newComponent) {
component = newComponent; component = newComponent;
} }


/** /**
* An <code>Exception</code> object which is thrown when an area exceeds
* the bounds of the grid.
* An <code>Exception</code> object which is thrown when an area exceeds the
* bounds of the grid.
* *
* @author IT Mill Ltd. * @author IT Mill Ltd.
* @version * @version
* reduced if there are any areas that would be outside of the shrunk grid. * reduced if there are any areas that would be outside of the shrunk grid.
* *
* @param columns * @param columns
* the new number of columns in the grid.
* the new number of columns in the grid.
*/ */
public void setColumns(int columns) { public void setColumns(int columns) {


* reduced if there are any areas that would be outside of the shrunk grid. * reduced if there are any areas that would be outside of the shrunk grid.
* *
* @param rows * @param rows
* the new number of rows in the grid.
* the new number of rows in the grid.
*/ */
public void setRows(int rows) { public void setRows(int rows) {


/* /*
* (non-Javadoc) * (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, public void setComponentAlignment(Component childComponent,
int horizontalAlignment, int verticalAlignment) { int horizontalAlignment, int verticalAlignment) {
* Inserts an empty row at the chosen position in the grid. * Inserts an empty row at the chosen position in the grid.
* *
* @param row * @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) { public void insertRow(int row) {
if (row > rows) { if (row > rows) {
* row. * row.
* *
* @param row * @param row
* The row number to remove
* The row number to remove
*/ */
public void removeRow(int row) { public void removeRow(int row) {
if (row >= rows) { if (row >= rows) {

+ 46
- 45
src/com/itmill/toolkit/ui/Label.java Dosyayı Görüntüle

* <p> * <p>
* The contents of the label may contain simple formatting: * The contents of the label may contain simple formatting:
* <ul> * <ul>
* <li> <b>&lt;b></b> Bold
* <li> <b>&lt;i></b> Italic
* <li> <b>&lt;u></b> Underlined
* <li> <b>&lt;br/></b> Linebreak
* <li> <b>&lt;ul>&lt;li>item 1&lt;/li>&lt;li>item 2&lt;/li>&lt;/ul></b> List
* of items
* <li><b>&lt;b></b> Bold
* <li><b>&lt;i></b> Italic
* <li><b>&lt;u></b> Underlined
* <li><b>&lt;br/></b> Linebreak
* <li><b>&lt;ul>&lt;li>item 1&lt;/li>&lt;li>item 2&lt;/li>&lt;/ul></b> List of
* items
* </ul> * </ul>
* The <b>b</b>,<b>i</b>,<b>u</b> and <b>li</b> tags can contain all the
* tags in the list recursively.
* The <b>b</b>,<b>i</b>,<b>u</b> and <b>li</b> tags can contain all the tags in
* the list recursively.
* </p> * </p>
* *
* @author IT Mill Ltd. * @author IT Mill Ltd.
* Set the component to read-only. Readonly is not used in label. * Set the component to read-only. Readonly is not used in label.
* *
* @param readOnly * @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) { public void setReadOnly(boolean readOnly) {
if (dataSource == null) { if (dataSource == null) {
* Paints the content of this component. * Paints the content of this component.
* *
* @param target * @param target
* the Paint Event.
* the Paint Event.
* @throws PaintException * @throws PaintException
* if the Paint Operation fails.
* if the Paint Operation fails.
*/ */
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {
if (contentMode != CONTENT_TEXT) { if (contentMode != CONTENT_TEXT) {
* label. * label.
* *
* @param newValue * @param newValue
* the New value of the label.
* the New value of the label.
*/ */
public void setValue(Object newValue) { public void setValue(Object newValue) {
if (dataSource == null) { if (dataSource == null) {
* Sets the property as data-source for viewing. * Sets the property as data-source for viewing.
* *
* @param newDataSource * @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) * @see com.itmill.toolkit.data.Property.Viewer#setPropertyDataSource(com.itmill.toolkit.data.Property)
*/ */
public void setPropertyDataSource(Property newDataSource) { public void setPropertyDataSource(Property newDataSource) {
* <p> * <p>
* Possible content modes include: * Possible content modes include:
* <ul> * <ul>
* <li><b>CONTENT_TEXT</b> Content mode, where the label contains only
* plain text. The getValue() result is coded to XML when painting.</li>
* <li><b>CONTENT_TEXT</b> Content mode, where the label contains only plain
* text. The getValue() result is coded to XML when painting.</li>
* <li><b>CONTENT_PREFORMATTED</b> Content mode, where the label contains * <li><b>CONTENT_PREFORMATTED</b> Content mode, where the label contains
* preformatted text.</li> * preformatted text.</li>
* <li><b>CONTENT_UIDL</b> Formatted content mode, where the contents is
* XML restricted to the UIDL 1.0 formatting markups.</li>
* <li><b>CONTENT_UIDL</b> Formatted content mode, where the contents is XML
* restricted to the UIDL 1.0 formatting markups.</li>
* <li><b>CONTENT_XHTML</b> Content mode, where the label contains XHTML. * <li><b>CONTENT_XHTML</b> Content mode, where the label contains XHTML.
* Contents is then enclosed in DIV elements having namespace of * Contents is then enclosed in DIV elements having namespace of
* "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".</li> * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".</li>
* <li><b>CONTENT_XML</b> Content mode, where the label contains
* well-formed or well-balanced XML. Each of the root elements must have
* their default namespace specified.</li>
* <li><b>CONTENT_RAW</b> Content mode, where the label contains RAW
* output. Output is not required to comply to with XML. In Web Adapter
* output is inserted inside the resulting HTML document as-is. This is
* useful for some specific purposes where possibly broken HTML content
* needs to be shown, but in most cases XHTML mode should be preferred.</li>
* <li><b>CONTENT_XML</b> Content mode, where the label contains well-formed
* or well-balanced XML. Each of the root elements must have their default
* namespace specified.</li>
* <li><b>CONTENT_RAW</b> Content mode, where the label contains RAW output.
* Output is not required to comply to with XML. In Web Adapter output is
* inserted inside the resulting HTML document as-is. This is useful for
* some specific purposes where possibly broken HTML content needs to be
* shown, but in most cases XHTML mode should be preferred.</li>
* </ul> * </ul>
* </p> * </p>
* *
* <p> * <p>
* Possible content modes include: * Possible content modes include:
* <ul> * <ul>
* <li><b>CONTENT_TEXT</b> Content mode, where the label contains only
* plain text. The getValue() result is coded to XML when painting.</li>
* <li><b>CONTENT_TEXT</b> Content mode, where the label contains only plain
* text. The getValue() result is coded to XML when painting.</li>
* <li><b>CONTENT_PREFORMATTED</b> Content mode, where the label contains * <li><b>CONTENT_PREFORMATTED</b> Content mode, where the label contains
* preformatted text.</li> * preformatted text.</li>
* <li><b>CONTENT_UIDL</b> Formatted content mode, where the contents is
* XML restricted to the UIDL 1.0 formatting markups.</li>
* <li><b>CONTENT_UIDL</b> Formatted content mode, where the contents is XML
* restricted to the UIDL 1.0 formatting markups.</li>
* <li><b>CONTENT_XHTML</b> Content mode, where the label contains XHTML. * <li><b>CONTENT_XHTML</b> Content mode, where the label contains XHTML.
* Contents is then enclosed in DIV elements having namespace of * Contents is then enclosed in DIV elements having namespace of
* "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".</li> * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".</li>
* <li><b>CONTENT_XML</b> Content mode, where the label contains
* well-formed or well-balanced XML. Each of the root elements must have
* their default namespace specified.</li>
* <li><b>CONTENT_RAW</b> Content mode, where the label contains RAW
* output. Output is not required to comply to with XML. In Web Adapter
* output is inserted inside the resulting HTML document as-is. This is
* useful for some specific purposes where possibly broken HTML content
* needs to be shown, but in most cases XHTML mode should be preferred.</li>
* <li><b>CONTENT_XML</b> Content mode, where the label contains well-formed
* or well-balanced XML. Each of the root elements must have their default
* namespace specified.</li>
* <li><b>CONTENT_RAW</b> Content mode, where the label contains RAW output.
* Output is not required to comply to with XML. In Web Adapter output is
* inserted inside the resulting HTML document as-is. This is useful for
* some specific purposes where possibly broken HTML content needs to be
* shown, but in most cases XHTML mode should be preferred.</li>
* </ul> * </ul>
* </p> * </p>
* *
* @param contentMode * @param contentMode
* the New content mode of the label.
* the New content mode of the label.
*/ */
public void setContentMode(int contentMode) { public void setContentMode(int contentMode) {
if (contentMode >= CONTENT_TEXT && contentMode <= CONTENT_RAW) { if (contentMode >= CONTENT_TEXT && contentMode <= CONTENT_RAW) {
} }
} }


/* Value change events ****************************************** */
/* Value change events */


private static final Method VALUE_CHANGE_METHOD; private static final Method VALUE_CHANGE_METHOD;


new Class[] { Property.ValueChangeEvent.class }); new Class[] { Property.ValueChangeEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error finding methods in Label");
} }
} }


* New instance of text change event * New instance of text change event
* *
* @param source * @param source
* the Source of the event.
* the Source of the event.
*/ */
public ValueChangeEvent(Label source) { public ValueChangeEvent(Label source) {
super(source); super(source);
* Adds the value change listener. * Adds the value change listener.
* *
* @param 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) * @see com.itmill.toolkit.data.Property.ValueChangeNotifier#addListener(com.itmill.toolkit.data.Property.ValueChangeListener)
*/ */
public void addListener(Property.ValueChangeListener listener) { public void addListener(Property.ValueChangeListener listener) {
* Removes the value change listener. * Removes the value change listener.
* *
* @param 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) * @see com.itmill.toolkit.data.Property.ValueChangeNotifier#removeListener(com.itmill.toolkit.data.Property.ValueChangeListener)
*/ */
public void removeListener(Property.ValueChangeListener listener) { public void removeListener(Property.ValueChangeListener listener) {
* </p> * </p>
* *
* @param other * @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 * @return a negative integer, zero, or a positive integer as this object is
* less than, equal to, or greater than the specified object. * less than, equal to, or greater than the specified object.
* @see java.lang.Comparable#compareTo(java.lang.Object) * @see java.lang.Comparable#compareTo(java.lang.Object)
* Strips the tags from the XML. * Strips the tags from the XML.
* *
* @param xml * @param xml
* the String containing a XML snippet.
* the String containing a XML snippet.
* @return the original XML without tags. * @return the original XML without tags.
*/ */
private String stripTags(String xml) { private String stripTags(String xml) {

+ 2
- 1
src/com/itmill/toolkit/ui/LoginForm.java Dosyayı Görüntüle

new Class[] { LoginEvent.class }); new Class[] { LoginEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error finding methods in LoginForm");
} }
} }



+ 53
- 44
src/com/itmill/toolkit/ui/Slider.java Dosyayı Görüntüle

* *
* Example code: <code> * Example code: <code>
* class MyPlayer extends CustomComponent implements ValueChangeListener { * 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());
* }
* }
* *
* </code> * </code>
* *
* values set to defaults. * values set to defaults.
* *
* @param caption * @param caption
* The caption for this Slider (e.g. "Volume").
* The caption for this Slider (e.g. "Volume").
*/ */
public Slider(String caption) { public Slider(String caption) {
this(); this();
* is out of new bounds, the value is set to new minimum. * is out of new bounds, the value is set to new minimum.
* *
* @param max * @param max
* New maximum value of the Slider.
* New maximum value of the Slider.
*/ */
public void setMax(double max) { public void setMax(double max) {
this.max = max; this.max = max;
super.setValue(new Double(max)); super.setValue(new Double(max));
} }
} catch (final ClassCastException e) { } catch (final ClassCastException e) {
// FIXME: Handle exception
/*
* Where does ClassCastException come from? Can't see any casts
* above
*/
super.setValue(new Double(max)); super.setValue(new Double(max));
} }
requestRepaint(); requestRepaint();
* is out of new bounds, the value is set to new minimum. * is out of new bounds, the value is set to new minimum.
* *
* @param min * @param min
* New minimum value of the Slider.
* New minimum value of the Slider.
*/ */
public void setMin(double min) { public void setMin(double min) {
this.min = min; this.min = min;
super.setValue(new Double(min)); super.setValue(new Double(min));
} }
} catch (final ClassCastException e) { } catch (final ClassCastException e) {
// FIXME: Handle exception
/*
* Where does ClassCastException come from? Can't see any casts
* above
*/
super.setValue(new Double(min)); super.setValue(new Double(min));
} }
requestRepaint(); requestRepaint();
/** /**
* Set the orientation of the Slider. * Set the orientation of the Slider.
* *
* @param int
* new orientation
* @param int new orientation
*/ */
public void setOrientation(int orientation) { public void setOrientation(int orientation) {
this.orientation = orientation; this.orientation = orientation;
* Set the value of this Slider. * Set the value of this Slider.
* *
* @param value * @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 * @param repaintIsNotNeeded
* If true, client-side is not requested to repaint itself.
* If true, client-side is not requested to repaint itself.
* @throws ValueOutOfBoundsException * @throws ValueOutOfBoundsException
*/ */
public void setValue(Double value, boolean repaintIsNotNeeded) public void setValue(Double value, boolean repaintIsNotNeeded)
* Set the value of this Slider. * Set the value of this Slider.
* *
* @param value * @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 * @throws ValueOutOfBoundsException
*/ */
public void setValue(Double value) throws ValueOutOfBoundsException { public void setValue(Double value) throws ValueOutOfBoundsException {
* Set the value of this Slider. * Set the value of this Slider.
* *
* @param value * @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 * @throws ValueOutOfBoundsException
*/ */
public void setValue(double value) throws ValueOutOfBoundsException { public void setValue(double value) throws ValueOutOfBoundsException {
* Set the size for this Slider. * Set the size for this Slider.
* *
* @param size * @param size
* in pixels, or -1 auto sizing.
* in pixels, or -1 auto sizing.
* @deprecated use standard setWidth/setHeight instead * @deprecated use standard setWidth/setHeight instead
*/ */
public void setSize(int size) { public void setSize(int size) {
* Set the handle size of this Slider. * Set the handle size of this Slider.
* *
* @param handleSize * @param handleSize
* in percentages relative to slider base size.
* in percentages relative to slider base size.
*/ */
public void setHandleSize(int handleSize) { public void setHandleSize(int handleSize) {
if (handleSize < 0) { if (handleSize < 0) {
* *
* @param visible * @param visible
*//* *//*
* public void setArrows(boolean visible) { arrows = visible;
* requestRepaint(); }
*/
* public void setArrows(boolean visible) { arrows = visible;
* requestRepaint(); }
*/
/* /*
* Does the slider have arrows? * Does the slider have arrows?
* *
* @return arrows visible * @return arrows visible
*//* *//*
* public boolean isArrowsVisible() { return arrows; }
*/
* public boolean isArrowsVisible() { return arrows; }
*/
public String getTag() { public String getTag() {
return "slider"; return "slider";

+ 23
- 22
src/com/itmill/toolkit/ui/TabSheet.java Dosyayı Görüntüle

* Removes the component from this container. * Removes the component from this container.
* *
* @param c * @param c
* the component to be removed.
* the component to be removed.
*/ */
public void removeComponent(Component c) { public void removeComponent(Component c) {
if (c != null && tabs.contains(c)) { if (c != null && tabs.contains(c)) {
* into tab. * into tab.
* *
* @param c * @param c
* the component to be added.
* the component to be added.
*/ */
public void addComponent(Component c) { public void addComponent(Component c) {
addTab(c); addTab(c);
* Adds a new tab into TabSheet. * Adds a new tab into TabSheet.
* *
* @param c * @param c
* the component to be added onto tab.
* the component to be added onto tab.
* @param caption * @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 * @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) { public void addTab(Component c, String caption, Resource icon) {
if (c != null) { if (c != null) {
* into tab. * into tab.
* *
* @param c * @param c
* the component to be added onto tab.
* the component to be added onto tab.
*/ */
public void addTab(Component c) { public void addTab(Component c) {
if (c != null) { if (c != null) {
* components are removed from the other container. * components are removed from the other container.
* *
* @param source * @param source
* the container components are removed from.
* the container components are removed from.
*/ */
public void moveComponentsFrom(ComponentContainer source) { public void moveComponentsFrom(ComponentContainer source) {
for (final Iterator i = source.getComponentIterator(); i.hasNext();) { for (final Iterator i = source.getComponentIterator(); i.hasNext();) {
* Paints the content of this component. * Paints the content of this component.
* *
* @param event * @param event
* the Paint Event.
* the Paint Event.
* @throws PaintException * @throws PaintException
* if the paint operation failed.
* if the paint operation failed.
*/ */
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {


* Setter for property tabsHidden. * Setter for property tabsHidden.
* *
* @param tabsHidden * @param tabsHidden
* True if the tabs should be hidden.
* True if the tabs should be hidden.
*/ */
public void hideTabs(boolean tabsHidden) { public void hideTabs(boolean tabsHidden) {
this.tabsHidden = tabsHidden; this.tabsHidden = tabsHidden;
* Gets the caption for a component. * Gets the caption for a component.
* *
* @param c * @param c
* the component.
* the component.
*/ */
public String getTabCaption(Component c) { public String getTabCaption(Component c) {
if (c.getCaption() == null) { if (c.getCaption() == null) {
* Sets tabs captions. * Sets tabs captions.
* *
* @param c * @param c
* the component.
* the component.
* @param caption * @param caption
* the caption to set.
* the caption to set.
*/ */
public void setTabCaption(Component c, String caption) { public void setTabCaption(Component c, String caption) {
if (tabs.contains(c)) { if (tabs.contains(c)) {
* Gets the icon for a component. * Gets the icon for a component.
* *
* @param c * @param c
* the component.
* the component.
*/ */
public Resource getTabIcon(Component c) { public Resource getTabIcon(Component c) {
return c.getIcon(); return c.getIcon();


} }


/* Click event ************************************************ */
/* Click event */


private static final Method SELECTED_TAB_CHANGE_METHOD; private static final Method SELECTED_TAB_CHANGE_METHOD;
static { static {
new Class[] { SelectedTabChangeEvent.class }); new Class[] { SelectedTabChangeEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error finding methods in TabSheet");
} }
} }


* New instance of selected tab change event * New instance of selected tab change event
* *
* @param source * @param source
* the Source of the event.
* the Source of the event.
*/ */
public SelectedTabChangeEvent(Component source) { public SelectedTabChangeEvent(Component source) {
super(source); super(source);
* Visible tab in tab sheet has has been changed. * Visible tab in tab sheet has has been changed.
* *
* @param event * @param event
* the Selected tab change event.
* the Selected tab change event.
*/ */
public void selectedTabChange(SelectedTabChangeEvent event); public void selectedTabChange(SelectedTabChangeEvent event);
} }
* Adds the selected tab change listener * Adds the selected tab change listener
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(SelectedTabChangeListener listener) { public void addListener(SelectedTabChangeListener listener) {
addListener(SelectedTabChangeEvent.class, listener, addListener(SelectedTabChangeEvent.class, listener,
* Removes the selected tab change listener * Removes the selected tab change listener
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(SelectedTabChangeListener listener) { public void removeListener(SelectedTabChangeListener listener) {
removeListener(SelectedTabChangeEvent.class, listener, removeListener(SelectedTabChangeEvent.class, listener,

+ 107
- 104
src/com/itmill/toolkit/ui/Table.java Dosyayı Görüntüle

*/ */
public static final int ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID = AbstractSelect.ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID; 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. * True if column collapsing is allowed.
*/ */
private CellStyleGenerator cellStyleGenerator = null; private CellStyleGenerator cellStyleGenerator = null;


/* Table constructors *************************************************** */
/* Table constructors */


/** /**
* Creates a new empty table. * Creates a new empty table.
setContainerDataSource(dataSource); setContainerDataSource(dataSource);
} }


/* Table functionality ************************************************** */
/* Table functionality */


/** /**
* Gets the array of visible column id:s, including generated columns. * Gets the array of visible column id:s, including generated columns.
* </p> * </p>
* *
* @param visibleColumns * @param visibleColumns
* the Array of shown property id:s.
* the Array of shown property id:s.
*/ */
public void setVisibleColumns(Object[] visibleColumns) { public void setVisibleColumns(Object[] visibleColumns) {


* </p> * </p>
* *
* @param columnHeaders * @param columnHeaders
* the Array of column headers that match the
* <code>getVisibleColumns</code> method.
* the Array of column headers that match the
* <code>getVisibleColumns</code> method.
*/ */
public void setColumnHeaders(String[] columnHeaders) { public void setColumnHeaders(String[] columnHeaders) {


* </p> * </p>
* *
* @param columnIcons * @param columnIcons
* the Array of icons that match the
* <code>getVisibleColumns</code>.
* the Array of icons that match the
* <code>getVisibleColumns</code>.
*/ */
public void setColumnIcons(Resource[] columnIcons) { public void setColumnIcons(Resource[] columnIcons) {


* *
* <p> * <p>
* The items in the array must match the properties identified by * The items in the array must match the properties identified by
* <code>getVisibleColumns()</code>. The possible values for the
* alignments include:
* <code>getVisibleColumns()</code>. The possible values for the alignments
* include:
* <ul> * <ul>
* <li><code>ALIGN_LEFT</code>: Left alignment</li> * <li><code>ALIGN_LEFT</code>: Left alignment</li>
* <li><code>ALIGN_CENTER</code>: Centered</li> * <li><code>ALIGN_CENTER</code>: Centered</li>
* *
* <p> * <p>
* The items in the array must match the properties identified by * The items in the array must match the properties identified by
* <code>getVisibleColumns()</code>. The possible values for the
* alignments include:
* <code>getVisibleColumns()</code>. The possible values for the alignments
* include:
* <ul> * <ul>
* <li><code>ALIGN_LEFT</code>: Left alignment</li> * <li><code>ALIGN_LEFT</code>: Left alignment</li>
* <li><code>ALIGN_CENTER</code>: Centered</li> * <li><code>ALIGN_CENTER</code>: Centered</li>
* </p> * </p>
* *
* @param columnAlignments * @param columnAlignments
* the Column alignments array.
* the Column alignments array.
*/ */
public void setColumnAlignments(String[] columnAlignments) { public void setColumnAlignments(String[] columnAlignments) {


* will make decision of width. * will make decision of width.
* *
* @param columnId * @param columnId
* colunmns property id
* colunmns property id
* @param width * @param width
* width to be reserved for colunmns content
* width to be reserved for colunmns content
* @since 4.0.3 * @since 4.0.3
*/ */
public void setColumnWidth(Object columnId, int width) { public void setColumnWidth(Object columnId, int width) {
* </p> * </p>
* *
* @param pageLength * @param pageLength
* the Length of one page.
* the Length of one page.
*/ */
public void setPageLength(int pageLength) { public void setPageLength(int pageLength) {
if (pageLength >= 0 && this.pageLength != pageLength) { if (pageLength >= 0 && this.pageLength != pageLength) {
* Setter for property currentPageFirstItemId. * Setter for property currentPageFirstItemId.
* *
* @param currentPageFirstItemId * @param currentPageFirstItemId
* the New value of property currentPageFirstItemId.
* the New value of property currentPageFirstItemId.
*/ */
public void setCurrentPageFirstItemId(Object currentPageFirstItemId) { public void setCurrentPageFirstItemId(Object currentPageFirstItemId) {


// Gets the corresponding index // Gets the corresponding index
int index = -1; int index = -1;
try {
if (items instanceof Container.Indexed) {
index = ((Container.Indexed) items) index = ((Container.Indexed) items)
.indexOfId(currentPageFirstItemId); .indexOfId(currentPageFirstItemId);
} catch (final ClassCastException e) {

} else {
// If the table item container does not have index, we have to // If the table item container does not have index, we have to
// calculates the index by hand // calculates the index by hand
Object id = ((Container.Ordered) items).firstItemId(); Object id = ((Container.Ordered) items).firstItemId();
* Gets the icon Resource for the specified column. * Gets the icon Resource for the specified column.
* *
* @param propertyId * @param propertyId
* the propertyId indentifying the column.
* the propertyId indentifying the column.
* @return the icon for the specified column; null if the column has no icon * @return the icon for the specified column; null if the column has no icon
* set, or if the column is not visible. * set, or if the column is not visible.
*/ */
* </p> * </p>
* *
* @param propertyId * @param propertyId
* the propertyId identifying the column.
* the propertyId identifying the column.
* @param icon * @param icon
* the icon Resource to set.
* the icon Resource to set.
*/ */
public void setColumnIcon(Object propertyId, Resource icon) { public void setColumnIcon(Object propertyId, Resource icon) {


* Gets the header for the specified column. * Gets the header for the specified column.
* *
* @param propertyId * @param propertyId
* the propertyId indentifying the column.
* the propertyId indentifying the column.
* @return the header for the specifed column if it has one. * @return the header for the specifed column if it has one.
*/ */
public String getColumnHeader(Object propertyId) { public String getColumnHeader(Object propertyId) {
* Sets the column header for the specified column; * Sets the column header for the specified column;
* *
* @param propertyId * @param propertyId
* the propertyId indentifying the column.
* the propertyId indentifying the column.
* @param header * @param header
* the header to set.
* the header to set.
*/ */
public void setColumnHeader(Object propertyId, String header) { public void setColumnHeader(Object propertyId, String header) {


* Gets the specified column's alignment. * Gets the specified column's alignment.
* *
* @param propertyId * @param propertyId
* the propertyID identifying the column.
* the propertyID identifying the column.
* @return the specified column's alignment if it as one; null otherwise. * @return the specified column's alignment if it as one; null otherwise.
*/ */
public String getColumnAlignment(Object propertyId) { public String getColumnAlignment(Object propertyId) {
* </p> * </p>
* *
* @param propertyId * @param propertyId
* the propertyID identifying the column.
* the propertyID identifying the column.
* @param alignment * @param alignment
* the desired alignment.
* the desired alignment.
*/ */
public void setColumnAlignment(Object propertyId, String alignment) { public void setColumnAlignment(Object propertyId, String alignment) {


* Checks if the specified column is collapsed. * Checks if the specified column is collapsed.
* *
* @param propertyId * @param propertyId
* the propertyID identifying the column.
* the propertyID identifying the column.
* @return true if the column is collapsed; false otherwise; * @return true if the column is collapsed; false otherwise;
*/ */
public boolean isColumnCollapsed(Object propertyId) { public boolean isColumnCollapsed(Object propertyId) {
* *
* *
* @param propertyId * @param propertyId
* the propertyID identifying the column.
* the propertyID identifying the column.
* @param collapsed * @param collapsed
* the desired collapsedness.
* the desired collapsedness.
* @throws IllegalAccessException * @throws IllegalAccessException
*/ */
public void setColumnCollapsed(Object propertyId, boolean collapsed) public void setColumnCollapsed(Object propertyId, boolean collapsed)
* Sets whether column collapsing is allowed or not. * Sets whether column collapsing is allowed or not.
* *
* @param collapsingAllowed * @param collapsingAllowed
* specifies whether column collapsing is allowed.
* specifies whether column collapsing is allowed.
*/ */
public void setColumnCollapsingAllowed(boolean collapsingAllowed) { public void setColumnCollapsingAllowed(boolean collapsingAllowed) {
columnCollapsingAllowed = collapsingAllowed; columnCollapsingAllowed = collapsingAllowed;
* Sets whether column reordering is allowed or not. * Sets whether column reordering is allowed or not.
* *
* @param reorderingAllowed * @param reorderingAllowed
* specifies whether column reordering is allowed.
* specifies whether column reordering is allowed.
*/ */
public void setColumnReorderingAllowed(boolean reorderingAllowed) { public void setColumnReorderingAllowed(boolean reorderingAllowed) {
columnReorderingAllowed = reorderingAllowed; columnReorderingAllowed = reorderingAllowed;
* Setter for property currentPageFirstItem. * Setter for property currentPageFirstItem.
* *
* @param newIndex * @param newIndex
* the New value of property currentPageFirstItem.
* the New value of property currentPageFirstItem.
*/ */
public void setCurrentPageFirstItemIndex(int newIndex) { public void setCurrentPageFirstItemIndex(int newIndex) {
setCurrentPageFirstItemIndex(newIndex, true); setCurrentPageFirstItemIndex(newIndex, true);
* @deprecated functionality is not needed in ajax rendering model * @deprecated functionality is not needed in ajax rendering model
* *
* @param pageBuffering * @param pageBuffering
* the New value of property pageBuffering.
* the New value of property pageBuffering.
*/ */
public void setPageBufferingEnabled(boolean pageBuffering) { public void setPageBufferingEnabled(boolean pageBuffering) {


* </p> * </p>
* *
* @param selectable * @param selectable
* the New value of property selectable.
* the New value of property selectable.
*/ */
public void setSelectable(boolean selectable) { public void setSelectable(boolean selectable) {
if (this.selectable != selectable) { if (this.selectable != selectable) {
* Setter for property columnHeaderMode. * Setter for property columnHeaderMode.
* *
* @param columnHeaderMode * @param columnHeaderMode
* the New value of property columnHeaderMode.
* the New value of property columnHeaderMode.
*/ */
public void setColumnHeaderMode(int columnHeaderMode) { public void setColumnHeaderMode(int columnHeaderMode) {
if (columnHeaderMode >= COLUMN_HEADER_MODE_HIDDEN if (columnHeaderMode >= COLUMN_HEADER_MODE_HIDDEN
* <p> * <p>
* The mode can be one of the following ones: * The mode can be one of the following ones:
* <ul> * <ul>
* <li><code>ROW_HEADER_MODE_HIDDEN</code>: The row captions are hidden.
* </li>
* <li><code>ROW_HEADER_MODE_HIDDEN</code>: The row captions are hidden.</li>
* <li><code>ROW_HEADER_MODE_ID</code>: Items Id-objects * <li><code>ROW_HEADER_MODE_ID</code>: Items Id-objects
* <code>toString()</code> is used as row caption. * <code>toString()</code> is used as row caption.
* <li><code>ROW_HEADER_MODE_ITEM</code>: Item-objects * <li><code>ROW_HEADER_MODE_ITEM</code>: Item-objects
* <code>toString()</code> is used as row caption. * <code>toString()</code> is used as row caption.
* <li><code>ROW_HEADER_MODE_PROPERTY</code>: Property set with * <li><code>ROW_HEADER_MODE_PROPERTY</code>: Property set with
* <code>setItemCaptionPropertyId()</code> is used as row header. * <code>setItemCaptionPropertyId()</code> is used as row header.
* <li><code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code>: Items
* Id-objects <code>toString()</code> is used as row header. If caption is
* explicitly specified, it overrides the id-caption.
* <li><code>ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID</code>: Items Id-objects
* <code>toString()</code> is used as row header. If caption is explicitly
* specified, it overrides the id-caption.
* <li><code>ROW_HEADER_MODE_EXPLICIT</code>: The row headers must be * <li><code>ROW_HEADER_MODE_EXPLICIT</code>: The row headers must be
* explicitly specified.</li> * explicitly specified.</li>
* <li><code>ROW_HEADER_MODE_INDEX</code>: The index of the item is used
* as row caption. The index mode can only be used with the containers
* <li><code>ROW_HEADER_MODE_INDEX</code>: The index of the item is used as
* row caption. The index mode can only be used with the containers
* implementing <code>Container.Indexed</code> interface.</li> * implementing <code>Container.Indexed</code> interface.</li>
* </ul> * </ul>
* The default value is <code>ROW_HEADER_MODE_HIDDEN</code> * The default value is <code>ROW_HEADER_MODE_HIDDEN</code>
* </p> * </p>
* *
* @param mode * @param mode
* the One of the modes listed above.
* the One of the modes listed above.
*/ */
public void setRowHeaderMode(int mode) { public void setRowHeaderMode(int mode) {
if (ROW_HEADER_MODE_HIDDEN == mode) { if (ROW_HEADER_MODE_HIDDEN == mode) {
* columns) with given values. * columns) with given values.
* *
* @param cells * @param cells
* the Object array that is used for filling the visible
* cells new row. The types must be settable to visible
* column property types.
* the Object array that is used for filling the visible cells
* new row. The types must be settable to visible column property
* types.
* @param itemId * @param itemId
* the Id the new row. If null, a new id is automatically
* assigned. If given, the table cant already have a item
* with given id.
* the Id the new row. If null, a new id is automatically
* assigned. If given, the table cant already have a item with
* given id.
* @return Returns item id for the new row. Returns null if operation fails. * @return Returns item id for the new row. Returns null if operation fails.
*/ */
public Object addItem(Object[] cells, Object itemId) public Object addItem(Object[] cells, Object itemId)
return itemId; return itemId;
} }


/* Overriding select behavior ******************************************** */
/* Overriding select behavior */


public void setValue(Object newValue) throws ReadOnlyException, public void setValue(Object newValue) throws ReadOnlyException,
ConversionException { ConversionException {


} }


/* Component basics ***************************************************** */
/* Component basics */


/** /**
* Invoked when the value of a variable has changed. * Invoked when the value of a variable has changed.
lastToBeRenderedInClient = ((Integer) variables lastToBeRenderedInClient = ((Integer) variables
.get("lastToBeRendered")).intValue(); .get("lastToBeRendered")).intValue();
} catch (Exception e) { } catch (Exception e) {
// FIXME: Handle exception
e.printStackTrace(); e.printStackTrace();
} }


setColumnCollapsed(columnIdMap.get(ids[i].toString()), setColumnCollapsed(columnIdMap.get(ids[i].toString()),
true); true);
} }
} catch (final Exception ignored) {
} catch (final Exception e) {
// FIXME: Handle exception
e.printStackTrace();
} }
clientNeedsContentRefresh = true; clientNeedsContentRefresh = true;
} }
ids[i] = columnIdMap.get(ids[i].toString()); ids[i] = columnIdMap.get(ids[i].toString());
} }
setColumnOrder(ids); setColumnOrder(ids);
} catch (final Exception ignored) {
} catch (final Exception e) {
// FIXME: Handle exception
e.printStackTrace();

} }
clientNeedsContentRefresh = true; clientNeedsContentRefresh = true;
} }
* Go to mode where content content refreshing has effect. * Go to mode where content content refreshing has effect.
* *
* @param refreshContent * @param refreshContent
* true if content refresh needs to be done
* true if content refresh needs to be done
*/ */
protected void enableContentRefreshing(boolean refreshContent) { protected void enableContentRefreshing(boolean refreshContent) {
isContentRefreshesEnabled = true; isContentRefreshesEnabled = true;
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see com.itmill.toolkit.ui.AbstractSelect#paintContent(com.itmill.toolkit.terminal.PaintTarget)
* @see
* com.itmill.toolkit.ui.AbstractSelect#paintContent(com.itmill.toolkit.
* terminal.PaintTarget)
*/ */
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {


* the value representation. * the value representation.
* *
* @param rowId * @param rowId
* the Id of the row (same as item Id).
* the Id of the row (same as item Id).
* @param colId * @param colId
* the Id of the column.
* the Id of the column.
* @param property * @param property
* the Property to be presented.
* the Property to be presented.
* @return Object Either formatted value or Component for field. * @return Object Either formatted value or Component for field.
* @see #setFieldFactory(FieldFactory) * @see #setFieldFactory(FieldFactory)
*/ */
* and return a empty string for null properties. * and return a empty string for null properties.
* *
* @param rowId * @param rowId
* the Id of the row (same as item Id).
* the Id of the row (same as item Id).
* @param colId * @param colId
* the Id of the column.
* the Id of the column.
* @param property * @param property
* the Property to be formatted.
* the Property to be formatted.
* @return the String representation of property and its value. * @return the String representation of property and its value.
* @since 3.1 * @since 3.1
*/ */
return property.toString(); return property.toString();
} }


/* Action container *************************************************** */
/* Action container */


/** /**
* Registers a new action handler for this container * Registers a new action handler for this container
} }
} }


/* Property value change listening support **************************** */
/* Property value change listening support */


/** /**
* Notifies this listener that the Property's value has changed. * Notifies this listener that the Property's value has changed.
* Adds a new property to the table and show it as a visible column. * Adds a new property to the table and show it as a visible column.
* *
* @param propertyId * @param propertyId
* the Id of the proprty.
* the Id of the proprty.
* @param type * @param type
* the class of the property.
* the class of the property.
* @param defaultValue * @param defaultValue
* the default value given for all existing items.
* the default value given for all existing items.
* @see com.itmill.toolkit.data.Container#addContainerProperty(Object, * @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
* Class, Object) * Class, Object)
*/ */
* Adds a new property to the table and show it as a visible column. * Adds a new property to the table and show it as a visible column.
* *
* @param propertyId * @param propertyId
* the Id of the proprty
* the Id of the proprty
* @param type * @param type
* the class of the property
* the class of the property
* @param defaultValue * @param defaultValue
* the default value given for all existing items
* the default value given for all existing items
* @param columnHeader * @param columnHeader
* the Explicit header of the column. If explicit header is
* not needed, this should be set null.
* the Explicit header of the column. If explicit header is not
* needed, this should be set null.
* @param columnIcon * @param columnIcon
* the Icon of the column. If icon is not needed, this should
* be set null.
* the Icon of the column. If icon is not needed, this should be
* set null.
* @param columnAlignment * @param columnAlignment
* the Alignment of the column. Null implies align left.
* the Alignment of the column. Null implies align left.
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if the operation is not supported.
* if the operation is not supported.
* @see com.itmill.toolkit.data.Container#addContainerProperty(Object, * @see com.itmill.toolkit.data.Container#addContainerProperty(Object,
* Class, Object) * Class, Object)
*/ */
* </p> * </p>
* *
* @param id * @param id
* the id of the column to be added
* the id of the column to be added
* @param generatedColumn * @param generatedColumn
* the {@link ColumnGenerator} to use for this column
* the {@link ColumnGenerator} to use for this column
*/ */
public void addGeneratedColumn(Object id, ColumnGenerator generatedColumn) { public void addGeneratedColumn(Object id, ColumnGenerator generatedColumn) {
if (generatedColumn == null) { if (generatedColumn == null) {
* Removes a generated column previously added with addGeneratedColumn. * Removes a generated column previously added with addGeneratedColumn.
* *
* @param id * @param id
* id of the generated column to remove
* id of the generated column to remove
* @return true if the column could be removed (existed in the Table) * @return true if the column could be removed (existed in the Table)
*/ */
public boolean removeGeneratedColumn(Object id) { public boolean removeGeneratedColumn(Object id) {
* Adding new items is not supported. * Adding new items is not supported.
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if set to true.
* if set to true.
* @see com.itmill.toolkit.ui.Select#setNewItemsAllowed(boolean) * @see com.itmill.toolkit.ui.Select#setNewItemsAllowed(boolean)
*/ */
public void setNewItemsAllowed(boolean allowNewOptions) public void setNewItemsAllowed(boolean allowNewOptions)
* Focusing to this component is not supported. * Focusing to this component is not supported.
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if invoked.
* if invoked.
* @see com.itmill.toolkit.ui.AbstractField#focus() * @see com.itmill.toolkit.ui.AbstractField#focus()
*/ */
public void focus() throws UnsupportedOperationException { public void focus() throws UnsupportedOperationException {
* BaseFieldFactory is used. * BaseFieldFactory is used.
* *
* @param fieldFactory * @param fieldFactory
* the field factory to set.
* the field factory to set.
* @see #isEditable * @see #isEditable
* @see BaseFieldFactory * @see BaseFieldFactory
* *
* property to true. * property to true.
* *
* @param editable * @param editable
* true if table should be editable by user.
* true if table should be editable by user.
* @see Field * @see Field
* @see FieldFactory * @see FieldFactory
* *
* Sorts the table. * Sorts the table.
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if the container data source does not implement
* Container.Sortable
* if the container data source does not implement
* Container.Sortable
* @see com.itmill.toolkit.data.Container.Sortable#sort(java.lang.Object[], * @see com.itmill.toolkit.data.Container.Sortable#sort(java.lang.Object[],
* boolean[]) * boolean[])
* *
* Sorts the table by currently selected sorting column. * Sorts the table by currently selected sorting column.
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if the container data source does not implement
* Container.Sortable
* if the container data source does not implement
* Container.Sortable
*/ */
public void sort() { public void sort() {
if (getSortContainerPropertyId() == null) { if (getSortContainerPropertyId() == null) {
* Sets the currently sorted column property id. * Sets the currently sorted column property id.
* *
* @param propertyId * @param propertyId
* the Container property id of the currently sorted column.
* the Container property id of the currently sorted column.
*/ */
public void setSortContainerPropertyId(Object propertyId) { public void setSortContainerPropertyId(Object propertyId) {
setSortContainerPropertyId(propertyId, true); setSortContainerPropertyId(propertyId, true);
/** /**
* Is the table currently sorted in ascending order. * Is the table currently sorted in ascending order.
* *
* @return <code>true</code> if ascending, <code>false</code> if
* descending.
* @return <code>true</code> if ascending, <code>false</code> if descending.
*/ */
public boolean isSortAscending() { public boolean isSortAscending() {
return sortAscending; return sortAscending;
* Sets the table in ascending order. * Sets the table in ascending order.
* *
* @param ascending * @param ascending
* <code>true</code> if ascending, <code>false</code> if
* descending.
* <code>true</code> if ascending, <code>false</code> if
* descending.
*/ */
public void setSortAscending(boolean ascending) { public void setSortAscending(boolean ascending) {
setSortAscending(ascending, true); setSortAscending(ascending, true);
* columns are given even in the case where datasource would support this. * columns are given even in the case where datasource would support this.
* *
* @param sortDisabled * @param sortDisabled
* True iff sorting is disabled.
* True iff sorting is disabled.
*/ */
public void setSortDisabled(boolean sortDisabled) { public void setSortDisabled(boolean sortDisabled) {
if (this.sortDisabled != sortDisabled) { if (this.sortDisabled != sortDisabled) {
* generated. * generated.
* *
* @param source * @param source
* the source Table
* the source Table
* @param itemId * @param itemId
* the itemId (aka rowId) for the of the cell to be
* generated
* the itemId (aka rowId) for the of the cell to be generated
* @param columnId * @param columnId
* the id for the generated column (as specified in
* addGeneratedColumn)
* the id for the generated column (as specified in
* addGeneratedColumn)
* @return * @return
*/ */
public abstract Component generateCell(Table source, Object itemId, public abstract Component generateCell(Table source, Object itemId,
* Set cell style generator for Table. * Set cell style generator for Table.
* *
* @param cellStyleGenerator * @param cellStyleGenerator
* New cell style generator or null to remove generator.
* New cell style generator or null to remove generator.
*/ */
public void setCellStyleGenerator(CellStyleGenerator cellStyleGenerator) { public void setCellStyleGenerator(CellStyleGenerator cellStyleGenerator) {
this.cellStyleGenerator = cellStyleGenerator; this.cellStyleGenerator = cellStyleGenerator;
* Called by Table when a cell (and row) is painted. * Called by Table when a cell (and row) is painted.
* *
* @param itemId * @param itemId
* The itemId of the painted cell
* The itemId of the painted cell
* @param propertyId * @param propertyId
* The propertyId of the cell, null when getting row
* style
* The propertyId of the cell, null when getting row style
* @return The style name to add to this cell or row. (the CSS class * @return The style name to add to this cell or row. (the CSS class
* name will be i-table-cell-content-[style name], or * name will be i-table-cell-content-[style name], or
* i-table-row-[style name] for rows) * i-table-row-[style name] for rows)

+ 26
- 26
src/com/itmill/toolkit/ui/TextField.java Dosyayı Görüntüle

* </p> * </p>
* *
* <p> * <p>
* Since <code>TextField</code> extends <code>AbstractField</code> it
* implements the {@link com.itmill.toolkit.data.Buffered} interface. A
* Since <code>TextField</code> extends <code>AbstractField</code> it implements
* the {@link com.itmill.toolkit.data.Buffered} interface. A
* <code>TextField</code> is in write-through mode by default, so * <code>TextField</code> is in write-through mode by default, so
* {@link com.itmill.toolkit.ui.AbstractField#setWriteThrough(boolean)} must be * {@link com.itmill.toolkit.ui.AbstractField#setWriteThrough(boolean)} must be
* called to enable buffering. * called to enable buffering.
*/ */
public class TextField extends AbstractField { public class TextField extends AbstractField {


/* Private members ************************************************* */
/* Private members */


/** /**
* Value formatter used to format the string contents. * Value formatter used to format the string contents.
*/ */
private boolean nullSettingAllowed = false; private boolean nullSettingAllowed = false;


/* Constructors **************************************************** */
/* Constructors */


/** /**
* Constructs an empty <code>TextField</code> with no caption. * Constructs an empty <code>TextField</code> with no caption.
* Constructs an empty <code>TextField</code> with given caption. * Constructs an empty <code>TextField</code> with given caption.
* *
* @param caption * @param caption
* the caption <code>String</code> for the editor.
* the caption <code>String</code> for the editor.
*/ */
public TextField(String caption) { public TextField(String caption) {
setValue(""); setValue("");
* <code>Property</code> and has no caption. * <code>Property</code> and has no caption.
* *
* @param dataSource * @param dataSource
* the Property to be edited with this editor.
* the Property to be edited with this editor.
*/ */
public TextField(Property dataSource) { public TextField(Property dataSource) {
setPropertyDataSource(dataSource); setPropertyDataSource(dataSource);
* <code>Property</code> and has the given caption <code>String</code>. * <code>Property</code> and has the given caption <code>String</code>.
* *
* @param caption * @param caption
* the caption <code>String</code> for the editor.
* the caption <code>String</code> for the editor.
* @param dataSource * @param dataSource
* the Property to be edited with this editor.
* the Property to be edited with this editor.
*/ */
public TextField(String caption, Property dataSource) { public TextField(String caption, Property dataSource) {
this(dataSource); this(dataSource);
* is called to bind it. * is called to bind it.
* *
* @param caption * @param caption
* the caption <code>String</code> for the editor.
* the caption <code>String</code> for the editor.
* @param text * @param text
* the initial text content of the editor.
* the initial text content of the editor.
*/ */
public TextField(String caption, String value) { public TextField(String caption, String value) {
setValue(value); setValue(value);
setCaption(caption); setCaption(caption);
} }


/* Component basic features ********************************************* */
/* Component basic features */


/* /*
* Paints this component. Don't add a JavaDoc comment here, we use the * Paints this component. Don't add a JavaDoc comment here, we use the
if (format != null && value != null) { if (format != null && value != null) {
try { try {
return format.format(value); return format.format(value);
} catch (final IllegalArgumentException ignored) {
// Ignored exception
} catch (final IllegalArgumentException e) {
// FIXME: Handle exception ?
} }
} }
if (value != null) { if (value != null) {


} }


/* Text field configuration ********************************************* */
/* Text field configuration */


/** /**
* Gets the number of columns in the editor. If the number of columns is set * Gets the number of columns in the editor. If the number of columns is set
* adapter. * adapter.
* *
* @param columns * @param columns
* the number of columns to set.
* the number of columns to set.
*/ */
public void setColumns(int columns) { public void setColumns(int columns) {
if (columns < 0) { if (columns < 0) {
* adapter. * adapter.
* *
* @param rows * @param rows
* the number of rows for this editor.
* the number of rows for this editor.
*/ */
public void setRows(int rows) { public void setRows(int rows) {
if (rows < 0) { if (rows < 0) {
* Sets the editor's word-wrap mode on or off. * Sets the editor's word-wrap mode on or off.
* *
* @param wordwrap * @param wordwrap
* the boolean value specifying if the editor should be in
* word-wrap mode after the call or not.
* the boolean value specifying if the editor should be in
* word-wrap mode after the call or not.
*/ */
public void setWordwrap(boolean wordwrap) { public void setWordwrap(boolean wordwrap) {
this.wordwrap = wordwrap; this.wordwrap = wordwrap;
} }


/* Property features **************************************************** */
/* Property features */


/* /*
* Gets the edited property's type. Don't add a JavaDoc comment here, we use * Gets the edited property's type. Don't add a JavaDoc comment here, we use
* secretinformation the information is not echoed to display. * secretinformation the information is not echoed to display.
* *
* @param secret * @param secret
* the value specifying if the field is used to enter secret
* information.
* the value specifying if the field is used to enter secret
* information.
*/ */
public void setSecret(boolean secret) { public void setSecret(boolean secret) {
this.secret = secret; this.secret = secret;
* </p> * </p>
* *
* @param nullRepresentation * @param nullRepresentation
* Textual representation for null strings.
* Textual representation for null strings.
* @see TextField#setNullSettingAllowed(boolean) * @see TextField#setNullSettingAllowed(boolean)
*/ */
public void setNullRepresentation(String nullRepresentation) { public void setNullRepresentation(String nullRepresentation) {
* </p> * </p>
* *
* @param nullSettingAllowed * @param nullSettingAllowed
* Should the null-string represenation be allways converted
* to null-values.
* Should the null-string represenation be allways converted to
* null-values.
* @see TextField#getNullRepresentation() * @see TextField#getNullRepresentation()
*/ */
public void setNullSettingAllowed(boolean nullSettingAllowed) { public void setNullSettingAllowed(boolean nullSettingAllowed) {
* Gets the value formatter of TextField. * Gets the value formatter of TextField.
* *
* @param format * @param format
* the Format used to format the value. Null disables the
* formatting.
* the Format used to format the value. Null disables the
* formatting.
*/ */
public void setFormat(Format format) { public void setFormat(Format format) {
this.format = format; this.format = format;

+ 32
- 33
src/com/itmill/toolkit/ui/Tree.java Dosyayı Görüntüle

public class Tree extends AbstractSelect implements Container.Hierarchical, public class Tree extends AbstractSelect implements Container.Hierarchical,
Action.Container { Action.Container {


/* Static members ***************************************************** */
/* Static members */


private static final Method EXPAND_METHOD; private static final Method EXPAND_METHOD;


"nodeCollapse", new Class[] { CollapseEvent.class }); "nodeCollapse", new Class[] { CollapseEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
e.printStackTrace();
throw new java.lang.RuntimeException( throw new java.lang.RuntimeException(
"Internal error, please report");
"Internal error finding methods in Tree");
} }
} }


/* Private members **************************************************** */
/* Private members */


/** /**
* Set of expanded nodes. * Set of expanded nodes.
*/ */
private boolean initialPaint = true; private boolean initialPaint = true;


/* Tree constructors ************************************************** */
/* Tree constructors */


/** /**
* Creates a new empty tree. * Creates a new empty tree.
setContainerDataSource(dataSource); setContainerDataSource(dataSource);
} }


/* Expanding and collapsing ******************************************* */
/* Expanding and collapsing */


/** /**
* Check is an item is expanded * Check is an item is expanded
* *
* @param itemId * @param itemId
* the item id.
* the item id.
* @return true iff the item is expanded. * @return true iff the item is expanded.
*/ */
public boolean isExpanded(Object itemId) { public boolean isExpanded(Object itemId) {
* Expands an item. * Expands an item.
* *
* @param itemId * @param itemId
* the item id.
* the item id.
* @return True iff the expand operation succeeded * @return True iff the expand operation succeeded
*/ */
public boolean expandItem(Object itemId) { public boolean expandItem(Object itemId) {
* Expands an item. * Expands an item.
* *
* @param itemId * @param itemId
* the item id.
* the item id.
* @param sendChildTree * @param sendChildTree
* flag to indicate if client needs subtree or not (may be
* cached)
* flag to indicate if client needs subtree or not (may be
* cached)
* @return True iff the expand operation succeeded * @return True iff the expand operation succeeded
*/ */
private boolean expandItem(Object itemId, boolean sendChildTree) { private boolean expandItem(Object itemId, boolean sendChildTree) {
* Collapses an item. * Collapses an item.
* *
* @param itemId * @param itemId
* the item id.
* the item id.
* @return True iff the collapse operation succeeded * @return True iff the collapse operation succeeded
*/ */
public boolean collapseItem(Object itemId) { public boolean collapseItem(Object itemId) {
* </p> * </p>
* *
* @param selectable * @param selectable
* the New value of property selectable.
* the New value of property selectable.
*/ */
public void setSelectable(boolean selectable) { public void setSelectable(boolean selectable) {
if (this.selectable != selectable) { if (this.selectable != selectable) {
} }
} }


/* Component API ****************************************************** */
/* Component API */


/** /**
* Gets the UIDL tag corresponding to the component. * Gets the UIDL tag corresponding to the component.
} }
} }


/* Container.Hierarchical API ***************************************** */
/* Container.Hierarchical API */


/** /**
* Tests if the Item with given ID can have any children. * Tests if the Item with given ID can have any children.
} }


/** /**
* Tests if the Item specified with <code>itemId</code> has any child
* Items, that is, is it a leaf Item.
* Tests if the Item specified with <code>itemId</code> has any child Items,
* that is, is it a leaf Item.
* *
* @see com.itmill.toolkit.data.Container.Hierarchical#hasChildren(Object) * @see com.itmill.toolkit.data.Container.Hierarchical#hasChildren(Object)
*/ */
return success; return success;
} }


/* Overriding select behavior******************************************** */
/* Overriding select behavior */


/** /**
* Sets the Container that serves as the data source of the viewer. * Sets the Container that serves as the data source of the viewer.
} }
} }


/* Expand event and listener ****************************************** */
/* Expand event and listener */


/** /**
* Event to fired when a node is expanded. ExapandEvent is fired when a node * Event to fired when a node is expanded. ExapandEvent is fired when a node
* New instance of options change event * New instance of options change event
* *
* @param source * @param source
* the Source of the event.
* the Source of the event.
* @param expandedItemId * @param expandedItemId
*/ */
public ExpandEvent(Component source, Object expandedItemId) { public ExpandEvent(Component source, Object expandedItemId) {
* A node has been expanded. * A node has been expanded.
* *
* @param event * @param event
* the Expand event.
* the Expand event.
*/ */
public void nodeExpand(ExpandEvent event); public void nodeExpand(ExpandEvent event);
} }
* Adds the expand listener. * Adds the expand listener.
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(ExpandListener listener) { public void addListener(ExpandListener listener) {
addListener(ExpandEvent.class, listener, EXPAND_METHOD); addListener(ExpandEvent.class, listener, EXPAND_METHOD);
* Removes the expand listener. * Removes the expand listener.
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(ExpandListener listener) { public void removeListener(ExpandListener listener) {
removeListener(ExpandEvent.class, listener, EXPAND_METHOD); removeListener(ExpandEvent.class, listener, EXPAND_METHOD);
* Emits the expand event. * Emits the expand event.
* *
* @param itemId * @param itemId
* the item id.
* the item id.
*/ */
protected void fireExpandEvent(Object itemId) { protected void fireExpandEvent(Object itemId) {
fireEvent(new ExpandEvent(this, itemId)); fireEvent(new ExpandEvent(this, itemId));
} }


/* Collapse event ****************************************** */
/* Collapse event */


/** /**
* Collapse event * Collapse event
* New instance of options change event. * New instance of options change event.
* *
* @param source * @param source
* the Source of the event.
* the Source of the event.
* @param collapsedItemId * @param collapsedItemId
*/ */
public CollapseEvent(Component source, Object collapsedItemId) { public CollapseEvent(Component source, Object collapsedItemId) {
* A node has been collapsed. * A node has been collapsed.
* *
* @param event * @param event
* the Collapse event.
* the Collapse event.
*/ */
public void nodeCollapse(CollapseEvent event); public void nodeCollapse(CollapseEvent event);
} }
* Adds the collapse listener. * Adds the collapse listener.
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(CollapseListener listener) { public void addListener(CollapseListener listener) {
addListener(CollapseEvent.class, listener, COLLAPSE_METHOD); addListener(CollapseEvent.class, listener, COLLAPSE_METHOD);
* Removes the collapse listener. * Removes the collapse listener.
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(CollapseListener listener) { public void removeListener(CollapseListener listener) {
removeListener(CollapseEvent.class, listener, COLLAPSE_METHOD); removeListener(CollapseEvent.class, listener, COLLAPSE_METHOD);
* Emits collapse event. * Emits collapse event.
* *
* @param itemId * @param itemId
* the item id.
* the item id.
*/ */
protected void fireCollapseEvent(Object itemId) { protected void fireCollapseEvent(Object itemId) {
fireEvent(new CollapseEvent(this, itemId)); fireEvent(new CollapseEvent(this, itemId));
} }


/* Action container *************************************************** */
/* Action container */


/** /**
* Adds an action handler. * Adds an action handler.
* Adding new items is not supported. * Adding new items is not supported.
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if set to true.
* if set to true.
* @see com.itmill.toolkit.ui.Select#setNewItemsAllowed(boolean) * @see com.itmill.toolkit.ui.Select#setNewItemsAllowed(boolean)
*/ */
public void setNewItemsAllowed(boolean allowNewOptions) public void setNewItemsAllowed(boolean allowNewOptions)
* Focusing to this component is not supported. * Focusing to this component is not supported.
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* if invoked.
* if invoked.
* @see com.itmill.toolkit.ui.AbstractField#focus() * @see com.itmill.toolkit.ui.AbstractField#focus()
*/ */
public void focus() throws UnsupportedOperationException { public void focus() throws UnsupportedOperationException {

+ 35
- 36
src/com/itmill/toolkit/ui/Upload.java Dosyayı Görüntüle

* stream given by the Receiver. * stream given by the Receiver.
* *
* @param caption * @param caption
* Normal component caption. You can set the caption of the
* upload submit button with setButtonCaption().
* Normal component caption. You can set the caption of the
* upload submit button with setButtonCaption().
* @param uploadReceiver * @param uploadReceiver
* Receiver to call to retrieve output stream when upload
* starts.
* Receiver to call to retrieve output stream when upload starts.
*/ */
public Upload(String caption, Receiver uploadReceiver) { public Upload(String caption, Receiver uploadReceiver) {
setCaption(caption); setCaption(caption);
* Paints the content of this component. * Paints the content of this component.
* *
* @param target * @param target
* Target to paint the content on.
* Target to paint the content on.
* @throws PaintException * @throws PaintException
* if the paint operation failed.
* if the paint operation failed.
*/ */
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {
// The field should be focused // The field should be focused
* Invoked when a new upload arrives. * Invoked when a new upload arrives.
* *
* @param filename * @param filename
* the desired filename of the upload, usually as
* specified by the client.
* the desired filename of the upload, usually as specified
* by the client.
* @param MIMEType * @param MIMEType
* the MIME type of the uploaded file.
* the MIME type of the uploaded file.
* @return Stream to which the uploaded file should be written. * @return Stream to which the uploaded file should be written.
*/ */
public OutputStream receiveUpload(String filename, String MIMEType); public OutputStream receiveUpload(String filename, String MIMEType);
} }


/* Upload events ************************************************ */
/* Upload events */


private static final Method UPLOAD_FINISHED_METHOD; private static final Method UPLOAD_FINISHED_METHOD;


new Class[] { SucceededEvent.class }); new Class[] { SucceededEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException("Internal error");
throw new java.lang.RuntimeException(
"Internal error finding methods in Upload");
} }
} }


/** /**
* *
* @param source * @param source
* the source of the file.
* the source of the file.
* @param filename * @param filename
* the received file name.
* the received file name.
* @param MIMEType * @param MIMEType
* the MIME type of the received file.
* the MIME type of the received file.
* @param length * @param length
* the length of the received file.
* the length of the received file.
*/ */
public FinishedEvent(Upload source, String filename, String MIMEType, public FinishedEvent(Upload source, String filename, String MIMEType,
long length) { long length) {
* Upload has started. * Upload has started.
* *
* @param event * @param event
* the Upload started event.
* the Upload started event.
*/ */
public void uploadStarted(StartedEvent event); public void uploadStarted(StartedEvent event);
} }
* Upload has finished. * Upload has finished.
* *
* @param event * @param event
* the Upload finished event.
* the Upload finished event.
*/ */
public void uploadFinished(FinishedEvent event); public void uploadFinished(FinishedEvent event);
} }
* Upload has finished unsuccessfully. * Upload has finished unsuccessfully.
* *
* @param event * @param event
* the Upload failed event.
* the Upload failed event.
*/ */
public void uploadFailed(FailedEvent event); public void uploadFailed(FailedEvent event);
} }
* Upload successfull.. * Upload successfull..
* *
* @param event * @param event
* the Upload successfull event.
* the Upload successfull event.
*/ */
public void uploadSucceeded(SucceededEvent event); public void uploadSucceeded(SucceededEvent event);
} }
* Adds the upload started event listener. * Adds the upload started event listener.
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(StartedListener listener) { public void addListener(StartedListener listener) {
addListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD); addListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD);
* Removes the upload started event listener. * Removes the upload started event listener.
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(StartedListener listener) { public void removeListener(StartedListener listener) {
removeListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD); removeListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD);
* Adds the upload received event listener. * Adds the upload received event listener.
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(FinishedListener listener) { public void addListener(FinishedListener listener) {
addListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD); addListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD);
* Removes the upload received event listener. * Removes the upload received event listener.
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(FinishedListener listener) { public void removeListener(FinishedListener listener) {
removeListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD); removeListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD);
* Adds the upload interrupted event listener. * Adds the upload interrupted event listener.
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(FailedListener listener) { public void addListener(FailedListener listener) {
addListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD); addListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD);
* Removes the upload interrupted event listener. * Removes the upload interrupted event listener.
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(FailedListener listener) { public void removeListener(FailedListener listener) {
removeListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD); removeListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD);
* Adds the upload success event listener. * Adds the upload success event listener.
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(SucceededListener listener) { public void addListener(SucceededListener listener) {
addListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD); addListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD);
* Removes the upload success event listener. * Removes the upload success event listener.
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(SucceededListener listener) { public void removeListener(SucceededListener listener) {
removeListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD); removeListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD);
* Adds the upload success event listener. * Adds the upload success event listener.
* *
* @param listener * @param listener
* the Listener to be added.
* the Listener to be added.
*/ */
public void addListener(ProgressListener listener) { public void addListener(ProgressListener listener) {
if (progressListeners == null) { if (progressListeners == null) {
* Removes the upload success event listener. * Removes the upload success event listener.
* *
* @param listener * @param listener
* the Listener to be removed.
* the Listener to be removed.
*/ */
public void removeListener(ProgressListener listener) { public void removeListener(ProgressListener listener) {
if (progressListeners != null) { if (progressListeners != null) {
* Emits the progress event. * Emits the progress event.
* *
* @param totalBytes * @param totalBytes
* bytes received so far
* bytes received so far
* @param contentLength * @param contentLength
* actual size of the file being uploaded, if known
* actual size of the file being uploaded, if known
* *
*/ */
protected void fireUpdateProgress(long totalBytes, long contentLength) { protected void fireUpdateProgress(long totalBytes, long contentLength) {
* Sets the receiver. * Sets the receiver.
* *
* @param receiver * @param receiver
* the receiver to set.
* the receiver to set.
*/ */
public void setReceiver(Receiver receiver) { public void setReceiver(Receiver receiver) {
this.receiver = receiver; this.receiver = receiver;
* Updates progress to listener * Updates progress to listener
* *
* @param readBytes * @param readBytes
* bytes transferred
* bytes transferred
* @param contentLength * @param contentLength
* total size of file currently being uploaded, -1 if
* unknown
* total size of file currently being uploaded, -1 if unknown
*/ */
public void updateProgress(long readBytes, long contentLength); public void updateProgress(long readBytes, long contentLength);
} }
* method is used to set text in that button. * method is used to set text in that button.
* *
* @param buttonCaption * @param buttonCaption
* text for uploads button.
* text for uploads button.
*/ */
public void setButtonCaption(String buttonCaption) { public void setButtonCaption(String buttonCaption) {
this.buttonCaption = buttonCaption; this.buttonCaption = buttonCaption;

+ 77
- 79
src/com/itmill/toolkit/ui/Window.java Dosyayı Görüntüle

* </p> * </p>
* *
* @param caption * @param caption
* the Title of the window.
* the Title of the window.
*/ */
public Window() { public Window() {
this("", null); this("", null);
* </p> * </p>
* *
* @param caption * @param caption
* the Title of the window.
* the Title of the window.
*/ */
public Window(String caption) { public Window(String caption) {
this(caption, null); this(caption, null);
* </p> * </p>
* *
* @param caption * @param caption
* the Title of the window.
* the Title of the window.
* @param layout * @param layout
* the Layout of the window.
* the Layout of the window.
*/ */
public Window(String caption, Layout layout) { public Window(String caption, Layout layout) {
super(caption, layout); super(caption, layout);
* *
* <p> * <p>
* For windows attached directly to the application, parent is * For windows attached directly to the application, parent is
* <code>null</code>. For windows inside other windows, parent is the
* window containing this window.
* <code>null</code>. For windows inside other windows, parent is the window
* containing this window.
* </p> * </p>
* *
* @return the Value of property parent. * @return the Value of property parent.
* </p> * </p>
* *
* @param parent * @param parent
* the New value of property parent.
* the New value of property parent.
*/ */
public void setParent(Component parent) { public void setParent(Component parent) {
super.setParent(parent); super.setParent(parent);
* are attached to root level window. * are attached to root level window.
* *
* @param handler * @param handler
* the URI handler to add.
* the URI handler to add.
*/ */
public void addURIHandler(URIHandler handler) { public void addURIHandler(URIHandler handler) {
if (getParent() != null) { if (getParent() != null) {
* Removes the given URI handler from this window. * Removes the given URI handler from this window.
* *
* @param handler * @param handler
* the URI handler to remove.
* the URI handler to remove.
*/ */
public void removeURIHandler(URIHandler handler) { public void removeURIHandler(URIHandler handler) {
if (getParent() != null) { if (getParent() != null) {
* handlers are attached to parent windows. * handlers are attached to parent windows.
* *
* @param handler * @param handler
* the parameter handler to add.
* the parameter handler to add.
*/ */
public void addParameterHandler(ParameterHandler handler) { public void addParameterHandler(ParameterHandler handler) {
if (getParent() != null) { if (getParent() != null) {
* Removes the given URI handler from this window. * Removes the given URI handler from this window.
* *
* @param handler * @param handler
* the parameter handler to remove.
* the parameter handler to remove.
*/ */
public void removeParameterHandler(ParameterHandler handler) { public void removeParameterHandler(ParameterHandler handler) {
if (getParent() != null) { if (getParent() != null) {
* In Toolkit 5 terminal will reload its host page on theme changes. * In Toolkit 5 terminal will reload its host page on theme changes.
* *
* @param theme * @param theme
* the New theme for this window. Null implies the default
* theme.
* the New theme for this window. Null implies the default theme.
*/ */
public void setTheme(String theme) { public void setTheme(String theme) {
if (getParent() != null) { if (getParent() != null) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Setting theme for sub-windws is not supported.");
"Setting theme for sub-windows is not supported.");
} }
this.theme = theme; this.theme = theme;
requestRepaint(); requestRepaint();
* Paints the content of this component. * Paints the content of this component.
* *
* @param event * @param event
* the Paint Event.
* the Paint Event.
* @throws PaintException * @throws PaintException
* if the paint operation failed.
* if the paint operation failed.
*/ */
public synchronized void paintContent(PaintTarget target) public synchronized void paintContent(PaintTarget target)
throws PaintException { throws PaintException {
if (resizable) { if (resizable) {
target.addAttribute("resizable", true); target.addAttribute("resizable", true);
} }
if(centerRequested) {
if (centerRequested) {
target.addAttribute("center", true); target.addAttribute("center", true);
centerRequested = false; centerRequested = false;
} }
* window. * window.
* *
* @param resource * @param resource
* the resource.
* the resource.
* @param windowName * @param windowName
* the name of the window.
* the name of the window.
*/ */
public void open(Resource resource, String windowName) { public void open(Resource resource, String windowName) {
synchronized (openList) { synchronized (openList) {
try { try {
return new URL(application.getURL(), getName() + "/"); return new URL(application.getURL(), getName() + "/");
} catch (final MalformedURLException e) { } catch (final MalformedURLException e) {
throw new RuntimeException("Internal problem, please report");
throw new RuntimeException(
"Internal problem getting window URL, please report");
} }
} }


* not used for windows inside other windows. all application-level windows * not used for windows inside other windows. all application-level windows
* can be accessed by their names in url * can be accessed by their names in url
* <code>http://host:port/foo/bar/</code> where * <code>http://host:port/foo/bar/</code> where
* <code>http://host:port/foo/</code> is the application url as returned
* by getURL() and <code>bar</code> 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.
* <code>http://host:port/foo/</code> is the application url as returned by
* getURL() and <code>bar</code> 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.
* </p> * </p>
* *
* @return the Name of the Window. * @return the Name of the Window.
* Sets the border. * Sets the border.
* *
* @param border * @param border
* the border to set.
* the border to set.
*/ */
public void setBorder(int border) { public void setBorder(int border) {
this.border = border; this.border = border;
* <p> * <p>
* *
* @param application * @param application
* the application to set.
* the application to set.
*/ */
public void setApplication(Application application) { public void setApplication(Application application) {


* </p> * </p>
* *
* @param name * @param name
* the name to set.
* the name to set.
*/ */
public void setName(String name) { public void setName(String name) {


* adapter and may change from time to time. * adapter and may change from time to time.
* *
* @param type * @param type
* the terminal type to set.
* the terminal type to set.
*/ */
public void setTerminal(Terminal type) { public void setTerminal(Terminal type) {
terminal = type; terminal = type;
* Paints the open-tag inside the window. * Paints the open-tag inside the window.
* *
* @param target * @param target
* the Paint Event.
* the Paint Event.
* @throws PaintException * @throws PaintException
* if the Paint Operation fails.
* if the Paint Operation fails.
*/ */
private void paintContent(PaintTarget target) throws PaintException { private void paintContent(PaintTarget target) throws PaintException {
target.startTag("open"); target.startTag("open");
* containing (main window). * containing (main window).
* *
* @param positionX * @param positionX
* the Distance of Window left border in pixels from left
* border of the containing (main window). or -1 if
* unspecified.
* the Distance of Window left border in pixels from left border
* of the containing (main window). or -1 if unspecified.
* @since 4.0.0 * @since 4.0.0
*/ */
public void setPositionX(int positionX) { public void setPositionX(int positionX) {
* containing (main window). * containing (main window).
* *
* @param positionY * @param positionY
* the Distance of Window top border in pixels from top
* border of the containing (main window). or -1 if
* unspecified
* the Distance of Window top border in pixels from top border of
* the containing (main window). or -1 if unspecified
* *
* @since 4.0.0 * @since 4.0.0
*/ */
"windowClose", new Class[] { CloseEvent.class }); "windowClose", new Class[] { CloseEvent.class });
} catch (final java.lang.NoSuchMethodException e) { } catch (final java.lang.NoSuchMethodException e) {
// This should never happen // This should never happen
throw new java.lang.RuntimeException();
throw new java.lang.RuntimeException(
"Internal error, window close method not found");
} }
} }


* Adds the listener. * Adds the listener.
* *
* @param listener * @param listener
* the listener to add.
* the listener to add.
*/ */
public void addListener(CloseListener listener) { public void addListener(CloseListener listener) {
addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD); addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
* Removes the listener. * Removes the listener.
* *
* @param listener * @param listener
* the listener to remove.
* the listener to remove.
*/ */
public void removeListener(CloseListener listener) { public void removeListener(CloseListener listener) {
addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD); addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
* *
* @param window * @param window
* @throws IllegalArgumentException * @throws IllegalArgumentException
* if a window is added inside non-application level window.
* if a window is added inside non-application level window.
* @throws NullPointerException * @throws NullPointerException
* if the given <code>Window</code> is <code>null</code>.
* if the given <code>Window</code> is <code>null</code>.
*/ */
public void addWindow(Window window) throws IllegalArgumentException, public void addWindow(Window window) throws IllegalArgumentException,
NullPointerException { NullPointerException {
* Remove the given subwindow from this window. * Remove the given subwindow from this window.
* *
* @param window * @param window
* Window to be removed.
* Window to be removed.
*/ */
public void removeWindow(Window window) { public void removeWindow(Window window) {
subwindows.remove(window); subwindows.remove(window);
* <b>Note:</b> affects sub-windows only. * <b>Note:</b> affects sub-windows only.
* *
* @param modality * @param modality
* true if modality is to be turned on
* true if modality is to be turned on
*/ */
public void setModal(boolean modality) { public void setModal(boolean modality) {
modal = modality; modal = modality;
} }


/** /**
* Sets sub-window resizable.
* <b>Note:</b> affects sub-windows only.
* Sets sub-window resizable. <b>Note:</b> affects sub-windows only.
* *
* @param resizable * @param resizable
* true if resizability is to be turned on
* true if resizability is to be turned on
*/ */
public void setResizable(boolean resizeability) { public void setResizable(boolean resizeability) {
resizable = resizeability; resizable = resizeability;
} }


/** /**
* Request to center this window on the screen.
* <b>Note:</b> affects sub-windows only.
* Request to center this window on the screen. <b>Note:</b> affects
* sub-windows only.
*/ */
public void center() { public void center() {
centerRequested = true; centerRequested = true;
* @see Notification * @see Notification
* *
* @param caption * @param caption
* The message
* The message
*/ */
public void showNotification(String caption) { public void showNotification(String caption) {
addNotification(new Notification(caption)); addNotification(new Notification(caption));
* @see Notification * @see Notification
* *
* @param caption * @param caption
* The message
* The message
* @param type * @param type
* The message type
* The message type
*/ */
public void showNotification(String caption, int type) { public void showNotification(String caption, int type) {
addNotification(new Notification(caption, type)); addNotification(new Notification(caption, type));
* @see Notification * @see Notification
* *
* @param caption * @param caption
* The caption of the message
* The caption of the message
* @param description * @param description
* The message description
* The message description
* *
*/ */
public void showNotification(String caption, String description) { public void showNotification(String caption, String description) {
* @see Notification * @see Notification
* *
* @param caption * @param caption
* The caption of the message
* The caption of the message
* @param description * @param description
* The message description
* The message description
* @param type * @param type
* The message type
* The message type
*/ */
public void showNotification(String caption, String description, int type) { public void showNotification(String caption, String description, int type) {
addNotification(new Notification(caption, description, type)); addNotification(new Notification(caption, description, type));
* @see #showNotification(String, String, int) * @see #showNotification(String, String, int)
* *
* @param notification * @param notification
* The notification message to show
* The notification message to show
*/ */
public void showNotification(Notification notification) { public void showNotification(Notification notification) {
addNotification(notification); addNotification(notification);
* still drawing needed attention. There are several basic types of messages * still drawing needed attention. There are several basic types of messages
* that can be used in different situations: * that can be used in different situations:
* <ul> * <ul>
* <li> TYPE_HUMANIZED_MESSAGE fades away quickly as soon as the user uses
* <li>TYPE_HUMANIZED_MESSAGE fades away quickly as soon as the user uses
* the mouse or types something. It can be used to show fairly unimportant * the mouse or types something. It can be used to show fairly unimportant
* messages, such as feedback that an operation succeeded ("Document Saved") -
* the kind of messages the user ignores once the application is familiar.</li>
* messages, such as feedback that an operation succeeded ("Document Saved")
* - the kind of messages the user ignores once the application is familiar.
* </li>
* <li>TYPE_WARNING_MESSAGE is shown for a short while after the user uses * <li>TYPE_WARNING_MESSAGE is shown for a short while after the user uses
* the mouse or types something. It's default style is also more noticeable * the mouse or types something. It's default style is also more noticeable
* than the humanized message. It can be used for messages that do not * than the humanized message. It can be used for messages that do not
* contain a lot of important information, but should be noticed by the * contain a lot of important information, but should be noticed by the
* user. Despite the name, it does not have to be a warning, but can be used * user. Despite the name, it does not have to be a warning, but can be used
* instead of the humanized message whenever you want to make the message a * instead of the humanized message whenever you want to make the message a
* little more noticeable. </li>
* little more noticeable.</li>
* <li>TYPE_ERROR_MESSAGE requires to user to click it before disappearing, * <li>TYPE_ERROR_MESSAGE requires to user to click it before disappearing,
* and can be used for critical messages.</li> * and can be used for critical messages.</li>
* <li>TYPE_TRAY_NOTIFICATION is shown for a while in the lower left corner * <li>TYPE_TRAY_NOTIFICATION is shown for a while in the lower left corner
* of the window, and can be used for "convenience notifications" that do * of the window, and can be used for "convenience notifications" that do
* not have to be noticed immediately, and should not interfere with the * not have to be noticed immediately, and should not interfere with the
* current task - for instance to show "You have a new message in your * current task - for instance to show "You have a new message in your
* inbox" while the user is working in some other area of the application.
* </li>
* inbox" while the user is working in some other area of the application.</li>
* </ul> * </ul>
* </p> * </p>
* <p> * <p>
* Creates a "humanized" notification message. * Creates a "humanized" notification message.
* *
* @param caption * @param caption
* The message to show
* The message to show
*/ */
public Notification(String caption) { public Notification(String caption) {
this(caption, null, TYPE_HUMANIZED_MESSAGE); this(caption, null, TYPE_HUMANIZED_MESSAGE);
* Creates a notification message of the specified type. * Creates a notification message of the specified type.
* *
* @param caption * @param caption
* The message to show
* The message to show
* @param type * @param type
* The type of message
* The type of message
*/ */
public Notification(String caption, int type) { public Notification(String caption, int type) {
this(caption, null, type); this(caption, null, type);
* smaller description. * smaller description.
* *
* @param caption * @param caption
* The message caption
* The message caption
* @param description * @param description
* The message description
* The message description
*/ */
public Notification(String caption, String description) { public Notification(String caption, String description) {
this(caption, description, TYPE_HUMANIZED_MESSAGE); this(caption, description, TYPE_HUMANIZED_MESSAGE);
* caption and smaller description. * caption and smaller description.
* *
* @param caption * @param caption
* The message caption
* The message caption
* @param description * @param description
* The message description
* The message description
* @param type * @param type
* The type of message
* The type of message
*/ */
public Notification(String caption, String description, int type) { public Notification(String caption, String description, int type) {
this.caption = caption; this.caption = caption;
* Sets the caption part of the notification message * Sets the caption part of the notification message
* *
* @param caption * @param caption
* The message caption
* The message caption
*/ */
public void setCaption(String caption) { public void setCaption(String caption) {
this.caption = caption; this.caption = caption;
* Sets the position of the notification message. * Sets the position of the notification message.
* *
* @param position * @param position
* The desired notification position
* The desired notification position
*/ */
public void setPosition(int position) { public void setPosition(int position) {
this.position = position; this.position = position;
* Sets the icon part of the notification message. * Sets the icon part of the notification message.
* *
* @param icon * @param icon
* The desired message icon
* The desired message icon
*/ */
public void setIcon(Resource icon) { public void setIcon(Resource icon) {
this.icon = icon; this.icon = icon;
* Sets the delay before the notification disappears. * Sets the delay before the notification disappears.
* *
* @param delayMsec * @param delayMsec
* the desired delay in msec, -1 to require the user to
* click the message
* the desired delay in msec, -1 to require the user to click
* the message
*/ */
public void setDelayMsec(int delayMsec) { public void setDelayMsec(int delayMsec) {
this.delayMsec = delayMsec; this.delayMsec = delayMsec;
* Sets the style name for the notification message. * Sets the style name for the notification message.
* *
* @param styleName * @param styleName
* The desired style name.
* The desired style name.
*/ */
public void setStyleName(String styleName) { public void setStyleName(String styleName) {
this.styleName = styleName; this.styleName = styleName;

Loading…
İptal
Kaydet