diff options
author | Jouni Koivuviita <jouni@vaadin.com> | 2012-08-07 16:05:49 +0300 |
---|---|---|
committer | Jouni Koivuviita <jouni@vaadin.com> | 2012-08-07 16:05:49 +0300 |
commit | 8356465b3897fa16233064cfd586b4557f33e8e4 (patch) | |
tree | aa14a1e52e85935486e7a4aec453247939a228fc /src/com/vaadin/ui | |
parent | 9a83722fde94af949b45d4c091399ba9e1f6ba29 (diff) | |
parent | 5813e0e9e5af4f946e5ea9c73d426e95d93b7bc4 (diff) | |
download | vaadin-framework-8356465b3897fa16233064cfd586b4557f33e8e4.tar.gz vaadin-framework-8356465b3897fa16233064cfd586b4557f33e8e4.zip |
merge master
Diffstat (limited to 'src/com/vaadin/ui')
51 files changed, 762 insertions, 206 deletions
diff --git a/src/com/vaadin/ui/AbsoluteLayout.java b/src/com/vaadin/ui/AbsoluteLayout.java index 7d8c402fc9..1c84ca2865 100644 --- a/src/com/vaadin/ui/AbsoluteLayout.java +++ b/src/com/vaadin/ui/AbsoluteLayout.java @@ -12,12 +12,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.shared.Connector; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.absolutelayout.AbsoluteLayoutServerRpc; +import com.vaadin.shared.ui.absolutelayout.AbsoluteLayoutState; import com.vaadin.terminal.Sizeable; -import com.vaadin.terminal.gwt.client.Connector; -import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.LayoutClickEventHandler; -import com.vaadin.terminal.gwt.client.ui.absolutelayout.AbsoluteLayoutServerRpc; -import com.vaadin.terminal.gwt.client.ui.absolutelayout.AbsoluteLayoutState; /** * AbsoluteLayout is a layout implementation that mimics html absolute @@ -30,6 +30,7 @@ public class AbsoluteLayout extends AbstractLayout implements private AbsoluteLayoutServerRpc rpc = new AbsoluteLayoutServerRpc() { + @Override public void layoutClick(MouseEventDetails mouseDetails, Connector clickedConnector) { fireEvent(LayoutClickEvent.createEvent(AbsoluteLayout.this, @@ -56,6 +57,7 @@ public class AbsoluteLayout extends AbstractLayout implements * Gets an iterator for going through all components enclosed in the * absolute layout. */ + @Override public Iterator<Component> getComponentIterator() { return componentToCoordinates.keySet().iterator(); } @@ -66,6 +68,7 @@ public class AbsoluteLayout extends AbstractLayout implements * * @return the number of contained components */ + @Override public int getComponentCount() { return componentToCoordinates.size(); } @@ -74,6 +77,7 @@ public class AbsoluteLayout extends AbstractLayout implements * Replaces one component with another one. The new component inherits the * old components position. */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { ComponentPosition position = getPosition(oldComponent); removeComponent(oldComponent); @@ -612,12 +616,14 @@ public class AbsoluteLayout extends AbstractLayout implements } + @Override public void addListener(LayoutClickListener listener) { addListener(LayoutClickEventHandler.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } + @Override public void removeListener(LayoutClickListener listener) { removeListener(LayoutClickEventHandler.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java index ba0e5db89c..e7cb38256c 100644 --- a/src/com/vaadin/ui/AbstractComponent.java +++ b/src/com/vaadin/ui/AbstractComponent.java @@ -20,11 +20,11 @@ import com.vaadin.event.ActionManager; import com.vaadin.event.EventRouter; import com.vaadin.event.MethodEventSource; import com.vaadin.event.ShortcutListener; +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.client.ComponentState; import com.vaadin.terminal.gwt.server.ClientConnector; import com.vaadin.terminal.gwt.server.ComponentSizeValidator; import com.vaadin.terminal.gwt.server.ResourceReference; @@ -101,10 +101,12 @@ public abstract class AbstractComponent extends AbstractClientConnector /* Get/Set component properties */ + @Override public void setDebugId(String id) { getState().setDebugId(id); } + @Override public String getDebugId() { return getState().getDebugId(); } @@ -141,6 +143,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * Gets the component's style. Don't add a JavaDoc comment here, we use the * default documentation from implemented interface. */ + @Override public String getStyleName() { String s = ""; if (getState().getStyles() != null) { @@ -159,6 +162,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * Sets the component's style. Don't add a JavaDoc comment here, we use the * default documentation from implemented interface. */ + @Override public void setStyleName(String style) { if (style == null || "".equals(style)) { getState().setStyles(null); @@ -179,6 +183,7 @@ public abstract class AbstractComponent extends AbstractClientConnector requestRepaint(); } + @Override public void addStyleName(String style) { if (style == null || "".equals(style)) { return; @@ -201,6 +206,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } } + @Override public void removeStyleName(String style) { if (getState().getStyles() != null) { String[] styleParts = style.split(" +"); @@ -217,6 +223,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * Get's the component's caption. Don't add a JavaDoc comment here, we use * the default documentation from implemented interface. */ + @Override public String getCaption() { return getState().getCaption(); } @@ -229,6 +236,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * @param caption * the new caption <code>String</code> for the component. */ + @Override public void setCaption(String caption) { getState().setCaption(caption); requestRepaint(); @@ -238,6 +246,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * Don't add a JavaDoc comment here, we use the default documentation from * implemented interface. */ + @Override public Locale getLocale() { if (locale != null) { return locale; @@ -283,13 +292,9 @@ public abstract class AbstractComponent extends AbstractClientConnector * Gets the component's icon resource. Don't add a JavaDoc comment here, we * use the default documentation from implemented interface. */ + @Override public Resource getIcon() { - ResourceReference ref = ((ResourceReference) getState().getIcon()); - if (ref == null) { - return null; - } else { - return ref.getResource(); - } + return ResourceReference.getResource(getState().getIcon()); } /** @@ -299,12 +304,9 @@ public abstract class AbstractComponent extends AbstractClientConnector * @param icon * the icon to be shown with the component's caption. */ + @Override public void setIcon(Resource icon) { - if (icon == null) { - getState().setIcon(null); - } else { - getState().setIcon(new ResourceReference(icon)); - } + getState().setIcon(ResourceReference.create(icon)); requestRepaint(); } @@ -313,6 +315,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.ui.Component#isEnabled() */ + @Override public boolean isEnabled() { return getState().isEnabled(); } @@ -322,6 +325,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.ui.Component#setEnabled(boolean) */ + @Override public void setEnabled(boolean enabled) { if (getState().isEnabled() != enabled) { getState().setEnabled(enabled); @@ -377,6 +381,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.ui.Component#isVisible() */ + @Override public boolean isVisible() { return getState().isVisible(); } @@ -386,6 +391,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.ui.Component#setVisible(boolean) */ + @Override public void setVisible(boolean visible) { if (getState().isVisible() == visible) { return; @@ -566,6 +572,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * Tests if the component is in read-only mode. Don't add a JavaDoc comment * here, we use the default documentation from implemented interface. */ + @Override public boolean isReadOnly() { return getState().isReadOnly(); } @@ -574,6 +581,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * Sets the component's read-only mode. Don't add a JavaDoc comment here, we * use the default documentation from implemented interface. */ + @Override public void setReadOnly(boolean readOnly) { getState().setReadOnly(readOnly); requestRepaint(); @@ -704,6 +712,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.ui.Component#updateState() */ + @Override public void updateState() { // TODO This logic should be on the client side and the state should // simply be a data object with "width" and "height". @@ -863,6 +872,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * @param method * the activation method. */ + @Override public void addListener(Class<?> eventType, Object target, Method method) { if (eventRouter == null) { eventRouter = new EventRouter(); @@ -904,6 +914,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * @param methodName * the name of the activation method. */ + @Override public void addListener(Class<?> eventType, Object target, String methodName) { if (eventRouter == null) { eventRouter = new EventRouter(); @@ -929,6 +940,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * the target object that has registered to listen to events of * type <code>eventType</code> with one or more methods. */ + @Override public void removeListener(Class<?> eventType, Object target) { if (eventRouter != null) { eventRouter.removeListener(eventType, target); @@ -954,6 +966,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * the method owned by <code>target</code> that's registered to * listen to events of type <code>eventType</code>. */ + @Override public void removeListener(Class<?> eventType, Object target, Method method) { if (eventRouter != null) { eventRouter.removeListener(eventType, target, method); @@ -988,6 +1001,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * the name of the method owned by <code>target</code> that's * registered to listen to events of type <code>eventType</code>. */ + @Override public void removeListener(Class<?> eventType, Object target, String methodName) { if (eventRouter != null) { @@ -1032,6 +1046,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * Don't add a JavaDoc comment here, we use the default documentation from * implemented interface. */ + @Override public void addListener(Component.Listener listener) { addListener(Component.Event.class, listener, COMPONENT_EVENT_METHOD); } @@ -1041,6 +1056,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * JavaDoc comment here, we use the default documentation from implemented * interface. */ + @Override public void removeListener(Component.Listener listener) { removeListener(Component.Event.class, listener, COMPONENT_EVENT_METHOD); } @@ -1090,6 +1106,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#getHeight() */ + @Override public float getHeight() { return height; } @@ -1099,6 +1116,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#getHeightUnits() */ + @Override public Unit getHeightUnits() { return heightUnit; } @@ -1108,6 +1126,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#getWidth() */ + @Override public float getWidth() { return width; } @@ -1117,6 +1136,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#getWidthUnits() */ + @Override public Unit getWidthUnits() { return widthUnit; } @@ -1126,6 +1146,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#setHeight(float, Unit) */ + @Override public void setHeight(float height, Unit unit) { if (unit == null) { throw new IllegalArgumentException("Unit can not be null"); @@ -1141,6 +1162,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#setSizeFull() */ + @Override public void setSizeFull() { setWidth(100, Unit.PERCENTAGE); setHeight(100, Unit.PERCENTAGE); @@ -1151,6 +1173,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#setSizeUndefined() */ + @Override public void setSizeUndefined() { setWidth(-1, Unit.PIXELS); setHeight(-1, Unit.PIXELS); @@ -1161,6 +1184,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#setWidth(float, Unit) */ + @Override public void setWidth(float width, Unit unit) { if (unit == null) { throw new IllegalArgumentException("Unit can not be null"); @@ -1176,6 +1200,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#setWidth(java.lang.String) */ + @Override public void setWidth(String width) { Size size = parseStringSize(width); if (size != null) { @@ -1190,6 +1215,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * * @see com.vaadin.terminal.Sizeable#setHeight(java.lang.String) */ + @Override public void setHeight(String height) { Size size = parseStringSize(height); if (size != null) { diff --git a/src/com/vaadin/ui/AbstractComponentContainer.java b/src/com/vaadin/ui/AbstractComponentContainer.java index 8ef458b704..bc27242bb8 100644 --- a/src/com/vaadin/ui/AbstractComponentContainer.java +++ b/src/com/vaadin/ui/AbstractComponentContainer.java @@ -38,6 +38,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * Removes all components from the container. This should probably be * re-implemented in extending classes for a more powerful implementation. */ + @Override public void removeAllComponents() { final LinkedList<Component> l = new LinkedList<Component>(); @@ -57,6 +58,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * add a JavaDoc comment here, we use the default documentation from * implemented interface. */ + @Override public void moveComponentsFrom(ComponentContainer source) { final LinkedList<Component> components = new LinkedList<Component>(); for (final Iterator<Component> i = source.getComponentIterator(); i @@ -93,24 +95,28 @@ public abstract class AbstractComponentContainer extends AbstractComponent } /* documented in interface */ + @Override public void addListener(ComponentAttachListener listener) { addListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD); } /* documented in interface */ + @Override public void addListener(ComponentDetachListener listener) { addListener(ComponentContainer.ComponentDetachEvent.class, listener, COMPONENT_DETACHED_METHOD); } /* documented in interface */ + @Override public void removeListener(ComponentAttachListener listener) { removeListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD); } /* documented in interface */ + @Override public void removeListener(ComponentDetachListener listener) { removeListener(ComponentContainer.ComponentDetachEvent.class, listener, COMPONENT_DETACHED_METHOD); @@ -147,6 +153,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * * @see com.vaadin.ui.ComponentContainer#addComponent(Component) */ + @Override public void addComponent(Component c) { if (c instanceof ComponentContainer) { // Make sure we're not adding the component inside it's own content @@ -177,6 +184,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * * @see com.vaadin.ui.ComponentContainer#removeComponent(Component) */ + @Override public void removeComponent(Component c) { if (c.getParent() == this) { c.setParent(null); @@ -325,6 +333,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent true); } + @Override public Iterator<Component> iterator() { return getComponentIterator(); } @@ -335,6 +344,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * @see * com.vaadin.ui.HasComponents#isComponentVisible(com.vaadin.ui.Component) */ + @Override public boolean isComponentVisible(Component childComponent) { return true; } diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index ce62fb43ed..6fe7f54df5 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -25,10 +25,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.shared.AbstractFieldState; import com.vaadin.terminal.AbstractErrorMessage; import com.vaadin.terminal.CompositeErrorMessage; import com.vaadin.terminal.ErrorMessage; -import com.vaadin.terminal.gwt.client.AbstractFieldState; /** * <p> @@ -178,6 +178,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @return the type of the Field */ + @Override public abstract Class<? extends T> getType(); /** @@ -206,6 +207,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @see com.vaadin.data.BufferedValidatable#isInvalidCommitted() */ + @Override public boolean isInvalidCommitted() { return invalidCommitted; } @@ -215,6 +217,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @see com.vaadin.data.BufferedValidatable#setInvalidCommitted(boolean) */ + @Override public void setInvalidCommitted(boolean isCommitted) { invalidCommitted = isCommitted; } @@ -223,6 +226,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * Saves the current value to the data source Don't add a JavaDoc comment * here, we use the default documentation from the implemented interface. */ + @Override public void commit() throws Buffered.SourceException, InvalidValueException { if (dataSource != null && !dataSource.isReadOnly()) { if ((isInvalidCommitted() || isValid())) { @@ -271,6 +275,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * Updates the value from the data source. Don't add a JavaDoc comment here, * we use the default documentation from the implemented interface. */ + @Override public void discard() throws Buffered.SourceException { if (dataSource != null) { @@ -343,6 +348,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * comment here, we use the default documentation from the implemented * interface. */ + @Override public boolean isModified() { return getState().isModified(); } @@ -356,6 +362,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * Tests if the field is in write-through mode. Don't add a JavaDoc comment * here, we use the default documentation from the implemented interface. */ + @Override public boolean isWriteThrough() { return writeThroughMode; } @@ -381,6 +388,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * setReadThrough(true), setWriteThrough(true) equals * setBuffered(false) */ + @Override @Deprecated public void setWriteThrough(boolean writeThrough) throws Buffered.SourceException, InvalidValueException { @@ -397,6 +405,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * Tests if the field is in read-through mode. Don't add a JavaDoc comment * here, we use the default documentation from the implemented interface. */ + @Override public boolean isReadThrough() { return readThroughMode; } @@ -420,6 +429,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * setReadThrough(true), setWriteThrough(true) equals * setBuffered(false) */ + @Override @Deprecated public void setReadThrough(boolean readThrough) throws Buffered.SourceException { @@ -452,6 +462,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @param buffered * true if buffered mode should be turned on, false otherwise */ + @Override public void setBuffered(boolean buffered) { setReadThrough(!buffered); setWriteThrough(!buffered); @@ -464,6 +475,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @return true if buffered mode is on, false otherwise */ + @Override public boolean isBuffered() { return !isReadThrough() && !isWriteThrough(); } @@ -517,6 +529,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @return the current value of the field. */ + @Override public T getValue() { return getFieldValue(); } @@ -528,6 +541,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * the New value of the field. * @throws Property.ReadOnlyException */ + @Override public void setValue(Object newFieldValue) throws Property.ReadOnlyException, Converter.ConversionException { // This check is needed as long as setValue accepts Object instead of T @@ -644,6 +658,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @return the current data source as a Property, or <code>null</code> if * none defined. */ + @Override public Property getPropertyDataSource() { return dataSource; } @@ -686,6 +701,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @param newDataSource * the new data source Property. */ + @Override public void setPropertyDataSource(Property newDataSource) { // Saves the old value @@ -863,6 +879,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @param validator * the new validator to be added. */ + @Override public void addValidator(Validator validator) { if (validators == null) { validators = new LinkedList<Validator>(); @@ -877,6 +894,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @return the Unmodifiable collection that holds all validators for the * field. */ + @Override public Collection<Validator> getValidators() { if (validators == null || validators.isEmpty()) { return null; @@ -890,6 +908,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @param validator * the validator to remove. */ + @Override public void removeValidator(Validator validator) { if (validators != null) { validators.remove(validator); @@ -919,6 +938,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * current value is valid or if the field is empty and not required, * <code>false</code> otherwise. */ + @Override public boolean isValid() { try { @@ -943,6 +963,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @see com.vaadin.data.Validatable#validate() */ + @Override public void validate() throws Validator.InvalidValueException { if (isRequired() && isEmpty()) { @@ -1014,6 +1035,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @return true iff the invalid values are allowed. * @see com.vaadin.data.Validatable#isInvalidAllowed() */ + @Override public boolean isInvalidAllowed() { return invalidAllowed; } @@ -1031,6 +1053,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @see com.vaadin.data.Validatable#setInvalidAllowed(boolean) */ + @Override public void setInvalidAllowed(boolean invalidAllowed) throws UnsupportedOperationException { this.invalidAllowed = invalidAllowed; @@ -1103,6 +1126,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * Adds a value change listener for the field. Don't add a JavaDoc comment * here, we use the default documentation from the implemented interface. */ + @Override public void addListener(Property.ValueChangeListener listener) { addListener(AbstractField.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); @@ -1113,6 +1137,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * comment here, we use the default documentation from the implemented * interface. */ + @Override public void removeListener(Property.ValueChangeListener listener) { removeListener(AbstractField.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); @@ -1152,6 +1177,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @see Property.ReadOnlyStatusChangeListener */ + @Override public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event) { getState().setPropertyReadOnly(event.getProperty().isReadOnly()); requestRepaint(); @@ -1184,6 +1210,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @return the Source of the event. */ + @Override public Property getProperty() { return (Property) getSource(); } @@ -1194,6 +1221,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * JavaDoc comment here, we use the default documentation from the * implemented interface. */ + @Override public void addListener(Property.ReadOnlyStatusChangeListener listener) { addListener(Property.ReadOnlyStatusChangeEvent.class, listener, READ_ONLY_STATUS_CHANGE_METHOD); @@ -1204,6 +1232,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * JavaDoc comment here, we use the default documentation from the * implemented interface. */ + @Override public void removeListener(Property.ReadOnlyStatusChangeListener listener) { removeListener(Property.ReadOnlyStatusChangeEvent.class, listener, READ_ONLY_STATUS_CHANGE_METHOD); @@ -1228,6 +1257,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * the value change event telling the data source contents have * changed. */ + @Override public void valueChange(Property.ValueChangeEvent event) { if (isReadThrough()) { if (committingValueToDataSource) { @@ -1271,6 +1301,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @see com.vaadin.ui.Component.Focusable#getTabIndex() */ + @Override public int getTabIndex() { return getState().getTabIndex(); } @@ -1280,6 +1311,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * * @see com.vaadin.ui.Component.Focusable#setTabIndex(int) */ + @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); requestRepaint(); @@ -1362,6 +1394,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @return <code>true</code> if the field is required, otherwise * <code>false</code>. */ + @Override public boolean isRequired() { return getState().isRequired(); } @@ -1381,6 +1414,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @param required * Is the field required. */ + @Override public void setRequired(boolean required) { getState().setRequired(required); requestRepaint(); @@ -1395,11 +1429,13 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @param requiredMessage * Message to be shown when this field is required, but empty. */ + @Override public void setRequiredError(String requiredMessage) { requiredError = requiredMessage; requestRepaint(); } + @Override public String getRequiredError() { return requiredError; } diff --git a/src/com/vaadin/ui/AbstractJavaScriptComponent.java b/src/com/vaadin/ui/AbstractJavaScriptComponent.java index 95c45f55f9..3668669d16 100644 --- a/src/com/vaadin/ui/AbstractJavaScriptComponent.java +++ b/src/com/vaadin/ui/AbstractJavaScriptComponent.java @@ -3,8 +3,9 @@ */ package com.vaadin.ui; +import com.vaadin.shared.ui.JavaScriptComponentState; import com.vaadin.terminal.JavaScriptCallbackHelper; -import com.vaadin.terminal.gwt.client.ui.JavaScriptComponentState; +import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget; /** @@ -37,9 +38,9 @@ import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget; * the connector's parent. If <code>connectorId</code> is provided, the id of * the parent of the corresponding connector with the passed id is returned * instead.</li> - * <li><code>getWidgetElement([connectorId])</code> - returns the DOM Element - * that is the root of a connector's widget. <code>null</code> is returned if - * the connector can not be found or if the connector doesn't have a widget. If + * <li><code>getElement([connectorId])</code> - returns the DOM Element that is + * the root of a connector's widget. <code>null</code> is returned if the + * connector can not be found or if the connector doesn't have a widget. If * <code>connectorId</code> is not provided, the connector id of the current * connector will be used.</li> * <li><code>getState()</code> - returns an object corresponding to the shared @@ -66,6 +67,9 @@ import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget; * exception when called. The scheme for conversion between Java types in the * RPC interface and the JavaScript values that should be passed to the * 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 ApplicationConnection#translateVaadinUri(String)}</li> * </ul> * The connector wrapper also supports these special functions: * <ul> @@ -110,7 +114,7 @@ import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget; * @version @VERSION@ * @since 7.0.0 */ -public class AbstractJavaScriptComponent extends AbstractComponent { +public abstract class AbstractJavaScriptComponent extends AbstractComponent { private JavaScriptCallbackHelper callbackHelper = new JavaScriptCallbackHelper( this); @@ -142,8 +146,9 @@ public class AbstractJavaScriptComponent extends AbstractComponent { /** * Invoke a named function that the connector JavaScript has added to the * JavaScript connector wrapper object. The arguments should only contain - * data types that can be represented in JavaScript, including primitive - * boxing types, arrays, String, List, Set, Map, Connector and JavaBeans. + * data types that can be represented in JavaScript including primitives, + * their boxed types, arrays, String, List, Set, Map, Connector and + * JavaBeans. * * @param name * the name of the function diff --git a/src/com/vaadin/ui/AbstractLayout.java b/src/com/vaadin/ui/AbstractLayout.java index 4876b40265..7b3a537d06 100644 --- a/src/com/vaadin/ui/AbstractLayout.java +++ b/src/com/vaadin/ui/AbstractLayout.java @@ -4,7 +4,7 @@ package com.vaadin.ui; -import com.vaadin.terminal.gwt.client.ui.AbstractLayoutState; +import com.vaadin.shared.ui.AbstractLayoutState; import com.vaadin.ui.Layout.MarginHandler; /** @@ -32,6 +32,7 @@ public abstract class AbstractLayout extends AbstractComponentContainer * * @see com.vaadin.ui.Layout#setMargin(boolean) */ + @Override public void setMargin(boolean enabled) { margins.setMargins(enabled); getState().setMarginsBitmask(margins.getBitMask()); @@ -43,6 +44,7 @@ public abstract class AbstractLayout extends AbstractComponentContainer * * @see com.vaadin.ui.Layout.MarginHandler#getMargin() */ + @Override public MarginInfo getMargin() { return margins; } @@ -52,6 +54,7 @@ public abstract class AbstractLayout extends AbstractComponentContainer * * @see com.vaadin.ui.Layout.MarginHandler#setMargin(MarginInfo) */ + @Override public void setMargin(MarginInfo marginInfo) { margins.setMargins(marginInfo); getState().setMarginsBitmask(margins.getBitMask()); @@ -63,6 +66,7 @@ public abstract class AbstractLayout extends AbstractComponentContainer * * @see com.vaadin.ui.Layout#setMargin(boolean, boolean, boolean, boolean) */ + @Override public void setMargin(boolean topEnabled, boolean rightEnabled, boolean bottomEnabled, boolean leftEnabled) { margins.setMargins(topEnabled, rightEnabled, bottomEnabled, leftEnabled); diff --git a/src/com/vaadin/ui/AbstractMedia.java b/src/com/vaadin/ui/AbstractMedia.java index 760d9878ca..71b2e38ef3 100644 --- a/src/com/vaadin/ui/AbstractMedia.java +++ b/src/com/vaadin/ui/AbstractMedia.java @@ -7,10 +7,10 @@ package com.vaadin.ui; import java.util.ArrayList; import java.util.List; +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.client.communication.URLReference; -import com.vaadin.terminal.gwt.client.ui.AbstractMediaState; -import com.vaadin.terminal.gwt.client.ui.MediaBaseConnector.MediaControl; import com.vaadin.terminal.gwt.server.ResourceReference; /** @@ -18,7 +18,7 @@ import com.vaadin.terminal.gwt.server.ResourceReference; * * @author Vaadin Ltd */ -public class AbstractMedia extends AbstractComponent { +public abstract class AbstractMedia extends AbstractComponent { @Override public AbstractMediaState getState() { diff --git a/src/com/vaadin/ui/AbstractOrderedLayout.java b/src/com/vaadin/ui/AbstractOrderedLayout.java index 2cd6fc2a9a..0581d0a279 100644 --- a/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -10,13 +10,13 @@ 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.shared.Connector; +import com.vaadin.shared.MouseEventDetails; +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; -import com.vaadin.terminal.gwt.client.Connector; -import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.LayoutClickEventHandler; -import com.vaadin.terminal.gwt.client.ui.orderedlayout.AbstractOrderedLayoutServerRpc; -import com.vaadin.terminal.gwt.client.ui.orderedlayout.AbstractOrderedLayoutState; -import com.vaadin.terminal.gwt.client.ui.orderedlayout.AbstractOrderedLayoutState.ChildComponentData; @SuppressWarnings("serial") public abstract class AbstractOrderedLayout extends AbstractLayout implements @@ -24,6 +24,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements private AbstractOrderedLayoutServerRpc rpc = new AbstractOrderedLayoutServerRpc() { + @Override public void layoutClick(MouseEventDetails mouseDetails, Connector clickedConnector) { fireEvent(LayoutClickEvent.createEvent(AbstractOrderedLayout.this, @@ -157,6 +158,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * * @return the Iterator of the components inside the container. */ + @Override public Iterator<Component> getComponentIterator() { return components.iterator(); } @@ -167,11 +169,13 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * * @return the number of contained components */ + @Override public int getComponentCount() { return components.size(); } /* Documented in superclass */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { // Gets the locations @@ -220,12 +224,14 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * @see com.vaadin.ui.Layout.AlignmentHandler#setComponentAlignment(com * .vaadin.ui.Component, int, int) */ + @Override public void setComponentAlignment(Component childComponent, int horizontalAlignment, int verticalAlignment) { Alignment a = new Alignment(horizontalAlignment + verticalAlignment); setComponentAlignment(childComponent, a); } + @Override public void setComponentAlignment(Component childComponent, Alignment alignment) { ChildComponentData childData = getState().getChildData().get( @@ -247,6 +253,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * @see com.vaadin.ui.Layout.AlignmentHandler#getComponentAlignment(com * .vaadin.ui.Component) */ + @Override public Alignment getComponentAlignment(Component childComponent) { ChildComponentData childData = getState().getChildData().get( childComponent); @@ -263,6 +270,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * * @see com.vaadin.ui.Layout.SpacingHandler#setSpacing(boolean) */ + @Override public void setSpacing(boolean spacing) { getState().setSpacing(spacing); requestRepaint(); @@ -273,6 +281,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * * @see com.vaadin.ui.Layout.SpacingHandler#isSpacing() */ + @Override public boolean isSpacing() { return getState().isSpacing(); } @@ -334,12 +343,14 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements return childData.getExpandRatio(); } + @Override public void addListener(LayoutClickListener listener) { addListener(LayoutClickEventHandler.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } + @Override public void removeListener(LayoutClickListener listener) { removeListener(LayoutClickEventHandler.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java index 6a927251af..0a97ceb649 100644 --- a/src/com/vaadin/ui/AbstractSelect.java +++ b/src/com/vaadin/ui/AbstractSelect.java @@ -27,12 +27,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.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.terminal.gwt.client.ui.dd.VerticalDropLocation; import com.vaadin.ui.AbstractSelect.ItemCaptionMode; /** @@ -320,6 +320,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @throws PaintException * if the paint operation failed. */ + @Override public void paintContent(PaintTarget target) throws PaintException { // Paints select attributes @@ -422,6 +423,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, * java.util.Map) */ + @Override public void changeVariables(Object source, Map<String, Object> variables) { // New option entered (and it is allowed) @@ -434,7 +436,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements // Selection change if (variables.containsKey("selected")) { - final String[] ka = (String[]) variables.get("selected"); + final String[] clientSideSelectedKeys = (String[]) variables + .get("selected"); // Multiselect mode if (isMultiSelect()) { @@ -442,19 +445,20 @@ public abstract class AbstractSelect extends AbstractField<Object> implements // TODO Optimize by adding repaintNotNeeded when applicable // 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]); + final LinkedList<Object> acceptedSelections = new LinkedList<Object>(); + for (int i = 0; i < clientSideSelectedKeys.length; i++) { + final Object id = itemIdMapper + .get(clientSideSelectedKeys[i]); if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed requestRepaint(); } else if (id != null && containsId(id)) { - s.add(id); + acceptedSelections.add(id); } } - if (!isNullSelectionAllowed() && s.size() < 1) { + if (!isNullSelectionAllowed() && acceptedSelections.size() < 1) { // empty selection not allowed, keep old value requestRepaint(); return; @@ -462,27 +466,32 @@ public abstract class AbstractSelect extends AbstractField<Object> implements // Limits the deselection to the set of visible items // (non-visible items can not be deselected) - final Collection<?> visible = getVisibleItemIds(); - if (visible != null) { + Collection<?> visibleNotSelected = getVisibleItemIds(); + if (visibleNotSelected != null) { + visibleNotSelected = new HashSet<Object>(visibleNotSelected); + // Don't remove those that will be added to preserve order + visibleNotSelected.removeAll(acceptedSelections); + @SuppressWarnings("unchecked") Set<Object> newsel = (Set<Object>) getValue(); if (newsel == null) { - newsel = new HashSet<Object>(); + newsel = new LinkedHashSet<Object>(); } else { - newsel = new HashSet<Object>(newsel); + newsel = new LinkedHashSet<Object>(newsel); } - newsel.removeAll(visible); - newsel.addAll(s); + newsel.removeAll(visibleNotSelected); + newsel.addAll(acceptedSelections); setValue(newsel, true); } } else { // Single select mode if (!isNullSelectionAllowed() - && (ka.length == 0 || ka[0] == null || ka[0] == getNullSelectionItemId())) { + && (clientSideSelectedKeys.length == 0 + || clientSideSelectedKeys[0] == null || clientSideSelectedKeys[0] == getNullSelectionItemId())) { requestRepaint(); return; } - if (ka.length == 0) { + if (clientSideSelectedKeys.length == 0) { // Allows deselection only if the deselected item is // visible final Object current = getValue(); @@ -491,7 +500,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements setValue(null, true); } } else { - final Object id = itemIdMapper.get(ka[0]); + final Object id = itemIdMapper + .get(clientSideSelectedKeys[0]); if (!isNullSelectionAllowed() && id == null) { requestRepaint(); } else if (id != null @@ -542,6 +552,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * */ public class DefaultNewItemHandler implements NewItemHandler { + @Override public void addNewItem(String newItemCaption) { // Checks for readonly if (isReadOnly()) { @@ -672,10 +683,10 @@ public abstract class AbstractSelect extends AbstractField<Object> implements if (isMultiSelect()) { if (newValue == null) { - super.setValue(new HashSet<Object>(), repaintIsNotNeeded); + super.setValue(new LinkedHashSet<Object>(), repaintIsNotNeeded); } else if (Collection.class.isAssignableFrom(newValue.getClass())) { - super.setValue(new HashSet<Object>((Collection<?>) newValue), - repaintIsNotNeeded); + super.setValue(new LinkedHashSet<Object>( + (Collection<?>) newValue), repaintIsNotNeeded); } } else if (newValue == null || items.containsId(newValue)) { super.setValue(newValue, repaintIsNotNeeded); @@ -692,6 +703,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * the item id. * @return the item from the container. */ + @Override public Item getItem(Object itemId) { return items.getItem(itemId); } @@ -701,6 +713,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @return the Collection of item ids. */ + @Override public Collection<?> getItemIds() { return items.getItemIds(); } @@ -710,6 +723,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @return the Collection of property ids. */ + @Override public Collection<?> getContainerPropertyIds() { return items.getContainerPropertyIds(); } @@ -721,6 +735,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * the Id identifying the property. * @see com.vaadin.data.Container#getType(java.lang.Object) */ + @Override public Class<?> getType(Object propertyId) { return items.getType(propertyId); } @@ -732,6 +747,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container#size() */ + @Override public int size() { return items.size(); } @@ -742,6 +758,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @param itemId * the Id the of item to be tested. */ + @Override public boolean containsId(Object itemId) { if (itemId != null) { return items.containsId(itemId); @@ -756,6 +773,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container#getContainerProperty(Object, Object) */ + @Override public Property<?> getContainerProperty(Object itemId, Object propertyId) { return items.getContainerProperty(itemId, propertyId); } @@ -771,6 +789,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @see com.vaadin.data.Container#addContainerProperty(java.lang.Object, * java.lang.Class, java.lang.Object) */ + @Override public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException { @@ -791,6 +810,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @return True if the operation succeeded. * @see com.vaadin.data.Container#removeAllItems() */ + @Override public boolean removeAllItems() throws UnsupportedOperationException { final boolean retval = items.removeAllItems(); @@ -812,6 +832,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @return the Id of the created item or null in case of failure. * @see com.vaadin.data.Container#addItem() */ + @Override public Object addItem() throws UnsupportedOperationException { final Object retval = items.addItem(); @@ -836,6 +857,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @return the Created item with the given id, or null in case of failure. * @see com.vaadin.data.Container#addItem(java.lang.Object) */ + @Override public Item addItem(Object itemId) throws UnsupportedOperationException { final Item retval = items.addItem(itemId); @@ -851,6 +873,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container#removeItem(java.lang.Object) */ + @Override public boolean removeItem(Object itemId) throws UnsupportedOperationException { @@ -873,6 +896,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @return True if the operation succeeded. * @see com.vaadin.data.Container#removeContainerProperty(java.lang.Object) */ + @Override public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException { @@ -896,6 +920,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @param newDataSource * the new data source. */ + @Override public void setContainerDataSource(Container newDataSource) { if (newDataSource == null) { newDataSource = new IndexedContainer(); @@ -950,6 +975,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container.Viewer#getContainerDataSource() */ + @Override public Container getContainerDataSource() { return items; } @@ -1432,6 +1458,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container.PropertySetChangeListener#containerPropertySetChange(com.vaadin.data.Container.PropertySetChangeEvent) */ + @Override public void containerPropertySetChange( Container.PropertySetChangeEvent event) { firePropertySetChange(); @@ -1442,6 +1469,7 @@ 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) { if (propertySetEventListeners == null) { propertySetEventListeners = new LinkedHashSet<Container.PropertySetChangeListener>(); @@ -1454,6 +1482,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container.PropertySetChangeNotifier#removeListener(com.vaadin.data.Container.PropertySetChangeListener) */ + @Override public void removeListener(Container.PropertySetChangeListener listener) { if (propertySetEventListeners != null) { propertySetEventListeners.remove(listener); @@ -1468,6 +1497,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container.ItemSetChangeNotifier#addListener(com.vaadin.data.Container.ItemSetChangeListener) */ + @Override public void addListener(Container.ItemSetChangeListener listener) { if (itemSetEventListeners == null) { itemSetEventListeners = new LinkedHashSet<Container.ItemSetChangeListener>(); @@ -1480,6 +1510,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container.ItemSetChangeNotifier#removeListener(com.vaadin.data.Container.ItemSetChangeListener) */ + @Override public void removeListener(Container.ItemSetChangeListener listener) { if (itemSetEventListeners != null) { itemSetEventListeners.remove(listener); @@ -1516,6 +1547,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container.ItemSetChangeListener#containerItemSetChange(com.vaadin.data.Container.ItemSetChangeEvent) */ + @Override public void containerItemSetChange(Container.ItemSetChangeEvent event) { // Clears the item id mapping table itemIdMapper.removeAll(); @@ -1566,6 +1598,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container.ItemSetChangeEvent#getContainer() */ + @Override public Container getContainer() { return AbstractSelect.this; } @@ -1583,6 +1616,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * * @see com.vaadin.data.Container.PropertySetChangeEvent#getContainer() */ + @Override public Container getContainer() { return AbstractSelect.this; } @@ -1778,10 +1812,12 @@ public abstract class AbstractSelect extends AbstractField<Object> implements captionChangeNotifiers.clear(); } + @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { requestRepaint(); } + @Override public void itemPropertySetChange( com.vaadin.data.Item.PropertySetChangeEvent event) { requestRepaint(); @@ -1809,6 +1845,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements super(select, itemId); } + @Override public boolean accept(DragAndDropEvent dragEvent) { AbstractSelectTargetDetails dropTargetData = (AbstractSelectTargetDetails) dragEvent .getTargetDetails(); @@ -1875,6 +1912,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements super(select, itemId); } + @Override public boolean accept(DragAndDropEvent dragEvent) { DataBoundTransferable transferable = (DataBoundTransferable) dragEvent .getTransferable(); diff --git a/src/com/vaadin/ui/AbstractSplitPanel.java b/src/com/vaadin/ui/AbstractSplitPanel.java index 876d39f2ae..90dc38ff65 100644 --- a/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/src/com/vaadin/ui/AbstractSplitPanel.java @@ -10,12 +10,12 @@ import java.util.Iterator; import com.vaadin.event.ComponentEventListener; import com.vaadin.event.MouseEvents.ClickEvent; +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.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.ClickEventHandler; -import com.vaadin.terminal.gwt.client.ui.splitpanel.AbstractSplitPanelRpc; -import com.vaadin.terminal.gwt.client.ui.splitpanel.AbstractSplitPanelState; -import com.vaadin.terminal.gwt.client.ui.splitpanel.AbstractSplitPanelState.SplitterState; import com.vaadin.tools.ReflectTools; /** @@ -38,11 +38,13 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { private AbstractSplitPanelRpc rpc = new AbstractSplitPanelRpc() { + @Override public void splitterClick(MouseEventDetails mouseDetails) { fireEvent(new SplitterClickEvent(AbstractSplitPanel.this, mouseDetails)); } + @Override public void setSplitterPosition(float position) { getSplitterState().setPosition(position); } @@ -63,6 +65,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { int i = 0; + @Override public boolean hasNext() { if (i < getComponentCount()) { return true; @@ -70,6 +73,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { return false; } + @Override public Component next() { if (!hasNext()) { return null; @@ -84,6 +88,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { return null; } + @Override public void remove() { if (i == 1) { if (getFirstComponent() != null) { @@ -211,6 +216,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @see com.vaadin.ui.ComponentContainer#getComponentIterator() */ + @Override public Iterator<Component> getComponentIterator() { return new ComponentIterator(); } @@ -222,6 +228,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @return the number of contained components (zero, one or two) */ + @Override public int getComponentCount() { int count = 0; if (getFirstComponent() != null) { @@ -235,6 +242,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { /* Documented in superclass */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { if (oldComponent == getFirstComponent()) { setFirstComponent(newComponent); diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java index d584374bda..2326c07d97 100644 --- a/src/com/vaadin/ui/AbstractTextField.java +++ b/src/com/vaadin/ui/AbstractTextField.java @@ -15,10 +15,10 @@ 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.shared.ui.textfield.AbstractTextFieldState; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Vaadin6Component; -import com.vaadin.terminal.gwt.client.ui.textfield.AbstractTextFieldState; import com.vaadin.terminal.gwt.client.ui.textfield.VTextField; public abstract class AbstractTextField extends AbstractField<String> implements @@ -95,6 +95,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements getState().setText(value); } + @Override public void paintContent(PaintTarget target) throws PaintException { if (selectionPosition != -1) { @@ -123,6 +124,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements } + @Override public void changeVariables(Object source, Map<String, Object> variables) { changingVariables = true; @@ -498,11 +500,13 @@ public abstract class AbstractTextField extends AbstractField<String> implements LAZY } + @Override public void addListener(TextChangeListener listener) { addListener(TextChangeListener.EVENT_ID, TextChangeEvent.class, listener, TextChangeListener.EVENT_METHOD); } + @Override public void removeListener(TextChangeListener listener) { removeListener(TextChangeListener.EVENT_ID, TextChangeEvent.class, listener); @@ -645,20 +649,24 @@ public abstract class AbstractTextField extends AbstractField<String> implements return lastKnownCursorPosition; } + @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); } + @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); } diff --git a/src/com/vaadin/ui/Alignment.java b/src/com/vaadin/ui/Alignment.java index eb9e75e4d2..0d73da8504 100644 --- a/src/com/vaadin/ui/Alignment.java +++ b/src/com/vaadin/ui/Alignment.java @@ -5,7 +5,7 @@ package com.vaadin.ui; import java.io.Serializable; -import com.vaadin.terminal.gwt.client.ui.AlignmentInfo.Bits; +import com.vaadin.shared.ui.AlignmentInfo.Bits; /** * Class containing information about alignment of a component. Use the diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 0abc50f26f..0cb667d527 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -18,9 +18,9 @@ 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.terminal.gwt.client.MouseEventDetails; -import com.vaadin.terminal.gwt.client.ui.button.ButtonServerRpc; -import com.vaadin.terminal.gwt.client.ui.button.ButtonState; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.button.ButtonServerRpc; +import com.vaadin.shared.ui.button.ButtonState; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.Component.Focusable; @@ -39,10 +39,12 @@ public class Button extends AbstractComponent implements private ButtonServerRpc rpc = new ButtonServerRpc() { + @Override public void click(MouseEventDetails mouseEventDetails) { fireClick(mouseEventDetails); } + @Override public void disableOnClick() { // Could be optimized so the button is not repainted because of // this (client side has already disabled the button) @@ -332,20 +334,24 @@ public class Button extends AbstractComponent implements fireEvent(new Button.ClickEvent(this, details)); } + @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); @@ -474,6 +480,7 @@ public class Button extends AbstractComponent implements * * @see com.vaadin.ui.Component.Focusable#getTabIndex() */ + @Override public int getTabIndex() { return getState().getTabIndex(); } @@ -483,6 +490,7 @@ public class Button extends AbstractComponent implements * * @see com.vaadin.ui.Component.Focusable#setTabIndex(int) */ + @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); requestRepaint(); diff --git a/src/com/vaadin/ui/CheckBox.java b/src/com/vaadin/ui/CheckBox.java index 147a270059..30ac9b4626 100644 --- a/src/com/vaadin/ui/CheckBox.java +++ b/src/com/vaadin/ui/CheckBox.java @@ -10,14 +10,15 @@ import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.terminal.gwt.client.MouseEventDetails; -import com.vaadin.terminal.gwt.client.ui.checkbox.CheckBoxServerRpc; -import com.vaadin.terminal.gwt.client.ui.checkbox.CheckBoxState; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc; +import com.vaadin.shared.ui.checkbox.CheckBoxState; public class CheckBox extends AbstractField<Boolean> { private CheckBoxServerRpc rpc = new CheckBoxServerRpc() { + @Override public void setChecked(boolean checked, MouseEventDetails mouseEventDetails) { if (isReadOnly()) { diff --git a/src/com/vaadin/ui/Component.java b/src/com/vaadin/ui/Component.java index 81e0319880..a2c257ab68 100644 --- a/src/com/vaadin/ui/Component.java +++ b/src/com/vaadin/ui/Component.java @@ -11,11 +11,11 @@ import java.util.Locale; import com.vaadin.Application; import com.vaadin.event.FieldEvents; +import com.vaadin.shared.ComponentState; 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.client.ComponentState; import com.vaadin.terminal.gwt.server.ClientConnector; /** @@ -305,6 +305,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * * @return the parent component */ + @Override public HasComponents getParent(); /** @@ -507,6 +508,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * @return the Root of the component or <code>null</code> if it is not * attached to a Root */ + @Override public Root getRoot(); /** @@ -520,8 +522,8 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * <p> * Getting a null value is often a problem in constructors of regular * components and in the initializers of custom composite components. A - * standard workaround is to use {@link Application#getCurrent()} - * to retrieve the application instance that the current request relates to. + * standard workaround is to use {@link Application#getCurrent()} to + * retrieve the application instance that the current request relates to. * Another way is to move the problematic initialization to * {@link #attach()}, as described in the documentation of the method. * </p> @@ -585,6 +587,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * } * </pre> */ + @Override public void attach(); /** @@ -620,6 +623,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * * @since 7.0 */ + @Override public ComponentState getState(); /** diff --git a/src/com/vaadin/ui/ConnectorTracker.java b/src/com/vaadin/ui/ConnectorTracker.java index 75a75ad22a..e3d1bf86db 100644 --- a/src/com/vaadin/ui/ConnectorTracker.java +++ b/src/com/vaadin/ui/ConnectorTracker.java @@ -17,7 +17,7 @@ import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.server.ClientConnector; /** - * A class which takes care of book keeping of {@link ClientConnector}s for one + * A class which takes care of book keeping of {@link ClientConnector}s for a * Root. * <p> * Provides {@link #getConnector(String)} which can be used to lookup a @@ -53,6 +53,14 @@ public class ConnectorTracker implements Serializable { return Logger.getLogger(ConnectorTracker.class.getName()); } + /** + * Creates a new ConnectorTracker for the given root. A tracker is always + * attached to a root and the root cannot be changed during the lifetime of + * a {@link ConnectorTracker}. + * + * @param root + * The root to attach to. Cannot be null. + */ public ConnectorTracker(Root root) { this.root = root; } @@ -144,61 +152,134 @@ public class ConnectorTracker implements Serializable { while (iterator.hasNext()) { String connectorId = iterator.next(); ClientConnector connector = connectorIdToConnector.get(connectorId); - if (connector instanceof Component) { - Component component = (Component) connector; - if (component.getRoot() != root) { - // If component is no longer part of this application, - // remove it from the map. If it is re-attached to the - // application at some point it will be re-added through - // registerConnector(connector) - iterator.remove(); - } + if (getRootForConnector(connector) != root) { + // If connector is no longer part of this root, + // remove it from the map. If it is re-attached to the + // application at some point it will be re-added through + // registerConnector(connector) + + // This code should never be called as cleanup should take place + // in detach() + getLogger() + .warning( + "cleanConnectorMap unregistered connector " + + getConnectorAndParentInfo(connector) + + "). This should have been done when the connector was detached."); + iterator.remove(); } } } + /** + * Finds the root that the connector is attached to. + * + * @param connector + * The connector to lookup + * @return The root the connector is attached to or null if it is not + * attached to any root. + */ + private Root getRootForConnector(ClientConnector connector) { + if (connector == null) { + return null; + } + if (connector instanceof Component) { + return ((Component) connector).getRoot(); + } + + return getRootForConnector(connector.getParent()); + } + + /** + * Mark the connector as dirty. + * + * @see #getDirtyConnectors() + * + * @param connector + * The connector that should be marked clean. + */ public void markDirty(ClientConnector connector) { if (getLogger().isLoggable(Level.FINE)) { if (!dirtyConnectors.contains(connector)) { - getLogger() - .fine(getDebugInfo(connector) + " " + "is now dirty"); + getLogger().fine( + getConnectorAndParentInfo(connector) + " " + + "is now dirty"); } } dirtyConnectors.add(connector); } + /** + * Mark the connector as clean. + * + * @param connector + * The connector that should be marked clean. + */ public void markClean(ClientConnector connector) { if (getLogger().isLoggable(Level.FINE)) { if (dirtyConnectors.contains(connector)) { getLogger().fine( - getDebugInfo(connector) + " " + "is no longer dirty"); + getConnectorAndParentInfo(connector) + " " + + "is no longer dirty"); } } dirtyConnectors.remove(connector); } - private String getDebugInfo(ClientConnector connector) { - String message = getObjectString(connector); + /** + * Returns {@link #getConnectorString(ClientConnector)} for the connector + * and its parent (if it has a parent). + * + * @param connector + * The connector + * @return A string describing the connector and its parent + */ + private String getConnectorAndParentInfo(ClientConnector connector) { + String message = getConnectorString(connector); if (connector.getParent() != null) { - message += " (parent: " + getObjectString(connector.getParent()) + message += " (parent: " + getConnectorString(connector.getParent()) + ")"; } return message; } - private String getObjectString(Object connector) { - return connector.getClass().getName() + "@" - + Integer.toHexString(connector.hashCode()); + /** + * Returns a string with the connector name and id. Useful mostly for + * debugging and logging. + * + * @param connector + * The connector + * @return A string that describes the connector + */ + private String getConnectorString(ClientConnector connector) { + if (connector == null) { + return "(null)"; + } + + String connectorId; + try { + connectorId = connector.getConnectorId(); + } catch (RuntimeException e) { + // This happens if the connector is not attached to the application. + // SHOULD not happen in this case but theoretically can. + connectorId = "@" + Integer.toHexString(connector.hashCode()); + } + return connector.getClass().getName() + "(" + connectorId + ")"; } + /** + * Mark all connectors in this root as dirty. + */ public void markAllConnectorsDirty() { markConnectorsDirtyRecursively(root); getLogger().fine("All connectors are now dirty"); } + /** + * Mark all connectors in this root as clean. + */ public void markAllConnectorsClean() { dirtyConnectors.clear(); getLogger().fine("All connectors are now clean"); @@ -222,6 +303,16 @@ public class ConnectorTracker implements Serializable { } } + /** + * Returns a collection of all connectors which have been marked as dirty. + * <p> + * The state and pending RPC calls for dirty connectors are sent to the + * client in the following request. + * </p> + * + * @return A collection of all dirty connectors for this root. This list may + * contain invisible connectors. + */ public Collection<ClientConnector> getDirtyConnectors() { return dirtyConnectors; } diff --git a/src/com/vaadin/ui/CssLayout.java b/src/com/vaadin/ui/CssLayout.java index e8ec6bd041..356f0a3843 100644 --- a/src/com/vaadin/ui/CssLayout.java +++ b/src/com/vaadin/ui/CssLayout.java @@ -9,11 +9,11 @@ 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.terminal.gwt.client.Connector; -import com.vaadin.terminal.gwt.client.MouseEventDetails; +import com.vaadin.shared.Connector; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.csslayout.CssLayoutServerRpc; +import com.vaadin.shared.ui.csslayout.CssLayoutState; import com.vaadin.terminal.gwt.client.ui.LayoutClickEventHandler; -import com.vaadin.terminal.gwt.client.ui.csslayout.CssLayoutServerRpc; -import com.vaadin.terminal.gwt.client.ui.csslayout.CssLayoutState; /** * CssLayout is a layout component that can be used in browser environment only. @@ -60,6 +60,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { private CssLayoutServerRpc rpc = new CssLayoutServerRpc() { + @Override public void layoutClick(MouseEventDetails mouseDetails, Connector clickedConnector) { fireEvent(LayoutClickEvent.createEvent(CssLayout.this, @@ -167,6 +168,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { * * @return the Iterator of the components inside the container. */ + @Override public Iterator<Component> getComponentIterator() { return components.iterator(); } @@ -177,6 +179,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { * * @return the number of contained components */ + @Override public int getComponentCount() { return components.size(); } @@ -223,6 +226,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { } /* Documented in superclass */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { // Gets the locations @@ -264,12 +268,14 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { } } + @Override public void addListener(LayoutClickListener listener) { addListener(LayoutClickEventHandler.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } + @Override public void removeListener(LayoutClickListener listener) { removeListener(LayoutClickEventHandler.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); diff --git a/src/com/vaadin/ui/CustomComponent.java b/src/com/vaadin/ui/CustomComponent.java index 98d650f6db..40b5dcd636 100644 --- a/src/com/vaadin/ui/CustomComponent.java +++ b/src/com/vaadin/ui/CustomComponent.java @@ -100,20 +100,24 @@ public class CustomComponent extends AbstractComponentContainer { Serializable { boolean first = getCompositionRoot() != null; + @Override public boolean hasNext() { return first; } + @Override public Component next() { first = false; return root; } + @Override public void remove() { throw new UnsupportedOperationException(); } } + @Override public Iterator<Component> getComponentIterator() { return new ComponentIterator(); } @@ -124,6 +128,7 @@ public class CustomComponent extends AbstractComponentContainer { * * @return the number of contained components (zero or one) */ + @Override public int getComponentCount() { return (root != null ? 1 : 0); } @@ -134,6 +139,7 @@ public class CustomComponent extends AbstractComponentContainer { * @see com.vaadin.ui.ComponentContainer#replaceComponent(com.vaadin.ui.Component, * com.vaadin.ui.Component) */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { throw new UnsupportedOperationException(); } diff --git a/src/com/vaadin/ui/CustomField.java b/src/com/vaadin/ui/CustomField.java index 0998c11612..ab3797a58c 100644 --- a/src/com/vaadin/ui/CustomField.java +++ b/src/com/vaadin/ui/CustomField.java @@ -123,28 +123,34 @@ public abstract class CustomField<T> extends AbstractField<T> implements Serializable { boolean first = (root != null); + @Override public boolean hasNext() { return first; } + @Override public Component next() { first = false; return getContent(); } + @Override public void remove() { throw new UnsupportedOperationException(); } } + @Override public Iterator<Component> getComponentIterator() { return new ComponentIterator(); } + @Override public Iterator<Component> iterator() { return getComponentIterator(); } + @Override public int getComponentCount() { return (null != getContent()) ? 1 : 0; } @@ -163,22 +169,27 @@ public abstract class CustomField<T> extends AbstractField<T> implements // TODO remove these methods when ComponentContainer interface is cleaned up + @Override public void addComponent(Component c) { throw new UnsupportedOperationException(); } + @Override public void removeComponent(Component c) { throw new UnsupportedOperationException(); } + @Override public void removeAllComponents() { throw new UnsupportedOperationException(); } + @Override public void replaceComponent(Component oldComponent, Component newComponent) { throw new UnsupportedOperationException(); } + @Override public void moveComponentsFrom(ComponentContainer source) { throw new UnsupportedOperationException(); } @@ -197,24 +208,29 @@ public abstract class CustomField<T> extends AbstractField<T> implements } } + @Override public void addListener(ComponentAttachListener listener) { addListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD); } + @Override public void removeListener(ComponentAttachListener listener) { removeListener(ComponentContainer.ComponentAttachEvent.class, listener, COMPONENT_ATTACHED_METHOD); } + @Override public void addListener(ComponentDetachListener listener) { // content never detached } + @Override public void removeListener(ComponentDetachListener listener) { // content never detached } + @Override public boolean isComponentVisible(Component childComponent) { return true; } diff --git a/src/com/vaadin/ui/CustomLayout.java b/src/com/vaadin/ui/CustomLayout.java index 97cea1c49d..d7830603f0 100644 --- a/src/com/vaadin/ui/CustomLayout.java +++ b/src/com/vaadin/ui/CustomLayout.java @@ -12,10 +12,10 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +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.client.ui.customlayout.CustomLayoutState; import com.vaadin.terminal.gwt.server.JsonPaintTarget; /** @@ -185,6 +185,7 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { * * @return the Iterator of the components inside the container. */ + @Override public Iterator<Component> getComponentIterator() { return slots.values().iterator(); } @@ -195,6 +196,7 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { * * @return the number of contained components */ + @Override public int getComponentCount() { return slots.values().size(); } @@ -212,6 +214,7 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { } /* Documented in superclass */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { // Gets the locations @@ -305,10 +308,12 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { "CustomLayout does not support margins."); } + @Override public void changeVariables(Object source, Map<String, Object> variables) { // Nothing to see here } + @Override public void paintContent(PaintTarget target) throws PaintException { // Workaround to make the CommunicationManager read the template file // and send it to the client diff --git a/src/com/vaadin/ui/DateField.java b/src/com/vaadin/ui/DateField.java index 55ff67229c..d0a22f3c29 100644 --- a/src/com/vaadin/ui/DateField.java +++ b/src/com/vaadin/ui/DateField.java @@ -286,6 +286,7 @@ public class DateField extends AbstractField<Date> implements * Paints this component. Don't add a JavaDoc comment here, we use the * default documentation from implemented interface. */ + @Override public void paintContent(PaintTarget target) throws PaintException { // Adds the locale as attribute @@ -339,6 +340,7 @@ public class DateField extends AbstractField<Date> implements * comment here, we use the default documentation from implemented * interface. */ + @Override public void changeVariables(Object source, Map<String, Object> variables) { if (!isReadOnly() @@ -729,20 +731,24 @@ public class DateField extends AbstractField<Date> implements return lenient; } + @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); } + @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); } diff --git a/src/com/vaadin/ui/DefaultFieldFactory.java b/src/com/vaadin/ui/DefaultFieldFactory.java index 9d096094e3..e17f08c1c6 100644 --- a/src/com/vaadin/ui/DefaultFieldFactory.java +++ b/src/com/vaadin/ui/DefaultFieldFactory.java @@ -35,6 +35,7 @@ public class DefaultFieldFactory implements FormFieldFactory, TableFieldFactory protected DefaultFieldFactory() { } + @Override public Field<?> createField(Item item, Object propertyId, Component uiContext) { Class<?> type = item.getItemProperty(propertyId).getType(); @@ -43,6 +44,7 @@ public class DefaultFieldFactory implements FormFieldFactory, TableFieldFactory return field; } + @Override public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) { Property<?> containerProperty = container.getContainerProperty(itemId, diff --git a/src/com/vaadin/ui/DragAndDropWrapper.java b/src/com/vaadin/ui/DragAndDropWrapper.java index b623197a4c..67229a45fe 100644 --- a/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/src/com/vaadin/ui/DragAndDropWrapper.java @@ -17,13 +17,13 @@ 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.shared.MouseEventDetails; +import com.vaadin.shared.ui.dd.HorizontalDropLocation; +import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.StreamVariable; import com.vaadin.terminal.Vaadin6Component; -import com.vaadin.terminal.gwt.client.MouseEventDetails; -import com.vaadin.terminal.gwt.client.ui.dd.HorizontalDropLocation; -import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; import com.vaadin.terminal.gwt.client.ui.draganddropwrapper.VDragAndDropWrapper; @SuppressWarnings("serial") @@ -214,10 +214,12 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, requestRepaint(); } + @Override public void changeVariables(Object source, Map<String, Object> variables) { // TODO Remove once Vaadin6Component is no longer implemented } + @Override public void paintContent(PaintTarget target) throws PaintException { target.addAttribute(VDragAndDropWrapper.DRAG_START_MODE, dragStartMode.ordinal()); @@ -249,6 +251,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, private DropHandler dropHandler; + @Override public DropHandler getDropHandler() { return dropHandler; } @@ -258,11 +261,13 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, requestRepaint(); } + @Override public TargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { return new WrapperTargetDetails(clientVariables); } + @Override public Transferable getTransferable(final Map<String, Object> rawVariables) { return new WrapperTransferable(this, rawVariables); } @@ -286,6 +291,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, private boolean listenProgressOfUploadedFile; + @Override public OutputStream getOutputStream() { if (file.getStreamVariable() == null) { return null; @@ -293,15 +299,18 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, return file.getStreamVariable().getOutputStream(); } + @Override public boolean listenProgress() { return file.getStreamVariable().listenProgress(); } + @Override public void onProgress(StreamingProgressEvent event) { file.getStreamVariable().onProgress( new ReceivingEventWrapper(event)); } + @Override public void streamingStarted(StreamingStartEvent event) { listenProgressOfUploadedFile = file.getStreamVariable() != null; if (listenProgressOfUploadedFile) { @@ -315,6 +324,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, event.disposeStreamVariable(); } + @Override public void streamingFinished(StreamingEndEvent event) { if (listenProgressOfUploadedFile) { file.getStreamVariable().streamingFinished( @@ -322,6 +332,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, } } + @Override public void streamingFailed(final StreamingErrorEvent event) { if (listenProgressOfUploadedFile) { file.getStreamVariable().streamingFailed( @@ -329,6 +340,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, } } + @Override public boolean isInterrupted() { return file.getStreamVariable().isInterrupted(); } @@ -348,14 +360,17 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, wrappedEvent = e; } + @Override public String getMimeType() { return file.getType(); } + @Override public String getFileName() { return file.getFileName(); } + @Override public long getContentLength() { return file.getFileSize(); } @@ -364,6 +379,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, return ProxyReceiver.this; } + @Override public Exception getException() { if (wrappedEvent instanceof StreamingErrorEvent) { return ((StreamingErrorEvent) wrappedEvent).getException(); @@ -371,6 +387,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, return null; } + @Override public long getBytesReceived() { return wrappedEvent.getBytesReceived(); } @@ -379,6 +396,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, * Calling this method has no effect. DD files are receive only once * anyway. */ + @Override public void disposeStreamVariable() { } diff --git a/src/com/vaadin/ui/Embedded.java b/src/com/vaadin/ui/Embedded.java index 1bcd984666..6088c5aa66 100644 --- a/src/com/vaadin/ui/Embedded.java +++ b/src/com/vaadin/ui/Embedded.java @@ -10,14 +10,14 @@ import java.util.Map; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.shared.MouseEventDetails; +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; -import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.ClickEventHandler; import com.vaadin.terminal.gwt.client.ui.embedded.EmbeddedConnector; -import com.vaadin.terminal.gwt.client.ui.embedded.EmbeddedServerRpc; /** * Component for embedding external objects. @@ -81,6 +81,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { private String altText; private EmbeddedServerRpc rpc = new EmbeddedServerRpc() { + @Override public void click(MouseEventDetails mouseDetails) { fireEvent(new ClickEvent(Embedded.this, mouseDetails)); } @@ -120,6 +121,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { /** * Invoked when the component state should be painted. */ + @Override public void paintContent(PaintTarget target) throws PaintException { switch (type) { @@ -521,6 +523,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { ClickEvent.class, listener); } + @Override public void changeVariables(Object source, Map<String, Object> variables) { // TODO Remove once Vaadin6Component is no longer implemented } diff --git a/src/com/vaadin/ui/Field.java b/src/com/vaadin/ui/Field.java index 3a66db47b0..6dc40d192f 100644 --- a/src/com/vaadin/ui/Field.java +++ b/src/com/vaadin/ui/Field.java @@ -89,6 +89,7 @@ public interface Field<T> extends Component, BufferedValidatable, Property<T>, * * @return the Source Property of the event. */ + @Override public Property getProperty() { return (Property) getSource(); } diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java index 796ad17448..fbc4d5a8e6 100644 --- a/src/com/vaadin/ui/Form.java +++ b/src/com/vaadin/ui/Form.java @@ -24,6 +24,7 @@ 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.shared.ui.form.FormState; import com.vaadin.terminal.AbstractErrorMessage; import com.vaadin.terminal.CompositeErrorMessage; import com.vaadin.terminal.ErrorMessage; @@ -31,7 +32,6 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.UserError; import com.vaadin.terminal.Vaadin6Component; -import com.vaadin.terminal.gwt.client.ui.form.FormState; /** * Form component provides easy way of creating and managing sets fields. @@ -126,6 +126,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * See e.g. DateField#notifyFormOfValidityChange(). */ private final ValueChangeListener fieldValueChangeListener = new ValueChangeListener() { + @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { requestRepaint(); } @@ -194,12 +195,14 @@ public class Form extends AbstractField<Object> implements Item.Editor, } /* Documented in interface */ + @Override public void paintContent(PaintTarget target) throws PaintException { if (ownActionManager != null) { ownActionManager.paintActions(null, target); } } + @Override public void changeVariables(Object source, Map<String, Object> variables) { // Actions if (ownActionManager != null) { @@ -467,6 +470,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * * @see com.vaadin.data.Item#addItemProperty(Object, Property) */ + @Override public boolean addItemProperty(Object id, Property property) { // Checks inputs @@ -598,6 +602,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * * @see com.vaadin.data.Item#getItemProperty(Object) */ + @Override public Property<?> getItemProperty(Object id) { final Field<?> field = fields.get(id); if (field == null) { @@ -624,6 +629,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, } /* Documented in interface */ + @Override public Collection<?> getItemPropertyIds() { return Collections.unmodifiableCollection(propertyIds); } @@ -633,6 +639,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * * @see com.vaadin.data.Item#removeItemProperty(Object) */ + @Override public boolean removeItemProperty(Object id) { ownProperties.remove(id); @@ -687,6 +694,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, } /* Documented in the interface */ + @Override public Item getItemDataSource() { return itemDatasource; } @@ -701,6 +709,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * * @see com.vaadin.data.Item.Viewer#setItemDataSource(Item) */ + @Override public void setItemDataSource(Item newDataSource) { setItemDataSource(newDataSource, newDataSource != null ? newDataSource.getItemPropertyIds() @@ -1301,10 +1310,12 @@ public class Form extends AbstractField<Object> implements Item.Editor, return ownActionManager; } + @Override public void addActionHandler(Handler actionHandler) { getOwnActionManager().addActionHandler(actionHandler); } + @Override public void removeActionHandler(Handler actionHandler) { if (ownActionManager != null) { ownActionManager.removeActionHandler(actionHandler); @@ -1320,11 +1331,13 @@ public class Form extends AbstractField<Object> implements Item.Editor, } } + @Override public <T extends Action & com.vaadin.event.Action.Listener> void addAction( T action) { getOwnActionManager().addAction(action); } + @Override public <T extends Action & com.vaadin.event.Action.Listener> void removeAction( T action) { if (ownActionManager != null) { @@ -1332,6 +1345,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, } } + @Override public Iterator<Component> iterator() { return getComponentIterator(); } @@ -1345,6 +1359,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, int i = 0; + @Override public boolean hasNext() { if (i < getComponentCount()) { return true; @@ -1352,6 +1367,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, return false; } + @Override public Component next() { if (!hasNext()) { return null; @@ -1365,6 +1381,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, return null; } + @Override public void remove() { if (i == 1) { if (getLayout() != null) { @@ -1379,6 +1396,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, } } + @Override public Iterator<Component> getComponentIterator() { return new ComponentIterator(); } @@ -1395,6 +1413,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, return count; } + @Override public boolean isComponentVisible(Component childComponent) { return true; }; diff --git a/src/com/vaadin/ui/GridLayout.java b/src/com/vaadin/ui/GridLayout.java index 0ab729ce5c..2391a9cd3a 100644 --- a/src/com/vaadin/ui/GridLayout.java +++ b/src/com/vaadin/ui/GridLayout.java @@ -15,15 +15,15 @@ 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.shared.Connector; +import com.vaadin.shared.MouseEventDetails; +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; -import com.vaadin.terminal.gwt.client.Connector; -import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.LayoutClickEventHandler; -import com.vaadin.terminal.gwt.client.ui.gridlayout.GridLayoutServerRpc; -import com.vaadin.terminal.gwt.client.ui.gridlayout.GridLayoutState; /** * A layout where the components are laid out on a grid using cell coordinates. @@ -58,6 +58,7 @@ public class GridLayout extends AbstractLayout implements private GridLayoutServerRpc rpc = new GridLayoutServerRpc() { + @Override public void layoutClick(MouseEventDetails mouseDetails, Connector clickedConnector) { fireEvent(LayoutClickEvent.createEvent(GridLayout.this, @@ -417,6 +418,7 @@ public class GridLayout extends AbstractLayout implements * * @return the Iterator of the components inside the layout. */ + @Override public Iterator<Component> getComponentIterator() { return Collections.unmodifiableCollection(components).iterator(); } @@ -427,10 +429,12 @@ public class GridLayout extends AbstractLayout implements * * @return the number of contained components */ + @Override public int getComponentCount() { return components.size(); } + @Override public void changeVariables(Object source, Map<String, Object> variables) { // TODO Remove once Vaadin6Component is no longer implemented } @@ -443,6 +447,7 @@ public class GridLayout extends AbstractLayout implements * @throws PaintException * if the paint operation failed. */ + @Override public void paintContent(PaintTarget target) throws PaintException { // TODO refactor attribute names in future release. target.addAttribute("structuralChange", structuralChange); @@ -668,6 +673,7 @@ public class GridLayout extends AbstractLayout implements * @see com.vaadin.ui.Layout.AlignmentHandler#getComponentAlignment(com * .vaadin.ui.Component) */ + @Override public Alignment getComponentAlignment(Component childComponent) { Alignment alignment = componentToAlignment.get(childComponent); if (alignment == null) { @@ -1094,6 +1100,7 @@ public class GridLayout extends AbstractLayout implements } /* Documented in superclass */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { // Gets the locations @@ -1143,6 +1150,7 @@ public class GridLayout extends AbstractLayout implements * @see com.vaadin.ui.Layout.AlignmentHandler#setComponentAlignment(com * .vaadin.ui.Component, int, int) */ + @Override public void setComponentAlignment(Component childComponent, int horizontalAlignment, int verticalAlignment) { componentToAlignment.put(childComponent, new Alignment( @@ -1150,6 +1158,7 @@ public class GridLayout extends AbstractLayout implements requestRepaint(); } + @Override public void setComponentAlignment(Component childComponent, Alignment alignment) { componentToAlignment.put(childComponent, alignment); @@ -1161,6 +1170,7 @@ public class GridLayout extends AbstractLayout implements * * @see com.vaadin.ui.Layout.SpacingHandler#setSpacing(boolean) */ + @Override public void setSpacing(boolean spacing) { getState().setSpacing(spacing); requestRepaint(); @@ -1171,6 +1181,7 @@ public class GridLayout extends AbstractLayout implements * * @see com.vaadin.ui.Layout.SpacingHandler#isSpacing() */ + @Override public boolean isSpacing() { return getState().isSpacing(); } @@ -1388,12 +1399,14 @@ public class GridLayout extends AbstractLayout implements return null; } + @Override public void addListener(LayoutClickListener listener) { addListener(LayoutClickEventHandler.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } + @Override public void removeListener(LayoutClickListener listener) { removeListener(LayoutClickEventHandler.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); diff --git a/src/com/vaadin/ui/HelloWorldExtension.java b/src/com/vaadin/ui/HelloWorldExtension.java deleted file mode 100644 index e705954f2e..0000000000 --- a/src/com/vaadin/ui/HelloWorldExtension.java +++ /dev/null @@ -1,38 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.ui; - -import com.vaadin.terminal.AbstractExtension; -import com.vaadin.terminal.gwt.client.ui.helloworldfeature.GreetAgainRpc; -import com.vaadin.terminal.gwt.client.ui.helloworldfeature.HelloWorldRpc; -import com.vaadin.terminal.gwt.client.ui.helloworldfeature.HelloWorldState; - -public class HelloWorldExtension extends AbstractExtension { - - public HelloWorldExtension() { - registerRpc(new HelloWorldRpc() { - public void onMessageSent(String message) { - Notification.show(message); - } - }); - } - - @Override - public HelloWorldState getState() { - return (HelloWorldState) super.getState(); - } - - public void setGreeting(String greeting) { - getState().setGreeting(greeting); - requestRepaint(); - } - - public String getGreeting() { - return getState().getGreeting(); - } - - public void greetAgain() { - getRpcProxy(GreetAgainRpc.class).greetAgain(); - } -} diff --git a/src/com/vaadin/ui/JavaScript.java b/src/com/vaadin/ui/JavaScript.java index d256717711..53efb62965 100644 --- a/src/com/vaadin/ui/JavaScript.java +++ b/src/com/vaadin/ui/JavaScript.java @@ -9,11 +9,11 @@ import java.util.Map; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; +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; -import com.vaadin.terminal.gwt.client.communication.ServerRpc; -import com.vaadin.terminal.gwt.client.extensions.javascriptmanager.ExecuteJavaScriptRpc; -import com.vaadin.terminal.gwt.client.extensions.javascriptmanager.JavaScriptManagerState; /** * Provides access to JavaScript functionality in the web browser. To get an @@ -41,6 +41,7 @@ public class JavaScript extends AbstractExtension { */ public JavaScript() { registerRpc(new JavaScriptCallbackRpc() { + @Override public void call(String name, JSONArray arguments) { JavaScriptCallback callback = callbacks.get(name); // TODO handle situation if name is not registered @@ -115,6 +116,16 @@ public class JavaScript extends AbstractExtension { } /** + * Executes the given JavaScript code in the browser. + * + * @param script + * The JavaScript code to run. + */ + public static void eval(String script) { + getCurrent().execute(script); + } + + /** * Get the JavaScript object for the current Page, or null if there is no * current page. * diff --git a/src/com/vaadin/ui/Label.java b/src/com/vaadin/ui/Label.java index e1c64605d7..7e50a37805 100644 --- a/src/com/vaadin/ui/Label.java +++ b/src/com/vaadin/ui/Label.java @@ -5,12 +5,13 @@ package com.vaadin.ui; import java.lang.reflect.Method; +import java.util.logging.Logger; import com.vaadin.data.Property; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.ConverterUtil; -import com.vaadin.terminal.gwt.client.ui.label.ContentMode; -import com.vaadin.terminal.gwt.client.ui.label.LabelState; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.shared.ui.label.LabelState; /** * Label component for showing non-editable short texts. @@ -41,6 +42,9 @@ public class Label extends AbstractComponent implements Property<String>, Property.Viewer, Property.ValueChangeListener, Property.ValueChangeNotifier, Comparable<Label> { + private static final Logger logger = Logger + .getLogger(Label.class.getName()); + /** * @deprecated From 7.0, use {@link ContentMode#TEXT} instead */ @@ -142,11 +146,15 @@ public class Label extends AbstractComponent implements Property<String>, } /** - * Gets the value of the label. Value of the label is the XML contents of - * the label. + * Gets the value of the label. + * <p> + * The value of the label is the text that is shown to the end user. + * Depending on the {@link ContentMode} it is plain text or markup. + * </p> * - * @return the Value of the label. + * @return the value of the label. */ + @Override public String getValue() { if (getPropertyDataSource() == null) { // Use internal value if we are running without a data source @@ -163,6 +171,7 @@ public class Label extends AbstractComponent implements Property<String>, * @param newStringValue * the New value of the label. */ + @Override public void setValue(Object newStringValue) { if (newStringValue != null && newStringValue.getClass() != String.class) { throw new Converter.ConversionException("Value of type " @@ -179,15 +188,20 @@ public class Label extends AbstractComponent implements Property<String>, } /** + * Returns the value displayed by this label. + * * @see java.lang.Object#toString() - * @deprecated use the data source value or {@link #getStringValue()} - * instead + * @deprecated As of 7.0.0, use {@link #getValue()} to get the value of the + * label or {@link #getPropertyDataSource()} .getValue() to get + * the value of the data source. */ @Deprecated @Override public String toString() { - throw new UnsupportedOperationException( - "Use getValue() instead of Label.toString()"); + logger.warning("You are using Label.toString() to get the value for a " + + getClass().getSimpleName() + + ". This is not recommended and will not be supported in future versions."); + return getValue(); } /** @@ -195,6 +209,7 @@ public class Label extends AbstractComponent implements Property<String>, * * @see com.vaadin.data.Property#getType() */ + @Override public Class<String> getType() { return String.class; } @@ -205,6 +220,7 @@ public class Label extends AbstractComponent implements Property<String>, * @return the data source property. * @see com.vaadin.data.Property.Viewer#getPropertyDataSource() */ + @Override public Property getPropertyDataSource() { return dataSource; } @@ -216,6 +232,7 @@ public class Label extends AbstractComponent implements Property<String>, * the new data source Property * @see com.vaadin.data.Property.Viewer#setPropertyDataSource(com.vaadin.data.Property) */ + @Override public void setPropertyDataSource(Property newDataSource) { // Stops listening the old data source changes if (dataSource != null @@ -312,6 +329,7 @@ public class Label extends AbstractComponent implements Property<String>, * * @see com.vaadin.data.Property.ValueChangeEvent#getProperty() */ + @Override public Property getProperty() { return (Property) getSource(); } @@ -324,6 +342,7 @@ public class Label extends AbstractComponent implements Property<String>, * the Listener to be added. * @see com.vaadin.data.Property.ValueChangeNotifier#addListener(com.vaadin.data.Property.ValueChangeListener) */ + @Override public void addListener(Property.ValueChangeListener listener) { addListener(Label.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); } @@ -335,6 +354,7 @@ public class Label extends AbstractComponent implements Property<String>, * the Listener to be removed. * @see com.vaadin.data.Property.ValueChangeNotifier#removeListener(com.vaadin.data.Property.ValueChangeListener) */ + @Override public void removeListener(Property.ValueChangeListener listener) { removeListener(Label.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); @@ -353,6 +373,7 @@ public class Label extends AbstractComponent implements Property<String>, * * @see com.vaadin.data.Property.ValueChangeListener#valueChange(Property.ValueChangeEvent) */ + @Override public void valueChange(Property.ValueChangeEvent event) { // Update the internal value from the data source getState().setText(getValue()); @@ -397,6 +418,7 @@ public class Label extends AbstractComponent implements Property<String>, * less than, equal to, or greater than the specified object. * @see java.lang.Comparable#compareTo(java.lang.Object) */ + @Override public int compareTo(Label other) { String thisValue = getComparableValue(); diff --git a/src/com/vaadin/ui/Layout.java b/src/com/vaadin/ui/Layout.java index 67bfaa75ff..d083f9afdc 100644 --- a/src/com/vaadin/ui/Layout.java +++ b/src/com/vaadin/ui/Layout.java @@ -6,8 +6,8 @@ package com.vaadin.ui; import java.io.Serializable; -import com.vaadin.terminal.gwt.client.ui.AlignmentInfo.Bits; -import com.vaadin.terminal.gwt.client.ui.VMarginInfo; +import com.vaadin.shared.ui.VMarginInfo; +import com.vaadin.shared.ui.AlignmentInfo.Bits; /** * Extension to the {@link ComponentContainer} interface which adds the diff --git a/src/com/vaadin/ui/Link.java b/src/com/vaadin/ui/Link.java index db0dc58e6b..fd105f3255 100644 --- a/src/com/vaadin/ui/Link.java +++ b/src/com/vaadin/ui/Link.java @@ -96,6 +96,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { * @throws PaintException * if the paint operation failed. */ + @Override public void paintContent(PaintTarget target) throws PaintException { if (resource != null) { @@ -234,6 +235,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { requestRepaint(); } + @Override public void changeVariables(Object source, Map<String, Object> variables) { // TODO Remove once Vaadin6Component is no longer implemented } diff --git a/src/com/vaadin/ui/LoginForm.java b/src/com/vaadin/ui/LoginForm.java index 1d5203bc6b..db7e5f9dd9 100644 --- a/src/com/vaadin/ui/LoginForm.java +++ b/src/com/vaadin/ui/LoginForm.java @@ -48,33 +48,40 @@ public class LoginForm extends CustomComponent { 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; } + @Override public String getFilename() { return "login"; } + @Override public DownloadStream getStream() { return new DownloadStream(new ByteArrayInputStream(getLoginHTML()), getMIMEType(), getFilename()); } + @Override public String getMIMEType() { return "text/html; charset=utf-8"; } }; private final RequestHandler requestHandler = new RequestHandler() { + @Override public boolean handleRequest(Application application, WrappedRequest request, WrappedResponse response) throws IOException { @@ -84,7 +91,7 @@ public class LoginForm extends CustomComponent { response.setContentType("text/html; charset=utf-8"); response.getWriter() .write("<html><body>Login form handled." - + "<script type='text/javascript'>top.vaadin.forceSync();" + + "<script type='text/javascript'>parent.parent.vaadin.forceSync();" + "</script></body></html>"); Map<String, String[]> parameters = request.getParameterMap(); diff --git a/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java index f94bd7ea64..5b5dc13e20 100644 --- a/src/com/vaadin/ui/MenuBar.java +++ b/src/com/vaadin/ui/MenuBar.java @@ -39,6 +39,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { private boolean htmlContentAllowed; /** Paint (serialise) the component for the client. */ + @Override public void paintContent(PaintTarget target) throws PaintException { target.addAttribute(VMenuBar.OPEN_ROOT_MENU_ON_HOWER, openRootOnHover); @@ -125,6 +126,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { } /** Deserialize changes received from client. */ + @Override public void changeVariables(Object source, Map<String, Object> variables) { Stack<MenuItem> items = new Stack<MenuItem>(); boolean found = false; diff --git a/src/com/vaadin/ui/Notification.java b/src/com/vaadin/ui/Notification.java index 0358283cb4..502e5ff788 100644 --- a/src/com/vaadin/ui/Notification.java +++ b/src/com/vaadin/ui/Notification.java @@ -76,8 +76,7 @@ public class Notification implements Serializable { /** * Creates a "humanized" notification message. * - * Care should be taken to to avoid XSS vulnerabilities as the caption is by - * default rendered as html. + * The caption is rendered as plain text with HTML automatically escaped. * * @param caption * The message to show @@ -89,8 +88,7 @@ public class Notification implements Serializable { /** * Creates a notification message of the specified type. * - * Care should be taken to to avoid XSS vulnerabilities as the caption is by - * default rendered as html. + * The caption is rendered as plain text with HTML automatically escaped. * * @param caption * The message to show @@ -105,8 +103,8 @@ public class Notification implements Serializable { * Creates a "humanized" notification message with a bigger caption and * smaller description. * - * Care should be taken to to avoid XSS vulnerabilities as the caption and - * description are by default rendered as html. + * The caption and description are rendered as plain text with HTML + * automatically escaped. * * @param caption * The message caption @@ -121,8 +119,8 @@ public class Notification implements Serializable { * Creates a notification message of the specified type, with a bigger * caption and smaller description. * - * Care should be taken to to avoid XSS vulnerabilities as the caption and - * description are by default rendered as html. + * The caption and description are rendered as plain text with HTML + * automatically escaped. * * @param caption * The message caption @@ -132,7 +130,7 @@ public class Notification implements Serializable { * The type of message */ public Notification(String caption, String description, int type) { - this(caption, description, type, true); + this(caption, description, type, false); } /** @@ -335,8 +333,7 @@ public class Notification implements Serializable { * Shows a notification message on the middle of the current page. The * message automatically disappears ("humanized message"). * - * Care should be taken to to avoid XSS vulnerabilities as the caption is - * rendered as html. + * The caption is rendered as plain text with HTML automatically escaped. * * @see #Notification(String) * @see #show(Page) @@ -354,8 +351,7 @@ public class Notification implements Serializable { * defined in {@link Notification}, for instance * Notification.TYPE_WARNING_MESSAGE. * - * Care should be taken to to avoid XSS vulnerabilities as the caption is - * rendered as html. + * The caption is rendered as plain text with HTML automatically escaped. * * @see #Notification(String, int) * @see #show(Page) diff --git a/src/com/vaadin/ui/OptionGroup.java b/src/com/vaadin/ui/OptionGroup.java index a4aaf7ec99..e3bcdd61b7 100644 --- a/src/com/vaadin/ui/OptionGroup.java +++ b/src/com/vaadin/ui/OptionGroup.java @@ -75,20 +75,24 @@ public class OptionGroup extends AbstractSelect implements } } + @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); diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java index c339100cda..3c26b73f09 100644 --- a/src/com/vaadin/ui/Panel.java +++ b/src/com/vaadin/ui/Panel.java @@ -13,14 +13,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.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.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.ClickEventHandler; -import com.vaadin.terminal.gwt.client.ui.panel.PanelServerRpc; -import com.vaadin.terminal.gwt.client.ui.panel.PanelState; import com.vaadin.ui.Component.Focusable; /** @@ -49,6 +49,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, protected ActionManager actionManager; private PanelServerRpc rpc = new PanelServerRpc() { + @Override public void click(MouseEventDetails mouseDetails) { fireEvent(new ClickEvent(Panel.this, mouseDetails)); } @@ -188,6 +189,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * com.vaadin.terminal.Vaadin6Component#paintContent(com.vaadin.terminal * .PaintTarget) */ + @Override public void paintContent(PaintTarget target) throws PaintException { if (actionManager != null) { actionManager.paintActions(null, target); @@ -229,6 +231,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * @return the Iterator of the components inside the container. * @see com.vaadin.ui.ComponentContainer#getComponentIterator() */ + @Override public Iterator<Component> getComponentIterator() { return Collections.singleton((Component) content).iterator(); } @@ -239,6 +242,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.terminal.VariableOwner#changeVariables(Object, Map) */ + @Override @SuppressWarnings("unchecked") public void changeVariables(Object source, Map<String, Object> variables) { // Get new size @@ -277,6 +281,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.terminal.Scrollable#setScrollable(boolean) */ + @Override public int getScrollLeft() { return getState().getScrollLeft(); } @@ -286,6 +291,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.terminal.Scrollable#setScrollable(boolean) */ + @Override public int getScrollTop() { return getState().getScrollTop(); } @@ -295,6 +301,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.terminal.Scrollable#setScrollLeft(int) */ + @Override public void setScrollLeft(int scrollLeft) { if (scrollLeft < 0) { throw new IllegalArgumentException( @@ -309,6 +316,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.terminal.Scrollable#setScrollTop(int) */ + @Override public void setScrollTop(int scrollTop) { if (scrollTop < 0) { throw new IllegalArgumentException( @@ -319,6 +327,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, } /* Documented in superclass */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { content.replaceComponent(oldComponent, newComponent); @@ -329,6 +338,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.ui.ComponentContainer.ComponentAttachListener#componentAttachedToContainer(com.vaadin.ui.ComponentContainer.ComponentAttachEvent) */ + @Override public void componentAttachedToContainer(ComponentAttachEvent event) { if (event.getContainer() == content) { fireComponentAttachEvent(event.getAttachedComponent()); @@ -340,6 +350,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.ui.ComponentContainer.ComponentDetachListener#componentDetachedFromContainer(com.vaadin.ui.ComponentContainer.ComponentDetachEvent) */ + @Override public void componentDetachedFromContainer(ComponentDetachEvent event) { if (event.getContainer() == content) { fireComponentDetachEvent(event.getDetachedComponent()); @@ -367,11 +378,13 @@ public class Panel extends AbstractComponentContainer implements Scrollable, return actionManager; } + @Override public <T extends Action & com.vaadin.event.Action.Listener> void addAction( T action) { getActionManager().addAction(action); } + @Override public <T extends Action & com.vaadin.event.Action.Listener> void removeAction( T action) { if (actionManager != null) { @@ -379,10 +392,12 @@ public class Panel extends AbstractComponentContainer implements Scrollable, } } + @Override public void addActionHandler(Handler actionHandler) { getActionManager().addActionHandler(actionHandler); } + @Override public void removeActionHandler(Handler actionHandler) { if (actionManager != null) { actionManager.removeActionHandler(actionHandler); @@ -429,6 +444,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, /** * {@inheritDoc} */ + @Override public int getTabIndex() { return getState().getTabIndex(); } @@ -436,6 +452,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, /** * {@inheritDoc} */ + @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); requestRepaint(); @@ -455,6 +472,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.ui.ComponentContainer#getComponentCount() */ + @Override public int getComponentCount() { // This is so wrong... (#2924) return content.getComponentCount(); diff --git a/src/com/vaadin/ui/PopupView.java b/src/com/vaadin/ui/PopupView.java index 911d926053..766181b50f 100644 --- a/src/com/vaadin/ui/PopupView.java +++ b/src/com/vaadin/ui/PopupView.java @@ -58,10 +58,12 @@ public class PopupView extends AbstractComponentContainer implements first = (component == null); } + @Override public boolean hasNext() { return !first; } + @Override public Component next() { if (!first) { first = true; @@ -71,6 +73,7 @@ public class PopupView extends AbstractComponentContainer implements } } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -90,10 +93,12 @@ public class PopupView extends AbstractComponentContainer implements */ public PopupView(final java.lang.String small, final Component large) { this(new PopupView.Content() { + @Override public java.lang.String getMinimizedValueAsHTML() { return small; } + @Override public Component getPopupComponent() { return large; } @@ -223,6 +228,7 @@ public class PopupView extends AbstractComponentContainer implements * * @see com.vaadin.ui.ComponentContainer#getComponentIterator() */ + @Override public Iterator<Component> getComponentIterator() { return new SingleComponentIterator(visibleComponent); } @@ -233,6 +239,7 @@ public class PopupView extends AbstractComponentContainer implements * * @return the number of contained components (zero or one) */ + @Override public int getComponentCount() { return (visibleComponent != null ? 1 : 0); } @@ -280,6 +287,7 @@ public class PopupView extends AbstractComponentContainer implements * com.vaadin.ui.Component) * @throws UnsupportedOperationException */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) throws UnsupportedOperationException { @@ -307,6 +315,7 @@ public class PopupView extends AbstractComponentContainer implements * * @see com.vaadin.ui.AbstractComponent#paintContent(com.vaadin.terminal.PaintTarget) */ + @Override public void paintContent(PaintTarget target) throws PaintException { String html = content.getMinimizedValueAsHTML(); if (html == null) { @@ -331,6 +340,7 @@ public class PopupView extends AbstractComponentContainer implements * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, * java.util.Map) */ + @Override public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey("popupVisibility")) { setPopupVisible(((Boolean) variables.get("popupVisibility")) diff --git a/src/com/vaadin/ui/ProgressIndicator.java b/src/com/vaadin/ui/ProgressIndicator.java index 4d585cfdd7..fef54a267c 100644 --- a/src/com/vaadin/ui/ProgressIndicator.java +++ b/src/com/vaadin/ui/ProgressIndicator.java @@ -111,6 +111,7 @@ public class ProgressIndicator extends AbstractField<Number> implements * @throws PaintException * if the Paint Operation fails. */ + @Override public void paintContent(PaintTarget target) throws PaintException { target.addAttribute("indeterminate", indeterminate); target.addAttribute("pollinginterval", pollingInterval); @@ -247,6 +248,7 @@ public class ProgressIndicator extends AbstractField<Number> implements return pollingInterval; } + @Override public void changeVariables(Object source, Map<String, Object> variables) { // TODO Remove once Vaadin6Component is no longer implemented diff --git a/src/com/vaadin/ui/RichTextArea.java b/src/com/vaadin/ui/RichTextArea.java index 16d4761b40..cec952926b 100644 --- a/src/com/vaadin/ui/RichTextArea.java +++ b/src/com/vaadin/ui/RichTextArea.java @@ -103,6 +103,7 @@ public class RichTextArea extends AbstractField<String> implements setCaption(caption); } + @Override public void paintContent(PaintTarget target) throws PaintException { if (selectAll) { target.addAttribute("selectAll", true); @@ -185,6 +186,7 @@ public class RichTextArea extends AbstractField<String> implements } } + @Override public void changeVariables(Object source, Map<String, Object> variables) { // Sets the text if (variables.containsKey("text") && !isReadOnly()) { diff --git a/src/com/vaadin/ui/Root.java b/src/com/vaadin/ui/Root.java index 7ae687be79..bd4842632b 100644 --- a/src/com/vaadin/ui/Root.java +++ b/src/com/vaadin/ui/Root.java @@ -20,6 +20,9 @@ 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.shared.MouseEventDetails; +import com.vaadin.shared.ui.root.RootServerRpc; +import com.vaadin.shared.ui.root.RootState; import com.vaadin.terminal.Page; import com.vaadin.terminal.Page.BrowserWindowResizeEvent; import com.vaadin.terminal.Page.BrowserWindowResizeListener; @@ -29,9 +32,6 @@ 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.client.MouseEventDetails; -import com.vaadin.terminal.gwt.client.ui.root.RootServerRpc; -import com.vaadin.terminal.gwt.client.ui.root.RootState; import com.vaadin.terminal.gwt.client.ui.root.VRoot; import com.vaadin.ui.Window.CloseListener; @@ -419,6 +419,7 @@ public abstract class Root extends AbstractComponentContainer implements private Page page = new Page(this); private RootServerRpc rpc = new RootServerRpc() { + @Override public void click(MouseEventDetails mouseDetails) { fireEvent(new ClickEvent(Root.this, mouseDetails)); } @@ -502,6 +503,7 @@ public abstract class Root extends AbstractComponentContainer implements return this; } + @Override public void replaceComponent(Component oldComponent, Component newComponent) { throw new UnsupportedOperationException(); } @@ -511,6 +513,7 @@ public abstract class Root extends AbstractComponentContainer implements return application; } + @Override public void paintContent(PaintTarget target) throws PaintException { page.paintContent(target); @@ -550,6 +553,7 @@ public abstract class Root extends AbstractComponentContainer implements fireEvent(new ClickEvent(this, mouseDetails)); } + @Override @SuppressWarnings("unchecked") public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey(CLICK_EVENT_ID)) { @@ -578,6 +582,7 @@ public abstract class Root extends AbstractComponentContainer implements * * @see com.vaadin.ui.ComponentContainer#getComponentIterator() */ + @Override public Iterator<Component> getComponentIterator() { // TODO could directly create some kind of combined iterator instead of // creating a new ArrayList @@ -597,6 +602,7 @@ public abstract class Root extends AbstractComponentContainer implements * * @see com.vaadin.ui.ComponentContainer#getComponentCount() */ + @Override public int getComponentCount() { return windows.size() + (getContent() == null ? 0 : 1); } @@ -956,11 +962,13 @@ public abstract class Root extends AbstractComponentContainer implements return actionManager; } + @Override public <T extends Action & com.vaadin.event.Action.Listener> void addAction( T action) { getActionManager().addAction(action); } + @Override public <T extends Action & com.vaadin.event.Action.Listener> void removeAction( T action) { if (actionManager != null) { @@ -968,10 +976,12 @@ public abstract class Root extends AbstractComponentContainer implements } } + @Override public void addActionHandler(Handler actionHandler) { getActionManager().addActionHandler(actionHandler); } + @Override public void removeActionHandler(Handler actionHandler) { if (actionManager != null) { actionManager.removeActionHandler(actionHandler); @@ -1071,11 +1081,14 @@ public abstract class Root extends AbstractComponentContainer implements * @param caption * The message * - * @deprecated As of 7.0, use Notification.show instead + * @deprecated As of 7.0, use Notification.show instead but be aware that + * Notification.show does not allow HTML. */ @Deprecated public void showNotification(String caption) { - getPage().showNotification(new Notification(caption)); + Notification notification = new Notification(caption); + notification.setHtmlContentAllowed(true);// Backwards compatibility + getPage().showNotification(notification); } /** @@ -1094,11 +1107,14 @@ public abstract class Root extends AbstractComponentContainer implements * @param type * The message type * - * @deprecated As of 7.0, use Notification.show instead + * @deprecated As of 7.0, use Notification.show instead but be aware that + * Notification.show does not allow HTML. */ @Deprecated public void showNotification(String caption, int type) { - getPage().showNotification(new Notification(caption, type)); + Notification notification = new Notification(caption, type); + notification.setHtmlContentAllowed(true);// Backwards compatibility + getPage().showNotification(notification); } /** @@ -1117,11 +1133,14 @@ public abstract class Root extends AbstractComponentContainer implements * @param description * The message description * - * @deprecated As of 7.0, use Notification.show instead + * @deprecated As of 7.0, use new Notification(...).show(Page) instead but + * be aware that HTML by default not allowed. */ @Deprecated public void showNotification(String caption, String description) { - getPage().showNotification(new Notification(caption, description)); + Notification notification = new Notification(caption, description); + notification.setHtmlContentAllowed(true);// Backwards compatibility + getPage().showNotification(notification); } /** @@ -1143,12 +1162,14 @@ public abstract class Root extends AbstractComponentContainer implements * @param type * The message type * - * @deprecated As of 7.0, use Notification.show instead + * @deprecated As of 7.0, use new Notification(...).show(Page) instead but + * be aware that HTML by default not allowed. */ @Deprecated public void showNotification(String caption, String description, int type) { - getPage() - .showNotification(new Notification(caption, description, type)); + Notification notification = new Notification(caption, description, type); + notification.setHtmlContentAllowed(true);// Backwards compatibility + getPage().showNotification(notification); } /** @@ -1173,7 +1194,7 @@ public abstract class Root extends AbstractComponentContainer implements * Whether html in the caption and description should be * displayed as html or as plain text * - * @deprecated As of 7.0, use Notification.show instead + * @deprecated As of 7.0, use new Notification(...).show(Page). */ @Deprecated public void showNotification(String caption, String description, int type, diff --git a/src/com/vaadin/ui/Select.java b/src/com/vaadin/ui/Select.java index 5398f11391..f60935c64b 100644 --- a/src/com/vaadin/ui/Select.java +++ b/src/com/vaadin/ui/Select.java @@ -677,10 +677,12 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, super.requestRepaint(); } + @Override public void setFilteringMode(int filteringMode) { this.filteringMode = filteringMode; } + @Override public int getFilteringMode() { return filteringMode; } @@ -719,20 +721,24 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, return columns; } + @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); diff --git a/src/com/vaadin/ui/Slider.java b/src/com/vaadin/ui/Slider.java index dc5dc0be98..94afe4e2bd 100644 --- a/src/com/vaadin/ui/Slider.java +++ b/src/com/vaadin/ui/Slider.java @@ -278,6 +278,7 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { super.setValue(newFieldValue); } + @Override public void paintContent(PaintTarget target) throws PaintException { target.addAttribute("min", min); @@ -307,6 +308,7 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component { * @param source * @param variables */ + @Override public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey("value")) { final Object value = variables.get("value"); diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index 061809de67..c52e9394c0 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -109,6 +109,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, setImmediate(true); setCloseHandler(new CloseHandler() { + @Override public void onTabClose(TabSheet tabsheet, Component c) { tabsheet.removeComponent(c); } @@ -122,6 +123,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * @return the unmodifiable Iterator of the tab content components */ + @Override public Iterator<Component> getComponentIterator() { return Collections.unmodifiableList(components).iterator(); } @@ -133,6 +135,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * @return the number of contained components */ + @Override public int getComponentCount() { return components.size(); } @@ -366,6 +369,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * if the paint operation failed. */ + @Override public void paintContent(PaintTarget target) throws PaintException { if (areTabsHidden()) { @@ -691,6 +695,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, // inherits javadoc + @Override public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey("selected")) { setSelectedTab(keyMapper.get((String) variables.get("selected"))); @@ -728,6 +733,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * {@inheritDoc} */ + @Override public void replaceComponent(Component oldComponent, Component newComponent) { if (selected == oldComponent) { @@ -1083,28 +1089,34 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * Returns the tab caption. Can never be null. */ + @Override public String getCaption() { return caption; } + @Override public void setCaption(String caption) { this.caption = caption; requestRepaint(); } + @Override public Resource getIcon() { return icon; } + @Override public void setIcon(Resource icon) { this.icon = icon; requestRepaint(); } + @Override public boolean isEnabled() { return enabled; } + @Override public void setEnabled(boolean enabled) { this.enabled = enabled; if (updateSelection()) { @@ -1113,10 +1125,12 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, requestRepaint(); } + @Override public boolean isVisible() { return visible; } + @Override public void setVisible(boolean visible) { this.visible = visible; if (updateSelection()) { @@ -1125,10 +1139,12 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, requestRepaint(); } + @Override public boolean isClosable() { return closable; } + @Override public void setClosable(boolean closable) { this.closable = closable; requestRepaint(); @@ -1138,24 +1154,29 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, } + @Override public String getDescription() { return description; } + @Override public void setDescription(String description) { this.description = description; requestRepaint(); } + @Override public ErrorMessage getComponentError() { return componentError; } + @Override public void setComponentError(ErrorMessage componentError) { this.componentError = componentError; requestRepaint(); } + @Override public Component getComponent() { for (Map.Entry<Component, Tab> entry : tabs.entrySet()) { if (entry.getValue() == this) { @@ -1165,11 +1186,13 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, return null; } + @Override public void setStyleName(String styleName) { this.styleName = styleName; requestRepaint(); } + @Override public String getStyleName() { return styleName; } @@ -1245,29 +1268,35 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, super.focus(); } + @Override public int getTabIndex() { return tabIndex; } + @Override public void setTabIndex(int tabIndex) { this.tabIndex = tabIndex; requestRepaint(); } + @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); diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index a1cc4f95fe..39b7fb7473 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -40,12 +40,12 @@ 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.shared.MouseEventDetails; 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.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.table.VScrollTable; /** @@ -538,6 +538,13 @@ public class Table extends AbstractSelect implements Action.Container, private HashMap<Object, Converter<String, Object>> propertyValueConverters = new HashMap<Object, Converter<String, Object>>(); + /** + * Set to true if the client-side should be informed that the key mapper has + * been reset so it can avoid sending back references to keys that are no + * longer present. + */ + private boolean keyMapperReset; + /* Table constructors */ /** @@ -1587,9 +1594,10 @@ public class Table extends AbstractSelect implements Action.Container, // Collects the basic facts about the table page final int pagelen = getPageLength(); - int firstIndex = getCurrentPageFirstItemIndex(); int rows, totalRows; rows = totalRows = size(); + int firstIndex = Math + .min(getCurrentPageFirstItemIndex(), totalRows - 1); if (rows > 0 && firstIndex >= 0) { rows -= firstIndex; } @@ -2409,8 +2417,9 @@ public class Table extends AbstractSelect implements Action.Container, * The end key * @return */ - private Set<Object> getItemIdsInRange(Object itemId, final int length) { - HashSet<Object> ids = new HashSet<Object>(); + private LinkedHashSet<Object> getItemIdsInRange(Object itemId, + final int length) { + LinkedHashSet<Object> ids = new LinkedHashSet<Object>(); for (int i = 0; i < length; i++) { assert itemId != null; // should not be null unless client-server // are out of sync @@ -2430,21 +2439,15 @@ public class Table extends AbstractSelect implements Action.Container, final String[] ka = (String[]) variables.get("selected"); final String[] ranges = (String[]) variables.get("selectedRanges"); - Set<Object> renderedItemIds = getCurrentlyRenderedItemIds(); + Set<Object> renderedButNotSelectedItemIds = getCurrentlyRenderedItemIds(); @SuppressWarnings("unchecked") - HashSet<Object> newValue = new HashSet<Object>( + HashSet<Object> newValue = new LinkedHashSet<Object>( (Collection<Object>) getValue()); if (variables.containsKey("clearSelections")) { // the client side has instructed to swipe all previous selections newValue.clear(); - } else { - /* - * first clear all selections that are currently rendered rows (the - * ones that the client side counterpart is aware of) - */ - newValue.removeAll(renderedItemIds); } /* @@ -2461,6 +2464,7 @@ public class Table extends AbstractSelect implements Action.Container, requestRepaint(); } else if (id != null && containsId(id)) { newValue.add(id); + renderedButNotSelectedItemIds.remove(id); } } @@ -2470,9 +2474,17 @@ public class Table extends AbstractSelect implements Action.Container, String[] split = range.split("-"); Object startItemId = itemIdMapper.get(split[0]); int length = Integer.valueOf(split[1]); - newValue.addAll(getItemIdsInRange(startItemId, length)); + LinkedHashSet<Object> itemIdsInRange = getItemIdsInRange( + startItemId, length); + newValue.addAll(itemIdsInRange); + renderedButNotSelectedItemIds.removeAll(itemIdsInRange); } } + /* + * finally clear all currently rendered rows (the ones that the client + * side counterpart is aware of) that the client didn't send as selected + */ + newValue.removeAll(renderedButNotSelectedItemIds); if (!isNullSelectionAllowed() && newValue.isEmpty()) { // empty selection not allowed, keep old value @@ -2885,6 +2897,11 @@ public class Table extends AbstractSelect implements Action.Container, paintVisibleColumns(target); + if (keyMapperReset) { + keyMapperReset = false; + target.addAttribute(VScrollTable.ATTRIBUTE_KEY_MAPPER_RESET, true); + } + if (dropHandler != null) { dropHandler.getAcceptCriterion().paint(target); } @@ -3681,6 +3698,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.event.Action.Container#addActionHandler(Action.Handler) */ + @Override public void addActionHandler(Action.Handler actionHandler) { if (actionHandler != null) { @@ -3708,6 +3726,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.event.Action.Container#removeActionHandler(Action.Handler) */ + @Override public void removeActionHandler(Action.Handler actionHandler) { if (actionHandlers != null && actionHandlers.contains(actionHandler)) { @@ -4046,6 +4065,10 @@ public class Table extends AbstractSelect implements Action.Container, public void containerItemSetChange(Container.ItemSetChangeEvent event) { super.containerItemSetChange(event); + // super method clears the key map, must inform client about this to + // avoid getting invalid keys back (#8584) + keyMapperReset = true; + // ensure that page still has first item in page, ignore buffer refresh // (forced in this method) setCurrentPageFirstItemIndex(getCurrentPageFirstItemIndex(), false); @@ -4117,6 +4140,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Ordered#nextItemId(java.lang.Object) */ + @Override public Object nextItemId(Object itemId) { return ((Container.Ordered) items).nextItemId(itemId); } @@ -4128,6 +4152,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Ordered#prevItemId(java.lang.Object) */ + @Override public Object prevItemId(Object itemId) { return ((Container.Ordered) items).prevItemId(itemId); } @@ -4138,6 +4163,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Ordered#firstItemId() */ + @Override public Object firstItemId() { return ((Container.Ordered) items).firstItemId(); } @@ -4148,6 +4174,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Ordered#lastItemId() */ + @Override public Object lastItemId() { return ((Container.Ordered) items).lastItemId(); } @@ -4159,6 +4186,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Ordered#isFirstId(java.lang.Object) */ + @Override public boolean isFirstId(Object itemId) { return ((Container.Ordered) items).isFirstId(itemId); } @@ -4170,6 +4198,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Ordered#isLastId(java.lang.Object) */ + @Override public boolean isLastId(Object itemId) { return ((Container.Ordered) items).isLastId(itemId); } @@ -4180,6 +4209,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Ordered#addItemAfter(java.lang.Object) */ + @Override public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException { Object itemId = ((Container.Ordered) items) @@ -4197,6 +4227,7 @@ public class Table extends AbstractSelect implements Action.Container, * java.lang.Object) */ + @Override public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException { Item item = ((Container.Ordered) items).addItemAfter(previousItemId, @@ -4290,6 +4321,7 @@ public class Table extends AbstractSelect implements Action.Container, * */ + @Override public void sort(Object[] propertyId, boolean[] ascending) throws UnsupportedOperationException { final Container c = getContainerDataSource(); @@ -4331,6 +4363,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() */ + @Override public Collection<?> getSortableContainerPropertyIds() { final Container c = getContainerDataSource(); if (c instanceof Container.Sortable && isSortEnabled()) { @@ -4544,11 +4577,13 @@ public class Table extends AbstractSelect implements Action.Container, public abstract String getStyle(Object itemId, Object propertyId); } + @Override public void addListener(ItemClickListener listener) { addListener(VScrollTable.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener, ItemClickEvent.ITEM_CLICK_METHOD); } + @Override public void removeListener(ItemClickListener listener) { removeListener(VScrollTable.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener); @@ -4625,11 +4660,13 @@ public class Table extends AbstractSelect implements Action.Container, } + @Override public TableTransferable getTransferable(Map<String, Object> rawVariables) { TableTransferable transferable = new TableTransferable(rawVariables); return transferable; } + @Override public DropHandler getDropHandler() { return dropHandler; } @@ -4638,6 +4675,7 @@ public class Table extends AbstractSelect implements Action.Container, this.dropHandler = dropHandler; } + @Override public AbstractSelectTargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { return new AbstractSelectTargetDetails(clientVariables); @@ -4706,6 +4744,7 @@ public class Table extends AbstractSelect implements Action.Container, * com.vaadin.event.dd.acceptcriteria.AcceptCriterion#accepts(com.vaadin * .event.dd.DragAndDropEvent) */ + @Override @SuppressWarnings("unchecked") public boolean accept(DragAndDropEvent dragEvent) { AbstractSelectTargetDetails dropTargetData = (AbstractSelectTargetDetails) dragEvent @@ -5381,10 +5420,12 @@ public class Table extends AbstractSelect implements Action.Container, super.setVisible(visible); } + @Override public Iterator<Component> iterator() { return getComponentIterator(); } + @Override public Iterator<Component> getComponentIterator() { if (visibleComponents == null) { Collection<Component> empty = Collections.emptyList(); @@ -5394,6 +5435,7 @@ public class Table extends AbstractSelect implements Action.Container, return visibleComponents.iterator(); } + @Override public boolean isComponentVisible(Component childComponent) { return true; } diff --git a/src/com/vaadin/ui/TextArea.java b/src/com/vaadin/ui/TextArea.java index 4c0b563b00..d7837dd33f 100644 --- a/src/com/vaadin/ui/TextArea.java +++ b/src/com/vaadin/ui/TextArea.java @@ -5,7 +5,7 @@ package com.vaadin.ui; import com.vaadin.data.Property; -import com.vaadin.terminal.gwt.client.ui.textarea.TextAreaState; +import com.vaadin.shared.ui.textarea.TextAreaState; /** * A text field that supports multi line editing. diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java index dacb3a2027..c15975d879 100644 --- a/src/com/vaadin/ui/Tree.java +++ b/src/com/vaadin/ui/Tree.java @@ -37,12 +37,12 @@ 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.shared.MouseEventDetails; +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.gwt.client.MouseEventDetails; -import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; import com.vaadin.terminal.gwt.client.ui.tree.TreeConnector; import com.vaadin.terminal.gwt.client.ui.tree.VTree; import com.vaadin.tools.ReflectTools; @@ -721,6 +721,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.data.Container.Hierarchical#areChildrenAllowed(Object) */ + @Override public boolean areChildrenAllowed(Object itemId) { return ((Container.Hierarchical) items).areChildrenAllowed(itemId); } @@ -730,6 +731,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.data.Container.Hierarchical#getChildren(Object) */ + @Override public Collection<?> getChildren(Object itemId) { return ((Container.Hierarchical) items).getChildren(itemId); } @@ -739,6 +741,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.data.Container.Hierarchical#getParent(Object) */ + @Override public Object getParent(Object itemId) { return ((Container.Hierarchical) items).getParent(itemId); } @@ -748,6 +751,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.data.Container.Hierarchical#hasChildren(Object) */ + @Override public boolean hasChildren(Object itemId) { return ((Container.Hierarchical) items).hasChildren(itemId); } @@ -757,6 +761,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.data.Container.Hierarchical#isRoot(Object) */ + @Override public boolean isRoot(Object itemId) { return ((Container.Hierarchical) items).isRoot(itemId); } @@ -766,6 +771,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.data.Container.Hierarchical#rootItemIds() */ + @Override public Collection<?> rootItemIds() { return ((Container.Hierarchical) items).rootItemIds(); } @@ -776,6 +782,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @see com.vaadin.data.Container.Hierarchical#setChildrenAllowed(Object, * boolean) */ + @Override public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) { final boolean success = ((Container.Hierarchical) items) .setChildrenAllowed(itemId, areChildrenAllowed); @@ -791,6 +798,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @see com.vaadin.data.Container.Hierarchical#setParent(java.lang.Object , * java.lang.Object) */ + @Override public boolean setParent(Object itemId, Object newParentId) { final boolean success = ((Container.Hierarchical) items).setParent( itemId, newParentId); @@ -1015,6 +1023,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.event.Action.Container#addActionHandler(Action.Handler) */ + @Override public void addActionHandler(Action.Handler actionHandler) { if (actionHandler != null) { @@ -1036,6 +1045,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.event.Action.Container#removeActionHandler(Action.Handler) */ + @Override public void removeActionHandler(Action.Handler actionHandler) { if (actionHandlers != null && actionHandlers.contains(actionHandler)) { @@ -1150,11 +1160,13 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, private DropHandler dropHandler; + @Override public void addListener(ItemClickListener listener) { addListener(VTree.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener, ItemClickEvent.ITEM_CLICK_METHOD); } + @Override public void removeListener(ItemClickListener listener) { removeListener(VTree.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, listener); @@ -1206,6 +1218,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, return super.removeItem(itemId); } + @Override public DropHandler getDropHandler() { return dropHandler; } @@ -1304,6 +1317,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @see * com.vaadin.event.dd.DropTarget#translateDropTargetDetails(java.util.Map) */ + @Override public TreeTargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { return new TreeTargetDetails(clientVariables); @@ -1371,6 +1385,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.event.dd.DragSource#getTransferable(java.util.Map) */ + @Override public Transferable getTransferable(Map<String, Object> payload) { TreeTransferable transferable = new TreeTransferable(this, payload); // updating drag source variables @@ -1418,6 +1433,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * com.vaadin.event.dd.acceptCriteria.AcceptCriterion#accepts(com.vaadin * .event.dd.DragAndDropEvent) */ + @Override public boolean accept(DragAndDropEvent dragEvent) { AbstractSelectTargetDetails dropTargetData = (AbstractSelectTargetDetails) dragEvent .getTargetDetails(); @@ -1541,6 +1557,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, this.depthToCheck = depthToCheck; } + @Override public boolean accept(DragAndDropEvent dragEvent) { try { TreeTargetDetails eventDetails = (TreeTargetDetails) dragEvent diff --git a/src/com/vaadin/ui/TreeTable.java b/src/com/vaadin/ui/TreeTable.java index 3294f6fab0..6132b652f7 100644 --- a/src/com/vaadin/ui/TreeTable.java +++ b/src/com/vaadin/ui/TreeTable.java @@ -82,6 +82,7 @@ public class TreeTable extends Table implements Hierarchical { * scalability with some container implementations. */ + @Override public int getDepth(Object itemId) { int depth = 0; Hierarchical hierarchicalContainer = getContainerDataSource(); @@ -92,6 +93,7 @@ public class TreeTable extends Table implements Hierarchical { return depth; } + @Override public void containerItemSetChange(ItemSetChangeEvent event) { } @@ -110,44 +112,54 @@ public class TreeTable extends Table implements Hierarchical { return (Collapsible) getContainerDataSource(); } + @Override public void toggleChildVisibility(Object itemId) { c().setCollapsed(itemId, !c().isCollapsed(itemId)); } + @Override public boolean isNodeOpen(Object itemId) { return !c().isCollapsed(itemId); } + @Override public int size() { return TreeTable.super.size(); } + @Override public Object getIdByIndex(int index) { return TreeTable.super.getIdByIndex(index); } + @Override public int indexOfId(Object id) { return TreeTable.super.indexOfId(id); } + @Override public boolean isLastId(Object itemId) { // using the default impl return TreeTable.super.isLastId(itemId); } + @Override public Object lastItemId() { // using the default impl return TreeTable.super.lastItemId(); } + @Override public Object nextItemId(Object itemId) { return TreeTable.super.nextItemId(itemId); } + @Override public Object prevItemId(Object itemId) { return TreeTable.super.prevItemId(itemId); } + @Override public Collection<?> getItemIds() { return TreeTable.super.getItemIds(); } @@ -165,18 +177,22 @@ public class TreeTable extends Table implements Hierarchical { private final HashSet<Object> openItems = new HashSet<Object>(); + @Override public boolean isNodeOpen(Object itemId) { return openItems.contains(itemId); } + @Override public int size() { return getPreOrder().size(); } + @Override public Collection<Object> getItemIds() { return Collections.unmodifiableCollection(getPreOrder()); } + @Override public boolean isLastId(Object itemId) { if (itemId == null) { return false; @@ -185,6 +201,7 @@ public class TreeTable extends Table implements Hierarchical { return itemId.equals(lastItemId()); } + @Override public Object lastItemId() { if (getPreOrder().size() > 0) { return getPreOrder().get(getPreOrder().size() - 1); @@ -193,6 +210,7 @@ public class TreeTable extends Table implements Hierarchical { } } + @Override public Object nextItemId(Object itemId) { int indexOf = getPreOrder().indexOf(itemId); if (indexOf == -1) { @@ -206,6 +224,7 @@ public class TreeTable extends Table implements Hierarchical { } } + @Override public Object prevItemId(Object itemId) { int indexOf = getPreOrder().indexOf(itemId); indexOf--; @@ -216,6 +235,7 @@ public class TreeTable extends Table implements Hierarchical { } } + @Override public void toggleChildVisibility(Object itemId) { boolean removed = openItems.remove(itemId); if (!removed) { @@ -265,10 +285,12 @@ public class TreeTable extends Table implements Hierarchical { } + @Override public int indexOfId(Object id) { return getPreOrder().indexOf(id); } + @Override public Object getIdByIndex(int index) { return getPreOrder().get(index); } @@ -610,36 +632,44 @@ public class TreeTable extends Table implements Hierarchical { return getContainerStrategy().getItemIds(); } + @Override public boolean areChildrenAllowed(Object itemId) { return getContainerDataSource().areChildrenAllowed(itemId); } + @Override public Collection<?> getChildren(Object itemId) { return getContainerDataSource().getChildren(itemId); } + @Override public Object getParent(Object itemId) { return getContainerDataSource().getParent(itemId); } + @Override public boolean hasChildren(Object itemId) { return getContainerDataSource().hasChildren(itemId); } + @Override public boolean isRoot(Object itemId) { return getContainerDataSource().isRoot(itemId); } + @Override public Collection<?> rootItemIds() { return getContainerDataSource().rootItemIds(); } + @Override public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException { return getContainerDataSource().setChildrenAllowed(itemId, areChildrenAllowed); } + @Override public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException { return getContainerDataSource().setParent(itemId, newParentId); diff --git a/src/com/vaadin/ui/Upload.java b/src/com/vaadin/ui/Upload.java index 4dff71e45b..9d533b67f6 100644 --- a/src/com/vaadin/ui/Upload.java +++ b/src/com/vaadin/ui/Upload.java @@ -122,6 +122,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, * java.util.Map) */ + @Override public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey("pollForStart")) { int id = (Integer) variables.get("pollForStart"); @@ -141,6 +142,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, * @throws PaintException * if the paint operation failed. */ + @Override public void paintContent(PaintTarget target) throws PaintException { if (notStarted) { target.addAttribute("notStarted", true); @@ -782,6 +784,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, * * @see com.vaadin.ui.Component.Focusable#getTabIndex() */ + @Override public int getTabIndex() { return tabIndex; } @@ -791,6 +794,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, * * @see com.vaadin.ui.Component.Focusable#setTabIndex(int) */ + @Override public void setTabIndex(int tabIndex) { this.tabIndex = tabIndex; } @@ -974,20 +978,24 @@ public class Upload extends AbstractComponent implements Component.Focusable, streamVariable = new com.vaadin.terminal.StreamVariable() { private StreamingStartEvent lastStartedEvent; + @Override public boolean listenProgress() { return (progressListeners != null && !progressListeners .isEmpty()); } + @Override public void onProgress(StreamingProgressEvent event) { fireUpdateProgress(event.getBytesReceived(), event.getContentLength()); } + @Override public boolean isInterrupted() { return interrupted; } + @Override public OutputStream getOutputStream() { OutputStream receiveUpload = receiver.receiveUpload( lastStartedEvent.getFileName(), @@ -996,6 +1004,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, return receiveUpload; } + @Override public void streamingStarted(StreamingStartEvent event) { startUpload(); contentLength = event.getContentLength(); @@ -1003,6 +1012,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, lastStartedEvent = event; } + @Override public void streamingFinished(StreamingEndEvent event) { fireUploadSuccess(event.getFileName(), event.getMimeType(), event.getContentLength()); @@ -1010,6 +1020,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, requestRepaint(); } + @Override public void streamingFailed(StreamingErrorEvent event) { Exception exception = event.getException(); if (exception instanceof NoInputStreamException) { diff --git a/src/com/vaadin/ui/Video.java b/src/com/vaadin/ui/Video.java index 0a2eccca0f..d4f95a5be3 100644 --- a/src/com/vaadin/ui/Video.java +++ b/src/com/vaadin/ui/Video.java @@ -4,8 +4,8 @@ package com.vaadin.ui; +import com.vaadin.shared.ui.video.VideoState; import com.vaadin.terminal.Resource; -import com.vaadin.terminal.gwt.client.ui.video.VideoState; import com.vaadin.terminal.gwt.server.ResourceReference; /** @@ -67,7 +67,7 @@ public class Video extends AbstractMedia { * @param poster */ public void setPoster(Resource poster) { - getState().setPoster(new ResourceReference(poster)); + getState().setPoster(ResourceReference.create(poster)); requestRepaint(); } @@ -75,7 +75,7 @@ public class Video extends AbstractMedia { * @return The poster image. */ public Resource getPoster() { - return ((ResourceReference) getState().getPoster()).getResource(); + return ResourceReference.getResource(getState().getPoster()); } } diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index 8866362587..e413d35e6d 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -19,13 +19,13 @@ 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.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; -import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.root.VRoot; -import com.vaadin.terminal.gwt.client.ui.window.WindowServerRpc; -import com.vaadin.terminal.gwt.client.ui.window.WindowState; /** * A component that represents a floating popup window that can be added to a @@ -44,6 +44,10 @@ import com.vaadin.terminal.gwt.client.ui.window.WindowState; * <p> * The caption is displayed in the window header. * </p> + * <p> + * In Vaadin versions prior to 7.0.0, Window was also used as application level + * windows. This function is now covered by the {@link Root} class. + * </p> * * @author Vaadin Ltd. * @version @@ -56,6 +60,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, private WindowServerRpc rpc = new WindowServerRpc() { + @Override public void click(MouseEventDetails mouseDetails) { fireEvent(new ClickEvent(Window.this, mouseDetails)); } @@ -793,11 +798,13 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @see com.vaadin.event.FieldEvents.FocusNotifier#addListener(com.vaadin.event.FieldEvents.FocusListener) */ + @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); } @@ -810,11 +817,13 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @see com.vaadin.event.FieldEvents.BlurNotifier#addListener(com.vaadin.event.FieldEvents.BlurListener) */ + @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); } |