From dd6265dcf5376fe4ead3fab7dbe10df2099389c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pekka=20Hyv=C3=B6nen?= Date: Tue, 4 Sep 2012 10:33:22 +0300 Subject: [PATCH] inner Event classes converted to static nested classes (#5855) --- .../util/sqlcontainer/query/TableQuery.java | 2 +- server/src/com/vaadin/event/FieldEvents.java | 5 ++-- server/src/com/vaadin/event/MouseEvents.java | 4 +-- server/src/com/vaadin/server/Page.java | 4 +-- server/src/com/vaadin/ui/AbstractSelect.java | 25 +++++++++++++------ .../src/com/vaadin/ui/AbstractSplitPanel.java | 6 ++--- .../src/com/vaadin/ui/AbstractTextField.java | 2 +- server/src/com/vaadin/ui/Button.java | 2 +- server/src/com/vaadin/ui/Component.java | 4 +-- .../src/com/vaadin/ui/ComponentContainer.java | 4 +-- server/src/com/vaadin/ui/LoginForm.java | 8 +++--- server/src/com/vaadin/ui/PopupView.java | 4 +-- server/src/com/vaadin/ui/TabSheet.java | 4 +-- server/src/com/vaadin/ui/Window.java | 4 +-- .../navigator/UriFragmentManagerTest.java | 3 +-- 15 files changed, 46 insertions(+), 35 deletions(-) diff --git a/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java b/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java index a6a1a5a8fb..8a3dabbf0e 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java @@ -678,7 +678,7 @@ public class TableQuery implements QueryDelegate, /** * Simple RowIdChangeEvent implementation. */ - public class RowIdChangeEvent extends EventObject implements + public static class RowIdChangeEvent extends EventObject implements QueryDelegate.RowIdChangeEvent { private final RowId oldId; private final RowId newId; diff --git a/server/src/com/vaadin/event/FieldEvents.java b/server/src/com/vaadin/event/FieldEvents.java index 3da60ee466..1a1bc95305 100644 --- a/server/src/com/vaadin/event/FieldEvents.java +++ b/server/src/com/vaadin/event/FieldEvents.java @@ -144,7 +144,7 @@ public interface FieldEvents { * @since 6.2 */ @SuppressWarnings("serial") - public class FocusEvent extends Component.Event { + public static class FocusEvent extends Component.Event { /** * Identifier for event that can be used in {@link EventRouter} @@ -184,7 +184,7 @@ public interface FieldEvents { * @since 6.2 */ @SuppressWarnings("serial") - public class BlurEvent extends Component.Event { + public static class BlurEvent extends Component.Event { /** * Identifier for event that can be used in {@link EventRouter} @@ -243,6 +243,7 @@ public interface FieldEvents { * @since 6.5 */ public static abstract class TextChangeEvent extends Component.Event { + public TextChangeEvent(Component source) { super(source); } diff --git a/server/src/com/vaadin/event/MouseEvents.java b/server/src/com/vaadin/event/MouseEvents.java index 6712ef79a5..e287055c2b 100644 --- a/server/src/com/vaadin/event/MouseEvents.java +++ b/server/src/com/vaadin/event/MouseEvents.java @@ -43,7 +43,7 @@ public interface MouseEvents { * @see ClickListener * @since 6.2 */ - public class ClickEvent extends Component.Event { + public static class ClickEvent extends Component.Event { public static final int BUTTON_LEFT = MouseEventDetails.BUTTON_LEFT; public static final int BUTTON_MIDDLE = MouseEventDetails.BUTTON_MIDDLE; public static final int BUTTON_RIGHT = MouseEventDetails.BUTTON_RIGHT; @@ -202,7 +202,7 @@ public interface MouseEvents { * @author Vaadin Ltd. * @since 6.2 */ - public class DoubleClickEvent extends Component.Event { + public static class DoubleClickEvent extends Component.Event { public DoubleClickEvent(Component source) { super(source); diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index b5718d10bb..015c6c907f 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -54,7 +54,7 @@ public class Page implements Serializable { /** * Event that is fired when a browser window containing a uI is resized. */ - public class BrowserWindowResizeEvent extends EventObject { + public static class BrowserWindowResizeEvent extends EventObject { private final int width; private final int height; @@ -233,7 +233,7 @@ public class Page implements Serializable { /** * Event fired when uri fragment changes. */ - public class FragmentChangedEvent extends EventObject { + public static class FragmentChangedEvent extends EventObject { /** * The new uri fragment diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 2fc3bf4080..2f420b9286 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -19,6 +19,7 @@ package com.vaadin.ui; import java.io.Serializable; import java.util.Collection; import java.util.Collections; +import java.util.EventObject; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -1612,7 +1613,8 @@ public abstract class AbstractSelect extends AbstractField implements protected void firePropertySetChange() { if (propertySetEventListeners != null && !propertySetEventListeners.isEmpty()) { - final Container.PropertySetChangeEvent event = new PropertySetChangeEvent(); + final Container.PropertySetChangeEvent event = new PropertySetChangeEvent( + this); final Object[] listeners = propertySetEventListeners.toArray(); for (int i = 0; i < listeners.length; i++) { ((Container.PropertySetChangeListener) listeners[i]) @@ -1627,7 +1629,8 @@ public abstract class AbstractSelect extends AbstractField implements */ protected void fireItemSetChange() { if (itemSetEventListeners != null && !itemSetEventListeners.isEmpty()) { - final Container.ItemSetChangeEvent event = new ItemSetChangeEvent(); + final Container.ItemSetChangeEvent event = new ItemSetChangeEvent( + this); final Object[] listeners = itemSetEventListeners.toArray(); for (int i = 0; i < listeners.length; i++) { ((Container.ItemSetChangeListener) listeners[i]) @@ -1640,8 +1643,12 @@ public abstract class AbstractSelect extends AbstractField implements /** * Implementation of item set change event. */ - private class ItemSetChangeEvent implements Serializable, - Container.ItemSetChangeEvent { + private static class ItemSetChangeEvent extends EventObject implements + Serializable, Container.ItemSetChangeEvent { + + private ItemSetChangeEvent(Container source) { + super(source); + } /** * Gets the Property where the event occurred. @@ -1650,7 +1657,7 @@ public abstract class AbstractSelect extends AbstractField implements */ @Override public Container getContainer() { - return AbstractSelect.this; + return (Container) getSource(); } } @@ -1658,9 +1665,13 @@ public abstract class AbstractSelect extends AbstractField implements /** * Implementation of property set change event. */ - private class PropertySetChangeEvent implements + private static class PropertySetChangeEvent extends EventObject implements Container.PropertySetChangeEvent, Serializable { + private PropertySetChangeEvent(Container source) { + super(source); + } + /** * Retrieves the Container whose contents have been modified. * @@ -1668,7 +1679,7 @@ public abstract class AbstractSelect extends AbstractField implements */ @Override public Container getContainer() { - return AbstractSelect.this; + return (Container) getSource(); } } diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index 93c4ec4f59..dd6ff50efb 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -392,8 +392,8 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * Allowed units are UNITS_PERCENTAGE and UNITS_PIXELS */ public void setMaxSplitPosition(float pos, Unit unit) { - setSplitPositionLimits(getSplitterState().minPosition, posMinUnit, - pos, unit); + setSplitPositionLimits(getSplitterState().minPosition, posMinUnit, pos, + unit); } /** @@ -492,7 +492,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { public void splitterClick(SplitterClickEvent event); } - public class SplitterClickEvent extends ClickEvent { + public static class SplitterClickEvent extends ClickEvent { public SplitterClickEvent(Component source, MouseEventDetails mouseEventDetails) { diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 0cb74dae6d..3dd2b4dae8 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -570,7 +570,7 @@ public abstract class AbstractTextField extends AbstractField implements return textChangeEventTimeout; } - public class TextChangeEventImpl extends TextChangeEvent { + public static class TextChangeEventImpl extends TextChangeEvent { private String curText; private int cursorPosition; diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index ec75d2da9b..02b7689259 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -108,7 +108,7 @@ public class Button extends AbstractComponent implements * @author Vaadin Ltd. * @since 3.0 */ - public class ClickEvent extends Component.Event { + public static class ClickEvent extends Component.Event { private final MouseEventDetails details; diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index 01033ff560..5bd1d53b86 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -670,7 +670,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * @see Component.Listener */ @SuppressWarnings("serial") - public class Event extends EventObject { + public static class Event extends EventObject { /** * Constructs a new event with the specified source component. @@ -860,7 +860,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { *

*/ @SuppressWarnings("serial") - public class ErrorEvent extends Event { + public static class ErrorEvent extends Event { private final ErrorMessage message; diff --git a/server/src/com/vaadin/ui/ComponentContainer.java b/server/src/com/vaadin/ui/ComponentContainer.java index cee6d7300b..50a6e7e148 100644 --- a/server/src/com/vaadin/ui/ComponentContainer.java +++ b/server/src/com/vaadin/ui/ComponentContainer.java @@ -174,7 +174,7 @@ public interface ComponentContainer extends HasComponents { * Component attach event sent when a component is attached to container. */ @SuppressWarnings("serial") - public class ComponentAttachEvent extends Component.Event { + public static class ComponentAttachEvent extends Component.Event { private final Component component; @@ -218,7 +218,7 @@ public interface ComponentContainer extends HasComponents { * Component detach event sent when a component is detached from container. */ @SuppressWarnings("serial") - public class ComponentDetachEvent extends Component.Event { + public static class ComponentDetachEvent extends Component.Event { private final Component component; diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index abcc7ff607..61846eab4e 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -108,7 +108,7 @@ public class LoginForm extends CustomComponent { String value = (parameters.get(key))[0]; params.put(key, value); } - LoginEvent event = new LoginEvent(params); + LoginEvent event = new LoginEvent(LoginForm.this, params); fireEvent(event); return true; } @@ -200,12 +200,12 @@ public class LoginForm extends CustomComponent { /** * This event is sent when login form is submitted. */ - public class LoginEvent extends Event { + public static class LoginEvent extends Event { private Map params; - private LoginEvent(Map params) { - super(LoginForm.this); + private LoginEvent(Component source, Map params) { + super(source); this.params = params; } diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java index 8d6d28e121..182e71d6c9 100644 --- a/server/src/com/vaadin/ui/PopupView.java +++ b/server/src/com/vaadin/ui/PopupView.java @@ -20,10 +20,10 @@ import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.LegacyPaint; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; -import com.vaadin.server.LegacyComponent; /** * @@ -421,7 +421,7 @@ public class PopupView extends AbstractComponentContainer implements * event with {@link #getPopupView()}. * */ - public class PopupVisibilityEvent extends Event { + public static class PopupVisibilityEvent extends Event { public PopupVisibilityEvent(PopupView source) { super(source); diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java index eb66de519f..291aea3bd6 100644 --- a/server/src/com/vaadin/ui/TabSheet.java +++ b/server/src/com/vaadin/ui/TabSheet.java @@ -32,11 +32,11 @@ import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.FieldEvents.FocusNotifier; import com.vaadin.server.ErrorMessage; import com.vaadin.server.KeyMapper; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.LegacyPaint; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.tabsheet.TabsheetBaseConstants; import com.vaadin.shared.ui.tabsheet.TabsheetConstants; import com.vaadin.ui.Component.Focusable; @@ -743,7 +743,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * @author Vaadin Ltd. * @since 3.0 */ - public class SelectedTabChangeEvent extends Component.Event { + public static class SelectedTabChangeEvent extends Component.Event { /** * New instance of selected tab change event diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 5c94a4c929..d7a33d742c 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -299,7 +299,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } } - public class CloseEvent extends Component.Event { + public static class CloseEvent extends Component.Event { /** * @@ -422,7 +422,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * (e.g. the browser window is resized). The frequency may vary across * browsers. */ - public class ResizeEvent extends Component.Event { + public static class ResizeEvent extends Component.Event { /** * diff --git a/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java b/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java index d58ff28b00..905ddb529b 100644 --- a/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java +++ b/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java @@ -56,8 +56,7 @@ public class UriFragmentManagerTest extends TestCase { navigator.navigateTo("test"); control.replay(); - FragmentChangedEvent event = page.new FragmentChangedEvent(page, - "oldtest"); + FragmentChangedEvent event = new FragmentChangedEvent(page, "oldtest"); manager.fragmentChanged(event); } } -- 2.39.5