diff options
Diffstat (limited to 'server/src')
198 files changed, 3815 insertions, 2071 deletions
diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index bdad94355d..164f04bb79 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -30,7 +30,6 @@ import java.util.EventListener; import java.util.EventObject; import java.util.HashMap; import java.util.HashSet; -import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -51,27 +50,27 @@ import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.ConverterFactory; import com.vaadin.data.util.converter.DefaultConverterFactory; import com.vaadin.event.EventRouter; +import com.vaadin.server.AbstractApplicationServlet; +import com.vaadin.server.AbstractErrorMessage; +import com.vaadin.server.BootstrapFragmentResponse; +import com.vaadin.server.BootstrapListener; +import com.vaadin.server.BootstrapPageResponse; +import com.vaadin.server.BootstrapResponse; +import com.vaadin.server.ChangeVariablesErrorEvent; +import com.vaadin.server.ClientConnector; +import com.vaadin.server.CombinedRequest; +import com.vaadin.server.DeploymentConfiguration; +import com.vaadin.server.GlobalResourceHandler; +import com.vaadin.server.RequestHandler; +import com.vaadin.server.Terminal; +import com.vaadin.server.UIProvider; +import com.vaadin.server.VariableOwner; +import com.vaadin.server.WebApplicationContext; +import com.vaadin.server.WrappedRequest; +import com.vaadin.server.WrappedRequest.BrowserDetails; +import com.vaadin.server.WrappedResponse; import com.vaadin.service.ApplicationContext; import com.vaadin.shared.ui.ui.UIConstants; -import com.vaadin.terminal.AbstractErrorMessage; -import com.vaadin.terminal.ApplicationResource; -import com.vaadin.terminal.CombinedRequest; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.Terminal; -import com.vaadin.terminal.UIProvider; -import com.vaadin.terminal.VariableOwner; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedRequest.BrowserDetails; -import com.vaadin.terminal.WrappedResponse; -import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; -import com.vaadin.terminal.gwt.server.BootstrapFragmentResponse; -import com.vaadin.terminal.gwt.server.BootstrapListener; -import com.vaadin.terminal.gwt.server.BootstrapPageResponse; -import com.vaadin.terminal.gwt.server.BootstrapResponse; -import com.vaadin.terminal.gwt.server.ChangeVariablesErrorEvent; -import com.vaadin.terminal.gwt.server.ClientConnector; -import com.vaadin.terminal.gwt.server.WebApplicationContext; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; @@ -123,8 +122,8 @@ import com.vaadin.ui.Window; * found out, the window itself is queried for a preferred theme. If the window * does not prefer a specific theme, the application containing the window is * queried. If neither the application prefers a theme, the default theme for - * the {@link com.vaadin.terminal.Terminal terminal} is used. The terminal - * always defines a default theme. + * the {@link com.vaadin.server.Terminal terminal} is used. The terminal always + * defines a default theme. * </p> * * @author Vaadin Ltd. @@ -458,10 +457,6 @@ public class Application implements Terminal.ErrorListener, Serializable { /** * Application resource mapping: key <-> resource. */ - private final Hashtable<ApplicationResource, String> resourceKeyMap = new Hashtable<ApplicationResource, String>(); - - private final Hashtable<String, ApplicationResource> keyResourceMap = new Hashtable<String, ApplicationResource>(); - private long lastResourceKeyNumber = 0; /** @@ -508,6 +503,8 @@ public class Application implements Terminal.ErrorListener, Serializable { private List<UIProvider> uiProviders = new LinkedList<UIProvider>(); + private GlobalResourceHandler globalResourceHandler; + /** * Gets the user of the application. * @@ -694,71 +691,6 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Adds new resource to the application. The resource can be accessed by the - * user of the application. - * - * @param resource - * the resource to add. - */ - public void addResource(ApplicationResource resource) { - - // Check if the resource is already mapped - if (resourceKeyMap.containsKey(resource)) { - return; - } - - // Generate key - final String key = String.valueOf(++lastResourceKeyNumber); - - // Add the resource to mappings - resourceKeyMap.put(resource, key); - keyResourceMap.put(key, resource); - } - - /** - * Removes the resource from the application. - * - * @param resource - * the resource to remove. - */ - public void removeResource(ApplicationResource resource) { - final Object key = resourceKeyMap.get(resource); - if (key != null) { - resourceKeyMap.remove(resource); - keyResourceMap.remove(key); - } - } - - /** - * Gets the relative uri of the resource. This method is intended to be - * called only be the terminal implementation. - * - * This method can only be called from within the processing of a UIDL - * request, not from a background thread. - * - * @param resource - * the resource to get relative location. - * @return the relative uri of the resource or null if called in a - * background thread - * - * @deprecated this method is intended to be used by the terminal only. It - * may be removed or moved in the future. - */ - @Deprecated - public String getRelativeLocation(ApplicationResource resource) { - - // Gets the key - final String key = resourceKeyMap.get(resource); - - // If the resource is not registered, return null - if (key == null) { - return null; - } - - return context.generateApplicationResourceURL(resource, key); - } - - /** * Gets the default locale for this application. * * By default this is the preferred locale of the user using the @@ -881,7 +813,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * @param listener * the user change listener to add. */ - public void addListener(UserChangeListener listener) { + public void addUserChangeListener(UserChangeListener listener) { if (userChangeListeners == null) { userChangeListeners = new LinkedList<UserChangeListener>(); } @@ -889,12 +821,22 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** + * @deprecated Since 7.0, replaced by + * {@link #addUserChangeListener(UserChangeListener)} + **/ + @Deprecated + public void addListener(UserChangeListener listener) { + addUserChangeListener(listener); + } + + /** * Removes the user change listener. * * @param listener * the user change listener to remove. */ - public void removeListener(UserChangeListener listener) { + + public void removeUserChangeListener(UserChangeListener listener) { if (userChangeListeners == null) { return; } @@ -905,6 +847,15 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** + * @deprecated Since 7.0, replaced by + * {@link #removeUserChangeListener(UserChangeListener)} + **/ + @Deprecated + public void removeListener(UserChangeListener listener) { + removeUserChangeListener(listener); + } + + /** * Window detach event. * * This event is sent each time a window is removed from the application @@ -1075,7 +1026,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * * @param event * the change event. - * @see com.vaadin.terminal.Terminal.ErrorListener#terminalError(com.vaadin.terminal.Terminal.ErrorEvent) + * @see com.vaadin.server.Terminal.ErrorListener#terminalError(com.vaadin.server.Terminal.ErrorEvent) */ @Override @@ -2066,20 +2017,6 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Find an application resource with a given key. - * - * @param key - * The key of the resource - * @return The application resource corresponding to the provided key, or - * <code>null</code> if no resource is registered for the key - * - * @since 7.0 - */ - public ApplicationResource getResource(String key) { - return keyResourceMap.get(key); - } - - /** * Thread local for keeping track of currently used application instance * * @since 7.0 @@ -2510,4 +2447,30 @@ public class Application implements Terminal.ErrorListener, Serializable { } return true; } + + /** + * Gets this application's global resource handler that takes care of + * serving connector resources that are not served by any single connector + * because e.g. because they are served with strong caching or because of + * legacy reasons. + * + * @param createOnDemand + * <code>true</code> if a resource handler should be initialized + * if there is no handler associated with this application. + * </code>false</code> if </code>null</code> should be returned + * if there is no registered handler. + * @return this application's global resource handler, or <code>null</code> + * if there is no handler and the createOnDemand parameter is + * <code>false</code>. + * + * @since 7.0.0 + */ + public GlobalResourceHandler getGlobalResourceHandler(boolean createOnDemand) { + if (globalResourceHandler == null && createOnDemand) { + globalResourceHandler = new GlobalResourceHandler(); + addRequestHandler(globalResourceHandler); + } + + return globalResourceHandler; + } } diff --git a/server/src/com/vaadin/UIRequiresMoreInformationException.java b/server/src/com/vaadin/UIRequiresMoreInformationException.java index 493c31acb6..76a31d88ef 100644 --- a/server/src/com/vaadin/UIRequiresMoreInformationException.java +++ b/server/src/com/vaadin/UIRequiresMoreInformationException.java @@ -16,8 +16,8 @@ package com.vaadin; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedRequest.BrowserDetails; +import com.vaadin.server.WrappedRequest; +import com.vaadin.server.WrappedRequest.BrowserDetails; /** * Exception that is thrown to indicate that creating or initializing the UI diff --git a/server/src/com/vaadin/annotations/EagerInit.java b/server/src/com/vaadin/annotations/EagerInit.java index 462c6bb5ac..f08d46b551 100644 --- a/server/src/com/vaadin/annotations/EagerInit.java +++ b/server/src/com/vaadin/annotations/EagerInit.java @@ -20,7 +20,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.vaadin.terminal.WrappedRequest; +import com.vaadin.server.WrappedRequest; import com.vaadin.ui.UI; /** @@ -29,7 +29,7 @@ import com.vaadin.ui.UI; * This will make the UI appear more quickly, as ensuring the availability of * this information typically requires an additional round trip to the client. * - * @see UI#init(com.vaadin.terminal.WrappedRequest) + * @see UI#init(com.vaadin.server.WrappedRequest) * @see WrappedRequest#getBrowserDetails() * * @since 7.0 diff --git a/server/src/com/vaadin/annotations/JavaScript.java b/server/src/com/vaadin/annotations/JavaScript.java index 7943fe1055..1a2fdf7583 100644 --- a/server/src/com/vaadin/annotations/JavaScript.java +++ b/server/src/com/vaadin/annotations/JavaScript.java @@ -21,7 +21,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.vaadin.terminal.gwt.server.ClientConnector; +import com.vaadin.server.ClientConnector; /** * If this annotation is present on a {@link ClientConnector} class, the diff --git a/server/src/com/vaadin/annotations/StyleSheet.java b/server/src/com/vaadin/annotations/StyleSheet.java index 7833544ab5..e1a9efd696 100644 --- a/server/src/com/vaadin/annotations/StyleSheet.java +++ b/server/src/com/vaadin/annotations/StyleSheet.java @@ -21,7 +21,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.vaadin.terminal.gwt.server.ClientConnector; +import com.vaadin.server.ClientConnector; /** * If this annotation is present on a {@link ClientConnector} class, the diff --git a/server/src/com/vaadin/data/Container.java b/server/src/com/vaadin/data/Container.java index de53b88018..155dde87ef 100644 --- a/server/src/com/vaadin/data/Container.java +++ b/server/src/com/vaadin/data/Container.java @@ -1016,6 +1016,14 @@ public interface Container extends Serializable { * @param listener * listener to be added */ + public void addItemSetChangeListener( + Container.ItemSetChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addItemSetChangeListener(ItemSetChangeListener)} + **/ + @Deprecated public void addListener(Container.ItemSetChangeListener listener); /** @@ -1024,6 +1032,14 @@ public interface Container extends Serializable { * @param listener * listener to be removed */ + public void removeItemSetChangeListener( + Container.ItemSetChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemSetChangeListener(ItemSetChangeListener)} + **/ + @Deprecated public void removeListener(Container.ItemSetChangeListener listener); } @@ -1102,6 +1118,14 @@ public interface Container extends Serializable { * @param listener * The new Listener to be registered */ + public void addPropertySetChangeListener( + Container.PropertySetChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addPropertySetChangeListener(PropertySetChangeListener)} + **/ + @Deprecated public void addListener(Container.PropertySetChangeListener listener); /** @@ -1110,6 +1134,14 @@ public interface Container extends Serializable { * @param listener * Listener to be removed */ + public void removePropertySetChangeListener( + Container.PropertySetChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(PropertySetChangeListener)} + **/ + @Deprecated public void removeListener(Container.PropertySetChangeListener listener); } } diff --git a/server/src/com/vaadin/data/Item.java b/server/src/com/vaadin/data/Item.java index 684027e608..8bdf963835 100644 --- a/server/src/com/vaadin/data/Item.java +++ b/server/src/com/vaadin/data/Item.java @@ -177,6 +177,14 @@ public interface Item extends Serializable { * @param listener * The new Listener to be registered. */ + public void addPropertySetChangeListener( + Item.PropertySetChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addPropertySetChangeListener(PropertySetChangeListener)} + **/ + @Deprecated public void addListener(Item.PropertySetChangeListener listener); /** @@ -185,6 +193,14 @@ public interface Item extends Serializable { * @param listener * Listener to be removed. */ + public void removePropertySetChangeListener( + Item.PropertySetChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(PropertySetChangeListener)} + **/ + @Deprecated public void removeListener(Item.PropertySetChangeListener listener); } } diff --git a/server/src/com/vaadin/data/Property.java b/server/src/com/vaadin/data/Property.java index 3e5c6826bb..7e46af09b7 100644 --- a/server/src/com/vaadin/data/Property.java +++ b/server/src/com/vaadin/data/Property.java @@ -304,6 +304,13 @@ public interface Property<T> extends Serializable { * @param listener * the new Listener to be registered */ + public void addValueChangeListener(Property.ValueChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addValueChangeListener(ValueChangeListener)} + **/ + @Deprecated public void addListener(Property.ValueChangeListener listener); /** @@ -312,6 +319,14 @@ public interface Property<T> extends Serializable { * @param listener * listener to be removed */ + public void removeValueChangeListener( + Property.ValueChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeValueChangeListener(ValueChangeListener)} + **/ + @Deprecated public void removeListener(Property.ValueChangeListener listener); } @@ -379,6 +394,14 @@ public interface Property<T> extends Serializable { * @param listener * the new Listener to be registered */ + public void addReadOnlyStatusChangeListener( + Property.ReadOnlyStatusChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addReadOnlyStatusChangeListener(ReadOnlyStatusChangeListener)} + **/ + @Deprecated public void addListener(Property.ReadOnlyStatusChangeListener listener); /** @@ -387,6 +410,14 @@ public interface Property<T> extends Serializable { * @param listener * listener to be removed */ + public void removeReadOnlyStatusChangeListener( + Property.ReadOnlyStatusChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeReadOnlyStatusChangeListener(ReadOnlyStatusChangeListener)} + **/ + @Deprecated public void removeListener( Property.ReadOnlyStatusChangeListener listener); } diff --git a/server/src/com/vaadin/data/Validator.java b/server/src/com/vaadin/data/Validator.java index ef07d3eadc..1755a44920 100644 --- a/server/src/com/vaadin/data/Validator.java +++ b/server/src/com/vaadin/data/Validator.java @@ -18,7 +18,7 @@ package com.vaadin.data; import java.io.Serializable; -import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; +import com.vaadin.server.AbstractApplicationServlet; /** * Interface that implements a method for validating if an {@link Object} is diff --git a/server/src/com/vaadin/data/util/AbstractBeanContainer.java b/server/src/com/vaadin/data/util/AbstractBeanContainer.java index 9cd4afa3c2..cb09cdad46 100644 --- a/server/src/com/vaadin/data/util/AbstractBeanContainer.java +++ b/server/src/com/vaadin/data/util/AbstractBeanContainer.java @@ -741,14 +741,35 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends return new PropertyBasedBeanIdResolver(propertyId); } + /** + * @deprecated Since 7.0, replaced by {@link #addPropertySetChangeListener} + **/ + @Deprecated @Override public void addListener(Container.PropertySetChangeListener listener) { - super.addListener(listener); + addPropertySetChangeListener(listener); + } + + @Override + public void addPropertySetChangeListener( + Container.PropertySetChangeListener listener) { + super.addPropertySetChangeListener(listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated @Override public void removeListener(Container.PropertySetChangeListener listener) { - super.removeListener(listener); + removePropertySetChangeListener(listener); + } + + @Override + public void removePropertySetChangeListener( + Container.PropertySetChangeListener listener) { + super.removePropertySetChangeListener(listener); } @Override diff --git a/server/src/com/vaadin/data/util/AbstractContainer.java b/server/src/com/vaadin/data/util/AbstractContainer.java index fbce468bce..ff8fc90651 100644 --- a/server/src/com/vaadin/data/util/AbstractContainer.java +++ b/server/src/com/vaadin/data/util/AbstractContainer.java @@ -100,7 +100,8 @@ public abstract class AbstractContainer implements Container { * * @see PropertySetChangeNotifier#addListener(com.vaadin.data.Container.PropertySetChangeListener) */ - protected void addListener(Container.PropertySetChangeListener listener) { + protected void addPropertySetChangeListener( + Container.PropertySetChangeListener listener) { if (getPropertySetChangeListeners() == null) { setPropertySetChangeListeners(new LinkedList<Container.PropertySetChangeListener>()); } @@ -108,6 +109,15 @@ public abstract class AbstractContainer implements Container { } /** + * @deprecated Since 7.0, replaced by + * {@link #addPropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + protected void addListener(Container.PropertySetChangeListener listener) { + addPropertySetChangeListener(listener); + } + + /** * Implementation of the corresponding method in * {@link PropertySetChangeNotifier}, override with the corresponding public * method and implement the interface to use this. @@ -115,12 +125,22 @@ public abstract class AbstractContainer implements Container { * @see PropertySetChangeNotifier#removeListener(com.vaadin.data.Container. * PropertySetChangeListener) */ - protected void removeListener(Container.PropertySetChangeListener listener) { + protected void removePropertySetChangeListener( + Container.PropertySetChangeListener listener) { if (getPropertySetChangeListeners() != null) { getPropertySetChangeListeners().remove(listener); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + protected void removeListener(Container.PropertySetChangeListener listener) { + removePropertySetChangeListener(listener); + } + // ItemSetChangeNotifier /** @@ -130,7 +150,8 @@ public abstract class AbstractContainer implements Container { * * @see ItemSetChangeNotifier#addListener(com.vaadin.data.Container.ItemSetChangeListener) */ - protected void addListener(Container.ItemSetChangeListener listener) { + protected void addItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (getItemSetChangeListeners() == null) { setItemSetChangeListeners(new LinkedList<Container.ItemSetChangeListener>()); } @@ -138,19 +159,38 @@ public abstract class AbstractContainer implements Container { } /** + * @deprecated Since 7.0, replaced by + * {@link #addItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + protected void addListener(Container.ItemSetChangeListener listener) { + addItemSetChangeListener(listener); + } + + /** * Implementation of the corresponding method in * {@link ItemSetChangeNotifier}, override with the corresponding public * method and implement the interface to use this. * * @see ItemSetChangeNotifier#removeListener(com.vaadin.data.Container.ItemSetChangeListener) */ - protected void removeListener(Container.ItemSetChangeListener listener) { + protected void removeItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (getItemSetChangeListeners() != null) { getItemSetChangeListeners().remove(listener); } } /** + * @deprecated Since 7.0, replaced by + * {@link #addItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + protected void removeListener(Container.ItemSetChangeListener listener) { + removeItemSetChangeListener(listener); + } + + /** * Sends a simple Property set change event to all interested listeners. */ protected void fireContainerPropertySetChange() { diff --git a/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java b/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java index fd2ced2d4a..6eea9cb421 100644 --- a/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java +++ b/server/src/com/vaadin/data/util/AbstractInMemoryContainer.java @@ -324,15 +324,36 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE } // ItemSetChangeNotifier - + /** + * @deprecated Since 7.0, replaced by + * {@link #addItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated @Override public void addListener(Container.ItemSetChangeListener listener) { - super.addListener(listener); + addItemSetChangeListener(listener); + } + + @Override + public void addItemSetChangeListener( + Container.ItemSetChangeListener listener) { + super.addItemSetChangeListener(listener); } @Override + public void removeItemSetChangeListener( + Container.ItemSetChangeListener listener) { + super.removeItemSetChangeListener(listener); + } + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + @Override public void removeListener(Container.ItemSetChangeListener listener) { - super.removeListener(listener); + removeItemSetChangeListener(listener); } // internal methods diff --git a/server/src/com/vaadin/data/util/AbstractProperty.java b/server/src/com/vaadin/data/util/AbstractProperty.java index f508156d05..6636996cd5 100644 --- a/server/src/com/vaadin/data/util/AbstractProperty.java +++ b/server/src/com/vaadin/data/util/AbstractProperty.java @@ -121,7 +121,8 @@ public abstract class AbstractProperty<T> implements Property<T>, * the new Listener to be registered. */ @Override - public void addListener(Property.ReadOnlyStatusChangeListener listener) { + public void addReadOnlyStatusChangeListener( + Property.ReadOnlyStatusChangeListener listener) { if (readOnlyStatusChangeListeners == null) { readOnlyStatusChangeListeners = new LinkedList<ReadOnlyStatusChangeListener>(); } @@ -129,19 +130,38 @@ public abstract class AbstractProperty<T> implements Property<T>, } /** + * @deprecated Since 7.0, replaced by + * {@link #addReadOnlyStatusChangeListener(com.vaadin.data.Property.ReadOnlyStatusChangeListener)} + **/ + @Deprecated + public void addListener(Property.ReadOnlyStatusChangeListener listener) { + addReadOnlyStatusChangeListener(listener); + } + + /** * Removes a previously registered read-only status change listener. * * @param listener * the listener to be removed. */ @Override - public void removeListener(Property.ReadOnlyStatusChangeListener listener) { + public void removeReadOnlyStatusChangeListener( + Property.ReadOnlyStatusChangeListener listener) { if (readOnlyStatusChangeListeners != null) { readOnlyStatusChangeListeners.remove(listener); } } /** + * @deprecated Since 7.0, replaced by + * {@link #removeReadOnlyStatusChangeListener(com.vaadin.data.Property.ReadOnlyStatusChangeListener)} + **/ + @Deprecated + public void removeListener(Property.ReadOnlyStatusChangeListener listener) { + removeReadOnlyStatusChangeListener(listener); + } + + /** * Sends a read only status change event to all registered listeners. */ protected void fireReadOnlyStatusChange() { @@ -186,7 +206,7 @@ public abstract class AbstractProperty<T> implements Property<T>, } @Override - public void addListener(ValueChangeListener listener) { + public void addValueChangeListener(ValueChangeListener listener) { if (valueChangeListeners == null) { valueChangeListeners = new LinkedList<ValueChangeListener>(); } @@ -194,8 +214,17 @@ public abstract class AbstractProperty<T> implements Property<T>, } + /** + * @deprecated Since 7.0, replaced by + * {@link #addValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void addListener(ValueChangeListener listener) { + addValueChangeListener(listener); + } + @Override - public void removeListener(ValueChangeListener listener) { + public void removeValueChangeListener(ValueChangeListener listener) { if (valueChangeListeners != null) { valueChangeListeners.remove(listener); } @@ -203,6 +232,15 @@ public abstract class AbstractProperty<T> implements Property<T>, } /** + * @deprecated Since 7.0, replaced by + * {@link #removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void removeListener(ValueChangeListener listener) { + removeValueChangeListener(listener); + } + + /** * Sends a value change event to all registered listeners. */ protected void fireValueChange() { diff --git a/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java b/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java index 8f9000bce0..24d0a8d3a0 100644 --- a/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java +++ b/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java @@ -710,53 +710,95 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, * interface. */ @Override - public void addListener(Container.ItemSetChangeListener listener) { + public void addItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (container instanceof Container.ItemSetChangeNotifier) { ((Container.ItemSetChangeNotifier) container) - .addListener(new PiggybackListener(listener)); + .addItemSetChangeListener(new PiggybackListener(listener)); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #addItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + public void addListener(Container.ItemSetChangeListener listener) { + addItemSetChangeListener(listener); + } + /* * Removes a Item set change listener from the object. Don't add a JavaDoc * comment here, we use the default documentation from implemented * interface. */ @Override - public void removeListener(Container.ItemSetChangeListener listener) { + public void removeItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (container instanceof Container.ItemSetChangeNotifier) { ((Container.ItemSetChangeNotifier) container) - .removeListener(new PiggybackListener(listener)); + .removeItemSetChangeListener(new PiggybackListener(listener)); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + public void removeListener(Container.ItemSetChangeListener listener) { + removeItemSetChangeListener(listener); + } + /* * Registers a new Property set change listener for this Container. Don't * add a JavaDoc comment here, we use the default documentation from * implemented interface. */ @Override - public void addListener(Container.PropertySetChangeListener listener) { + public void addPropertySetChangeListener( + Container.PropertySetChangeListener listener) { if (container instanceof Container.PropertySetChangeNotifier) { ((Container.PropertySetChangeNotifier) container) - .addListener(new PiggybackListener(listener)); + .addPropertySetChangeListener(new PiggybackListener( + listener)); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #addPropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + public void addListener(Container.PropertySetChangeListener listener) { + addPropertySetChangeListener(listener); + } + /* * Removes a Property set change listener from the object. Don't add a * JavaDoc comment here, we use the default documentation from implemented * interface. */ @Override - public void removeListener(Container.PropertySetChangeListener listener) { + public void removePropertySetChangeListener( + Container.PropertySetChangeListener listener) { if (container instanceof Container.PropertySetChangeNotifier) { ((Container.PropertySetChangeNotifier) container) - .removeListener(new PiggybackListener(listener)); + .removePropertySetChangeListener(new PiggybackListener( + listener)); } } /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + public void removeListener(Container.PropertySetChangeListener listener) { + removePropertySetChangeListener(listener); + } + + /** * This listener 'piggybacks' on the real listener in order to update the * wrapper when needed. It proxies equals() and hashCode() to the real * listener so that the correct listener gets removed. diff --git a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java index d332931008..bb904f4cda 100644 --- a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java +++ b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java @@ -510,52 +510,94 @@ public class ContainerOrderedWrapper implements Container.Ordered, * interface. */ @Override - public void addListener(Container.ItemSetChangeListener listener) { + public void addItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (container instanceof Container.ItemSetChangeNotifier) { ((Container.ItemSetChangeNotifier) container) - .addListener(new PiggybackListener(listener)); + .addItemSetChangeListener(new PiggybackListener(listener)); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #addItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + public void addListener(Container.ItemSetChangeListener listener) { + addItemSetChangeListener(listener); + } + /* * Removes a Item set change listener from the object. Don't add a JavaDoc * comment here, we use the default documentation from implemented * interface. */ @Override - public void removeListener(Container.ItemSetChangeListener listener) { + public void removeItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (container instanceof Container.ItemSetChangeNotifier) { ((Container.ItemSetChangeNotifier) container) - .removeListener(new PiggybackListener(listener)); + .removeItemSetChangeListener(new PiggybackListener(listener)); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + public void removeListener(Container.ItemSetChangeListener listener) { + removeItemSetChangeListener(listener); + } + /* * Registers a new Property set change listener for this Container. Don't * add a JavaDoc comment here, we use the default documentation from * implemented interface. */ @Override - public void addListener(Container.PropertySetChangeListener listener) { + public void addPropertySetChangeListener( + Container.PropertySetChangeListener listener) { if (container instanceof Container.PropertySetChangeNotifier) { ((Container.PropertySetChangeNotifier) container) - .addListener(new PiggybackListener(listener)); + .addPropertySetChangeListener(new PiggybackListener( + listener)); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #addPropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + public void addListener(Container.PropertySetChangeListener listener) { + addPropertySetChangeListener(listener); + } + /* * Removes a Property set change listener from the object. Don't add a * JavaDoc comment here, we use the default documentation from implemented * interface. */ @Override - public void removeListener(Container.PropertySetChangeListener listener) { + public void removePropertySetChangeListener( + Container.PropertySetChangeListener listener) { if (container instanceof Container.PropertySetChangeNotifier) { ((Container.PropertySetChangeNotifier) container) - .removeListener(new PiggybackListener(listener)); + .removePropertySetChangeListener(new PiggybackListener( + listener)); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + public void removeListener(Container.PropertySetChangeListener listener) { + removePropertySetChangeListener(listener); + } + /* * (non-Javadoc) * diff --git a/server/src/com/vaadin/data/util/FilesystemContainer.java b/server/src/com/vaadin/data/util/FilesystemContainer.java index 54ee2d6f0c..4c27169409 100644 --- a/server/src/com/vaadin/data/util/FilesystemContainer.java +++ b/server/src/com/vaadin/data/util/FilesystemContainer.java @@ -33,8 +33,8 @@ import java.util.List; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.Property; +import com.vaadin.server.Resource; import com.vaadin.service.FileTypeResolver; -import com.vaadin.terminal.Resource; /** * A hierarchical container wrapper for a filesystem. diff --git a/server/src/com/vaadin/data/util/IndexedContainer.java b/server/src/com/vaadin/data/util/IndexedContainer.java index 5566b2f18c..e0a8fe1dc1 100644 --- a/server/src/com/vaadin/data/util/IndexedContainer.java +++ b/server/src/com/vaadin/data/util/IndexedContainer.java @@ -483,13 +483,35 @@ public class IndexedContainer extends } @Override + public void addPropertySetChangeListener( + Container.PropertySetChangeListener listener) { + super.addPropertySetChangeListener(listener); + } + + /** + * @deprecated Since 7.0, replaced by + * {@link #addPropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + @Override public void addListener(Container.PropertySetChangeListener listener) { - super.addListener(listener); + addPropertySetChangeListener(listener); } @Override + public void removePropertySetChangeListener( + Container.PropertySetChangeListener listener) { + super.removePropertySetChangeListener(listener); + } + + /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + @Override public void removeListener(Container.PropertySetChangeListener listener) { - super.removeListener(listener); + removePropertySetChangeListener(listener); } /* @@ -499,13 +521,22 @@ public class IndexedContainer extends * vaadin.data.Property.ValueChangeListener) */ @Override - public void addListener(Property.ValueChangeListener listener) { + public void addValueChangeListener(Property.ValueChangeListener listener) { if (propertyValueChangeListeners == null) { propertyValueChangeListeners = new LinkedList<Property.ValueChangeListener>(); } propertyValueChangeListeners.add(listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void addListener(Property.ValueChangeListener listener) { + addValueChangeListener(listener); + } + /* * (non-Javadoc) * @@ -513,13 +544,22 @@ public class IndexedContainer extends * .vaadin.data.Property.ValueChangeListener) */ @Override - public void removeListener(Property.ValueChangeListener listener) { + public void removeValueChangeListener(Property.ValueChangeListener listener) { if (propertyValueChangeListeners != null) { propertyValueChangeListeners.remove(listener); } } /** + * @deprecated Since 7.0, replaced by + * {@link #removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void removeListener(Property.ValueChangeListener listener) { + removeValueChangeListener(listener); + } + + /** * Sends a Property value change event to all interested listeners. * * @param source @@ -965,10 +1005,19 @@ public class IndexedContainer extends * com.vaadin.data.Property.ValueChangeListener) */ @Override - public void addListener(Property.ValueChangeListener listener) { + public void addValueChangeListener(Property.ValueChangeListener listener) { addSinglePropertyChangeListener(propertyId, itemId, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void addListener(Property.ValueChangeListener listener) { + addValueChangeListener(listener); + } + /* * (non-Javadoc) * @@ -976,10 +1025,20 @@ public class IndexedContainer extends * (com.vaadin.data.Property.ValueChangeListener) */ @Override - public void removeListener(Property.ValueChangeListener listener) { + public void removeValueChangeListener( + Property.ValueChangeListener listener) { removeSinglePropertyChangeListener(propertyId, itemId, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void removeListener(Property.ValueChangeListener listener) { + removeValueChangeListener(listener); + } + private IndexedContainer getHost() { return IndexedContainer.this; } diff --git a/server/src/com/vaadin/data/util/PropertysetItem.java b/server/src/com/vaadin/data/util/PropertysetItem.java index e86d813809..6fba011d75 100644 --- a/server/src/com/vaadin/data/util/PropertysetItem.java +++ b/server/src/com/vaadin/data/util/PropertysetItem.java @@ -200,7 +200,8 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, * the new Listener to be registered. */ @Override - public void addListener(Item.PropertySetChangeListener listener) { + public void addPropertySetChangeListener( + Item.PropertySetChangeListener listener) { if (propertySetChangeListeners == null) { propertySetChangeListeners = new LinkedList<PropertySetChangeListener>(); } @@ -208,19 +209,38 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, } /** + * @deprecated Since 7.0, replaced by + * {@link #addPropertySetChangeListener(com.vaadin.data.Item.PropertySetChangeListener)} + **/ + @Deprecated + public void addListener(Item.PropertySetChangeListener listener) { + addPropertySetChangeListener(listener); + } + + /** * Removes a previously registered property set change listener. * * @param listener * the Listener to be removed. */ @Override - public void removeListener(Item.PropertySetChangeListener listener) { + public void removePropertySetChangeListener( + Item.PropertySetChangeListener listener) { if (propertySetChangeListeners != null) { propertySetChangeListeners.remove(listener); } } /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(com.vaadin.data.Item.PropertySetChangeListener)} + **/ + @Deprecated + public void removeListener(Item.PropertySetChangeListener listener) { + removePropertySetChangeListener(listener); + } + + /** * Sends a Property set change event to all interested listeners. */ private void fireItemPropertySetChange() { diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index 13248f1e06..a53f32b96e 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -1493,13 +1493,23 @@ public class SQLContainer implements Container, Container.Filterable, */ @Override - public void addListener(Container.ItemSetChangeListener listener) { + public void addItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (itemSetChangeListeners == null) { itemSetChangeListeners = new LinkedList<Container.ItemSetChangeListener>(); } itemSetChangeListeners.add(listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + public void addListener(Container.ItemSetChangeListener listener) { + addItemSetChangeListener(listener); + } + /* * (non-Javadoc) * @@ -1509,12 +1519,22 @@ public class SQLContainer implements Container, Container.Filterable, */ @Override - public void removeListener(Container.ItemSetChangeListener listener) { + public void removeItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (itemSetChangeListeners != null) { itemSetChangeListeners.remove(listener); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + public void removeListener(Container.ItemSetChangeListener listener) { + removeItemSetChangeListener(listener); + } + protected void fireContentsChange() { if (itemSetChangeListeners != null) { final Object[] l = itemSetChangeListeners.toArray(); @@ -1553,7 +1573,7 @@ public class SQLContainer implements Container, Container.Filterable, * * @param listener */ - public void addListener(RowIdChangeListener listener) { + public void addRowIdChangeListener(RowIdChangeListener listener) { if (delegate instanceof QueryDelegate.RowIdChangeNotifier) { ((QueryDelegate.RowIdChangeNotifier) delegate) .addListener(listener); @@ -1561,11 +1581,20 @@ public class SQLContainer implements Container, Container.Filterable, } /** + * @deprecated Since 7.0, replaced by + * {@link #addRowIdChangeListener(RowIdChangeListener)} + **/ + @Deprecated + public void addListener(RowIdChangeListener listener) { + addRowIdChangeListener(listener); + } + + /** * Removes a RowIdChangeListener from the QueryDelegate * * @param listener */ - public void removeListener(RowIdChangeListener listener) { + public void removeRowIdChangeListener(RowIdChangeListener listener) { if (delegate instanceof QueryDelegate.RowIdChangeNotifier) { ((QueryDelegate.RowIdChangeNotifier) delegate) .removeListener(listener); @@ -1573,6 +1602,15 @@ public class SQLContainer implements Container, Container.Filterable, } /** + * @deprecated Since 7.0, replaced by + * {@link #removeRowIdChangeListener(RowIdChangeListener)} + **/ + @Deprecated + public void removeListener(RowIdChangeListener listener) { + removeRowIdChangeListener(listener); + } + + /** * Calling this will enable this SQLContainer to send and receive cache * flush notifications for its lifetime. */ diff --git a/server/src/com/vaadin/data/util/sqlcontainer/query/QueryDelegate.java b/server/src/com/vaadin/data/util/sqlcontainer/query/QueryDelegate.java index 3e1866932b..10a710e823 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/query/QueryDelegate.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/query/QueryDelegate.java @@ -210,6 +210,14 @@ public interface QueryDelegate extends Serializable { * @param listener * listener to be added */ + public void addRowIdChangeListener( + QueryDelegate.RowIdChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addRowIdChangeListener(RowIdChangeListener)} + **/ + @Deprecated public void addListener(QueryDelegate.RowIdChangeListener listener); /** @@ -218,6 +226,14 @@ public interface QueryDelegate extends Serializable { * @param listener * listener to be removed */ + public void removeRowIdChangeListener( + QueryDelegate.RowIdChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeRowIdChangeListener(RowIdChangeListener)} + **/ + @Deprecated public void removeListener(QueryDelegate.RowIdChangeListener listener); } } diff --git a/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java b/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java index e4544a491a..a6a1a5a8fb 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java @@ -704,7 +704,7 @@ public class TableQuery implements QueryDelegate, * Adds RowIdChangeListener to this query */ @Override - public void addListener(RowIdChangeListener listener) { + public void addRowIdChangeListener(RowIdChangeListener listener) { if (rowIdChangeListeners == null) { rowIdChangeListeners = new LinkedList<QueryDelegate.RowIdChangeListener>(); } @@ -712,15 +712,33 @@ public class TableQuery implements QueryDelegate, } /** + * @deprecated Since 7.0, replaced by + * {@link #addRowIdChangeListener(com.vaadin.data.util.sqlcontainer.query.QueryDelegate.RowIdChangeListener)} + **/ + @Deprecated + public void addListener(RowIdChangeListener listener) { + addRowIdChangeListener(listener); + } + + /** * Removes the given RowIdChangeListener from this query */ @Override - public void removeListener(RowIdChangeListener listener) { + public void removeRowIdChangeListener(RowIdChangeListener listener) { if (rowIdChangeListeners != null) { rowIdChangeListeners.remove(listener); } } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeRowIdChangeListener(com.vaadin.data.util.sqlcontainer.query.QueryDelegate.RowIdChangeListener)} + **/ + @Deprecated + public void removeListener(RowIdChangeListener listener) { + removeRowIdChangeListener(listener); + } + private static final Logger getLogger() { return Logger.getLogger(TableQuery.class.getName()); } diff --git a/server/src/com/vaadin/event/Action.java b/server/src/com/vaadin/event/Action.java index aca28940a1..b8296418d3 100644 --- a/server/src/com/vaadin/event/Action.java +++ b/server/src/com/vaadin/event/Action.java @@ -18,7 +18,7 @@ package com.vaadin.event; import java.io.Serializable; -import com.vaadin.terminal.Resource; +import com.vaadin.server.Resource; /** * Implements the action framework. This class contains subinterfaces for action diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index 296d12ba92..85a1bf0f12 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -20,10 +20,10 @@ import java.util.Map; import com.vaadin.event.Action.Container; import com.vaadin.event.Action.Handler; -import com.vaadin.terminal.KeyMapper; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.VariableOwner; +import com.vaadin.server.KeyMapper; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.VariableOwner; import com.vaadin.ui.Component; /** diff --git a/server/src/com/vaadin/event/FieldEvents.java b/server/src/com/vaadin/event/FieldEvents.java index 8e247a6fef..10df08291e 100644 --- a/server/src/com/vaadin/event/FieldEvents.java +++ b/server/src/com/vaadin/event/FieldEvents.java @@ -59,6 +59,13 @@ public interface FieldEvents { * @see FocusListener * @since 6.2 */ + public void addFocusListener(FocusListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated public void addListener(FocusListener listener); /** @@ -68,6 +75,13 @@ public interface FieldEvents { * @see FocusListener * @since 6.2 */ + public void removeFocusListener(FocusListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated public void removeListener(FocusListener listener); } @@ -97,6 +111,13 @@ public interface FieldEvents { * @see BlurListener * @since 6.2 */ + public void addBlurListener(BlurListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addBlurListener(BlurListener)} + **/ + @Deprecated public void addListener(BlurListener listener); /** @@ -106,6 +127,13 @@ public interface FieldEvents { * @see BlurListener * @since 6.2 */ + public void removeBlurListener(BlurListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated public void removeListener(BlurListener listener); } @@ -257,8 +285,22 @@ public interface FieldEvents { * {@link TextChangeListener}s. */ public interface TextChangeNotifier extends Serializable { + public void addTextChangeListener(TextChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addTextChangeListener(TextChangeListener)} + **/ + @Deprecated public void addListener(TextChangeListener listener); + public void removeTextChangeListener(TextChangeListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeTextChangeListener(TextChangeListener)} + **/ + @Deprecated public void removeListener(TextChangeListener listener); } diff --git a/server/src/com/vaadin/event/ItemClickEvent.java b/server/src/com/vaadin/event/ItemClickEvent.java index c736353614..99c36cf51b 100644 --- a/server/src/com/vaadin/event/ItemClickEvent.java +++ b/server/src/com/vaadin/event/ItemClickEvent.java @@ -119,6 +119,13 @@ public class ItemClickEvent extends ClickEvent implements Serializable { * @param listener * ItemClickListener to be registered */ + public void addItemClickListener(ItemClickListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addItemClickListener(ItemClickListener)} + **/ + @Deprecated public void addListener(ItemClickListener listener); /** @@ -127,6 +134,13 @@ public class ItemClickEvent extends ClickEvent implements Serializable { * @param listener * ItemClickListener to be removed */ + public void removeItemClickListener(ItemClickListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemClickListener(ItemClickListener)} + **/ + @Deprecated public void removeListener(ItemClickListener listener); } diff --git a/server/src/com/vaadin/event/LayoutEvents.java b/server/src/com/vaadin/event/LayoutEvents.java index 7fc6e5a42d..7f88ddc640 100644 --- a/server/src/com/vaadin/event/LayoutEvents.java +++ b/server/src/com/vaadin/event/LayoutEvents.java @@ -78,6 +78,13 @@ public interface LayoutEvents { * @param listener * The listener to add */ + public void addLayoutClickListener(LayoutClickListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addLayoutClickListener(LayoutClickListener)} + **/ + @Deprecated public void addListener(LayoutClickListener listener); /** @@ -86,6 +93,13 @@ public interface LayoutEvents { * @param listener * LayoutClickListener to be removed */ + public void removeLayoutClickListener(LayoutClickListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeLayoutClickListener(LayoutClickListener)} + **/ + @Deprecated public void removeListener(LayoutClickListener listener); } diff --git a/server/src/com/vaadin/event/ShortcutAction.java b/server/src/com/vaadin/event/ShortcutAction.java index b3f41b474d..b1d14b15fe 100644 --- a/server/src/com/vaadin/event/ShortcutAction.java +++ b/server/src/com/vaadin/event/ShortcutAction.java @@ -20,7 +20,7 @@ import java.io.Serializable; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.vaadin.terminal.Resource; +import com.vaadin.server.Resource; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Panel; import com.vaadin.ui.Window; diff --git a/server/src/com/vaadin/event/ShortcutListener.java b/server/src/com/vaadin/event/ShortcutListener.java index 82a09585b3..d7e0577e84 100644 --- a/server/src/com/vaadin/event/ShortcutListener.java +++ b/server/src/com/vaadin/event/ShortcutListener.java @@ -16,7 +16,7 @@ package com.vaadin.event; import com.vaadin.event.Action.Listener; -import com.vaadin.terminal.Resource; +import com.vaadin.server.Resource; public abstract class ShortcutListener extends ShortcutAction implements Listener { diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java b/server/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java index 7b04efc4b3..850e68b231 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java @@ -23,8 +23,8 @@ import java.io.Serializable; import com.vaadin.event.Transferable; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DropHandler; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * Criterion that can be used create policy to accept/discard dragged content diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/And.java b/server/src/com/vaadin/event/dd/acceptcriteria/And.java index 3d11ecf7bf..183010a298 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/And.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/And.java @@ -19,8 +19,8 @@ package com.vaadin.event.dd.acceptcriteria; import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * A compound criterion that accepts the drag if all of its criteria accepts the diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java b/server/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java index be7e2d4033..e862cdfd39 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java @@ -17,8 +17,8 @@ package com.vaadin.event.dd.acceptcriteria; import java.io.Serializable; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * Parent class for criteria that can be completely validated on client side. diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java b/server/src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java index 55ee17fea9..97094814ef 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java @@ -20,8 +20,8 @@ package com.vaadin.event.dd.acceptcriteria; import com.vaadin.event.Transferable; import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * A Criterion that checks whether {@link Transferable} contains given data diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/Not.java b/server/src/com/vaadin/event/dd/acceptcriteria/Not.java index b3f73699ea..9e1b1571ae 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/Not.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/Not.java @@ -19,8 +19,8 @@ package com.vaadin.event.dd.acceptcriteria; import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * Criterion that wraps another criterion and inverts its return value. diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/Or.java b/server/src/com/vaadin/event/dd/acceptcriteria/Or.java index 42d1c3293d..7aa7d8cd20 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/Or.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/Or.java @@ -19,8 +19,8 @@ package com.vaadin.event.dd.acceptcriteria; import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * A compound criterion that accepts the drag if any of its criterion accepts diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java b/server/src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java index b9c2855021..b7457605b8 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java @@ -18,8 +18,8 @@ package com.vaadin.event.dd.acceptcriteria; import java.io.Serializable; import com.vaadin.event.Transferable; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * Parent class for criteria which are verified on the server side during a drag diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java b/server/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java index cc1d586076..6258aed423 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java @@ -23,8 +23,8 @@ import java.util.logging.Logger; import com.vaadin.event.TransferableImpl; import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; import com.vaadin.ui.Component; /** diff --git a/server/src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java b/server/src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java index 536ba8780e..a6d3e2c5d5 100644 --- a/server/src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java +++ b/server/src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java @@ -20,8 +20,8 @@ package com.vaadin.event.dd.acceptcriteria; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.TargetDetails; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * Criterion for checking if drop target details contains the specific property diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java index 13e87c16ad..cef27c221d 100644 --- a/server/src/com/vaadin/navigator/Navigator.java +++ b/server/src/com/vaadin/navigator/Navigator.java @@ -22,9 +22,9 @@ import java.util.LinkedList; import java.util.List; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; -import com.vaadin.terminal.Page; -import com.vaadin.terminal.Page.FragmentChangedEvent; -import com.vaadin.terminal.Page.FragmentChangedListener; +import com.vaadin.server.Page; +import com.vaadin.server.Page.FragmentChangedEvent; +import com.vaadin.server.Page.FragmentChangedListener; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.CssLayout; @@ -435,7 +435,7 @@ public class Navigator implements Serializable { } } if (viewWithLongestName != null) { - String parameters = null; + String parameters = ""; if (viewAndParameters.length() > longestViewName.length() + 1) { parameters = viewAndParameters.substring(longestViewName .length() + 1); @@ -469,7 +469,7 @@ public class Navigator implements Serializable { if (null != viewName && getFragmentManager() != null) { String currentFragment = viewName; - if (fragmentParameters != null) { + if (!fragmentParameters.equals("")) { currentFragment += "/" + fragmentParameters; } if (!currentFragment.equals(getFragmentManager().getFragment())) { @@ -651,18 +651,36 @@ public class Navigator implements Serializable { * @param listener * Listener to invoke after view changes. */ - public void addListener(ViewChangeListener listener) { + public void addViewChangeListener(ViewChangeListener listener) { listeners.add(listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #addViewChangeListener(ViewChangeListener)} + **/ + @Deprecated + public void addListener(ViewChangeListener listener) { + addViewChangeListener(listener); + } + + /** * Remove a view change listener. * * @param listener * Listener to remove. */ - public void removeListener(ViewChangeListener listener) { + public void removeViewChangeListener(ViewChangeListener listener) { listeners.remove(listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeViewChangeListener(ViewChangeListener)} + **/ + @Deprecated + public void removeListener(ViewChangeListener listener) { + removeViewChangeListener(listener); + } + } diff --git a/server/src/com/vaadin/navigator/View.java b/server/src/com/vaadin/navigator/View.java index 4db334a2dd..caee801f0c 100644 --- a/server/src/com/vaadin/navigator/View.java +++ b/server/src/com/vaadin/navigator/View.java @@ -38,11 +38,9 @@ public interface View extends Serializable { * is any additional id to data what should be shown in the view, it is also * optionally passed as parameter. * - * TODO fragmentParameters null if no parameters or empty string? - * * @param fragmentParameters - * parameters to the view or null if none given. This is the - * string that appears e.g. in URI after "viewname/" + * parameters to the view or empty string if none given. This is + * the string that appears e.g. in URI after "viewname/" */ public void navigateTo(String fragmentParameters); }
\ No newline at end of file diff --git a/server/src/com/vaadin/package.html b/server/src/com/vaadin/package.html index f771019709..097fd94aca 100644 --- a/server/src/com/vaadin/package.html +++ b/server/src/com/vaadin/package.html @@ -5,22 +5,20 @@ <body bgcolor="white"> -<p>The Vaadin base package. Contains the Application class, the -starting point of any application that uses Vaadin.</p> + <p>The Vaadin base package. Contains the Application class, the + starting point of any application that uses Vaadin.</p> -<p>Contains all Vaadin core classes. A Vaadin application is based -on the {@link com.vaadin.Application} class and deployed as a servlet -using {@link com.vaadin.terminal.gwt.server.ApplicationServlet} or -{@link com.vaadin.terminal.gwt.server.GAEApplicationServlet} (for Google -App Engine).</p> + <p>Contains all Vaadin core classes. A Vaadin application is based + on the {@link com.vaadin.Application} class and deployed as a servlet + using {@link com.vaadin.server.ApplicationServlet} or {@link + com.vaadin.server.GAEApplicationServlet} (for Google App Engine).</p> -<p>Vaadin applications can also be deployed as portlets using {@link -com.vaadin.terminal.gwt.server.ApplicationPortlet} (JSR-168) or {@link -com.vaadin.terminal.gwt.server.ApplicationPortlet2} (JSR-286).</p> + <p>Vaadin applications can also be deployed as portlets using + {@link com.vaadin.server.ApplicationPortlet2} (JSR-286).</p> -<p>All classes in Vaadin are serializable unless otherwise noted. -This allows Vaadin applications to run in cluster and cloud -environments.</p> + <p>All classes in Vaadin are serializable unless otherwise noted. + This allows Vaadin applications to run in cluster and cloud + environments.</p> </body> diff --git a/server/src/com/vaadin/portal/gwt/PortalDefaultWidgetSet.gwt.xml b/server/src/com/vaadin/portal/gwt/PortalDefaultWidgetSet.gwt.xml deleted file mode 100644 index bd91d05b02..0000000000 --- a/server/src/com/vaadin/portal/gwt/PortalDefaultWidgetSet.gwt.xml +++ /dev/null @@ -1,6 +0,0 @@ -<module> - <!-- WS Compiler: manually edited --> - - <!-- Inherit the DefaultWidgetSet --> - <inherits name="com.vaadin.terminal.gwt.DefaultWidgetSet" /> -</module> diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/server/src/com/vaadin/server/AbstractApplicationPortlet.java index 345f462239..e47e00577b 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/server/src/com/vaadin/server/AbstractApplicationPortlet.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.BufferedWriter; import java.io.IOException; @@ -57,11 +57,7 @@ import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.Application.SystemMessages; import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.Terminal; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; -import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.Callback; +import com.vaadin.server.AbstractCommunicationManager.Callback; import com.vaadin.ui.UI; /** diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/server/src/com/vaadin/server/AbstractApplicationServlet.java index 13fd869166..2f0dad7079 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/server/src/com/vaadin/server/AbstractApplicationServlet.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.BufferedWriter; import java.io.IOException; @@ -49,13 +49,8 @@ import javax.servlet.http.HttpSession; import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.Application.SystemMessages; +import com.vaadin.server.AbstractCommunicationManager.Callback; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.Terminal; -import com.vaadin.terminal.ThemeResource; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; -import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.Callback; import com.vaadin.ui.UI; /** diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java index 157bd17e41..2f660a443d 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/server/AbstractClientConnector.java @@ -13,8 +13,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; +import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; @@ -36,12 +37,6 @@ import com.vaadin.external.json.JSONObject; import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.communication.SharedState; -import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; -import com.vaadin.terminal.gwt.server.ClientConnector; -import com.vaadin.terminal.gwt.server.ClientMethodInvocation; -import com.vaadin.terminal.gwt.server.RpcManager; -import com.vaadin.terminal.gwt.server.RpcTarget; -import com.vaadin.terminal.gwt.server.ServerRpcManager; import com.vaadin.ui.HasComponents; import com.vaadin.ui.UI; @@ -373,8 +368,8 @@ public abstract class AbstractClientConnector implements ClientConnector { /** * Finds a UI ancestor of this connector. <code>null</code> is returned if - * no UI ancestor is found (typically because the connector is not - * attached to a proper hierarchy). + * no UI ancestor is found (typically because the connector is not attached + * to a proper hierarchy). * * @return the UI ancestor of this connector, or <code>null</code> if none * is found. @@ -567,4 +562,59 @@ public abstract class AbstractClientConnector implements ClientConnector { public void beforeClientResponse(boolean initial) { // Do nothing by default } + + @Override + public boolean handleConnectorRequest(WrappedRequest request, + WrappedResponse response, String path) throws IOException { + String[] parts = path.split("/", 2); + String key = parts[0]; + + ConnectorResource resource = (ConnectorResource) getResource(key); + if (resource != null) { + DownloadStream stream = resource.getStream(); + stream.writeResponse(request, response); + return true; + } else { + return false; + } + } + + /** + * Gets a resource defined using {@link #setResource(String, Resource)} with + * the corresponding key. + * + * @param key + * the string identifier of the resource + * @return a resource, or <code>null</code> if there's no resource + * associated with the given key + * + * @see #setResource(String, Resource) + */ + protected Resource getResource(String key) { + return ResourceReference.getResource(getState().resources.get(key)); + } + + /** + * Registers a resource with this connector using the given key. This will + * make the URL for retrieving the resource available to the client-side + * connector using + * {@link com.vaadin.terminal.gwt.client.ui.AbstractConnector#getResourceUrl(String)} + * with the same key. + * + * @param key + * the string key to associate the resource with + * @param resource + * the resource to set, or <code>null</code> to clear a previous + * association. + */ + protected void setResource(String key, Resource resource) { + ResourceReference resourceReference = ResourceReference.create( + resource, this, key); + + if (resourceReference == null) { + getState().resources.remove(key); + } else { + getState().resources.put(key, resourceReference); + } + } } diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index 81c497713b..2655ee9a00 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -66,6 +66,13 @@ import com.vaadin.annotations.StyleSheet; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; +import com.vaadin.server.BootstrapHandler.BootstrapContext; +import com.vaadin.server.ComponentSizeValidator.InvalidLayout; +import com.vaadin.server.RpcManager.RpcInvocationException; +import com.vaadin.server.StreamVariable.StreamingEndEvent; +import com.vaadin.server.StreamVariable.StreamingErrorEvent; +import com.vaadin.server.Terminal.ErrorEvent; +import com.vaadin.server.Terminal.ErrorListener; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Connector; import com.vaadin.shared.JavaScriptConnectorState; @@ -75,24 +82,6 @@ import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.UidlValue; import com.vaadin.shared.ui.ui.UIConstants; -import com.vaadin.terminal.AbstractClientConnector; -import com.vaadin.terminal.CombinedRequest; -import com.vaadin.terminal.LegacyPaint; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.StreamVariable; -import com.vaadin.terminal.StreamVariable.StreamingEndEvent; -import com.vaadin.terminal.StreamVariable.StreamingErrorEvent; -import com.vaadin.terminal.Terminal.ErrorEvent; -import com.vaadin.terminal.Terminal.ErrorListener; -import com.vaadin.terminal.Vaadin6Component; -import com.vaadin.terminal.VariableOwner; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; -import com.vaadin.terminal.gwt.server.BootstrapHandler.BootstrapContext; -import com.vaadin.terminal.gwt.server.ComponentSizeValidator.InvalidLayout; -import com.vaadin.terminal.gwt.server.RpcManager.RpcInvocationException; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; import com.vaadin.ui.Component; @@ -105,7 +94,7 @@ import com.vaadin.ui.Window; * This is a common base class for the server-side implementations of the * communication system between the client code (compiled with GWT into * JavaScript) and the server side components. Its client side counterpart is - * {@link com.vaadin.terminal.gwt.client.ApplicationConnection}. + * {@link com.vaadin.client.ApplicationConnection}. * <p> * TODO Document better! */ @@ -114,10 +103,10 @@ public abstract class AbstractCommunicationManager implements Serializable { private static final String DASHDASH = "--"; - private static final RequestHandler APP_RESOURCE_HANDLER = new ApplicationResourceHandler(); - private static final RequestHandler UNSUPPORTED_BROWSER_HANDLER = new UnsupportedBrowserHandler(); + private static final RequestHandler CONNECTOR_RESOURCE_HANDLER = new ConnectorResourceHandler(); + /** * TODO Document me! * @@ -189,8 +178,8 @@ public abstract class AbstractCommunicationManager implements Serializable { public AbstractCommunicationManager(Application application) { this.application = application; application.addRequestHandler(getBootstrapHandler()); - application.addRequestHandler(APP_RESOURCE_HANDLER); application.addRequestHandler(UNSUPPORTED_BROWSER_HANDLER); + application.addRequestHandler(CONNECTOR_RESOURCE_HANDLER); requireLocale(application.getLocale().toString()); } @@ -1342,18 +1331,18 @@ public abstract class AbstractCommunicationManager implements Serializable { private void legacyPaint(PaintTarget paintTarget, ArrayList<ClientConnector> dirtyVisibleConnectors) throws PaintException { - List<Vaadin6Component> legacyComponents = new ArrayList<Vaadin6Component>(); + List<LegacyComponent> legacyComponents = new ArrayList<LegacyComponent>(); for (Connector connector : dirtyVisibleConnectors) { // All Components that want to use paintContent must implement - // Vaadin6Component - if (connector instanceof Vaadin6Component) { - legacyComponents.add((Vaadin6Component) connector); + // LegacyComponent + if (connector instanceof LegacyComponent) { + legacyComponents.add((LegacyComponent) connector); } } sortByHierarchy((List) legacyComponents); - for (Vaadin6Component c : legacyComponents) { + for (LegacyComponent c : legacyComponents) { getLogger().fine( - "Painting Vaadin6Component " + c.getClass().getName() + "@" + "Painting LegacyComponent " + c.getClass().getName() + "@" + Integer.toHexString(c.hashCode())); paintTarget.startTag("change"); final String pid = c.getConnectorId(); diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java b/server/src/com/vaadin/server/AbstractDeploymentConfiguration.java index 4052f5a400..d1280d29ce 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java +++ b/server/src/com/vaadin/server/AbstractDeploymentConfiguration.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.lang.reflect.Constructor; import java.util.Iterator; @@ -22,8 +22,6 @@ import java.util.Properties; import java.util.ServiceLoader; import java.util.logging.Logger; -import com.vaadin.terminal.DeploymentConfiguration; - public abstract class AbstractDeploymentConfiguration implements DeploymentConfiguration { diff --git a/server/src/com/vaadin/terminal/AbstractErrorMessage.java b/server/src/com/vaadin/server/AbstractErrorMessage.java index 808791158a..0928ea4bd4 100644 --- a/server/src/com/vaadin/terminal/AbstractErrorMessage.java +++ b/server/src/com/vaadin/server/AbstractErrorMessage.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.PrintWriter; import java.io.StringWriter; @@ -23,7 +23,6 @@ import java.util.List; import com.vaadin.data.Buffered; import com.vaadin.data.Validator; -import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; /** * Base class for component error messages. diff --git a/server/src/com/vaadin/terminal/AbstractExtension.java b/server/src/com/vaadin/server/AbstractExtension.java index 8ac0ce01e3..747caee967 100644 --- a/server/src/com/vaadin/terminal/AbstractExtension.java +++ b/server/src/com/vaadin/server/AbstractExtension.java @@ -14,9 +14,7 @@ * the License. */ -package com.vaadin.terminal; - -import com.vaadin.terminal.gwt.server.ClientConnector; +package com.vaadin.server; /** * An extension is an entity that is attached to a Component or another diff --git a/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java b/server/src/com/vaadin/server/AbstractJavaScriptExtension.java index 1def6df697..1f67631203 100644 --- a/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java +++ b/server/src/com/vaadin/server/AbstractJavaScriptExtension.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import com.vaadin.shared.JavaScriptExtensionState; import com.vaadin.ui.JavaScriptFunction; @@ -77,8 +77,7 @@ import com.vaadin.ui.JavaScriptFunction; * functions is described bellow.</li> * <li><code>translateVaadinUri(uri)</code> - Translates a Vaadin URI to a URL * that can be used in the browser. This is just way of accessing - * {@link com.vaadin.terminal.gwt.client.ApplicationConnection#translateVaadinUri(String)} - * </li> + * {@link com.vaadin.client.ApplicationConnection#translateVaadinUri(String)}</li> * </ul> * The connector wrapper also supports these special functions: * <ul> diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java b/server/src/com/vaadin/server/AbstractStreamingEvent.java index ec2aa84947..39e43c725d 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java +++ b/server/src/com/vaadin/server/AbstractStreamingEvent.java @@ -13,9 +13,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; -import com.vaadin.terminal.StreamVariable.StreamingEvent; +import com.vaadin.server.StreamVariable.StreamingEvent; /** * Abstract base class for StreamingEvent implementations. diff --git a/server/src/com/vaadin/terminal/AbstractUIProvider.java b/server/src/com/vaadin/server/AbstractUIProvider.java index 5bb4d35b30..07b95fc713 100644 --- a/server/src/com/vaadin/terminal/AbstractUIProvider.java +++ b/server/src/com/vaadin/server/AbstractUIProvider.java @@ -14,7 +14,7 @@ * the License.
*/
-package com.vaadin.terminal;
+package com.vaadin.server;
import com.vaadin.Application;
import com.vaadin.ui.UI;
@@ -22,8 +22,8 @@ import com.vaadin.ui.UI; public abstract class AbstractUIProvider implements UIProvider {
@Override
- public UI instantiateUI(Application application,
- Class<? extends UI> type, WrappedRequest request) {
+ public UI instantiateUI(Application application, Class<? extends UI> type,
+ WrappedRequest request) {
try {
return type.newInstance();
} catch (InstantiationException e) {
diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java b/server/src/com/vaadin/server/AbstractWebApplicationContext.java index d857eeef4a..cf983f4c80 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java +++ b/server/src/com/vaadin/server/AbstractWebApplicationContext.java @@ -13,14 +13,11 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.PrintWriter; import java.io.Serializable; import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -35,8 +32,6 @@ import javax.servlet.http.HttpSessionBindingListener; import com.vaadin.Application; import com.vaadin.service.ApplicationContext; -import com.vaadin.shared.ApplicationConstants; -import com.vaadin.terminal.ApplicationResource; /** * Base class for web application contexts (including portlet contexts) that @@ -187,66 +182,6 @@ public abstract class AbstractWebApplicationContext implements applicationToAjaxAppMgrMap.remove(application); } - @Override - public String generateApplicationResourceURL(ApplicationResource resource, - String mapKey) { - - final String filename = resource.getFilename(); - if (filename == null) { - return ApplicationConstants.APP_PROTOCOL_PREFIX - + ApplicationConstants.APP_REQUEST_PATH + mapKey + "/"; - } else { - // #7738 At least Tomcat and JBoss refuses requests containing - // encoded slashes or backslashes in URLs. Application resource URLs - // should really be passed in another way than as part of the path - // in the future. - String encodedFileName = urlEncode(filename).replace("%2F", "/") - .replace("%5C", "\\"); - return ApplicationConstants.APP_PROTOCOL_PREFIX - + ApplicationConstants.APP_REQUEST_PATH + mapKey + "/" - + encodedFileName; - } - - } - - static String urlEncode(String filename) { - try { - return URLEncoder.encode(filename, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException( - "UTF-8 charset not available (\"this should never happen\")", - e); - } - } - - @Override - public boolean isApplicationResourceURL(URL context, String relativeUri) { - // If the relative uri is null, we are ready - if (relativeUri == null) { - return false; - } - - // Resolves the prefix - String prefix = relativeUri; - final int index = relativeUri.indexOf('/'); - if (index >= 0) { - prefix = relativeUri.substring(0, index); - } - - // Handles the resource requests - return (prefix.equals("APP")); - } - - @Override - public String getURLKey(URL context, String relativeUri) { - final int index = relativeUri.indexOf('/'); - final int next = relativeUri.indexOf('/', index + 1); - if (next < 0) { - return null; - } - return relativeUri.substring(index + 1, next); - } - /** * @return The total time spent servicing requests in this session. */ diff --git a/server/src/com/vaadin/terminal/gwt/server/AddonContext.java b/server/src/com/vaadin/server/AddonContext.java index 2af22c560b..b3cd5ea226 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AddonContext.java +++ b/server/src/com/vaadin/server/AddonContext.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.lang.reflect.Method; import java.util.ArrayList; @@ -24,7 +24,6 @@ import java.util.ServiceLoader; import com.vaadin.Application; import com.vaadin.event.EventRouter; -import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.tools.ReflectTools; /** @@ -35,10 +34,10 @@ import com.vaadin.tools.ReflectTools; * <p> * By default, AddonContextListeners are loaded using {@link ServiceLoader}, * which means that the file - * META-INF/services/com.vaadin.terminal.gwt.server.AddonContextListener will be - * checked for lines containing fully qualified names of classes to use. This - * behavior can however be overridden for custom deployment situations (e.g. to - * use CDI or OSGi) by overriding + * META-INF/services/com.vaadin.server.AddonContextListener will be checked for + * lines containing fully qualified names of classes to use. This behavior can + * however be overridden for custom deployment situations (e.g. to use CDI or + * OSGi) by overriding * {@link DeploymentConfiguration#getAddonContextListeners()}. * * @author Vaadin Ltd diff --git a/server/src/com/vaadin/terminal/gwt/server/AddonContextEvent.java b/server/src/com/vaadin/server/AddonContextEvent.java index 0f3900fa20..d83b1b0084 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AddonContextEvent.java +++ b/server/src/com/vaadin/server/AddonContextEvent.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.EventObject; diff --git a/server/src/com/vaadin/terminal/gwt/server/AddonContextListener.java b/server/src/com/vaadin/server/AddonContextListener.java index b76d233716..a5d9e8c5c9 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AddonContextListener.java +++ b/server/src/com/vaadin/server/AddonContextListener.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.EventListener; @@ -22,8 +22,7 @@ import java.util.EventListener; * Listener that gets notified then the {@link AddonContext} is initialized, * allowing an add-on to add listeners to various parts of the framework. In a * default configuration, add-ons can register their listeners by including a - * file named - * META-INF/services/com.vaadin.terminal.gwt.server.AddonContextListener + * file named META-INF/services/com.vaadin.server.AddonContextListener * containing the fully qualified class names of classes implementing this * interface. * diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationPortlet2.java b/server/src/com/vaadin/server/ApplicationPortlet2.java index 743670438e..3708d8fe0d 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationPortlet2.java +++ b/server/src/com/vaadin/server/ApplicationPortlet2.java @@ -14,13 +14,13 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import javax.portlet.PortletConfig; import javax.portlet.PortletException; import com.vaadin.Application; -import com.vaadin.terminal.gwt.server.ServletPortletHelper.ApplicationClassException; +import com.vaadin.server.ServletPortletHelper.ApplicationClassException; /** * TODO Write documentation, fix JavaDoc tags. diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java b/server/src/com/vaadin/server/ApplicationServlet.java index 857c7c738c..af0cebcf86 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java +++ b/server/src/com/vaadin/server/ApplicationServlet.java @@ -14,14 +14,13 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import com.vaadin.Application; -import com.vaadin.terminal.DefaultUIProvider; -import com.vaadin.terminal.gwt.server.ServletPortletHelper.ApplicationClassException; +import com.vaadin.server.ServletPortletHelper.ApplicationClassException; /** * This servlet connects a Vaadin Application to Web. diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationStartedEvent.java b/server/src/com/vaadin/server/ApplicationStartedEvent.java index 02d73884f5..d06744ae40 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationStartedEvent.java +++ b/server/src/com/vaadin/server/ApplicationStartedEvent.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.EventObject; diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationStartedListener.java b/server/src/com/vaadin/server/ApplicationStartedListener.java index c6976aee57..c54132d875 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationStartedListener.java +++ b/server/src/com/vaadin/server/ApplicationStartedListener.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.EventListener; diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapDom.java b/server/src/com/vaadin/server/BootstrapDom.java index 15210a7de5..65ee9f2761 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapDom.java +++ b/server/src/com/vaadin/server/BootstrapDom.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; public class BootstrapDom { diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java b/server/src/com/vaadin/server/BootstrapFragmentResponse.java index 6f69086523..16f7bc653b 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java +++ b/server/src/com/vaadin/server/BootstrapFragmentResponse.java @@ -14,14 +14,13 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.List; import org.jsoup.nodes.Node; import com.vaadin.Application; -import com.vaadin.terminal.WrappedRequest; /** * A representation of a bootstrap fragment being generated. The bootstrap diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 02005e8d22..280372a5e5 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.BufferedWriter; import java.io.IOException; @@ -43,11 +43,6 @@ import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Version; import com.vaadin.shared.ui.ui.UIConstants; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; import com.vaadin.ui.UI; public abstract class BootstrapHandler implements RequestHandler { diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapListener.java b/server/src/com/vaadin/server/BootstrapListener.java index d99d5b7b84..9b68df3d51 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapListener.java +++ b/server/src/com/vaadin/server/BootstrapListener.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.EventListener; diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java b/server/src/com/vaadin/server/BootstrapPageResponse.java index 847578ef97..d6df145728 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java +++ b/server/src/com/vaadin/server/BootstrapPageResponse.java @@ -14,15 +14,13 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.Map; import org.jsoup.nodes.Document; import com.vaadin.Application; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; /** * A representation of a bootstrap page being generated. The bootstrap page @@ -52,8 +50,7 @@ public class BootstrapPageResponse extends BootstrapResponse { * the application for which the bootstrap page should be * generated * @param uiId - * the generated id of the UI that will be displayed on the - * page + * the generated id of the UI that will be displayed on the page * @param document * the DOM document making up the HTML page * @param headers diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java b/server/src/com/vaadin/server/BootstrapResponse.java index a422cba345..962b48dc31 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java +++ b/server/src/com/vaadin/server/BootstrapResponse.java @@ -14,13 +14,12 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.EventObject; import com.vaadin.Application; import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.UI; /** diff --git a/server/src/com/vaadin/terminal/gwt/server/ChangeVariablesErrorEvent.java b/server/src/com/vaadin/server/ChangeVariablesErrorEvent.java index cb0645d94f..f208fffcef 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ChangeVariablesErrorEvent.java +++ b/server/src/com/vaadin/server/ChangeVariablesErrorEvent.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.Map; diff --git a/server/src/com/vaadin/terminal/ClassResource.java b/server/src/com/vaadin/server/ClassResource.java index e4921f2413..2f05115fd4 100644 --- a/server/src/com/vaadin/terminal/ClassResource.java +++ b/server/src/com/vaadin/server/ClassResource.java @@ -14,12 +14,14 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; import com.vaadin.Application; import com.vaadin.service.FileTypeResolver; +import com.vaadin.ui.UI; +import com.vaadin.ui.UI.LegacyWindow; /** * <code>ClassResource</code> is a named resource accessed with the class @@ -33,7 +35,7 @@ import com.vaadin.service.FileTypeResolver; * @since 3.0 */ @SuppressWarnings("serial") -public class ClassResource implements ApplicationResource, Serializable { +public class ClassResource implements ConnectorResource, Serializable { /** * Default buffer size for this stream resource. @@ -43,10 +45,10 @@ public class ClassResource implements ApplicationResource, Serializable { /** * Default cache time for this stream resource. */ - private long cacheTime = DEFAULT_CACHETIME; + private long cacheTime = DownloadStream.DEFAULT_CACHETIME; /** - * Associated class used for indetifying the source of the resource. + * Associated class used for identifying the source of the resource. */ private final Class<?> associatedClass; @@ -56,21 +58,15 @@ public class ClassResource implements ApplicationResource, Serializable { private final String resourceName; /** - * Application used for serving the class. - */ - private final Application application; - - /** * Creates a new application resource instance. The resource id is relative - * to the location of the application class. + * to the location of the UI of the component using this resource (or the + * Application if using LegacyWindow). * * @param resourceName * the Unique identifier of the resource within the application. - * @param application - * the application this resource will be added to. */ - public ClassResource(String resourceName, Application application) { - this(application.getClass(), resourceName, application); + public ClassResource(String resourceName) { + this(null, resourceName); } /** @@ -80,74 +76,62 @@ public class ClassResource implements ApplicationResource, Serializable { * the class of the which the resource is associated. * @param resourceName * the Unique identifier of the resource within the application. - * @param application - * the application this resource will be added to. */ - public ClassResource(Class<?> associatedClass, String resourceName, - Application application) { + public ClassResource(Class<?> associatedClass, String resourceName) { this.associatedClass = associatedClass; this.resourceName = resourceName; - this.application = application; - if (resourceName == null || associatedClass == null) { + if (resourceName == null) { throw new NullPointerException(); } - application.addResource(this); } /** * Gets the MIME type of this resource. * - * @see com.vaadin.terminal.Resource#getMIMEType() + * @see com.vaadin.server.Resource#getMIMEType() */ @Override public String getMIMEType() { return FileTypeResolver.getMIMEType(resourceName); } - /** - * Gets the application of this resource. - * - * @see com.vaadin.terminal.ApplicationResource#getApplication() - */ - @Override - public Application getApplication() { - return application; - } - - /** - * Gets the virtual filename for this resource. - * - * @return the file name associated to this resource. - * @see com.vaadin.terminal.ApplicationResource#getFilename() - */ @Override public String getFilename() { - int index = 0; - int next = 0; - while ((next = resourceName.indexOf('/', index)) > 0 - && next + 1 < resourceName.length()) { - index = next + 1; - } - return resourceName.substring(index); + String[] parts = resourceName.split("/"); + return parts[parts.length - 1]; } - /** - * Gets resource as stream. - * - * @see com.vaadin.terminal.ApplicationResource#getStream() - */ @Override public DownloadStream getStream() { - final DownloadStream ds = new DownloadStream( - associatedClass.getResourceAsStream(resourceName), - getMIMEType(), getFilename()); + final DownloadStream ds = new DownloadStream(getAssociatedClass() + .getResourceAsStream(resourceName), getMIMEType(), + getFilename()); ds.setBufferSize(getBufferSize()); - ds.setCacheTime(cacheTime); + ds.setCacheTime(getCacheTime()); return ds; } - /* documented in superclass */ - @Override + protected Class<?> getAssociatedClass() { + if (associatedClass == null) { + Class<? extends UI> associatedClass = UI.getCurrent().getClass(); + if (associatedClass == LegacyWindow.class) { + return Application.getCurrent().getClass(); + } + return associatedClass; + } + return associatedClass; + } + + /** + * Gets the size of the download buffer used for this resource. + * + * <p> + * If the buffer size is 0, the buffer size is decided by the terminal + * adapter. The default value is 0. + * </p> + * + * @return the size of the buffer in bytes. + */ public int getBufferSize() { return bufferSize; } @@ -157,13 +141,24 @@ public class ClassResource implements ApplicationResource, Serializable { * * @param bufferSize * the size of the buffer in bytes. + * + * @see #getBufferSize() */ public void setBufferSize(int bufferSize) { this.bufferSize = bufferSize; } - /* documented in superclass */ - @Override + /** + * Gets the length of cache expiration time. + * + * <p> + * This gives the adapter the possibility cache streams sent to the client. + * The caching may be made in adapter or at the client if the client + * supports caching. Default is {@link DownloadStream#DEFAULT_CACHETIME}. + * </p> + * + * @return Cache time in milliseconds + */ public long getCacheTime() { return cacheTime; } @@ -174,7 +169,7 @@ public class ClassResource implements ApplicationResource, Serializable { * <p> * This gives the adapter the possibility cache streams sent to the client. * The caching may be made in adapter or at the client if the client - * supports caching. Zero or negavive value disbales the caching of this + * supports caching. Zero or negative value disables the caching of this * stream. * </p> * diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/server/ClientConnector.java index c2fbbe37d4..3a340c2d7d 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java +++ b/server/src/com/vaadin/server/ClientConnector.java @@ -13,8 +13,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; +import java.io.IOException; import java.util.Collection; import java.util.List; @@ -22,8 +23,6 @@ import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.Connector; import com.vaadin.shared.communication.SharedState; -import com.vaadin.terminal.AbstractClientConnector; -import com.vaadin.terminal.Extension; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.UI; @@ -213,4 +212,30 @@ public interface ClientConnector extends Connector, RpcTarget { * if the state can not be encoded */ public JSONObject encodeState() throws JSONException; + + /** + * Handle a request directed to this connector. This can be used by + * connectors to dynamically generate a response and it is also used + * internally when serving {@link ConnectorResource}s. + * <p> + * Requests to <code>/APP/connector/[ui id]/[connector id]/</code> are + * routed to this method with the remaining part of the requested path + * available in the path parameter. + * <p> + * {@link DynamicConnectorResource} can be used to easily make an + * appropriate URL available to the client-side code. + * + * @param request + * the request that should be handled + * @param response + * the response object to which the response should be written + * @param path + * the requested relative path + * @return <code>true</code> if the request has been handled, + * <code>false</code> if no response has been written. + * @throws IOException + * if there is a problem generating a response. + */ + public boolean handleConnectorRequest(WrappedRequest request, + WrappedResponse response, String path) throws IOException; } diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java b/server/src/com/vaadin/server/ClientMethodInvocation.java index 7cc5159bc0..1533222b3a 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java +++ b/server/src/com/vaadin/server/ClientMethodInvocation.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.Serializable; import java.lang.reflect.Method; diff --git a/server/src/com/vaadin/terminal/CombinedRequest.java b/server/src/com/vaadin/server/CombinedRequest.java index 3d6c3c2149..c186fcc87c 100644 --- a/server/src/com/vaadin/terminal/CombinedRequest.java +++ b/server/src/com/vaadin/server/CombinedRequest.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.IOException; import java.io.InputStream; @@ -28,8 +28,6 @@ import com.vaadin.Application; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; -import com.vaadin.terminal.gwt.server.WebApplicationContext; -import com.vaadin.terminal.gwt.server.WebBrowser; /** * A {@link WrappedRequest} with path and parameters from one request and diff --git a/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/server/src/com/vaadin/server/CommunicationManager.java index 7551e849a1..9b56e20fd4 100644 --- a/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/server/src/com/vaadin/server/CommunicationManager.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.InputStream; import java.net.URL; @@ -23,8 +23,6 @@ import javax.servlet.ServletContext; import com.vaadin.Application; import com.vaadin.external.json.JSONException; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.UI; /** diff --git a/server/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java b/server/src/com/vaadin/server/ComponentSizeValidator.java index 2349be1974..08fa150a9d 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java +++ b/server/src/com/vaadin/server/ComponentSizeValidator.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.PrintStream; import java.io.PrintWriter; @@ -28,7 +28,7 @@ import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; -import com.vaadin.terminal.Sizeable.Unit; +import com.vaadin.server.Sizeable.Unit; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.AbstractSplitPanel; import com.vaadin.ui.Component; diff --git a/server/src/com/vaadin/terminal/CompositeErrorMessage.java b/server/src/com/vaadin/server/CompositeErrorMessage.java index e86102ae3b..f51ba559eb 100644 --- a/server/src/com/vaadin/terminal/CompositeErrorMessage.java +++ b/server/src/com/vaadin/server/CompositeErrorMessage.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.util.Collection; import java.util.Iterator; diff --git a/server/src/com/vaadin/server/ConnectorResource.java b/server/src/com/vaadin/server/ConnectorResource.java new file mode 100644 index 0000000000..e696c35c0d --- /dev/null +++ b/server/src/com/vaadin/server/ConnectorResource.java @@ -0,0 +1,42 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.server; + +/** + * A resource that is served through the Connector that is using the resource. + * + * @see AbstractClientConnector#setResource(String, Resource) + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public interface ConnectorResource extends Resource { + public static final String CONNECTOR_REQUEST_PATH = "connector/"; + + /** + * Gets resource as stream. + */ + public DownloadStream getStream(); + + /** + * Gets the virtual filename for this resource. + * + * @return the file name associated to this resource. + */ + public String getFilename(); +} diff --git a/server/src/com/vaadin/server/ConnectorResourceHandler.java b/server/src/com/vaadin/server/ConnectorResourceHandler.java new file mode 100644 index 0000000000..b988510b8e --- /dev/null +++ b/server/src/com/vaadin/server/ConnectorResourceHandler.java @@ -0,0 +1,81 @@ +package com.vaadin.server; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.http.HttpServletResponse; + +import com.vaadin.Application; +import com.vaadin.shared.ApplicationConstants; +import com.vaadin.ui.UI; + +public class ConnectorResourceHandler implements RequestHandler { + // APP/connector/[uiid]/[cid]/[filename.xyz] + private static final Pattern CONNECTOR_RESOURCE_PATTERN = Pattern + .compile("^/?" + ApplicationConstants.APP_REQUEST_PATH + + ConnectorResource.CONNECTOR_REQUEST_PATH + + "(\\d+)/(\\d+)/(.*)"); + + private static Logger getLogger() { + return Logger.getLogger(ConnectorResourceHandler.class.getName()); + + } + + @Override + public boolean handleRequest(Application application, + WrappedRequest request, WrappedResponse response) + throws IOException { + String requestPath = request.getRequestPathInfo(); + if (requestPath == null) { + return false; + } + Matcher matcher = CONNECTOR_RESOURCE_PATTERN.matcher(requestPath); + if (matcher.matches()) { + String uiId = matcher.group(1); + String cid = matcher.group(2); + String key = matcher.group(3); + UI ui = application.getUIById(Integer.parseInt(uiId)); + if (ui == null) { + return error(request, response, + "Ignoring connector request for no-existent root " + + uiId); + } + + UI.setCurrent(ui); + Application.setCurrent(ui.getApplication()); + + ClientConnector connector = ui.getConnectorTracker().getConnector( + cid); + if (connector == null) { + return error(request, response, + "Ignoring connector request for no-existent connector " + + cid + " in root " + uiId); + } + + if (!connector.handleConnectorRequest(request, response, key)) { + return error(request, response, connector.getClass() + .getSimpleName() + + " (" + + connector.getConnectorId() + + ") did not handle connector request for " + key); + } + + return true; + } else { + return false; + } + } + + private static boolean error(WrappedRequest request, + WrappedResponse response, String logMessage) throws IOException { + getLogger().log(Level.WARNING, logMessage); + response.sendError(HttpServletResponse.SC_NOT_FOUND, + request.getRequestPathInfo() + " can not be found"); + + // Request handled (though not in a nice way) + return true; + } +} diff --git a/server/src/com/vaadin/terminal/gwt/server/Constants.java b/server/src/com/vaadin/server/Constants.java index 9640216488..afb2d4dae1 100644 --- a/server/src/com/vaadin/terminal/gwt/server/Constants.java +++ b/server/src/com/vaadin/server/Constants.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; /** * TODO Document me! @@ -81,7 +81,7 @@ public interface Constants { static final String WIDGETSET_DIRECTORY_PATH = "VAADIN/widgetsets/"; // Name of the default widget set, used if not specified in web.xml - static final String DEFAULT_WIDGETSET = "com.vaadin.terminal.gwt.DefaultWidgetSet"; + static final String DEFAULT_WIDGETSET = "com.vaadin.DefaultWidgetSet"; // Widget set parameter name static final String PARAMETER_WIDGETSET = "widgetset"; diff --git a/server/src/com/vaadin/terminal/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java index 8713c45b31..913402c89f 100644 --- a/server/src/com/vaadin/terminal/DefaultUIProvider.java +++ b/server/src/com/vaadin/server/DefaultUIProvider.java @@ -14,7 +14,7 @@ * the License.
*/
-package com.vaadin.terminal;
+package com.vaadin.server;
import com.vaadin.Application;
import com.vaadin.UIRequiresMoreInformationException;
diff --git a/server/src/com/vaadin/terminal/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java index 0cfbdb7544..d1cbdfc499 100644 --- a/server/src/com/vaadin/terminal/DeploymentConfiguration.java +++ b/server/src/com/vaadin/server/DeploymentConfiguration.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; import java.util.Iterator; @@ -24,8 +24,6 @@ import javax.portlet.PortletContext; import javax.servlet.ServletContext; import com.vaadin.service.ApplicationContext; -import com.vaadin.terminal.gwt.server.AddonContext; -import com.vaadin.terminal.gwt.server.AddonContextListener; /** * Provide deployment specific settings that are required outside terminal diff --git a/server/src/com/vaadin/terminal/DownloadStream.java b/server/src/com/vaadin/server/DownloadStream.java index 30810d5da4..0c00f96832 100644 --- a/server/src/com/vaadin/terminal/DownloadStream.java +++ b/server/src/com/vaadin/server/DownloadStream.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.IOException; import java.io.InputStream; @@ -26,8 +26,6 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; -import com.vaadin.terminal.gwt.server.Constants; - /** * Downloadable stream. * @@ -232,14 +230,18 @@ public class DownloadStream implements Serializable { * redirect (302 Moved temporarily) is sent instead of the contents of this * stream. * + * @param request + * the request for which the response should be written * @param response * the wrapped response to write this download stream to + * * @throws IOException * passed through from the wrapped response * * @since 7.0 */ - public void writeTo(WrappedResponse response) throws IOException { + public void writeResponse(WrappedRequest request, WrappedResponse response) + throws IOException { if (getParameter("Location") != null) { response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); response.setHeader("Location", getParameter("Location")); diff --git a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/server/src/com/vaadin/server/DragAndDropService.java index 0106f466fc..3e7de5c9a2 100644 --- a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/server/src/com/vaadin/server/DragAndDropService.java @@ -13,8 +13,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; +import java.io.IOException; import java.io.PrintWriter; import java.util.Collection; import java.util.Collections; @@ -36,9 +37,6 @@ import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.ui.dd.DragEventType; -import com.vaadin.terminal.Extension; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.VariableOwner; import com.vaadin.ui.Component; import com.vaadin.ui.UI; @@ -341,4 +339,10 @@ public class DragAndDropService implements VariableOwner, ClientConnector { // TODO Auto-generated method stub return null; } + + @Override + public boolean handleConnectorRequest(WrappedRequest request, + WrappedResponse response, String path) throws IOException { + return false; + } } diff --git a/server/src/com/vaadin/server/DynamicConnectorResource.java b/server/src/com/vaadin/server/DynamicConnectorResource.java new file mode 100644 index 0000000000..8269f261f7 --- /dev/null +++ b/server/src/com/vaadin/server/DynamicConnectorResource.java @@ -0,0 +1,95 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.server; + +import java.util.Collections; +import java.util.Map; + +import com.vaadin.service.FileTypeResolver; + +/** + * A resource that is served by calling + * {@link ClientConnector#handleConnectorRequest(WrappedRequest, WrappedResponse, String)} + * with appropriate parameters. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public class DynamicConnectorResource implements Resource { + + private final ClientConnector connector; + private final String path; + private final Map<String, String> parameters; + + /** + * Creates a DynamicConnectorResoruce for the given connector that will be + * served by calling + * {@link ClientConnector#handleConnectorRequest(WrappedRequest, WrappedResponse, String)} + * with the given path. + * + * @param connector + * the connector that should serve the resource + * @param path + * the relative path of the request + */ + public DynamicConnectorResource(ClientConnector connector, String path) { + this(connector, path, null); + } + + /** + * Creates a DynamicConnectorResoruce for the given connector that will be + * served by calling + * {@link ClientConnector#handleConnectorRequest(WrappedRequest, WrappedResponse, String)} + * with the given path and the given request parameters. + * + * @param connector + * the connector that should serve the resource + * @param path + * the relative path of the request + * @param parameters + * the parameters that should be present in the request + */ + public DynamicConnectorResource(ClientConnector connector, String path, + Map<String, String> parameters) { + this.connector = connector; + this.path = path; + this.parameters = parameters; + } + + @Override + public String getMIMEType() { + return FileTypeResolver.getMIMEType(path); + } + + public String getPath() { + return path; + } + + public ClientConnector getConnector() { + return connector; + } + + public Map<String, String> getParameters() { + if (parameters == null) { + return Collections.emptyMap(); + } else { + return Collections.unmodifiableMap(parameters); + } + } + +} diff --git a/server/src/com/vaadin/terminal/gwt/server/EncodeResult.java b/server/src/com/vaadin/server/EncodeResult.java index a62df2e632..f58c0b4810 100644 --- a/server/src/com/vaadin/terminal/gwt/server/EncodeResult.java +++ b/server/src/com/vaadin/server/EncodeResult.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; public class EncodeResult { private final Object encodedValue; diff --git a/server/src/com/vaadin/terminal/ErrorMessage.java b/server/src/com/vaadin/server/ErrorMessage.java index 15273efb6f..fcc481e826 100644 --- a/server/src/com/vaadin/terminal/ErrorMessage.java +++ b/server/src/com/vaadin/server/ErrorMessage.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; diff --git a/server/src/com/vaadin/terminal/Extension.java b/server/src/com/vaadin/server/Extension.java index 87901c3c13..bb7d133e8e 100644 --- a/server/src/com/vaadin/terminal/Extension.java +++ b/server/src/com/vaadin/server/Extension.java @@ -14,9 +14,7 @@ * the License. */ -package com.vaadin.terminal; - -import com.vaadin.terminal.gwt.server.ClientConnector; +package com.vaadin.server; /** * An extension is an entity that is attached to a Component or another diff --git a/server/src/com/vaadin/terminal/ExternalResource.java b/server/src/com/vaadin/server/ExternalResource.java index d970c0934b..925b0589f3 100644 --- a/server/src/com/vaadin/terminal/ExternalResource.java +++ b/server/src/com/vaadin/server/ExternalResource.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; import java.net.URL; @@ -108,7 +108,7 @@ public class ExternalResource implements Resource, Serializable { /** * Gets the MIME type of the resource. * - * @see com.vaadin.terminal.Resource#getMIMEType() + * @see com.vaadin.server.Resource#getMIMEType() */ @Override public String getMIMEType() { diff --git a/server/src/com/vaadin/terminal/FileResource.java b/server/src/com/vaadin/server/FileResource.java index ab8bc95ce3..fbf353362e 100644 --- a/server/src/com/vaadin/terminal/FileResource.java +++ b/server/src/com/vaadin/server/FileResource.java @@ -14,15 +14,15 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import com.vaadin.Application; +import com.vaadin.server.Terminal.ErrorEvent; import com.vaadin.service.FileTypeResolver; -import com.vaadin.terminal.Terminal.ErrorEvent; /** * <code>FileResources</code> are files or directories on local filesystem. The @@ -34,7 +34,7 @@ import com.vaadin.terminal.Terminal.ErrorEvent; * @since 3.0 */ @SuppressWarnings("serial") -public class FileResource implements ApplicationResource { +public class FileResource implements ConnectorResource { /** * Default buffer size for this stream resource. @@ -47,11 +47,6 @@ public class FileResource implements ApplicationResource { private File sourceFile; /** - * Application. - */ - private final Application application; - - /** * Default cache time for this stream resource. */ private long cacheTime = DownloadStream.DEFAULT_CACHETIME; @@ -59,18 +54,14 @@ public class FileResource implements ApplicationResource { /** * Creates a new file resource for providing given file for client * terminals. + * + * @param sourceFile + * the file that should be served. */ - public FileResource(File sourceFile, Application application) { - this.application = application; + public FileResource(File sourceFile) { setSourceFile(sourceFile); - application.addResource(this); } - /** - * Gets the resource as stream. - * - * @see com.vaadin.terminal.ApplicationResource#getStream() - */ @Override public DownloadStream getStream() { try { @@ -83,14 +74,15 @@ public class FileResource implements ApplicationResource { return ds; } catch (final FileNotFoundException e) { // Log the exception using the application error handler - getApplication().getErrorHandler().terminalError(new ErrorEvent() { + Application.getCurrent().getErrorHandler() + .terminalError(new ErrorEvent() { - @Override - public Throwable getThrowable() { - return e; - } + @Override + public Throwable getThrowable() { + return e; + } - }); + }); return null; } @@ -111,29 +103,15 @@ public class FileResource implements ApplicationResource { * @param sourceFile * the source file to set. */ - public void setSourceFile(File sourceFile) { + private void setSourceFile(File sourceFile) { this.sourceFile = sourceFile; } - /** - * @see com.vaadin.terminal.ApplicationResource#getApplication() - */ - @Override - public Application getApplication() { - return application; - } - - /** - * @see com.vaadin.terminal.ApplicationResource#getFilename() - */ @Override public String getFilename() { return sourceFile.getName(); } - /** - * @see com.vaadin.terminal.Resource#getMIMEType() - */ @Override public String getMIMEType() { return FileTypeResolver.getMIMEType(sourceFile); @@ -147,7 +125,6 @@ public class FileResource implements ApplicationResource { * * @return Cache time in milliseconds. */ - @Override public long getCacheTime() { return cacheTime; } @@ -165,8 +142,16 @@ public class FileResource implements ApplicationResource { this.cacheTime = cacheTime; } - /* documented in superclass */ - @Override + /** + * Gets the size of the download buffer used for this resource. + * + * <p> + * If the buffer size is 0, the buffer size is decided by the terminal + * adapter. The default value is 0. + * </p> + * + * @return the size of the buffer in bytes. + */ public int getBufferSize() { return bufferSize; } diff --git a/server/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java b/server/src/com/vaadin/server/GAEApplicationServlet.java index fe3d384c5c..16345edead 100644 --- a/server/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java +++ b/server/src/com/vaadin/server/GAEApplicationServlet.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -56,7 +56,7 @@ import com.vaadin.service.ApplicationContext; * <pre> * <servlet> * <servlet-name>HelloWorld</servlet-name> - * <servlet-class>com.vaadin.terminal.gwt.server.GAEApplicationServlet</servlet-class> + * <servlet-class>com.vaadin.server.GAEApplicationServlet</servlet-class> * <init-param> * <param-name>application</param-name> * <param-value>com.vaadin.demo.HelloWorld</param-value> diff --git a/server/src/com/vaadin/server/GlobalResourceHandler.java b/server/src/com/vaadin/server/GlobalResourceHandler.java new file mode 100644 index 0000000000..f3a72a0efc --- /dev/null +++ b/server/src/com/vaadin/server/GlobalResourceHandler.java @@ -0,0 +1,239 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.server; + +import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.http.HttpServletResponse; + +import com.vaadin.Application; +import com.vaadin.shared.ApplicationConstants; +import com.vaadin.ui.UI; + +/** + * A {@link RequestHandler} that takes care of {@link ConnectorResource}s that + * should not be served by the connector. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public class GlobalResourceHandler implements RequestHandler { + private static final String LEGACY_TYPE = "legacy"; + + private static final String RESOURCE_REQUEST_PATH = "global/"; + + /** + * Used to detect when a resource is no longer used by any connector. + */ + private final Map<Resource, Set<ClientConnector>> resourceUsers = new HashMap<Resource, Set<ClientConnector>>(); + /** + * Used to find the resources that might not be needed any more when a + * connector is unregistered. + */ + private final Map<ClientConnector, Set<Resource>> usedResources = new HashMap<ClientConnector, Set<Resource>>(); + + private final Map<ConnectorResource, String> legacyResourceKeys = new HashMap<ConnectorResource, String>(); + private final Map<String, ConnectorResource> legacyResources = new HashMap<String, ConnectorResource>(); + private int nextLegacyId = 0; + + // APP/global/[uiid]/[type]/[id] + private final Matcher matcher = Pattern.compile( + "^/?" + ApplicationConstants.APP_REQUEST_PATH + + RESOURCE_REQUEST_PATH + "(\\d+)/(([^/]+)(/.*))").matcher( + ""); + + @Override + public boolean handleRequest(Application application, + WrappedRequest request, WrappedResponse response) + throws IOException { + String pathInfo = request.getRequestPathInfo(); + if (pathInfo == null) { + return false; + } + + matcher.reset(pathInfo); + if (!matcher.matches()) { + return false; + } + + String uiid = matcher.group(1); + String type = matcher.group(3); + String key = matcher.group(2); + + // Allow GCing pathInfo string + matcher.reset(); + + if (key == null) { + return error(request, response, pathInfo + + " is not a valid global resource path"); + } + + UI ui = application.getUIById(Integer.parseInt(uiid)); + if (ui == null) { + return error(request, response, "No UI found for id " + uiid); + } + UI.setCurrent(ui); + + ConnectorResource resource; + if (LEGACY_TYPE.equals(type)) { + resource = legacyResources.get(key); + } else { + return error(request, response, "Unknown global resource type " + + type + " in requested path " + pathInfo); + } + + if (resource == null) { + return error(request, response, "Global resource " + key + + " not found"); + } + + DownloadStream stream = resource.getStream(); + if (stream == null) { + return error(request, response, "Resource " + resource + + " didn't produce any stream."); + } + + stream.writeResponse(request, response); + return true; + } + + /** + * Registers a resource to be served with a global URL. + * <p> + * A {@link ConnectorResource} registered for a {@link Vaadin6Component} + * will be set to be served with a global URL. Other resource types will be + * ignored and thus not served by this handler. + * + * @param resource + * the resource to register + * @param ownerConnector + * the connector to which the resource belongs + */ + public void register(Resource resource, ClientConnector ownerConnector) { + if (resource instanceof ConnectorResource) { + if (!(ownerConnector instanceof LegacyComponent)) { + throw new IllegalArgumentException( + "A normal ConnectorResource can only be registered for legacy components."); + } + ConnectorResource connectorResource = (ConnectorResource) resource; + if (!legacyResourceKeys.containsKey(resource)) { + String uri = LEGACY_TYPE + '/' + + Integer.toString(nextLegacyId++); + String filename = connectorResource.getFilename(); + if (filename != null && !filename.isEmpty()) { + uri += '/' + filename; + } + legacyResourceKeys.put(connectorResource, uri); + legacyResources.put(uri, connectorResource); + registerResourceUsage(connectorResource, ownerConnector); + } + } + } + + private void unregisterResource(Resource resource) { + String oldUri = legacyResourceKeys.remove(resource); + if (oldUri != null) { + legacyResources.remove(oldUri); + } + } + + private void registerResourceUsage(Resource resource, + ClientConnector connector) { + ensureInSet(resourceUsers, resource, connector); + ensureInSet(usedResources, connector, resource); + } + + private <K, V> void ensureInSet(Map<K, Set<V>> map, K key, V value) { + Set<V> set = map.get(key); + if (set == null) { + set = new HashSet<V>(); + map.put(key, set); + } + set.add(value); + } + + /** + * Gets a global URI for a resource if it's registered with this handler. + * + * @param connector + * the connector for which the uri should be generated. + * @param resource + * the resource for which the uri should be generated. + * @return an URI string, or <code>null</code> if the resource is not + * registered. + */ + public String getUri(ClientConnector connector, ConnectorResource resource) { + // app://APP/global/[ui]/[type]/[id] + String uri = legacyResourceKeys.get(resource); + if (uri != null && !uri.isEmpty()) { + return ApplicationConstants.APP_PROTOCOL_PREFIX + + ApplicationConstants.APP_REQUEST_PATH + + RESOURCE_REQUEST_PATH + connector.getUI().getUIId() + '/' + + uri; + } else { + return null; + } + } + + /** + * Notifies this handler that resources registered for the given connector + * can be released. + * + * @param connector + * the connector for which any registered resources can be + * released. + */ + public void unregisterConnector(ClientConnector connector) { + Set<Resource> set = usedResources.remove(connector); + if (set == null) { + return; + } + + for (Resource resource : set) { + Set<ClientConnector> users = resourceUsers.get(resource); + users.remove(connector); + if (users.isEmpty()) { + resourceUsers.remove(resource); + unregisterResource(resource); + } + } + } + + private static Logger getLogger() { + return Logger.getLogger(GlobalResourceHandler.class.getName()); + } + + private static boolean error(WrappedRequest request, + WrappedResponse response, String logMessage) throws IOException { + getLogger().log(Level.WARNING, logMessage); + response.sendError(HttpServletResponse.SC_NOT_FOUND, + request.getRequestPathInfo() + " can not be found"); + + // Request handled (though not in a nice way) + return true; + } + +} diff --git a/server/src/com/vaadin/terminal/gwt/server/HttpServletRequestListener.java b/server/src/com/vaadin/server/HttpServletRequestListener.java index 22467a0c1a..1f9f633c17 100644 --- a/server/src/com/vaadin/terminal/gwt/server/HttpServletRequestListener.java +++ b/server/src/com/vaadin/server/HttpServletRequestListener.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.Serializable; @@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; import com.vaadin.service.ApplicationContext.TransactionListener; -import com.vaadin.terminal.Terminal; /** * {@link Application} that implements this interface gets notified of request diff --git a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java b/server/src/com/vaadin/server/JavaScriptCallbackHelper.java index f0063a8708..19b19ce824 100644 --- a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java +++ b/server/src/com/vaadin/server/JavaScriptCallbackHelper.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; import java.lang.reflect.Method; @@ -36,7 +36,7 @@ import com.vaadin.ui.JavaScriptFunction; * Internal helper class used to implement functionality common to * {@link AbstractJavaScriptComponent} and {@link AbstractJavaScriptExtension}. * Corresponding support in client-side code is in - * {@link com.vaadin.terminal.gwt.client.JavaScriptConnectorHelper}. + * {@link com.vaadin.client.JavaScriptConnectorHelper}. * <p> * You should most likely no use this class directly. * diff --git a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/server/src/com/vaadin/server/JsonCodec.java index 3ba52a4e91..689ffe034e 100644 --- a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java +++ b/server/src/com/vaadin/server/JsonCodec.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.beans.IntrospectionException; import java.beans.Introspector; diff --git a/server/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/server/src/com/vaadin/server/JsonPaintTarget.java index cfc3cc7e7e..b193c47528 100644 --- a/server/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/server/src/com/vaadin/server/JsonPaintTarget.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.PrintWriter; import java.io.Serializable; @@ -27,11 +27,6 @@ import java.util.Stack; import java.util.Vector; import java.util.logging.Logger; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.StreamVariable; -import com.vaadin.terminal.VariableOwner; import com.vaadin.ui.Alignment; import com.vaadin.ui.Component; import com.vaadin.ui.CustomLayout; @@ -349,7 +344,12 @@ public class JsonPaintTarget implements PaintTarget { if (value == null) { throw new NullPointerException(); } - ResourceReference reference = ResourceReference.create(value); + ClientConnector ownerConnector = openPaintables.peek(); + ownerConnector.getUI().getApplication().getGlobalResourceHandler(true) + .register(value, ownerConnector); + + ResourceReference reference = ResourceReference.create(value, + ownerConnector, name); addAttribute(name, reference.getURL()); } @@ -589,8 +589,7 @@ public class JsonPaintTarget implements PaintTarget { * @throws PaintException * if the paint operation failed. * - * @see com.vaadin.terminal.PaintTarget#addXMLSection(String, String, - * String) + * @see com.vaadin.server.PaintTarget#addXMLSection(String, String, String) */ @Override diff --git a/server/src/com/vaadin/terminal/KeyMapper.java b/server/src/com/vaadin/server/KeyMapper.java index cf54af545f..86714cfc66 100644 --- a/server/src/com/vaadin/terminal/KeyMapper.java +++ b/server/src/com/vaadin/server/KeyMapper.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; import java.util.HashMap; diff --git a/server/src/com/vaadin/terminal/Vaadin6Component.java b/server/src/com/vaadin/server/LegacyComponent.java index eb169c90f9..b6e620f920 100644 --- a/server/src/com/vaadin/terminal/Vaadin6Component.java +++ b/server/src/com/vaadin/server/LegacyComponent.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.util.EventListener; @@ -29,7 +29,7 @@ import com.vaadin.ui.Component; * @since 7.0.0 * */ -public interface Vaadin6Component extends VariableOwner, Component, +public interface LegacyComponent extends VariableOwner, Component, EventListener { /** @@ -55,11 +55,11 @@ public interface Vaadin6Component extends VariableOwner, Component, /** * (non-Javadoc) {@inheritDoc} * <p> - * For a Vaadin6Component, markAsDirty will also cause + * For a LegacyComponent, markAsDirty will also cause * {@link #paintContent(PaintTarget)} to be called before sending changes to * the client. * - * @see com.vaadin.terminal.gwt.server.ClientConnector#markAsDirty() + * @see com.vaadin.server.ClientConnector#markAsDirty() */ @Override public void markAsDirty(); diff --git a/server/src/com/vaadin/terminal/LegacyPaint.java b/server/src/com/vaadin/server/LegacyPaint.java index 3db0f52079..c39e0e8247 100644 --- a/server/src/com/vaadin/terminal/LegacyPaint.java +++ b/server/src/com/vaadin/server/LegacyPaint.java @@ -13,11 +13,11 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; -import com.vaadin.terminal.PaintTarget.PaintStatus; +import com.vaadin.server.PaintTarget.PaintStatus; import com.vaadin.ui.Component; import com.vaadin.ui.HasComponents; @@ -61,8 +61,8 @@ public class LegacyPaint implements Serializable { target.addAttribute("cached", true); } else { // Paint the contents of the component - if (component instanceof Vaadin6Component) { - ((Vaadin6Component) component).paintContent(target); + if (component instanceof LegacyComponent) { + ((LegacyComponent) component).paintContent(target); } } diff --git a/server/src/com/vaadin/terminal/gwt/server/NoInputStreamException.java b/server/src/com/vaadin/server/NoInputStreamException.java index 445d8c3cb1..acd148864a 100644 --- a/server/src/com/vaadin/terminal/gwt/server/NoInputStreamException.java +++ b/server/src/com/vaadin/server/NoInputStreamException.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; @SuppressWarnings("serial") public class NoInputStreamException extends Exception { diff --git a/server/src/com/vaadin/terminal/gwt/server/NoOutputStreamException.java b/server/src/com/vaadin/server/NoOutputStreamException.java index fc9b3dee8a..8900079b4b 100644 --- a/server/src/com/vaadin/terminal/gwt/server/NoOutputStreamException.java +++ b/server/src/com/vaadin/server/NoOutputStreamException.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; @SuppressWarnings("serial") public class NoOutputStreamException extends Exception { diff --git a/server/src/com/vaadin/terminal/Page.java b/server/src/com/vaadin/server/Page.java index 66ef7da296..b8fdae6cfb 100644 --- a/server/src/com/vaadin/terminal/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; import java.lang.reflect.Method; @@ -24,12 +24,10 @@ import java.util.LinkedList; import java.util.List; import com.vaadin.event.EventRouter; +import com.vaadin.server.WrappedRequest.BrowserDetails; import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.ui.PageClientRpc; import com.vaadin.shared.ui.ui.UIConstants; -import com.vaadin.terminal.WrappedRequest.BrowserDetails; -import com.vaadin.terminal.gwt.server.WebApplicationContext; -import com.vaadin.terminal.gwt.server.WebBrowser; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.JavaScript; import com.vaadin.ui.Notification; @@ -303,17 +301,36 @@ public class Page implements Serializable { } } - public void addListener(Page.FragmentChangedListener listener) { + public void addFragmentChangedListener(Page.FragmentChangedListener listener) { addListener(FragmentChangedEvent.class, listener, FRAGMENT_CHANGED_METHOD); } - public void removeListener(Page.FragmentChangedListener listener) { + /** + * @deprecated Since 7.0, replaced by + * {@link #addFragmentChangedListener(FragmentChangedListener)} + **/ + @Deprecated + public void addListener(Page.FragmentChangedListener listener) { + addFragmentChangedListener(listener); + } + + public void removeFragmentChangedListener( + Page.FragmentChangedListener listener) { removeListener(FragmentChangedEvent.class, listener, FRAGMENT_CHANGED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeFragmentChangedListener(FragmentChangedListener)} + **/ + @Deprecated + public void removeListener(Page.FragmentChangedListener listener) { + removeFragmentChangedListener(listener); + } + + /** * Sets URI fragment. Optionally fires a {@link FragmentChangedEvent} * * @param newFragment @@ -400,8 +417,8 @@ public class Page implements Serializable { /** * Adds a new {@link BrowserWindowResizeListener} to this uI. The listener - * will be notified whenever the browser window within which this uI - * resides is resized. + * will be notified whenever the browser window within which this uI resides + * is resized. * * @param resizeListener * the listener to add @@ -409,25 +426,45 @@ public class Page implements Serializable { * @see BrowserWindowResizeListener#browserWindowResized(BrowserWindowResizeEvent) * @see #setResizeLazy(boolean) */ - public void addListener(BrowserWindowResizeListener resizeListener) { + public void addBrowserWindowResizeListener( + BrowserWindowResizeListener resizeListener) { addListener(BrowserWindowResizeEvent.class, resizeListener, BROWSWER_RESIZE_METHOD); } /** - * Removes a {@link BrowserWindowResizeListener} from this uI. The - * listener will no longer be notified when the browser window is resized. + * @deprecated Since 7.0, replaced by + * {@link #addBrowserWindowResizeListener(BrowserWindowResizeListener)} + **/ + @Deprecated + public void addListener(BrowserWindowResizeListener resizeListener) { + addBrowserWindowResizeListener(resizeListener); + } + + /** + * Removes a {@link BrowserWindowResizeListener} from this UI. The listener + * will no longer be notified when the browser window is resized. * * @param resizeListener * the listener to remove */ - public void removeListener(BrowserWindowResizeListener resizeListener) { + public void removeBrowserWindowResizeListener( + BrowserWindowResizeListener resizeListener) { removeListener(BrowserWindowResizeEvent.class, resizeListener, BROWSWER_RESIZE_METHOD); } /** - * Gets the last known height of the browser window in which this uI + * @deprecated Since 7.0, replaced by + * {@link #removeBrowserWindowResizeListener(BrowserWindowResizeListener)} + **/ + @Deprecated + public void removeListener(BrowserWindowResizeListener resizeListener) { + removeBrowserWindowResizeListener(resizeListener); + } + + /** + * Gets the last known height of the browser window in which this UI * resides. * * @return the browser window height in pixels @@ -437,8 +474,7 @@ public class Page implements Serializable { } /** - * Gets the last known width of the browser window in which this uI - * resides. + * Gets the last known width of the browser window in which this uI resides. * * @return the browser window width in pixels */ @@ -515,8 +551,8 @@ public class Page implements Serializable { } /** - * Opens the given resource in this uI. The contents of this UI is - * replaced by the {@code Resource}. + * Opens the given resource in this uI. The contents of this UI is replaced + * by the {@code Resource}. * * @param resource * the resource to show in this uI diff --git a/server/src/com/vaadin/terminal/PaintException.java b/server/src/com/vaadin/server/PaintException.java index dd5752653a..5d6f7b1d58 100644 --- a/server/src/com/vaadin/terminal/PaintException.java +++ b/server/src/com/vaadin/server/PaintException.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.IOException; import java.io.Serializable; diff --git a/server/src/com/vaadin/terminal/PaintTarget.java b/server/src/com/vaadin/server/PaintTarget.java index 5ccca8a8f0..268523f92f 100644 --- a/server/src/com/vaadin/terminal/PaintTarget.java +++ b/server/src/com/vaadin/server/PaintTarget.java @@ -14,13 +14,12 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; import java.util.Map; -import com.vaadin.terminal.StreamVariable.StreamingStartEvent; -import com.vaadin.terminal.gwt.server.ClientConnector; +import com.vaadin.server.StreamVariable.StreamingStartEvent; import com.vaadin.ui.Component; /** @@ -194,7 +193,7 @@ public interface PaintTarget extends Serializable { * <p> * The urls in UIDL message may use Vaadin specific protocol. Before * actually using the urls on the client side, they should be passed via - * {@link com.vaadin.terminal.gwt.client.ApplicationConnection#translateVaadinUri(String)}. + * {@link com.vaadin.client.ApplicationConnection#translateVaadinUri(String)}. * <p> * Note that in current terminal implementation StreamVariables are cleaned * from the terminal only when: diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/server/src/com/vaadin/server/PortletApplicationContext2.java index 3e0f8d6b99..aca80f9c17 100644 --- a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/server/src/com/vaadin/server/PortletApplicationContext2.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.File; import java.io.Serializable; @@ -45,7 +45,6 @@ import javax.servlet.http.HttpSessionBindingListener; import javax.xml.namespace.QName; import com.vaadin.Application; -import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.UI; /** diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/server/src/com/vaadin/server/PortletCommunicationManager.java index e127425786..f7d9371022 100644 --- a/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java +++ b/server/src/com/vaadin/server/PortletCommunicationManager.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.IOException; import java.io.InputStream; @@ -30,10 +30,6 @@ import com.vaadin.Application; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; import com.vaadin.ui.UI; /** diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletRequestListener.java b/server/src/com/vaadin/server/PortletRequestListener.java index f7b6421e11..35f2a946c5 100644 --- a/server/src/com/vaadin/terminal/gwt/server/PortletRequestListener.java +++ b/server/src/com/vaadin/server/PortletRequestListener.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.Serializable; @@ -23,7 +23,6 @@ import javax.servlet.Filter; import com.vaadin.Application; import com.vaadin.service.ApplicationContext.TransactionListener; -import com.vaadin.terminal.Terminal; /** * An {@link Application} that implements this interface gets notified of diff --git a/server/src/com/vaadin/terminal/RequestHandler.java b/server/src/com/vaadin/server/RequestHandler.java index 2ea02487b1..fcc506cc54 100644 --- a/server/src/com/vaadin/terminal/RequestHandler.java +++ b/server/src/com/vaadin/server/RequestHandler.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.IOException; import java.io.Serializable; diff --git a/server/src/com/vaadin/terminal/gwt/server/RequestTimer.java b/server/src/com/vaadin/server/RequestTimer.java index e3e0dc0106..1dfe24f23b 100644 --- a/server/src/com/vaadin/terminal/gwt/server/RequestTimer.java +++ b/server/src/com/vaadin/server/RequestTimer.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.Serializable; diff --git a/server/src/com/vaadin/terminal/Resource.java b/server/src/com/vaadin/server/Resource.java index 27adb16869..fa1e040929 100644 --- a/server/src/com/vaadin/terminal/Resource.java +++ b/server/src/com/vaadin/server/Resource.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; diff --git a/server/src/com/vaadin/server/ResourceReference.java b/server/src/com/vaadin/server/ResourceReference.java new file mode 100644 index 0000000000..098fb6c3e4 --- /dev/null +++ b/server/src/com/vaadin/server/ResourceReference.java @@ -0,0 +1,147 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.server; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Map.Entry; +import java.util.Set; + +import com.vaadin.shared.ApplicationConstants; +import com.vaadin.shared.communication.URLReference; + +public class ResourceReference extends URLReference { + + private final Resource resource; + private final ClientConnector connector; + private final String key; + + public ResourceReference(Resource resource, ClientConnector connector, + String key) { + this.resource = resource; + this.connector = connector; + this.key = key; + } + + public Resource getResource() { + return resource; + } + + @Override + public String getURL() { + if (resource instanceof ExternalResource) { + return ((ExternalResource) resource).getURL(); + } else if (resource instanceof DynamicConnectorResource) { + DynamicConnectorResource dcr = (DynamicConnectorResource) resource; + + String filename = dcr.getPath(); + StringBuilder builder = new StringBuilder(getConnectorResourceBase( + filename, dcr.getConnector())); + + Set<Entry<String, String>> entrySet = dcr.getParameters() + .entrySet(); + boolean first = true; + for (Entry<String, String> entry : entrySet) { + String key = entry.getKey(); + String value = entry.getValue(); + if (first) { + builder.append('?'); + first = false; + } else { + builder.append('&'); + } + // TODO URL encode!!! + builder.append(key).append('=').append(value); + } + return builder.toString(); + } else if (resource instanceof ConnectorResource) { + ConnectorResource connectorResource = (ConnectorResource) resource; + + GlobalResourceHandler globalResourceHandler = connector.getUI() + .getApplication().getGlobalResourceHandler(false); + if (globalResourceHandler != null) { + String uri = globalResourceHandler.getUri(connector, + connectorResource); + if (uri != null && !uri.isEmpty()) { + return uri; + } + } + + // app://APP/connector/[uiid]/[cid]/[key]/[filename] + String prefix = key; + String filename = connectorResource.getFilename(); + if (filename != null && !filename.isEmpty()) { + prefix += '/' + filename; + } + String uri = getConnectorResourceBase(prefix, connector); + return uri; + } else if (resource instanceof ThemeResource) { + final String uri = "theme://" + + ((ThemeResource) resource).getResourceId(); + return uri; + } else { + throw new RuntimeException(getClass().getSimpleName() + + " does not support resources of type: " + + resource.getClass().getName()); + } + + } + + private static String getConnectorResourceBase(String filename, + ClientConnector connector) { + String uri = ApplicationConstants.APP_PROTOCOL_PREFIX + + ApplicationConstants.APP_REQUEST_PATH + + ConnectorResource.CONNECTOR_REQUEST_PATH + + connector.getUI().getUIId() + '/' + + connector.getConnectorId() + '/' + encodeFileName(filename); + return uri; + } + + public static String encodeFileName(String filename) { + // #7738 At least Tomcat and JBoss refuses requests containing + // encoded slashes or backslashes in URLs. Application resource URLs + // should really be passed in another way than as part of the path + // in the future. + return urlEncode(filename).replace("%2F", "/").replace("%5C", "\\"); + } + + static String urlEncode(String filename) { + try { + return URLEncoder.encode(filename, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException( + "UTF-8 charset not available (\"this should never happen\")", + e); + } + } + + public static ResourceReference create(Resource resource, + ClientConnector connector, String key) { + if (resource == null) { + return null; + } else { + return new ResourceReference(resource, connector, key); + } + } + + public static Resource getResource(URLReference reference) { + if (reference == null) { + return null; + } + assert reference instanceof ResourceReference; + return ((ResourceReference) reference).getResource(); + } +} diff --git a/server/src/com/vaadin/terminal/gwt/server/RestrictedRenderResponse.java b/server/src/com/vaadin/server/RestrictedRenderResponse.java index 1e23a48388..6923a042d6 100644 --- a/server/src/com/vaadin/terminal/gwt/server/RestrictedRenderResponse.java +++ b/server/src/com/vaadin/server/RestrictedRenderResponse.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.IOException; import java.io.OutputStream; diff --git a/server/src/com/vaadin/terminal/gwt/server/RpcManager.java b/server/src/com/vaadin/server/RpcManager.java index 4d1e0fc152..bb1c116388 100644 --- a/server/src/com/vaadin/terminal/gwt/server/RpcManager.java +++ b/server/src/com/vaadin/server/RpcManager.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.Serializable; diff --git a/server/src/com/vaadin/terminal/gwt/server/RpcTarget.java b/server/src/com/vaadin/server/RpcTarget.java index 1a3cf28fcc..c491707995 100644 --- a/server/src/com/vaadin/terminal/gwt/server/RpcTarget.java +++ b/server/src/com/vaadin/server/RpcTarget.java @@ -14,12 +14,10 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.Serializable; -import com.vaadin.terminal.VariableOwner; - /** * Marker interface for server side classes that can receive RPC calls. * diff --git a/server/src/com/vaadin/terminal/Scrollable.java b/server/src/com/vaadin/server/Scrollable.java index 641b20ab34..ca89d598c5 100644 --- a/server/src/com/vaadin/terminal/Scrollable.java +++ b/server/src/com/vaadin/server/Scrollable.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; diff --git a/server/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java b/server/src/com/vaadin/server/ServerRpcManager.java index 9db6c20f00..92e4d24240 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java +++ b/server/src/com/vaadin/server/ServerRpcManager.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; diff --git a/server/src/com/vaadin/terminal/gwt/server/ServerRpcMethodInvocation.java b/server/src/com/vaadin/server/ServerRpcMethodInvocation.java index 060fb686d4..761db687bb 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ServerRpcMethodInvocation.java +++ b/server/src/com/vaadin/server/ServerRpcMethodInvocation.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.lang.reflect.Method; import java.util.Map; diff --git a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java b/server/src/com/vaadin/server/ServletPortletHelper.java index 1d35785a57..cce98ab925 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java +++ b/server/src/com/vaadin/server/ServletPortletHelper.java @@ -1,11 +1,9 @@ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.Serializable; import com.vaadin.Application; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.UI; /* diff --git a/server/src/com/vaadin/terminal/gwt/server/SessionExpiredException.java b/server/src/com/vaadin/server/SessionExpiredException.java index 05e85c1f72..1e93fbf4ee 100644 --- a/server/src/com/vaadin/terminal/gwt/server/SessionExpiredException.java +++ b/server/src/com/vaadin/server/SessionExpiredException.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; @SuppressWarnings("serial") public class SessionExpiredException extends Exception { diff --git a/server/src/com/vaadin/terminal/Sizeable.java b/server/src/com/vaadin/server/Sizeable.java index d8d0b0e043..36562a059d 100644 --- a/server/src/com/vaadin/terminal/Sizeable.java +++ b/server/src/com/vaadin/server/Sizeable.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; diff --git a/server/src/com/vaadin/terminal/StreamResource.java b/server/src/com/vaadin/server/StreamResource.java index bbb58c71e2..26514c9353 100644 --- a/server/src/com/vaadin/terminal/StreamResource.java +++ b/server/src/com/vaadin/server/StreamResource.java @@ -14,12 +14,11 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.InputStream; import java.io.Serializable; -import com.vaadin.Application; import com.vaadin.service.FileTypeResolver; /** @@ -32,7 +31,7 @@ import com.vaadin.service.FileTypeResolver; * @since 3.0 */ @SuppressWarnings("serial") -public class StreamResource implements ApplicationResource { +public class StreamResource implements ConnectorResource { /** * Source stream the downloaded content is fetched from. @@ -50,11 +49,6 @@ public class StreamResource implements ApplicationResource { private String filename; /** - * Application. - */ - private final Application application; - - /** * Default buffer size for this stream resource. */ private int bufferSize = 0; @@ -62,7 +56,7 @@ public class StreamResource implements ApplicationResource { /** * Default cache time for this stream resource. */ - private long cacheTime = DEFAULT_CACHETIME; + private long cacheTime = DownloadStream.DEFAULT_CACHETIME; /** * Creates a new stream resource for downloading from stream. @@ -74,20 +68,13 @@ public class StreamResource implements ApplicationResource { * @param application * the Application object. */ - public StreamResource(StreamSource streamSource, String filename, - Application application) { - - this.application = application; + public StreamResource(StreamSource streamSource, String filename) { setFilename(filename); setStreamSource(streamSource); - - // Register to application - application.addResource(this); - } /** - * @see com.vaadin.terminal.Resource#getMIMEType() + * @see com.vaadin.server.Resource#getMIMEType() */ @Override public String getMIMEType() { @@ -149,17 +136,6 @@ public class StreamResource implements ApplicationResource { this.filename = filename; } - /** - * @see com.vaadin.terminal.ApplicationResource#getApplication() - */ - @Override - public Application getApplication() { - return application; - } - - /** - * @see com.vaadin.terminal.ApplicationResource#getStream() - */ @Override public DownloadStream getStream() { final StreamSource ss = getStreamSource(); @@ -187,8 +163,16 @@ public class StreamResource implements ApplicationResource { public InputStream getStream(); } - /* documented in superclass */ - @Override + /** + * Gets the size of the download buffer used for this resource. + * + * <p> + * If the buffer size is 0, the buffer size is decided by the terminal + * adapter. The default value is 0. + * </p> + * + * @return the size of the buffer in bytes. + */ public int getBufferSize() { return bufferSize; } @@ -203,8 +187,14 @@ public class StreamResource implements ApplicationResource { this.bufferSize = bufferSize; } - /* documented in superclass */ - @Override + /** + * Gets the length of cache expiration time. This gives the adapter the + * possibility cache streams sent to the client. The caching may be made in + * adapter or at the client if the client supports caching. Default is + * <code>DownloadStream.DEFAULT_CACHETIME</code>. + * + * @return Cache time in milliseconds. + */ public long getCacheTime() { return cacheTime; } @@ -227,4 +217,29 @@ public class StreamResource implements ApplicationResource { this.cacheTime = cacheTime; } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (obj instanceof StreamResource) { + StreamResource that = (StreamResource) obj; + return getStreamSource().equals(that.getStreamSource()) + && getMIMEType().equals(that.getMIMEType()) + && String.valueOf(getFilename()).equals( + String.valueOf(that.getFilename())) + && getBufferSize() == that.getBufferSize() + && getCacheTime() == that.getCacheTime(); + } else { + return false; + } + } + + @Override + public int hashCode() { + return (int) (getStreamSource().hashCode() + 37 + * getMIMEType().hashCode() + 37 ^ 2 + * String.valueOf(getFilename()).hashCode() + 37 ^ 3 + * getBufferSize() + 37 ^ 4 * getCacheTime()); + } + } diff --git a/server/src/com/vaadin/terminal/StreamVariable.java b/server/src/com/vaadin/server/StreamVariable.java index 53f398f09c..f289e7612a 100644 --- a/server/src/com/vaadin/terminal/StreamVariable.java +++ b/server/src/com/vaadin/server/StreamVariable.java @@ -13,15 +13,15 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.OutputStream; import java.io.Serializable; import com.vaadin.Application; -import com.vaadin.terminal.StreamVariable.StreamingEndEvent; -import com.vaadin.terminal.StreamVariable.StreamingErrorEvent; -import com.vaadin.terminal.StreamVariable.StreamingStartEvent; +import com.vaadin.server.StreamVariable.StreamingEndEvent; +import com.vaadin.server.StreamVariable.StreamingErrorEvent; +import com.vaadin.server.StreamVariable.StreamingStartEvent; /** * StreamVariable is a special kind of variable whose value is streamed to an @@ -152,7 +152,7 @@ public interface StreamVariable extends Serializable { * the streaming ended before the end of the input. The streaming may fail * due an interruption by {@link } or due an other unknown exception in * communication. In the latter case the exception is also passed to - * {@link Application#terminalError(com.vaadin.terminal.Terminal.ErrorEvent)} + * {@link Application#terminalError(com.vaadin.server.Terminal.ErrorEvent)} * . */ public interface StreamingErrorEvent extends StreamingEvent { diff --git a/server/src/com/vaadin/terminal/gwt/server/StreamingEndEventImpl.java b/server/src/com/vaadin/server/StreamingEndEventImpl.java index 6bc9f8fbd9..0b97989230 100644 --- a/server/src/com/vaadin/terminal/gwt/server/StreamingEndEventImpl.java +++ b/server/src/com/vaadin/server/StreamingEndEventImpl.java @@ -13,9 +13,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; -import com.vaadin.terminal.StreamVariable.StreamingEndEvent; +import com.vaadin.server.StreamVariable.StreamingEndEvent; @SuppressWarnings("serial") final class StreamingEndEventImpl extends AbstractStreamingEvent implements diff --git a/server/src/com/vaadin/terminal/gwt/server/StreamingErrorEventImpl.java b/server/src/com/vaadin/server/StreamingErrorEventImpl.java index cf9339d676..b892f5d386 100644 --- a/server/src/com/vaadin/terminal/gwt/server/StreamingErrorEventImpl.java +++ b/server/src/com/vaadin/server/StreamingErrorEventImpl.java @@ -13,9 +13,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; -import com.vaadin.terminal.StreamVariable.StreamingErrorEvent; +import com.vaadin.server.StreamVariable.StreamingErrorEvent; @SuppressWarnings("serial") final class StreamingErrorEventImpl extends AbstractStreamingEvent implements diff --git a/server/src/com/vaadin/terminal/gwt/server/StreamingProgressEventImpl.java b/server/src/com/vaadin/server/StreamingProgressEventImpl.java index bcb114db60..ae665a24e8 100644 --- a/server/src/com/vaadin/terminal/gwt/server/StreamingProgressEventImpl.java +++ b/server/src/com/vaadin/server/StreamingProgressEventImpl.java @@ -13,9 +13,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; -import com.vaadin.terminal.StreamVariable.StreamingProgressEvent; +import com.vaadin.server.StreamVariable.StreamingProgressEvent; @SuppressWarnings("serial") final class StreamingProgressEventImpl extends AbstractStreamingEvent implements diff --git a/server/src/com/vaadin/terminal/gwt/server/StreamingStartEventImpl.java b/server/src/com/vaadin/server/StreamingStartEventImpl.java index 07ff6cf7b1..5c9b215877 100644 --- a/server/src/com/vaadin/terminal/gwt/server/StreamingStartEventImpl.java +++ b/server/src/com/vaadin/server/StreamingStartEventImpl.java @@ -13,9 +13,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; -import com.vaadin.terminal.StreamVariable.StreamingStartEvent; +import com.vaadin.server.StreamVariable.StreamingStartEvent; @SuppressWarnings("serial") final class StreamingStartEventImpl extends AbstractStreamingEvent implements diff --git a/server/src/com/vaadin/terminal/SystemError.java b/server/src/com/vaadin/server/SystemError.java index c4cb7eef0c..5d1426e87c 100644 --- a/server/src/com/vaadin/terminal/SystemError.java +++ b/server/src/com/vaadin/server/SystemError.java @@ -14,9 +14,7 @@ * the License. */ -package com.vaadin.terminal; - -import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; +package com.vaadin.server; /** * <code>SystemError</code> is an error message for a problem caused by error in diff --git a/server/src/com/vaadin/terminal/gwt/server/SystemMessageException.java b/server/src/com/vaadin/server/SystemMessageException.java index 5575bcb618..9c37d61424 100644 --- a/server/src/com/vaadin/terminal/gwt/server/SystemMessageException.java +++ b/server/src/com/vaadin/server/SystemMessageException.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; @SuppressWarnings("serial") public class SystemMessageException extends RuntimeException { diff --git a/server/src/com/vaadin/terminal/Terminal.java b/server/src/com/vaadin/server/Terminal.java index a02bcb50bb..265668aa42 100644 --- a/server/src/com/vaadin/terminal/Terminal.java +++ b/server/src/com/vaadin/server/Terminal.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; diff --git a/server/src/com/vaadin/terminal/ThemeResource.java b/server/src/com/vaadin/server/ThemeResource.java index 61fe157ee6..7ae0bab828 100644 --- a/server/src/com/vaadin/terminal/ThemeResource.java +++ b/server/src/com/vaadin/server/ThemeResource.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import com.vaadin.service.FileTypeResolver; @@ -97,7 +97,7 @@ public class ThemeResource implements Resource { } /** - * @see com.vaadin.terminal.Resource#getMIMEType() + * @see com.vaadin.server.Resource#getMIMEType() */ @Override public String getMIMEType() { diff --git a/server/src/com/vaadin/terminal/UIProvider.java b/server/src/com/vaadin/server/UIProvider.java index 27b63fbcac..f262a3e225 100644 --- a/server/src/com/vaadin/terminal/UIProvider.java +++ b/server/src/com/vaadin/server/UIProvider.java @@ -14,7 +14,7 @@ * the License.
*/
-package com.vaadin.terminal;
+package com.vaadin.server;
import com.vaadin.Application;
import com.vaadin.UIRequiresMoreInformationException;
@@ -24,6 +24,6 @@ public interface UIProvider { public Class<? extends UI> getUIClass(Application application,
WrappedRequest request) throws UIRequiresMoreInformationException;
- public UI instantiateUI(Application application,
- Class<? extends UI> type, WrappedRequest request);
+ public UI instantiateUI(Application application, Class<? extends UI> type,
+ WrappedRequest request);
}
diff --git a/server/src/com/vaadin/terminal/gwt/server/UnsupportedBrowserHandler.java b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java index 22e46cb722..325edb5d61 100644 --- a/server/src/com/vaadin/terminal/gwt/server/UnsupportedBrowserHandler.java +++ b/server/src/com/vaadin/server/UnsupportedBrowserHandler.java @@ -13,15 +13,12 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.IOException; import java.io.Writer; import com.vaadin.Application; -import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; /** * A {@link RequestHandler} that presents an informative page if the browser in diff --git a/server/src/com/vaadin/terminal/gwt/server/UploadException.java b/server/src/com/vaadin/server/UploadException.java index 566c98bf2b..cc3b075a8b 100644 --- a/server/src/com/vaadin/terminal/gwt/server/UploadException.java +++ b/server/src/com/vaadin/server/UploadException.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; @SuppressWarnings("serial") public class UploadException extends Exception { diff --git a/server/src/com/vaadin/terminal/UserError.java b/server/src/com/vaadin/server/UserError.java index 18680f912f..756f2e70e0 100644 --- a/server/src/com/vaadin/terminal/UserError.java +++ b/server/src/com/vaadin/server/UserError.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; /** * <code>UserError</code> is a controlled error occurred in application. User diff --git a/server/src/com/vaadin/terminal/VariableOwner.java b/server/src/com/vaadin/server/VariableOwner.java index faa0298311..c917996e6b 100644 --- a/server/src/com/vaadin/terminal/VariableOwner.java +++ b/server/src/com/vaadin/server/VariableOwner.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.Serializable; import java.util.Map; @@ -31,7 +31,7 @@ import java.util.Map; * @author Vaadin Ltd. * @since 3.0 * @deprecated in 7.0. Only provided to ease porting of Vaadin 6 components. Do - * not implement this directly, implement {@link Vaadin6Component}. + * not implement this directly, implement {@link LegacyComponent}. */ @Deprecated public interface VariableOwner extends Serializable { diff --git a/server/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java b/server/src/com/vaadin/server/WebApplicationContext.java index bfcc0c1038..7059a04682 100644 --- a/server/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java +++ b/server/src/com/vaadin/server/WebApplicationContext.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.File; import java.util.Enumeration; diff --git a/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java b/server/src/com/vaadin/server/WebBrowser.java index 37bc81cfcf..92090da14a 100644 --- a/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java +++ b/server/src/com/vaadin/server/WebBrowser.java @@ -14,13 +14,12 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.util.Date; import java.util.Locale; import com.vaadin.shared.VBrowserDetails; -import com.vaadin.terminal.WrappedRequest; /** * Class that provides information about the web browser the user is using. diff --git a/server/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java b/server/src/com/vaadin/server/WrappedHttpServletRequest.java index a64be4c163..cb8a9e8c5f 100644 --- a/server/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java +++ b/server/src/com/vaadin/server/WrappedHttpServletRequest.java @@ -14,15 +14,12 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import com.vaadin.Application; -import com.vaadin.terminal.CombinedRequest; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.WrappedRequest; /** * Wrapper for {@link HttpServletRequest}. diff --git a/server/src/com/vaadin/terminal/gwt/server/WrappedHttpServletResponse.java b/server/src/com/vaadin/server/WrappedHttpServletResponse.java index 237bb643ee..f2916ac0eb 100644 --- a/server/src/com/vaadin/terminal/gwt/server/WrappedHttpServletResponse.java +++ b/server/src/com/vaadin/server/WrappedHttpServletResponse.java @@ -14,14 +14,11 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.WrappedResponse; - /** * Wrapper for {@link HttpServletResponse}. * diff --git a/server/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java b/server/src/com/vaadin/server/WrappedPortletRequest.java index 9ac2e5a608..40a5c5f509 100644 --- a/server/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java +++ b/server/src/com/vaadin/server/WrappedPortletRequest.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.IOException; import java.io.InputStream; @@ -27,9 +27,6 @@ import javax.portlet.ResourceRequest; import com.vaadin.Application; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.terminal.CombinedRequest; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.WrappedRequest; /** * Wrapper for {@link PortletRequest} and its subclasses. diff --git a/server/src/com/vaadin/terminal/gwt/server/WrappedPortletResponse.java b/server/src/com/vaadin/server/WrappedPortletResponse.java index 39ccacd331..f84e3619d2 100644 --- a/server/src/com/vaadin/terminal/gwt/server/WrappedPortletResponse.java +++ b/server/src/com/vaadin/server/WrappedPortletResponse.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.server; import java.io.IOException; import java.io.OutputStream; @@ -29,9 +29,6 @@ import javax.portlet.MimeResponse; import javax.portlet.PortletResponse; import javax.portlet.ResourceResponse; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.WrappedResponse; - /** * Wrapper for {@link PortletResponse} and its subclasses. * diff --git a/server/src/com/vaadin/terminal/WrappedRequest.java b/server/src/com/vaadin/server/WrappedRequest.java index 343a60848e..8ae5335763 100644 --- a/server/src/com/vaadin/terminal/WrappedRequest.java +++ b/server/src/com/vaadin/server/WrappedRequest.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.IOException; import java.io.InputStream; @@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletRequest; import com.vaadin.Application; import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.annotations.EagerInit; -import com.vaadin.terminal.gwt.server.WebBrowser; import com.vaadin.ui.UI; /** diff --git a/server/src/com/vaadin/terminal/WrappedResponse.java b/server/src/com/vaadin/server/WrappedResponse.java index 02daaa1bdd..c8d9342418 100644 --- a/server/src/com/vaadin/terminal/WrappedResponse.java +++ b/server/src/com/vaadin/server/WrappedResponse.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.terminal; +package com.vaadin.server; import java.io.IOException; import java.io.OutputStream; diff --git a/server/src/com/vaadin/terminal/package.html b/server/src/com/vaadin/server/package.html index 83514a0de5..83514a0de5 100644 --- a/server/src/com/vaadin/terminal/package.html +++ b/server/src/com/vaadin/server/package.html diff --git a/server/src/com/vaadin/service/ApplicationContext.java b/server/src/com/vaadin/service/ApplicationContext.java index 55495dcd5c..591704764f 100644 --- a/server/src/com/vaadin/service/ApplicationContext.java +++ b/server/src/com/vaadin/service/ApplicationContext.java @@ -18,12 +18,9 @@ package com.vaadin.service; import java.io.File; import java.io.Serializable; -import java.net.URL; import java.util.Collection; import com.vaadin.Application; -import com.vaadin.terminal.ApplicationResource; -import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; /** * <code>ApplicationContext</code> provides information about the running @@ -86,59 +83,6 @@ public interface ApplicationContext extends Serializable { public int getMaxInactiveInterval(); /** - * Generate a URL that can be used as the relative location of e.g. an - * {@link ApplicationResource}. - * - * This method should only be called from the processing of a UIDL request, - * not from a background thread. The return value is null if used outside a - * suitable request. - * - * @deprecated this method is intended for terminal implementation only and - * is subject to change/removal from the interface (to - * {@link AbstractCommunicationManager}) - * - * @param resource - * @param urlKey - * a key for the resource that can later be extracted from a URL - * with {@link #getURLKey(URL, String)} - */ - @Deprecated - public String generateApplicationResourceURL(ApplicationResource resource, - String urlKey); - - /** - * Tests if a URL is for an application resource (APP/...). - * - * @deprecated this method is intended for terminal implementation only and - * is subject to change/removal from the interface (to - * {@link AbstractCommunicationManager}) - * - * @param context - * @param relativeUri - * @return - */ - @Deprecated - public boolean isApplicationResourceURL(URL context, String relativeUri); - - /** - * Gets the identifier (key) from an application resource URL. This key is - * the one that was given to - * {@link #generateApplicationResourceURL(ApplicationResource, String)} when - * creating the URL. - * - * @deprecated this method is intended for terminal implementation only and - * is subject to change/removal from the interface (to - * {@link AbstractCommunicationManager}) - * - * - * @param context - * @param relativeUri - * @return - */ - @Deprecated - public String getURLKey(URL context, String relativeUri); - - /** * Interface for listening to transaction events. Implement this interface * to listen to all transactions between the client and the application. * diff --git a/server/src/com/vaadin/service/FileTypeResolver.java b/server/src/com/vaadin/service/FileTypeResolver.java index 2b289d6752..4b1c8697eb 100644 --- a/server/src/com/vaadin/service/FileTypeResolver.java +++ b/server/src/com/vaadin/service/FileTypeResolver.java @@ -23,8 +23,8 @@ import java.util.Hashtable; import java.util.Map; import java.util.StringTokenizer; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.ThemeResource; +import com.vaadin.server.Resource; +import com.vaadin.server.ThemeResource; /** * Utility class that can figure out mime-types and icons related to files. diff --git a/server/src/com/vaadin/terminal/ApplicationResource.java b/server/src/com/vaadin/terminal/ApplicationResource.java deleted file mode 100644 index 1d1444b774..0000000000 --- a/server/src/com/vaadin/terminal/ApplicationResource.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.terminal; - -import java.io.Serializable; - -import com.vaadin.Application; - -/** - * This interface must be implemented by classes wishing to provide Application - * resources. - * <p> - * <code>ApplicationResource</code> are a set of named resources (pictures, - * sounds, etc) associated with some specific application. Having named - * application resources provides a convenient method for having inter-theme - * common resources for an application. - * </p> - * - * @author Vaadin Ltd. - * @since 3.0 - */ -public interface ApplicationResource extends Resource, Serializable { - - /** - * Default cache time. - */ - public static final long DEFAULT_CACHETIME = 1000 * 60 * 60 * 24; - - /** - * Gets resource as stream. - */ - public DownloadStream getStream(); - - /** - * Gets the application of the resource. - */ - public Application getApplication(); - - /** - * Gets the virtual filename for this resource. - * - * @return the file name associated to this resource. - */ - public String getFilename(); - - /** - * Gets the length of cache expiration time. - * - * <p> - * This gives the adapter the possibility cache streams sent to the client. - * The caching may be made in adapter or at the client if the client - * supports caching. Default is <code>DEFAULT_CACHETIME</code>. - * </p> - * - * @return Cache time in milliseconds - */ - public long getCacheTime(); - - /** - * Gets the size of the download buffer used for this resource. - * - * <p> - * If the buffer size is 0, the buffer size is decided by the terminal - * adapter. The default value is 0. - * </p> - * - * @return int the size of the buffer in bytes. - */ - public int getBufferSize(); - -} diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationResourceHandler.java b/server/src/com/vaadin/terminal/gwt/server/ApplicationResourceHandler.java deleted file mode 100644 index d5c0d604c3..0000000000 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationResourceHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.terminal.gwt.server; - -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.servlet.http.HttpServletResponse; - -import com.vaadin.Application; -import com.vaadin.terminal.ApplicationResource; -import com.vaadin.terminal.DownloadStream; -import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; - -public class ApplicationResourceHandler implements RequestHandler { - private static final Pattern APP_RESOURCE_PATTERN = Pattern - .compile("^/?APP/(\\d+)/.*"); - - @Override - public boolean handleRequest(Application application, - WrappedRequest request, WrappedResponse response) - throws IOException { - // Check for application resources - String requestPath = request.getRequestPathInfo(); - if (requestPath == null) { - return false; - } - Matcher resourceMatcher = APP_RESOURCE_PATTERN.matcher(requestPath); - - if (resourceMatcher.matches()) { - ApplicationResource resource = application - .getResource(resourceMatcher.group(1)); - if (resource != null) { - DownloadStream stream = resource.getStream(); - if (stream != null) { - stream.setCacheTime(resource.getCacheTime()); - stream.writeTo(response); - return true; - } - } - // We get here if the url looks like an application resource but no - // resource can be served - response.sendError(HttpServletResponse.SC_NOT_FOUND, - request.getRequestPathInfo() + " can not be found"); - return true; - } - - return false; - } -} diff --git a/server/src/com/vaadin/terminal/gwt/server/ResourceReference.java b/server/src/com/vaadin/terminal/gwt/server/ResourceReference.java deleted file mode 100644 index a1d5731f7d..0000000000 --- a/server/src/com/vaadin/terminal/gwt/server/ResourceReference.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.terminal.gwt.server; - -import com.vaadin.Application; -import com.vaadin.shared.communication.URLReference; -import com.vaadin.terminal.ApplicationResource; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.ThemeResource; - -public class ResourceReference extends URLReference { - - private Resource resource; - - public ResourceReference(Resource resource) { - this.resource = resource; - } - - public Resource getResource() { - return resource; - } - - @Override - public String getURL() { - if (resource instanceof ExternalResource) { - return ((ExternalResource) resource).getURL(); - } else if (resource instanceof ApplicationResource) { - final ApplicationResource r = (ApplicationResource) resource; - final Application a = r.getApplication(); - if (a == null) { - throw new RuntimeException( - "An ApplicationResource (" - + r.getClass().getName() - + " must be attached to an application when it is sent to the client."); - } - final String uri = a.getRelativeLocation(r); - return uri; - } else if (resource instanceof ThemeResource) { - final String uri = "theme://" - + ((ThemeResource) resource).getResourceId(); - return uri; - } else { - throw new RuntimeException(getClass().getSimpleName() - + " does not support resources of type: " - + resource.getClass().getName()); - } - - } - - public static ResourceReference create(Resource resource) { - if (resource == null) { - return null; - } else { - return new ResourceReference(resource); - } - } - - public static Resource getResource(URLReference reference) { - if (reference == null) { - return null; - } - assert reference instanceof ResourceReference; - return ((ResourceReference) reference).getResource(); - } -} diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java index 56bbd19852..794de49671 100644 --- a/server/src/com/vaadin/ui/AbsoluteLayout.java +++ b/server/src/com/vaadin/ui/AbsoluteLayout.java @@ -24,12 +24,12 @@ import java.util.Map; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickNotifier; +import com.vaadin.server.Sizeable; import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.absolutelayout.AbsoluteLayoutServerRpc; import com.vaadin.shared.ui.absolutelayout.AbsoluteLayoutState; -import com.vaadin.terminal.Sizeable; /** * AbsoluteLayout is a layout implementation that mimics html absolute @@ -629,16 +629,33 @@ public class AbsoluteLayout extends AbstractLayout implements } @Override - public void addListener(LayoutClickListener listener) { + public void addLayoutClickListener(LayoutClickListener listener) { addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addLayoutClickListener(LayoutClickListener)} + **/ + @Deprecated + public void addListener(LayoutClickListener listener) { + addLayoutClickListener(listener); + } + @Override - public void removeListener(LayoutClickListener listener) { + public void removeLayoutClickListener(LayoutClickListener listener) { removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeLayoutClickListener(LayoutClickListener)} + **/ + @Deprecated + public void removeListener(LayoutClickListener listener) { + removeLayoutClickListener(listener); + } } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 917b1a516d..045173036e 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -32,14 +32,14 @@ import com.vaadin.event.ActionManager; import com.vaadin.event.EventRouter; import com.vaadin.event.MethodEventSource; import com.vaadin.event.ShortcutListener; +import com.vaadin.server.AbstractClientConnector; +import com.vaadin.server.ClientConnector; +import com.vaadin.server.ComponentSizeValidator; +import com.vaadin.server.ErrorMessage; +import com.vaadin.server.Resource; +import com.vaadin.server.Terminal; +import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ComponentState; -import com.vaadin.terminal.AbstractClientConnector; -import com.vaadin.terminal.ErrorMessage; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Terminal; -import com.vaadin.terminal.gwt.server.ClientConnector; -import com.vaadin.terminal.gwt.server.ComponentSizeValidator; -import com.vaadin.terminal.gwt.server.ResourceReference; import com.vaadin.tools.ReflectTools; /** @@ -297,7 +297,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public Resource getIcon() { - return ResourceReference.getResource(getState().getIcon()); + return getResource(ComponentConstants.ICON_RESOURCE); } /** @@ -309,7 +309,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setIcon(Resource icon) { - getState().setIcon(ResourceReference.create(icon)); + setResource(ComponentConstants.ICON_RESOURCE, icon); } /* @@ -335,7 +335,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.gwt.client.Connector#isConnectorEnabled() + * @see com.vaadin.client.Connector#isConnectorEnabled() */ @Override public boolean isConnectorEnabled() { @@ -1072,7 +1072,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#getHeight() + * @see com.vaadin.Sizeable#getHeight() */ @Override public float getHeight() { @@ -1082,7 +1082,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#getHeightUnits() + * @see com.vaadin.server.Sizeable#getHeightUnits() */ @Override public Unit getHeightUnits() { @@ -1092,7 +1092,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#getWidth() + * @see com.vaadin.server.Sizeable#getWidth() */ @Override public float getWidth() { @@ -1102,7 +1102,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#getWidthUnits() + * @see com.vaadin.server.Sizeable#getWidthUnits() */ @Override public Unit getWidthUnits() { @@ -1112,7 +1112,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#setHeight(float, Unit) + * @see com.vaadin.server.Sizeable#setHeight(float, Unit) */ @Override public void setHeight(float height, Unit unit) { @@ -1128,7 +1128,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#setSizeFull() + * @see com.vaadin.server.Sizeable#setSizeFull() */ @Override public void setSizeFull() { @@ -1139,7 +1139,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#setSizeUndefined() + * @see com.vaadin.server.Sizeable#setSizeUndefined() */ @Override public void setSizeUndefined() { @@ -1150,7 +1150,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#setWidth(float, Unit) + * @see com.vaadin.server.Sizeable#setWidth(float, Unit) */ @Override public void setWidth(float width, Unit unit) { @@ -1166,7 +1166,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#setWidth(java.lang.String) + * @see com.vaadin.server.Sizeable#setWidth(java.lang.String) */ @Override public void setWidth(String width) { @@ -1181,7 +1181,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /* * (non-Javadoc) * - * @see com.vaadin.terminal.Sizeable#setHeight(java.lang.String) + * @see com.vaadin.server.Sizeable#setHeight(java.lang.String) */ @Override public void setHeight(String height) { diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java index 4939eb1265..cf3bf1d2b9 100644 --- a/server/src/com/vaadin/ui/AbstractComponentContainer.java +++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java @@ -22,7 +22,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; -import com.vaadin.terminal.gwt.server.ComponentSizeValidator; +import com.vaadin.server.ComponentSizeValidator; /** * Extension to {@link AbstractComponent} that defines the default @@ -106,33 +106,69 @@ public abstract class AbstractComponentContainer extends AbstractComponent /* documented in interface */ @Override - public void addListener(ComponentAttachListener listener) { + public void addComponentAttachListener(ComponentAttachListener listener) { addListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)} + **/ + @Deprecated + public void addListener(ComponentAttachListener listener) { + addComponentAttachListener(listener); + } + /* documented in interface */ @Override - public void addListener(ComponentDetachListener listener) { + public void addComponentDetachListener(ComponentDetachListener listener) { addListener(ComponentContainer.ComponentDetachEvent.class, listener, COMPONENT_DETACHED_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)} + **/ + @Deprecated + public void addListener(ComponentDetachListener listener) { + addComponentDetachListener(listener); + } + /* documented in interface */ @Override - public void removeListener(ComponentAttachListener listener) { + public void removeComponentAttachListener(ComponentAttachListener listener) { removeListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)} + **/ + @Deprecated + public void removeListener(ComponentAttachListener listener) { + removeComponentAttachListener(listener); + } + /* documented in interface */ @Override - public void removeListener(ComponentDetachListener listener) { + public void removeComponentDetachListener(ComponentDetachListener listener) { removeListener(ComponentContainer.ComponentDetachEvent.class, listener, COMPONENT_DETACHED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)} + **/ + @Deprecated + public void removeListener(ComponentDetachListener listener) { + removeComponentDetachListener(listener); + } + + /** * Fires the component attached event. This should be called by the * addComponent methods after the component have been added to this * container. diff --git a/server/src/com/vaadin/ui/AbstractEmbedded.java b/server/src/com/vaadin/ui/AbstractEmbedded.java index 9396af5c44..d94f62120f 100644 --- a/server/src/com/vaadin/ui/AbstractEmbedded.java +++ b/server/src/com/vaadin/ui/AbstractEmbedded.java @@ -4,9 +4,8 @@ package com.vaadin.ui; +import com.vaadin.server.Resource; import com.vaadin.shared.ui.AbstractEmbeddedState; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.gwt.server.ResourceReference; /** * Abstract base for embedding components. @@ -32,12 +31,7 @@ public abstract class AbstractEmbedded extends AbstractComponent { * the source to set. */ public void setSource(Resource source) { - if (source == null) { - getState().setSource(null); - } else { - getState().setSource(new ResourceReference(source)); - } - requestRepaint(); + setResource(AbstractEmbeddedState.SOURCE_RESOURCE, source); } /** @@ -46,12 +40,7 @@ public abstract class AbstractEmbedded extends AbstractComponent { * @return the source */ public Resource getSource() { - ResourceReference ref = ((ResourceReference) getState().getSource()); - if (ref == null) { - return null; - } else { - return ref.getResource(); - } + return getResource(AbstractEmbeddedState.SOURCE_RESOURCE); } /** diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 5123d08da9..b1d45ae590 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -37,10 +37,10 @@ import com.vaadin.data.util.converter.ConverterUtil; import com.vaadin.event.Action; import com.vaadin.event.ShortcutAction; import com.vaadin.event.ShortcutListener; +import com.vaadin.server.AbstractErrorMessage; +import com.vaadin.server.CompositeErrorMessage; +import com.vaadin.server.ErrorMessage; import com.vaadin.shared.AbstractFieldState; -import com.vaadin.terminal.AbstractErrorMessage; -import com.vaadin.terminal.CompositeErrorMessage; -import com.vaadin.terminal.ErrorMessage; /** * <p> @@ -1047,23 +1047,41 @@ public abstract class AbstractField<T> extends AbstractComponent implements * here, we use the default documentation from the implemented interface. */ @Override - public void addListener(Property.ValueChangeListener listener) { + public void addValueChangeListener(Property.ValueChangeListener listener) { addListener(AbstractField.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void addListener(Property.ValueChangeListener listener) { + addValueChangeListener(listener); + } + /* * Removes a value change listener from the field. Don't add a JavaDoc * comment here, we use the default documentation from the implemented * interface. */ @Override - public void removeListener(Property.ValueChangeListener listener) { + public void removeValueChangeListener(Property.ValueChangeListener listener) { removeListener(AbstractField.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void removeListener(Property.ValueChangeListener listener) { + removeValueChangeListener(listener); + } + + /** * Emits the value change event. The value contained in the field is * validated before the event is created. */ @@ -1139,23 +1157,43 @@ public abstract class AbstractField<T> extends AbstractComponent implements * implemented interface. */ @Override - public void addListener(Property.ReadOnlyStatusChangeListener listener) { + public void addReadOnlyStatusChangeListener( + Property.ReadOnlyStatusChangeListener listener) { addListener(Property.ReadOnlyStatusChangeEvent.class, listener, READ_ONLY_STATUS_CHANGE_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addReadOnlyStatusChangeListener(com.vaadin.data.Property.ReadOnlyStatusChangeListener)} + **/ + @Deprecated + public void addListener(Property.ReadOnlyStatusChangeListener listener) { + addReadOnlyStatusChangeListener(listener); + } + /* * Removes a read-only status change listener from the field. Don't add a * JavaDoc comment here, we use the default documentation from the * implemented interface. */ @Override - public void removeListener(Property.ReadOnlyStatusChangeListener listener) { + public void removeReadOnlyStatusChangeListener( + Property.ReadOnlyStatusChangeListener listener) { removeListener(Property.ReadOnlyStatusChangeEvent.class, listener, READ_ONLY_STATUS_CHANGE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeReadOnlyStatusChangeListener(com.vaadin.data.Property.ReadOnlyStatusChangeListener)} + **/ + @Deprecated + public void removeListener(Property.ReadOnlyStatusChangeListener listener) { + removeReadOnlyStatusChangeListener(listener); + } + + /** * Emits the read-only status change event. The value contained in the field * is validated before the event is created. */ diff --git a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java index e19bdf1b2b..47420334d7 100644 --- a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java +++ b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java @@ -15,8 +15,8 @@ */ package com.vaadin.ui; +import com.vaadin.server.JavaScriptCallbackHelper; import com.vaadin.shared.ui.JavaScriptComponentState; -import com.vaadin.terminal.JavaScriptCallbackHelper; /** * Base class for Components with all client-side logic implemented using @@ -35,9 +35,9 @@ import com.vaadin.terminal.JavaScriptCallbackHelper; * <code>com_example_MyComponent</code> has not been defined. * <p> * JavaScript components have a very simple GWT widget ( - * {@link com.vaadin.terminal.gwt.client.ui.JavaScriptWidget} ) just consisting - * of a <code>div</code> element to which the JavaScript code should initialize - * its own user interface. + * {@link com.vaadin.client.ui.JavaScriptWidget} ) just consisting of a + * <code>div</code> element to which the JavaScript code should initialize its + * own user interface. * <p> * The initialization function will be called with <code>this</code> pointing to * a connector wrapper object providing integration to Vaadin with the following @@ -80,8 +80,7 @@ import com.vaadin.terminal.JavaScriptCallbackHelper; * functions is described bellow.</li> * <li><code>translateVaadinUri(uri)</code> - Translates a Vaadin URI to a URL * that can be used in the browser. This is just way of accessing - * {@link com.vaadin.terminal.gwt.client.ApplicationConnection#translateVaadinUri(String)} - * </li> + * {@link com.vaadin.client.ApplicationConnection#translateVaadinUri(String)}</li> * </ul> * The connector wrapper also supports these special functions: * <ul> diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 77c12ac045..3f59b070b7 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -16,14 +16,21 @@ package com.vaadin.ui; +import java.io.IOException; import java.util.ArrayList; import java.util.List; - +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.vaadin.server.ConnectorResource; +import com.vaadin.server.Resource; +import com.vaadin.server.ResourceReference; +import com.vaadin.server.WrappedRequest; +import com.vaadin.server.WrappedResponse; import com.vaadin.shared.communication.URLReference; import com.vaadin.shared.ui.AbstractMediaState; import com.vaadin.shared.ui.MediaControl; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.gwt.server.ResourceReference; /** * Abstract base class for the HTML5 media components. @@ -64,11 +71,43 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void addSource(Resource source) { if (source != null) { - getState().getSources().add(new ResourceReference(source)); + List<URLReference> sources = getState().getSources(); + sources.add(new ResourceReference(source, this, Integer + .toString(sources.size()))); getState().getSourceTypes().add(source.getMIMEType()); } } + @Override + public boolean handleConnectorRequest(WrappedRequest request, + WrappedResponse response, String path) throws IOException { + Matcher matcher = Pattern.compile("(\\d+)(/.*)?").matcher(path); + if (matcher.matches()) { + List<URLReference> sources = getState().getSources(); + + int sourceIndex = Integer.parseInt(matcher.group(1)); + + if (sourceIndex < 0 || sourceIndex >= sources.size()) { + getLogger().warning( + "Requested source index " + sourceIndex + + " is out of bounds"); + return false; + } + + URLReference reference = sources.get(sourceIndex); + ConnectorResource resource = (ConnectorResource) ResourceReference + .getResource(reference); + resource.getStream().writeResponse(request, response); + return true; + } else { + return super.handleConnectorRequest(request, response, path); + } + } + + private Logger getLogger() { + return Logger.getLogger(AbstractMedia.class.getName()); + } + /** * Set multiple sources at once. Which of the sources is used is selected by * the browser depending on which file formats it supports. See <a diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 596bbb7ee2..184f7c40f4 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -22,6 +22,7 @@ import java.util.LinkedList; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickNotifier; +import com.vaadin.server.Sizeable; import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; @@ -29,7 +30,6 @@ import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutServerRpc; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState.ChildComponentData; -import com.vaadin.terminal.Sizeable; @SuppressWarnings("serial") public abstract class AbstractOrderedLayout extends AbstractLayout implements @@ -339,19 +339,37 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } @Override - public void addListener(LayoutClickListener listener) { + public void addLayoutClickListener(LayoutClickListener listener) { addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addLayoutClickListener(LayoutClickListener)} + **/ + @Deprecated + public void addListener(LayoutClickListener listener) { + addLayoutClickListener(listener); + } + @Override - public void removeListener(LayoutClickListener listener) { + public void removeLayoutClickListener(LayoutClickListener listener) { removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeLayoutClickListener(LayoutClickListener)} + **/ + @Deprecated + public void removeListener(LayoutClickListener listener) { + removeLayoutClickListener(listener); + } + + /** * Returns the index of the given component. * * @param component diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 21ff7ba948..3dba5088df 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -39,12 +39,12 @@ import com.vaadin.event.dd.TargetDetailsImpl; import com.vaadin.event.dd.acceptcriteria.ClientSideCriterion; import com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor; import com.vaadin.event.dd.acceptcriteria.TargetDetailIs; +import com.vaadin.server.KeyMapper; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.dd.VerticalDropLocation; -import com.vaadin.terminal.KeyMapper; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Vaadin6Component; import com.vaadin.ui.AbstractSelect.ItemCaptionMode; /** @@ -68,7 +68,7 @@ import com.vaadin.ui.AbstractSelect.ItemCaptionMode; public abstract class AbstractSelect extends AbstractField<Object> implements Container, Container.Viewer, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.ItemSetChangeNotifier, - Container.ItemSetChangeListener, Vaadin6Component { + Container.ItemSetChangeListener, LegacyComponent { public enum ItemCaptionMode { /** @@ -1480,7 +1480,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @see com.vaadin.data.Container.PropertySetChangeNotifier#addListener(com.vaadin.data.Container.PropertySetChangeListener) */ @Override - public void addListener(Container.PropertySetChangeListener listener) { + public void addPropertySetChangeListener( + Container.PropertySetChangeListener listener) { if (propertySetEventListeners == null) { propertySetEventListeners = new LinkedHashSet<Container.PropertySetChangeListener>(); } @@ -1488,12 +1489,22 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } /** + * @deprecated Since 7.0, replaced by + * {@link #addPropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + public void addListener(Container.PropertySetChangeListener listener) { + addPropertySetChangeListener(listener); + } + + /** * Removes a previously registered Property set change listener. * * @see com.vaadin.data.Container.PropertySetChangeNotifier#removeListener(com.vaadin.data.Container.PropertySetChangeListener) */ @Override - public void removeListener(Container.PropertySetChangeListener listener) { + public void removePropertySetChangeListener( + Container.PropertySetChangeListener listener) { if (propertySetEventListeners != null) { propertySetEventListeners.remove(listener); if (propertySetEventListeners.isEmpty()) { @@ -1503,12 +1514,22 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } /** + * @deprecated Since 7.0, replaced by + * {@link #removePropertySetChangeListener(com.vaadin.data.Container.PropertySetChangeListener)} + **/ + @Deprecated + public void removeListener(Container.PropertySetChangeListener listener) { + removePropertySetChangeListener(listener); + } + + /** * Adds an Item set change listener for the object. * * @see com.vaadin.data.Container.ItemSetChangeNotifier#addListener(com.vaadin.data.Container.ItemSetChangeListener) */ @Override - public void addListener(Container.ItemSetChangeListener listener) { + public void addItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (itemSetEventListeners == null) { itemSetEventListeners = new LinkedHashSet<Container.ItemSetChangeListener>(); } @@ -1516,12 +1537,22 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } /** + * @deprecated Since 7.0, replaced by + * {@link #addItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + public void addListener(Container.ItemSetChangeListener listener) { + addItemSetChangeListener(listener); + } + + /** * Removes the Item set change listener from the object. * * @see com.vaadin.data.Container.ItemSetChangeNotifier#removeListener(com.vaadin.data.Container.ItemSetChangeListener) */ @Override - public void removeListener(Container.ItemSetChangeListener listener) { + public void removeItemSetChangeListener( + Container.ItemSetChangeListener listener) { if (itemSetEventListeners != null) { itemSetEventListeners.remove(listener); if (itemSetEventListeners.isEmpty()) { @@ -1530,6 +1561,15 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemSetChangeListener(com.vaadin.data.Container.ItemSetChangeListener)} + **/ + @Deprecated + public void removeListener(Container.ItemSetChangeListener listener) { + removeItemSetChangeListener(listener); + } + @Override public Collection<?> getListeners(Class<?> eventType) { if (Container.ItemSetChangeEvent.class.isAssignableFrom(eventType)) { diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index 8b7499115c..f1452caacf 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -22,12 +22,12 @@ import java.util.Iterator; import com.vaadin.event.ComponentEventListener; import com.vaadin.event.MouseEvents.ClickEvent; +import com.vaadin.server.Sizeable; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelRpc; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState.SplitterState; -import com.vaadin.terminal.Sizeable; import com.vaadin.tools.ReflectTools; /** @@ -501,16 +501,34 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } - public void addListener(SplitterClickListener listener) { + public void addSplitterClickListener(SplitterClickListener listener) { addListener(EventId.CLICK_EVENT_IDENTIFIER, SplitterClickEvent.class, listener, SplitterClickListener.clickMethod); } - public void removeListener(SplitterClickListener listener) { + /** + * @deprecated Since 7.0, replaced by + * {@link #addSplitterClickListener(SplitterClickListener)} + **/ + @Deprecated + public void addListener(SplitterClickListener listener) { + addSplitterClickListener(listener); + } + + public void removeSplitterClickListener(SplitterClickListener listener) { removeListener(EventId.CLICK_EVENT_IDENTIFIER, SplitterClickEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeSplitterClickListener(SplitterClickListener)} + **/ + @Deprecated + public void removeListener(SplitterClickListener listener) { + removeSplitterClickListener(listener); + } + @Override protected AbstractSplitPanelState getState() { return (AbstractSplitPanelState) super.getState(); diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 1bd61023a4..c187d9e198 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -27,14 +27,14 @@ import com.vaadin.event.FieldEvents.FocusNotifier; import com.vaadin.event.FieldEvents.TextChangeEvent; import com.vaadin.event.FieldEvents.TextChangeListener; import com.vaadin.event.FieldEvents.TextChangeNotifier; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.textfield.AbstractTextFieldState; import com.vaadin.shared.ui.textfield.TextFieldConstants; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; public abstract class AbstractTextField extends AbstractField<String> implements - BlurNotifier, FocusNotifier, TextChangeNotifier, Vaadin6Component { + BlurNotifier, FocusNotifier, TextChangeNotifier, LegacyComponent { /** * Null representation. @@ -512,18 +512,36 @@ public abstract class AbstractTextField extends AbstractField<String> implements } @Override - public void addListener(TextChangeListener listener) { + public void addTextChangeListener(TextChangeListener listener) { addListener(TextChangeListener.EVENT_ID, TextChangeEvent.class, listener, TextChangeListener.EVENT_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addTextChangeListener(TextChangeListener)} + **/ + @Deprecated + public void addListener(TextChangeListener listener) { + addTextChangeListener(listener); + } + @Override - public void removeListener(TextChangeListener listener) { + public void removeTextChangeListener(TextChangeListener listener) { removeListener(TextChangeListener.EVENT_ID, TextChangeEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeTextChangeListener(TextChangeListener)} + **/ + @Deprecated + public void removeListener(TextChangeListener listener) { + removeTextChangeListener(listener); + } + + /** * The text change timeout modifies how often text change events are * communicated to the application when {@link #getTextChangeEventMode()} is * {@link TextChangeEventMode#LAZY} or {@link TextChangeEventMode#TIMEOUT}. @@ -661,25 +679,60 @@ public abstract class AbstractTextField extends AbstractField<String> implements } @Override - public void addListener(FocusListener listener) { + public void addFocusListener(FocusListener listener) { addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated + public void addListener(FocusListener listener) { + addFocusListener(listener); + } + @Override - public void removeListener(FocusListener listener) { + public void removeFocusListener(FocusListener listener) { removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated + public void removeListener(FocusListener listener) { + removeFocusListener(listener); + } + @Override - public void addListener(BlurListener listener) { + public void addBlurListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } + /** + * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} + **/ + @Deprecated + public void addListener(BlurListener listener) { + addBlurListener(listener); + } + @Override - public void removeListener(BlurListener listener) { + public void removeBlurListener(BlurListener listener) { removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated + public void removeListener(BlurListener listener) { + removeBlurListener(listener); + } + } diff --git a/server/src/com/vaadin/ui/Audio.java b/server/src/com/vaadin/ui/Audio.java index 03ed7ba6d5..d111c0c74c 100644 --- a/server/src/com/vaadin/ui/Audio.java +++ b/server/src/com/vaadin/ui/Audio.java @@ -16,7 +16,7 @@ package com.vaadin.ui; -import com.vaadin.terminal.Resource; +import com.vaadin.server.Resource; /** * The Audio component translates into an HTML5 <audio> element and as diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index 68b9f1392f..2e026ebc52 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -290,23 +290,41 @@ public class Button extends AbstractComponent implements * @param listener * the Listener to be added. */ - public void addListener(ClickListener listener) { + public void addClickListener(ClickListener listener) { addListener(ClickEvent.class, listener, ClickListener.BUTTON_CLICK_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addClickListener(ClickListener)} + **/ + @Deprecated + public void addListener(ClickListener listener) { + addClickListener(listener); + } + + /** * Removes the button click listener. * * @param listener * the Listener to be removed. */ - public void removeListener(ClickListener listener) { + public void removeClickListener(ClickListener listener) { removeListener(ClickEvent.class, listener, ClickListener.BUTTON_CLICK_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeClickListener(ClickListener)} + **/ + @Deprecated + public void removeListener(ClickListener listener) { + removeClickListener(listener); + } + + /** * Simulates a button click, notifying all server-side listeners. * * No action is taken is the button is disabled. @@ -341,26 +359,60 @@ public class Button extends AbstractComponent implements } @Override - public void addListener(BlurListener listener) { + public void addBlurListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } + /** + * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} + **/ + @Deprecated + public void addListener(BlurListener listener) { + addBlurListener(listener); + } + @Override - public void removeListener(BlurListener listener) { + public void removeBlurListener(BlurListener listener) { removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated + public void removeListener(BlurListener listener) { + removeBlurListener(listener); + } + @Override - public void addListener(FocusListener listener) { + public void addFocusListener(FocusListener listener) { addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated + public void addListener(FocusListener listener) { + addFocusListener(listener); + } + @Override - public void removeListener(FocusListener listener) { + public void removeFocusListener(FocusListener listener) { removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); + } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated + public void removeListener(FocusListener listener) { + removeFocusListener(listener); } /* diff --git a/server/src/com/vaadin/ui/CheckBox.java b/server/src/com/vaadin/ui/CheckBox.java index 6da86b9711..149d4779d8 100644 --- a/server/src/com/vaadin/ui/CheckBox.java +++ b/server/src/com/vaadin/ui/CheckBox.java @@ -119,25 +119,60 @@ public class CheckBox extends AbstractField<Boolean> { getState().setChecked(newValue); } - public void addListener(BlurListener listener) { + public void addBlurListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } - public void removeListener(BlurListener listener) { + /** + * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} + **/ + @Deprecated + public void addListener(BlurListener listener) { + addBlurListener(listener); + } + + public void removeBlurListener(BlurListener listener) { removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); } - public void addListener(FocusListener listener) { + /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated + public void removeListener(BlurListener listener) { + removeBlurListener(listener); + } + + public void addFocusListener(FocusListener listener) { addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } - public void removeListener(FocusListener listener) { + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated + public void addListener(FocusListener listener) { + addFocusListener(listener); + } + + public void removeFocusListener(FocusListener listener) { removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated + public void removeListener(FocusListener listener) { + removeFocusListener(listener); + } + + /** * Get the boolean value of the button state. * * @return True iff the button is pressed down or checked. diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java index af19ca5b96..da3d2fd91d 100644 --- a/server/src/com/vaadin/ui/ComboBox.java +++ b/server/src/com/vaadin/ui/ComboBox.java @@ -16,12 +16,24 @@ package com.vaadin.ui; +import java.util.ArrayList; import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import com.vaadin.data.Container; +import com.vaadin.data.util.filter.SimpleStringFilter; +import com.vaadin.event.FieldEvents; +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; import com.vaadin.shared.ui.combobox.ComboBoxConstants; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; /** * A filtering dropdown single-select. Suitable for newItemsAllowed, but it's @@ -32,11 +44,59 @@ import com.vaadin.terminal.PaintTarget; * */ @SuppressWarnings("serial") -public class ComboBox extends Select { +public class ComboBox extends AbstractSelect implements + AbstractSelect.Filtering, FieldEvents.BlurNotifier, + FieldEvents.FocusNotifier { private String inputPrompt = null; /** + * Holds value of property pageLength. 0 disables paging. + */ + protected int pageLength = 10; + + private int columns = 0; + + // Current page when the user is 'paging' trough options + private int currentPage = -1; + + private int filteringMode = Filtering.FILTERINGMODE_STARTSWITH; + + private String filterstring; + private String prevfilterstring; + + /** + * Number of options that pass the filter, excluding the null item if any. + */ + private int filteredSize; + + /** + * Cache of filtered options, used only by the in-memory filtering system. + */ + private List<Object> filteredOptions; + + /** + * Flag to indicate that request repaint is called by filter request only + */ + private boolean optionRequest; + + /** + * True if the container is being filtered temporarily and item set change + * notifications should be suppressed. + */ + private boolean filteringContainer; + + /** + * Flag to indicate whether to scroll the selected item visible (select the + * page on which it is) when opening the popup or not. Only applies to + * single select mode. + * + * This requires finding the index of the item, which can be expensive in + * many large lazy loading containers. + */ + private boolean scrollToSelectedItem = true; + + /** * If text input is not allowed, the ComboBox behaves like a pretty * NativeSelect - the user can not enter any text and clicking the text * field opens the drop down with options @@ -89,11 +149,139 @@ public class ComboBox extends Select { if (inputPrompt != null) { target.addAttribute(ComboBoxConstants.ATTR_INPUTPROMPT, inputPrompt); } - super.paintContent(target); if (!textInputAllowed) { target.addAttribute(ComboBoxConstants.ATTR_NO_TEXT_INPUT, true); } + + // clear caption change listeners + getCaptionChangeListener().clear(); + + // The tab ordering number + if (getTabIndex() != 0) { + target.addAttribute("tabindex", getTabIndex()); + } + + // If the field is modified, but not committed, set modified attribute + if (isModified()) { + target.addAttribute("modified", true); + } + + if (isNewItemsAllowed()) { + target.addAttribute("allownewitem", true); + } + + boolean needNullSelectOption = false; + if (isNullSelectionAllowed()) { + target.addAttribute("nullselect", true); + needNullSelectOption = (getNullSelectionItemId() == null); + if (!needNullSelectOption) { + target.addAttribute("nullselectitem", true); + } + } + + // Constructs selected keys array + String[] selectedKeys = new String[(getValue() == null + && getNullSelectionItemId() == null ? 0 : 1)]; + + target.addAttribute("pagelength", pageLength); + + target.addAttribute("filteringmode", getFilteringMode()); + + // Paints the options and create array of selected id keys + int keyIndex = 0; + + target.startTag("options"); + + if (currentPage < 0) { + optionRequest = false; + currentPage = 0; + filterstring = ""; + } + + boolean nullFilteredOut = filterstring != null + && !"".equals(filterstring) + && filteringMode != Filtering.FILTERINGMODE_OFF; + // null option is needed and not filtered out, even if not on current + // page + boolean nullOptionVisible = needNullSelectOption && !nullFilteredOut; + + // first try if using container filters is possible + List<?> options = getOptionsWithFilter(nullOptionVisible); + if (null == options) { + // not able to use container filters, perform explicit in-memory + // filtering + options = getFilteredOptions(); + filteredSize = options.size(); + options = sanitetizeList(options, nullOptionVisible); + } + + final boolean paintNullSelection = needNullSelectOption + && currentPage == 0 && !nullFilteredOut; + + if (paintNullSelection) { + target.startTag("so"); + target.addAttribute("caption", ""); + target.addAttribute("key", ""); + target.endTag("so"); + } + + final Iterator<?> i = options.iterator(); + // Paints the available selection options from data source + + while (i.hasNext()) { + + final Object id = i.next(); + + if (!isNullSelectionAllowed() && id != null + && id.equals(getNullSelectionItemId()) && !isSelected(id)) { + continue; + } + + // Gets the option attribute values + final String key = itemIdMapper.key(id); + final String caption = getItemCaption(id); + final Resource icon = getItemIcon(id); + getCaptionChangeListener().addNotifierForItem(id); + + // Paints the option + target.startTag("so"); + if (icon != null) { + target.addAttribute("icon", icon); + } + target.addAttribute("caption", caption); + if (id != null && id.equals(getNullSelectionItemId())) { + target.addAttribute("nullselection", true); + } + target.addAttribute("key", key); + if (isSelected(id) && keyIndex < selectedKeys.length) { + target.addAttribute("selected", true); + selectedKeys[keyIndex++] = key; + } + target.endTag("so"); + } + target.endTag("options"); + + target.addAttribute("totalitems", size() + + (needNullSelectOption ? 1 : 0)); + if (filteredSize > 0 || nullOptionVisible) { + target.addAttribute("totalMatches", filteredSize + + (nullOptionVisible ? 1 : 0)); + } + + // Paint variables + target.addVariable(this, "selected", selectedKeys); + if (isNewItemsAllowed()) { + target.addVariable(this, "newitem", ""); + } + + target.addVariable(this, "filter", filterstring); + target.addVariable(this, "page", currentPage); + + currentPage = -1; // current page is always set by client + + optionRequest = true; + } /** @@ -125,4 +313,504 @@ public class ComboBox extends Select { return textInputAllowed; } + /** + * Returns the filtered options for the current page using a container + * filter. + * + * As a size effect, {@link #filteredSize} is set to the total number of + * items passing the filter. + * + * The current container must be {@link Filterable} and {@link Indexed}, and + * the filtering mode must be suitable for container filtering (tested with + * {@link #canUseContainerFilter()}). + * + * Use {@link #getFilteredOptions()} and + * {@link #sanitetizeList(List, boolean)} if this is not the case. + * + * @param needNullSelectOption + * @return filtered list of options (may be empty) or null if cannot use + * container filters + */ + protected List<?> getOptionsWithFilter(boolean needNullSelectOption) { + Container container = getContainerDataSource(); + + if (pageLength == 0) { + // no paging: return all items + filteredSize = container.size(); + return new ArrayList<Object>(container.getItemIds()); + } + + if (!(container instanceof Filterable) + || !(container instanceof Indexed) + || getItemCaptionMode() != ITEM_CAPTION_MODE_PROPERTY) { + return null; + } + + Filterable filterable = (Filterable) container; + + Filter filter = buildFilter(filterstring, filteringMode); + + // adding and removing filters leads to extraneous item set + // change events from the underlying container, but the ComboBox does + // not process or propagate them based on the flag filteringContainer + if (filter != null) { + filteringContainer = true; + filterable.addContainerFilter(filter); + } + + Indexed indexed = (Indexed) container; + + int indexToEnsureInView = -1; + + // if not an option request (item list when user changes page), go + // to page with the selected item after filtering if accepted by + // filter + Object selection = getValue(); + if (isScrollToSelectedItem() && !optionRequest && selection != null) { + // ensure proper page + indexToEnsureInView = indexed.indexOfId(selection); + } + + filteredSize = container.size(); + currentPage = adjustCurrentPage(currentPage, needNullSelectOption, + indexToEnsureInView, filteredSize); + int first = getFirstItemIndexOnCurrentPage(needNullSelectOption, + filteredSize); + int last = getLastItemIndexOnCurrentPage(needNullSelectOption, + filteredSize, first); + + List<Object> options = new ArrayList<Object>(); + for (int i = first; i <= last && i < filteredSize; ++i) { + options.add(indexed.getIdByIndex(i)); + } + + // to the outside, filtering should not be visible + if (filter != null) { + filterable.removeContainerFilter(filter); + filteringContainer = false; + } + + return options; + } + + /** + * Constructs a filter instance to use when using a Filterable container in + * the <code>ITEM_CAPTION_MODE_PROPERTY</code> mode. + * + * Note that the client side implementation expects the filter string to + * apply to the item caption string it sees, so changing the behavior of + * this method can cause problems. + * + * @param filterString + * @param filteringMode + * @return + */ + protected Filter buildFilter(String filterString, int filteringMode) { + Filter filter = null; + + if (null != filterString && !"".equals(filterString)) { + switch (filteringMode) { + case Filtering.FILTERINGMODE_OFF: + break; + case Filtering.FILTERINGMODE_STARTSWITH: + filter = new SimpleStringFilter(getItemCaptionPropertyId(), + filterString, true, true); + break; + case Filtering.FILTERINGMODE_CONTAINS: + filter = new SimpleStringFilter(getItemCaptionPropertyId(), + filterString, true, false); + break; + } + } + return filter; + } + + @Override + public void containerItemSetChange(Container.ItemSetChangeEvent event) { + if (!filteringContainer) { + super.containerItemSetChange(event); + } + } + + /** + * Makes correct sublist of given list of options. + * + * If paint is not an option request (affected by page or filter change), + * page will be the one where possible selection exists. + * + * Detects proper first and last item in list to return right page of + * options. Also, if the current page is beyond the end of the list, it will + * be adjusted. + * + * @param options + * @param needNullSelectOption + * flag to indicate if nullselect option needs to be taken into + * consideration + */ + private List<?> sanitetizeList(List<?> options, boolean needNullSelectOption) { + + if (pageLength != 0 && options.size() > pageLength) { + + int indexToEnsureInView = -1; + + // if not an option request (item list when user changes page), go + // to page with the selected item after filtering if accepted by + // filter + Object selection = getValue(); + if (isScrollToSelectedItem() && !optionRequest && selection != null) { + // ensure proper page + indexToEnsureInView = options.indexOf(selection); + } + + int size = options.size(); + currentPage = adjustCurrentPage(currentPage, needNullSelectOption, + indexToEnsureInView, size); + int first = getFirstItemIndexOnCurrentPage(needNullSelectOption, + size); + int last = getLastItemIndexOnCurrentPage(needNullSelectOption, + size, first); + return options.subList(first, last + 1); + } else { + return options; + } + } + + /** + * Returns the index of the first item on the current page. The index is to + * the underlying (possibly filtered) contents. The null item, if any, does + * not have an index but takes up a slot on the first page. + * + * @param needNullSelectOption + * true if a null option should be shown before any other options + * (takes up the first slot on the first page, not counted in + * index) + * @param size + * number of items after filtering (not including the null item, + * if any) + * @return first item to show on the UI (index to the filtered list of + * options, not taking the null item into consideration if any) + */ + private int getFirstItemIndexOnCurrentPage(boolean needNullSelectOption, + int size) { + // Not all options are visible, find out which ones are on the + // current "page". + int first = currentPage * pageLength; + if (needNullSelectOption && currentPage > 0) { + first--; + } + return first; + } + + /** + * Returns the index of the last item on the current page. The index is to + * the underlying (possibly filtered) contents. If needNullSelectOption is + * true, the null item takes up the first slot on the first page, + * effectively reducing the first page size by one. + * + * @param needNullSelectOption + * true if a null option should be shown before any other options + * (takes up the first slot on the first page, not counted in + * index) + * @param size + * number of items after filtering (not including the null item, + * if any) + * @param first + * index in the filtered view of the first item of the page + * @return index in the filtered view of the last item on the page + */ + private int getLastItemIndexOnCurrentPage(boolean needNullSelectOption, + int size, int first) { + // page length usable for non-null items + int effectivePageLength = pageLength + - (needNullSelectOption && (currentPage == 0) ? 1 : 0); + return Math.min(size - 1, first + effectivePageLength - 1); + } + + /** + * Adjusts the index of the current page if necessary: make sure the current + * page is not after the end of the contents, and optionally go to the page + * containg a specific item. There are no side effects but the adjusted page + * index is returned. + * + * @param page + * page number to use as the starting point + * @param needNullSelectOption + * true if a null option should be shown before any other options + * (takes up the first slot on the first page, not counted in + * index) + * @param indexToEnsureInView + * index of an item that should be included on the page (in the + * data set, not counting the null item if any), -1 for none + * @param size + * number of items after filtering (not including the null item, + * if any) + */ + private int adjustCurrentPage(int page, boolean needNullSelectOption, + int indexToEnsureInView, int size) { + if (indexToEnsureInView != -1) { + int newPage = (indexToEnsureInView + (needNullSelectOption ? 1 : 0)) + / pageLength; + page = newPage; + } + // adjust the current page if beyond the end of the list + if (page * pageLength > size) { + page = (size + (needNullSelectOption ? 1 : 0)) / pageLength; + } + return page; + } + + /** + * Filters the options in memory and returns the full filtered list. + * + * This can be less efficient than using container filters, so use + * {@link #getOptionsWithFilter(boolean)} if possible (filterable container + * and suitable item caption mode etc.). + * + * @return + */ + protected List<?> getFilteredOptions() { + if (null == filterstring || "".equals(filterstring) + || Filtering.FILTERINGMODE_OFF == filteringMode) { + prevfilterstring = null; + filteredOptions = new LinkedList<Object>(getItemIds()); + return filteredOptions; + } + + if (filterstring.equals(prevfilterstring)) { + return filteredOptions; + } + + Collection<?> items; + if (prevfilterstring != null + && filterstring.startsWith(prevfilterstring)) { + items = filteredOptions; + } else { + items = getItemIds(); + } + prevfilterstring = filterstring; + + filteredOptions = new LinkedList<Object>(); + for (final Iterator<?> it = items.iterator(); it.hasNext();) { + final Object itemId = it.next(); + String caption = getItemCaption(itemId); + if (caption == null || caption.equals("")) { + continue; + } else { + caption = caption.toLowerCase(); + } + switch (filteringMode) { + case Filtering.FILTERINGMODE_CONTAINS: + if (caption.indexOf(filterstring) > -1) { + filteredOptions.add(itemId); + } + break; + case Filtering.FILTERINGMODE_STARTSWITH: + default: + if (caption.startsWith(filterstring)) { + filteredOptions.add(itemId); + } + break; + } + } + + return filteredOptions; + } + + /** + * Invoked when the value of a variable has changed. + * + * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, + * java.util.Map) + */ + @Override + public void changeVariables(Object source, Map<String, Object> variables) { + // Not calling super.changeVariables due the history of select + // component hierarchy + + // Selection change + if (variables.containsKey("selected")) { + final String[] ka = (String[]) variables.get("selected"); + + // Single select mode + if (ka.length == 0) { + + // Allows deselection only if the deselected item is visible + final Object current = getValue(); + final Collection<?> visible = getVisibleItemIds(); + if (visible != null && visible.contains(current)) { + setValue(null, true); + } + } else { + final Object id = itemIdMapper.get(ka[0]); + if (id != null && id.equals(getNullSelectionItemId())) { + setValue(null, true); + } else { + setValue(id, true); + } + } + } + + String newFilter; + if ((newFilter = (String) variables.get("filter")) != null) { + // this is a filter request + currentPage = ((Integer) variables.get("page")).intValue(); + filterstring = newFilter; + if (filterstring != null) { + filterstring = filterstring.toLowerCase(); + } + requestRepaint(); + } else if (isNewItemsAllowed()) { + // New option entered (and it is allowed) + final String newitem = (String) variables.get("newitem"); + if (newitem != null && newitem.length() > 0) { + getNewItemHandler().addNewItem(newitem); + // rebuild list + filterstring = null; + prevfilterstring = null; + } + } + + if (variables.containsKey(FocusEvent.EVENT_ID)) { + fireEvent(new FocusEvent(this)); + } + if (variables.containsKey(BlurEvent.EVENT_ID)) { + fireEvent(new BlurEvent(this)); + } + + } + + @Override + @Deprecated + public void requestRepaint() { + markAsDirty(); + } + + @Override + public void setFilteringMode(int filteringMode) { + this.filteringMode = filteringMode; + } + + @Override + public int getFilteringMode() { + return filteringMode; + } + + public void addBlurListener(BlurListener listener) { + addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, + BlurListener.blurMethod); + } + + /** + * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} + **/ + @Deprecated + public void addListener(BlurListener listener) { + addBlurListener(listener); + } + + @Override + public void removeBlurListener(BlurListener listener) { + removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); + } + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated + public void removeListener(BlurListener listener) { + removeBlurListener(listener); + } + + @Override + public void addFocusListener(FocusListener listener) { + addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, + FocusListener.focusMethod); + } + + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated + public void addListener(FocusListener listener) { + addFocusListener(listener); + } + + @Override + public void removeFocusListener(FocusListener listener) { + removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); + } + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated + public void removeListener(FocusListener listener) { + removeFocusListener(listener); + } + + /** + * ComboBox does not support multi select mode. + * + * @deprecated use {@link ListSelect}, {@link OptionGroup} or + * {@link TwinColSelect} instead + * @see com.vaadin.ui.AbstractSelect#setMultiSelect(boolean) + * @throws UnsupportedOperationException + * if trying to activate multiselect mode + */ + @Deprecated + @Override + public void setMultiSelect(boolean multiSelect) { + if (multiSelect) { + throw new UnsupportedOperationException("Multiselect not supported"); + } + } + + /** + * ComboBox does not support multi select mode. + * + * @deprecated use {@link ListSelect}, {@link OptionGroup} or + * {@link TwinColSelect} instead + * + * @see com.vaadin.ui.AbstractSelect#isMultiSelect() + * + * @return false + */ + @Deprecated + @Override + public boolean isMultiSelect() { + return false; + } + + /** + * Sets whether to scroll the selected item visible (directly open the page + * on which it is) when opening the combo box popup or not. Only applies to + * single select mode. + * + * This requires finding the index of the item, which can be expensive in + * many large lazy loading containers. + * + * @param scrollToSelectedItem + * true to find the page with the selected item when opening the + * selection popup + */ + public void setScrollToSelectedItem(boolean scrollToSelectedItem) { + this.scrollToSelectedItem = scrollToSelectedItem; + } + + /** + * Returns true if the select should find the page with the selected item + * when opening the popup (single select combo box only). + * + * @see #setScrollToSelectedItem(boolean) + * + * @return true if the page with the selected item will be shown when + * opening the popup + */ + public boolean isScrollToSelectedItem() { + return scrollToSelectedItem; + } + } diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index 0559cc5e6a..01033ff560 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -23,11 +23,11 @@ import java.util.Locale; import com.vaadin.Application; import com.vaadin.event.FieldEvents; -import com.vaadin.terminal.ErrorMessage; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Sizeable; -import com.vaadin.terminal.VariableOwner; -import com.vaadin.terminal.gwt.server.ClientConnector; +import com.vaadin.server.ClientConnector; +import com.vaadin.server.ErrorMessage; +import com.vaadin.server.Resource; +import com.vaadin.server.Sizeable; +import com.vaadin.server.VariableOwner; /** * {@code Component} is the top-level interface that is and must be implemented @@ -136,8 +136,9 @@ public interface Component extends ClientConnector, Sizeable, Serializable { public void setStyleName(String style); /** - * Adds a style name to component. The style name will be rendered as a HTML - * class name, which can be used in a CSS definition. + * Adds one or more style names to this component. Multiple styles can be + * specified as a space-separated list of style names. The style name will + * be rendered as a HTML class name, which can be used in a CSS definition. * * <pre> * Label label = new Label("This text has style"); @@ -462,7 +463,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * * <p> * The image is loaded by the browser from a resource, typically a - * {@link com.vaadin.terminal.ThemeResource}. + * {@link com.vaadin.server.ThemeResource}. * </p> * * <pre> diff --git a/server/src/com/vaadin/ui/ComponentContainer.java b/server/src/com/vaadin/ui/ComponentContainer.java index c2a75f9313..cee6d7300b 100644 --- a/server/src/com/vaadin/ui/ComponentContainer.java +++ b/server/src/com/vaadin/ui/ComponentContainer.java @@ -94,6 +94,13 @@ public interface ComponentContainer extends HasComponents { * @param listener * the listener to add. */ + public void addComponentAttachListener(ComponentAttachListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addComponentAttachListener(ComponentAttachListener)} + **/ + @Deprecated public void addListener(ComponentAttachListener listener); /** @@ -102,16 +109,37 @@ public interface ComponentContainer extends HasComponents { * @param listener * the listener to removed. */ + public void removeComponentAttachListener(ComponentAttachListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeComponentAttachListener(ComponentAttachListener)} + **/ + @Deprecated public void removeListener(ComponentAttachListener listener); /** * Listens the component detach events. */ + public void addComponentDetachListener(ComponentDetachListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #addComponentDetachListener(ComponentDetachListener)} + **/ + @Deprecated public void addListener(ComponentDetachListener listener); /** * Stops the listening component detach events. */ + public void removeComponentDetachListener(ComponentDetachListener listener); + + /** + * @deprecated Since 7.0, replaced by + * {@link #removeComponentDetachListener(ComponentDetachListener)} + **/ + @Deprecated public void removeListener(ComponentDetachListener listener); /** diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index b44189f838..3140c26525 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -25,9 +25,10 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import com.vaadin.terminal.AbstractClientConnector; -import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; -import com.vaadin.terminal.gwt.server.ClientConnector; +import com.vaadin.server.AbstractClientConnector; +import com.vaadin.server.AbstractCommunicationManager; +import com.vaadin.server.ClientConnector; +import com.vaadin.server.GlobalResourceHandler; /** * A class which takes care of book keeping of {@link ClientConnector}s for a @@ -42,7 +43,7 @@ import com.vaadin.terminal.gwt.server.ClientConnector; * client when the following response is sent. A connector is dirty when an * operation has been performed on it on the server and as a result of this * operation new information needs to be sent to its - * {@link com.vaadin.terminal.gwt.client.ServerConnector}. + * {@link com.vaadin.client.ServerConnector}. * </p> * * @author Vaadin Ltd @@ -141,11 +142,22 @@ public class ConnectorTracker implements Serializable { getLogger().fine( "Unregistered " + connector.getClass().getSimpleName() + " (" + connectorId + ")"); + + removeFromGlobalResourceHandler(connector); connectorIdToConnector.remove(connectorId); uninitializedConnectors.remove(connector); diffStates.remove(connector); } + private void removeFromGlobalResourceHandler(ClientConnector connector) { + GlobalResourceHandler globalResourceHandler = uI.getApplication() + .getGlobalResourceHandler(false); + // Nothing to do if there is no handler + if (globalResourceHandler != null) { + globalResourceHandler.unregisterConnector(connector); + } + } + /** * Checks whether the given connector has already been initialized in the * browser. The given connector should be registered with this connector @@ -224,6 +236,8 @@ public class ConnectorTracker implements Serializable { "cleanConnectorMap unregistered connector " + getConnectorAndParentInfo(connector) + "). This should have been done when the connector was detached."); + + removeFromGlobalResourceHandler(connector); uninitializedConnectors.remove(connector); diffStates.remove(connector); iterator.remove(); diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java index b16bcf31df..b63c8573ba 100644 --- a/server/src/com/vaadin/ui/CssLayout.java +++ b/server/src/com/vaadin/ui/CssLayout.java @@ -281,19 +281,37 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { } @Override - public void addListener(LayoutClickListener listener) { + public void addLayoutClickListener(LayoutClickListener listener) { addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addLayoutClickListener(LayoutClickListener)} + **/ + @Deprecated + public void addListener(LayoutClickListener listener) { + addLayoutClickListener(listener); + } + @Override - public void removeListener(LayoutClickListener listener) { + public void removeLayoutClickListener(LayoutClickListener listener) { removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeLayoutClickListener(LayoutClickListener)} + **/ + @Deprecated + public void removeListener(LayoutClickListener listener) { + removeLayoutClickListener(listener); + } + + /** * Returns the index of the given component. * * @param component diff --git a/server/src/com/vaadin/ui/CustomField.java b/server/src/com/vaadin/ui/CustomField.java index 9ac5e2defb..7bb6e66cf9 100644 --- a/server/src/com/vaadin/ui/CustomField.java +++ b/server/src/com/vaadin/ui/CustomField.java @@ -221,27 +221,64 @@ public abstract class CustomField<T> extends AbstractField<T> implements } @Override - public void addListener(ComponentAttachListener listener) { + public void addComponentAttachListener(ComponentAttachListener listener) { addListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)} + **/ + @Deprecated + public void addListener(ComponentAttachListener listener) { + addComponentAttachListener(listener); + } + @Override - public void removeListener(ComponentAttachListener listener) { + public void removeComponentAttachListener(ComponentAttachListener listener) { removeListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)} + **/ + @Deprecated + public void removeListener(ComponentAttachListener listener) { + removeComponentAttachListener(listener); + } + @Override - public void addListener(ComponentDetachListener listener) { + public void addComponentDetachListener(ComponentDetachListener listener) { // content never detached } + /** + * @deprecated Since 7.0, replaced by + * {@link #addComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)} + **/ + @Deprecated + public void addListener(ComponentDetachListener listener) { + addComponentDetachListener(listener); + + } + @Override - public void removeListener(ComponentDetachListener listener) { + public void removeComponentDetachListener(ComponentDetachListener listener) { // content never detached } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)} + **/ + @Deprecated + public void removeListener(ComponentDetachListener listener) { + removeComponentDetachListener(listener); + } + @Override public boolean isComponentVisible(Component childComponent) { return true; diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index 54308b99c3..f747b6ff3b 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -24,11 +24,11 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import com.vaadin.server.JsonPaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.customlayout.CustomLayoutState; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; -import com.vaadin.terminal.gwt.server.JsonPaintTarget; /** * <p> @@ -58,7 +58,7 @@ import com.vaadin.terminal.gwt.server.JsonPaintTarget; * @since 3.0 */ @SuppressWarnings("serial") -public class CustomLayout extends AbstractLayout implements Vaadin6Component { +public class CustomLayout extends AbstractLayout implements LegacyComponent { private static final int BUFFER_SIZE = 10000; diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java index 828fa3b21d..712034a562 100644 --- a/server/src/com/vaadin/ui/DateField.java +++ b/server/src/com/vaadin/ui/DateField.java @@ -36,10 +36,10 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.datefield.DateFieldConstants; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; /** * <p> @@ -61,7 +61,7 @@ import com.vaadin.terminal.Vaadin6Component; */ @SuppressWarnings("serial") public class DateField extends AbstractField<Date> implements - FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, Vaadin6Component { + FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, LegacyComponent { /** * Resolutions for DateFields @@ -741,28 +741,63 @@ public class DateField extends AbstractField<Date> implements } @Override - public void addListener(FocusListener listener) { + public void addFocusListener(FocusListener listener) { addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated + public void addListener(FocusListener listener) { + addFocusListener(listener); + } + @Override - public void removeListener(FocusListener listener) { + public void removeFocusListener(FocusListener listener) { removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated + public void removeListener(FocusListener listener) { + removeFocusListener(listener); + } + @Override - public void addListener(BlurListener listener) { + public void addBlurListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } + /** + * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} + **/ + @Deprecated + public void addListener(BlurListener listener) { + addBlurListener(listener); + } + @Override - public void removeListener(BlurListener listener) { + public void removeBlurListener(BlurListener listener) { removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated + public void removeListener(BlurListener listener) { + removeBlurListener(listener); + } + + /** * Checks whether ISO 8601 week numbers are shown in the date selector. * * @return true if week numbers are shown, false otherwise. diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java index ec805ecf46..d3f3e23448 100644 --- a/server/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java @@ -29,18 +29,18 @@ import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropTarget; import com.vaadin.event.dd.TargetDetails; import com.vaadin.event.dd.TargetDetailsImpl; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.StreamVariable; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.dd.HorizontalDropLocation; import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperConstants; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.StreamVariable; -import com.vaadin.terminal.Vaadin6Component; @SuppressWarnings("serial") public class DragAndDropWrapper extends CustomComponent implements DropTarget, - DragSource, Vaadin6Component { + DragSource, LegacyComponent { public class WrapperTransferable extends TransferableImpl { @@ -212,7 +212,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, @Override public void changeVariables(Object source, Map<String, Object> variables) { - // TODO Remove once Vaadin6Component is no longer implemented + // TODO Remove once LegacyComponent is no longer implemented } @Override diff --git a/server/src/com/vaadin/ui/Embedded.java b/server/src/com/vaadin/ui/Embedded.java index 41b93d0b27..b3afb52249 100644 --- a/server/src/com/vaadin/ui/Embedded.java +++ b/server/src/com/vaadin/ui/Embedded.java @@ -22,23 +22,27 @@ import java.util.Map; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.embedded.EmbeddedConstants; import com.vaadin.shared.ui.embedded.EmbeddedServerRpc; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Vaadin6Component; /** * Component for embedding external objects. + * <p> + * As of Vaadin 7.0, the {@link Image}, {@link Flash}, and + * {@link EmbeddedBrowser} components should be used instead of + * <code>Embedded</code> whenever appropriate. * * @author Vaadin Ltd. * @since 3.0 */ @SuppressWarnings("serial") -public class Embedded extends AbstractComponent implements Vaadin6Component { +public class Embedded extends AbstractComponent implements LegacyComponent { /** * General object type. @@ -47,12 +51,18 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { /** * Image types. + * + * @deprecated As of 7.0, use the {@link Image} component instead. */ + @Deprecated public static final int TYPE_IMAGE = 1; /** * Browser ("iframe") type. + * + * @deprecated As of 7.0, use the {@link EmbeddedBrowser} component instead. */ + @Deprecated public static final int TYPE_BROWSER = 2; /** @@ -452,9 +462,9 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { * <p> * This can be one of the following: * <ul> - * <li>TYPE_OBJECT <i>(This is the default)</i> - * <li>TYPE_IMAGE - * <li>TYPE_BROWSER + * <li>{@link #TYPE_OBJECT} <i>(This is the default)</i> + * <li>{@link #TYPE_IMAGE} <i>(Deprecated)</i> + * <li>{@link #TYPE_BROWSER} <i>(Deprecated)</i> * </ul> * </p> * @@ -516,26 +526,44 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { * @param listener * The listener to add */ - public void addListener(ClickListener listener) { + public void addClickListener(ClickListener listener) { addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener, ClickListener.clickMethod); } /** + * @deprecated Since 7.0, replaced by + * {@link #addClickListener(ClickListener)} + **/ + @Deprecated + public void addListener(ClickListener listener) { + addClickListener(listener); + } + + /** * Remove a click listener from the component. The listener should earlier * have been added using {@link #addListener(ClickListener)}. * * @param listener * The listener to remove */ - public void removeListener(ClickListener listener) { + public void removeClickListener(ClickListener listener) { removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeClickListener(ClickListener)} + **/ + @Deprecated + public void removeListener(ClickListener listener) { + removeClickListener(listener); + } + @Override public void changeVariables(Object source, Map<String, Object> variables) { - // TODO Remove once Vaadin6Component is no longer implemented + // TODO Remove once LegacyComponent is no longer implemented } } diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index 55404b2e6b..7e77117acb 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -36,14 +36,14 @@ import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; import com.vaadin.event.Action.ShortcutNotifier; import com.vaadin.event.ActionManager; +import com.vaadin.server.AbstractErrorMessage; +import com.vaadin.server.CompositeErrorMessage; +import com.vaadin.server.ErrorMessage; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.UserError; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.form.FormState; -import com.vaadin.terminal.AbstractErrorMessage; -import com.vaadin.terminal.CompositeErrorMessage; -import com.vaadin.terminal.ErrorMessage; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.UserError; -import com.vaadin.terminal.Vaadin6Component; /** * Form component provides easy way of creating and managing sets fields. @@ -79,7 +79,7 @@ import com.vaadin.terminal.Vaadin6Component; @Deprecated public class Form extends AbstractField<Object> implements Item.Editor, Buffered, Item, Validatable, Action.Notifier, HasComponents, - Vaadin6Component { + LegacyComponent { private Object propertyValue; diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 3870b71611..21602c6802 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -27,16 +27,16 @@ import java.util.Map.Entry; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickNotifier; +import com.vaadin.server.LegacyPaint; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.gridlayout.GridLayoutServerRpc; import com.vaadin.shared.ui.gridlayout.GridLayoutState; -import com.vaadin.terminal.LegacyPaint; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; /** * A layout where the components are laid out on a grid using cell coordinates. @@ -65,7 +65,7 @@ import com.vaadin.terminal.Vaadin6Component; @SuppressWarnings("serial") public class GridLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.SpacingHandler, Layout.MarginHandler, - LayoutClickNotifier, Vaadin6Component { + LayoutClickNotifier, LegacyComponent { private GridLayoutServerRpc rpc = new GridLayoutServerRpc() { @@ -447,7 +447,7 @@ public class GridLayout extends AbstractLayout implements @Override public void changeVariables(Object source, Map<String, Object> variables) { - // TODO Remove once Vaadin6Component is no longer implemented + // TODO Remove once LegacyComponent is no longer implemented } /** @@ -1354,18 +1354,38 @@ public class GridLayout extends AbstractLayout implements } @Override - public void addListener(LayoutClickListener listener) { + public void addLayoutClickListener(LayoutClickListener listener) { addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addLayoutClickListener(LayoutClickListener)} + **/ @Override - public void removeListener(LayoutClickListener listener) { + @Deprecated + public void addListener(LayoutClickListener listener) { + addLayoutClickListener(listener); + } + + @Override + public void removeLayoutClickListener(LayoutClickListener listener) { removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeLayoutClickListener(LayoutClickListener)} + **/ + @Override + @Deprecated + public void removeListener(LayoutClickListener listener) { + removeLayoutClickListener(listener); + } + /* * (non-Javadoc) * diff --git a/server/src/com/vaadin/ui/Html5File.java b/server/src/com/vaadin/ui/Html5File.java index 596f83a1d8..47af708160 100644 --- a/server/src/com/vaadin/ui/Html5File.java +++ b/server/src/com/vaadin/ui/Html5File.java @@ -18,7 +18,7 @@ package com.vaadin.ui; import java.io.Serializable; import com.vaadin.event.dd.DropHandler; -import com.vaadin.terminal.StreamVariable; +import com.vaadin.server.StreamVariable; /** * {@link DragAndDropWrapper} can receive also files from client computer if diff --git a/server/src/com/vaadin/ui/Image.java b/server/src/com/vaadin/ui/Image.java index b0dbc9e629..178e557cf3 100644 --- a/server/src/com/vaadin/ui/Image.java +++ b/server/src/com/vaadin/ui/Image.java @@ -6,11 +6,11 @@ package com.vaadin.ui; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.server.Resource; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.image.ImageServerRpc; import com.vaadin.shared.ui.image.ImageState; -import com.vaadin.terminal.Resource; /** * Component for embedding images. @@ -66,28 +66,46 @@ public class Image extends AbstractEmbedded { } /** + * @deprecated As of 7.0.0, use {@link #addClickListener(ClickListener)} + * instead + */ + @Deprecated + public void addListener(ClickListener listener) { + addClickListener(listener); + } + + /** * Add a click listener to the component. The listener is called whenever * the user clicks inside the component. Depending on the content the event * may be blocked and in that case no event is fired. * - * Use {@link #removeListener(ClickListener)} to remove the listener. + * Use {@link #removeClickListener(ClickListener)} to remove the listener. * * @param listener * The listener to add */ - public void addListener(ClickListener listener) { + public void addClickListener(ClickListener listener) { addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener, ClickListener.clickMethod); } /** + * @deprecated As of 7.0.0, use {@link #removeClickListener(ClickListener)} + * instead + */ + @Deprecated + public void removeListener(ClickListener listener) { + removeClickListener(listener); + } + + /** * Remove a click listener from the component. The listener should earlier - * have been added using {@link #addListener(ClickListener)}. + * have been added using {@link #addClickListener(ClickListener)}. * * @param listener * The listener to remove */ - public void removeListener(ClickListener listener) { + public void removeClickListener(ClickListener listener) { removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener); } diff --git a/server/src/com/vaadin/ui/JavaScript.java b/server/src/com/vaadin/ui/JavaScript.java index e34ccae82a..f3e8564fab 100644 --- a/server/src/com/vaadin/ui/JavaScript.java +++ b/server/src/com/vaadin/ui/JavaScript.java @@ -21,11 +21,11 @@ import java.util.Map; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; +import com.vaadin.server.AbstractExtension; +import com.vaadin.server.Page; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.extension.javascriptmanager.ExecuteJavaScriptRpc; import com.vaadin.shared.extension.javascriptmanager.JavaScriptManagerState; -import com.vaadin.terminal.AbstractExtension; -import com.vaadin.terminal.Page; /** * Provides access to JavaScript functionality in the web browser. To get an diff --git a/server/src/com/vaadin/ui/JavaScriptFunction.java b/server/src/com/vaadin/ui/JavaScriptFunction.java index 3a17fef995..ebb5e2c073 100644 --- a/server/src/com/vaadin/ui/JavaScriptFunction.java +++ b/server/src/com/vaadin/ui/JavaScriptFunction.java @@ -20,7 +20,7 @@ import java.io.Serializable; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; -import com.vaadin.terminal.AbstractJavaScriptExtension; +import com.vaadin.server.AbstractJavaScriptExtension; /** * Defines a method that is called by a client-side JavaScript function. When diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 81a343e937..ff4a5dcb07 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -349,11 +349,20 @@ public class Label extends AbstractComponent implements Property<String>, * @see com.vaadin.data.Property.ValueChangeNotifier#addListener(com.vaadin.data.Property.ValueChangeListener) */ @Override - public void addListener(Property.ValueChangeListener listener) { + public void addValueChangeListener(Property.ValueChangeListener listener) { addListener(Label.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void addListener(Property.ValueChangeListener listener) { + addValueChangeListener(listener); + } + + /** * Removes the value change listener. * * @param listener @@ -361,12 +370,21 @@ public class Label extends AbstractComponent implements Property<String>, * @see com.vaadin.data.Property.ValueChangeNotifier#removeListener(com.vaadin.data.Property.ValueChangeListener) */ @Override - public void removeListener(Property.ValueChangeListener listener) { + public void removeValueChangeListener(Property.ValueChangeListener listener) { removeListener(Label.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} + **/ + @Deprecated + public void removeListener(Property.ValueChangeListener listener) { + removeValueChangeListener(listener); + } + + /** * Emits the options change event. */ protected void fireValueChange() { diff --git a/server/src/com/vaadin/ui/Link.java b/server/src/com/vaadin/ui/Link.java index f98a2b0d2d..a2737e4483 100644 --- a/server/src/com/vaadin/ui/Link.java +++ b/server/src/com/vaadin/ui/Link.java @@ -18,11 +18,12 @@ package com.vaadin.ui; import java.util.Map; +import com.vaadin.server.LegacyComponent; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; import com.vaadin.shared.ui.BorderStyle; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Vaadin6Component; +import com.vaadin.shared.ui.link.LinkConstants; /** * Link is used to create external or internal URL links. @@ -31,7 +32,7 @@ import com.vaadin.terminal.Vaadin6Component; * @since 3.0 */ @SuppressWarnings("serial") -public class Link extends AbstractComponent implements Vaadin6Component { +public class Link extends AbstractComponent implements LegacyComponent { /* Target window border type constant: No window border */ @Deprecated @@ -45,8 +46,6 @@ public class Link extends AbstractComponent implements Vaadin6Component { @Deprecated public static final BorderStyle TARGET_BORDER_DEFAULT = BorderStyle.DEFAULT; - private Resource resource = null; - private String targetName; private BorderStyle targetBorder = BorderStyle.DEFAULT; @@ -70,7 +69,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public Link(String caption, Resource resource) { setCaption(caption); - this.resource = resource; + setResource(resource); } /** @@ -94,7 +93,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { public Link(String caption, Resource resource, String targetName, int width, int height, BorderStyle border) { setCaption(caption); - this.resource = resource; + setResource(resource); setTargetName(targetName); setTargetWidth(width); setTargetHeight(height); @@ -111,10 +110,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ @Override public void paintContent(PaintTarget target) throws PaintException { - - if (resource != null) { - target.addAttribute("src", resource); - } else { + if (getResource() == null) { return; } @@ -230,7 +226,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { * @return the Resource. */ public Resource getResource() { - return resource; + return getResource(LinkConstants.HREF_RESOURCE); } /** @@ -240,12 +236,11 @@ public class Link extends AbstractComponent implements Vaadin6Component { * the resource to set. */ public void setResource(Resource resource) { - this.resource = resource; - markAsDirty(); + setResource(LinkConstants.HREF_RESOURCE, resource); } @Override public void changeVariables(Object source, Map<String, Object> variables) { - // TODO Remove once Vaadin6Component is no longer implemented + // TODO Remove once LegacyComponent is no longer implemented } } diff --git a/server/src/com/vaadin/ui/ListSelect.java b/server/src/com/vaadin/ui/ListSelect.java index da78e24fa8..90e1c16a4d 100644 --- a/server/src/com/vaadin/ui/ListSelect.java +++ b/server/src/com/vaadin/ui/ListSelect.java @@ -19,8 +19,8 @@ package com.vaadin.ui; import java.util.Collection; import com.vaadin.data.Container; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * This is a simple list select without, for instance, support for new items, diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index 1c154699d8..abcc7ff607 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -25,12 +25,12 @@ import java.util.Iterator; import java.util.Map; import com.vaadin.Application; +import com.vaadin.server.ConnectorResource; +import com.vaadin.server.DownloadStream; +import com.vaadin.server.RequestHandler; +import com.vaadin.server.WrappedRequest; +import com.vaadin.server.WrappedResponse; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.terminal.ApplicationResource; -import com.vaadin.terminal.DownloadStream; -import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; /** * LoginForm is a Vaadin component to handle common problem among Ajax @@ -58,23 +58,7 @@ public class LoginForm extends CustomComponent { private Embedded iframe = new Embedded(); - private ApplicationResource loginPage = new ApplicationResource() { - - @Override - public Application getApplication() { - return LoginForm.this.getApplication(); - } - - @Override - public int getBufferSize() { - return getLoginHTML().length; - } - - @Override - public long getCacheTime() { - return -1; - } - + private ConnectorResource loginPage = new ConnectorResource() { @Override public String getFilename() { return "login"; @@ -82,8 +66,13 @@ public class LoginForm extends CustomComponent { @Override public DownloadStream getStream() { - return new DownloadStream(new ByteArrayInputStream(getLoginHTML()), - getMIMEType(), getFilename()); + byte[] loginHTML = getLoginHTML(); + DownloadStream downloadStream = new DownloadStream( + new ByteArrayInputStream(loginHTML), getMIMEType(), + getFilename()); + downloadStream.setBufferSize(loginHTML.length); + downloadStream.setCacheTime(-1); + return downloadStream; } @Override @@ -197,14 +186,12 @@ public class LoginForm extends CustomComponent { @Override public void attach() { super.attach(); - getApplication().addResource(loginPage); getApplication().addRequestHandler(requestHandler); iframe.setSource(loginPage); } @Override public void detach() { - getApplication().removeResource(loginPage); getApplication().removeRequestHandler(requestHandler); super.detach(); @@ -271,19 +258,37 @@ public class LoginForm extends CustomComponent { * * @param listener */ - public void addListener(LoginListener listener) { + public void addLoginListener(LoginListener listener) { addListener(LoginEvent.class, listener, ON_LOGIN_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addLoginListener(LoginListener)} + **/ + @Deprecated + public void addListener(LoginListener listener) { + addLoginListener(listener); + } + + /** * Removes LoginListener * * @param listener */ - public void removeListener(LoginListener listener) { + public void removeLoginListener(LoginListener listener) { removeListener(LoginEvent.class, listener, ON_LOGIN_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeLoginListener(LoginListener)} + **/ + @Deprecated + public void removeListener(LoginListener listener) { + removeLoginListener(listener); + } + @Override public void setWidth(float width, Unit unit) { super.setWidth(width, unit); diff --git a/server/src/com/vaadin/ui/MenuBar.java b/server/src/com/vaadin/ui/MenuBar.java index 51c06cf934..d948ef813a 100644 --- a/server/src/com/vaadin/ui/MenuBar.java +++ b/server/src/com/vaadin/ui/MenuBar.java @@ -22,11 +22,11 @@ import java.util.List; import java.util.Map; import java.util.Stack; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.menubar.MenuBarConstants; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Vaadin6Component; /** * <p> @@ -36,7 +36,7 @@ import com.vaadin.terminal.Vaadin6Component; * </p> */ @SuppressWarnings("serial") -public class MenuBar extends AbstractComponent implements Vaadin6Component { +public class MenuBar extends AbstractComponent implements LegacyComponent { // Items of the top-level menu private final List<MenuItem> menuItems; diff --git a/server/src/com/vaadin/ui/NativeSelect.java b/server/src/com/vaadin/ui/NativeSelect.java index c2969874b0..8006813276 100644 --- a/server/src/com/vaadin/ui/NativeSelect.java +++ b/server/src/com/vaadin/ui/NativeSelect.java @@ -19,8 +19,8 @@ package com.vaadin.ui; import java.util.Collection; import com.vaadin.data.Container; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * This is a simple drop-down select without, for instance, support for diff --git a/server/src/com/vaadin/ui/Notification.java b/server/src/com/vaadin/ui/Notification.java index 22ad31dffe..758d2c86a3 100644 --- a/server/src/com/vaadin/ui/Notification.java +++ b/server/src/com/vaadin/ui/Notification.java @@ -18,9 +18,9 @@ package com.vaadin.ui; import java.io.Serializable; +import com.vaadin.server.Page; +import com.vaadin.server.Resource; import com.vaadin.shared.Position; -import com.vaadin.terminal.Page; -import com.vaadin.terminal.Resource; /** * A notification message, used to display temporary messages to the user - for diff --git a/server/src/com/vaadin/ui/OptionGroup.java b/server/src/com/vaadin/ui/OptionGroup.java index 12507442c9..983a01381d 100644 --- a/server/src/com/vaadin/ui/OptionGroup.java +++ b/server/src/com/vaadin/ui/OptionGroup.java @@ -27,9 +27,9 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; import com.vaadin.shared.ui.optiongroup.OptionGroupConstants; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; /** * Configures select to be used as an option group. @@ -89,28 +89,63 @@ public class OptionGroup extends AbstractSelect implements } @Override - public void addListener(BlurListener listener) { + public void addBlurListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } + /** + * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} + **/ + @Deprecated + public void addListener(BlurListener listener) { + addBlurListener(listener); + } + @Override - public void removeListener(BlurListener listener) { + public void removeBlurListener(BlurListener listener) { removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated + public void removeListener(BlurListener listener) { + removeBlurListener(listener); + } + @Override - public void addListener(FocusListener listener) { + public void addFocusListener(FocusListener listener) { addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated + public void addListener(FocusListener listener) { + addFocusListener(listener); + } + @Override - public void removeListener(FocusListener listener) { + public void removeFocusListener(FocusListener listener) { removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated + public void removeListener(FocusListener listener) { + removeFocusListener(listener); + } + @Override protected void setValue(Object newValue, boolean repaintIsNotNeeded) { if (repaintIsNotNeeded) { diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java index 00810b83db..6f399bcc19 100644 --- a/server/src/com/vaadin/ui/Panel.java +++ b/server/src/com/vaadin/ui/Panel.java @@ -25,14 +25,14 @@ import com.vaadin.event.Action.Handler; import com.vaadin.event.ActionManager; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Scrollable; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.panel.PanelServerRpc; import com.vaadin.shared.ui.panel.PanelState; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Scrollable; -import com.vaadin.terminal.Vaadin6Component; import com.vaadin.ui.Component.Focusable; /** @@ -45,7 +45,7 @@ import com.vaadin.ui.Component.Focusable; public class Panel extends AbstractComponentContainer implements Scrollable, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, Action.Notifier, Focusable, - Vaadin6Component { + LegacyComponent { /** * Content of the panel. @@ -195,8 +195,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, /* * (non-Javadoc) * - * @see - * com.vaadin.terminal.Vaadin6Component#paintContent(com.vaadin.terminal + * @see com.vaadin.server.LegacyComponent#paintContent(com.vaadin.server * .PaintTarget) */ @Override @@ -250,7 +249,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * Called when one or more variables handled by the implementing class are * changed. * - * @see com.vaadin.terminal.VariableOwner#changeVariables(Object, Map) + * @see com.vaadin.server.VariableOwner#changeVariables(Object, Map) */ @Override @SuppressWarnings("unchecked") @@ -289,7 +288,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, /* * (non-Javadoc) * - * @see com.vaadin.terminal.Scrollable#setScrollable(boolean) + * @see com.vaadin.server.Scrollable#setScrollable(boolean) */ @Override public int getScrollLeft() { @@ -299,7 +298,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, /* * (non-Javadoc) * - * @see com.vaadin.terminal.Scrollable#setScrollable(boolean) + * @see com.vaadin.server.Scrollable#setScrollable(boolean) */ @Override public int getScrollTop() { @@ -309,7 +308,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, /* * (non-Javadoc) * - * @see com.vaadin.terminal.Scrollable#setScrollLeft(int) + * @see com.vaadin.server.Scrollable#setScrollLeft(int) */ @Override public void setScrollLeft(int scrollLeft) { @@ -323,7 +322,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, /* * (non-Javadoc) * - * @see com.vaadin.terminal.Scrollable#setScrollTop(int) + * @see com.vaadin.server.Scrollable#setScrollTop(int) */ @Override public void setScrollTop(int scrollTop) { @@ -432,24 +431,42 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * @param listener * The listener to add */ - public void addListener(ClickListener listener) { + public void addClickListener(ClickListener listener) { addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener, ClickListener.clickMethod); } /** + * @deprecated Since 7.0, replaced by + * {@link #addClickListener(ClickListener)} + **/ + @Deprecated + public void addListener(ClickListener listener) { + addClickListener(listener); + } + + /** * Remove a click listener from the Panel. The listener should earlier have * been added using {@link #addListener(ClickListener)}. * * @param listener * The listener to remove */ - public void removeListener(ClickListener listener) { + public void removeClickListener(ClickListener listener) { removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeClickListener(ClickListener)} + **/ + @Deprecated + public void removeListener(ClickListener listener) { + addClickListener(listener); + } + + /** * {@inheritDoc} */ @Override diff --git a/server/src/com/vaadin/ui/PopupDateField.java b/server/src/com/vaadin/ui/PopupDateField.java index acff49a142..39e0578301 100644 --- a/server/src/com/vaadin/ui/PopupDateField.java +++ b/server/src/com/vaadin/ui/PopupDateField.java @@ -19,8 +19,8 @@ package com.vaadin.ui; import java.util.Date; import com.vaadin.data.Property; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; /** * <p> diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java index 786257c240..8d6d28e121 100644 --- a/server/src/com/vaadin/ui/PopupView.java +++ b/server/src/com/vaadin/ui/PopupView.java @@ -20,10 +20,10 @@ import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; -import com.vaadin.terminal.LegacyPaint; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; +import com.vaadin.server.LegacyPaint; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; /** * @@ -36,7 +36,7 @@ import com.vaadin.terminal.Vaadin6Component; */ @SuppressWarnings("serial") public class PopupView extends AbstractComponentContainer implements - Vaadin6Component { + LegacyComponent { private Content content; private boolean hideOnMouseOut; @@ -309,7 +309,7 @@ public class PopupView extends AbstractComponentContainer implements /** * Paint (serialize) the component for the client. * - * @see com.vaadin.ui.AbstractComponent#paintContent(com.vaadin.terminal.PaintTarget) + * @see com.vaadin.ui.AbstractComponent#paintContent(com.vaadin.server.PaintTarget) */ @Override public void paintContent(PaintTarget target) throws PaintException { @@ -377,12 +377,21 @@ public class PopupView extends AbstractComponentContainer implements * @see #removeListener(PopupVisibilityListener) * */ - public void addListener(PopupVisibilityListener listener) { + public void addPopupVisibilityListener(PopupVisibilityListener listener) { addListener(PopupVisibilityEvent.class, listener, POPUP_VISIBILITY_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addPopupVisibilityListener(PopupVisibilityListener)} + **/ + @Deprecated + public void addListener(PopupVisibilityListener listener) { + addPopupVisibilityListener(listener); + } + + /** * Removes a previously added listener, so that it no longer receives events * when the visibility of the popup changes. * @@ -391,12 +400,21 @@ public class PopupView extends AbstractComponentContainer implements * @see PopupVisibilityListener * @see #addListener(PopupVisibilityListener) */ - public void removeListener(PopupVisibilityListener listener) { + public void removePopupVisibilityListener(PopupVisibilityListener listener) { removeListener(PopupVisibilityEvent.class, listener, POPUP_VISIBILITY_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removePopupVisibilityListener(PopupVisibilityListener)} + **/ + @Deprecated + public void removeListener(PopupVisibilityListener listener) { + removePopupVisibilityListener(listener); + } + + /** * This event is received by the PopupVisibilityListeners when the * visibility of the popup changes. You can get the new visibility directly * with {@link #isPopupVisible()}, or get the PopupView that produced the diff --git a/server/src/com/vaadin/ui/ProgressIndicator.java b/server/src/com/vaadin/ui/ProgressIndicator.java index 528c404ab9..7558ff0e43 100644 --- a/server/src/com/vaadin/ui/ProgressIndicator.java +++ b/server/src/com/vaadin/ui/ProgressIndicator.java @@ -20,9 +20,9 @@ import java.util.Map; import com.vaadin.data.Property; import com.vaadin.data.util.ObjectProperty; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; /** * <code>ProgressIndicator</code> is component that shows user state of a @@ -38,7 +38,7 @@ import com.vaadin.terminal.Vaadin6Component; */ @SuppressWarnings("serial") public class ProgressIndicator extends AbstractField<Number> implements - Property.Viewer, Property.ValueChangeListener, Vaadin6Component { + Property.Viewer, Property.ValueChangeListener, LegacyComponent { /** * Content mode, where the label contains only plain text. The getValue() @@ -260,7 +260,7 @@ public class ProgressIndicator extends AbstractField<Number> implements @Override public void changeVariables(Object source, Map<String, Object> variables) { - // TODO Remove once Vaadin6Component is no longer implemented + // TODO Remove once LegacyComponent is no longer implemented } diff --git a/server/src/com/vaadin/ui/RichTextArea.java b/server/src/com/vaadin/ui/RichTextArea.java index 51caa82136..261701b835 100644 --- a/server/src/com/vaadin/ui/RichTextArea.java +++ b/server/src/com/vaadin/ui/RichTextArea.java @@ -19,9 +19,9 @@ package com.vaadin.ui; import java.util.Map; import com.vaadin.data.Property; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; /** * A simple RichTextArea to edit HTML format text. @@ -31,7 +31,7 @@ import com.vaadin.terminal.Vaadin6Component; * into length of field. */ public class RichTextArea extends AbstractField<String> implements - Vaadin6Component { + LegacyComponent { /** * Null representation. diff --git a/server/src/com/vaadin/ui/Select.java b/server/src/com/vaadin/ui/Select.java index 6ff7c9c9bc..ef8ba6d307 100644 --- a/server/src/com/vaadin/ui/Select.java +++ b/server/src/com/vaadin/ui/Select.java @@ -16,25 +16,9 @@ package com.vaadin.ui; -import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; import com.vaadin.data.Container; -import com.vaadin.data.util.filter.SimpleStringFilter; -import com.vaadin.event.FieldEvents; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; /** * <p> @@ -51,59 +35,10 @@ import com.vaadin.terminal.Resource; * * @author Vaadin Ltd. * @since 3.0 + * @deprecated as of 7.0. Use {@link ComboBox} instead. */ -@SuppressWarnings("serial") -public class Select extends AbstractSelect implements AbstractSelect.Filtering, - FieldEvents.BlurNotifier, FieldEvents.FocusNotifier { - - /** - * Holds value of property pageLength. 0 disables paging. - */ - protected int pageLength = 10; - - private int columns = 0; - - // Current page when the user is 'paging' trough options - private int currentPage = -1; - - private int filteringMode = FILTERINGMODE_STARTSWITH; - - private String filterstring; - private String prevfilterstring; - - /** - * Number of options that pass the filter, excluding the null item if any. - */ - private int filteredSize; - - /** - * Cache of filtered options, used only by the in-memory filtering system. - */ - private List<Object> filteredOptions; - - /** - * Flag to indicate that request repaint is called by filter request only - */ - private boolean optionRequest; - - /** - * True if the container is being filtered temporarily and item set change - * notifications should be suppressed. - */ - private boolean filteringContainer; - - /** - * Flag to indicate whether to scroll the selected item visible (select the - * page on which it is) when opening the popup or not. Only applies to - * single select mode. - * - * This requires finding the index of the item, which can be expensive in - * many large lazy loading containers. - */ - private boolean scrollToSelectedItem = true; - - /* Constructors */ - +@Deprecated +public class Select extends ComboBox { /* Component methods */ public Select() { @@ -122,652 +57,4 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, super(caption); } - /** - * Paints the content of this component. - * - * @param target - * the Paint Event. - * @throws PaintException - * if the paint operation failed. - */ - @Override - public void paintContent(PaintTarget target) throws PaintException { - if (isMultiSelect()) { - // background compatibility hack. This object shouldn't be used for - // multiselect lists anymore (ListSelect instead). This fallbacks to - // a simpler paint method in super class. - super.paintContent(target); - // Fix for #4553 - target.addAttribute("type", "legacy-multi"); - return; - } - - // clear caption change listeners - getCaptionChangeListener().clear(); - - // The tab ordering number - if (getTabIndex() != 0) { - target.addAttribute("tabindex", getTabIndex()); - } - - // If the field is modified, but not committed, set modified attribute - if (isModified()) { - target.addAttribute("modified", true); - } - - if (isNewItemsAllowed()) { - target.addAttribute("allownewitem", true); - } - - boolean needNullSelectOption = false; - if (isNullSelectionAllowed()) { - target.addAttribute("nullselect", true); - needNullSelectOption = (getNullSelectionItemId() == null); - if (!needNullSelectOption) { - target.addAttribute("nullselectitem", true); - } - } - - // Constructs selected keys array - String[] selectedKeys; - if (isMultiSelect()) { - selectedKeys = new String[((Set<?>) getValue()).size()]; - } else { - selectedKeys = new String[(getValue() == null - && getNullSelectionItemId() == null ? 0 : 1)]; - } - - target.addAttribute("pagelength", pageLength); - - target.addAttribute("filteringmode", getFilteringMode()); - - // Paints the options and create array of selected id keys - int keyIndex = 0; - - target.startTag("options"); - - if (currentPage < 0) { - optionRequest = false; - currentPage = 0; - filterstring = ""; - } - - boolean nullFilteredOut = filterstring != null - && !"".equals(filterstring) - && filteringMode != FILTERINGMODE_OFF; - // null option is needed and not filtered out, even if not on current - // page - boolean nullOptionVisible = needNullSelectOption && !nullFilteredOut; - - // first try if using container filters is possible - List<?> options = getOptionsWithFilter(nullOptionVisible); - if (null == options) { - // not able to use container filters, perform explicit in-memory - // filtering - options = getFilteredOptions(); - filteredSize = options.size(); - options = sanitetizeList(options, nullOptionVisible); - } - - final boolean paintNullSelection = needNullSelectOption - && currentPage == 0 && !nullFilteredOut; - - if (paintNullSelection) { - target.startTag("so"); - target.addAttribute("caption", ""); - target.addAttribute("key", ""); - target.endTag("so"); - } - - final Iterator<?> i = options.iterator(); - // Paints the available selection options from data source - - while (i.hasNext()) { - - final Object id = i.next(); - - if (!isNullSelectionAllowed() && id != null - && id.equals(getNullSelectionItemId()) && !isSelected(id)) { - continue; - } - - // Gets the option attribute values - final String key = itemIdMapper.key(id); - final String caption = getItemCaption(id); - final Resource icon = getItemIcon(id); - getCaptionChangeListener().addNotifierForItem(id); - - // Paints the option - target.startTag("so"); - if (icon != null) { - target.addAttribute("icon", icon); - } - target.addAttribute("caption", caption); - if (id != null && id.equals(getNullSelectionItemId())) { - target.addAttribute("nullselection", true); - } - target.addAttribute("key", key); - if (isSelected(id) && keyIndex < selectedKeys.length) { - target.addAttribute("selected", true); - selectedKeys[keyIndex++] = key; - } - target.endTag("so"); - } - target.endTag("options"); - - target.addAttribute("totalitems", size() - + (needNullSelectOption ? 1 : 0)); - if (filteredSize > 0 || nullOptionVisible) { - target.addAttribute("totalMatches", filteredSize - + (nullOptionVisible ? 1 : 0)); - } - - // Paint variables - target.addVariable(this, "selected", selectedKeys); - if (isNewItemsAllowed()) { - target.addVariable(this, "newitem", ""); - } - - target.addVariable(this, "filter", filterstring); - target.addVariable(this, "page", currentPage); - - currentPage = -1; // current page is always set by client - - optionRequest = true; - } - - /** - * Returns the filtered options for the current page using a container - * filter. - * - * As a size effect, {@link #filteredSize} is set to the total number of - * items passing the filter. - * - * The current container must be {@link Filterable} and {@link Indexed}, and - * the filtering mode must be suitable for container filtering (tested with - * {@link #canUseContainerFilter()}). - * - * Use {@link #getFilteredOptions()} and - * {@link #sanitetizeList(List, boolean)} if this is not the case. - * - * @param needNullSelectOption - * @return filtered list of options (may be empty) or null if cannot use - * container filters - */ - protected List<?> getOptionsWithFilter(boolean needNullSelectOption) { - Container container = getContainerDataSource(); - - if (pageLength == 0) { - // no paging: return all items - filteredSize = container.size(); - return new ArrayList<Object>(container.getItemIds()); - } - - if (!(container instanceof Filterable) - || !(container instanceof Indexed) - || getItemCaptionMode() != ITEM_CAPTION_MODE_PROPERTY) { - return null; - } - - Filterable filterable = (Filterable) container; - - Filter filter = buildFilter(filterstring, filteringMode); - - // adding and removing filters leads to extraneous item set - // change events from the underlying container, but the ComboBox does - // not process or propagate them based on the flag filteringContainer - if (filter != null) { - filteringContainer = true; - filterable.addContainerFilter(filter); - } - - Indexed indexed = (Indexed) container; - - int indexToEnsureInView = -1; - - // if not an option request (item list when user changes page), go - // to page with the selected item after filtering if accepted by - // filter - Object selection = getValue(); - if (isScrollToSelectedItem() && !optionRequest && !isMultiSelect() - && selection != null) { - // ensure proper page - indexToEnsureInView = indexed.indexOfId(selection); - } - - filteredSize = container.size(); - currentPage = adjustCurrentPage(currentPage, needNullSelectOption, - indexToEnsureInView, filteredSize); - int first = getFirstItemIndexOnCurrentPage(needNullSelectOption, - filteredSize); - int last = getLastItemIndexOnCurrentPage(needNullSelectOption, - filteredSize, first); - - List<Object> options = new ArrayList<Object>(); - for (int i = first; i <= last && i < filteredSize; ++i) { - options.add(indexed.getIdByIndex(i)); - } - - // to the outside, filtering should not be visible - if (filter != null) { - filterable.removeContainerFilter(filter); - filteringContainer = false; - } - - return options; - } - - /** - * Constructs a filter instance to use when using a Filterable container in - * the <code>ITEM_CAPTION_MODE_PROPERTY</code> mode. - * - * Note that the client side implementation expects the filter string to - * apply to the item caption string it sees, so changing the behavior of - * this method can cause problems. - * - * @param filterString - * @param filteringMode - * @return - */ - protected Filter buildFilter(String filterString, int filteringMode) { - Filter filter = null; - - if (null != filterString && !"".equals(filterString)) { - switch (filteringMode) { - case FILTERINGMODE_OFF: - break; - case FILTERINGMODE_STARTSWITH: - filter = new SimpleStringFilter(getItemCaptionPropertyId(), - filterString, true, true); - break; - case FILTERINGMODE_CONTAINS: - filter = new SimpleStringFilter(getItemCaptionPropertyId(), - filterString, true, false); - break; - } - } - return filter; - } - - @Override - public void containerItemSetChange(Container.ItemSetChangeEvent event) { - if (!filteringContainer) { - super.containerItemSetChange(event); - } - } - - /** - * Makes correct sublist of given list of options. - * - * If paint is not an option request (affected by page or filter change), - * page will be the one where possible selection exists. - * - * Detects proper first and last item in list to return right page of - * options. Also, if the current page is beyond the end of the list, it will - * be adjusted. - * - * @param options - * @param needNullSelectOption - * flag to indicate if nullselect option needs to be taken into - * consideration - */ - private List<?> sanitetizeList(List<?> options, boolean needNullSelectOption) { - - if (pageLength != 0 && options.size() > pageLength) { - - int indexToEnsureInView = -1; - - // if not an option request (item list when user changes page), go - // to page with the selected item after filtering if accepted by - // filter - Object selection = getValue(); - if (isScrollToSelectedItem() && !optionRequest && !isMultiSelect() - && selection != null) { - // ensure proper page - indexToEnsureInView = options.indexOf(selection); - } - - int size = options.size(); - currentPage = adjustCurrentPage(currentPage, needNullSelectOption, - indexToEnsureInView, size); - int first = getFirstItemIndexOnCurrentPage(needNullSelectOption, - size); - int last = getLastItemIndexOnCurrentPage(needNullSelectOption, - size, first); - return options.subList(first, last + 1); - } else { - return options; - } - } - - /** - * Returns the index of the first item on the current page. The index is to - * the underlying (possibly filtered) contents. The null item, if any, does - * not have an index but takes up a slot on the first page. - * - * @param needNullSelectOption - * true if a null option should be shown before any other options - * (takes up the first slot on the first page, not counted in - * index) - * @param size - * number of items after filtering (not including the null item, - * if any) - * @return first item to show on the UI (index to the filtered list of - * options, not taking the null item into consideration if any) - */ - private int getFirstItemIndexOnCurrentPage(boolean needNullSelectOption, - int size) { - // Not all options are visible, find out which ones are on the - // current "page". - int first = currentPage * pageLength; - if (needNullSelectOption && currentPage > 0) { - first--; - } - return first; - } - - /** - * Returns the index of the last item on the current page. The index is to - * the underlying (possibly filtered) contents. If needNullSelectOption is - * true, the null item takes up the first slot on the first page, - * effectively reducing the first page size by one. - * - * @param needNullSelectOption - * true if a null option should be shown before any other options - * (takes up the first slot on the first page, not counted in - * index) - * @param size - * number of items after filtering (not including the null item, - * if any) - * @param first - * index in the filtered view of the first item of the page - * @return index in the filtered view of the last item on the page - */ - private int getLastItemIndexOnCurrentPage(boolean needNullSelectOption, - int size, int first) { - // page length usable for non-null items - int effectivePageLength = pageLength - - (needNullSelectOption && (currentPage == 0) ? 1 : 0); - return Math.min(size - 1, first + effectivePageLength - 1); - } - - /** - * Adjusts the index of the current page if necessary: make sure the current - * page is not after the end of the contents, and optionally go to the page - * containg a specific item. There are no side effects but the adjusted page - * index is returned. - * - * @param page - * page number to use as the starting point - * @param needNullSelectOption - * true if a null option should be shown before any other options - * (takes up the first slot on the first page, not counted in - * index) - * @param indexToEnsureInView - * index of an item that should be included on the page (in the - * data set, not counting the null item if any), -1 for none - * @param size - * number of items after filtering (not including the null item, - * if any) - */ - private int adjustCurrentPage(int page, boolean needNullSelectOption, - int indexToEnsureInView, int size) { - if (indexToEnsureInView != -1) { - int newPage = (indexToEnsureInView + (needNullSelectOption ? 1 : 0)) - / pageLength; - page = newPage; - } - // adjust the current page if beyond the end of the list - if (page * pageLength > size) { - page = (size + (needNullSelectOption ? 1 : 0)) / pageLength; - } - return page; - } - - /** - * Filters the options in memory and returns the full filtered list. - * - * This can be less efficient than using container filters, so use - * {@link #getOptionsWithFilter(boolean)} if possible (filterable container - * and suitable item caption mode etc.). - * - * @return - */ - protected List<?> getFilteredOptions() { - if (null == filterstring || "".equals(filterstring) - || FILTERINGMODE_OFF == filteringMode) { - prevfilterstring = null; - filteredOptions = new LinkedList<Object>(getItemIds()); - return filteredOptions; - } - - if (filterstring.equals(prevfilterstring)) { - return filteredOptions; - } - - Collection<?> items; - if (prevfilterstring != null - && filterstring.startsWith(prevfilterstring)) { - items = filteredOptions; - } else { - items = getItemIds(); - } - prevfilterstring = filterstring; - - filteredOptions = new LinkedList<Object>(); - for (final Iterator<?> it = items.iterator(); it.hasNext();) { - final Object itemId = it.next(); - String caption = getItemCaption(itemId); - if (caption == null || caption.equals("")) { - continue; - } else { - caption = caption.toLowerCase(); - } - switch (filteringMode) { - case FILTERINGMODE_CONTAINS: - if (caption.indexOf(filterstring) > -1) { - filteredOptions.add(itemId); - } - break; - case FILTERINGMODE_STARTSWITH: - default: - if (caption.startsWith(filterstring)) { - filteredOptions.add(itemId); - } - break; - } - } - - return filteredOptions; - } - - /** - * Invoked when the value of a variable has changed. - * - * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, - * java.util.Map) - */ - @Override - public void changeVariables(Object source, Map<String, Object> variables) { - // Not calling super.changeVariables due the history of select - // component hierarchy - - // Selection change - if (variables.containsKey("selected")) { - final String[] ka = (String[]) variables.get("selected"); - - if (isMultiSelect()) { - // Multiselect mode - - // TODO Optimize by adding repaintNotNeeded whan applicaple - - // Converts the key-array to id-set - final LinkedList<Object> s = new LinkedList<Object>(); - for (int i = 0; i < ka.length; i++) { - final Object id = itemIdMapper.get(ka[i]); - if (id != null && containsId(id)) { - s.add(id); - } - } - - // Limits the deselection to the set of visible items - // (non-visible items can not be deselected) - final Collection<?> visible = getVisibleItemIds(); - if (visible != null) { - @SuppressWarnings("unchecked") - Set<Object> newsel = (Set<Object>) getValue(); - if (newsel == null) { - newsel = new HashSet<Object>(); - } else { - newsel = new HashSet<Object>(newsel); - } - newsel.removeAll(visible); - newsel.addAll(s); - setValue(newsel, true); - } - } else { - // Single select mode - if (ka.length == 0) { - - // Allows deselection only if the deselected item is visible - final Object current = getValue(); - final Collection<?> visible = getVisibleItemIds(); - if (visible != null && visible.contains(current)) { - setValue(null, true); - } - } else { - final Object id = itemIdMapper.get(ka[0]); - if (id != null && id.equals(getNullSelectionItemId())) { - setValue(null, true); - } else { - setValue(id, true); - } - } - } - } - - String newFilter; - if ((newFilter = (String) variables.get("filter")) != null) { - // this is a filter request - currentPage = ((Integer) variables.get("page")).intValue(); - filterstring = newFilter; - if (filterstring != null) { - filterstring = filterstring.toLowerCase(); - } - requestRepaint(); - } else if (isNewItemsAllowed()) { - // New option entered (and it is allowed) - final String newitem = (String) variables.get("newitem"); - if (newitem != null && newitem.length() > 0) { - getNewItemHandler().addNewItem(newitem); - // rebuild list - filterstring = null; - prevfilterstring = null; - } - } - - if (variables.containsKey(FocusEvent.EVENT_ID)) { - fireEvent(new FocusEvent(this)); - } - if (variables.containsKey(BlurEvent.EVENT_ID)) { - fireEvent(new BlurEvent(this)); - } - - } - - @Override - @Deprecated - public void requestRepaint() { - markAsDirty(); - } - - @Override - public void setFilteringMode(int filteringMode) { - this.filteringMode = filteringMode; - } - - @Override - public int getFilteringMode() { - return filteringMode; - } - - @Override - public void addListener(BlurListener listener) { - addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, - BlurListener.blurMethod); - } - - @Override - public void removeListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override - public void addListener(FocusListener listener) { - addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, - FocusListener.focusMethod); - } - - @Override - public void removeListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - - } - - /** - * @deprecated use {@link ListSelect}, {@link OptionGroup} or - * {@link TwinColSelect} instead - * @see com.vaadin.ui.AbstractSelect#setMultiSelect(boolean) - * @throws UnsupportedOperationException - * if trying to activate multiselect mode - */ - @Deprecated - @Override - public void setMultiSelect(boolean multiSelect) { - if (multiSelect) { - throw new UnsupportedOperationException("Multiselect not supported"); - } - } - - /** - * @deprecated use {@link ListSelect}, {@link OptionGroup} or - * {@link TwinColSelect} instead - * - * @see com.vaadin.ui.AbstractSelect#isMultiSelect() - */ - @Deprecated - @Override - public boolean isMultiSelect() { - return super.isMultiSelect(); - } - - /** - * Sets whether to scroll the selected item visible (directly open the page - * on which it is) when opening the combo box popup or not. Only applies to - * single select mode. - * - * This requires finding the index of the item, which can be expensive in - * many large lazy loading containers. - * - * @param scrollToSelectedItem - * true to find the page with the selected item when opening the - * selection popup - */ - public void setScrollToSelectedItem(boolean scrollToSelectedItem) { - this.scrollToSelectedItem = scrollToSelectedItem; - } - - /** - * Returns true if the select should find the page with the selected item - * when opening the popup (single select combo box only). - * - * @see #setScrollToSelectedItem(boolean) - * - * @return true if the page with the selected item will be shown when - * opening the popup - */ - public boolean isScrollToSelectedItem() { - return scrollToSelectedItem; - } - } diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java index 82faedcc41..eb66de519f 100644 --- a/server/src/com/vaadin/ui/TabSheet.java +++ b/server/src/com/vaadin/ui/TabSheet.java @@ -30,15 +30,15 @@ import com.vaadin.event.FieldEvents.BlurNotifier; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.FieldEvents.FocusNotifier; +import com.vaadin.server.ErrorMessage; +import com.vaadin.server.KeyMapper; +import com.vaadin.server.LegacyPaint; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.tabsheet.TabsheetBaseConstants; import com.vaadin.shared.ui.tabsheet.TabsheetConstants; -import com.vaadin.terminal.ErrorMessage; -import com.vaadin.terminal.KeyMapper; -import com.vaadin.terminal.LegacyPaint; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Vaadin6Component; import com.vaadin.ui.Component.Focusable; import com.vaadin.ui.themes.Reindeer; import com.vaadin.ui.themes.Runo; @@ -71,7 +71,7 @@ import com.vaadin.ui.themes.Runo; * @since 3.0 */ public class TabSheet extends AbstractComponentContainer implements Focusable, - FocusNotifier, BlurNotifier, Vaadin6Component { + FocusNotifier, BlurNotifier, LegacyComponent { /** * List of component tabs (tab contents). In addition to being on this list, @@ -791,23 +791,42 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * @param listener * the Listener to be added. */ - public void addListener(SelectedTabChangeListener listener) { + public void addSelectedTabChangeListener(SelectedTabChangeListener listener) { addListener(SelectedTabChangeEvent.class, listener, SELECTED_TAB_CHANGE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addSelectedTabChangeListener(SelectedTabChangeListener)} + **/ + @Deprecated + public void addListener(SelectedTabChangeListener listener) { + addSelectedTabChangeListener(listener); + } + + /** * Removes a tab selection listener * * @param listener * the Listener to be removed. */ - public void removeListener(SelectedTabChangeListener listener) { + public void removeSelectedTabChangeListener( + SelectedTabChangeListener listener) { removeListener(SelectedTabChangeEvent.class, listener, SELECTED_TAB_CHANGE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeSelectedTabChangeListener(SelectedTabChangeListener)} + **/ + @Deprecated + public void removeListener(SelectedTabChangeListener listener) { + removeSelectedTabChangeListener(listener); + } + + /** * Sends an event that the currently selected tab has changed. */ protected void fireSelectedTabChange() { @@ -1211,26 +1230,60 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, } @Override - public void addListener(BlurListener listener) { + public void addBlurListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } + /** + * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} + **/ + @Deprecated + public void addListener(BlurListener listener) { + addBlurListener(listener); + } + @Override - public void removeListener(BlurListener listener) { + public void removeBlurListener(BlurListener listener) { removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated + public void removeListener(BlurListener listener) { + removeBlurListener(listener); + } + @Override - public void addListener(FocusListener listener) { + public void addFocusListener(FocusListener listener) { addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated + public void addListener(FocusListener listener) { + addFocusListener(listener); + } + @Override - public void removeListener(FocusListener listener) { + public void removeFocusListener(FocusListener listener) { removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); + } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated + public void removeListener(FocusListener listener) { + removeFocusListener(listener); } @Override diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 8fc3fc2572..d1bdcdd708 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -52,13 +52,13 @@ import com.vaadin.event.dd.DragSource; import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropTarget; import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion; +import com.vaadin.server.KeyMapper; +import com.vaadin.server.LegacyPaint; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.table.TableConstants; -import com.vaadin.terminal.KeyMapper; -import com.vaadin.terminal.LegacyPaint; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; /** * <p> @@ -4575,17 +4575,35 @@ public class Table extends AbstractSelect implements Action.Container, } @Override - public void addListener(ItemClickListener listener) { + public void addItemClickListener(ItemClickListener listener) { addListener(TableConstants.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener, ItemClickEvent.ITEM_CLICK_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addItemClickListener(ItemClickListener)} + **/ + @Deprecated + public void addListener(ItemClickListener listener) { + addItemClickListener(listener); + } + @Override - public void removeListener(ItemClickListener listener) { + public void removeItemClickListener(ItemClickListener listener) { removeListener(TableConstants.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemClickListener(ItemClickListener)} + **/ + @Deprecated + public void removeListener(ItemClickListener listener) { + removeItemClickListener(listener); + } + // Identical to AbstractCompoenentContainer.setEnabled(); @Override @@ -4759,7 +4777,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @see * com.vaadin.event.dd.acceptcriteria.AcceptCriterion#paintResponse( - * com.vaadin.terminal.PaintTarget) + * com.vaadin.server.PaintTarget) */ @Override @@ -4926,24 +4944,42 @@ public class Table extends AbstractSelect implements Action.Container, * @param listener * The handler which should handle the header click events. */ - public void addListener(HeaderClickListener listener) { + public void addHeaderClickListener(HeaderClickListener listener) { addListener(TableConstants.HEADER_CLICK_EVENT_ID, HeaderClickEvent.class, listener, HeaderClickEvent.HEADER_CLICK_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addHeaderClickListener(HeaderClickListener)} + **/ + @Deprecated + public void addListener(HeaderClickListener listener) { + addHeaderClickListener(listener); + } + + /** * Removes a header click listener * * @param listener * The listener to remove. */ - public void removeListener(HeaderClickListener listener) { + public void removeHeaderClickListener(HeaderClickListener listener) { removeListener(TableConstants.HEADER_CLICK_EVENT_ID, HeaderClickEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeHeaderClickListener(HeaderClickListener)} + **/ + @Deprecated + public void removeListener(HeaderClickListener listener) { + removeHeaderClickListener(listener); + } + + /** * Adds a footer click listener which handles the click events when the user * clicks on a column footer cell in the Table. * <p> @@ -4954,24 +4990,42 @@ public class Table extends AbstractSelect implements Action.Container, * @param listener * The handler which should handle the footer click events. */ - public void addListener(FooterClickListener listener) { + public void addFooterClickListener(FooterClickListener listener) { addListener(TableConstants.FOOTER_CLICK_EVENT_ID, FooterClickEvent.class, listener, FooterClickEvent.FOOTER_CLICK_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addFooterClickListener(FooterClickListener)} + **/ + @Deprecated + public void addListener(FooterClickListener listener) { + addFooterClickListener(listener); + } + + /** * Removes a footer click listener * * @param listener * The listener to remove. */ - public void removeListener(FooterClickListener listener) { + public void removeFooterClickListener(FooterClickListener listener) { removeListener(TableConstants.FOOTER_CLICK_EVENT_ID, FooterClickEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeFooterClickListener(FooterClickListener)} + **/ + @Deprecated + public void removeListener(FooterClickListener listener) { + removeFooterClickListener(listener); + } + + /** * Gets the footer caption beneath the rows * * @param propertyId @@ -5122,24 +5176,42 @@ public class Table extends AbstractSelect implements Action.Container, * @param listener * The listener to attach to the Table */ - public void addListener(ColumnResizeListener listener) { + public void addColumnResizeListener(ColumnResizeListener listener) { addListener(TableConstants.COLUMN_RESIZE_EVENT_ID, ColumnResizeEvent.class, listener, ColumnResizeEvent.COLUMN_RESIZE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addColumnResizeListener(ColumnResizeListener)} + **/ + @Deprecated + public void addListener(ColumnResizeListener listener) { + addColumnResizeListener(listener); + } + + /** * Removes a column resize listener from the Table. * * @param listener * The listener to remove */ - public void removeListener(ColumnResizeListener listener) { + public void removeColumnResizeListener(ColumnResizeListener listener) { removeListener(TableConstants.COLUMN_RESIZE_EVENT_ID, ColumnResizeEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeColumnResizeListener(ColumnResizeListener)} + **/ + @Deprecated + public void removeListener(ColumnResizeListener listener) { + removeColumnResizeListener(listener); + } + + /** * This event is fired when a columns are reordered by the end user user. */ public static class ColumnReorderEvent extends Component.Event { @@ -5188,23 +5260,41 @@ public class Table extends AbstractSelect implements Action.Container, * @param listener * The listener to attach to the Table */ - public void addListener(ColumnReorderListener listener) { + public void addColumnReorderListener(ColumnReorderListener listener) { addListener(TableConstants.COLUMN_REORDER_EVENT_ID, ColumnReorderEvent.class, listener, ColumnReorderEvent.METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addColumnReorderListener(ColumnReorderListener)} + **/ + @Deprecated + public void addListener(ColumnReorderListener listener) { + addColumnReorderListener(listener); + } + + /** * Removes a column reorder listener from the Table. * * @param listener * The listener to remove */ - public void removeListener(ColumnReorderListener listener) { + public void removeColumnReorderListener(ColumnReorderListener listener) { removeListener(TableConstants.COLUMN_REORDER_EVENT_ID, ColumnReorderEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeColumnReorderListener(ColumnReorderListener)} + **/ + @Deprecated + public void removeListener(ColumnReorderListener listener) { + removeColumnReorderListener(listener); + } + + /** * Set the item description generator which generates tooltips for cells and * rows in the Table * diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index 2d6673a67d..9cf1aa3511 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -49,13 +49,13 @@ import com.vaadin.event.dd.TargetDetails; import com.vaadin.event.dd.acceptcriteria.ClientSideCriterion; import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion; import com.vaadin.event.dd.acceptcriteria.TargetDetailIs; +import com.vaadin.server.KeyMapper; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.shared.ui.tree.TreeConstants; -import com.vaadin.terminal.KeyMapper; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; import com.vaadin.tools.ReflectTools; /** @@ -906,22 +906,40 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @param listener * the Listener to be added. */ - public void addListener(ExpandListener listener) { + public void addExpandListener(ExpandListener listener) { addListener(ExpandEvent.class, listener, ExpandListener.EXPAND_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addExpandListener(ExpandListener)} + **/ + @Deprecated + public void addListener(ExpandListener listener) { + addExpandListener(listener); + } + + /** * Removes the expand listener. * * @param listener * the Listener to be removed. */ - public void removeListener(ExpandListener listener) { + public void removeExpandListener(ExpandListener listener) { removeListener(ExpandEvent.class, listener, ExpandListener.EXPAND_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeExpandListener(ExpandListener)} + **/ + @Deprecated + public void removeListener(ExpandListener listener) { + removeExpandListener(listener); + } + + /** * Emits the expand event. * * @param itemId @@ -991,23 +1009,41 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @param listener * the Listener to be added. */ - public void addListener(CollapseListener listener) { + public void addCollapseListener(CollapseListener listener) { addListener(CollapseEvent.class, listener, CollapseListener.COLLAPSE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addCollapseListener(CollapseListener)} + **/ + @Deprecated + public void addListener(CollapseListener listener) { + addCollapseListener(listener); + } + + /** * Removes the collapse listener. * * @param listener * the Listener to be removed. */ - public void removeListener(CollapseListener listener) { + public void removeCollapseListener(CollapseListener listener) { removeListener(CollapseEvent.class, listener, CollapseListener.COLLAPSE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeCollapseListener(CollapseListener)} + **/ + @Deprecated + public void removeListener(CollapseListener listener) { + removeCollapseListener(listener); + } + + /** * Emits collapse event. * * @param itemId @@ -1162,18 +1198,36 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, private DropHandler dropHandler; @Override - public void addListener(ItemClickListener listener) { + public void addItemClickListener(ItemClickListener listener) { addListener(TreeConstants.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener, ItemClickEvent.ITEM_CLICK_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addItemClickListener(ItemClickListener)} + **/ + @Deprecated + public void addListener(ItemClickListener listener) { + addItemClickListener(listener); + } + @Override - public void removeListener(ItemClickListener listener) { + public void removeItemClickListener(ItemClickListener listener) { removeListener(TreeConstants.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeItemClickListener(ItemClickListener)} + **/ + @Deprecated + public void removeListener(ItemClickListener listener) { + removeItemClickListener(listener); + } + + /** * Sets the {@link ItemStyleGenerator} to be used with this tree. * * @param itemStyleGenerator @@ -1449,7 +1503,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see * com.vaadin.event.dd.acceptCriteria.AcceptCriterion#paintResponse( - * com.vaadin.terminal.PaintTarget) + * com.vaadin.server.PaintTarget) */ @Override public void paintResponse(PaintTarget target) throws PaintException { diff --git a/server/src/com/vaadin/ui/TreeTable.java b/server/src/com/vaadin/ui/TreeTable.java index 05757a6d09..ef5850a8af 100644 --- a/server/src/com/vaadin/ui/TreeTable.java +++ b/server/src/com/vaadin/ui/TreeTable.java @@ -32,10 +32,10 @@ import com.vaadin.data.Container.ItemSetChangeEvent; import com.vaadin.data.util.ContainerHierarchicalWrapper; import com.vaadin.data.util.HierarchicalContainer; import com.vaadin.data.util.HierarchicalContainerOrderedWrapper; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; import com.vaadin.shared.ui.treetable.TreeTableConstants; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; import com.vaadin.ui.Tree.CollapseEvent; import com.vaadin.ui.Tree.CollapseListener; import com.vaadin.ui.Tree.ExpandEvent; @@ -752,22 +752,40 @@ public class TreeTable extends Table implements Hierarchical { * @param listener * the Listener to be added. */ - public void addListener(ExpandListener listener) { + public void addExpandListener(ExpandListener listener) { addListener(ExpandEvent.class, listener, ExpandListener.EXPAND_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addExpandListener(ExpandListener)} + **/ + @Deprecated + public void addListener(ExpandListener listener) { + addExpandListener(listener); + } + + /** * Removes an expand listener. * * @param listener * the Listener to be removed. */ - public void removeListener(ExpandListener listener) { + public void removeExpandListener(ExpandListener listener) { removeListener(ExpandEvent.class, listener, ExpandListener.EXPAND_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeExpandListener(ExpandListener)} + **/ + @Deprecated + public void removeListener(ExpandListener listener) { + removeExpandListener(listener); + } + + /** * Emits an expand event. * * @param itemId @@ -783,23 +801,41 @@ public class TreeTable extends Table implements Hierarchical { * @param listener * the Listener to be added. */ - public void addListener(CollapseListener listener) { + public void addCollapseListener(CollapseListener listener) { addListener(CollapseEvent.class, listener, CollapseListener.COLLAPSE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addCollapseListener(CollapseListener)} + **/ + @Deprecated + public void addListener(CollapseListener listener) { + addCollapseListener(listener); + } + + /** * Removes a collapse listener. * * @param listener * the Listener to be removed. */ - public void removeListener(CollapseListener listener) { + public void removeCollapseListener(CollapseListener listener) { removeListener(CollapseEvent.class, listener, CollapseListener.COLLAPSE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeCollapseListener(CollapseListener)} + **/ + @Deprecated + public void removeListener(CollapseListener listener) { + removeCollapseListener(listener); + } + + /** * Emits a collapse event. * * @param itemId diff --git a/server/src/com/vaadin/ui/TwinColSelect.java b/server/src/com/vaadin/ui/TwinColSelect.java index 891e695a5f..76f1e1e8c7 100644 --- a/server/src/com/vaadin/ui/TwinColSelect.java +++ b/server/src/com/vaadin/ui/TwinColSelect.java @@ -19,9 +19,9 @@ package com.vaadin.ui; import java.util.Collection; import com.vaadin.data.Container; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; import com.vaadin.shared.ui.twincolselect.TwinColSelectConstants; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; /** * Multiselect component with two lists: left side for available items and right diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 17a028bcdf..a59b96d27a 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -34,22 +34,22 @@ import com.vaadin.event.Action.Handler; import com.vaadin.event.ActionManager; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.server.AbstractApplicationServlet; +import com.vaadin.server.Page; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.Resource; +import com.vaadin.server.LegacyComponent; +import com.vaadin.server.WrappedRequest; +import com.vaadin.server.Page.BrowserWindowResizeEvent; +import com.vaadin.server.Page.BrowserWindowResizeListener; +import com.vaadin.server.WrappedRequest.BrowserDetails; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.shared.ui.ui.UIServerRpc; import com.vaadin.shared.ui.ui.UIState; -import com.vaadin.terminal.Page; -import com.vaadin.terminal.Page.BrowserWindowResizeEvent; -import com.vaadin.terminal.Page.BrowserWindowResizeListener; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Vaadin6Component; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedRequest.BrowserDetails; -import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; import com.vaadin.tools.ReflectTools; /** @@ -90,7 +90,7 @@ import com.vaadin.tools.ReflectTools; * @since 7.0 */ public abstract class UI extends AbstractComponentContainer implements - Action.Container, Action.Notifier, Vaadin6Component { + Action.Container, Action.Notifier, LegacyComponent { /** * Helper class to emulate the main window from Vaadin 6 using UIs. This @@ -1094,45 +1094,39 @@ public abstract class UI extends AbstractComponentContainer implements * @param listener * The listener to add */ - public void addListener(ClickListener listener) { + public void addClickListener(ClickListener listener) { addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener, ClickListener.clickMethod); } /** + * @deprecated Since 7.0, replaced by + * {@link #addClickListener(ClickListener)} + **/ + @Deprecated + public void addListener(ClickListener listener) { + addClickListener(listener); + } + + /** * Remove a click listener from the UI. The listener should earlier have * been added using {@link #addListener(ClickListener)}. * * @param listener * The listener to remove */ - public void removeListener(ClickListener listener) { + public void removeClickListener(ClickListener listener) { removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener); } /** - * Adds a close listener to the UI. The listener is called when the UI is - * removed from the application. - * - * @param listener - * The listener to add. - */ - public void addListener(CloseListener listener) { - addListener(CloseEvent.CLOSE_EVENT_IDENTIFIER, CloseEvent.class, - listener, CloseListener.closeMethod); - } - - /** - * Removes a close listener from the UI if it has previously been added with - * {@link #addListener(ClickListener)}. Otherwise, has no effect. - * - * @param listener - * The listener to remove. - */ - public void removeListener(CloseListener listener) { - removeListener(CloseEvent.CLOSE_EVENT_IDENTIFIER, CloseEvent.class, - listener); + * @deprecated Since 7.0, replaced by + * {@link #removeClickListener(ClickListener)} + **/ + @Deprecated + public void removeListener(ClickListener listener) { + removeClickListener(listener); } @Override diff --git a/server/src/com/vaadin/ui/Upload.java b/server/src/com/vaadin/ui/Upload.java index 619db07eea..2323b22e17 100644 --- a/server/src/com/vaadin/ui/Upload.java +++ b/server/src/com/vaadin/ui/Upload.java @@ -24,12 +24,12 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.StreamVariable.StreamingProgressEvent; -import com.vaadin.terminal.Vaadin6Component; -import com.vaadin.terminal.gwt.server.NoInputStreamException; -import com.vaadin.terminal.gwt.server.NoOutputStreamException; +import com.vaadin.server.NoInputStreamException; +import com.vaadin.server.NoOutputStreamException; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; +import com.vaadin.server.StreamVariable.StreamingProgressEvent; /** * Component for uploading files from client to server. @@ -71,7 +71,7 @@ import com.vaadin.terminal.gwt.server.NoOutputStreamException; */ @SuppressWarnings("serial") public class Upload extends AbstractComponent implements Component.Focusable, - Vaadin6Component { + LegacyComponent { /** * Should the field be focused on next repaint? @@ -570,87 +570,159 @@ public class Upload extends AbstractComponent implements Component.Focusable, * @param listener * the Listener to be added. */ - public void addListener(StartedListener listener) { + public void addStartedListener(StartedListener listener) { addListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addStartedListener(StartedListener)} + **/ + @Deprecated + public void addListener(StartedListener listener) { + addStartedListener(listener); + } + + /** * Removes the upload started event listener. * * @param listener * the Listener to be removed. */ - public void removeListener(StartedListener listener) { + public void removeStartedListener(StartedListener listener) { removeListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeStartedListener(StartedListener)} + **/ + @Deprecated + public void removeListener(StartedListener listener) { + removeStartedListener(listener); + } + + /** * Adds the upload received event listener. * * @param listener * the Listener to be added. */ - public void addListener(FinishedListener listener) { + public void addFinishedListener(FinishedListener listener) { addListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addFinishedListener(FinishedListener)} + **/ + @Deprecated + public void addListener(FinishedListener listener) { + addFinishedListener(listener); + } + + /** * Removes the upload received event listener. * * @param listener * the Listener to be removed. */ - public void removeListener(FinishedListener listener) { + public void removeFinishedListener(FinishedListener listener) { removeListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeFinishedListener(FinishedListener)} + **/ + @Deprecated + public void removeListener(FinishedListener listener) { + removeFinishedListener(listener); + } + + /** * Adds the upload interrupted event listener. * * @param listener * the Listener to be added. */ - public void addListener(FailedListener listener) { + public void addFailedListener(FailedListener listener) { addListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addFailedListener(FailedListener)} + **/ + @Deprecated + public void addListener(FailedListener listener) { + addFailedListener(listener); + } + + /** * Removes the upload interrupted event listener. * * @param listener * the Listener to be removed. */ - public void removeListener(FailedListener listener) { + public void removeFailedListener(FailedListener listener) { removeListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeFailedListener(FailedListener)} + **/ + @Deprecated + public void removeListener(FailedListener listener) { + removeFailedListener(listener); + } + + /** * Adds the upload success event listener. * * @param listener * the Listener to be added. */ - public void addListener(SucceededListener listener) { + public void addSucceededListener(SucceededListener listener) { addListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addSucceededListener(SucceededListener)} + **/ + @Deprecated + public void addListener(SucceededListener listener) { + addSucceededListener(listener); + } + + /** * Removes the upload success event listener. * * @param listener * the Listener to be removed. */ - public void removeListener(SucceededListener listener) { + public void removeSucceededListener(SucceededListener listener) { removeListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeSucceededListener(SucceededListener)} + **/ + @Deprecated + public void removeListener(SucceededListener listener) { + removeSucceededListener(listener); + } + + /** * Adds the upload success event listener. * * @param listener * the Listener to be added. */ - public void addListener(ProgressListener listener) { + public void addProgressListener(ProgressListener listener) { if (progressListeners == null) { progressListeners = new LinkedHashSet<ProgressListener>(); } @@ -658,18 +730,36 @@ public class Upload extends AbstractComponent implements Component.Focusable, } /** + * @deprecated Since 7.0, replaced by + * {@link #addProgressListener(ProgressListener)} + **/ + @Deprecated + public void addListener(ProgressListener listener) { + addProgressListener(listener); + } + + /** * Removes the upload success event listener. * * @param listener * the Listener to be removed. */ - public void removeListener(ProgressListener listener) { + public void removeProgressListener(ProgressListener listener) { if (progressListeners != null) { progressListeners.remove(listener); } } /** + * @deprecated Since 7.0, replaced by + * {@link #removeProgressListener(ProgressListener)} + **/ + @Deprecated + public void removeListener(ProgressListener listener) { + removeProgressListener(listener); + } + + /** * Emit upload received event. * * @param filename @@ -936,11 +1026,11 @@ public class Upload extends AbstractComponent implements Component.Focusable, * Handle to terminal via Upload monitors and controls the upload during it * is being streamed. */ - private com.vaadin.terminal.StreamVariable streamVariable; + private com.vaadin.server.StreamVariable streamVariable; - protected com.vaadin.terminal.StreamVariable getStreamVariable() { + protected com.vaadin.server.StreamVariable getStreamVariable() { if (streamVariable == null) { - streamVariable = new com.vaadin.terminal.StreamVariable() { + streamVariable = new com.vaadin.server.StreamVariable() { private StreamingStartEvent lastStartedEvent; @Override diff --git a/server/src/com/vaadin/ui/Video.java b/server/src/com/vaadin/ui/Video.java index b54d404da6..2d83538d57 100644 --- a/server/src/com/vaadin/ui/Video.java +++ b/server/src/com/vaadin/ui/Video.java @@ -16,9 +16,9 @@ package com.vaadin.ui; +import com.vaadin.server.Resource; +import com.vaadin.shared.ui.video.VideoConstants; import com.vaadin.shared.ui.video.VideoState; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.gwt.server.ResourceReference; /** * The Video component translates into an HTML5 <video> element and as @@ -79,14 +79,14 @@ public class Video extends AbstractMedia { * @param poster */ public void setPoster(Resource poster) { - getState().setPoster(ResourceReference.create(poster)); + setResource(VideoConstants.POSTER_RESOURCE, poster); } /** * @return The poster image. */ public Resource getPoster() { - return ResourceReference.getResource(getState().getPoster()); + return getResource(VideoConstants.POSTER_RESOURCE); } } diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 6102350566..aaf0fbc492 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -31,12 +31,12 @@ import com.vaadin.event.ShortcutAction; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.event.ShortcutListener; +import com.vaadin.server.PaintException; +import com.vaadin.server.PaintTarget; +import com.vaadin.server.LegacyComponent; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.window.WindowServerRpc; import com.vaadin.shared.ui.window.WindowState; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; /** * A component that represents a floating popup window that can be added to a @@ -65,7 +65,7 @@ import com.vaadin.terminal.Vaadin6Component; */ @SuppressWarnings("serial") public class Window extends Panel implements FocusNotifier, BlurNotifier, - Vaadin6Component { + LegacyComponent { private WindowServerRpc rpc = new WindowServerRpc() { @@ -127,7 +127,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, /* * (non-Javadoc) * - * @see com.vaadin.ui.Panel#paintContent(com.vaadin.terminal.PaintTarget) + * @see com.vaadin.ui.Panel#paintContent(com.vaadin.server.PaintTarget) */ @Override @@ -362,11 +362,20 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @param listener * the CloseListener to add. */ - public void addListener(CloseListener listener) { + public void addCloseListener(CloseListener listener) { addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addCloseListener(CloseListener)} + **/ + @Deprecated + public void addListener(CloseListener listener) { + addCloseListener(listener); + } + + /** * Removes the CloseListener from the window. * * <p> @@ -376,10 +385,19 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @param listener * the CloseListener to remove. */ - public void removeListener(CloseListener listener) { + public void removeCloseListener(CloseListener listener) { removeListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD); } + /** + * @deprecated Since 7.0, replaced by + * {@link #removeCloseListener(CloseListener)} + **/ + @Deprecated + public void removeListener(CloseListener listener) { + removeCloseListener(listener); + } + protected void fireClose() { fireEvent(new Window.CloseEvent(this)); } @@ -438,20 +456,38 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * * @param listener */ - public void addListener(ResizeListener listener) { + public void addResizeListener(ResizeListener listener) { addListener(ResizeEvent.class, listener, WINDOW_RESIZE_METHOD); } /** + * @deprecated Since 7.0, replaced by + * {@link #addResizeListener(ResizeListener)} + **/ + @Deprecated + public void addListener(ResizeListener listener) { + addResizeListener(listener); + } + + /** * Remove a resize listener. * * @param listener */ - public void removeListener(ResizeListener listener) { + public void removeResizeListener(ResizeListener listener) { removeListener(ResizeEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeResizeListener(ResizeListener)} + **/ + @Deprecated + public void removeListener(ResizeListener listener) { + removeResizeListener(listener); + } + + /** * Fire the resize event. */ protected void fireResize() { @@ -748,17 +784,35 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ @Override - public void addListener(FocusListener listener) { + public void addFocusListener(FocusListener listener) { addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } + /** + * @deprecated Since 7.0, replaced by + * {@link #addFocusListener(FocusListener)} + **/ + @Deprecated + public void addListener(FocusListener listener) { + addFocusListener(listener); + } + @Override - public void removeListener(FocusListener listener) { + public void removeFocusListener(FocusListener listener) { removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeFocusListener(FocusListener)} + **/ + @Deprecated + public void removeListener(FocusListener listener) { + removeFocusListener(listener); + } + + /** * Note, that focus/blur listeners in Window class are only supported by sub * windows. Also note that Window is not considered focused if its contained * component currently has focus. @@ -767,17 +821,34 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ @Override - public void addListener(BlurListener listener) { + public void addBlurListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } + /** + * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} + **/ + @Deprecated + public void addListener(BlurListener listener) { + addBlurListener(listener); + } + @Override - public void removeListener(BlurListener listener) { + public void removeBlurListener(BlurListener listener) { removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); } /** + * @deprecated Since 7.0, replaced by + * {@link #removeBlurListener(BlurListener)} + **/ + @Deprecated + public void removeListener(BlurListener listener) { + removeBlurListener(listener); + } + + /** * {@inheritDoc} * * If the window is a sub-window focusing will cause the sub-window to be |