Author: rwhitcomb Date: Mon Oct 30 17:46:58 2023 New Revision: 1913451 URL: http://svn.apache.org/viewvc?rev=1913451&view=rev Log: PIVOT-1032: Miscellaneous listener classes.
Modified: pivot/trunk/core/src/org/apache/pivot/beans/PropertyChangeListener.java pivot/trunk/core/src/org/apache/pivot/util/MessageBus.java pivot/trunk/core/src/org/apache/pivot/util/MessageBusListener.java pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/ActionListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/BorderListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentMouseWheelListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/ContainerListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java Modified: pivot/trunk/core/src/org/apache/pivot/beans/PropertyChangeListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/PropertyChangeListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/beans/PropertyChangeListener.java (original) +++ pivot/trunk/core/src/org/apache/pivot/beans/PropertyChangeListener.java Mon Oct 30 17:46:58 2023 @@ -19,6 +19,7 @@ package org.apache.pivot.beans; /** * Java bean property change listener. */ +@FunctionalInterface public interface PropertyChangeListener { /** * Called when a Java bean property has changed. Modified: pivot/trunk/core/src/org/apache/pivot/util/MessageBus.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/MessageBus.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/util/MessageBus.java (original) +++ pivot/trunk/core/src/org/apache/pivot/util/MessageBus.java Mon Oct 30 17:46:58 2023 @@ -63,7 +63,7 @@ public final class MessageBus { ListenerList<MessageBusListener<?>> topicListeners = messageTopics.get(topic); if (topicListeners == null) { - throw new IllegalArgumentException(topic.getName() + " does not exist."); + throw new IllegalArgumentException(String.format("'%1$s' topic does not exist.", topic.getName())); } topicListeners.remove(messageListener); Modified: pivot/trunk/core/src/org/apache/pivot/util/MessageBusListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/MessageBusListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/util/MessageBusListener.java (original) +++ pivot/trunk/core/src/org/apache/pivot/util/MessageBusListener.java Mon Oct 30 17:46:58 2023 @@ -21,6 +21,7 @@ package org.apache.pivot.util; * * @param <T> The type of message being sent. */ +@FunctionalInterface public interface MessageBusListener<T> { /** * Called when a message has been sent via Modified: pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java (original) +++ pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java Mon Oct 30 17:46:58 2023 @@ -21,6 +21,7 @@ import org.apache.pivot.util.ListenerLis /** * Node listener interface. */ +@FunctionalInterface public interface NodeListener { /** * Node listeners. Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ActionListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ActionListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/ActionListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ActionListener.java Mon Oct 30 17:46:58 2023 @@ -22,14 +22,14 @@ import org.apache.pivot.util.ListenerLis /** * Action listener interface. */ +@FunctionalInterface public interface ActionListener { /** * Action listener listeners list. */ - public static class Listeners extends ListenerList<ActionListener> - implements ActionListener { + class Listeners extends ListenerList<ActionListener> implements ActionListener { @Override - public void enabledChanged(Action action) { + public void enabledChanged(final Action action) { forEach(listener -> listener.enabledChanged(action)); } } @@ -39,5 +39,5 @@ public interface ActionListener { * * @param action The action that has been enabled/disabled. */ - public void enabledChanged(Action action); + void enabledChanged(Action action); } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/BorderListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/BorderListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/BorderListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/BorderListener.java Mon Oct 30 17:46:58 2023 @@ -25,14 +25,14 @@ public interface BorderListener { /** * Border listeners. */ - public static class Listeners extends ListenerList<BorderListener> implements BorderListener { + class Listeners extends ListenerList<BorderListener> implements BorderListener { @Override - public void titleChanged(Border border, String previousTitle) { + public void titleChanged(final Border border, final String previousTitle) { forEach(listener -> listener.titleChanged(border, previousTitle)); } @Override - public void contentChanged(Border border, Component previousContent) { + public void contentChanged(final Border border, final Component previousContent) { forEach(listener -> listener.contentChanged(border, previousContent)); } } @@ -42,14 +42,14 @@ public interface BorderListener { * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ @Deprecated - public static class Adapter implements BorderListener { + class Adapter implements BorderListener { @Override - public void titleChanged(Border border, String previousTitle) { + public void titleChanged(final Border border, final String previousTitle) { // empty block } @Override - public void contentChanged(Border border, Component previousContent) { + public void contentChanged(final Border border, final Component previousContent) { // empty block } } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentMouseWheelListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentMouseWheelListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentMouseWheelListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentMouseWheelListener.java Mon Oct 30 17:46:58 2023 @@ -22,15 +22,15 @@ import org.apache.pivot.util.ListenerLis /** * Component mouse wheel listener interface. */ +@FunctionalInterface public interface ComponentMouseWheelListener { /** * Mouse wheel listeners. */ - public static class Listeners extends ListenerList<ComponentMouseWheelListener> - implements ComponentMouseWheelListener { + class Listeners extends ListenerList<ComponentMouseWheelListener> implements ComponentMouseWheelListener { @Override - public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, - int scrollAmount, int wheelRotation, int x, int y) { + public boolean mouseWheel(final Component component, final Mouse.ScrollType scrollType, + final int scrollAmount, final int wheelRotation, final int x, final int y) { BooleanResult consumed = new BooleanResult(); forEach(listener -> consumed.or(listener.mouseWheel(component, scrollType, scrollAmount, wheelRotation, @@ -52,6 +52,6 @@ public interface ComponentMouseWheelList * @return {@code true} to consume the event; {@code false} to allow it to * propagate. */ - public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, + boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y); } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ContainerListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ContainerListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/ContainerListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ContainerListener.java Mon Oct 30 17:46:58 2023 @@ -26,26 +26,27 @@ public interface ContainerListener { /** * Container listeners. */ - public static class Listeners extends ListenerList<ContainerListener> implements + class Listeners extends ListenerList<ContainerListener> implements ContainerListener { @Override - public void componentInserted(Container container, int index) { + public void componentInserted(final Container container, final int index) { forEach(listener -> listener.componentInserted(container, index)); } @Override - public void componentsRemoved(Container container, int index, Sequence<Component> components) { + public void componentsRemoved(final Container container, final int index, + final Sequence<Component> components) { forEach(listener -> listener.componentsRemoved(container, index, components)); } @Override - public void componentMoved(Container container, int from, int to) { + public void componentMoved(final Container container, final int from, final int to) { forEach(listener -> listener.componentMoved(container, from, to)); } @Override - public void focusTraversalPolicyChanged(Container container, - FocusTraversalPolicy previousFocusTraversalPolicy) { + public void focusTraversalPolicyChanged(final Container container, + final FocusTraversalPolicy previousFocusTraversalPolicy) { forEach(listener -> listener.focusTraversalPolicyChanged(container, previousFocusTraversalPolicy)); } } @@ -55,25 +56,25 @@ public interface ContainerListener { * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ @Deprecated - public static class Adapter implements ContainerListener { + class Adapter implements ContainerListener { @Override - public void componentInserted(Container container, int index) { + public void componentInserted(final Container container, final int index) { // empty block } @Override - public void componentsRemoved(Container container, int index, Sequence<Component> removed) { + public void componentsRemoved(final Container container, final int index, final Sequence<Component> removed) { // empty block } @Override - public void componentMoved(Container container, int from, int to) { + public void componentMoved(final Container container, final int from, final int to) { // empty block } @Override - public void focusTraversalPolicyChanged(Container container, - FocusTraversalPolicy previousFocusTraversalPolicy) { + public void focusTraversalPolicyChanged(final Container container, + final FocusTraversalPolicy previousFocusTraversalPolicy) { // empty block } } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuListener.java Mon Oct 30 17:46:58 2023 @@ -26,19 +26,19 @@ public interface MenuListener { /** * Menu listeners. */ - public static class Listeners extends ListenerList<MenuListener> implements MenuListener { + class Listeners extends ListenerList<MenuListener> implements MenuListener { @Override - public void sectionInserted(Menu menu, int index) { + public void sectionInserted(final Menu menu, final int index) { forEach(listener -> listener.sectionInserted(menu, index)); } @Override - public void sectionsRemoved(Menu menu, int index, Sequence<Menu.Section> removed) { + public void sectionsRemoved(final Menu menu, final int index, final Sequence<Menu.Section> removed) { forEach(listener -> listener.sectionsRemoved(menu, index, removed)); } @Override - public void activeItemChanged(Menu menu, Menu.Item previousActiveItem) { + public void activeItemChanged(final Menu menu, final Menu.Item previousActiveItem) { forEach(listener -> listener.activeItemChanged(menu, previousActiveItem)); } } @@ -48,19 +48,19 @@ public interface MenuListener { * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ @Deprecated - public static class Adapter implements MenuListener { + class Adapter implements MenuListener { @Override - public void sectionInserted(Menu menu, int index) { + public void sectionInserted(final Menu menu, final int index) { // empty block } @Override - public void sectionsRemoved(Menu menu, int index, Sequence<Menu.Section> removed) { + public void sectionsRemoved(final Menu menu, final int index, final Sequence<Menu.Section> removed) { // empty block } @Override - public void activeItemChanged(Menu menu, Menu.Item previousActiveItem) { + public void activeItemChanged(final Menu menu, final Menu.Item previousActiveItem) { // empty block } } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java?rev=1913451&r1=1913450&r2=1913451&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java Mon Oct 30 17:46:58 2023 @@ -21,16 +21,15 @@ import org.apache.pivot.util.ListenerLis /** * Text area selection listener interface. */ +@FunctionalInterface public interface TextAreaSelectionListener { /** * Text area selection listeners. */ - public static class Listeners extends ListenerList<TextAreaSelectionListener> - implements TextAreaSelectionListener { + class Listeners extends ListenerList<TextAreaSelectionListener> implements TextAreaSelectionListener { @Override - public void selectionChanged(TextArea textArea, int previousSelectionStart, - int previousSelectionLength) { - forEach(listener -> listener.selectionChanged(textArea, previousSelectionStart, previousSelectionLength)); + public void selectionChanged(final TextArea textArea, final int previousStart, final int previousLength) { + forEach(listener -> listener.selectionChanged(textArea, previousStart, previousLength)); } } @@ -41,6 +40,5 @@ public interface TextAreaSelectionListen * @param previousSelectionStart Where the selection used to start. * @param previousSelectionLength The previous selection length. */ - public void selectionChanged(TextArea textArea, int previousSelectionStart, - int previousSelectionLength); + void selectionChanged(TextArea textArea, int previousSelectionStart, int previousSelectionLength); }