From: Henri Sara Date: Thu, 1 Jul 2010 08:14:45 +0000 (+0000) Subject: #5286 implement Serializable where necessary X-Git-Tag: 6.7.0.beta1~1472 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dcd1c14c837cfd94a41d7c74cd2a4cb8f0cda0c7;p=vaadin-framework.git #5286 implement Serializable where necessary svn changeset:13989/svn branch:6.4 --- diff --git a/src/com/vaadin/terminal/StreamResource.java b/src/com/vaadin/terminal/StreamResource.java index 7b4c040229..7fefd0119c 100644 --- a/src/com/vaadin/terminal/StreamResource.java +++ b/src/com/vaadin/terminal/StreamResource.java @@ -5,6 +5,7 @@ package com.vaadin.terminal; import java.io.InputStream; +import java.io.Serializable; import com.vaadin.Application; import com.vaadin.service.FileTypeResolver; @@ -166,7 +167,7 @@ public class StreamResource implements ApplicationResource { * @VERSION@ * @since 3.0 */ - public interface StreamSource { + public interface StreamSource extends Serializable { /** * Returns new input stream that is used for reading the resource. diff --git a/src/com/vaadin/ui/DragAndDropWrapper.java b/src/com/vaadin/ui/DragAndDropWrapper.java index e431592e8e..2421e43401 100644 --- a/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/src/com/vaadin/ui/DragAndDropWrapper.java @@ -6,6 +6,7 @@ package com.vaadin.ui; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.Serializable; import java.util.HashMap; import java.util.Map; @@ -100,7 +101,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, * computer if appropriate HTML 5 features are supported on client side. * This class wraps information about dragged file on server side. */ - public class Html5File { + public class Html5File implements Serializable { public String name; private int size; diff --git a/src/com/vaadin/ui/PopupView.java b/src/com/vaadin/ui/PopupView.java index 6a14238f8b..93208d84d2 100644 --- a/src/com/vaadin/ui/PopupView.java +++ b/src/com/vaadin/ui/PopupView.java @@ -42,6 +42,40 @@ public class PopupView extends AbstractComponentContainer { } } + /** + * Iterator for the visible components (zero or one components), used by + * {@link PopupView#getComponentIterator()}. + */ + private static class SingleComponentIterator implements + Iterator, + Serializable { + + private final Component component; + private boolean first; + + public SingleComponentIterator(Component component) { + this.component = component; + first = (component == null); + } + + public boolean hasNext() { + return !first; + } + + public Component next() { + if (!first) { + first = true; + return component; + } else { + return null; + } + } + + public void remove() { + throw new UnsupportedOperationException(); + } + } + /* Constructors */ /** @@ -190,28 +224,7 @@ public class PopupView extends AbstractComponentContainer { * @see com.vaadin.ui.ComponentContainer#getComponentIterator() */ public Iterator getComponentIterator() { - return new Iterator() { - - private boolean first = visibleComponent == null; - - public boolean hasNext() { - return !first; - } - - public Component next() { - if (!first) { - first = true; - return visibleComponent; - } else { - return null; - } - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }; - + return new SingleComponentIterator(visibleComponent); } /** diff --git a/src/com/vaadin/ui/SplitPanel.java b/src/com/vaadin/ui/SplitPanel.java index cd41a82760..d38dc06f9e 100644 --- a/src/com/vaadin/ui/SplitPanel.java +++ b/src/com/vaadin/ui/SplitPanel.java @@ -4,6 +4,7 @@ package com.vaadin.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; @@ -63,6 +64,51 @@ public class SplitPanel extends AbstractLayout { private static final String SPLITTER_CLICK_EVENT = VSplitPanel.SPLITTER_CLICK_EVENT_IDENTIFIER; + /** + * Modifiable and Serializable Iterator for the components, used by + * {@link SplitPanel#getComponentIterator()}. + */ + private class ComponentIterator implements Iterator, + Serializable { + + int i = 0; + + public boolean hasNext() { + if (i < (firstComponent == null ? 0 : 1) + + (secondComponent == null ? 0 : 1)) { + return true; + } + return false; + } + + public Component next() { + if (!hasNext()) { + return null; + } + i++; + if (i == 1) { + return firstComponent == null ? secondComponent + : firstComponent; + } else if (i == 2) { + return secondComponent; + } + return null; + } + + public void remove() { + if (i == 1) { + if (firstComponent != null) { + setFirstComponent(null); + i = 0; + } else { + setSecondComponent(null); + } + } else if (i == 2) { + setSecondComponent(null); + } + } + } + /** * Creates a new split panel. The orientation of the panels is * ORIENTATION_VERTICAL. @@ -165,50 +211,13 @@ public class SplitPanel extends AbstractLayout { } /** - * Gets the component container iterator for going trough all the components - * in the container. + * Gets the component container iterator for going through all the + * components in the container. * * @return the Iterator of the components inside the container. */ public Iterator getComponentIterator() { - return new Iterator() { - int i = 0; - - public boolean hasNext() { - if (i < (firstComponent == null ? 0 : 1) - + (secondComponent == null ? 0 : 1)) { - return true; - } - return false; - } - - public Component next() { - if (!hasNext()) { - return null; - } - i++; - if (i == 1) { - return firstComponent == null ? secondComponent - : firstComponent; - } else if (i == 2) { - return secondComponent; - } - return null; - } - - public void remove() { - if (i == 1) { - if (firstComponent != null) { - setFirstComponent(null); - i = 0; - } else { - setSecondComponent(null); - } - } else if (i == 2) { - setSecondComponent(null); - } - } - }; + return new ComponentIterator(); } /** diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 20aaedd1fc..8162d72545 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -4099,7 +4099,7 @@ public class Table extends AbstractSelect implements Action.Container, /** * Interface for listening to column resize events. */ - public interface ColumnResizeListener { + public interface ColumnResizeListener extends Serializable { /** * This method is triggered when the column has been resized