diff options
Diffstat (limited to 'server/src/com/vaadin/ui')
53 files changed, 2091 insertions, 1107 deletions
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 |