diff options
author | Jouni Koivuviita <jouni.koivuviita@itmill.com> | 2009-04-29 13:22:53 +0000 |
---|---|---|
committer | Jouni Koivuviita <jouni.koivuviita@itmill.com> | 2009-04-29 13:22:53 +0000 |
commit | 217580bb8afc6068eba951429defb66b4cdcab2f (patch) | |
tree | f35526e300ee6a67845228354efbcc2a35f7e96f /src/com | |
parent | cd4c6d8ed95bb26672363d2e008464961935166b (diff) | |
parent | 8b0cf2389f1152f50cb38832f0b1d84b9e5cdbe4 (diff) | |
download | vaadin-framework-217580bb8afc6068eba951429defb66b4cdcab2f.tar.gz vaadin-framework-217580bb8afc6068eba951429defb66b4cdcab2f.zip |
Major theme refactoring:
-Base theme now completed.
-Default theme is now inherited from the Base theme, all redundant (but mandatory) style properties have been moved to the Base theme.
----
Includes major merges from 6.0 branch as well.
svn changeset:7572/svn branch:theme_2009_03
Diffstat (limited to 'src/com')
180 files changed, 2533 insertions, 1149 deletions
diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java index 60045ac702..049969f9ec 100644 --- a/src/com/itmill/toolkit/Application.java +++ b/src/com/itmill/toolkit/Application.java @@ -4,6 +4,7 @@ package com.itmill.toolkit; +import java.io.Serializable; import java.net.SocketException; import java.net.URL; import java.util.Collection; @@ -84,7 +85,9 @@ import com.itmill.toolkit.ui.Window; * @VERSION@ * @since 3.0 */ -public abstract class Application implements URIHandler, Terminal.ErrorListener { +@SuppressWarnings("serial") +public abstract class Application implements URIHandler, + Terminal.ErrorListener, Serializable { /** * Random window name generator. @@ -758,11 +761,6 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener public class UserChangeEvent extends java.util.EventObject { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3544951069307188281L; - - /** * New user of the application. */ private final Object newUser; @@ -826,7 +824,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * @VERSION@ * @since 3.0 */ - public interface UserChangeListener extends EventListener { + public interface UserChangeListener extends EventListener, Serializable { /** * The <code>applicationUserChanged</code> method Invoked when the @@ -872,11 +870,6 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener */ public class WindowDetachEvent extends EventObject { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3544669568644691769L; - private final Window window; /** @@ -914,11 +907,6 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener */ public class WindowAttachEvent extends EventObject { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3977578104367822392L; - private final Window window; /** @@ -954,7 +942,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * Window attach listener interface. */ - public interface WindowAttachListener { + public interface WindowAttachListener extends Serializable { /** * Window attached @@ -968,7 +956,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * Window detach listener interface. */ - public interface WindowDetachListener { + public interface WindowDetachListener extends Serializable { /** * Window detached. @@ -1186,7 +1174,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * </p> * */ - public static class SystemMessages { + public static class SystemMessages implements Serializable { protected String sessionExpiredURL = null; protected boolean sessionExpiredNotificationEnabled = true; protected String sessionExpiredCaption = "Session Expired"; @@ -1369,7 +1357,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * </p> */ - public static class CustomizedSystemMessages extends SystemMessages { + public static class CustomizedSystemMessages extends SystemMessages + implements Serializable { /** * Sets the URL to go to when the session has expired. @@ -1557,7 +1546,6 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener } public class ApplicationError implements Terminal.ErrorEvent { - private final Throwable throwable; public ApplicationError(Throwable throwable) { @@ -1569,5 +1557,4 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener } } - }
\ No newline at end of file diff --git a/src/com/itmill/toolkit/annotations/AutoGenerated.java b/src/com/itmill/toolkit/annotations/AutoGenerated.java new file mode 100644 index 0000000000..f2483f4146 --- /dev/null +++ b/src/com/itmill/toolkit/annotations/AutoGenerated.java @@ -0,0 +1,15 @@ +package com.itmill.toolkit.annotations;
+
+/**
+ * Marker annotation for automatically generated code elements.
+ *
+ * These elements may be modified or removed by code generation.
+ *
+ * @author IT Mill Ltd.
+ * @version
+ * @VERSION@
+ * @since 6.0
+ */
+public @interface AutoGenerated {
+
+}
diff --git a/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java b/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java index 1aabdfea71..4ac547bb0e 100644 --- a/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java +++ b/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.ui.OrderedLayout; import com.itmill.toolkit.ui.Table;
import com.itmill.toolkit.ui.Button.ClickEvent;
+@SuppressWarnings("serial")
public class ComponentsInTable extends CustomComponent {
public ComponentsInTable(int cols, int rows) {
@@ -40,7 +41,6 @@ public class ComponentsInTable extends CustomComponent { content.add(new Button("b" + i, new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Button b = event.getButton();
System.out.println(event.getButton().getCaption()
+ " click: " + (new Date()).toGMTString());
System.out.println(event.getButton().getApplication());
diff --git a/src/com/itmill/toolkit/automatedtests/SimplestApplication.java b/src/com/itmill/toolkit/automatedtests/SimplestApplication.java index 01f3990bd2..fef17670c1 100644 --- a/src/com/itmill/toolkit/automatedtests/SimplestApplication.java +++ b/src/com/itmill/toolkit/automatedtests/SimplestApplication.java @@ -7,6 +7,7 @@ package com.itmill.toolkit.automatedtests; import com.itmill.toolkit.ui.Label; import com.itmill.toolkit.ui.Window; +@SuppressWarnings("serial") public class SimplestApplication extends com.itmill.toolkit.Application { @Override diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java index f5e81ba9d5..4d35a85bb5 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java @@ -10,7 +10,9 @@ import com.itmill.toolkit.ui.VerticalLayout; * Accordion is a derivative of TabSheet, a vertical tabbed layout that places * the tab contents between the vertical tabs. */ +@SuppressWarnings("serial") public class AccordionExample extends CustomComponent { + public AccordionExample() { // Create a new accordion final Accordion accordion = new Accordion(); diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java index bf61a443c6..f9c3b18fea 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java @@ -21,6 +21,7 @@ import com.itmill.toolkit.ui.Button.ClickEvent; *
* @author IT Mill Ltd.
*/
+@SuppressWarnings("serial")
public class ButtonExample extends CustomComponent implements
Button.ClickListener {
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java index 6cddcd29dc..af4b6e8827 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java @@ -21,6 +21,7 @@ import com.itmill.toolkit.ui.VerticalLayout; *
* @author IT Mill Ltd.
*/
+@SuppressWarnings("serial")
public class ClientCachingExample extends CustomComponent {
private static final String msg = "This example is a (simple) demonstration of client-side caching."
@@ -52,6 +53,7 @@ public class ClientCachingExample extends CustomComponent { layout = new VerticalLayout();
layout.setMargin(true);
l = new Label("Slow label - until cached client side.") {
+
@Override
public void paintContent(PaintTarget target) throws PaintException {
try {
diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java index 03271a98e3..130b9187b6 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.ui.AbstractSelect.Filtering; /** * */ +@SuppressWarnings("serial") public class ComboBoxExample extends CustomComponent { private static final String[] firstnames = new String[] { "John", "Mary", diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java index 22f7d103f4..d5d54fa798 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java @@ -21,6 +21,7 @@ import com.itmill.toolkit.ui.Window.Notification; * @author IT Mill Ltd. * @see com.itmill.toolkit.ui.Window */ +@SuppressWarnings("serial") public class EmbeddedBrowserExample extends VerticalLayout implements Select.ValueChangeListener { diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java index 5edbca6ea2..5e235aea6e 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java @@ -36,10 +36,12 @@ import com.itmill.toolkit.ui.Button.ClickEvent; * @author IT Mill Ltd. * @see com.itmill.toolkit.ui.Window */ +@SuppressWarnings("serial") public class FeatureBrowser extends com.itmill.toolkit.Application implements Select.ValueChangeListener { // Property IDs + private static final Object PROPERTY_ID_CATEGORY = "Category"; private static final Object PROPERTY_ID_NAME = "Name"; private static final Object PROPERTY_ID_DESC = "Description"; @@ -167,7 +169,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements tree.addListener(this); tree.setImmediate(true); tree.expandItemsRecursively(rootId); - for (Iterator i = container.getItemIds().iterator(); i.hasNext();) { + for (Iterator<?> i = container.getItemIds().iterator(); i.hasNext();) { Object id = i.next(); if (container.getChildren(id) == null) { tree.setChildrenAllowed(id, false); @@ -207,6 +209,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements final HorizontalLayout wbLayout = new HorizontalLayout(); Button b = new Button("Open in sub-window", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { Component component = (Component) ts.getComponentIterator() .next(); @@ -231,6 +234,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements b.setStyleName(Button.STYLE_LINK); wbLayout.addComponent(b); b = new Button("Open in native window", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { Component component = (Component) ts.getComponentIterator() .next(); @@ -348,8 +352,8 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements tree.setValue(table.getValue()); table.addListener(this); final Item item = table.getItem(table.getValue()); - final Class c = (Class) item.getItemProperty(PROPERTY_ID_CLASS) - .getValue(); + final Class<?> c = (Class<?>) item.getItemProperty( + PROPERTY_ID_CLASS).getValue(); final Component component = getComponent(c); if (component != null) { final String caption = (String) item.getItemProperty( @@ -369,7 +373,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements } - private Component getComponent(Class componentClass) { + private Component getComponent(Class<?> componentClass) { if (!exampleInstances.containsKey(componentClass)) { try { final Component c = (Component) componentClass.newInstance(); diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java index 90ce0237c7..58e606b654 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java @@ -1,5 +1,7 @@ package com.itmill.toolkit.automatedtests.featurebrowser; +import java.io.Serializable; + import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Validator; import com.itmill.toolkit.data.util.BeanItem; @@ -23,6 +25,7 @@ import com.itmill.toolkit.ui.Button.ClickEvent; * more complex than real use, as it tries to demonstrate more features than * needed in general case. */ +@SuppressWarnings("serial") public class FormExample extends CustomComponent { static final String cities[] = { "Amsterdam", "Berlin", "Helsinki", @@ -61,6 +64,7 @@ public class FormExample extends CustomComponent { } public static class AddressForm extends Form { + public AddressForm(String caption) { setCaption(caption); @@ -114,7 +118,8 @@ public class FormExample extends CustomComponent { * This is example on how to customize field creation. Any kind of field * components could be created on the fly. */ - static class MyFieldFactory extends BaseFieldFactory { + static class MyFieldFactory extends BaseFieldFactory implements + Serializable { @Override public Field createField(Item item, Object propertyId, @@ -159,7 +164,8 @@ public class FormExample extends CustomComponent { * it would be a good idea to implement Item -interface for the datamodel to * make it directly bindable to form (without BeanItem wrapper) */ - public static class Address { + public static class Address implements Serializable { + String name = ""; String streetAddress = ""; String postalCode = ""; diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java index 6052d96642..5b9e4d86eb 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java @@ -36,7 +36,9 @@ import com.itmill.toolkit.ui.Button.ClickListener; * * @author magi */ +@SuppressWarnings("serial") public class GeneratedColumnExample extends CustomComponent { + /** * The business model: fill-up at a gas station. */ @@ -116,12 +118,13 @@ public class GeneratedColumnExample extends CustomComponent { * implementations, as they are not needed in this example. */ public class MySimpleIndexedContainer implements Container, Indexed { - Vector items; + + Vector<BeanItem> items; Object itemtemplate; public MySimpleIndexedContainer(Object itemtemplate) { this.itemtemplate = itemtemplate; - items = new Vector(); // Yeah this is just a test + items = new Vector<BeanItem>(); // Yeah this is just a test } public boolean addContainerProperty(Object propertyId, Class type, @@ -164,7 +167,7 @@ public class GeneratedColumnExample extends CustomComponent { if (itemId instanceof Integer) { int pos = ((Integer) itemId).intValue(); if (pos >= 0 && pos < items.size()) { - Item item = (Item) items.get(pos); + Item item = items.get(pos); // The BeanItem provides the property objects for the items. return item.getItemProperty(propertyId); @@ -185,7 +188,7 @@ public class GeneratedColumnExample extends CustomComponent { if (itemId instanceof Integer) { int pos = ((Integer) itemId).intValue(); if (pos >= 0 && pos < items.size()) { - return (Item) items.get(pos); + return items.get(pos); } } return null; @@ -365,6 +368,7 @@ public class GeneratedColumnExample extends CustomComponent { /** Table column generator for calculating consumption column. */ class ConsumptionColumnGenerator implements Table.ColumnGenerator { + /** * Generates a cell containing value calculated from the item. */ @@ -408,6 +412,7 @@ public class GeneratedColumnExample extends CustomComponent { /** Table column generator for calculating daily cost column. */ class DailyCostColumnGenerator extends ConsumptionColumnGenerator { + @Override public Component generateCell(FillUp fillup, FillUp prev) { double dailycost = fillup.dailyCost(prev); diff --git a/src/com/itmill/toolkit/automatedtests/util/DebugId.java b/src/com/itmill/toolkit/automatedtests/util/DebugId.java index 03dc6cedec..bcf9453109 100644 --- a/src/com/itmill/toolkit/automatedtests/util/DebugId.java +++ b/src/com/itmill/toolkit/automatedtests/util/DebugId.java @@ -4,11 +4,12 @@ package com.itmill.toolkit.automatedtests.util; +import java.io.Serializable; import java.util.HashMap; import com.itmill.toolkit.ui.Component; -public class DebugId { +public class DebugId implements Serializable { private static HashMap debugIds = new HashMap(); diff --git a/src/com/itmill/toolkit/automatedtests/util/Log.java b/src/com/itmill/toolkit/automatedtests/util/Log.java index 8d113e0fe5..d7f98540d1 100644 --- a/src/com/itmill/toolkit/automatedtests/util/Log.java +++ b/src/com/itmill/toolkit/automatedtests/util/Log.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.automatedtests.util; +import java.io.Serializable; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -17,7 +18,7 @@ import java.util.Iterator; * figure out what went wrong. * */ -public class Log { +public class Log implements Serializable { // 3 (errors only) // 2 (+ warnings) diff --git a/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java b/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java index af2c44a40b..03b045e4a4 100644 --- a/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java +++ b/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.automatedtests.util; +import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.Random; @@ -41,7 +42,7 @@ import com.itmill.toolkit.ui.Select; import com.itmill.toolkit.ui.TabSheet; import com.itmill.toolkit.ui.TextField; -public class RandomComponents { +public class RandomComponents implements Serializable { private Random rand = null; diff --git a/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java b/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java index 9912b23d1b..caf44abc89 100644 --- a/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java +++ b/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java @@ -15,10 +15,9 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +@SuppressWarnings("serial") public class StatusServlet extends HttpServlet { - private static final long serialVersionUID = -6764317622536660947L; - public static DateFormat dfHuman = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); diff --git a/src/com/itmill/toolkit/data/Buffered.java b/src/com/itmill/toolkit/data/Buffered.java index 4aba27376d..0550c49146 100644 --- a/src/com/itmill/toolkit/data/Buffered.java +++ b/src/com/itmill/toolkit/data/Buffered.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + import com.itmill.toolkit.data.Validator.InvalidValueException; import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; @@ -42,7 +44,7 @@ import com.itmill.toolkit.terminal.SystemError; * @VERSION@ * @since 3.0 */ -public interface Buffered { +public interface Buffered extends Serializable { /** * Updates all changes since the previous commit to the data source. The @@ -147,13 +149,9 @@ public interface Buffered { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class SourceException extends RuntimeException implements - ErrorMessage { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256720671781630518L; + ErrorMessage, Serializable { /** Source class implementing the buffered interface */ private final Buffered source; diff --git a/src/com/itmill/toolkit/data/BufferedValidatable.java b/src/com/itmill/toolkit/data/BufferedValidatable.java index 756936710a..24fd689122 100644 --- a/src/com/itmill/toolkit/data/BufferedValidatable.java +++ b/src/com/itmill/toolkit/data/BufferedValidatable.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + /** * <p> * This interface defines the combination of <code>Validatable</code> and @@ -16,7 +18,8 @@ package com.itmill.toolkit.data; * @VERSION@ * @since 3.0 */ -public interface BufferedValidatable extends Buffered, Validatable { +public interface BufferedValidatable extends Buffered, Validatable, + Serializable { /** * Tests if the invalid data is committed to datasource. The default is diff --git a/src/com/itmill/toolkit/data/Container.java b/src/com/itmill/toolkit/data/Container.java index 5df1b34f91..7b9bb31971 100644 --- a/src/com/itmill/toolkit/data/Container.java +++ b/src/com/itmill/toolkit/data/Container.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -51,7 +52,7 @@ import java.util.Collection; * @VERSION@ * @since 3.0 */ -public interface Container { +public interface Container extends Serializable { /** * Gets the Item with the given Item ID from the Container. If the Container @@ -70,7 +71,7 @@ public interface Container { * * @return unmodifiable collection of Property IDs */ - public Collection getContainerPropertyIds(); + public Collection<?> getContainerPropertyIds(); /** * Gets the ID's of all Items stored in the Container. The ID's are returned @@ -78,7 +79,7 @@ public interface Container { * * @return unmodifiable collection of Item IDs */ - public Collection getItemIds(); + public Collection<?> getItemIds(); /** * Gets the Property identified by the given itemId and propertyId from the @@ -100,7 +101,7 @@ public interface Container { * ID identifying the Properties * @return data type of the Properties */ - public Class getType(Object propertyId); + public Class<?> getType(Object propertyId); /** * Gets the number of Items in the Container. @@ -181,7 +182,7 @@ public interface Container { * @return <code>true</code> if the operation succeeded, <code>false</code> * if not */ - public boolean addContainerProperty(Object propertyId, Class type, + public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException; /** @@ -334,7 +335,7 @@ public interface Container { * * @return The sortable field ids. */ - Collection getSortableContainerPropertyIds(); + Collection<?> getSortableContainerPropertyIds(); } @@ -418,7 +419,7 @@ public interface Container { * containing the IDs of all other Items that are children in * the container hierarchy */ - public Collection getChildren(Object itemId); + public Collection<?> getChildren(Object itemId); /** * Gets the ID of the parent Item of the specified Item. @@ -438,7 +439,7 @@ public interface Container { * @return An unmodifiable {@link java.util.Collection collection} * containing IDs of all root elements of the container */ - public Collection rootItemIds(); + public Collection<?> rootItemIds(); /** * <p> @@ -568,7 +569,7 @@ public interface Container { * * @since 5.0 */ - public interface Filterable extends Container { + public interface Filterable extends Container, Serializable { /** * Add a filter for given property. @@ -600,7 +601,7 @@ public interface Container { * Interface implemented by viewer classes capable of using a Container as a * data source. */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Container that serves as the data source of the viewer. @@ -631,7 +632,7 @@ public interface Container { * internally. * </p> */ - public interface Editor extends Container.Viewer { + public interface Editor extends Container.Viewer, Serializable { } @@ -641,7 +642,7 @@ public interface Container { * An <code>Event</code> object specifying the Container whose Item set has * changed. */ - public interface ItemSetChangeEvent { + public interface ItemSetChangeEvent extends Serializable { /** * Gets the Property where the event occurred. @@ -652,7 +653,7 @@ public interface Container { } /** Container Item set change listener interface. */ - public interface ItemSetChangeListener { + public interface ItemSetChangeListener extends Serializable { /** * Lets the listener know a Containers Item set has changed. @@ -677,7 +678,7 @@ public interface Container { * be able to implement an interface. * </p> */ - public interface ItemSetChangeNotifier { + public interface ItemSetChangeNotifier extends Serializable { /** * Adds an Item set change listener for the object. @@ -702,7 +703,7 @@ public interface Container { * An <code>Event</code> object specifying the Container whose Property set * has changed. */ - public interface PropertySetChangeEvent { + public interface PropertySetChangeEvent extends Serializable { /** * Retrieves the Container whose contents have been modified. @@ -716,7 +717,7 @@ public interface Container { * The listener interface for receiving <code>PropertySetChangeEvent</code> * objects. */ - public interface PropertySetChangeListener { + public interface PropertySetChangeListener extends Serializable { /** * Notifies this listener that the Containers contents has changed. @@ -744,7 +745,7 @@ public interface Container { * be able to implement an interface. * </p> */ - public interface PropertySetChangeNotifier { + public interface PropertySetChangeNotifier extends Serializable { /** * Registers a new Property set change listener for this Container. diff --git a/src/com/itmill/toolkit/data/Item.java b/src/com/itmill/toolkit/data/Item.java index a8ffc3d7c2..1259d9cbda 100644 --- a/src/com/itmill/toolkit/data/Item.java +++ b/src/com/itmill/toolkit/data/Item.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -18,7 +19,7 @@ import java.util.Collection; * @VERSION@ * @since 3.0 */ -public interface Item { +public interface Item extends Serializable { /** * Gets the Property corresponding to the given Property ID stored in the @@ -37,7 +38,7 @@ public interface Item { * @return unmodifiable collection containing IDs of the Properties stored * the Item */ - public Collection getItemPropertyIds(); + public Collection<?> getItemPropertyIds(); /** * Tries to add a new Property into the Item. @@ -78,7 +79,7 @@ public interface Item { * Interface implemented by viewer classes capable of using an Item as a * data source. */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Item that serves as the data source of the viewer. @@ -105,7 +106,7 @@ public interface Item { * restrict the class from editing the contents of an internally. * </p> */ - public interface Editor extends Item.Viewer { + public interface Editor extends Item.Viewer, Serializable { } @@ -119,7 +120,7 @@ public interface Item { * this event. * </p> */ - public interface PropertySetChangeEvent { + public interface PropertySetChangeEvent extends Serializable { /** * Retrieves the Item whose contents has been modified. @@ -133,7 +134,7 @@ public interface Item { * The listener interface for receiving <code>PropertySetChangeEvent</code> * objects. */ - public interface PropertySetChangeListener { + public interface PropertySetChangeListener extends Serializable { /** * Notifies this listener that the Item's property set has changed. @@ -158,7 +159,7 @@ public interface Item { * be able to implement an interface. * </p> */ - public interface PropertySetChangeNotifier { + public interface PropertySetChangeNotifier extends Serializable { /** * Registers a new property set change listener for this Item. diff --git a/src/com/itmill/toolkit/data/Property.java b/src/com/itmill/toolkit/data/Property.java index 42e438025c..b3277fdde2 100644 --- a/src/com/itmill/toolkit/data/Property.java +++ b/src/com/itmill/toolkit/data/Property.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + /** * <p> * The <code>Property</code> is a simple data object that contains one typed @@ -33,7 +35,7 @@ package com.itmill.toolkit.data; * @VERSION@ * @since 3.0 */ -public interface Property { +public interface Property extends Serializable { /** * Gets the value stored in the Property. The returned object is compatible @@ -91,7 +93,7 @@ public interface Property { * * @return type of the Property */ - public Class getType(); + public Class<?> getType(); /** * Tests if the Property is in read-only mode. In read-only mode calls to @@ -124,14 +126,10 @@ public interface Property { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class ReadOnlyException extends RuntimeException { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257571702287119410L; - - /** * Constructs a new <code>ReadOnlyException</code> without a detail * message. */ @@ -160,14 +158,10 @@ public interface Property { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class ConversionException extends RuntimeException { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257571706666366008L; - - /** * Constructs a new <code>ConversionException</code> without a detail * message. */ @@ -206,7 +200,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Property that serves as the data source of the viewer. @@ -240,7 +234,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface Editor extends Property.Viewer { + public interface Editor extends Property.Viewer, Serializable { } @@ -255,7 +249,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeEvent { + public interface ValueChangeEvent extends Serializable { /** * Retrieves the Property that has been modified. @@ -274,7 +268,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeListener { + public interface ValueChangeListener extends Serializable { /** * Notifies this listener that the Property's value has changed. @@ -304,7 +298,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeNotifier { + public interface ValueChangeNotifier extends Serializable { /** * Registers a new value change listener for this Property. @@ -334,7 +328,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeEvent { + public interface ReadOnlyStatusChangeEvent extends Serializable { /** * Property whose read-only state has changed. @@ -353,7 +347,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeListener { + public interface ReadOnlyStatusChangeListener extends Serializable { /** * Notifies this listener that a Property's read-only status has @@ -385,7 +379,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeNotifier { + public interface ReadOnlyStatusChangeNotifier extends Serializable { /** * Registers a new read-only status change listener for this Property. diff --git a/src/com/itmill/toolkit/data/Validatable.java b/src/com/itmill/toolkit/data/Validatable.java index c8f5afb918..e5c074726b 100644 --- a/src/com/itmill/toolkit/data/Validatable.java +++ b/src/com/itmill/toolkit/data/Validatable.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -19,7 +20,7 @@ import java.util.Collection; * @since 3.0 * @see com.itmill.toolkit.data.Validator */ -public interface Validatable { +public interface Validatable extends Serializable { /** * <p> @@ -54,7 +55,7 @@ public interface Validatable { * * @return collection of validators or <code>null</code> */ - public Collection getValidators(); + public Collection<?> getValidators(); /** * <p> diff --git a/src/com/itmill/toolkit/data/Validator.java b/src/com/itmill/toolkit/data/Validator.java index d0094914ed..55626fb040 100644 --- a/src/com/itmill/toolkit/data/Validator.java +++ b/src/com/itmill/toolkit/data/Validator.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; @@ -25,7 +27,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ -public interface Validator { +public interface Validator extends Serializable { /** * Checks the given value against this validator. If the value is valid this @@ -57,14 +59,10 @@ public interface Validator { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class InvalidValueException extends RuntimeException implements ErrorMessage { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3689073941163422257L; - /** Array of validation errors that are causing the problem. */ private InvalidValueException[] causes = null; @@ -171,11 +169,8 @@ public interface Validator { } + @SuppressWarnings("serial") public class EmptyValueException extends Validator.InvalidValueException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -4488988853486652602L; public EmptyValueException(String message) { super(message); diff --git a/src/com/itmill/toolkit/data/util/BeanItem.java b/src/com/itmill/toolkit/data/util/BeanItem.java index 65bc57a1b3..0df0ea39e8 100644 --- a/src/com/itmill/toolkit/data/util/BeanItem.java +++ b/src/com/itmill/toolkit/data/util/BeanItem.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class BeanItem extends PropertysetItem { /** @@ -97,7 +98,7 @@ public class BeanItem extends PropertysetItem { * @param propertyIds * id of the property. */ - public BeanItem(Object bean, Collection propertyIds) { + public BeanItem(Object bean, Collection<?> propertyIds) { this.bean = bean; diff --git a/src/com/itmill/toolkit/data/util/BeanItemContainer.java b/src/com/itmill/toolkit/data/util/BeanItemContainer.java index 5ba44568ad..99e42e7e76 100644 --- a/src/com/itmill/toolkit/data/util/BeanItemContainer.java +++ b/src/com/itmill/toolkit/data/util/BeanItemContainer.java @@ -1,6 +1,7 @@ package com.itmill.toolkit.data.util; import java.beans.PropertyDescriptor; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -15,7 +16,6 @@ import java.util.Map; import java.util.Set; import com.itmill.toolkit.data.Container; -import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Property; import com.itmill.toolkit.data.Container.Filterable; import com.itmill.toolkit.data.Container.Indexed; @@ -36,6 +36,7 @@ import com.itmill.toolkit.data.Property.ValueChangeNotifier; * * @since 5.4 */ +@SuppressWarnings("serial") public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, ItemSetChangeNotifier, ValueChangeListener { // filtered and unfiltered item IDs @@ -45,42 +46,77 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, // internal data model to obtain property IDs etc. private final Class<BT> type; - private final LinkedHashMap<String, PropertyDescriptor> model; + private transient LinkedHashMap<String, PropertyDescriptor> model; private List<ItemSetChangeListener> itemSetChangeListeners; private Set<Filter> filters = new HashSet<Filter>(); - public BeanItemContainer(Class<BT> type) throws InstantiationException, - IllegalAccessException { + /* Special serialization to handle method references */ + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { + in.defaultReadObject(); + model = BeanItem.getPropertyDescriptors(type); + } + + /** + * Constructs BeanItemContainer for beans of a given type. + * + * @param type + * the class of beans to be used with this containers. + * @throws IllegalArgumentException + * If the type is null + */ + public BeanItemContainer(Class<BT> type) { + if (type == null) { + throw new IllegalArgumentException( + "The type passed to BeanItemContainer must not be null"); + } this.type = type; model = BeanItem.getPropertyDescriptors(type); } /** - * Constructs BeanItemContainer with given collection of beans in it. + * Constructs BeanItemContainer with given collection of beans in it. The + * collection must not be empty or an IllegalArgument is thrown. * - * @param list + * @param collection * non empty {@link Collection} of beans. - * @throws IllegalAccessException - * @throws InstantiationException + * @throws IllegalArgumentException + * If the collection is null or empty. */ - @SuppressWarnings("unchecked") - public BeanItemContainer(Collection<BT> list) - throws InstantiationException, IllegalAccessException { - type = (Class<BT>) list.iterator().next().getClass(); + public BeanItemContainer(Collection<BT> collection) + throws IllegalArgumentException { + if (collection == null || collection.isEmpty()) { + throw new IllegalArgumentException( + "The collection passed to BeanItemContainer must not be null or empty"); + } + + type = (Class<BT>) collection.iterator().next().getClass(); model = BeanItem.getPropertyDescriptors(type); int i = 0; - for (BT bt : list) { + for (BT bt : collection) { addItemAt(i++, bt); } } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int) + */ public Object addItemAt(int index) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } - public Item addItemAt(int index, Object newItemId) + /** + * Adds new item at given index. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int, Object) + */ + public BeanItem addItemAt(int index, Object newItemId) throws UnsupportedOperationException { if (index < 0 || index > size()) { return null; @@ -106,8 +142,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, * Id of the new item to be added. * @return Returns new item or null if the operation fails. */ - @SuppressWarnings("unchecked") - private Item addItemAtInternalIndex(int index, Object newItemId) { + private BeanItem addItemAtInternalIndex(int index, Object newItemId) { // Make sure that the Item has not been created yet if (allItems.contains(newItemId)) { return null; @@ -132,7 +167,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - public Object getIdByIndex(int index) { + public BT getIdByIndex(int index) { return list.get(index); } @@ -140,12 +175,25 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, return list.indexOf(itemId); } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object) + */ public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } - public Item addItemAfter(Object previousItemId, Object newItemId) + /** + * Adds new item after the given item. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object, + * Object) + */ + public BeanItem addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException { // only add if the previous item is visible if (list.contains(previousItemId)) { @@ -156,7 +204,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - public Object firstItemId() { + public BT firstItemId() { if (list.size() > 0) { return list.get(0); } else { @@ -172,7 +220,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, return lastItemId() == itemId; } - public Object lastItemId() { + public BT lastItemId() { if (list.size() > 0) { return list.get(list.size() - 1); } else { @@ -180,7 +228,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - public Object nextItemId(Object itemId) { + public BT nextItemId(Object itemId) { int index = list.indexOf(itemId); if (index >= 0 && index < list.size() - 1) { return list.get(index + 1); @@ -190,7 +238,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - public Object prevItemId(Object itemId) { + public BT prevItemId(Object itemId) { int index = list.indexOf(itemId); if (index > 0) { return list.get(index - 1); @@ -206,11 +254,34 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, throw new UnsupportedOperationException(); } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container#addItem() + */ public Object addItem() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } - public Item addItem(Object itemId) throws UnsupportedOperationException { + /** + * Creates a new Item with the bean into the Container. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container#addItem(Object) + */ + public BeanItem addBean(BT bean) { + return addItem(bean); + } + + /** + * Creates a new Item with the bean into the Container. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container#addItem(Object) + */ + public BeanItem addItem(Object itemId) throws UnsupportedOperationException { if (list.size() > 0) { // add immediately after last visible item int lastIndex = allItems.indexOf(lastItemId()); @@ -229,18 +300,16 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, return beanToItem.get(itemId).getItemProperty(propertyId); } - @SuppressWarnings("unchecked") - public Collection getContainerPropertyIds() { + public Collection<String> getContainerPropertyIds() { return model.keySet(); } - public Item getItem(Object itemId) { + public BeanItem getItem(Object itemId) { return beanToItem.get(itemId); } - @SuppressWarnings("unchecked") - public Collection getItemIds() { - return (Collection) list.clone(); + public Collection<BT> getItemIds() { + return (Collection<BT>) list.clone(); } public Class<?> getType(Object propertyId) { @@ -364,7 +433,6 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - @SuppressWarnings("unchecked") public void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) { if (filters.isEmpty()) { @@ -386,7 +454,6 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, * items, and send a notification if the set of visible items changed in any * way. */ - @SuppressWarnings("unchecked") protected void filterAll() { // avoid notification if the filtering had no effect List<BT> originalItems = list; diff --git a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java index 91dd00fc46..2c88c2ab61 100644 --- a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java +++ b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java @@ -34,6 +34,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ContainerHierarchicalWrapper implements Container.Hierarchical, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier { diff --git a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java index c9e5736b9a..a57fbb1719 100644 --- a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java +++ b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java @@ -31,6 +31,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ContainerOrderedWrapper implements Container.Ordered, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier { diff --git a/src/com/itmill/toolkit/data/util/FilesystemContainer.java b/src/com/itmill/toolkit/data/util/FilesystemContainer.java index f1d5273003..03451ad411 100644 --- a/src/com/itmill/toolkit/data/util/FilesystemContainer.java +++ b/src/com/itmill/toolkit/data/util/FilesystemContainer.java @@ -7,6 +7,7 @@ package com.itmill.toolkit.data.util; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -35,6 +36,7 @@ import com.itmill.toolkit.terminal.Resource; * @author mattitahvonen * */ +@SuppressWarnings("serial") public class FilesystemContainer implements Container.Hierarchical { /** @@ -62,13 +64,13 @@ public class FilesystemContainer implements Container.Hierarchical { */ public static Collection FILE_PROPERTIES; - private static Method FILEITEM_LASTMODIFIED; + private final static Method FILEITEM_LASTMODIFIED; - private static Method FILEITEM_NAME; + private final static Method FILEITEM_NAME; - private static Method FILEITEM_ICON; + private final static Method FILEITEM_ICON; - private static Method FILEITEM_SIZE; + private final static Method FILEITEM_SIZE; static { @@ -741,7 +743,7 @@ public class FilesystemContainer implements Container.Hierarchical { * @VERSION@ * @since 3.0 */ - public class FileExtensionFilter implements FilenameFilter { + public class FileExtensionFilter implements FilenameFilter, Serializable { private final String filter; diff --git a/src/com/itmill/toolkit/data/util/Filter.java b/src/com/itmill/toolkit/data/util/Filter.java index cbb1efae0d..cd31a57b9d 100644 --- a/src/com/itmill/toolkit/data/util/Filter.java +++ b/src/com/itmill/toolkit/data/util/Filter.java @@ -1,5 +1,7 @@ package com.itmill.toolkit.data.util;
+import java.io.Serializable;
+
import com.itmill.toolkit.data.Item;
import com.itmill.toolkit.data.Property;
@@ -9,7 +11,8 @@ import com.itmill.toolkit.data.Property; *
* @since 5.4
*/
-public class Filter {
+@SuppressWarnings("serial")
+public class Filter implements Serializable {
final Object propertyId;
final String filterString;
final boolean ignoreCase;
diff --git a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java index ce46da362a..75ade41e26 100644 --- a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java +++ b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.data.Item; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class HierarchicalContainer extends IndexedContainer implements Container.Hierarchical { diff --git a/src/com/itmill/toolkit/data/util/IndexedContainer.java b/src/com/itmill/toolkit/data/util/IndexedContainer.java index 0dbe44fc46..e649cace8e 100644 --- a/src/com/itmill/toolkit/data/util/IndexedContainer.java +++ b/src/com/itmill/toolkit/data/util/IndexedContainer.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data.util; +import java.io.Serializable; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collection; @@ -45,6 +46,7 @@ import com.itmill.toolkit.data.Property; * @since 3.0 */ +@SuppressWarnings("serial") public class IndexedContainer implements Container.Indexed, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier, Property.ValueChangeNotifier, Container.Sortable, Comparator, @@ -726,12 +728,7 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ private class PropertySetChangeEvent extends EventObject implements - Container.PropertySetChangeEvent { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257002172528079926L; + Container.PropertySetChangeEvent, Serializable { private PropertySetChangeEvent(IndexedContainer source) { super(source); @@ -759,12 +756,8 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ public class ItemSetChangeEvent extends EventObject implements - Container.ItemSetChangeEvent { + Container.ItemSetChangeEvent, Serializable { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3832616279386372147L; private final int addedItemIndex; private ItemSetChangeEvent(IndexedContainer source, int addedItemIndex) { @@ -804,12 +797,7 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ private class PropertyValueChangeEvent extends EventObject implements - Property.ValueChangeEvent { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3833749884498359857L; + Property.ValueChangeEvent, Serializable { private PropertyValueChangeEvent(Property source) { super(source); diff --git a/src/com/itmill/toolkit/data/util/MethodProperty.java b/src/com/itmill/toolkit/data/util/MethodProperty.java index 165d54c902..e8f220be79 100644 --- a/src/com/itmill/toolkit/data/util/MethodProperty.java +++ b/src/com/itmill/toolkit/data/util/MethodProperty.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data.util; +import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -43,18 +44,19 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class MethodProperty implements Property, Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { /** * The object that includes the property the MethodProperty is bound to. */ - private final Object instance; + private transient Object instance; /** * Argument arrays for the getter and setter methods. */ - private Object[] setArgs, getArgs; + private transient Object[] setArgs, getArgs; /** * Is the MethodProperty read-only? @@ -64,7 +66,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, /** * The getter and setter methods. */ - private Method setMethod, getMethod; + private transient Method setMethod, getMethod; /** * Index of the new value in the argument list for the setter method. If the @@ -90,6 +92,59 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, */ private LinkedList valueChangeListeners = null; + /* Special serialization to handle method references */ + private void writeObject(java.io.ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(instance); + out.writeObject(setArgs); + out.writeObject(getArgs); + if (setMethod != null) { + out.writeObject(setMethod.getName()); + out.writeObject(setMethod.getParameterTypes()); + } else { + out.writeObject(""); + out.writeObject(""); + } + if (getMethod != null) { + out.writeObject(getMethod.getName()); + out.writeObject(getMethod.getParameterTypes()); + } else { + out.writeObject(""); + out.writeObject(""); + } + }; + + /* Special serialization to handle method references */ + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { + in.defaultReadObject(); + try { + instance = in.readObject(); + setArgs = (Object[]) in.readObject(); + getArgs = (Object[]) in.readObject(); + String name = (String) in.readObject(); + Class<?>[] paramTypes = (Class<?>[]) in.readObject(); + if (name != null && !name.equals("")) { + setMethod = instance.getClass().getMethod(name, paramTypes); + } else { + setMethod = null; + } + name = (String) in.readObject(); + paramTypes = (Class<?>[]) in.readObject(); + if (name != null && !name.equals("")) { + getMethod = instance.getClass().getMethod(name, paramTypes); + } else { + getMethod = null; + } + } catch (SecurityException e) { + System.err.println("Internal deserialization error"); + e.printStackTrace(); + } catch (NoSuchMethodException e) { + System.err.println("Internal deserialization error"); + e.printStackTrace(); + } + }; + /** * <p> * Creates a new instance of <code>MethodProperty</code> from a named bean @@ -702,11 +757,6 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, public class MethodException extends RuntimeException { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3690473623827855153L; - - /** * Cause of the method exception */ private Throwable cause; @@ -763,11 +813,6 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, implements Property.ReadOnlyStatusChangeEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3258129163305955896L; - - /** * Constructs a new read-only status change event for this object. * * @param source diff --git a/src/com/itmill/toolkit/data/util/ObjectProperty.java b/src/com/itmill/toolkit/data/util/ObjectProperty.java index 1821a815ed..dd31c89606 100644 --- a/src/com/itmill/toolkit/data/util/ObjectProperty.java +++ b/src/com/itmill/toolkit/data/util/ObjectProperty.java @@ -19,6 +19,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ObjectProperty implements Property, Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { @@ -216,11 +217,6 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, Property.ValueChangeEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256718468479725873L; - - /** * Constructs a new value change event for this object. * * @param source @@ -253,11 +249,6 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, implements Property.ReadOnlyStatusChangeEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3907208273529616696L; - - /** * Constructs a new read-only status change event for this object. * * @param source diff --git a/src/com/itmill/toolkit/data/util/PropertyFormatter.java b/src/com/itmill/toolkit/data/util/PropertyFormatter.java index c6454a7f47..0b407bdd52 100644 --- a/src/com/itmill/toolkit/data/util/PropertyFormatter.java +++ b/src/com/itmill/toolkit/data/util/PropertyFormatter.java @@ -31,6 +31,7 @@ import com.itmill.toolkit.data.Property; * @author IT Mill Ltd. * @since 5.3.0 */ +@SuppressWarnings("serial") public abstract class PropertyFormatter implements Property, Property.ValueChangeNotifier, Property.ValueChangeListener, Property.ReadOnlyStatusChangeListener, @@ -229,11 +230,6 @@ public abstract class PropertyFormatter implements Property, Property.ValueChangeEvent { /** - * - */ - private static final long serialVersionUID = -489631310964258710L; - - /** * Constructs a new value change event for this object. * * @param source @@ -264,11 +260,6 @@ public abstract class PropertyFormatter implements Property, implements Property.ReadOnlyStatusChangeEvent { /** - * - */ - private static final long serialVersionUID = 8329395774911454548L; - - /** * Constructs a new read-only status change event for this object. * * @param source diff --git a/src/com/itmill/toolkit/data/util/PropertysetItem.java b/src/com/itmill/toolkit/data/util/PropertysetItem.java index c6c01743e2..d2d2946d4e 100644 --- a/src/com/itmill/toolkit/data/util/PropertysetItem.java +++ b/src/com/itmill/toolkit/data/util/PropertysetItem.java @@ -25,6 +25,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, Cloneable { @@ -165,11 +166,6 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, private class PropertySetChangeEvent extends EventObject implements Item.PropertySetChangeEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257562910590055991L; - private PropertySetChangeEvent(Item source) { super(source); } diff --git a/src/com/itmill/toolkit/data/util/QueryContainer.java b/src/com/itmill/toolkit/data/util/QueryContainer.java index 2c76e58702..2139318e0c 100644 --- a/src/com/itmill/toolkit/data/util/QueryContainer.java +++ b/src/com/itmill/toolkit/data/util/QueryContainer.java @@ -46,6 +46,7 @@ import com.itmill.toolkit.data.Property; * @since 4.0 */ +@SuppressWarnings("serial") public class QueryContainer implements Container, Container.Ordered, Container.Indexed { diff --git a/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java b/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java index 7f26a87861..cecc63a637 100644 --- a/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java +++ b/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java @@ -15,6 +15,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public abstract class AbstractStringValidator extends AbstractValidator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/AbstractValidator.java b/src/com/itmill/toolkit/data/validator/AbstractValidator.java index 93d6ae41fa..c12ea0d848 100644 --- a/src/com/itmill/toolkit/data/validator/AbstractValidator.java +++ b/src/com/itmill/toolkit/data/validator/AbstractValidator.java @@ -15,6 +15,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public abstract class AbstractValidator implements Validator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/CompositeValidator.java b/src/com/itmill/toolkit/data/validator/CompositeValidator.java index 6aa9d07b99..13266d4ca8 100644 --- a/src/com/itmill/toolkit/data/validator/CompositeValidator.java +++ b/src/com/itmill/toolkit/data/validator/CompositeValidator.java @@ -23,6 +23,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class CompositeValidator extends AbstractValidator { /** diff --git a/src/com/itmill/toolkit/data/validator/DoubleValidator.java b/src/com/itmill/toolkit/data/validator/DoubleValidator.java index 56f537f5e4..9ee4fec65e 100644 --- a/src/com/itmill/toolkit/data/validator/DoubleValidator.java +++ b/src/com/itmill/toolkit/data/validator/DoubleValidator.java @@ -10,6 +10,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public class DoubleValidator extends AbstractStringValidator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/EmailValidator.java b/src/com/itmill/toolkit/data/validator/EmailValidator.java index b5abb4d712..f833d5ca77 100644 --- a/src/com/itmill/toolkit/data/validator/EmailValidator.java +++ b/src/com/itmill/toolkit/data/validator/EmailValidator.java @@ -13,6 +13,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public class EmailValidator extends RegexpValidator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/IntegerValidator.java b/src/com/itmill/toolkit/data/validator/IntegerValidator.java index f48e85943e..48afacf8c8 100644 --- a/src/com/itmill/toolkit/data/validator/IntegerValidator.java +++ b/src/com/itmill/toolkit/data/validator/IntegerValidator.java @@ -10,6 +10,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public class IntegerValidator extends AbstractStringValidator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/NullValidator.java b/src/com/itmill/toolkit/data/validator/NullValidator.java index e2038d9017..be2b041bb2 100644 --- a/src/com/itmill/toolkit/data/validator/NullValidator.java +++ b/src/com/itmill/toolkit/data/validator/NullValidator.java @@ -15,6 +15,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class NullValidator implements Validator { private boolean onlyNullAllowed; diff --git a/src/com/itmill/toolkit/data/validator/RegexpValidator.java b/src/com/itmill/toolkit/data/validator/RegexpValidator.java index 56316bea84..eb42a2668a 100644 --- a/src/com/itmill/toolkit/data/validator/RegexpValidator.java +++ b/src/com/itmill/toolkit/data/validator/RegexpValidator.java @@ -21,6 +21,7 @@ import java.util.regex.Pattern; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public class RegexpValidator extends AbstractStringValidator {
private Pattern pattern;
diff --git a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java index e4c28041a7..6105b0e746 100644 --- a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java +++ b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java @@ -13,6 +13,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class StringLengthValidator extends AbstractValidator { private int minLength = -1; diff --git a/src/com/itmill/toolkit/demo/HelloWorld.java b/src/com/itmill/toolkit/demo/HelloWorld.java index d77ce235f2..e9860d5d1d 100644 --- a/src/com/itmill/toolkit/demo/HelloWorld.java +++ b/src/com/itmill/toolkit/demo/HelloWorld.java @@ -1,22 +1,58 @@ package com.itmill.toolkit.demo; import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.MenuBar; +import com.itmill.toolkit.ui.ProgressIndicator; +import com.itmill.toolkit.ui.VerticalLayout; import com.itmill.toolkit.ui.Window; public class HelloWorld extends com.itmill.toolkit.Application { /** - * Init is invoked on application load (when a user accesses the application - * for the first time). + * + */ + private static final long serialVersionUID = -2582480664174220379L; + + /** + * Init is invoked on application load (when a user accesses the application + * for the first time). */ @Override public void init() { - // Main window is the primary browser window + // Main window is the primary browser window final Window main = new Window("Hello window"); setMainWindow(main); - // "Hello world" text is added to window as a Label component + // "Hello world" text is added to window as a Label component main.addComponent(new Label("Hello World!")); + + MenuBar menu = new MenuBar(); + MenuBar.MenuItem file = menu.addItem("File", null); + file.addItem("New...", null); + file.addItem("Open...", null); + file.addItem("Save", null); + file.addItem("Save as...", null); + MenuBar.MenuItem export = file.addItem("Export", null); + export.addItem("As image...", null); + export.addItem("As movie...", null); + menu.addItem("Edit", null); + menu.addItem("View", null); + + main.addComponent(menu); + + ProgressIndicator p = new ProgressIndicator(0.6f); + main.addComponent(p); + p.setPollingInterval(1200000); + + ((VerticalLayout) main.getLayout()).setSpacing(true); + + Window w = new Window("Hidden window"); + w.setStyleName("hidden"); + w.addComponent(new Label("Test label")); + w.setModal(true); + + main.addWindow(w); + } } diff --git a/src/com/itmill/toolkit/demo/ToolkitTunesLayout.java b/src/com/itmill/toolkit/demo/ToolkitTunesLayout.java index fc0036d448..6d81263b39 100644 --- a/src/com/itmill/toolkit/demo/ToolkitTunesLayout.java +++ b/src/com/itmill/toolkit/demo/ToolkitTunesLayout.java @@ -23,6 +23,7 @@ import com.itmill.toolkit.ui.Window.Notification; * @author IT Mill Ltd. * */ +@SuppressWarnings("serial") public class ToolkitTunesLayout extends Application { @Override diff --git a/src/com/itmill/toolkit/demo/sampler/ActiveLink.java b/src/com/itmill/toolkit/demo/sampler/ActiveLink.java index 5432e96fc1..252a7b12e0 100644 --- a/src/com/itmill/toolkit/demo/sampler/ActiveLink.java +++ b/src/com/itmill/toolkit/demo/sampler/ActiveLink.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.demo.sampler; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.HashSet; import java.util.Map; @@ -12,6 +13,7 @@ import com.itmill.toolkit.ui.Link; import com.itmill.toolkit.ui.Button.ClickEvent; import com.itmill.toolkit.ui.Button.ClickListener; +@SuppressWarnings("serial") public class ActiveLink extends Link { private static final String TAG = "activelink"; @@ -110,8 +112,6 @@ public class ActiveLink extends Link { public class LinkActivatedEvent extends Component.Event { - private static final long serialVersionUID = -6406243194818230362L; - private boolean linkOpened; /** @@ -149,7 +149,7 @@ public class ActiveLink extends Link { /** * ActiveLink click listener */ - public interface LinkActivatedListener { + public interface LinkActivatedListener extends Serializable { /** * ActiveLink has been activated. diff --git a/src/com/itmill/toolkit/demo/sampler/Feature.java b/src/com/itmill/toolkit/demo/sampler/Feature.java index a63902aad4..54f5805916 100644 --- a/src/com/itmill/toolkit/demo/sampler/Feature.java +++ b/src/com/itmill/toolkit/demo/sampler/Feature.java @@ -3,6 +3,7 @@ package com.itmill.toolkit.demo.sampler; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.Serializable; import com.itmill.toolkit.ui.Component; @@ -13,7 +14,7 @@ import com.itmill.toolkit.ui.Component; * </p> * */ -abstract public class Feature { +abstract public class Feature implements Serializable { public static final Object PROPERTY_ICON = "Icon"; public static final Object PROPERTY_NAME = "Name"; @@ -54,8 +55,8 @@ abstract public class Feature { * May return null, if the example has no related resources. * </p> * <p> - * The name of the NamedExternalResource will be shown in the UI. <br/> Note - * that Javadoc should be referenced via {@link #getRelatedAPI()}. + * The name of the NamedExternalResource will be shown in the UI. <br/> + * Note that Javadoc should be referenced via {@link #getRelatedAPI()}. * </p> * * @see #getThemeBase() @@ -185,4 +186,18 @@ abstract public class Feature { return getName(); } + @Override + public boolean equals(Object obj) { + // A feature is uniquely identified by its class name + if (obj == null) { + return false; + } + return obj.getClass() == getClass(); + } + + @Override + public int hashCode() { + // A feature is uniquely identified by its class name + return getClass().hashCode(); + } }
\ No newline at end of file diff --git a/src/com/itmill/toolkit/demo/sampler/ModeSwitch.java b/src/com/itmill/toolkit/demo/sampler/ModeSwitch.java index d662d421c9..fb6b1d791e 100644 --- a/src/com/itmill/toolkit/demo/sampler/ModeSwitch.java +++ b/src/com/itmill/toolkit/demo/sampler/ModeSwitch.java @@ -9,6 +9,7 @@ import com.itmill.toolkit.ui.CustomComponent; import com.itmill.toolkit.ui.GridLayout; import com.itmill.toolkit.ui.Button.ClickEvent; +@SuppressWarnings("serial") public class ModeSwitch extends CustomComponent { GridLayout layout = new GridLayout(3, 1); @@ -92,7 +93,6 @@ public class ModeSwitch extends CustomComponent { } public class ModeSwitchEvent extends Event { - private static final long serialVersionUID = -576318750089478453L; public ModeSwitchEvent() { super(ModeSwitch.this); diff --git a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java index 6b24a8bf4f..926cfc5310 100644 --- a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java +++ b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java @@ -21,7 +21,6 @@ import com.itmill.toolkit.terminal.ExternalResource; import com.itmill.toolkit.terminal.Resource; import com.itmill.toolkit.terminal.ThemeResource; import com.itmill.toolkit.terminal.URIHandler; -import com.itmill.toolkit.terminal.gwt.server.WebApplicationContext; import com.itmill.toolkit.ui.Alignment; import com.itmill.toolkit.ui.Button; import com.itmill.toolkit.ui.ComboBox; @@ -45,6 +44,7 @@ import com.itmill.toolkit.ui.PopupView.PopupVisibilityEvent; import com.itmill.toolkit.ui.UriFragmentUtility.FragmentChangedEvent; import com.itmill.toolkit.ui.UriFragmentUtility.FragmentChangedListener; +@SuppressWarnings("serial") public class SamplerApplication extends Application { // All features in one container diff --git a/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java b/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java index a4e3e0f731..22ed844fd4 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.demo.sampler.features.form; +import java.io.Serializable; import java.util.Arrays; import java.util.Date; import java.util.UUID; @@ -21,6 +22,7 @@ import com.itmill.toolkit.ui.VerticalLayout; import com.itmill.toolkit.ui.Window; import com.itmill.toolkit.ui.Button.ClickEvent; +@SuppressWarnings("serial") public class FormPojoExample extends VerticalLayout { // the 'POJO' we're editing @@ -101,7 +103,8 @@ public class FormPojoExample extends VerticalLayout { public PersonFieldFactory() { countries.setWidth("30em"); - countries.setContainerDataSource(ExampleUtil.getStaticISO3166Container()); + countries.setContainerDataSource(ExampleUtil + .getStaticISO3166Container()); countries .setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME); countries.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG); @@ -152,7 +155,8 @@ public class FormPojoExample extends VerticalLayout { } } - public class Person { + public class Person implements Serializable { + private String firstName = ""; private String lastName = ""; private Date birthdate; diff --git a/src/com/itmill/toolkit/demo/sampler/features/table/TableMainFeaturesExample.java b/src/com/itmill/toolkit/demo/sampler/features/table/TableMainFeaturesExample.java index a7cbad0dc1..860467fbba 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/table/TableMainFeaturesExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/table/TableMainFeaturesExample.java @@ -69,6 +69,7 @@ public class TableMainFeaturesExample extends VerticalLayout { Table.ALIGN_CENTER); // Column width + table.setColumnExpandRatio(ExampleUtil.iso3166_PROPERTY_NAME, 1); table.setColumnWidth(ExampleUtil.iso3166_PROPERTY_SHORT, 70); // Collapse one column - the user can make it visible again diff --git a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/Person.java b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/Person.java index 02f670f4f4..80ed848205 100644 --- a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/Person.java +++ b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/Person.java @@ -1,117 +1,119 @@ package com.itmill.toolkit.demo.tutorial.addressbook.data; -public class Person { - private String firstName = ""; - private String lastName = ""; - private String email = ""; - private String phoneNumber = ""; - private String streetAddress = ""; - private Integer postalCode = null; - private String city = ""; - - /** - * @return the firstName - */ - public String getFirstName() { - return firstName; - } - - /** - * @param firstName - * the firstName to set - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * @return the lastName - */ - public String getLastName() { - return lastName; - } - - /** - * @param lastName - * the lastName to set - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * @param email - * the email to set - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * @return the phoneNumber - */ - public String getPhoneNumber() { - return phoneNumber; - } - - /** - * @param phoneNumber - * the phoneNumber to set - */ - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - /** - * @return the streetAddress - */ - public String getStreetAddress() { - return streetAddress; - } - - /** - * @param streetAddress - * the streetAddress to set - */ - public void setStreetAddress(String streetAddress) { - this.streetAddress = streetAddress; - } - - /** - * @return the postalCode - */ - public Integer getPostalCode() { - return postalCode; - } - - /** - * @param postalCode - * the postalCode to set - */ - public void setPostalCode(Integer postalCode) { - this.postalCode = postalCode; - } - - /** - * @return the city - */ - public String getCity() { - return city; - } - - /** - * @param city - * the city to set - */ - public void setCity(String city) { - this.city = city; - } +import java.io.Serializable; + +public class Person implements Serializable { + private String firstName = ""; + private String lastName = ""; + private String email = ""; + private String phoneNumber = ""; + private String streetAddress = ""; + private Integer postalCode = null; + private String city = ""; + + /** + * @return the firstName + */ + public String getFirstName() { + return firstName; + } + + /** + * @param firstName + * the firstName to set + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * @return the lastName + */ + public String getLastName() { + return lastName; + } + + /** + * @param lastName + * the lastName to set + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * @param email + * the email to set + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * @return the phoneNumber + */ + public String getPhoneNumber() { + return phoneNumber; + } + + /** + * @param phoneNumber + * the phoneNumber to set + */ + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + /** + * @return the streetAddress + */ + public String getStreetAddress() { + return streetAddress; + } + + /** + * @param streetAddress + * the streetAddress to set + */ + public void setStreetAddress(String streetAddress) { + this.streetAddress = streetAddress; + } + + /** + * @return the postalCode + */ + public Integer getPostalCode() { + return postalCode; + } + + /** + * @param postalCode + * the postalCode to set + */ + public void setPostalCode(Integer postalCode) { + this.postalCode = postalCode; + } + + /** + * @return the city + */ + public String getCity() { + return city; + } + + /** + * @param city + * the city to set + */ + public void setCity(String city) { + this.city = city; + } }
\ No newline at end of file diff --git a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/PersonContainer.java b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/PersonContainer.java index b627f7e039..3c84ac4764 100644 --- a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/PersonContainer.java +++ b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/PersonContainer.java @@ -1,91 +1,93 @@ package com.itmill.toolkit.demo.tutorial.addressbook.data; +import java.io.Serializable; import java.util.Random; import com.itmill.toolkit.data.util.BeanItemContainer; -public class PersonContainer extends BeanItemContainer<Person> { +public class PersonContainer extends BeanItemContainer<Person> implements + Serializable { - /** - * Natural property order for Person bean. Used in tables and forms. - */ - public static final Object[] NATURAL_COL_ORDER = new Object[] { - "firstName", "lastName", "email", "phoneNumber", "streetAddress", - "postalCode", "city" }; + /** + * Natural property order for Person bean. Used in tables and forms. + */ + public static final Object[] NATURAL_COL_ORDER = new Object[] { + "firstName", "lastName", "email", "phoneNumber", "streetAddress", + "postalCode", "city" }; - /** - * "Human readable" captions for properties in same order as in - * NATURAL_COL_ORDER. - */ - public static final String[] COL_HEADERS_ENGLISH = new String[] { - "First name", "Last name", "Email", "Phone number", - "Street Address", "Postal Code", "City" }; + /** + * "Human readable" captions for properties in same order as in + * NATURAL_COL_ORDER. + */ + public static final String[] COL_HEADERS_ENGLISH = new String[] { + "First name", "Last name", "Email", "Phone number", + "Street Address", "Postal Code", "City" }; - public PersonContainer() throws InstantiationException, - IllegalAccessException { - super(Person.class); - } + public PersonContainer() throws InstantiationException, + IllegalAccessException { + super(Person.class); + } - public static PersonContainer createWithTestData() { - final String[] fnames = { "Peter", "Alice", "Joshua", "Mike", "Olivia", - "Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene", - "Lisa", "Marge" }; - final String[] lnames = { "Smith", "Gordon", "Simpson", "Brown", - "Clavel", "Simons", "Verne", "Scott", "Allison", "Gates", - "Rowling", "Barks", "Ross", "Schneider", "Tate" }; - final String cities[] = { "Amsterdam", "Berlin", "Helsinki", - "Hong Kong", "London", "Luxemburg", "New York", "Oslo", - "Paris", "Rome", "Stockholm", "Tokyo", "Turku" }; - final String streets[] = { "4215 Blandit Av.", "452-8121 Sem Ave", - "279-4475 Tellus Road", "4062 Libero. Av.", "7081 Pede. Ave", - "6800 Aliquet St.", "P.O. Box 298, 9401 Mauris St.", - "161-7279 Augue Ave", "P.O. Box 496, 1390 Sagittis. Rd.", - "448-8295 Mi Avenue", "6419 Non Av.", - "659-2538 Elementum Street", "2205 Quis St.", - "252-5213 Tincidunt St.", "P.O. Box 175, 4049 Adipiscing Rd.", - "3217 Nam Ave", "P.O. Box 859, 7661 Auctor St.", - "2873 Nonummy Av.", "7342 Mi, Avenue", - "539-3914 Dignissim. Rd.", "539-3675 Magna Avenue", - "Ap #357-5640 Pharetra Avenue", "416-2983 Posuere Rd.", - "141-1287 Adipiscing Avenue", "Ap #781-3145 Gravida St.", - "6897 Suscipit Rd.", "8336 Purus Avenue", "2603 Bibendum. Av.", - "2870 Vestibulum St.", "Ap #722 Aenean Avenue", - "446-968 Augue Ave", "1141 Ultricies Street", - "Ap #992-5769 Nunc Street", "6690 Porttitor Avenue", - "Ap #105-1700 Risus Street", - "P.O. Box 532, 3225 Lacus. Avenue", "736 Metus Street", - "414-1417 Fringilla Street", "Ap #183-928 Scelerisque Road", - "561-9262 Iaculis Avenue" }; - PersonContainer c = null; - Random r = new Random(0); - try { - c = new PersonContainer(); - for (int i = 0; i < 100; i++) { - Person p = new Person(); - p.setFirstName(fnames[r.nextInt(fnames.length)]); - p.setLastName(lnames[r.nextInt(lnames.length)]); - p.setCity(cities[r.nextInt(cities.length)]); - p.setEmail(p.getFirstName().toLowerCase() + "." - + p.getLastName().toLowerCase() + "@itmill.com"); - p.setPhoneNumber("+358 02 555 " + r.nextInt(10) + r.nextInt(10) - + r.nextInt(10) + r.nextInt(10)); - int n = r.nextInt(100000); - if (n < 10000) { - n += 10000; - } - p.setPostalCode(n); - p.setStreetAddress(streets[r.nextInt(streets.length)]); - c.addItem(p); - } - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + public static PersonContainer createWithTestData() { + final String[] fnames = { "Peter", "Alice", "Joshua", "Mike", "Olivia", + "Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene", + "Lisa", "Marge" }; + final String[] lnames = { "Smith", "Gordon", "Simpson", "Brown", + "Clavel", "Simons", "Verne", "Scott", "Allison", "Gates", + "Rowling", "Barks", "Ross", "Schneider", "Tate" }; + final String cities[] = { "Amsterdam", "Berlin", "Helsinki", + "Hong Kong", "London", "Luxemburg", "New York", "Oslo", + "Paris", "Rome", "Stockholm", "Tokyo", "Turku" }; + final String streets[] = { "4215 Blandit Av.", "452-8121 Sem Ave", + "279-4475 Tellus Road", "4062 Libero. Av.", "7081 Pede. Ave", + "6800 Aliquet St.", "P.O. Box 298, 9401 Mauris St.", + "161-7279 Augue Ave", "P.O. Box 496, 1390 Sagittis. Rd.", + "448-8295 Mi Avenue", "6419 Non Av.", + "659-2538 Elementum Street", "2205 Quis St.", + "252-5213 Tincidunt St.", "P.O. Box 175, 4049 Adipiscing Rd.", + "3217 Nam Ave", "P.O. Box 859, 7661 Auctor St.", + "2873 Nonummy Av.", "7342 Mi, Avenue", + "539-3914 Dignissim. Rd.", "539-3675 Magna Avenue", + "Ap #357-5640 Pharetra Avenue", "416-2983 Posuere Rd.", + "141-1287 Adipiscing Avenue", "Ap #781-3145 Gravida St.", + "6897 Suscipit Rd.", "8336 Purus Avenue", "2603 Bibendum. Av.", + "2870 Vestibulum St.", "Ap #722 Aenean Avenue", + "446-968 Augue Ave", "1141 Ultricies Street", + "Ap #992-5769 Nunc Street", "6690 Porttitor Avenue", + "Ap #105-1700 Risus Street", + "P.O. Box 532, 3225 Lacus. Avenue", "736 Metus Street", + "414-1417 Fringilla Street", "Ap #183-928 Scelerisque Road", + "561-9262 Iaculis Avenue" }; + PersonContainer c = null; + Random r = new Random(0); + try { + c = new PersonContainer(); + for (int i = 0; i < 100; i++) { + Person p = new Person(); + p.setFirstName(fnames[r.nextInt(fnames.length)]); + p.setLastName(lnames[r.nextInt(lnames.length)]); + p.setCity(cities[r.nextInt(cities.length)]); + p.setEmail(p.getFirstName().toLowerCase() + "." + + p.getLastName().toLowerCase() + "@itmill.com"); + p.setPhoneNumber("+358 02 555 " + r.nextInt(10) + r.nextInt(10) + + r.nextInt(10) + r.nextInt(10)); + int n = r.nextInt(100000); + if (n < 10000) { + n += 10000; + } + p.setPostalCode(n); + p.setStreetAddress(streets[r.nextInt(streets.length)]); + c.addItem(p); + } + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } - return c; - } + return c; + } } diff --git a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/SearchFilter.java b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/SearchFilter.java index 137917a341..1ebd9fa372 100644 --- a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/SearchFilter.java +++ b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/SearchFilter.java @@ -1,41 +1,43 @@ package com.itmill.toolkit.demo.tutorial.addressbook.data; -public class SearchFilter { - - private final String term; - private final Object propertyId; - private String searchName; - - public SearchFilter(Object propertyId, String searchTerm, String name) { - this.propertyId = propertyId; - this.term = searchTerm; - this.searchName = name; - } - - /** - * @return the term - */ - public String getTerm() { - return term; - } - - /** - * @return the propertyId - */ - public Object getPropertyId() { - return propertyId; - } - - /** - * @return the name of the search - */ - public String getSearchName() { - return searchName; - } - - @Override - public String toString() { - return getSearchName(); - } +import java.io.Serializable; + +public class SearchFilter implements Serializable { + + private final String term; + private final Object propertyId; + private String searchName; + + public SearchFilter(Object propertyId, String searchTerm, String name) { + this.propertyId = propertyId; + term = searchTerm; + searchName = name; + } + + /** + * @return the term + */ + public String getTerm() { + return term; + } + + /** + * @return the propertyId + */ + public Object getPropertyId() { + return propertyId; + } + + /** + * @return the name of the search + */ + public String getSearchName() { + return searchName; + } + + @Override + public String toString() { + return getSearchName(); + } } diff --git a/src/com/itmill/toolkit/event/Action.java b/src/com/itmill/toolkit/event/Action.java index 3657a95c28..3c9074bc94 100644 --- a/src/com/itmill/toolkit/event/Action.java +++ b/src/com/itmill/toolkit/event/Action.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.event; +import java.io.Serializable; + import com.itmill.toolkit.terminal.Resource; /** @@ -16,7 +18,8 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ -public class Action { +@SuppressWarnings("serial") +public class Action implements Serializable { /** * Action title. @@ -77,7 +80,7 @@ public class Action { * @VERSION@ * @since 3.0 */ - public interface Handler { + public interface Handler extends Serializable { /** * Gets the list of actions applicable to this handler. @@ -120,7 +123,7 @@ public class Action { * @VERSION@ * @since 3.0 */ - public interface Container { + public interface Container extends Serializable { /** * Registers a new action handler for this container diff --git a/src/com/itmill/toolkit/event/EventRouter.java b/src/com/itmill/toolkit/event/EventRouter.java index 8ccd9b47d0..6d802a6fdc 100644 --- a/src/com/itmill/toolkit/event/EventRouter.java +++ b/src/com/itmill/toolkit/event/EventRouter.java @@ -20,6 +20,7 @@ import java.util.Set; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class EventRouter implements MethodEventSource { /** diff --git a/src/com/itmill/toolkit/event/ItemClickEvent.java b/src/com/itmill/toolkit/event/ItemClickEvent.java index 62d109b583..c68bc98788 100644 --- a/src/com/itmill/toolkit/event/ItemClickEvent.java +++ b/src/com/itmill/toolkit/event/ItemClickEvent.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.event; +import java.io.Serializable; import java.lang.reflect.Method; import com.itmill.toolkit.data.Container; @@ -26,7 +27,8 @@ import com.itmill.toolkit.ui.Component.Event; * TODO extract generic super class/interfaces if we implement some other * click events. */ -public class ItemClickEvent extends Event { +@SuppressWarnings("serial") +public class ItemClickEvent extends Event implements Serializable { public static final int BUTTON_LEFT = MouseEventDetails.BUTTON_LEFT; public static final int BUTTON_MIDDLE = MouseEventDetails.BUTTON_MIDDLE; public static final int BUTTON_RIGHT = MouseEventDetails.BUTTON_RIGHT; @@ -107,11 +109,6 @@ public class ItemClickEvent extends Event { return details.isShiftKey(); } - /** - * Serial generated by eclipse - */ - private static final long serialVersionUID = 3576399524236787971L; - public static final Method ITEM_CLICK_METHOD; static { @@ -124,7 +121,7 @@ public class ItemClickEvent extends Event { } } - public interface ItemClickListener { + public interface ItemClickListener extends Serializable { public void itemClick(ItemClickEvent event); } @@ -134,7 +131,7 @@ public class ItemClickEvent extends Event { * @link {@link Container} interface may support emitting * {@link ItemClickEvent}s. */ - public interface ItemClickSource { + public interface ItemClickSource extends Serializable { /** * Register listener to handle ItemClickEvents. * diff --git a/src/com/itmill/toolkit/event/ListenerMethod.java b/src/com/itmill/toolkit/event/ListenerMethod.java index 1984dd8380..b0732398c7 100644 --- a/src/com/itmill/toolkit/event/ListenerMethod.java +++ b/src/com/itmill/toolkit/event/ListenerMethod.java @@ -4,6 +4,9 @@ package com.itmill.toolkit.event; +import java.io.IOException; +import java.io.NotSerializableException; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Arrays; import java.util.EventListener; @@ -35,24 +38,25 @@ import java.util.EventObject; * @VERSION@ * @since 3.0 */ -public class ListenerMethod implements EventListener { +@SuppressWarnings("serial") +public class ListenerMethod implements EventListener, Serializable { /** * Type of the event that should trigger this listener. Also the subclasses * of this class are accepted to trigger the listener. */ - private final Class eventType; + private final Class<?> eventType; /** * The object containing the trigger method. */ - private final Object object; + private Object object; /** * The trigger method to call when an event passing the given criteria * fires. */ - private final Method method; + private transient Method method; /** * Optional argument set to pass to the trigger method. @@ -66,6 +70,67 @@ public class ListenerMethod implements EventListener { */ private int eventArgumentIndex; + /* Special serialization to handle method references */ + private void writeObject(java.io.ObjectOutputStream out) throws IOException { + try { + out.defaultWriteObject(); + String name = method.getName(); + Class<?>[] paramTypes = method.getParameterTypes(); + out.writeObject(name); + out.writeObject(paramTypes); + } catch (NotSerializableException e) { + System.err + .println("Fatal error in serialization of the application: Class " + + object.getClass().getName() + + " must implement serialization."); + throw e; + } + + }; + + /* Special serialization to handle method references */ + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { + in.defaultReadObject(); + try { + String name = (String) in.readObject(); + Class<?>[] paramTypes = (Class<?>[]) in.readObject(); + // We can not use getMethod directly as we want to support anonymous + // inner classes + method = findHighestMethod(object.getClass(), name, paramTypes); + } catch (SecurityException e) { + System.err.println("Internal deserialization error"); + e.printStackTrace(); + } + }; + + private static Method findHighestMethod(Class<?> cls, String method, + Class<?>[] paramTypes) { + Class<?>[] ifaces = cls.getInterfaces(); + for (int i = 0; i < ifaces.length; i++) { + Method ifaceMethod = findHighestMethod(ifaces[i], method, + paramTypes); + if (ifaceMethod != null) { + return ifaceMethod; + } + } + if (cls.getSuperclass() != null) { + Method parentMethod = findHighestMethod(cls.getSuperclass(), + method, paramTypes); + if (parentMethod != null) { + return parentMethod; + } + } + Method[] methods = cls.getMethods(); + for (int i = 0; i < methods.length; i++) { + // we ignore parameter types for now - you need to add this + if (methods[i].getName().equals(method)) { + return methods[i]; + } + } + return null; + } + /** * <p> * Constructs a new event listener from a trigger method, it's arguments and @@ -98,7 +163,7 @@ public class ListenerMethod implements EventListener { * 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) throws java.lang.IllegalArgumentException { @@ -157,7 +222,7 @@ public class ListenerMethod implements EventListener { * 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) throws java.lang.IllegalArgumentException { @@ -218,7 +283,7 @@ public class ListenerMethod implements EventListener { * 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 { // Check that the object is of correct type @@ -262,7 +327,7 @@ public class ListenerMethod implements EventListener { * 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 { // Find the correct method @@ -307,7 +372,7 @@ public class ListenerMethod implements EventListener { * 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 { // Checks that the object is of correct type @@ -320,7 +385,7 @@ public class ListenerMethod implements EventListener { this.method = method; eventArgumentIndex = -1; - final Class[] params = method.getParameterTypes(); + final Class<?>[] params = method.getParameterTypes(); if (params.length == 0) { arguments = new Object[0]; @@ -358,7 +423,7 @@ public class ListenerMethod implements EventListener { * 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 { // Finds the correct method @@ -378,7 +443,7 @@ public class ListenerMethod implements EventListener { this.method = method; eventArgumentIndex = -1; - final Class[] params = method.getParameterTypes(); + final Class<?>[] params = method.getParameterTypes(); if (params.length == 0) { arguments = new Object[0]; @@ -447,7 +512,7 @@ public class ListenerMethod implements EventListener { * 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)); } @@ -469,7 +534,7 @@ public class ListenerMethod implements EventListener { * the event type stored in this object and <code>method</code> * equals with the method stored in this object */ - public boolean matches(Class eventType, Object target, Method method) { + public boolean matches(Class<?> eventType, Object target, Method method) { return (target == object) && (eventType.equals(this.eventType) && method .equals(this.method)); @@ -524,12 +589,8 @@ public class ListenerMethod implements EventListener { * @VERSION@ * @since 3.0 */ - public class MethodException extends RuntimeException { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257005445242894135L; + public class MethodException extends RuntimeException implements + Serializable { private final Throwable cause; diff --git a/src/com/itmill/toolkit/event/MethodEventSource.java b/src/com/itmill/toolkit/event/MethodEventSource.java index 8b5d9d797f..16aca65208 100644 --- a/src/com/itmill/toolkit/event/MethodEventSource.java +++ b/src/com/itmill/toolkit/event/MethodEventSource.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.event; +import java.io.Serializable; import java.lang.reflect.Method; /** @@ -22,7 +23,7 @@ import java.lang.reflect.Method; * @VERSION@ * @since 3.0 */ -public interface MethodEventSource { +public interface MethodEventSource extends Serializable { /** * <p> diff --git a/src/com/itmill/toolkit/event/ShortcutAction.java b/src/com/itmill/toolkit/event/ShortcutAction.java index 4b4cca83b5..6090889ada 100644 --- a/src/com/itmill/toolkit/event/ShortcutAction.java +++ b/src/com/itmill/toolkit/event/ShortcutAction.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.event; +import java.io.Serializable; + import com.itmill.toolkit.terminal.Resource; /** @@ -13,6 +15,7 @@ import com.itmill.toolkit.terminal.Resource; * @version * @since 4.0.1 */ +@SuppressWarnings("serial") public class ShortcutAction extends Action { private final int keyCode; @@ -43,7 +46,7 @@ public class ShortcutAction extends Action { * Key codes that can be used for shortcuts * */ - public interface KeyCode { + public interface KeyCode extends Serializable { public static final int ENTER = 13; public static final int ESCAPE = 27; @@ -167,13 +170,15 @@ public class ShortcutAction extends Action { public static final int NUM8 = 56; public static final int NUM9 = 57; + + public static final int SPACEBAR = 32; } /** * Modifier key constants * */ - public interface ModifierKey { + public interface ModifierKey extends Serializable { public static final int SHIFT = 16; public static final int CTRL = 17; diff --git a/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java b/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java index 72aecc4464..e16fea21cb 100644 --- a/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java +++ b/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java @@ -63,14 +63,12 @@ public class ITMillToolkitDesktopMode { final String url = ITMillToolkitWebMode.runServer(serverArgs, "Desktop Mode"); - // Open browser into application URL - if (url != null) { + if (!serverArgs.containsKey("nogui") && url != null) { + + // Open browser into application URL BrowserLauncher.openBrowser(url); - } - - // Open control dialog - if (url != null) { + // Open control dialog /* * Swing components should never be manipulated outside the event * dispatch thread. diff --git a/src/com/itmill/toolkit/service/ApplicationContext.java b/src/com/itmill/toolkit/service/ApplicationContext.java index 0fc76c13cd..3bc0a29822 100644 --- a/src/com/itmill/toolkit/service/ApplicationContext.java +++ b/src/com/itmill/toolkit/service/ApplicationContext.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.service; import java.io.File; +import java.io.Serializable; import java.util.Collection; import com.itmill.toolkit.Application; @@ -19,7 +20,7 @@ import com.itmill.toolkit.Application; * @VERSION@ * @since 3.1 */ -public interface ApplicationContext { +public interface ApplicationContext extends Serializable { /** * Returns application context base directory. @@ -68,7 +69,7 @@ public interface ApplicationContext { * between the client and the application. * */ - public interface TransactionListener { + public interface TransactionListener extends Serializable { /** * Invoked at the beginning of every transaction. diff --git a/src/com/itmill/toolkit/service/FileTypeResolver.java b/src/com/itmill/toolkit/service/FileTypeResolver.java index 7c57fece6f..6a53441161 100644 --- a/src/com/itmill/toolkit/service/FileTypeResolver.java +++ b/src/com/itmill/toolkit/service/FileTypeResolver.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.service; import java.io.File; +import java.io.Serializable; import java.util.Collections; import java.util.Hashtable; import java.util.Map; @@ -25,7 +26,8 @@ import com.itmill.toolkit.terminal.ThemeResource; * @VERSION@ * @since 3.0 */ -public class FileTypeResolver { +@SuppressWarnings("serial") +public class FileTypeResolver implements Serializable { /** * Default icon given if no icon is specified for a mime-type. @@ -138,6 +140,7 @@ public class FileTypeResolver { + "image/jpeg jpeg jpg jpe," + "image/pcx pcx," + "image/png png," + + "image/svg+xml svg svgz," + "image/tiff tiff tif," + "image/vnd.wap.wbmp wbmp," + "image/x-cmu-raster ras," diff --git a/src/com/itmill/toolkit/terminal/ApplicationResource.java b/src/com/itmill/toolkit/terminal/ApplicationResource.java index 94f3a21a2e..c67de1a7a4 100644 --- a/src/com/itmill/toolkit/terminal/ApplicationResource.java +++ b/src/com/itmill/toolkit/terminal/ApplicationResource.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + import com.itmill.toolkit.Application; /** @@ -21,7 +23,7 @@ import com.itmill.toolkit.Application; * @VERSION@ * @since 3.0 */ -public interface ApplicationResource extends Resource { +public interface ApplicationResource extends Resource, Serializable { /** * Default cache time. diff --git a/src/com/itmill/toolkit/terminal/ClassResource.java b/src/com/itmill/toolkit/terminal/ClassResource.java index 60ac7e311f..a8062940bb 100644 --- a/src/com/itmill/toolkit/terminal/ClassResource.java +++ b/src/com/itmill/toolkit/terminal/ClassResource.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + import com.itmill.toolkit.Application; import com.itmill.toolkit.service.FileTypeResolver; @@ -20,7 +22,8 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ -public class ClassResource implements ApplicationResource { +@SuppressWarnings("serial") +public class ClassResource implements ApplicationResource, Serializable { /** * Default buffer size for this stream resource. diff --git a/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java b/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java index 47a50b1e26..7af3ac4628 100644 --- a/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java +++ b/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -17,7 +18,8 @@ import java.util.List; * @VERSION@ * @since 3.0 */ -public class CompositeErrorMessage implements ErrorMessage { +@SuppressWarnings("serial") +public class CompositeErrorMessage implements ErrorMessage, Serializable { /** * Array of all the errors. diff --git a/src/com/itmill/toolkit/terminal/DownloadStream.java b/src/com/itmill/toolkit/terminal/DownloadStream.java index 1703dc2b92..8b91e15bb1 100644 --- a/src/com/itmill/toolkit/terminal/DownloadStream.java +++ b/src/com/itmill/toolkit/terminal/DownloadStream.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal; import java.io.InputStream; +import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -17,7 +18,8 @@ import java.util.Map; * @VERSION@ * @since 3.0 */ -public class DownloadStream { +@SuppressWarnings("serial") +public class DownloadStream implements Serializable { /** * Maximum cache time. diff --git a/src/com/itmill/toolkit/terminal/ErrorMessage.java b/src/com/itmill/toolkit/terminal/ErrorMessage.java index d3cf40ba6d..5b07dcc4f7 100644 --- a/src/com/itmill/toolkit/terminal/ErrorMessage.java +++ b/src/com/itmill/toolkit/terminal/ErrorMessage.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * Interface for rendering error messages to terminal. All the visible errors * shown to user must implement this interface. @@ -13,7 +15,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface ErrorMessage extends Paintable { +public interface ErrorMessage extends Paintable, Serializable { /** * Error code for system errors and bugs. diff --git a/src/com/itmill/toolkit/terminal/ExternalResource.java b/src/com/itmill/toolkit/terminal/ExternalResource.java index 1a210a059e..80feae3d00 100644 --- a/src/com/itmill/toolkit/terminal/ExternalResource.java +++ b/src/com/itmill/toolkit/terminal/ExternalResource.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.net.URL; import com.itmill.toolkit.service.FileTypeResolver; @@ -18,7 +19,7 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ -public class ExternalResource implements Resource { +public class ExternalResource implements Resource, Serializable { /** * Url of the download. diff --git a/src/com/itmill/toolkit/terminal/FileResource.java b/src/com/itmill/toolkit/terminal/FileResource.java index 571d22ecfb..6fa26405e4 100644 --- a/src/com/itmill/toolkit/terminal/FileResource.java +++ b/src/com/itmill/toolkit/terminal/FileResource.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class FileResource implements ApplicationResource { /** diff --git a/src/com/itmill/toolkit/terminal/KeyMapper.java b/src/com/itmill/toolkit/terminal/KeyMapper.java index de6fbd27ba..4747cd4e98 100644 --- a/src/com/itmill/toolkit/terminal/KeyMapper.java +++ b/src/com/itmill/toolkit/terminal/KeyMapper.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.Hashtable; /** @@ -15,7 +16,8 @@ import java.util.Hashtable; * @VERSION@ * @since 3.0 */ -public class KeyMapper { +@SuppressWarnings("serial") +public class KeyMapper implements Serializable { private int lastKey = 0; diff --git a/src/com/itmill/toolkit/terminal/PaintException.java b/src/com/itmill/toolkit/terminal/PaintException.java index c421edf94a..8464a418bf 100644 --- a/src/com/itmill/toolkit/terminal/PaintException.java +++ b/src/com/itmill/toolkit/terminal/PaintException.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal; import java.io.IOException; +import java.io.Serializable; /** * <code>PaintExcepection</code> is thrown if painting of a component fails. @@ -14,12 +15,8 @@ import java.io.IOException; * @VERSION@ * @since 3.0 */ -public class PaintException extends IOException { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3762535607221891897L; +@SuppressWarnings("serial") +public class PaintException extends IOException implements Serializable { /** * Constructs an instance of <code>PaintExeception</code> with the specified diff --git a/src/com/itmill/toolkit/terminal/PaintTarget.java b/src/com/itmill/toolkit/terminal/PaintTarget.java index 43f134bfd8..b232325831 100644 --- a/src/com/itmill/toolkit/terminal/PaintTarget.java +++ b/src/com/itmill/toolkit/terminal/PaintTarget.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * This interface defines the methods for painting XML to the UIDL stream. * @@ -12,7 +14,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface PaintTarget { +public interface PaintTarget extends Serializable{ /** * Prints single XMLsection. diff --git a/src/com/itmill/toolkit/terminal/Paintable.java b/src/com/itmill/toolkit/terminal/Paintable.java index 61dbc27fc5..be09df281a 100644 --- a/src/com/itmill/toolkit/terminal/Paintable.java +++ b/src/com/itmill/toolkit/terminal/Paintable.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.EventObject; /** @@ -16,7 +17,7 @@ import java.util.EventObject; * @VERSION@ * @since 3.0 */ -public interface Paintable extends java.util.EventListener { +public interface Paintable extends java.util.EventListener, Serializable { /** * <p> @@ -65,14 +66,10 @@ public interface Paintable extends java.util.EventListener { * This is typically done when the <code>paint</code> method would return * dissimilar UIDL from the previous call of the method. */ + @SuppressWarnings("serial") public class RepaintRequestEvent extends EventObject { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256725095530442805L; - - /** * Constructs a new event. * * @param source @@ -99,7 +96,7 @@ public interface Paintable extends java.util.EventListener { * when the <code>paint</code> method would return dissimilar UIDL from the * previous call of the method. */ - public interface RepaintRequestListener { + public interface RepaintRequestListener extends Serializable { /** * Receives repaint request events. diff --git a/src/com/itmill/toolkit/terminal/ParameterHandler.java b/src/com/itmill/toolkit/terminal/ParameterHandler.java index 640292bc97..88ba0ae1c2 100644 --- a/src/com/itmill/toolkit/terminal/ParameterHandler.java +++ b/src/com/itmill/toolkit/terminal/ParameterHandler.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.Map; /** @@ -24,7 +25,7 @@ import java.util.Map; * @VERSION@ * @since 3.0 */ -public interface ParameterHandler { +public interface ParameterHandler extends Serializable{ /** * <p> diff --git a/src/com/itmill/toolkit/terminal/Resource.java b/src/com/itmill/toolkit/terminal/Resource.java index 5cf07729aa..7e29ae250a 100644 --- a/src/com/itmill/toolkit/terminal/Resource.java +++ b/src/com/itmill/toolkit/terminal/Resource.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * <code>Resource</code> provided to the client terminal. Support for actually * displaying the resource type is left to the terminal. @@ -13,7 +15,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface Resource { +public interface Resource extends Serializable{ /** * Gets the MIME type of the resource. diff --git a/src/com/itmill/toolkit/terminal/Scrollable.java b/src/com/itmill/toolkit/terminal/Scrollable.java index 4b9260c70d..3ab1a5df5c 100644 --- a/src/com/itmill/toolkit/terminal/Scrollable.java +++ b/src/com/itmill/toolkit/terminal/Scrollable.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * <p> * This interface is implemented by all visual objects that can be scrolled. The @@ -15,7 +17,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface Scrollable { +public interface Scrollable extends Serializable { /** * Gets scroll left offset. diff --git a/src/com/itmill/toolkit/terminal/Sizeable.java b/src/com/itmill/toolkit/terminal/Sizeable.java index e4030be7bc..8b83012157 100644 --- a/src/com/itmill/toolkit/terminal/Sizeable.java +++ b/src/com/itmill/toolkit/terminal/Sizeable.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * Interface to be implemented by components wishing to display some object that * may be dynamically resized during runtime. @@ -13,7 +15,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface Sizeable { +public interface Sizeable extends Serializable{ /** * Unit code representing pixels. diff --git a/src/com/itmill/toolkit/terminal/StreamResource.java b/src/com/itmill/toolkit/terminal/StreamResource.java index b1ad8f9c15..49bcc81d6f 100644 --- a/src/com/itmill/toolkit/terminal/StreamResource.java +++ b/src/com/itmill/toolkit/terminal/StreamResource.java @@ -20,6 +20,7 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class StreamResource implements ApplicationResource { /** diff --git a/src/com/itmill/toolkit/terminal/SystemError.java b/src/com/itmill/toolkit/terminal/SystemError.java index b5d2fae5d0..8f7f19a5a6 100644 --- a/src/com/itmill/toolkit/terminal/SystemError.java +++ b/src/com/itmill/toolkit/terminal/SystemError.java @@ -18,14 +18,10 @@ import java.io.StringWriter; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class SystemError extends RuntimeException implements ErrorMessage { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256445789512675891L; - - /** * The cause of the system error. The cause is stored separately as JDK 1.3 * does not support causes natively. */ diff --git a/src/com/itmill/toolkit/terminal/Terminal.java b/src/com/itmill/toolkit/terminal/Terminal.java index e7a61b6457..5f136679d9 100644 --- a/src/com/itmill/toolkit/terminal/Terminal.java +++ b/src/com/itmill/toolkit/terminal/Terminal.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * Interface for different terminal types. * @@ -12,7 +14,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface Terminal { +public interface Terminal extends Serializable { /** * Gets the name of the default theme. @@ -38,7 +40,7 @@ public interface Terminal { /** * Terminal error event. */ - public interface ErrorEvent { + public interface ErrorEvent extends Serializable{ /** * Gets the contained throwable. @@ -50,7 +52,7 @@ public interface Terminal { /** * Terminal error listener interface. */ - public interface ErrorListener { + public interface ErrorListener extends Serializable{ /** * Invoked when terminal error occurs. diff --git a/src/com/itmill/toolkit/terminal/ThemeResource.java b/src/com/itmill/toolkit/terminal/ThemeResource.java index 809f5a2bc8..1fcf0dd5f3 100644 --- a/src/com/itmill/toolkit/terminal/ThemeResource.java +++ b/src/com/itmill/toolkit/terminal/ThemeResource.java @@ -17,6 +17,7 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ThemeResource implements Resource { /** diff --git a/src/com/itmill/toolkit/terminal/URIHandler.java b/src/com/itmill/toolkit/terminal/URIHandler.java index fc72c0c204..46fb322b0d 100644 --- a/src/com/itmill/toolkit/terminal/URIHandler.java +++ b/src/com/itmill/toolkit/terminal/URIHandler.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.net.URL; /** @@ -19,7 +20,7 @@ import java.net.URL; * @VERSION@ * @since 3.0 */ -public interface URIHandler { +public interface URIHandler extends Serializable { /** * Handles a given relative URI. If the URI handling wants to emit a diff --git a/src/com/itmill/toolkit/terminal/UploadStream.java b/src/com/itmill/toolkit/terminal/UploadStream.java index b15bb1db15..225740ed43 100644 --- a/src/com/itmill/toolkit/terminal/UploadStream.java +++ b/src/com/itmill/toolkit/terminal/UploadStream.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal; import java.io.InputStream; +import java.io.Serializable; /** * Defines a variable type, that is used for passing uploaded files from @@ -16,7 +17,7 @@ import java.io.InputStream; * @VERSION@ * @since 3.0 */ -public interface UploadStream { +public interface UploadStream extends Serializable { /** * Gets the name of the stream. diff --git a/src/com/itmill/toolkit/terminal/UserError.java b/src/com/itmill/toolkit/terminal/UserError.java index 92b33e4f8b..e7c2df9004 100644 --- a/src/com/itmill/toolkit/terminal/UserError.java +++ b/src/com/itmill/toolkit/terminal/UserError.java @@ -13,6 +13,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class UserError implements ErrorMessage { /** diff --git a/src/com/itmill/toolkit/terminal/VariableOwner.java b/src/com/itmill/toolkit/terminal/VariableOwner.java index c97497aede..fc1fe2ba16 100644 --- a/src/com/itmill/toolkit/terminal/VariableOwner.java +++ b/src/com/itmill/toolkit/terminal/VariableOwner.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.Map; /** @@ -20,7 +21,7 @@ import java.util.Map; * @VERSION@ * @since 3.0 */ -public interface VariableOwner { +public interface VariableOwner extends Serializable { /** * Called when one or more variables handled by the implementing class are diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java index f3541b5bb3..cb6874075c 100755 --- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java @@ -899,6 +899,12 @@ public class ApplicationConnection { } public void updateVariable(String paintableId, String variableName, + Paintable newValue, boolean immediate) { + String pid = (newValue != null) ? getPid(newValue) : null; + addVariableToQueue(paintableId, variableName, pid, immediate, 'p'); + } + + public void updateVariable(String paintableId, String variableName, String newValue, boolean immediate) { addVariableToQueue(paintableId, variableName, newValue, immediate, 's'); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java b/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java index b0078868dc..c4f44c9440 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java @@ -10,12 +10,21 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IView; import com.itmill.toolkit.terminal.gwt.client.ui.SubPartAware; /** - * Helper class for TestingTools that builds appropriate locators for browser - * bot. + * ComponentLocator provides methods for uniquely identifying DOM elements using + * string expressions. This class is EXPERIMENTAL and subject to change. */ public class ComponentLocator { + /** + * Separator used in the string expression between a parent and a child + * widget. + */ private static final String PARENTCHILD_SEPARATOR = "/"; + + /** + * Separator used in the string expression between a widget and the widget's + * sub part. NOT CURRENTLY IN USE. + */ private static final String SUBPART_SEPARATOR = "#"; private ApplicationConnection client; @@ -24,6 +33,19 @@ public class ComponentLocator { this.client = client; } + /** + * EXPERIMENTAL. + * + * Generates a string expression (path) which uniquely identifies the target + * element . The getElementByPath method can be used for the inverse + * operation, i.e. locating an element based on the string expression. + * + * @since 5.4 + * @param targetElement + * The element to generate a path for. + * @return A string expression uniquely identifying the target element or + * null if a string expression could not be created. + */ public String getPathForElement(Element targetElement) { String pid = null; @@ -130,6 +152,21 @@ public class ComponentLocator { return path; } + /** + * EXPERIMENTAL. + * + * Locates an element by using a string expression (path) which uniquely + * identifies the element. The getPathForElement method can be used for the + * inverse operation, i.e. generating a string expression for a target + * element. + * + * @since 5.4 + * @param path + * The string expression which uniquely identifies the target + * element. + * @return The DOM element identified by the path or null if the element + * could not be located. + */ public Element getElementByPath(String path) { // ApplicationConnection.getConsole() // .log("getElementByPath(" + path + ")"); @@ -169,6 +206,10 @@ public class ComponentLocator { } private String getPathForWidget(Widget w) { + if (w == null) { + return ""; + } + String pid = client.getPid(w.getElement()); if (isStaticPid(pid)) { return pid; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java b/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java index 39c38bdd49..25a7058f5d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java @@ -4,13 +4,9 @@ package com.itmill.toolkit.terminal.gwt.client;
+@SuppressWarnings("serial")
public class LocaleNotLoadedException extends Exception {
- /**
- * Serial generated by Eclipse.
- */
- private static final long serialVersionUID = 2005227056545210838L;
-
public LocaleNotLoadedException(String locale) {
super(locale);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java index fb9c989afd..0b75a98c3b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java @@ -417,9 +417,9 @@ public class UIDL { return s; } - public Set getStringArrayVariableAsSet(String name) { + public Set<String> getStringArrayVariableAsSet(String name) { final JSONArray a = getArrayVariable(name); - final HashSet s = new HashSet(); + final HashSet<String> s = new HashSet<String>(); for (int i = 0; i < a.size(); i++) { s.add(((JSONString) a.get(i)).stringValue()); } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java index fc1f14cb83..8b10854959 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java @@ -32,7 +32,7 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { private DivElement marginElement; - private Element canvas; + protected final Element canvas = DOM.createDiv(); private int excessPixelsHorizontal; @@ -42,7 +42,7 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { private Map<String, AbsoluteWrapper> pidToComponentWrappper = new HashMap<String, AbsoluteWrapper>(); - private ApplicationConnection client; + protected ApplicationConnection client; private boolean rendering; @@ -50,7 +50,6 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { setElement(Document.get().createDivElement()); setStyleName(CLASSNAME); marginElement = Document.get().createDivElement(); - canvas = DOM.createDiv(); canvas.getStyle().setProperty("position", "relative"); marginElement.appendChild(canvas); getElement().appendChild(marginElement); @@ -180,8 +179,20 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { // inside marginals) canvas.getStyle().setProperty("width", width); - if (!rendering && BrowserInfo.get().isIE6()) { - relayoutWrappersForIe6(); + if (!rendering) { + if (BrowserInfo.get().isIE6()) { + relayoutWrappersForIe6(); + } + relayoutRelativeChildren(); + } + } + + private void relayoutRelativeChildren() { + for (Widget widget : getChildren()) { + if (widget instanceof Paintable) { + Paintable new_name = (Paintable) widget; + client.handleComponentRelativeSize(widget); + } } } @@ -192,8 +203,11 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { // inside marginals) canvas.getStyle().setProperty("height", height); - if (!rendering && BrowserInfo.get().isIE6()) { - relayoutWrappersForIe6(); + if (!rendering) { + if (BrowserInfo.get().isIE6()) { + relayoutWrappersForIe6(); + } + relayoutRelativeChildren(); } } @@ -228,7 +242,14 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { if (getWidget() != paintable) { setWidget((Widget) paintable); } - paintable.updateFromUIDL(componentUIDL.getChildUIDL(0), client); + UIDL childUIDL = componentUIDL.getChildUIDL(0); + paintable.updateFromUIDL(childUIDL, client); + if (childUIDL.hasAttribute("cached")) { + // child may need relative size adjustment if wrapper details + // have changed this could be optimized (check if wrapper size + // has changed) + client.handleComponentRelativeSize((Widget) paintable); + } } public void setPosition(String stringAttribute) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java index 6f386e231a..62514c49d9 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java @@ -318,6 +318,9 @@ public class ICalendarPanel extends FlexTable implements MouseListener { datefield.getClient().updateVariable(datefield.getId(), "year",
datefield.getCurrentDate().getYear() + 1900,
datefield.isImmediate());
+
+ /* Must update the value in the textfield also */
+ updateCalendar();
}
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java index 0b91268d25..1639b6693b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java @@ -75,11 +75,10 @@ public class IForm extends ComplexPanel implements Container { public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
rendering = true;
-
+ boolean measure = false;
if (this.client == null) {
this.client = client;
- borderPaddingVertical = getOffsetHeight();
- borderPaddingHorizontal = getOffsetWidth() - desc.getOffsetWidth();
+ measure = true;
}
if (client.updateComponent(this, uidl, false)) {
@@ -87,6 +86,14 @@ public class IForm extends ComplexPanel implements Container { return;
}
+ if (measure) {
+ // Measure the border when the style names have been set
+ borderPaddingVertical = getOffsetHeight();
+ int ow = getOffsetWidth();
+ int dow = desc.getOffsetWidth();
+ borderPaddingHorizontal = ow - dow;
+ }
+
boolean legendEmpty = true;
if (uidl.hasAttribute("caption")) {
DOM.setInnerText(caption, uidl.getStringAttribute("caption"));
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IMarginInfo.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IMarginInfo.java index 725659c916..62ef12a9bd 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IMarginInfo.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IMarginInfo.java @@ -4,7 +4,10 @@ package com.itmill.toolkit.terminal.gwt.client.ui; -public class IMarginInfo { +import java.io.Serializable; + +@SuppressWarnings("serial") +public class IMarginInfo implements Serializable { private static final int TOP = 1; private static final int RIGHT = 2; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java index 1186f99ad5..8df846cfea 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java @@ -34,6 +34,7 @@ public class INotification extends IToolkitOverlay { private static final int mouseMoveThreshold = 7;
private static final int Z_INDEX_BASE = 20000;
public static final String STYLE_SYSTEM = "system";
+ private static final int FADE_ANIMATION_INTERVAL = 50; // == 20 fps
private int startOpacity = 90;
private int fadeMsec = 400;
@@ -47,7 +48,7 @@ public class INotification extends IToolkitOverlay { private String temporaryStyle;
- private ArrayList listeners;
+ private ArrayList<EventListener> listeners;
public INotification() {
setStylePrimaryName(STYLENAME);
@@ -69,13 +70,15 @@ public class INotification extends IToolkitOverlay { public void startDelay() {
DOM.removeEventPreview(this);
if (delayMsec > 0) {
- delay = new Timer() {
- @Override
- public void run() {
- fade();
- }
- };
- delay.schedule(delayMsec);
+ if (delay == null) {
+ delay = new Timer() {
+ @Override
+ public void run() {
+ fade();
+ }
+ };
+ delay.schedule(delayMsec);
+ }
} else if (delayMsec == 0) {
fade();
}
@@ -130,17 +133,20 @@ public class INotification extends IToolkitOverlay { public void fade() {
DOM.removeEventPreview(this);
cancelDelay();
- final int msec = fadeMsec / (startOpacity / 5);
fader = new Timer() {
- long timestamp = 0;
- int opacity = startOpacity;
+ private final long start = new Date().getTime();
@Override
public void run() {
- double adjust = (timestamp == 0 ? 1
- : (new Date().getTime() - timestamp) / msec);
- opacity -= adjust * 5d;
- setOpacity(getElement(), opacity);
+ /*
+ * To make animation smooth, don't count that event happens on
+ * time. Reduce opacity according to the actual time spent
+ * instead of fixed decrement.
+ */
+ long now = new Date().getTime();
+ long timeEplaced = now - start;
+ float remainingFraction = 1 - timeEplaced / (float) fadeMsec;
+ int opacity = (int) (startOpacity * remainingFraction);
if (opacity <= 0) {
cancel();
hide();
@@ -150,12 +156,12 @@ public class INotification extends IToolkitOverlay { DOM.setStyleAttribute(getElement(), "width", "");
DOM.setStyleAttribute(getElement(), "height", "");
}
-
+ } else {
+ setOpacity(getElement(), opacity);
}
- timestamp = new Date().getTime();
}
};
- fader.scheduleRepeating(msec);
+ fader.scheduleRepeating(FADE_ANIMATION_INTERVAL);
}
public void setPosition(int position) {
@@ -219,8 +225,10 @@ public class INotification extends IToolkitOverlay { private void setOpacity(Element el, int opacity) {
DOM.setStyleAttribute(el, "opacity", "" + (opacity / 100.0));
- DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity + ")");
-
+ if (BrowserInfo.get().isIE()) {
+ DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity
+ + ")");
+ }
}
@Override
@@ -279,7 +287,7 @@ public class INotification extends IToolkitOverlay { public void addEventListener(EventListener listener) {
if (listeners == null) {
- listeners = new ArrayList();
+ listeners = new ArrayList<EventListener>();
}
listeners.add(listener);
}
@@ -293,14 +301,17 @@ public class INotification extends IToolkitOverlay { private void fireEvent(HideEvent event) {
if (listeners != null) {
- for (Iterator it = listeners.iterator(); it.hasNext();) {
- EventListener l = (EventListener) it.next();
+ for (Iterator<EventListener> it = listeners.iterator(); it
+ .hasNext();) {
+ EventListener l = it.next();
l.notificationHidden(event);
}
}
}
public class HideEvent extends EventObject {
+ private static final long serialVersionUID = 4428671753988459560L;
+
public HideEvent(Object source) {
super(source);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java index 03cef562e0..9fcc154ef7 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java @@ -106,13 +106,13 @@ public class IPanel extends SimplePanel implements Container { rendering = true; if (!uidl.hasAttribute("cached")) { // Handle caption displaying and style names, prior generics. - // Affects size - // calculations + // Affects size calculations // Restore default stylenames + captionNode.setClassName(CLASSNAME + "-caption"); contentNode.setClassName(CLASSNAME + "-content"); bottomDecoration.setClassName(CLASSNAME + "-deco"); - captionNode.setClassName(CLASSNAME + "-caption"); + boolean hasCaption = false; if (uidl.hasAttribute("caption") && !uidl.getStringAttribute("caption").equals("")) { diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java index f7a925ad00..2f604a9927 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -13,6 +13,11 @@ import java.util.List; import java.util.Set; import java.util.Vector; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.TableCellElement; +import com.google.gwt.dom.client.TableRowElement; +import com.google.gwt.dom.client.TableSectionElement; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DeferredCommand; @@ -21,7 +26,6 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.ScrollListener; @@ -91,10 +95,15 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int selectMode = Table.SELECT_MODE_NONE; - private final HashSet selectedRowKeys = new HashSet(); + private final HashSet<String> selectedRowKeys = new HashSet<String>(); private boolean initializedAndAttached = false; + /** + * Flag to indicate if a column width recalculation is needed due update. + */ + private boolean headerChangedDuringUpdate = false; + private final TableHead tHead = new TableHead(); private final ScrollPanel bodyContainer = new ScrollPanel(); @@ -114,7 +123,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { * This map contains captions and icon urls for actions like: * "33_c" -> * "Edit" * "33_i" -> "http://dom.com/edit.png" */ - private final HashMap actionMap = new HashMap(); + private final HashMap<Object, String> actionMap = new HashMap<Object, String>(); private String[] visibleColOrder; private boolean initialContentReceived = false; private Element scrollPositionElement; @@ -133,11 +142,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { */ boolean recalcWidths = false; - int scrollbarWidthReservedInColumn = -1; - int scrollbarWidthReserved = -1; - boolean relativeWidth = false; - - private final ArrayList lazyUnregistryBag = new ArrayList(); + private final ArrayList<Panel> lazyUnregistryBag = new ArrayList<Panel>(); private String height; private String width = ""; private boolean rendering = false; @@ -154,6 +159,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } + @SuppressWarnings("unchecked") public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { rendering = true; if (client.updateComponent(this, uidl, true)) { @@ -161,10 +167,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { return; } - if (uidl.hasAttribute("width")) { - relativeWidth = uidl.getStringAttribute("width").endsWith("%"); - } - // we may have pending cache row fetch, cancel it. See #2136 rowRequestHandler.cancel(); @@ -211,11 +213,11 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } if (uidl.hasVariable("selected")) { - final Set selectedKeys = uidl + final Set<String> selectedKeys = uidl .getStringArrayVariableAsSet("selected"); selectedRowKeys.clear(); - for (final Iterator it = selectedKeys.iterator(); it.hasNext();) { - selectedRowKeys.add(it.next()); + for (String string : selectedKeys) { + selectedRowKeys.add(string); } } @@ -260,6 +262,9 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (!recalcWidths && initializedAndAttached) { updateBody(rowData, uidl.getIntAttribute("firstrow"), uidl .getIntAttribute("rows")); + if (headerChangedDuringUpdate) { + lazyAdjustColumnWidths.schedule(1); + } } else { if (tBody != null) { tBody.removeFromParent(); @@ -278,6 +283,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { hideScrollPositionAnnotation(); purgeUnregistryBag(); rendering = false; + headerChangedDuringUpdate = false; } /** @@ -286,15 +292,15 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { * "subtreecaching" logic. */ private void purgeUnregistryBag() { - for (Iterator iterator = lazyUnregistryBag.iterator(); iterator + for (Iterator<Panel> iterator = lazyUnregistryBag.iterator(); iterator .hasNext();) { - client.unregisterChildPaintables((HasWidgets) iterator.next()); + client.unregisterChildPaintables(iterator.next()); } lazyUnregistryBag.clear(); } private void updateActionMap(UIDL c) { - final Iterator it = c.getChildIterator(); + final Iterator<?> it = c.getChildIterator(); while (it.hasNext()) { final UIDL action = (UIDL) it.next(); final String key = action.getStringAttribute("key"); @@ -310,11 +316,11 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public String getActionCaption(String actionKey) { - return (String) actionMap.get(actionKey + "_c"); + return actionMap.get(actionKey + "_c"); } public String getActionIcon(String actionKey) { - return (String) actionMap.get(actionKey + "_i"); + return actionMap.get(actionKey + "_i"); } private void updateHeader(String[] strings) { @@ -432,7 +438,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } private IScrollTableRow getRenderedRowByKey(String key) { - final Iterator it = tBody.iterator(); + final Iterator<Widget> it = tBody.iterator(); IScrollTableRow r = null; while (it.hasNext()) { r = (IScrollTableRow) it.next(); @@ -550,21 +556,18 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { while (headCells.hasNext()) { final HeaderCell hCell = (HeaderCell) headCells.next(); int w = hCell.getWidth(); - if (w > 0) { + if (hCell.isDefinedWidth()) { // server has defined column width explicitly totalExplicitColumnsWidths += w; } else { if (hCell.getExpandRatio() > 0) { expandRatioDivider += hCell.getExpandRatio(); - w = IScrollTableBody.CELL_EXTRA_WIDTH - + IScrollTableBody.CELL_CONTENT_PADDING; + w = 0; } else { // get and store greater of header width and column width, // and // store it as a minimumn natural col width - final int hw = hCell.getOffsetWidth(); - final int cw = tBody.getColWidth(i); - w = (hw > cw ? hw : cw) + IScrollTableBody.CELL_EXTRA_WIDTH; + w = hCell.getNaturalColumnWidth(i); } hCell.setNaturalMinimumColumnWidth(w); } @@ -575,24 +578,26 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { tHead.disableBrowserIntelligence(); + boolean willHaveScrollbarz = willHaveScrollbars(); + // fix "natural" width if width not set if (width == null || "".equals(width)) { int w = total; - w += getScrollbarWidth(); + w += tBody.getCellExtraWidth() * visibleColOrder.length; + if (willHaveScrollbarz) { + w += Util.getNativeScrollbarSize(); + } setContentWidth(w); } int availW = tBody.getAvailableWidth(); - // Hey IE, are you really sure about this? - availW = tBody.getAvailableWidth(); - - // FIXME this may fail if pagelenth does not correlate well with actual - // height (via setHeight()) - boolean verticalScrollbarVisible = (pageLength < totalRows); + if (BrowserInfo.get().isIE()) { + // Hey IE, are you really sure about this? + availW = tBody.getAvailableWidth(); + } + availW -= tBody.getCellExtraWidth() * visibleColOrder.length; - if (verticalScrollbarVisible) { - // There will be a vertical scrollbar and its width is not included - // in availW + if (willHaveScrollbarz) { availW -= Util.getNativeScrollbarSize(); } @@ -600,32 +605,11 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (availW > total) { // natural size is smaller than available space - int extraSpace = availW - total; - int totalWidthR = total - totalExplicitColumnsWidths; + final int extraSpace = availW - total; + final int totalWidthR = total - totalExplicitColumnsWidths; if (totalWidthR > 0) { needsReLayout = true; - /* - * If the table has a relative width and there is enough space - * for a scrollbar we reserve this in the last column - */ - int scrollbarWidth = getScrollbarWidth(); - scrollbarWidth = Util.getNativeScrollbarSize(); - if (!verticalScrollbarVisible && relativeWidth - && totalWidthR >= scrollbarWidth) { - - scrollbarWidthReserved = scrollbarWidth + 1; // - int columnindex = tHead.getVisibleCellCount() - 1; - widths[columnindex] += scrollbarWidthReserved; - HeaderCell headerCell = tHead.getHeaderCell(columnindex); - if (headerCell.getWidth() == -1) { - totalWidthR += scrollbarWidthReserved; - headerCell.setNaturalMinimumColumnWidth(headerCell - .getNaturalColumnWidth() - + scrollbarWidthReserved); - } - extraSpace -= scrollbarWidthReserved; - scrollbarWidthReservedInColumn = columnindex; - } + if (expandRatioDivider > 0) { // visible columns have some active expand ratios, excess // space is divided according to them @@ -649,7 +633,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { i = 0; while (headCells.hasNext()) { HeaderCell hCell = (HeaderCell) headCells.next(); - if (hCell.getWidth() == -1) { + if (!hCell.isDefinedWidth()) { int w = widths[i]; final int newSpace = extraSpace * w / totalWidthR; w += newSpace; @@ -690,11 +674,14 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { */ if (pageLength == totalRows) { /* - * We want to show all rows so the bodyHeight should be equal to - * the table height + * A hack to support variable height rows when paging is off. + * Generally this is not supported by scrolltable. We want to + * show all rows so the bodyHeight should be equal to the table + * height. */ - int bodyHeight = tBody.getTableHeight(); + int bodyHeight = tBody.getOffsetHeight(); bodyContainer.setHeight(bodyHeight + "px"); + Util.runWebkitOverflowAutoFix(bodyContainer.getElement()); } else { int bodyHeight = (tBody.getRowHeight(true) * pageLength); bodyContainer.setHeight(bodyHeight + "px"); @@ -732,14 +719,20 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { initializedAndAttached = true; } - private int getScrollbarWidth() { - if (BrowserInfo.get().isIE6()) { - return Util.measureHorizontalBorder(bodyContainer.getElement()); + private boolean willHaveScrollbars() { + if (!(height != null && !height.equals(""))) { + if (pageLength < totalRows) { + return true; + } + } else { + int fakeheight = tBody.getRowHeight() * totalRows; + int availableHeight = bodyContainer.getElement().getPropertyInt( + "clientHeight"); + if (fakeheight > availableHeight) { + return true; + } } - - return bodyContainer.getOffsetWidth() - - DOM.getElementPropertyInt(bodyContainer.getElement(), - "clientWidth"); + return false; } /** @@ -988,10 +981,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { public class HeaderCell extends Widget { - private static final int DRAG_WIDGET_WIDTH = 4; - - private static final int MINIMUM_COL_WIDTH = 20; - Element td = DOM.createTD(); Element captionContainer = DOM.createDiv(); @@ -1018,7 +1007,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int width = -1; - private int naturalWidth = 0; + private int naturalWidth = -1; private char align = ALIGN_LEFT; @@ -1039,8 +1028,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { DOM.setElementProperty(colResizeWidget, "className", CLASSNAME + "-resizer"); - DOM.setStyleAttribute(colResizeWidget, "width", DRAG_WIDGET_WIDTH - + "px"); DOM.sinkEvents(colResizeWidget, Event.MOUSEEVENTS); setText(headerText); @@ -1080,10 +1067,24 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { DOM.setStyleAttribute(captionContainer, "width", ""); setWidth(""); } else { - DOM.setStyleAttribute(captionContainer, "width", (w - - DRAG_WIDGET_WIDTH - 4) - + "px"); - setWidth(w + "px"); + captionContainer.getStyle().setPropertyPx("width", w); + + /* + * if we already have tBody, set the header width properly, if + * not defer it. IE will fail with complex float in table header + * unless TD width is not explicitly set. + */ + if (tBody != null) { + int tdWidth = width + tBody.getCellExtraWidth(); + setWidth(tdWidth + "px"); + } else { + DeferredCommand.addCommand(new Command() { + public void execute() { + int tdWidth = width + tBody.getCellExtraWidth(); + setWidth(tdWidth + "px"); + } + }); + } } } @@ -1298,8 +1299,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } int newWidth = originalWidth + deltaX; - if (newWidth < MINIMUM_COL_WIDTH) { - newWidth = MINIMUM_COL_WIDTH; + if (newWidth < tBody.getCellExtraWidth()) { + newWidth = tBody.getCellExtraWidth(); } setColWidth(colIndex, newWidth, true); } @@ -1345,12 +1346,35 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { * If column is resized by user or the width is defined by server the * actual width is returned. Else the natural min width is returned. * + * @param columnIndex + * column index hint, if -1 (unknown) it will be detected + * * @return */ - public int getNaturalColumnWidth() { + public int getNaturalColumnWidth(int columnIndex) { if (isDefinedWidth()) { return width; } else { + if (naturalWidth < 0) { + // This is recently revealed column. Try to detect a proper + // value (greater of header and data + // cols) + + final int hw = ((Element) getElement().getLastChild()) + .getOffsetWidth() + + tBody.getCellExtraWidth(); + if (columnIndex < 0) { + columnIndex = 0; + for (Iterator<Widget> it = tHead.iterator(); it + .hasNext(); columnIndex++) { + if (it.next() == this) { + break; + } + } + } + final int cw = tBody.getColWidth(columnIndex); + naturalWidth = (hw > cw ? hw : cw); + } return naturalWidth; } } @@ -1403,6 +1427,10 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int focusedSlot = -1; public TableHead() { + if (BrowserInfo.get().isIE()) { + table.setPropertyInt("cellSpacing", 0); + } + DOM.setStyleAttribute(hTableWrapper, "overflow", "hidden"); DOM.setElementProperty(hTableWrapper, "className", CLASSNAME + "-header"); @@ -1437,7 +1465,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public void updateCellsFromUIDL(UIDL uidl) { - Iterator it = uidl.getChildIterator(); + Iterator<?> it = uidl.getChildIterator(); HashSet<String> updated = new HashSet<String>(); updated.add("0"); while (it.hasNext()) { @@ -1467,7 +1495,10 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } else { c.setSorted(false); } + } else { + c.setSortable(false); } + if (col.hasAttribute("align")) { c.setAlign(col.getStringAttribute("align").charAt(0)); } @@ -1495,14 +1526,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { final HeaderCell c = getHeaderCell(cid); if (!c.isEnabled() || getHeaderCell(index) != c) { setHeaderCell(index, c); - if (c.getWidth() == -1) { - if (initializedAndAttached) { - // column is not drawn before, - // we will need a column width recalculation - initializedAndAttached = false; - initialContentReceived = false; - isNewBody = true; - } + if (initializedAndAttached) { + headerChangedDuringUpdate = true; } } } @@ -1668,6 +1693,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } else { tHead.removeCell(colKey); collapsedColumns.add(colKey); + lazyAdjustColumnWidths.schedule(1); } // update variable to server @@ -1717,7 +1743,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { for (i = 0; i < visibleColOrder.length; i++) { cols[i] = visibleColOrder[i]; } - for (final Iterator it = collapsedColumns.iterator(); it + for (final Iterator<String> it = collapsedColumns.iterator(); it .hasNext();) { cols[i++] = it.next(); } @@ -1750,7 +1776,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { * Returns column alignments for visible columns */ public char[] getColumnAlignments() { - final Iterator it = visibleCells.iterator(); + final Iterator<Widget> it = visibleCells.iterator(); final char[] aligns = new char[visibleCells.size()]; int colIndex = 0; while (it.hasNext()) { @@ -1769,29 +1795,25 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { */ public class IScrollTableBody extends Panel { - public static final int CELL_EXTRA_WIDTH = 20; - public static final int DEFAULT_ROW_HEIGHT = 24; - /** - * Amount of padding inside one table cell (this is reduced from the - * "cellContent" element's width). You may override this in your own - * widgetset. - */ - public static final int CELL_CONTENT_PADDING = 8; - private int rowHeight = -1; - private final List renderedRows = new Vector(); + private final List<Widget> renderedRows = new Vector<Widget>(); - private boolean initDone = false; + /** + * Due some optimizations row height measuring is deferred and initial + * set of rows is rendered detached. Flag set on when table body has + * been attached in dom and rowheight has been measured. + */ + private boolean tBodyMeasurementsDone = false; Element preSpacer = DOM.createDiv(); Element postSpacer = DOM.createDiv(); Element container = DOM.createDiv(); - Element tBody = DOM.createTBody(); + TableSectionElement tBodyElement = Document.get().createTBodyElement(); Element table = DOM.createTable(); private int firstRendered; @@ -1802,17 +1824,21 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { IScrollTableBody() { constructDOM(); + setElement(container); } private void constructDOM() { DOM.setElementProperty(table, "className", CLASSNAME + "-table"); + if (BrowserInfo.get().isIE()) { + table.setPropertyInt("cellSpacing", 0); + } DOM.setElementProperty(preSpacer, "className", CLASSNAME + "-row-spacer"); DOM.setElementProperty(postSpacer, "className", CLASSNAME + "-row-spacer"); - DOM.appendChild(table, tBody); + table.appendChild(tBodyElement); DOM.appendChild(container, preSpacer); DOM.appendChild(container, table); DOM.appendChild(container, postSpacer); @@ -1820,13 +1846,14 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public int getAvailableWidth() { - return DOM.getElementPropertyInt(preSpacer, "offsetWidth"); + int availW = bodyContainer.getOffsetWidth() - getBorderWidth(); + return availW; } public void renderInitialRows(UIDL rowData, int firstIndex, int rows) { firstRendered = firstIndex; lastRendered = firstIndex + rows - 1; - final Iterator it = rowData.getChildIterator(); + final Iterator<?> it = rowData.getChildIterator(); aligns = tHead.getColumnAlignments(); while (it.hasNext()) { final IScrollTableRow row = new IScrollTableRow((UIDL) it @@ -1841,7 +1868,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { public void renderRows(UIDL rowData, int firstIndex, int rows) { // FIXME REVIEW aligns = tHead.getColumnAlignments(); - final Iterator it = rowData.getChildIterator(); + final Iterator<?> it = rowData.getChildIterator(); if (firstIndex == lastRendered + 1) { while (it.hasNext()) { final IScrollTableRow row = createRow((UIDL) it.next()); @@ -1895,7 +1922,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { rowRequestHandler.setReqFirstRow(lastRendered + 1); rowRequestHandler.setReqRows(reactLastRow - lastRendered - 1); rowRequestHandler.deferRowFetch(1); - } else if (IScrollTable.this.tBody.getFirstRendered() > reactFirstRow) { + } else if (tBody.getFirstRendered() > reactFirstRow) { /* * Branch for fetching cache above visible area. * @@ -1926,9 +1953,9 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { final Element cell = DOM.getChild(row.getElement(), i); final int w = IScrollTable.this .getColWidth(getColKeyByIndex(i)); - DOM.setStyleAttribute(DOM.getFirstChild(cell), "width", - (w - CELL_CONTENT_PADDING) + "px"); - DOM.setStyleAttribute(cell, "width", w + "px"); + cell.getFirstChildElement().getStyle() + .setPropertyPx("width", w); + cell.getStyle().setPropertyPx("width", w); } return row; } @@ -1946,7 +1973,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (row.isSelected()) { row.addStyleName("i-selected"); } - DOM.insertChild(tBody, row.getElement(), 0); + tBodyElement.insertBefore(row.getElement(), tBodyElement + .getFirstChild()); adopt(row); renderedRows.add(0, row); } @@ -1965,12 +1993,12 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (row.isSelected()) { row.addStyleName("i-selected"); } - DOM.appendChild(tBody, row.getElement()); + tBodyElement.appendChild(row.getElement()); adopt(row); renderedRows.add(row); } - public Iterator iterator() { + public Iterator<Widget> iterator() { return renderedRows.iterator(); } @@ -1989,14 +2017,18 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { index = renderedRows.size() - 1; lastRendered--; } - final IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows - .get(index); - lazyUnregistryBag.add(toBeRemoved); - DOM.removeChild(tBody, toBeRemoved.getElement()); - orphan(toBeRemoved); - renderedRows.remove(index); - fixSpacers(); - return true; + if (index >= 0) { + final IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows + .get(index); + lazyUnregistryBag.add(toBeRemoved); + tBodyElement.removeChild(toBeRemoved.getElement()); + orphan(toBeRemoved); + renderedRows.remove(index); + fixSpacers(); + return true; + } else { + return false; + } } @Override @@ -2038,15 +2070,26 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public int getRowHeight(boolean forceUpdate) { - if (initDone && !forceUpdate) { + if (tBodyMeasurementsDone && !forceUpdate) { return rowHeight; } else { - if (DOM.getChildCount(tBody) > 0) { - rowHeight = getTableHeight() / DOM.getChildCount(tBody); + + if (tBodyElement.getRows().getLength() > 0) { + rowHeight = getTableHeight() + / tBodyElement.getRows().getLength(); } else { - return DEFAULT_ROW_HEIGHT; + if (isAttached()) { + // measure row height by adding a dummy row + IScrollTableRow scrollTableRow = new IScrollTableRow(); + tBodyElement.appendChild(scrollTableRow.getElement()); + getRowHeight(forceUpdate); + tBodyElement.removeChild(scrollTableRow.getElement()); + } else { + // TODO investigate if this can never happen anymore + return DEFAULT_ROW_HEIGHT; + } } - initDone = true; + tBodyMeasurementsDone = true; return rowHeight; } } @@ -2055,23 +2098,81 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { return table.getOffsetHeight(); } - public int getColWidth(int i) { - if (initDone) { - final Element e = DOM.getChild(DOM.getChild(tBody, 0), i); - return DOM.getElementPropertyInt(e, "offsetWidth"); + /** + * Returns the width available for column content. + * + * @param columnIndex + * @return + */ + public int getColWidth(int columnIndex) { + if (tBodyMeasurementsDone) { + NodeList<TableRowElement> rows = tBodyElement.getRows(); + if (rows.getLength() == 0) { + // no rows yet rendered + return 0; + } else { + com.google.gwt.dom.client.Element wrapperdiv = rows + .getItem(0).getCells().getItem(columnIndex) + .getFirstChildElement(); + return wrapperdiv.getOffsetWidth(); + } } else { return 0; } } + /** + * Sets the content width of a column. + * + * Due IE limitation, we must set the width to a wrapper elements inside + * table cells (with overflow hidden, which does not work on td + * elements). + * + * To get this work properly crossplatform, we will also set the width + * of td. + * + * @param colIndex + * @param w + */ public void setColWidth(int colIndex, int w) { - final int rows = DOM.getChildCount(tBody); + NodeList<TableRowElement> rows2 = tBodyElement.getRows(); + final int rows = rows2.getLength(); for (int i = 0; i < rows; i++) { - final Element cell = DOM.getChild(DOM.getChild(tBody, i), - colIndex); - DOM.setStyleAttribute(DOM.getFirstChild(cell), "width", - (w - CELL_CONTENT_PADDING) + "px"); - DOM.setStyleAttribute(cell, "width", w + "px"); + TableRowElement row = rows2.getItem(i); + TableCellElement cell = row.getCells().getItem(colIndex); + cell.getFirstChildElement().getStyle() + .setPropertyPx("width", w); + cell.getStyle().setPropertyPx("width", w); + } + } + + private int cellExtraWidth = -1; + + /** + * Method to return the space used for cell paddings + border. + */ + private int getCellExtraWidth() { + if (cellExtraWidth < 0) { + detectExtrawidth(); + } + return cellExtraWidth; + } + + private void detectExtrawidth() { + NodeList<TableRowElement> rows = tBodyElement.getRows(); + if (rows.getLength() == 0) { + /* need to temporary add empty row and detect */ + IScrollTableRow scrollTableRow = new IScrollTableRow(); + tBodyElement.appendChild(scrollTableRow.getElement()); + detectExtrawidth(); + tBodyElement.removeChild(scrollTableRow.getElement()); + } else { + TableRowElement item = rows.getItem(0); + TableCellElement firstTD = item.getCells().getItem(0); + com.google.gwt.dom.client.Element wrapper = firstTD + .getFirstChildElement(); + cellExtraWidth = firstTD.getOffsetWidth() + - wrapper.getOffsetWidth(); } } @@ -2095,7 +2196,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { public void moveCol(int oldIndex, int newIndex) { // loop all rows and move given index to its new place - final Iterator rows = iterator(); + final Iterator<?> rows = iterator(); while (rows.hasNext()) { final IScrollTableRow row = (IScrollTableRow) rows.next(); @@ -2111,16 +2212,18 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { public class IScrollTableRow extends Panel implements ActionOwner, Container { - Vector childWidgets = new Vector(); + Vector<Widget> childWidgets = new Vector<Widget>(); private boolean selected = false; private final int rowKey; private List<UIDL> pendingComponentPaints; private String[] actionKeys = null; + private TableRowElement rowElement; private IScrollTableRow(int rowKey) { this.rowKey = rowKey; - setElement(DOM.createElement("tr")); + rowElement = Document.get().createTRElement(); + setElement(rowElement); DOM.sinkEvents(getElement(), Event.ONCLICK | Event.ONDBLCLICK | Event.ONCONTEXTMENU); } @@ -2173,7 +2276,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { actionKeys = uidl.getStringArrayAttribute("al"); } - final Iterator cells = uidl.getChildIterator(); + final Iterator<?> cells = uidl.getChildIterator(); while (cells.hasNext()) { final Object cell = cells.next(); visibleColumnIndex++; @@ -2200,6 +2303,15 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } } + /** + * Add a dummy row, used for measurements if Table is empty. + */ + public IScrollTableRow() { + this(0); + addStyleName(CLASSNAME + "-row"); + addCell("_", 'b', "", true); + } + public void addCell(String text, char align, String style, boolean textIsHTML) { // String only content is optimized by not using Label widget @@ -2209,26 +2321,26 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (style != null && !style.equals("")) { className += " " + CLASSNAME + "-cell-content-" + style; } - - DOM.setElementProperty(container, "className", className); + td.setClassName(className); + container.setClassName(CLASSNAME + "-cell-wrapper"); if (textIsHTML) { - DOM.setInnerHTML(container, text); + container.setInnerHTML(text); } else { - DOM.setInnerText(container, text); + container.setInnerText(text); } if (align != ALIGN_LEFT) { switch (align) { case ALIGN_CENTER: - DOM.setStyleAttribute(container, "textAlign", "center"); + container.getStyle().setProperty("textAlign", "center"); break; case ALIGN_RIGHT: default: - DOM.setStyleAttribute(container, "textAlign", "right"); + container.getStyle().setProperty("textAlign", "right"); break; } } - DOM.appendChild(td, container); - DOM.appendChild(getElement(), td); + td.appendChild(container); + getElement().appendChild(td); } public void addCell(Widget w, char align, String style) { @@ -2238,7 +2350,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (style != null && !style.equals("")) { className += " " + CLASSNAME + "-cell-content-" + style; } - DOM.setElementProperty(container, "className", className); + td.setClassName(className); + container.setClassName(CLASSNAME + "-cell-wrapper"); // TODO most components work with this, but not all (e.g. // Select) // Old comment: make widget cells respect align. @@ -2246,25 +2359,25 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (align != ALIGN_LEFT) { switch (align) { case ALIGN_CENTER: - DOM.setStyleAttribute(container, "textAlign", "center"); + container.getStyle().setProperty("textAlign", "center"); break; case ALIGN_RIGHT: default: - DOM.setStyleAttribute(container, "textAlign", "right"); + container.getStyle().setProperty("textAlign", "right"); break; } } - DOM.appendChild(td, container); - DOM.appendChild(getElement(), td); + td.appendChild(container); + getElement().appendChild(td); // ensure widget not attached to another element (possible tBody // change) w.removeFromParent(); - DOM.appendChild(container, w.getElement()); + container.appendChild(w.getElement()); adopt(w); childWidgets.add(w); } - public Iterator iterator() { + public Iterator<Widget> iterator() { return childWidgets.iterator(); } @@ -2471,14 +2584,13 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { HeaderCell headerCell = tHead.getHeaderCell(i); if (headerCell != null) { if (initializedAndAttached) { - w = headerCell.getWidth() - CELL_CONTENT_PADDING; + w = headerCell.getWidth(); } else { // header offset width is not absolutely correct value, - // but - // a best guess (expecting similar content in all + // but a best guess (expecting similar content in all // columns -> // if one component is relative width so are others) - w = headerCell.getOffsetWidth() - CELL_CONTENT_PADDING; + w = headerCell.getOffsetWidth() - getCellExtraWidth(); } } return new RenderSpace(w, getRowHeight()); @@ -2487,14 +2599,13 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int getColIndexOf(Widget child) { com.google.gwt.dom.client.Element widgetCell = child .getElement().getParentElement().getParentElement(); - com.google.gwt.dom.client.Element td = getElement() - .getFirstChildElement(); - int index = 0; - while (td != widgetCell && td.getNextSiblingElement() != null) { - index++; - td = td.getNextSiblingElement(); + NodeList<TableCellElement> cells = rowElement.getCells(); + for (int i = 0; i < cells.getLength(); i++) { + if (cells.getItem(i) == widgetCell) { + return i; + } } - return index; + return -1; } public boolean hasChildComponent(Widget component) { @@ -2553,19 +2664,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { this.width = width; if (width != null && !"".equals(width)) { - int oldWidth = getOffsetWidth(); super.setWidth(width); - int newWidth = getOffsetWidth(); - - if (scrollbarWidthReservedInColumn != -1 && oldWidth > newWidth - && (oldWidth - newWidth) < scrollbarWidthReserved) { - int col = scrollbarWidthReservedInColumn; - String colKey = getColKeyByIndex(col); - setColWidth(scrollbarWidthReservedInColumn, getColWidth(colKey) - - (oldWidth - newWidth), false); - scrollbarWidthReservedInColumn = -1; - } - int innerPixels = getOffsetWidth() - getBorderWidth(); if (innerPixels < 0) { innerPixels = 0; @@ -2599,49 +2698,60 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { int usedMinimumWidth = 0; int totalExplicitColumnsWidths = 0; float expandRatioDivider = 0; + int colIndex = 0; while (headCells.hasNext()) { final HeaderCell hCell = (HeaderCell) headCells.next(); - usedMinimumWidth += hCell.getNaturalColumnWidth(); if (hCell.isDefinedWidth()) { totalExplicitColumnsWidths += hCell.getWidth(); + usedMinimumWidth += hCell.getWidth(); } else { + usedMinimumWidth += hCell.getNaturalColumnWidth(colIndex); expandRatioDivider += hCell.getExpandRatio(); } + colIndex++; } int availW = tBody.getAvailableWidth(); // Hey IE, are you really sure about this? availW = tBody.getAvailableWidth(); + availW -= tBody.getCellExtraWidth() * visibleColOrder.length; + if (willHaveScrollbars()) { + availW -= Util.getNativeScrollbarSize(); + } int extraSpace = availW - usedMinimumWidth; if (extraSpace < 0) { extraSpace = 0; } - int totalWidthR = usedMinimumWidth - totalExplicitColumnsWidths; - if (totalWidthR < 0) { - totalWidthR = 0; - } + + int totalUndefinedNaturaWidths = usedMinimumWidth + - totalExplicitColumnsWidths; // we have some space that can be divided optimally HeaderCell hCell; - int i = 0; + colIndex = 0; headCells = tHead.iterator(); while (headCells.hasNext()) { hCell = (HeaderCell) headCells.next(); if (!hCell.isDefinedWidth()) { - int w = hCell.getNaturalColumnWidth(); + int w = hCell.getNaturalColumnWidth(colIndex); int newSpace; if (expandRatioDivider > 0) { // divide excess space by expand ratios newSpace = (int) (w + extraSpace * hCell.getExpandRatio() / expandRatioDivider); } else { - // divide relatively to natural column widths - newSpace = w + extraSpace * w / totalWidthR; + if (totalUndefinedNaturaWidths != 0) { + // divide relatively to natural column widths + newSpace = w + extraSpace * w + / totalUndefinedNaturaWidths; + } else { + newSpace = w; + } } - setColWidth(i, newSpace, false); + setColWidth(colIndex, newSpace, false); } - i++; + colIndex++; } Util.runWebkitOverflowAutoFix(bodyContainer.getElement()); tBody.reLayoutComponents(); diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java index 5076dfbc75..67385f756b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISlider.java @@ -48,7 +48,7 @@ public class ISlider extends Widget implements Paintable, Field, /* DOM element for slider's base */
private final Element base;
- private final int BASE_BORDER_WIDTH = 1;
+ protected final int BASE_BORDER_WIDTH = 1;
/* DOM element for slider's handle */
private final Element handle;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java index 0bb89dcea6..519ec6034a 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java @@ -124,6 +124,14 @@ public class ITabsheet extends ITabsheetBase { */ DOM.removeChild(tr, td); + + /* + * If this widget was selected we need to unmark it as the last + * selected + */ + if (w == oldSelected) { + oldSelected = null; + } } @Override diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IToolkitOverlay.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IToolkitOverlay.java index 763d75c3af..0ea4f14133 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IToolkitOverlay.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IToolkitOverlay.java @@ -84,7 +84,9 @@ public class IToolkitOverlay extends PopupPanel { addPopupListener(new PopupListener() { public void onPopupClosed(PopupPanel sender, boolean autoClosed) { - DOM.removeChild(RootPanel.get().getElement(), shadow); + if (shadow.getParentElement() != null) { + shadow.getParentElement().removeChild(shadow); + } } }); } @@ -144,6 +146,15 @@ public class IToolkitOverlay extends PopupPanel { } } + @Override + public void setVisible(boolean visible) { + super.setVisible(visible); + if (shadow != null) { + shadow.getStyle().setProperty("visibility", + visible ? "visible" : "hidden"); + } + } + /* * Needed to position overlays on top of native SELECT elements in IE6. See * bug #2004 @@ -206,16 +217,16 @@ public class IToolkitOverlay extends PopupPanel { * A value between 0.0 and 1.0, indicating the progress of the * animation (0=start, 1=end). */ - private void updateShadowSizeAndPosition(double progress) { + private void updateShadowSizeAndPosition(final double progress) { // Don't do anything if overlay element is not attached - if (!isAttached() || !isVisible()) { + if (!isAttached()) { return; } // Calculate proper z-index String zIndex = null; try { - // Odd behaviour with Windows Hosted Mode forces us to use this - // redundant try/catch block (See dev.itmill.com #2011) + // Odd behaviour with Windows Hosted Mode forces us to use + // this redundant try/catch block (See dev.itmill.com #2011) zIndex = DOM.getStyleAttribute(getElement(), "zIndex"); } catch (Exception ignore) { // Ignored, will cause no harm @@ -255,7 +266,8 @@ public class IToolkitOverlay extends PopupPanel { width = (int) (width * progress); height = (int) (height * progress); - // Opera needs some shaking to get parts of the shadow showing properly + // Opera needs some shaking to get parts of the shadow showing + // properly // (ticket #2704) if (BrowserInfo.get().isOpera()) { // Clear the height of all middle elements diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java index e329d410c0..e58b32ab30 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java @@ -104,7 +104,7 @@ public class IWindow extends IToolkitOverlay implements Container, /** Last known positiony read from UIDL or updated to application connection */ private int uidlPositionY = -1; - private boolean modal = false; + private boolean vaadinModality = false; private boolean resizable = true; @@ -175,7 +175,7 @@ public class IWindow extends IToolkitOverlay implements Container, @Override protected void setZIndex(int zIndex) { super.setZIndex(zIndex); - if (modal) { + if (vaadinModality) { DOM.setStyleAttribute(modalityCurtain, "zIndex", "" + zIndex); } } @@ -239,8 +239,8 @@ public class IWindow extends IToolkitOverlay implements Container, } if (!uidl.hasAttribute("cached")) { - if (uidl.getBooleanAttribute("modal") != modal) { - setModal(!modal); + if (uidl.getBooleanAttribute("modal") != vaadinModality) { + setVaadinModality(!vaadinModality); } if (!isAttached()) { show(); @@ -485,7 +485,7 @@ public class IWindow extends IToolkitOverlay implements Container, @Override public void show() { - if (modal) { + if (vaadinModality) { showModalityCurtain(); } super.show(); @@ -529,15 +529,15 @@ public class IWindow extends IToolkitOverlay implements Container, @Override public void hide() { - if (modal) { + if (vaadinModality) { hideModalityCurtain(); } super.hide(); } - private void setModal(boolean modality) { - modal = modality; - if (modal) { + private void setVaadinModality(boolean modality) { + vaadinModality = modality; + if (vaadinModality) { modalityCurtain = DOM.createDiv(); DOM.setElementProperty(modalityCurtain, "className", CLASSNAME + "-modalitycurtain"); @@ -547,7 +547,7 @@ public class IWindow extends IToolkitOverlay implements Container, } else { DeferredCommand.addCommand(new Command() { public void execute() { - // modal window must on top of others + // vaadinModality window must on top of others bringToFront(); } }); @@ -900,7 +900,7 @@ public class IWindow extends IToolkitOverlay implements Container, } else if (resizing) { onResizeEvent(event); return false; - } else if (modal) { + } else if (vaadinModality) { // return false when modal and outside window final Element target = event.getTarget().cast(); if (!DOM.isOrHasChild(getElement(), target)) { diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java index 894eba519b..eff1fe3a66 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java @@ -2,6 +2,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.IOException;
import java.io.PrintWriter;
+import java.io.Serializable;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
@@ -15,7 +16,8 @@ import javax.portlet.RenderResponse; import com.itmill.toolkit.Application;
-public class ApplicationPortlet implements Portlet {
+@SuppressWarnings("serial")
+public class ApplicationPortlet implements Portlet, Serializable {
// The application to show
protected String app = null;
// some applications might require forced height (and, more seldom, width)
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java index b9c8d58ff5..17b6c66c45 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java @@ -10,6 +10,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -19,7 +20,6 @@ import java.security.GeneralSecurityException; import java.util.Collection; import java.util.Date; import java.util.Enumeration; -import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; @@ -55,10 +55,9 @@ import com.itmill.toolkit.ui.Window; * @since 5.0 */ +@SuppressWarnings("serial") public class ApplicationServlet extends HttpServlet { - private static final long serialVersionUID = -4937882979845826574L; - /** * Version number of this release. For example "5.0.0". */ @@ -127,10 +126,6 @@ public class ApplicationServlet extends HttpServlet { private static final int MAX_BUFFER_SIZE = 64 * 1024; - // TODO This is session specific not servlet wide data. No need to store - // this here, move it to Session from where it can be queried when required - protected static HashMap<Application, CommunicationManager> applicationToAjaxAppMgrMap = new HashMap<Application, CommunicationManager>(); - private static final String RESOURCE_URI = "/RES/"; private static final String AJAX_UIDL_URI = "/UIDL"; @@ -162,8 +157,6 @@ public class ApplicationServlet extends HttpServlet { // If servlet is application runner, store request's classname String applicationRunnerClassname = null; - private ClassLoader classLoader; - /** * Called by the servlet container to indicate to a servlet that the servlet * is being placed into service. @@ -229,28 +222,6 @@ public class ApplicationServlet extends HttpServlet { System.err.println(NOT_PRODUCTION_MODE_INFO); } - // Gets custom class loader - final String classLoaderName = getApplicationOrSystemProperty( - "ClassLoader", null); - ClassLoader classLoader; - if (classLoaderName == null) { - classLoader = getClass().getClassLoader(); - } else { - try { - final Class classLoaderClass = getClass().getClassLoader() - .loadClass(classLoaderName); - final Constructor c = classLoaderClass - .getConstructor(new Class[] { ClassLoader.class }); - classLoader = (ClassLoader) c - .newInstance(new Object[] { getClass().getClassLoader() }); - } catch (final Exception e) { - throw new ServletException( - "Could not find specified class loader: " - + classLoaderName, e); - } - } - this.classLoader = classLoader; - // Loads the application class using the same class loader // as the servlet itself if (!isApplicationRunnerServlet) { @@ -262,7 +233,8 @@ public class ApplicationServlet extends HttpServlet { "Application not specified in servlet parameters"); } try { - applicationClass = classLoader.loadClass(applicationClassName); + applicationClass = getClassLoader().loadClass( + applicationClassName); } catch (final ClassNotFoundException e) { throw new ServletException("Failed to load application class: " + applicationClassName); @@ -274,6 +246,30 @@ public class ApplicationServlet extends HttpServlet { } + private ClassLoader getClassLoader() throws ServletException { + // Gets custom class loader + final String classLoaderName = getApplicationOrSystemProperty( + "ClassLoader", null); + ClassLoader classLoader; + if (classLoaderName == null) { + classLoader = getClass().getClassLoader(); + } else { + try { + final Class<?> classLoaderClass = getClass().getClassLoader() + .loadClass(classLoaderName); + final Constructor<?> c = classLoaderClass + .getConstructor(new Class[] { ClassLoader.class }); + classLoader = (ClassLoader) c + .newInstance(new Object[] { getClass().getClassLoader() }); + } catch (final Exception e) { + throw new ServletException( + "Could not find specified class loader: " + + classLoaderName, e); + } + } + return classLoader; + } + /** * Gets an application or system property value. * @@ -371,8 +367,9 @@ public class ApplicationServlet extends HttpServlet { // note: endTransaction is called on finalize below ((WebApplicationContext) application.getContext()) .startTransaction(application, request); - getApplicationManager(application).handleFileUpload(request, - response); + ((WebApplicationContext) application.getContext()) + .getApplicationManager(application, this) + .handleFileUpload(request, response); return; } @@ -417,8 +414,9 @@ public class ApplicationServlet extends HttpServlet { .startTransaction(application, request); // Handle UIDL request - getApplicationManager(application).handleUidlRequest( - request, response, this); + ((WebApplicationContext) application.getContext()) + .getApplicationManager(application, this) + .handleUidlRequest(request, response, this); return; } } @@ -432,7 +430,7 @@ public class ApplicationServlet extends HttpServlet { application.close(); final HttpSession session = request.getSession(false); if (session != null) { - ApplicationServlet.applicationToAjaxAppMgrMap + WebApplicationContext.getApplicationContext(session).applicationToAjaxAppMgrMap .remove(application); WebApplicationContext.getApplicationContext(session) .removeApplication(application); @@ -474,8 +472,9 @@ public class ApplicationServlet extends HttpServlet { DownloadStream download = null; // Handles the URI if the application is still running - download = getApplicationManager(application).handleURI(window, - request, response); + download = ((WebApplicationContext) application.getContext()) + .getApplicationManager(application, this).handleURI(window, + request, response); // If this is not a download request if (download == null) { @@ -579,6 +578,11 @@ public class ApplicationServlet extends HttpServlet { ((WebApplicationContext) application.getContext()) .endTransaction(application, request); } + + // Work-around for GAE session problem. Explicitly touch session so + // it is re-serialized. + request.getSession().setAttribute("sessionUpdated", + new Date().getTime()); } } @@ -623,9 +627,10 @@ public class ApplicationServlet extends HttpServlet { * @param request * @param response * @throws IOException + * @throws ServletException */ private void serveStaticResourcesInITMILL(String filename, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException, ServletException { final ServletContext sc = getServletContext(); InputStream is = sc.getResourceAsStream(filename); @@ -634,7 +639,7 @@ public class ApplicationServlet extends HttpServlet { // strip leading "/" otherwise stream from JAR wont work filename = filename.substring(1); - is = classLoader.getResourceAsStream(filename); + is = getClassLoader().getResourceAsStream(filename); if (is == null) { // cannot serve requested file @@ -1430,10 +1435,12 @@ public class ApplicationServlet extends HttpServlet { * @throws SAXException * @throws IllegalAccessException * @throws InstantiationException + * @throws ServletException */ private Application getNewApplication(HttpServletRequest request, HttpServletResponse response) throws MalformedURLException, - SAXException, IllegalAccessException, InstantiationException { + SAXException, IllegalAccessException, InstantiationException, + ServletException { // Create application final WebApplicationContext context = WebApplicationContext @@ -1446,7 +1453,8 @@ public class ApplicationServlet extends HttpServlet { applicationUrl = new URL(getApplicationUrl(request).toString() + applicationClassname + "/"); try { - applicationClass = classLoader.loadClass(applicationClassname); + applicationClass = getClassLoader().loadClass( + applicationClassname); } catch (final ClassNotFoundException e) { throw new InstantiationException( "Failed to load application class: " @@ -1586,7 +1594,7 @@ public class ApplicationServlet extends HttpServlet { * Implementation of ParameterHandler.ErrorEvent interface. */ public class ParameterHandlerErrorImpl implements - ParameterHandler.ErrorEvent { + ParameterHandler.ErrorEvent, Serializable { private ParameterHandler owner; @@ -1615,7 +1623,8 @@ public class ApplicationServlet extends HttpServlet { /** * Implementation of URIHandler.ErrorEvent interface. */ - public class URIHandlerErrorImpl implements URIHandler.ErrorEvent { + public class URIHandlerErrorImpl implements URIHandler.ErrorEvent, + Serializable { private final URIHandler owner; @@ -1651,25 +1660,6 @@ public class ApplicationServlet extends HttpServlet { } /** - * Gets communication manager for an application. - * - * If this application has not been running before, new manager is created. - * - * @param application - * @return CommunicationManager - */ - private CommunicationManager getApplicationManager(Application application) { - CommunicationManager mgr = applicationToAjaxAppMgrMap.get(application); - - if (mgr == null) { - // Creates new manager - mgr = new CommunicationManager(application, this); - applicationToAjaxAppMgrMap.put(application, mgr); - } - return mgr; - } - - /** * Gets resource path using different implementations. Required to * supporting different servlet container implementations (application * servers). @@ -1697,7 +1687,7 @@ public class ApplicationServlet extends HttpServlet { return resultPath; } - public class RequestError implements Terminal.ErrorEvent { + public class RequestError implements Terminal.ErrorEvent, Serializable { private final Throwable throwable; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java b/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java index 76bd1822c0..53523bea5a 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java @@ -5,6 +5,7 @@ import java.util.Map; import com.itmill.toolkit.ui.Component;
import com.itmill.toolkit.ui.AbstractComponent.ComponentErrorEvent;
+@SuppressWarnings("serial")
public class ChangeVariablesErrorEvent implements ComponentErrorEvent {
private Throwable throwable;
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index 5cb8405d2a..033284259d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -12,10 +12,12 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; import java.security.GeneralSecurityException; +import java.text.DateFormat; import java.text.DateFormatSymbols; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -70,7 +72,9 @@ import com.itmill.toolkit.ui.Window; * @VERSION@ * @since 5.0 */ -public class CommunicationManager implements Paintable.RepaintRequestListener { +@SuppressWarnings("serial") +public class CommunicationManager implements Paintable.RepaintRequestListener, + Serializable { private static String GET_PARAM_REPAINT_ALL = "repaintAll"; @@ -608,17 +612,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { boolean success = true; if (request.getContentLength() > 0) { - - byte[] buffer = new byte[request.getContentLength()]; - ServletInputStream inputStream = request.getInputStream(); - int totalBytesRead = 0; - int bytesRead; - while ((bytesRead = inputStream.read(buffer, totalBytesRead, - MAX_BUFFER_SIZE)) != -1) { - totalBytesRead += bytesRead; - } - - String changes = new String(buffer, "utf-8"); + String changes = readRequest(request); // Manage bursts one by one final String[] bursts = changes.split(VAR_BURST_SEPARATOR); @@ -776,8 +770,40 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { return success; } - public class ErrorHandlerErrorEvent implements ErrorEvent { + /** + * Reads the request data from the HttpServletRequest and returns it + * converted to an UTF-8 string. + * + * @param request + * @return + * @throws IOException + */ + private static String readRequest(HttpServletRequest request) + throws IOException { + + int requestLength = request.getContentLength(); + + byte[] buffer = new byte[requestLength]; + ServletInputStream inputStream = request.getInputStream(); + + int bytesRemaining = requestLength; + while (bytesRemaining > 0) { + int bytesToRead = Math.min(bytesRemaining, MAX_BUFFER_SIZE); + int bytesRead = inputStream.read(buffer, requestLength + - bytesRemaining, bytesToRead); + if (bytesRead == -1) { + break; + } + bytesRemaining -= bytesRead; + } + + String result = new String(buffer, "utf-8"); + + return result; + } + + public class ErrorHandlerErrorEvent implements ErrorEvent, Serializable { private final Throwable throwable; public ErrorHandlerErrorEvent(Throwable throwable) { @@ -841,6 +867,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { case 'b': val = Boolean.valueOf(strValue); break; + case 'p': + val = idPaintableMap.get(strValue); + break; } return val; @@ -852,10 +881,6 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { * ----------------------------- */ - // Store JVM default locale for later restoration - // (we'll have to change the default locale for a while) - final Locale jvmDefault = Locale.getDefault(); - // Send locale informations to client outWriter.print(", \"locales\":["); for (; pendingLocalesIndex < locales.size(); pendingLocalesIndex++) { @@ -914,10 +939,17 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { /* * Date formatting (MM/DD/YYYY etc.) */ - // Force our locale as JVM default for a while (SimpleDateFormat - // uses JVM default) - Locale.setDefault(l); - final String df = new SimpleDateFormat().toPattern(); + + DateFormat dateFormat = DateFormat.getDateTimeInstance( + DateFormat.SHORT, DateFormat.SHORT, l); + if (!(dateFormat instanceof SimpleDateFormat)) { + System.err + .println("Unable to get default date pattern for locale " + + l.toString()); + dateFormat = new SimpleDateFormat(); + } + final String df = ((SimpleDateFormat) dateFormat).toPattern(); + int timeStart = df.indexOf("H"); if (timeStart < 0) { timeStart = df.indexOf("h"); @@ -961,9 +993,6 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { } } outWriter.print("]"); // Close locales - - // Restore JVM default locale - Locale.setDefault(jvmDefault); } /** @@ -1207,7 +1236,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { p.requestRepaintRequests(); } - private final class SingleValueMap implements Map { + private final class SingleValueMap implements Map<Object, Object>, + Serializable { + private final String name; private final Object value; @@ -1298,7 +1329,8 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { /** * Implementation of URIHandler.ErrorEvent interface. */ - public class URIHandlerErrorImpl implements URIHandler.ErrorEvent { + public class URIHandlerErrorImpl implements URIHandler.ErrorEvent, + Serializable { private final URIHandler owner; @@ -1356,7 +1388,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { * FileUpload can determine content length. Used to detect files total size, * uploads progress can be tracked inside upload. */ - private class UploadProgressListener implements ProgressListener { + private class UploadProgressListener implements ProgressListener, + Serializable { + Upload uploadComponent; boolean updated = false; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java b/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java index 7aeee6b10b..afc7f4f554 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java @@ -2,6 +2,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.PrintStream; import java.io.PrintWriter; +import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -26,7 +27,8 @@ import com.itmill.toolkit.ui.VerticalLayout; import com.itmill.toolkit.ui.Window; import com.itmill.toolkit.ui.GridLayout.Area; -public class ComponentSizeValidator { +@SuppressWarnings("serial") +public class ComponentSizeValidator implements Serializable { private final static int LAYERS_SHOWN = 4; @@ -72,12 +74,14 @@ public class ComponentSizeValidator { } } else if (component instanceof Form) { Form form = (Form) component; - if (form.getLayout() != null) + if (form.getLayout() != null) { errors = validateComponentRelativeSizes(form.getLayout(), errors, parent); - if (form.getFooter() != null) + } + if (form.getFooter() != null) { errors = validateComponentRelativeSizes(form.getFooter(), errors, parent); + } } return errors; @@ -148,7 +152,7 @@ public class ComponentSizeValidator { } } - public static class InvalidLayout { + public static class InvalidLayout implements Serializable { private Component component; @@ -265,7 +269,7 @@ public class ComponentSizeValidator { } } - private static class ComponentInfo { + private static class ComponentInfo implements Serializable { Component component; String info; @@ -561,8 +565,9 @@ public class ComponentSizeValidator { || parent instanceof TabSheet || parent instanceof CustomComponent) { // FIXME Could we use com.itmill.toolkit package name here and - // fail for all component containers? - // FIXME Actually this should be moved to containers so it can be implemented for custom containers + // fail for all component containers? + // FIXME Actually this should be moved to containers so it can + // be implemented for custom containers // TODO vertical splitpanel with another non relative component? return false; } else if (parent instanceof Window) { @@ -610,7 +615,7 @@ public class ComponentSizeValidator { private static Map<Object, FileLocation> widthLocations = new HashMap<Object, FileLocation>(); private static Map<Object, FileLocation> heightLocations = new HashMap<Object, FileLocation>(); - public static class FileLocation { + public static class FileLocation implements Serializable { public String method; public String file; public String className; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java b/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java index 5d789ac386..8026215088 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java @@ -14,6 +14,7 @@ import java.io.InputStream; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public class HttpUploadStream implements com.itmill.toolkit.terminal.UploadStream { diff --git a/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java b/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java index 81351daf0c..95818a4e46 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.PrintWriter; +import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; @@ -31,6 +32,7 @@ import com.itmill.toolkit.ui.Component; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public class JsonPaintTarget implements PaintTarget { /* Document type declarations */ @@ -813,7 +815,7 @@ public class JsonPaintTarget implements PaintTarget { * @author mattitahvonen * */ - class JsonTag { + class JsonTag implements Serializable { boolean firstField = false; Vector variables = new Vector(); @@ -963,14 +965,14 @@ public class JsonPaintTarget implements PaintTarget { } } - abstract class Variable { + abstract class Variable implements Serializable { String name; public abstract String getJsonPresentation(); } - class BooleanVariable extends Variable { + class BooleanVariable extends Variable implements Serializable { boolean value; public BooleanVariable(VariableOwner owner, String name, boolean v) { @@ -985,7 +987,7 @@ public class JsonPaintTarget implements PaintTarget { } - class StringVariable extends Variable { + class StringVariable extends Variable implements Serializable { String value; public StringVariable(VariableOwner owner, String name, String v) { @@ -1000,7 +1002,7 @@ public class JsonPaintTarget implements PaintTarget { } - class IntVariable extends Variable { + class IntVariable extends Variable implements Serializable { int value; public IntVariable(VariableOwner owner, String name, int v) { @@ -1014,7 +1016,7 @@ public class JsonPaintTarget implements PaintTarget { } } - class LongVariable extends Variable { + class LongVariable extends Variable implements Serializable { long value; public LongVariable(VariableOwner owner, String name, long v) { @@ -1028,7 +1030,7 @@ public class JsonPaintTarget implements PaintTarget { } } - class FloatVariable extends Variable { + class FloatVariable extends Variable implements Serializable { float value; public FloatVariable(VariableOwner owner, String name, float v) { @@ -1042,7 +1044,7 @@ public class JsonPaintTarget implements PaintTarget { } } - class DoubleVariable extends Variable { + class DoubleVariable extends Variable implements Serializable { double value; public DoubleVariable(VariableOwner owner, String name, double v) { @@ -1056,7 +1058,7 @@ public class JsonPaintTarget implements PaintTarget { } } - class ArrayVariable extends Variable { + class ArrayVariable extends Variable implements Serializable { String[] value; public ArrayVariable(VariableOwner owner, String name, String[] v) { diff --git a/src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java b/src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java index 1ec2d9f93b..20df917afb 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java @@ -6,6 +6,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -28,7 +29,9 @@ import com.itmill.toolkit.Application; * @author marc
*
*/
-public class PortletApplicationContext extends WebApplicationContext {
+@SuppressWarnings("serial")
+public class PortletApplicationContext extends WebApplicationContext implements
+ Serializable {
protected PortletSession portletSession;
@@ -182,7 +185,7 @@ public class PortletApplicationContext extends WebApplicationContext { }
}
- public interface PortletListener {
+ public interface PortletListener extends Serializable {
public void handleRenderRequest(RenderRequest request,
RenderResponse response);
@@ -190,7 +193,8 @@ public class PortletApplicationContext extends WebApplicationContext { ActionResponse response);
}
- private class RestrictedRenderResponse implements RenderResponse {
+ private class RestrictedRenderResponse implements RenderResponse,
+ Serializable {
private RenderResponse response;
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/SessionExpired.java b/src/com/itmill/toolkit/terminal/gwt/server/SessionExpired.java index bd085725a3..c6a5238e90 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/SessionExpired.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/SessionExpired.java @@ -1,7 +1,6 @@ package com.itmill.toolkit.terminal.gwt.server; +@SuppressWarnings("serial") public class SessionExpired extends Exception { - private static final long serialVersionUID = -2211425033877155423L; - } diff --git a/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java b/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java index 9ec3b5a2e1..098c728587 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java @@ -1,13 +1,9 @@ package com.itmill.toolkit.terminal.gwt.server;
+@SuppressWarnings("serial")
public class SystemMessageException extends RuntimeException {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = -8249486543123286960L;
-
- /**
* Cause of the method exception
*/
private Throwable cause;
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java index 143811789a..0193b4d3d7 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java @@ -6,9 +6,11 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.File; import java.io.PrintWriter; +import java.io.Serializable; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; @@ -30,17 +32,20 @@ import com.itmill.toolkit.service.ApplicationContext; * @VERSION@ * @since 3.1 */ +@SuppressWarnings("serial") public class WebApplicationContext implements ApplicationContext, - HttpSessionBindingListener { + HttpSessionBindingListener, Serializable { protected List listeners; - protected HttpSession session; + protected transient HttpSession session; protected final HashSet applications = new HashSet(); protected WebBrowser browser = new WebBrowser(); + protected HashMap<Application, CommunicationManager> applicationToAjaxAppMgrMap = new HashMap<Application, CommunicationManager>(); + /** * Creates a new Web Application Context. * @@ -230,7 +235,7 @@ public class WebApplicationContext implements ApplicationContext, final Application app = (Application) applications.iterator() .next(); app.close(); - ApplicationServlet.applicationToAjaxAppMgrMap.remove(app); + applicationToAjaxAppMgrMap.remove(app); removeApplication(app); } } catch (Exception e) { @@ -257,4 +262,25 @@ public class WebApplicationContext implements ApplicationContext, public WebBrowser getBrowser() { return browser; } + + /** + * Gets communication manager for an application. + * + * If this application has not been running before, new manager is created. + * + * @param application + * @return CommunicationManager + */ + protected CommunicationManager getApplicationManager( + Application application, ApplicationServlet servlet) { + CommunicationManager mgr = applicationToAjaxAppMgrMap.get(application); + + if (mgr == null) { + // Creates new manager + mgr = new CommunicationManager(application, servlet); + applicationToAjaxAppMgrMap.put(application, mgr); + } + return mgr; + } + } diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java index 027a8361de..789c28b843 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java @@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletRequest; import com.itmill.toolkit.terminal.Terminal; +@SuppressWarnings("serial") public class WebBrowser implements Terminal { private int screenHeight = 0; diff --git a/src/com/itmill/toolkit/tests/components/beanitemcontainer/TestBeanItemContainerUsage.java b/src/com/itmill/toolkit/tests/components/beanitemcontainer/TestBeanItemContainerUsage.java new file mode 100644 index 0000000000..b01197c759 --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/beanitemcontainer/TestBeanItemContainerUsage.java @@ -0,0 +1,75 @@ +package com.itmill.toolkit.tests.components.beanitemcontainer; + +import java.util.ArrayList; +import java.util.List; + +import com.itmill.toolkit.data.util.BeanItemContainer; +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Table; + +public class TestBeanItemContainerUsage extends TestBase { + + @Override + protected String getDescription() { + return "A test for the BeanItemContainer. The table should contain three persons and show their first and last names and their age."; + } + + @Override + protected Integer getTicketNumber() { + return 1061; + } + + @Override + protected void setup() { + Table t = new Table("Table containing Persons"); + t.setPageLength(5); + t.setWidth("100%"); + List<Person> persons = new ArrayList<Person>(); + persons.add(new Person("Jones", "Birchman", 35)); + persons.add(new Person("Marc", "Smith", 30)); + persons.add(new Person("Greg", "Sandman", 75)); + + BeanItemContainer<Person> bic = new BeanItemContainer<Person>(persons); + t.setContainerDataSource(bic); + + addComponent(t); + } + + public static class Person { + private String firstName; + private String lastName; + private int age; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public Person(String firstName, String lastName, int age) { + super(); + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + } + + } +} diff --git a/src/com/itmill/toolkit/tests/components/datefield/TestDatefieldYear.java b/src/com/itmill/toolkit/tests/components/datefield/TestDatefieldYear.java new file mode 100644 index 0000000000..5be49c1b0c --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/datefield/TestDatefieldYear.java @@ -0,0 +1,28 @@ +package com.itmill.toolkit.tests.components.datefield; + +import java.util.Date; + +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.DateField; + +public class TestDatefieldYear extends TestBase { + + @Override + protected String getDescription() { + return "A popup with resolution year or month should update the textfield when browsing. The value displayed in the textfield should always be the same as the popup shows."; + } + + @Override + protected Integer getTicketNumber() { + return 2813; + } + + @Override + protected void setup() { + DateField df = new DateField("Year", new Date(2009 - 1900, 4 - 1, 1)); + df.setResolution(DateField.RESOLUTION_YEAR); + df.setResolution(DateField.RESOLUTION_MONTH); + addComponent(df); + + } +} diff --git a/src/com/itmill/toolkit/tests/components/embedded/EmbeddedTooltip.java b/src/com/itmill/toolkit/tests/components/embedded/EmbeddedTooltip.java new file mode 100644 index 0000000000..f7644666ec --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/embedded/EmbeddedTooltip.java @@ -0,0 +1,28 @@ +package com.itmill.toolkit.tests.components.embedded;
+
+import com.itmill.toolkit.terminal.ThemeResource;
+import com.itmill.toolkit.tests.components.TestBase;
+import com.itmill.toolkit.ui.Embedded;
+
+public class EmbeddedTooltip extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The tooltip for an Embedded image should be visible also when hovering the image";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2853;
+ }
+
+ @Override
+ protected void setup() {
+ Embedded e = new Embedded("Embedded caption", new ThemeResource(
+ "icons/64/ok.png"));
+ e
+ .setDescription("Embedded tooltip, only shown on caption, not on the image");
+ addComponent(e);
+
+ }
+}
diff --git a/src/com/itmill/toolkit/tests/components/table/ColumnWidths.java b/src/com/itmill/toolkit/tests/components/table/ColumnWidths.java index af03414db5..1d7f9cc6fc 100644 --- a/src/com/itmill/toolkit/tests/components/table/ColumnWidths.java +++ b/src/com/itmill/toolkit/tests/components/table/ColumnWidths.java @@ -14,7 +14,8 @@ public class ColumnWidths extends TestBase { + "columns (by server or user (dragged)) columns " + "must consume the excess space. Space is divided " + "by default according to natural widths of columns." - + " Lastname should get 1/3 of excess spsace, the las column 2/3."; + + "In example last column is fixed width. Other columns" + + " should divide excess space relatively to 'natural' width unless user has resized column."; } @@ -58,7 +59,7 @@ public class ColumnWidths extends TestBase { table.setContainerDataSource(idx); table.setColumnHeader("firstname", "FirstName"); - table.setColumnHeader("lastname", "LastName"); + table.setColumnHeader("lastname", "LastName with long header"); table.setColumnWidth("150pxfixedCol", 150); diff --git a/src/com/itmill/toolkit/tests/components/table/ContainerSizeChange.java b/src/com/itmill/toolkit/tests/components/table/ContainerSizeChange.java new file mode 100644 index 0000000000..b7356fca5b --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/table/ContainerSizeChange.java @@ -0,0 +1,91 @@ +package com.itmill.toolkit.tests.components.table; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.util.IndexedContainer; +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Table; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public class ContainerSizeChange extends TestBase { + + private Table table; + private MyDataSource ds; + + @Override + protected String getDescription() { + return "A table should be able to handle a decrease in the size of the container. The original container here contains 50 items and the decrease button removes 10 of these. To reproduce the problem: Click 'Decrease size' two times to reduce size to 30 and scroll to the end (50). What should happen is the table should notice the container size has decreased and show the last items which now exists in the new container."; + } + + @Override + protected Integer getTicketNumber() { + return 2862; + } + + @Override + protected void setup() { + table = new Table("A table"); + ds = new MyDataSource(); + table.setContainerDataSource(ds); + table.setPageLength(5); + addComponent(table); + + Button b = new Button("Decrease size", new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + ds.decreaseSize(); + } + + }); + + addComponent(b); + + b = new Button("Increase size", new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + ds.increaseSize(); + } + + }); + + addComponent(b); + + } + +} + +class MyDataSource extends IndexedContainer { + + private int size = 0; + + public MyDataSource() { + addContainerProperty("a", String.class, ""); + addContainerProperty("b", String.class, ""); + addContainerProperty("c", String.class, ""); + + for (int i = 0; i < 100; i++) { + Item item = addItem(String.valueOf(i)); + item.getItemProperty("a").setValue("a " + i); + item.getItemProperty("b").setValue("b " + i); + item.getItemProperty("c").setValue("c " + i); + } + size = 50; + } + + public void increaseSize() { + size += 10; + + } + + public void decreaseSize() { + if (size > 10) { + size -= 10; + } + + } + + @Override + public int size() { + return size; + } +} diff --git a/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java b/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java index f02a110bab..dc366e40fe 100644 --- a/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java +++ b/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java @@ -8,6 +8,9 @@ import com.itmill.toolkit.ui.Table; public class TableRowHeight2 extends TestBase { + private static final int TABLE_EXTRA = 2; // borders + private static final int COLEXTRASPACE = 6; // cell margins by theme + @Override protected String getDescription() { return "The table contains 2 rows, which both should be shown completely as the table height is undefined."; @@ -25,10 +28,16 @@ public class TableRowHeight2 extends TestBase { vl.setSizeFull(); Table table = new Table(); - table.setWidth("300px"); + + int COL_TITLE_W = 200; + int COL_TEST_W = 98; + + table + .setWidth((COL_TEST_W + COL_TITLE_W + 2 * COLEXTRASPACE + TABLE_EXTRA) + + "px"); table.setPageLength(0); - table.setColumnWidth("title", 200); - table.setColumnWidth("test", 98); + table.setColumnWidth("title", COL_TITLE_W); + table.setColumnWidth("test", COL_TEST_W); table.addContainerProperty("title", Button.class, ""); table.addContainerProperty("test", Button.class, ""); for (int i = 0; i < 2; i++) { diff --git a/src/com/itmill/toolkit/tests/components/table/TestCurrentPageFirstItem.java b/src/com/itmill/toolkit/tests/components/table/TestCurrentPageFirstItem.java new file mode 100644 index 0000000000..fd4aed015d --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/table/TestCurrentPageFirstItem.java @@ -0,0 +1,60 @@ +package com.itmill.toolkit.tests.components.table;
+
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.data.Container;
+import com.itmill.toolkit.data.Item;
+import com.itmill.toolkit.data.util.IndexedContainer;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.Table;
+import com.itmill.toolkit.ui.VerticalLayout;
+import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+import com.itmill.toolkit.ui.Button.ClickListener;
+
+public class TestCurrentPageFirstItem extends Application implements
+ ClickListener {
+
+ private Button buttonIndex;
+ private Button buttonItem;
+ private Table table;
+ private int counter = 0;
+ IndexedContainer container = new IndexedContainer();
+
+ @Override
+ public void init() {
+ try {
+ Window main = new Window("Table header Test");
+ setMainWindow(main);
+ main.setSizeFull();
+ // setTheme("testtheme");
+ VerticalLayout baseLayout = new VerticalLayout();
+ main.setLayout(baseLayout);
+
+ table = new Table();
+ container.addContainerProperty("row", String.class, "");
+ table.setContainerDataSource(container);
+ table.setWidth("100%");
+ table.setPageLength(3);
+ buttonIndex = new Button("Add row and select last index", this);
+ buttonItem = new Button("Add row and select last item", this);
+
+ baseLayout.addComponent(table);
+ baseLayout.addComponent(buttonIndex);
+ baseLayout.addComponent(buttonItem);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void buttonClick(ClickEvent event) {
+ Item item = container.addItem(++counter);
+ item.getItemProperty("row").setValue(counter + "");
+ table.select(counter);
+ if (event.getButton() == buttonIndex) {
+ table.setCurrentPageFirstItemIndex(((Container.Indexed) table
+ .getContainerDataSource()).indexOfId(counter));
+ } else {
+ table.setCurrentPageFirstItemId(counter);
+ }
+ }
+}
diff --git a/src/com/itmill/toolkit/tests/components/tabsheet/AddAndRemoveTabs.java b/src/com/itmill/toolkit/tests/components/tabsheet/AddAndRemoveTabs.java new file mode 100644 index 0000000000..2962905578 --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/tabsheet/AddAndRemoveTabs.java @@ -0,0 +1,60 @@ +package com.itmill.toolkit.tests.components.tabsheet; + +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.HorizontalLayout; +import com.itmill.toolkit.ui.TabSheet; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public class AddAndRemoveTabs extends TestBase { + private TabSheet tabSheet; + + private int counter = 0; + + @Override + public void setup() { + tabSheet = new TabSheet(); + addTab(); + addComponent(tabSheet); + + Button addTabBtn = new Button("Add new tab", + new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + addTab(); + } + + }); + addComponent(addTabBtn); + } + + private void addTab() { + final HorizontalLayout layout = new HorizontalLayout(); + layout.setCaption("Test " + counter); + + Button closeTab = new Button("Close tab", new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + tabSheet.removeComponent(layout); + + } + + }); + + layout.addComponent(closeTab); + + tabSheet.addComponent(layout); + counter++; + } + + @Override + protected String getDescription() { + return "Removing all tabs and then adding new tabs should work properly and without javascript errors. All new tabs should be displayed and not only the first one"; + } + + @Override + protected Integer getTicketNumber() { + return 2861; + } + +} diff --git a/src/com/itmill/toolkit/tests/components/tabsheet/TabSheetCaptions.java b/src/com/itmill/toolkit/tests/components/tabsheet/TabSheetCaptions.java new file mode 100644 index 0000000000..be9cfaafbb --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/tabsheet/TabSheetCaptions.java @@ -0,0 +1,44 @@ +package com.itmill.toolkit.tests.components.tabsheet;
+
+import com.itmill.toolkit.tests.components.TestBase;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Panel;
+import com.itmill.toolkit.ui.TabSheet;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+public class TabSheetCaptions extends TestBase {
+
+ Panel panel1;
+
+ @Override
+ protected String getDescription() {
+ return "Updating the tabsheet tab text should not change the caption of the component. Click on the button to change the tab text. This must update the tab and not touch the Panel's caption.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2846;
+ }
+
+ @Override
+ protected void setup() {
+ final TabSheet tabSheet = new TabSheet();
+
+ panel1 = new Panel("tab 1");
+ panel1.setSizeFull();
+ panel1.getLayout().setSizeFull();
+ panel1.addComponent(new Label("This is first panel"));
+ tabSheet.addTab(panel1);
+
+ Button button = new Button("Update tab caption");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ tabSheet.setTabCaption(panel1, "This is a new caption");
+ }
+ });
+
+ addComponent(tabSheet);
+ addComponent(button);
+ }
+}
diff --git a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java index 6631df2963..f3c02dce3d 100644 --- a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java +++ b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java @@ -1,12 +1,73 @@ package com.itmill.toolkit.tests.layouts;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import com.itmill.toolkit.data.Item;
+import com.itmill.toolkit.data.Property;
+import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.data.Property.ValueChangeListener;
+import com.itmill.toolkit.data.util.BeanItem;
+import com.itmill.toolkit.data.util.IndexedContainer;
import com.itmill.toolkit.tests.components.TestBase;
import com.itmill.toolkit.ui.AbsoluteLayout;
+import com.itmill.toolkit.ui.AbstractComponent;
+import com.itmill.toolkit.ui.BaseFieldFactory;
import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.Component;
+import com.itmill.toolkit.ui.Field;
+import com.itmill.toolkit.ui.FieldFactory;
+import com.itmill.toolkit.ui.Form;
import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Layout;
+import com.itmill.toolkit.ui.NativeSelect;
+import com.itmill.toolkit.ui.TextField;
+import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.ui.Button.ClickEvent;
public class TestAbsoluteLayout extends TestBase {
+ private static class MFieldFactory extends BaseFieldFactory {
+
+ @Override
+ public Field createField(Item item, Object propertyId,
+ Component uiContext) {
+ if (propertyId.equals("CSSString")) {
+ TextField f = new TextField();
+ f.setRows(5);
+ f.setHeight("8em");
+ f.setCaption("CSS string");
+ return f;
+ } else if (((String) propertyId).contains("Units")) {
+ NativeSelect s = new NativeSelect() {
+ };
+ s.addContainerProperty("caption", String.class, "");
+ s.setItemCaptionPropertyId("caption");
+ s.setNullSelectionAllowed(false);
+ for (int i = 0; i < Layout.UNIT_SYMBOLS.length; i++) {
+ Item unitItem = s.addItem(i);
+ unitItem.getItemProperty("caption").setValue(
+ Layout.UNIT_SYMBOLS[i]);
+ }
+ return s;
+ }
+
+ return super.createField(item, propertyId, uiContext);
+ }
+
+ private static MFieldFactory instance;
+
+ public static FieldFactory get() {
+ if (instance == null) {
+ instance = new MFieldFactory();
+ }
+ return instance;
+ }
+ };
+
@Override
protected String getDescription() {
return "This is absolute layout tester.";
@@ -22,6 +83,8 @@ public class TestAbsoluteLayout extends TestBase { AbsoluteLayout layout = new AbsoluteLayout();
setTheme("tests-tickets");
layout.setStyleName("cyan");
+ layout.setWidth("1000px");
+ layout.setHeight("500px");
layout.addComponent(new Label("Hello World"));
@@ -50,5 +113,200 @@ public class TestAbsoluteLayout extends TestBase { getLayout().setSizeFull();
getLayout().addComponent(layout);
+ getMainWindow().addWindow(new EditorWindow(layout));
+
}
+
+ public class EditorWindow extends Window {
+ private final AbsoluteLayout l;
+ private Form componentEditor;
+ private Form positionEditor;
+
+ public EditorWindow(AbsoluteLayout lo) {
+ super("AbsoluteLayout editor aka köyhän miehen wysiwyg");
+ l = lo;
+
+ setHeight("600px");
+
+ Button componentChooser = new Button("choose component to edit");
+ componentChooser.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ final Window chooser = new Window("Choose component");
+ chooser.getLayout().setSizeUndefined();
+ chooser.setModal(true);
+
+ NativeSelect select = new NativeSelect(
+ "Choose component to edit");
+
+ select.setNullSelectionAllowed(false);
+
+ IndexedContainer container = new IndexedContainer();
+ container.addContainerProperty("caption", String.class, "");
+ Iterator<Component> componentIterator = l
+ .getComponentIterator();
+ while (componentIterator.hasNext()) {
+ AbstractComponent next = (AbstractComponent) componentIterator
+ .next();
+ Item item = container.addItem(next);
+
+ String caption = next.getTag();
+
+ caption += "; cap: " + next.getCaption() + "; debugid"
+ + getDebugId();
+
+ if (next instanceof Property) {
+ caption += " value:" + ((Property) next).getValue();
+ }
+
+ item.getItemProperty("caption").setValue(caption);
+ }
+ select.setContainerDataSource(container);
+ select.setItemCaptionPropertyId("caption");
+ select.setImmediate(true);
+
+ select.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ editcomponent((Component) event.getProperty()
+ .getValue());
+ getMainWindow().removeWindow(chooser);
+ }
+
+ });
+
+ chooser.addComponent(select);
+
+ getMainWindow().addWindow(chooser);
+
+ }
+ });
+
+ addComponent(componentChooser);
+
+ Button addComp = new Button("add component");
+ addComp.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ final Window chooser = new Window(
+ "Choose component type to add");
+ chooser.getLayout().setSizeUndefined();
+ chooser.setModal(true);
+
+ NativeSelect select = new NativeSelect(
+ "Choose component to edit");
+
+ select.setNullSelectionAllowed(false);
+
+ IndexedContainer container = new IndexedContainer();
+
+ URL resource = AbstractComponent.class.getResource(".");
+ File directory = new File(resource.getFile());
+ if (directory.exists()) {
+ // Get the list of the files contained in the
+ // package
+ final String[] files = directory.list();
+ for (int j = 0; j < files.length; j++) {
+ // we are only interested in .class files
+ if (files[j].endsWith(".class")) {
+ // removes the .class extension
+ String p = resource.toString()
+ + files[j].substring(0, files[j]
+ .length() - 6);
+ p = p.replaceAll(".*classes/", "");
+ p = p.replaceAll("/", ".");
+ Class c;
+ try {
+ c = Class.forName(p);
+ if (AbstractComponent.class
+ .isAssignableFrom(c)
+ && !p.toLowerCase().contains(
+ "layout")
+ && !p.toLowerCase().contains(
+ "abstract")) {
+ container.addItem(c);
+ }
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ select.setContainerDataSource(container);
+ select.setImmediate(true);
+
+ select.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ Class c = (Class) event.getProperty().getValue();
+
+ try {
+ Component newInstance = (Component) c
+ .newInstance();
+ l.addComponent(newInstance);
+ editcomponent(newInstance);
+ getMainWindow().removeWindow(chooser);
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ });
+
+ chooser.addComponent(select);
+
+ getMainWindow().addWindow(chooser);
+
+ }
+ });
+
+ addComponent(addComp);
+
+ componentEditor = new Form();
+ componentEditor.setWriteThrough(false);
+ componentEditor.setCaption("Component properties:");
+ componentEditor.setFieldFactory(MFieldFactory.get());
+ addComponent(componentEditor);
+
+ positionEditor = new Form();
+ positionEditor.setCaption("Component position");
+ positionEditor.setWriteThrough(false);
+ positionEditor.setFieldFactory(MFieldFactory.get());
+ addComponent(positionEditor);
+
+ Button b = new Button("Commit changes", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ positionEditor.commit();
+ componentEditor.commit();
+ }
+ });
+ addComponent(b);
+
+ }
+
+ private void editcomponent(Component value) {
+
+ BeanItem beanItem = new BeanItem(value);
+ String c = "Component properties for "
+ + value.getClass().getSimpleName();
+ ArrayList<String> fields = new ArrayList<String>(Arrays
+ .asList(new String[] { "width", "widthUnits", "height",
+ "heightUnits", "caption", "styleName" }));
+ if (value instanceof Label) {
+ c += "(" + ((Label) value).getValue() + ")";
+ fields.add("value");
+ }
+
+ componentEditor.setItemDataSource(beanItem, fields);
+
+ beanItem = new BeanItem(l.getPosition(value));
+ componentEditor.setCaption(c);
+
+ positionEditor.setItemDataSource(beanItem);
+
+ }
+ }
+
}
diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket695.java b/src/com/itmill/toolkit/tests/tickets/Ticket695.java new file mode 100644 index 0000000000..c37ee50c51 --- /dev/null +++ b/src/com/itmill/toolkit/tests/tickets/Ticket695.java @@ -0,0 +1,42 @@ +package com.itmill.toolkit.tests.tickets; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +import com.itmill.toolkit.Application; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Window; +import com.itmill.toolkit.ui.Button.ClickEvent; + +@SuppressWarnings("serial") +public class Ticket695 extends Application { + + @Override + public void init() { + final Window w = new Window("Serialization test #695"); + setMainWindow(w); + Button b = new Button("Serialize ApplicationContext"); + w.addComponent(b); + b.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + try { + ObjectOutputStream oos = new ObjectOutputStream(buffer); + long t = System.currentTimeMillis(); + oos.writeObject(getContext()); + w.showNotification("ApplicationContext serialized (" + + buffer.size() + "bytes) in " + + (System.currentTimeMillis() - t) + "ms"); + } catch (IOException e) { + e.printStackTrace(); + w + .showNotification("ApplicationContext serialization failed - see console for stacktrace"); + } + + } + }); + } + +} diff --git a/src/com/itmill/toolkit/ui/AbsoluteLayout.java b/src/com/itmill/toolkit/ui/AbsoluteLayout.java index 61a12bb76f..fd5e72aff6 100644 --- a/src/com/itmill/toolkit/ui/AbsoluteLayout.java +++ b/src/com/itmill/toolkit/ui/AbsoluteLayout.java @@ -1,9 +1,10 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Map; import com.itmill.toolkit.terminal.PaintException; @@ -15,9 +16,10 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IAbsoluteLayout; * positioning. * */ +@SuppressWarnings("serial") public class AbsoluteLayout extends AbstractLayout { - private Collection<Component> components = new HashSet<Component>(); + private Collection<Component> components = new LinkedHashSet<Component>(); private Map<Component, ComponentPosition> componentToCoordinates = new HashMap<Component, ComponentPosition>(); public AbsoluteLayout() { @@ -72,13 +74,13 @@ public class AbsoluteLayout extends AbstractLayout { * in generic java tools * */ - public class ComponentPosition { + public class ComponentPosition implements Serializable { private int zIndex = -1; - private float top = -1; - private float right = -1; - private float bottom = -1; - private float left = -1; + private float topValue = -1; + private float rightValue = -1; + private float bottomValue = -1; + private float leftValue = -1; private int topUnits; private int rightUnits; @@ -99,10 +101,18 @@ public class AbsoluteLayout extends AbstractLayout { for (int i = 0; i < cssProperties.length; i++) { String[] keyValuePair = cssProperties[i].split(":"); String key = keyValuePair[0].trim(); + if (key.equals("")) { + continue; + } if (key.equals("z-index")) { zIndex = Integer.parseInt(keyValuePair[1]); } else { - String value = keyValuePair[1].trim(); + String value; + if (keyValuePair.length > 1) { + value = keyValuePair[1].trim(); + } else { + value = ""; + } String unit = value.replaceAll("[0-9\\.]+", ""); if (!unit.equals("")) { value = value.substring(0, value.indexOf(unit)).trim(); @@ -110,16 +120,16 @@ public class AbsoluteLayout extends AbstractLayout { float v = Float.parseFloat(value); int unitInt = parseCssUnit(unit); if (key.equals("top")) { - top = v; + topValue = v; topUnits = unitInt; } else if (key.equals("right")) { - right = v; + rightValue = v; rightUnits = unitInt; } else if (key.equals("bottom")) { - bottom = v; + bottomValue = v; bottomUnits = unitInt; } else if (key.equals("left")) { - left = v; + leftValue = v; leftUnits = unitInt; } } @@ -138,17 +148,17 @@ public class AbsoluteLayout extends AbstractLayout { public String getCSSString() { String s = ""; - if (top >= 0) { - s += "top:" + top + UNIT_SYMBOLS[topUnits] + ";"; + if (topValue >= 0) { + s += "top:" + topValue + UNIT_SYMBOLS[topUnits] + ";"; } - if (right >= 0) { - s += "right:" + right + UNIT_SYMBOLS[rightUnits] + ";"; + if (rightValue >= 0) { + s += "right:" + rightValue + UNIT_SYMBOLS[rightUnits] + ";"; } - if (bottom >= 0) { - s += "bottom:" + bottom + UNIT_SYMBOLS[bottomUnits] + ";"; + if (bottomValue >= 0) { + s += "bottom:" + bottomValue + UNIT_SYMBOLS[bottomUnits] + ";"; } - if (left >= 0) { - s += "left:" + left + UNIT_SYMBOLS[leftUnits] + ";"; + if (leftValue >= 0) { + s += "left:" + leftValue + UNIT_SYMBOLS[leftUnits] + ";"; } if (zIndex >= 0) { s += "z-index:" + zIndex + ";"; @@ -158,28 +168,28 @@ public class AbsoluteLayout extends AbstractLayout { public void setTop(float topValue, int topUnits) { validateLength(topValue, topUnits); - top = topValue; + this.topValue = topValue; this.topUnits = topUnits; requestRepaint(); } public void setRight(float rightValue, int rightUnits) { validateLength(rightValue, rightUnits); - right = rightValue; + this.rightValue = rightValue; this.rightUnits = rightUnits; requestRepaint(); } public void setBottom(float bottomValue, int units) { validateLength(bottomValue, units); - bottom = bottomValue; + this.bottomValue = bottomValue; bottomUnits = units; requestRepaint(); } public void setLeft(float leftValue, int units) { validateLength(leftValue, units); - left = leftValue; + this.leftValue = leftValue; leftUnits = units; requestRepaint(); } @@ -189,6 +199,142 @@ public class AbsoluteLayout extends AbstractLayout { requestRepaint(); } + public void setTopValue(float topValue) { + validateLength(topValue, topUnits); + this.topValue = topValue; + requestRepaint(); + } + + public float getTopValue() { + return topValue; + } + + /** + * @return the rightValue + */ + public float getRightValue() { + return rightValue; + } + + /** + * @param rightValue + * the rightValue to set + */ + public void setRightValue(float rightValue) { + validateLength(rightValue, rightUnits); + this.rightValue = rightValue; + requestRepaint(); + } + + /** + * @return the bottomValue + */ + public float getBottomValue() { + return bottomValue; + } + + /** + * @param bottomValue + * the bottomValue to set + */ + public void setBottomValue(float bottomValue) { + validateLength(bottomValue, bottomUnits); + this.bottomValue = bottomValue; + requestRepaint(); + } + + /** + * @return the leftValue + */ + public float getLeftValue() { + return leftValue; + } + + /** + * @param leftValue + * the leftValue to set + */ + public void setLeftValue(float leftValue) { + validateLength(leftValue, leftUnits); + this.leftValue = leftValue; + requestRepaint(); + } + + /** + * @return the topUnits + */ + public int getTopUnits() { + return topUnits; + } + + /** + * @param topUnits + * the topUnits to set + */ + public void setTopUnits(int topUnits) { + validateLength(topValue, topUnits); + this.topUnits = topUnits; + requestRepaint(); + } + + /** + * @return the rightUnits + */ + public int getRightUnits() { + return rightUnits; + } + + /** + * @param rightUnits + * the rightUnits to set + */ + public void setRightUnits(int rightUnits) { + validateLength(rightValue, rightUnits); + this.rightUnits = rightUnits; + requestRepaint(); + } + + /** + * @return the bottomUnits + */ + public int getBottomUnits() { + return bottomUnits; + } + + /** + * @param bottomUnits + * the bottomUnits to set + */ + public void setBottomUnits(int bottomUnits) { + validateLength(bottomValue, bottomUnits); + this.bottomUnits = bottomUnits; + requestRepaint(); + } + + /** + * @return the leftUnits + */ + public int getLeftUnits() { + return leftUnits; + } + + /** + * @param leftUnits + * the leftUnits to set + */ + public void setLeftUnits(int leftUnits) { + validateLength(leftValue, leftUnits); + this.leftUnits = leftUnits; + requestRepaint(); + } + + /** + * @return the zIndex + */ + public int getZIndex() { + return zIndex; + } + } @Override diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 0d7f40d5b2..f067b52b88 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; @@ -35,6 +36,7 @@ import com.itmill.toolkit.terminal.gwt.server.ComponentSizeValidator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public abstract class AbstractComponent implements Component, MethodEventSource { /* Private members */ @@ -1236,7 +1238,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource public interface ComponentErrorEvent extends Terminal.ErrorEvent { } - public interface ComponentErrorHandler { + public interface ComponentErrorHandler extends Serializable { /** * Handle the component error * diff --git a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java index b9e96533e6..b46117d115 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java +++ b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java @@ -19,6 +19,7 @@ import java.util.LinkedList; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public abstract class AbstractComponentContainer extends AbstractComponent implements ComponentContainer { diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java index 4d717826e6..3cbc788d6b 100644 --- a/src/com/itmill/toolkit/ui/AbstractField.java +++ b/src/com/itmill/toolkit/ui/AbstractField.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; @@ -49,6 +50,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public abstract class AbstractField extends AbstractComponent implements Field, Property.ReadOnlyStatusChangeNotifier { @@ -873,12 +875,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * @since 3.0 */ public class ReadOnlyStatusChangeEvent extends Component.Event implements - Property.ReadOnlyStatusChangeEvent { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3258688823264161846L; + Property.ReadOnlyStatusChangeEvent, Serializable { /** * New instance of text change event. diff --git a/src/com/itmill/toolkit/ui/AbstractLayout.java b/src/com/itmill/toolkit/ui/AbstractLayout.java index d250501b46..63e70b8350 100644 --- a/src/com/itmill/toolkit/ui/AbstractLayout.java +++ b/src/com/itmill/toolkit/ui/AbstractLayout.java @@ -17,6 +17,7 @@ import com.itmill.toolkit.ui.Layout.MarginHandler; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public abstract class AbstractLayout extends AbstractComponentContainer implements Layout, MarginHandler { diff --git a/src/com/itmill/toolkit/ui/AbstractOrderedLayout.java b/src/com/itmill/toolkit/ui/AbstractOrderedLayout.java index 8d4b78b3ed..94a3bf3778 100644 --- a/src/com/itmill/toolkit/ui/AbstractOrderedLayout.java +++ b/src/com/itmill/toolkit/ui/AbstractOrderedLayout.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; import com.itmill.toolkit.terminal.Sizeable; +@SuppressWarnings("serial") public abstract class AbstractOrderedLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.SpacingHandler { diff --git a/src/com/itmill/toolkit/ui/AbstractSelect.java b/src/com/itmill/toolkit/ui/AbstractSelect.java index 86fbc7adc2..05f08c5a8f 100644 --- a/src/com/itmill/toolkit/ui/AbstractSelect.java +++ b/src/com/itmill/toolkit/ui/AbstractSelect.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -41,6 +42,7 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public abstract class AbstractSelect extends AbstractField implements Container, Container.Viewer, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.ItemSetChangeNotifier, @@ -90,7 +92,7 @@ public abstract class AbstractSelect extends AbstractField implements * caption. <code>FILTERINGMODE_CONTAINS</code> (1) matches anywhere in the * caption. */ - public interface Filtering { + public interface Filtering extends Serializable { public static final int FILTERINGMODE_OFF = 0; public static final int FILTERINGMODE_STARTSWITH = 1; public static final int FILTERINGMODE_CONTAINS = 2; @@ -459,7 +461,7 @@ public abstract class AbstractSelect extends AbstractField implements return newItemHandler; } - public interface NewItemHandler { + public interface NewItemHandler extends Serializable { void addNewItem(String newItemCaption); } @@ -1464,7 +1466,8 @@ public abstract class AbstractSelect extends AbstractField implements /** * Implementation of item set change event. */ - private class ItemSetChangeEvent implements Container.ItemSetChangeEvent { + private class ItemSetChangeEvent implements Serializable, + Container.ItemSetChangeEvent { /** * Gets the Property where the event occurred. @@ -1481,7 +1484,7 @@ public abstract class AbstractSelect extends AbstractField implements * Implementation of property set change event. */ private class PropertySetChangeEvent implements - Container.PropertySetChangeEvent { + Container.PropertySetChangeEvent, Serializable { /** * Retrieves the Container whose contents have been modified. diff --git a/src/com/itmill/toolkit/ui/Accordion.java b/src/com/itmill/toolkit/ui/Accordion.java index 78d9c42743..c7aeb369e6 100644 --- a/src/com/itmill/toolkit/ui/Accordion.java +++ b/src/com/itmill/toolkit/ui/Accordion.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +@SuppressWarnings("serial") public class Accordion extends TabSheet { @Override diff --git a/src/com/itmill/toolkit/ui/Alignment.java b/src/com/itmill/toolkit/ui/Alignment.java index 6d7ad9accf..91afc090fe 100644 --- a/src/com/itmill/toolkit/ui/Alignment.java +++ b/src/com/itmill/toolkit/ui/Alignment.java @@ -1,12 +1,15 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; + import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.Bits; /** * Class containing information about alignment of a component. Use the * pre-instantiated classes. */ -public final class Alignment { +@SuppressWarnings("serial") +public final class Alignment implements Serializable { public static final Alignment TOP_RIGHT = new Alignment(Bits.ALIGNMENT_TOP + Bits.ALIGNMENT_RIGHT); diff --git a/src/com/itmill/toolkit/ui/AlignmentUtils.java b/src/com/itmill/toolkit/ui/AlignmentUtils.java index 6a3c556241..f9962bef22 100644 --- a/src/com/itmill/toolkit/ui/AlignmentUtils.java +++ b/src/com/itmill/toolkit/ui/AlignmentUtils.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,8 @@ import com.itmill.toolkit.ui.Layout.AlignmentHandler; * r,right for right alignment * */ -public class AlignmentUtils { +@SuppressWarnings("serial") +public class AlignmentUtils implements Serializable { private static int horizontalMask = AlignmentHandler.ALIGNMENT_LEFT | AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER diff --git a/src/com/itmill/toolkit/ui/BaseFieldFactory.java b/src/com/itmill/toolkit/ui/BaseFieldFactory.java index 00e27fdfcc..d5fd225322 100644 --- a/src/com/itmill/toolkit/ui/BaseFieldFactory.java +++ b/src/com/itmill/toolkit/ui/BaseFieldFactory.java @@ -25,6 +25,7 @@ import com.itmill.toolkit.data.Property; * @since 3.1 */ +@SuppressWarnings("serial") public class BaseFieldFactory implements FieldFactory { /** diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java index e90ac2f12a..2af5ba49a3 100644 --- a/src/com/itmill/toolkit/ui/Button.java +++ b/src/com/itmill/toolkit/ui/Button.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.ui; import java.io.IOException; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Map; @@ -20,6 +21,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Button extends AbstractField { /* Private members */ @@ -270,11 +272,6 @@ public class Button extends AbstractField { public class ClickEvent extends Component.Event { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3546647602931118393L; - - /** * New instance of text change event. * * @param source @@ -302,7 +299,7 @@ public class Button extends AbstractField { * @VERSION@ * @since 3.0 */ - public interface ClickListener { + public interface ClickListener extends Serializable { /** * Button has been pressed. diff --git a/src/com/itmill/toolkit/ui/CheckBox.java b/src/com/itmill/toolkit/ui/CheckBox.java index abb8d7bff6..731808a55e 100644 --- a/src/com/itmill/toolkit/ui/CheckBox.java +++ b/src/com/itmill/toolkit/ui/CheckBox.java @@ -8,6 +8,7 @@ import java.lang.reflect.Method; import com.itmill.toolkit.data.Property; +@SuppressWarnings("serial") public class CheckBox extends Button { /** * Creates a new switch button. diff --git a/src/com/itmill/toolkit/ui/ComboBox.java b/src/com/itmill/toolkit/ui/ComboBox.java index 1c251ef0a0..a901d00540 100644 --- a/src/com/itmill/toolkit/ui/ComboBox.java +++ b/src/com/itmill/toolkit/ui/ComboBox.java @@ -18,6 +18,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * can not turn on multi-select mode.
*
*/
+@SuppressWarnings("serial")
public class ComboBox extends Select {
private String inputPrompt = null;
@@ -74,6 +75,7 @@ public class ComboBox extends Select { this.inputPrompt = inputPrompt;
}
+ @Override
public void paintContent(PaintTarget target) throws PaintException {
if (inputPrompt != null) {
target.addAttribute("prompt", inputPrompt);
diff --git a/src/com/itmill/toolkit/ui/Component.java b/src/com/itmill/toolkit/ui/Component.java index 5368bca2cc..9fbc6231cc 100644 --- a/src/com/itmill/toolkit/ui/Component.java +++ b/src/com/itmill/toolkit/ui/Component.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Collection; import java.util.EventListener; import java.util.EventObject; @@ -25,7 +26,8 @@ import com.itmill.toolkit.terminal.VariableOwner; * @VERSION@ * @since 3.0 */ -public interface Component extends Paintable, VariableOwner, Sizeable { +public interface Component extends Paintable, VariableOwner, Sizeable, + Serializable { /** * Gets style for component. Multiple styles are joined with spaces. @@ -317,11 +319,6 @@ public interface Component extends Paintable, VariableOwner, Sizeable { public class Event extends EventObject { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 4048791277653274933L; - - /** * Constructs a new event with a specified source component. * * @param source @@ -335,7 +332,7 @@ public interface Component extends Paintable, VariableOwner, Sizeable { /** * Listener interface for receiving <code>Component.Event</code>s. */ - public interface Listener extends EventListener { + public interface Listener extends EventListener, Serializable { /** * Notifies the listener of a component event. @@ -366,13 +363,9 @@ public interface Component extends Paintable, VariableOwner, Sizeable { /** * Class of all component originated <code>ErrorEvent</code>s. */ + @SuppressWarnings("serial") public class ErrorEvent extends Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 4051323457293857333L; - private final ErrorMessage message; /** @@ -401,7 +394,7 @@ public interface Component extends Paintable, VariableOwner, Sizeable { /** * Listener interface for receiving <code>Component.Errors</code>s. */ - public interface ErrorListener extends EventListener { + public interface ErrorListener extends EventListener, Serializable { /** * Notifies the listener of a component error. diff --git a/src/com/itmill/toolkit/ui/ComponentContainer.java b/src/com/itmill/toolkit/ui/ComponentContainer.java index a73c8f4d6e..b696c0730d 100644 --- a/src/com/itmill/toolkit/ui/ComponentContainer.java +++ b/src/com/itmill/toolkit/ui/ComponentContainer.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Iterator; /** @@ -116,7 +117,7 @@ public interface ComponentContainer extends Component { /** * Component attach listener interface. */ - public interface ComponentAttachListener { + public interface ComponentAttachListener extends Serializable { /** * A new component is attached to container. @@ -130,7 +131,7 @@ public interface ComponentContainer extends Component { /** * Component detach listener interface. */ - public interface ComponentDetachListener { + public interface ComponentDetachListener extends Serializable { /** * A component has been detached from container. @@ -144,13 +145,9 @@ public interface ComponentContainer extends Component { /** * Component attach event sent when a component is attached to container. */ + @SuppressWarnings("serial") public class ComponentAttachEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257285812184692019L; - private final Component component; /** @@ -192,13 +189,9 @@ public interface ComponentContainer extends Component { /** * Component detach event sent when a component is detached from container. */ + @SuppressWarnings("serial") public class ComponentDetachEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3618140052337930290L; - private final Component component; /** diff --git a/src/com/itmill/toolkit/ui/CustomComponent.java b/src/com/itmill/toolkit/ui/CustomComponent.java index b0bc392f26..8313609475 100644 --- a/src/com/itmill/toolkit/ui/CustomComponent.java +++ b/src/com/itmill/toolkit/ui/CustomComponent.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Iterator; import com.itmill.toolkit.terminal.PaintException; @@ -23,6 +24,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class CustomComponent extends AbstractComponentContainer { /** @@ -146,23 +148,26 @@ public class CustomComponent extends AbstractComponentContainer { return "customcomponent"; } - public Iterator getComponentIterator() { - return new Iterator() { - boolean first = getCompositionRoot() != null; + private class ComponentIterator implements Iterator, Serializable { + boolean first = getCompositionRoot() != null; - public boolean hasNext() { - return first; - } + public boolean hasNext() { + return first; + } - public Object next() { - first = false; - return root; - } + public Object next() { + first = false; + return root; + } - public void remove() { - throw new UnsupportedOperationException(); - } - }; + public void remove() { + throw new UnsupportedOperationException(); + } + } + + @SuppressWarnings("unchecked") + public Iterator getComponentIterator() { + return new ComponentIterator(); } /** diff --git a/src/com/itmill/toolkit/ui/CustomLayout.java b/src/com/itmill/toolkit/ui/CustomLayout.java index 826ddfb9b2..5fdfe24770 100644 --- a/src/com/itmill/toolkit/ui/CustomLayout.java +++ b/src/com/itmill/toolkit/ui/CustomLayout.java @@ -40,6 +40,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class CustomLayout extends AbstractLayout { private static final int BUFFER_SIZE = 10000; diff --git a/src/com/itmill/toolkit/ui/DateField.java b/src/com/itmill/toolkit/ui/DateField.java index 96ddc08b9e..6f76de48c5 100644 --- a/src/com/itmill/toolkit/ui/DateField.java +++ b/src/com/itmill/toolkit/ui/DateField.java @@ -33,6 +33,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class DateField extends AbstractField { /* Private members */ diff --git a/src/com/itmill/toolkit/ui/Embedded.java b/src/com/itmill/toolkit/ui/Embedded.java index 9577a2b643..6b1e2af445 100644 --- a/src/com/itmill/toolkit/ui/Embedded.java +++ b/src/com/itmill/toolkit/ui/Embedded.java @@ -19,6 +19,7 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Embedded extends AbstractComponent { /** diff --git a/src/com/itmill/toolkit/ui/ExpandLayout.java b/src/com/itmill/toolkit/ui/ExpandLayout.java index 352d11d1fd..ea6f037daa 100644 --- a/src/com/itmill/toolkit/ui/ExpandLayout.java +++ b/src/com/itmill/toolkit/ui/ExpandLayout.java @@ -18,6 +18,7 @@ package com.itmill.toolkit.ui; * * @deprecated Deprecated in favor of the new OrderedLayout */ +@SuppressWarnings("serial") @Deprecated public class ExpandLayout extends OrderedLayout { diff --git a/src/com/itmill/toolkit/ui/Field.java b/src/com/itmill/toolkit/ui/Field.java index 9f63fe0f18..8fb339a35d 100644 --- a/src/com/itmill/toolkit/ui/Field.java +++ b/src/com/itmill/toolkit/ui/Field.java @@ -79,15 +79,11 @@ public interface Field extends Component, BufferedValidatable, Property, * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class ValueChangeEvent extends Component.Event implements Property.ValueChangeEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3545803169444672816L; - - /** * Constructs a new event object with the specified source field object. * * @param source diff --git a/src/com/itmill/toolkit/ui/FieldFactory.java b/src/com/itmill/toolkit/ui/FieldFactory.java index 01bc707cc7..6598577f48 100644 --- a/src/com/itmill/toolkit/ui/FieldFactory.java +++ b/src/com/itmill/toolkit/ui/FieldFactory.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; + import com.itmill.toolkit.data.Container; import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Property; @@ -17,7 +19,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.1 */ -public interface FieldFactory { +public interface FieldFactory extends Serializable { /** * Creates a field based on type of data. diff --git a/src/com/itmill/toolkit/ui/Form.java b/src/com/itmill/toolkit/ui/Form.java index b31feaea68..ee45ec0478 100644 --- a/src/com/itmill/toolkit/ui/Form.java +++ b/src/com/itmill/toolkit/ui/Form.java @@ -53,6 +53,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Form extends AbstractField implements Item.Editor, Buffered, Item, Validatable { diff --git a/src/com/itmill/toolkit/ui/FormLayout.java b/src/com/itmill/toolkit/ui/FormLayout.java index ddff9fa07f..54074f05f9 100644 --- a/src/com/itmill/toolkit/ui/FormLayout.java +++ b/src/com/itmill/toolkit/ui/FormLayout.java @@ -19,6 +19,7 @@ package com.itmill.toolkit.ui; * bottom are by default on. * */ +@SuppressWarnings( { "deprecation", "serial" }) public class FormLayout extends OrderedLayout { public FormLayout() { diff --git a/src/com/itmill/toolkit/ui/GridLayout.java b/src/com/itmill/toolkit/ui/GridLayout.java index 17cdc6754f..608871bcf5 100644 --- a/src/com/itmill/toolkit/ui/GridLayout.java +++ b/src/com/itmill/toolkit/ui/GridLayout.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -34,6 +35,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class GridLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.SpacingHandler { @@ -656,7 +658,7 @@ public class GridLayout extends AbstractLayout implements * @VERSION@ * @since 3.0 */ - public class Area { + public class Area implements Serializable { /** * The column of the upper left corner cell of the area. @@ -843,11 +845,6 @@ public class GridLayout extends AbstractLayout implements */ public class OverlapsException extends java.lang.RuntimeException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3978144339870101561L; - private final Area existingArea; /** @@ -880,11 +877,6 @@ public class GridLayout extends AbstractLayout implements */ public class OutOfBoundsException extends java.lang.RuntimeException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3618985589664592694L; - private final Area areaOutOfBounds; /** diff --git a/src/com/itmill/toolkit/ui/HorizontalLayout.java b/src/com/itmill/toolkit/ui/HorizontalLayout.java index 1ae5d7a375..f648ba157a 100644 --- a/src/com/itmill/toolkit/ui/HorizontalLayout.java +++ b/src/com/itmill/toolkit/ui/HorizontalLayout.java @@ -11,6 +11,7 @@ package com.itmill.toolkit.ui; * @VERSION@ * @since 5.3 */ +@SuppressWarnings("serial") public class HorizontalLayout extends AbstractOrderedLayout { public HorizontalLayout() { diff --git a/src/com/itmill/toolkit/ui/InlineDateField.java b/src/com/itmill/toolkit/ui/InlineDateField.java index 46db9c7fc7..d24f1ecba5 100644 --- a/src/com/itmill/toolkit/ui/InlineDateField.java +++ b/src/com/itmill/toolkit/ui/InlineDateField.java @@ -21,6 +21,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@
* @since 5.0
*/
+@SuppressWarnings("serial")
public class InlineDateField extends DateField {
public InlineDateField() {
diff --git a/src/com/itmill/toolkit/ui/Label.java b/src/com/itmill/toolkit/ui/Label.java index 1a9e497e9c..4a272ed1d1 100644 --- a/src/com/itmill/toolkit/ui/Label.java +++ b/src/com/itmill/toolkit/ui/Label.java @@ -36,6 +36,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Label extends AbstractComponent implements Property, Property.Viewer, Property.ValueChangeListener, Property.ValueChangeNotifier, Comparable { @@ -404,11 +405,6 @@ public class Label extends AbstractComponent implements Property, Property.ValueChangeEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3906084563938586935L; - - /** * New instance of text change event * * @param source diff --git a/src/com/itmill/toolkit/ui/Layout.java b/src/com/itmill/toolkit/ui/Layout.java index 78de97eaa8..d18cd93ea1 100644 --- a/src/com/itmill/toolkit/ui/Layout.java +++ b/src/com/itmill/toolkit/ui/Layout.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; + import com.itmill.toolkit.terminal.gwt.client.ui.IMarginInfo; import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.Bits; @@ -18,7 +20,7 @@ import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.Bits; * @VERSION@ * @since 3.0 */ -public interface Layout extends ComponentContainer { +public interface Layout extends ComponentContainer, Serializable { /** * Enable layout margins. Affects all four sides of the layout. This will @@ -48,7 +50,7 @@ public interface Layout extends ComponentContainer { * AlignmentHandler is most commonly an advanced {@link Layout} that can * align its components. */ - public interface AlignmentHandler { + public interface AlignmentHandler extends Serializable { /** * Contained component should be aligned horizontally to the left. @@ -149,7 +151,7 @@ public interface Layout extends ComponentContainer { * components. * */ - public interface SpacingHandler { + public interface SpacingHandler extends Serializable { /** * Enable spacing between child components within this layout. * @@ -184,7 +186,7 @@ public interface Layout extends ComponentContainer { * This type of layout supports automatic addition of margins (space around * its components). */ - public interface MarginHandler { + public interface MarginHandler extends Serializable { /** * Enable margins for this layout. * @@ -212,7 +214,8 @@ public interface Layout extends ComponentContainer { public MarginInfo getMargin(); } - public static class MarginInfo extends IMarginInfo { + @SuppressWarnings("serial") + public static class MarginInfo extends IMarginInfo implements Serializable { public MarginInfo(boolean enabled) { super(enabled, enabled, enabled, enabled); diff --git a/src/com/itmill/toolkit/ui/Link.java b/src/com/itmill/toolkit/ui/Link.java index 50c1470acd..53f2837386 100644 --- a/src/com/itmill/toolkit/ui/Link.java +++ b/src/com/itmill/toolkit/ui/Link.java @@ -16,6 +16,7 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Link extends AbstractComponent { /* Target window border type constant: No window border */ diff --git a/src/com/itmill/toolkit/ui/ListSelect.java b/src/com/itmill/toolkit/ui/ListSelect.java index 508ac50858..9d3fe70fdb 100644 --- a/src/com/itmill/toolkit/ui/ListSelect.java +++ b/src/com/itmill/toolkit/ui/ListSelect.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * This is a simple list select without, for instance, support for new items, * lazyloading, and other advanced features. */ +@SuppressWarnings("serial") public class ListSelect extends AbstractSelect { private int columns = 0; diff --git a/src/com/itmill/toolkit/ui/LoginForm.java b/src/com/itmill/toolkit/ui/LoginForm.java index 4aa5c704e8..eef64d598e 100644 --- a/src/com/itmill/toolkit/ui/LoginForm.java +++ b/src/com/itmill/toolkit/ui/LoginForm.java @@ -1,6 +1,7 @@ package com.itmill.toolkit.ui; import java.io.ByteArrayInputStream; +import java.io.Serializable; import java.lang.reflect.Method; import java.net.URL; import java.util.HashMap; @@ -33,6 +34,7 @@ import com.itmill.toolkit.terminal.URIHandler; * * @since 5.3 */ +@SuppressWarnings("serial") public class LoginForm extends CustomComponent { private Embedded iframe = new Embedded(); @@ -90,14 +92,18 @@ public class LoginForm extends CustomComponent { + "</script></body></html>"; public DownloadStream handleURI(URL context, String relativeUri) { - if (window != null) { - window.removeURIHandler(this); + if (relativeUri != null && relativeUri.contains("loginHandler")) { + if (window != null) { + window.removeURIHandler(this); + } + DownloadStream downloadStream = new DownloadStream( + new ByteArrayInputStream(responce.getBytes()), + "text/html", "loginSuccesfull"); + downloadStream.setCacheTime(-1); + return downloadStream; + } else { + return null; } - DownloadStream downloadStream = new DownloadStream( - new ByteArrayInputStream(responce.getBytes()), "text/html", - "loginSuccesfull"); - downloadStream.setCacheTime(-1); - return downloadStream; } }; @@ -185,8 +191,6 @@ public class LoginForm extends CustomComponent { */ public class LoginEvent extends Event { - private static final long serialVersionUID = 1966036438671224308L; - private Map params; private LoginEvent(Map params) { @@ -213,7 +217,7 @@ public class LoginForm extends CustomComponent { * Login listener is a class capable to listen LoginEvents sent from * LoginBox */ - public interface LoginListener { + public interface LoginListener extends Serializable { /** * This method is fired on each login form post. * diff --git a/src/com/itmill/toolkit/ui/MenuBar.java b/src/com/itmill/toolkit/ui/MenuBar.java index c0f400933c..e3004eb196 100644 --- a/src/com/itmill/toolkit/ui/MenuBar.java +++ b/src/com/itmill/toolkit/ui/MenuBar.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -17,6 +18,7 @@ import com.itmill.toolkit.terminal.Resource; * are represented as vertical menu. * </p> */ +@SuppressWarnings("serial") public class MenuBar extends AbstractComponent { // Items of the top-level menu @@ -70,7 +72,7 @@ public class MenuBar extends AbstractComponent { // This generates the tree from the contents of the menu while (itr.hasNext()) { - MenuItem item = (MenuItem) itr.next(); + MenuItem item = itr.next(); target.startTag("item"); @@ -127,7 +129,7 @@ public class MenuBar extends AbstractComponent { // Go through all the items in the menu while (!found && !items.empty()) { - tmpItem = (MenuItem) items.pop(); + tmpItem = items.pop(); found = (clickedId.intValue() == tmpItem.getId()); if (tmpItem.hasChildren()) { @@ -343,7 +345,7 @@ public class MenuBar extends AbstractComponent { * {@link com.itmill.toolkit.ui.MenuBar.MenuItem}. The selected item is * given as an argument. */ - public interface Command { + public interface Command extends Serializable { public void menuSelected(MenuBar.MenuItem selectedItem); } @@ -354,7 +356,7 @@ public class MenuBar extends AbstractComponent { * multiple MenuItems to a MenuItem and create a sub-menu. * */ - public class MenuItem { + public class MenuItem implements Serializable { /** Private members * */ private final int itsId; diff --git a/src/com/itmill/toolkit/ui/NativeSelect.java b/src/com/itmill/toolkit/ui/NativeSelect.java index 2cd78ac699..33a88c4ceb 100644 --- a/src/com/itmill/toolkit/ui/NativeSelect.java +++ b/src/com/itmill/toolkit/ui/NativeSelect.java @@ -16,6 +16,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * "native" select without all the bells-and-whistles of the ComboBox is a * better choice. */ +@SuppressWarnings("serial") public class NativeSelect extends AbstractSelect { // width in characters, mimics TextField diff --git a/src/com/itmill/toolkit/ui/OptionGroup.java b/src/com/itmill/toolkit/ui/OptionGroup.java index 2ebaaea3ea..25664b2a7a 100644 --- a/src/com/itmill/toolkit/ui/OptionGroup.java +++ b/src/com/itmill/toolkit/ui/OptionGroup.java @@ -13,6 +13,7 @@ import com.itmill.toolkit.terminal.PaintTarget; /** * Configures select to be used as an option group. */ +@SuppressWarnings("serial") public class OptionGroup extends AbstractSelect { public OptionGroup() { diff --git a/src/com/itmill/toolkit/ui/OrderedLayout.java b/src/com/itmill/toolkit/ui/OrderedLayout.java index e95c490ee1..61c59b31aa 100644 --- a/src/com/itmill/toolkit/ui/OrderedLayout.java +++ b/src/com/itmill/toolkit/ui/OrderedLayout.java @@ -18,6 +18,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * OrderedLayout but AbstractOrderedLayout (which also OrderedLayout * extends). */ +@SuppressWarnings("serial") @Deprecated public class OrderedLayout extends AbstractOrderedLayout { /* Predefined orientations */ diff --git a/src/com/itmill/toolkit/ui/Panel.java b/src/com/itmill/toolkit/ui/Panel.java index 1a8871e7e3..b471a0d330 100644 --- a/src/com/itmill/toolkit/ui/Panel.java +++ b/src/com/itmill/toolkit/ui/Panel.java @@ -24,6 +24,7 @@ import com.itmill.toolkit.terminal.Scrollable; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Panel extends AbstractComponentContainer implements Scrollable, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, Action.Container { diff --git a/src/com/itmill/toolkit/ui/PopupDateField.java b/src/com/itmill/toolkit/ui/PopupDateField.java index b00f55ae92..873b991cd3 100644 --- a/src/com/itmill/toolkit/ui/PopupDateField.java +++ b/src/com/itmill/toolkit/ui/PopupDateField.java @@ -21,6 +21,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@
* @since 5.0
*/
+@SuppressWarnings("serial")
public class PopupDateField extends DateField {
public PopupDateField() {
diff --git a/src/com/itmill/toolkit/ui/PopupView.java b/src/com/itmill/toolkit/ui/PopupView.java index 183187ebae..a9b9cb13be 100644 --- a/src/com/itmill/toolkit/ui/PopupView.java +++ b/src/com/itmill/toolkit/ui/PopupView.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; @@ -16,6 +17,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * * @author IT Mill Ltd. */ +@SuppressWarnings("serial") public class PopupView extends AbstractComponentContainer { private Content content; @@ -330,7 +332,7 @@ public class PopupView extends AbstractComponentContainer { * dynamically loaded when they are redrawn. The user must take care that * neither of these methods ever return null. */ - public interface Content { + public interface Content extends Serializable { /** * This should return a small view of the full data. @@ -385,10 +387,6 @@ public class PopupView extends AbstractComponentContainer { * */ public class PopupVisibilityEvent extends Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -130167162207143457L; public PopupVisibilityEvent(PopupView source) { super(source); @@ -418,7 +416,7 @@ public class PopupView extends AbstractComponentContainer { * visibility of the popup changes. * */ - public interface PopupVisibilityListener { + public interface PopupVisibilityListener extends Serializable { /** * Pass to {@link PopupView#PopupVisibilityEvent} to start listening for * popup visibility changes. diff --git a/src/com/itmill/toolkit/ui/ProgressIndicator.java b/src/com/itmill/toolkit/ui/ProgressIndicator.java index fc5b308b64..6f05db772d 100644 --- a/src/com/itmill/toolkit/ui/ProgressIndicator.java +++ b/src/com/itmill/toolkit/ui/ProgressIndicator.java @@ -23,6 +23,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 4 */ +@SuppressWarnings("serial") public class ProgressIndicator extends AbstractField implements Property, Property.Viewer, Property.ValueChangeListener { diff --git a/src/com/itmill/toolkit/ui/RichTextArea.java b/src/com/itmill/toolkit/ui/RichTextArea.java index fad763819d..4e2830329b 100644 --- a/src/com/itmill/toolkit/ui/RichTextArea.java +++ b/src/com/itmill/toolkit/ui/RichTextArea.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * {@link RichTextArea} may produce unexpected results as formatting is counted * into length of field. */ +@SuppressWarnings("serial") public class RichTextArea extends TextField { @Override diff --git a/src/com/itmill/toolkit/ui/Select.java b/src/com/itmill/toolkit/ui/Select.java index a778155b75..a1acec5e3e 100644 --- a/src/com/itmill/toolkit/ui/Select.java +++ b/src/com/itmill/toolkit/ui/Select.java @@ -35,6 +35,7 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Select extends AbstractSelect implements AbstractSelect.Filtering { /** diff --git a/src/com/itmill/toolkit/ui/Slider.java b/src/com/itmill/toolkit/ui/Slider.java index 0fb3496404..06d2264810 100644 --- a/src/com/itmill/toolkit/ui/Slider.java +++ b/src/com/itmill/toolkit/ui/Slider.java @@ -10,9 +10,7 @@ import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget;
/**
- * A component for selecting a numerical value within a range. A Slider
- * can have the appearance of a scroll bar or e.g. look like an Adobe Photoshop
- * style of a slider.
+ * A component for selecting a numerical value within a range.
*
* Example code: <code>
* class MyPlayer extends CustomComponent implements ValueChangeListener {
@@ -21,19 +19,20 @@ import com.itmill.toolkit.terminal.PaintTarget; * Slider slider;
*
* public MyPlayer() {
- * OrderedLayout ol = new OrderedLayout();
- * setCompositionRoot(ol);
+ * VerticalLayout vl = new VerticalLayout();
+ * setCompositionRoot(vl);
* slider = new Slider("Volume", 0, 100);
* slider.setImmediate(true);
- * ol.addComponent(slider);
- * ol.addComponent(volumeIndicator);
- * volumeIndicator.setValue(new Double(50));
+ * slider.setValue(new Double(50));
+ * vl.addComponent(slider);
+ * vl.addComponent(volumeIndicator);
+ * volumeIndicator.setValue("Current volume:" + 50.0);
* slider.addListener(this);
*
* }
*
* public void setVolume(double d) {
- * volumeIndicator.setValue("Current volume : " + d);
+ * volumeIndicator.setValue("Current volume: " + d);
* }
*
* public void valueChange(ValueChangeEvent event) {
@@ -46,6 +45,7 @@ import com.itmill.toolkit.terminal.PaintTarget; *
* @author IT Mill Ltd.
*/
+@SuppressWarnings("serial")
public class Slider extends AbstractField {
public static final int ORIENTATION_HORIZONTAL = 0;
@@ -58,6 +58,7 @@ public class Slider extends AbstractField { * common slider found e.g. in Adobe Photoshop. The client side
* implementation dictates how different styles will look.
*/
+ @Deprecated
public static final String STYLE_SCROLLBAR = "scrollbar";
/** Minimum value of slider */
@@ -92,7 +93,10 @@ public class Slider extends AbstractField { * size. Must be a value between 1-99. Other values are converted to nearest
* bound. A negative value sets the width to auto (client-side
* implementation calculates).
+ *
+ * @deprecated The size is dictated by the current theme.
*/
+ @Deprecated
private int handleSize = -1;
/**
@@ -100,6 +104,7 @@ public class Slider extends AbstractField { * (client-side implementation decides the increment, usually somewhere
* between 5-10% of slide range).
*/
+ @Deprecated
private final boolean arrows = false;
/**
@@ -360,7 +365,9 @@ public class Slider extends AbstractField { * Get the handle size of this Slider.
*
* @return handle size in percentages.
+ * @deprecated The size is dictated by the current theme.
*/
+ @Deprecated
public int getHandleSize() {
return handleSize;
}
@@ -370,7 +377,9 @@ public class Slider extends AbstractField { *
* @param handleSize
* in percentages relative to slider base size.
+ * @deprecated The size is dictated by the current theme.
*/
+ @Deprecated
public void setHandleSize(int handleSize) {
if (handleSize < 0) {
this.handleSize = -1;
@@ -384,23 +393,6 @@ public class Slider extends AbstractField { requestRepaint();
}
- /*
- * Show or hide slider arrows.
- *
- * @param visible
- *//*
- * public void setArrows(boolean visible) { arrows = visible;
- * requestRepaint(); }
- */
-
- /*
- * Does the slider have arrows?
- *
- * @return arrows visible
- *//*
- * public boolean isArrowsVisible() { return arrows; }
- */
-
@Override
public String getTag() {
return "slider";
@@ -485,11 +477,6 @@ public class Slider extends AbstractField { */
public class ValueOutOfBoundsException extends Exception {
- /**
- * Serial generated by Eclipse.
- */
- private static final long serialVersionUID = -6451298598644446340L;
-
private final Double value;
/**
diff --git a/src/com/itmill/toolkit/ui/SplitPanel.java b/src/com/itmill/toolkit/ui/SplitPanel.java index 2af72da310..06b8073c6c 100644 --- a/src/com/itmill/toolkit/ui/SplitPanel.java +++ b/src/com/itmill/toolkit/ui/SplitPanel.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public class SplitPanel extends AbstractLayout { /* Predefined orientations */ diff --git a/src/com/itmill/toolkit/ui/TabSheet.java b/src/com/itmill/toolkit/ui/TabSheet.java index 25a5c65455..5d2e9ac57f 100644 --- a/src/com/itmill/toolkit/ui/TabSheet.java +++ b/src/com/itmill/toolkit/ui/TabSheet.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Iterator; import java.util.LinkedList; @@ -23,6 +24,7 @@ import com.itmill.toolkit.terminal.Paintable.RepaintRequestListener; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class TabSheet extends AbstractComponentContainer implements RepaintRequestListener { @@ -203,7 +205,7 @@ public class TabSheet extends AbstractComponentContainer implements * not) we select this tab instead */ if (selected == null || !selected.isVisible() - || (!selected.isEnabled() && this.isEnabled())) { + || (!selected.isEnabled() && isEnabled())) { selected = c; } target.startTag("tab"); @@ -452,11 +454,6 @@ public class TabSheet extends AbstractComponentContainer implements public class SelectedTabChangeEvent extends Component.Event { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3258129141914940469L; - - /** * New instance of selected tab change event * * @param source @@ -485,7 +482,7 @@ public class TabSheet extends AbstractComponentContainer implements * @VERSION@ * @since 3.0 */ - public interface SelectedTabChangeListener { + public interface SelectedTabChangeListener extends Serializable { /** * Visible tab in tab sheet has has been changed. diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 1ad0eda6ad..7ff6d53700 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -49,6 +50,7 @@ import com.itmill.toolkit.terminal.gwt.client.MouseEventDetails; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Table extends AbstractSelect implements Action.Container, Container.Ordered, Container.Sortable, ItemClickSource { @@ -820,8 +822,23 @@ public class Table extends AbstractSelect implements Action.Container, } } - // If the search for item index was successfull + // If the search for item index was successful if (index >= 0) { + /* + * The table is not capable of displaying an item in the container + * as the first if there are not enough items following the selected + * item so the whole table (pagelength) is filled. + */ + int maxIndex = size() - pageLength; + if (maxIndex < 0) { + maxIndex = 0; + } + + if (index > maxIndex) { + setCurrentPageFirstItemIndex(maxIndex); + return; + } + this.currentPageFirstItemId = currentPageFirstItemId; currentPageFirstItemIndex = index; } @@ -1085,14 +1102,32 @@ public class Table extends AbstractSelect implements Action.Container, private void setCurrentPageFirstItemIndex(int newIndex, boolean needsPageBufferReset) { - // Ensures that the new value is valid - if (newIndex >= size()) { - newIndex = size() - pageLength; - } + if (newIndex < 0) { newIndex = 0; } + /* + * minimize Container.size() calls which may be expensive. For example + * it may cause sql query. + */ + final int size = size(); + + /* + * The table is not capable of displaying an item in the container as + * the first if there are not enough items following the selected item + * so the whole table (pagelength) is filled. + */ + int maxIndex = size - pageLength; + if (maxIndex < 0) { + maxIndex = 0; + } + + // Ensures that the new value is valid + if (newIndex > maxIndex) { + newIndex = maxIndex; + } + // Refresh first item id if (items instanceof Container.Indexed) { try { @@ -1121,7 +1156,7 @@ public class Table extends AbstractSelect implements Action.Container, // If we did hit the border if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) { - currentPageFirstItemIndex = size() - 1; + currentPageFirstItemIndex = size - 1; } // Go backwards in the middle of the list (respect borders) @@ -1150,7 +1185,7 @@ public class Table extends AbstractSelect implements Action.Container, // If for some reason we do hit border again, override // the user index request if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) { - newIndex = currentPageFirstItemIndex = size() - 1; + newIndex = currentPageFirstItemIndex = size - 1; } } if (needsPageBufferReset) { @@ -3067,7 +3102,7 @@ public class Table extends AbstractSelect implements Action.Container, * Table.addGeneratedColumn along with an id for the column to be generated. * */ - public interface ColumnGenerator { + public interface ColumnGenerator extends Serializable { /** * Called by Table when a cell in a generated column needs to be @@ -3112,7 +3147,7 @@ public class Table extends AbstractSelect implements Action.Container, * to the cell content is <tt>i-table-cell-content-[style name]</tt>, and * the row style will be <tt>i-table-row-[style name]</tt>. */ - public interface CellStyleGenerator { + public interface CellStyleGenerator extends Serializable { /** * Called by Table when a cell (and row) is painted. diff --git a/src/com/itmill/toolkit/ui/TextField.java b/src/com/itmill/toolkit/ui/TextField.java index e5572f0b9f..8c124799d8 100644 --- a/src/com/itmill/toolkit/ui/TextField.java +++ b/src/com/itmill/toolkit/ui/TextField.java @@ -31,6 +31,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class TextField extends AbstractField { /* Private members */ diff --git a/src/com/itmill/toolkit/ui/Tree.java b/src/com/itmill/toolkit/ui/Tree.java index 20c7e03961..18b18651f9 100644 --- a/src/com/itmill/toolkit/ui/Tree.java +++ b/src/com/itmill/toolkit/ui/Tree.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; @@ -40,11 +41,10 @@ import com.itmill.toolkit.terminal.gwt.client.MouseEventDetails; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Tree extends AbstractSelect implements Container.Hierarchical, Action.Container, ItemClickSource { - /* Static members */ - private static final Method EXPAND_METHOD; private static final Method COLLAPSE_METHOD; @@ -723,11 +723,6 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public class ExpandEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3832624001804481075L; - private final Object expandedItemId; /** @@ -760,7 +755,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @VERSION@ * @since 3.0 */ - public interface ExpandListener { + public interface ExpandListener extends Serializable { /** * A node has been expanded. @@ -813,11 +808,6 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public class CollapseEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257009834783290160L; - private final Object collapsedItemId; /** @@ -850,7 +840,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @VERSION@ * @since 3.0 */ - public interface CollapseListener { + public interface CollapseListener extends Serializable { /** * A node has been collapsed. diff --git a/src/com/itmill/toolkit/ui/TwinColSelect.java b/src/com/itmill/toolkit/ui/TwinColSelect.java index 0876ec81d8..ac00498418 100644 --- a/src/com/itmill/toolkit/ui/TwinColSelect.java +++ b/src/com/itmill/toolkit/ui/TwinColSelect.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * Multiselect component with two lists: left side for available items and right * side for selected items. */ +@SuppressWarnings("serial") public class TwinColSelect extends AbstractSelect { private int columns = 0; diff --git a/src/com/itmill/toolkit/ui/Upload.java b/src/com/itmill/toolkit/ui/Upload.java index a6fe4df873..2b4620f322 100644 --- a/src/com/itmill/toolkit/ui/Upload.java +++ b/src/com/itmill/toolkit/ui/Upload.java @@ -6,6 +6,7 @@ package com.itmill.toolkit.ui; import java.io.InputStream; import java.io.OutputStream; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Iterator; import java.util.LinkedHashSet; @@ -42,6 +43,7 @@ import com.itmill.toolkit.terminal.UploadStream; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Upload extends AbstractComponent implements Component.Focusable { private boolean delayedFocus; @@ -235,7 +237,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public interface Receiver { + public interface Receiver extends Serializable { /** * Invoked when a new upload arrives. @@ -292,11 +294,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { public class FinishedEvent extends Component.Event { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257288015385670969L; - - /** * Length of the received file. */ private final long length; @@ -379,11 +376,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class FailedEvent extends FinishedEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3833746590157386293L; - private Exception reason = null; /** @@ -430,11 +422,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { public class NoOutputStreamEvent extends FailedEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 4745219890852396500L; - - /** * * @param source * @param filename @@ -453,11 +440,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { public class NoInputStreamEvent extends FailedEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -529960205445737170L; - - /** * * @param source * @param filename @@ -482,11 +464,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { public class SucceededEvent extends FinishedEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256445798169524023L; - - /** * * @param source * @param filename @@ -510,10 +487,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class StartedEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -3984393770487403525L; private final String filename; private final String type; @@ -567,7 +540,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 5.0 */ - public interface StartedListener { + public interface StartedListener extends Serializable { /** * Upload has started. @@ -586,7 +559,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public interface FinishedListener { + public interface FinishedListener extends Serializable { /** * Upload has finished. @@ -605,7 +578,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public interface FailedListener { + public interface FailedListener extends Serializable { /** * Upload has finished unsuccessfully. @@ -624,7 +597,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public interface SucceededListener { + public interface SucceededListener extends Serializable { /** * Upload successfull.. @@ -966,7 +939,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { /** * ProgressListener receives events to track progress of upload. */ - public interface ProgressListener { + public interface ProgressListener extends Serializable { /** * Updates progress to listener * diff --git a/src/com/itmill/toolkit/ui/UriFragmentUtility.java b/src/com/itmill/toolkit/ui/UriFragmentUtility.java index 11d141e05c..3852bdc7d2 100644 --- a/src/com/itmill/toolkit/ui/UriFragmentUtility.java +++ b/src/com/itmill/toolkit/ui/UriFragmentUtility.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Map; @@ -15,12 +16,13 @@ import com.itmill.toolkit.terminal.PaintTarget; * bookmarking a program state and back button. * */ +@SuppressWarnings("serial") public class UriFragmentUtility extends AbstractComponent { /** * Listener that listens changes in URI fragment. */ - public interface FragmentChangedListener { + public interface FragmentChangedListener extends Serializable { public void fragmentChanged(FragmentChangedEvent source); @@ -32,11 +34,6 @@ public class UriFragmentUtility extends AbstractComponent { public class FragmentChangedEvent extends Component.Event { /** - * Serial generated by eclipse - */ - private static final long serialVersionUID = -4142140007700263197L; - - /** * Creates a new instance of UriFragmentReader change event. * * @param source diff --git a/src/com/itmill/toolkit/ui/VerticalLayout.java b/src/com/itmill/toolkit/ui/VerticalLayout.java index 1bc5e99794..21934bbd0f 100644 --- a/src/com/itmill/toolkit/ui/VerticalLayout.java +++ b/src/com/itmill/toolkit/ui/VerticalLayout.java @@ -12,6 +12,7 @@ package com.itmill.toolkit.ui; * @VERSION@ * @since 5.3 */ +@SuppressWarnings("serial") public class VerticalLayout extends AbstractOrderedLayout { public VerticalLayout() { diff --git a/src/com/itmill/toolkit/ui/Window.java b/src/com/itmill/toolkit/ui/Window.java index 530bd8441d..9dac2c2c2a 100644 --- a/src/com/itmill/toolkit/ui/Window.java +++ b/src/com/itmill/toolkit/ui/Window.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; @@ -32,6 +33,7 @@ import com.itmill.toolkit.terminal.URIHandler; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Window extends Panel implements URIHandler, ParameterHandler { /** @@ -787,7 +789,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { /** * Private data structure for storing opening window properties. */ - private class OpenResource { + private class OpenResource implements Serializable { private final Resource resource; @@ -1001,11 +1003,6 @@ public class Window extends Panel implements URIHandler, ParameterHandler { public class CloseEvent extends Component.Event { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -7235770057344367327L; - - /** * * @param source */ @@ -1023,7 +1020,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { } } - public interface CloseListener { + public interface CloseListener extends Serializable { public void windowClose(CloseEvent e); } @@ -1073,9 +1070,6 @@ public class Window extends Panel implements URIHandler, ParameterHandler { */ public class ResizeEvent extends Component.Event { - // Generated serial - private static final long serialVersionUID = 8569831802323447687L; - /** * * @param source @@ -1099,7 +1093,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * * @see com.itmill.toolkit.ui.Window.ResizeEvent */ - public interface ResizeListener { + public interface ResizeListener extends Serializable { public void windowResized(ResizeEvent e); } @@ -1403,7 +1397,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * </p> * */ - public static class Notification { + public static class Notification implements Serializable { public static final int TYPE_HUMANIZED_MESSAGE = 1; public static final int TYPE_WARNING_MESSAGE = 2; public static final int TYPE_ERROR_MESSAGE = 3; |