Author: rwhitcomb Date: Tue Jan 16 20:07:44 2018 New Revision: 1821299 URL: http://svn.apache.org/viewvc?rev=1821299&view=rev Log: PIVOT-1011: A lot more work moving the ListenerList implementations for listeners into the Listener interfaces themselves; implementing default methods in the interface, and deprecating the "xxx.Adapter" classes.
Modified: pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java pivot/trunk/core/src/org/apache/pivot/beans/NamespaceBinding.java pivot/trunk/core/src/org/apache/pivot/collections/ArrayQueue.java pivot/trunk/core/src/org/apache/pivot/collections/ArrayStack.java pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java pivot/trunk/core/src/org/apache/pivot/collections/LinkedQueue.java pivot/trunk/core/src/org/apache/pivot/collections/LinkedStack.java pivot/trunk/core/src/org/apache/pivot/collections/ListListener.java pivot/trunk/core/src/org/apache/pivot/collections/Map.java pivot/trunk/core/src/org/apache/pivot/collections/MapListener.java pivot/trunk/core/src/org/apache/pivot/collections/Queue.java pivot/trunk/core/src/org/apache/pivot/collections/QueueListener.java pivot/trunk/core/src/org/apache/pivot/collections/Set.java pivot/trunk/core/src/org/apache/pivot/collections/SetListener.java pivot/trunk/core/src/org/apache/pivot/collections/Stack.java pivot/trunk/core/src/org/apache/pivot/collections/StackListener.java pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java pivot/trunk/core/src/org/apache/pivot/collections/adapter/SetAdapter.java pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedQueue.java pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedSet.java pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedStack.java pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableSet.java pivot/trunk/core/test/org/apache/pivot/collections/test/QueueTest.java pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java pivot/trunk/tests/src/org/apache/pivot/tests/CheckedListViewTest.java pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calculator/Calculator.java pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentKeyListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/RadioButtonGroup.java pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNodeListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNodeListener.java Modified: pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java (original) +++ pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java Tue Jan 16 20:07:44 2018 @@ -147,7 +147,7 @@ public class BeanAdapter implements Map< private Object bean; private boolean ignoreReadOnlyProperties; - private MapListenerList<String, Object> mapListeners = new MapListenerList<>(); + private MapListener.Listeners<String, Object> mapListeners = new MapListener.Listeners<>(); public static final String GET_PREFIX = "get"; public static final String IS_PREFIX = "is"; Modified: pivot/trunk/core/src/org/apache/pivot/beans/NamespaceBinding.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/NamespaceBinding.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/beans/NamespaceBinding.java (original) +++ pivot/trunk/core/src/org/apache/pivot/beans/NamespaceBinding.java Tue Jan 16 20:07:44 2018 @@ -58,7 +58,7 @@ public class NamespaceBinding { private boolean updating = false; - private MapListener<String, Object> sourceMapListener = new MapListener.Adapter<String, Object>() { + private MapListener<String, Object> sourceMapListener = new MapListener<String, Object>() { @Override public void valueUpdated(Map<String, Object> map, String key, Object previousValue) { if (key.equals(sourceKey) && !updating) { Modified: pivot/trunk/core/src/org/apache/pivot/collections/ArrayQueue.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/ArrayQueue.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/ArrayQueue.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/ArrayQueue.java Tue Jan 16 20:07:44 2018 @@ -32,7 +32,7 @@ public class ArrayQueue<T> implements Qu private ArrayList<T> arrayList = new ArrayList<>(); private int maxLength = 0; - private transient QueueListenerList<T> queueListeners = new QueueListenerList<>(); + private transient QueueListener.Listeners<T> queueListeners = new QueueListener.Listeners<>(); public ArrayQueue() { this(null); Modified: pivot/trunk/core/src/org/apache/pivot/collections/ArrayStack.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/ArrayStack.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/ArrayStack.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/ArrayStack.java Tue Jan 16 20:07:44 2018 @@ -32,7 +32,7 @@ public class ArrayStack<T> implements St private ArrayList<T> arrayList = new ArrayList<>(); private int maxDepth = 0; - private transient StackListenerList<T> stackListeners = new StackListenerList<>(); + private transient StackListener.Listeners<T> stackListeners = new StackListener.Listeners<>(); public ArrayStack() { this(null); Modified: pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java Tue Jan 16 20:07:44 2018 @@ -33,7 +33,7 @@ public class EnumMap<E extends Enum<E>, private EnumSet<E> keySet; private Object[] values; - private transient MapListenerList<E, V> mapListeners = new MapListenerList<>(); + private transient MapListener.Listeners<E, V> mapListeners = new MapListener.Listeners<>(); public EnumMap(Class<E> enumClass) { keySet = new EnumSet<>(enumClass); Modified: pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java Tue Jan 16 20:07:44 2018 @@ -75,7 +75,7 @@ public class EnumSet<E extends Enum<E>> private boolean[] members; private int count = 0; - private transient SetListenerList<E> setListeners = new SetListenerList<>(); + private transient SetListener.Listeners<E> setListeners = new SetListener.Listeners<>(); public EnumSet(Class<E> enumClass) { this.enumClass = enumClass; Modified: pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java Tue Jan 16 20:07:44 2018 @@ -102,7 +102,7 @@ public class HashMap<K, V> implements Ma private int count = 0; private ArrayList<K> keys = null; - private transient MapListenerList<K, V> mapListeners = null; + private transient MapListener.Listeners<K, V> mapListeners = null; public static final int DEFAULT_CAPACITY = 16; public static final float DEFAULT_LOAD_FACTOR = 0.75f; @@ -423,7 +423,7 @@ public class HashMap<K, V> implements Ma @Override public ListenerList<MapListener<K, V>> getMapListeners() { if (mapListeners == null) { - mapListeners = new MapListenerList<>(); + mapListeners = new MapListener.Listeners<>(); } return mapListeners; Modified: pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java Tue Jan 16 20:07:44 2018 @@ -74,7 +74,7 @@ public class HashSet<E> implements Set<E protected HashMap<E, Void> hashMap = new HashMap<>(); - private transient SetListenerList<E> setListeners = null; + private transient SetListener.Listeners<E> setListeners = null; public HashSet() { } @@ -178,7 +178,7 @@ public class HashSet<E> implements Set<E @Override public ListenerList<SetListener<E>> getSetListeners() { if (setListeners == null) { - setListeners = new SetListenerList<>(); + setListeners = new SetListener.Listeners<>(); } return setListeners; Modified: pivot/trunk/core/src/org/apache/pivot/collections/LinkedQueue.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/LinkedQueue.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/LinkedQueue.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/LinkedQueue.java Tue Jan 16 20:07:44 2018 @@ -33,7 +33,7 @@ public class LinkedQueue<T> implements Q private LinkedList<T> linkedList = new LinkedList<>(); private int maxLength = 0; - private transient QueueListenerList<T> queueListeners = new QueueListenerList<>(); + private transient QueueListener.Listeners<T> queueListeners = new QueueListener.Listeners<>(); public LinkedQueue() { this(null); Modified: pivot/trunk/core/src/org/apache/pivot/collections/LinkedStack.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/LinkedStack.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/LinkedStack.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/LinkedStack.java Tue Jan 16 20:07:44 2018 @@ -33,7 +33,7 @@ public class LinkedStack<T> implements S private LinkedList<T> linkedList = new LinkedList<>(); private int maxDepth = 0; - private transient StackListenerList<T> stackListeners = new StackListenerList<>(); + private transient StackListener.Listeners<T> stackListeners = new StackListener.Listeners<>(); public LinkedStack() { this(null); Modified: pivot/trunk/core/src/org/apache/pivot/collections/ListListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/ListListener.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/ListListener.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/ListListener.java Tue Jan 16 20:07:44 2018 @@ -24,7 +24,9 @@ import java.util.Comparator; public interface ListListener<T> { /** * List listener adapter. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ + @Deprecated public static class Adapter<T> implements ListListener<T> { @Override public void itemInserted(List<T> list, int index) { @@ -58,7 +60,8 @@ public interface ListListener<T> { * @param list The source of the list event. * @param index The index at which the item was added. */ - public void itemInserted(List<T> list, int index); + default public void itemInserted(List<T> list, int index) { + } /** * Called when items have been removed from a list. @@ -67,7 +70,8 @@ public interface ListListener<T> { * @param index The starting index from which items have been removed. * @param items The items that were removed from the list. */ - public void itemsRemoved(List<T> list, int index, Sequence<T> items); + default public void itemsRemoved(List<T> list, int index, Sequence<T> items) { + } /** * Called when a list item has been updated. @@ -76,14 +80,16 @@ public interface ListListener<T> { * @param index The index of the item that was updated. * @param previousItem The item that was previously stored at <tt>index</tt>. */ - public void itemUpdated(List<T> list, int index, T previousItem); + default public void itemUpdated(List<T> list, int index, T previousItem) { + } /** * Called when list data has been reset. * * @param list The source of the list event. */ - public void listCleared(List<T> list); + default public void listCleared(List<T> list) { + } /** * Called when a list's comparator has changed. @@ -91,5 +97,6 @@ public interface ListListener<T> { * @param list The source of the event. * @param previousComparator The previous comparator value. */ - public void comparatorChanged(List<T> list, Comparator<T> previousComparator); + default public void comparatorChanged(List<T> list, Comparator<T> previousComparator) { + } } Modified: pivot/trunk/core/src/org/apache/pivot/collections/Map.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/Map.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/Map.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/Map.java Tue Jan 16 20:07:44 2018 @@ -25,37 +25,6 @@ import org.apache.pivot.util.ListenerLis */ public interface Map<K, V> extends Dictionary<K, V>, Collection<K> { /** - * Map listener list. - */ - public static class MapListenerList<K, V> extends ListenerList<MapListener<K, V>> implements - MapListener<K, V> { - @Override - public void valueAdded(Map<K, V> map, K key) { - forEach(listener -> listener.valueAdded(map, key)); - } - - @Override - public void valueRemoved(Map<K, V> map, K key, V value) { - forEach(listener -> listener.valueRemoved(map, key, value)); - } - - @Override - public void valueUpdated(Map<K, V> map, K key, V previousValue) { - forEach(listener -> listener.valueUpdated(map, key, previousValue)); - } - - @Override - public void mapCleared(Map<K, V> map) { - forEach(listener -> listener.mapCleared(map)); - } - - @Override - public void comparatorChanged(Map<K, V> map, Comparator<K> previousComparator) { - forEach(listener -> listener.comparatorChanged(map, previousComparator)); - } - } - - /** * Sets the value of the given key, creating a new entry or replacing the * existing value, and firing a corresponding event. * Modified: pivot/trunk/core/src/org/apache/pivot/collections/MapListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/MapListener.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/MapListener.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/MapListener.java Tue Jan 16 20:07:44 2018 @@ -17,14 +17,48 @@ package org.apache.pivot.collections; import java.util.Comparator; +import org.apache.pivot.util.ListenerList; /** * Map listener interface. */ public interface MapListener<K, V> { /** + * Map listeners. + */ + public static class Listeners<K, V> extends ListenerList<MapListener<K, V>> implements + MapListener<K, V> { + @Override + public void valueAdded(Map<K, V> map, K key) { + forEach(listener -> listener.valueAdded(map, key)); + } + + @Override + public void valueRemoved(Map<K, V> map, K key, V value) { + forEach(listener -> listener.valueRemoved(map, key, value)); + } + + @Override + public void valueUpdated(Map<K, V> map, K key, V previousValue) { + forEach(listener -> listener.valueUpdated(map, key, previousValue)); + } + + @Override + public void mapCleared(Map<K, V> map) { + forEach(listener -> listener.mapCleared(map)); + } + + @Override + public void comparatorChanged(Map<K, V> map, Comparator<K> previousComparator) { + forEach(listener -> listener.comparatorChanged(map, previousComparator)); + } + } + + /** * Map listener adapter. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ + @Deprecated public static class Adapter<K, V> implements MapListener<K, V> { @Override public void valueAdded(Map<K, V> map, K key) { @@ -58,7 +92,8 @@ public interface MapListener<K, V> { * @param map The source of the map event. * @param key The key that was added to the map. */ - public void valueAdded(Map<K, V> map, K key); + default public void valueAdded(Map<K, V> map, K key) { + } /** * Called when a map value has been updated. @@ -68,7 +103,8 @@ public interface MapListener<K, V> { * @param previousValue The value that was previously associated with the * key. */ - public void valueUpdated(Map<K, V> map, K key, V previousValue); + default public void valueUpdated(Map<K, V> map, K key, V previousValue) { + } /** * Called when a key/value pair has been removed from a map. @@ -77,14 +113,16 @@ public interface MapListener<K, V> { * @param key The key that was removed. * @param value The value that was removed. */ - public void valueRemoved(Map<K, V> map, K key, V value); + default public void valueRemoved(Map<K, V> map, K key, V value) { + } /** * Called when map data has been reset. * * @param map The source of the map event. */ - public void mapCleared(Map<K, V> map); + default public void mapCleared(Map<K, V> map) { + } /** * Called when a map's comparator has changed. @@ -92,5 +130,6 @@ public interface MapListener<K, V> { * @param map The source of the event. * @param previousComparator The previous comparator value. */ - public void comparatorChanged(Map<K, V> map, Comparator<K> previousComparator); + default public void comparatorChanged(Map<K, V> map, Comparator<K> previousComparator) { + } } Modified: pivot/trunk/core/src/org/apache/pivot/collections/Queue.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/Queue.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/Queue.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/Queue.java Tue Jan 16 20:07:44 2018 @@ -26,32 +26,6 @@ import org.apache.pivot.util.ListenerLis */ public interface Queue<T> extends Collection<T> { /** - * Queue listener list. - */ - public static class QueueListenerList<T> extends ListenerList<QueueListener<T>> implements - QueueListener<T> { - @Override - public void itemEnqueued(Queue<T> queue, T item) { - forEach(listener -> listener.itemEnqueued(queue, item)); - } - - @Override - public void itemDequeued(Queue<T> queue, T item) { - forEach(listener -> listener.itemDequeued(queue, item)); - } - - @Override - public void queueCleared(Queue<T> queue) { - forEach(listener -> listener.queueCleared(queue)); - } - - @Override - public void comparatorChanged(Queue<T> queue, Comparator<T> previousComparator) { - forEach(listener -> listener.comparatorChanged(queue, previousComparator)); - } - } - - /** * Enqueues an item. If the queue is unsorted, the item is added at the tail * of the queue (index <tt>0</tt>). Otherwise, it is inserted at the * appropriate index. Modified: pivot/trunk/core/src/org/apache/pivot/collections/QueueListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/QueueListener.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/QueueListener.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/QueueListener.java Tue Jan 16 20:07:44 2018 @@ -17,14 +17,43 @@ package org.apache.pivot.collections; import java.util.Comparator; +import org.apache.pivot.util.ListenerList; /** * Queue listener interface. */ public interface QueueListener<T> { /** + * Queue listeners. + */ + public static class Listeners<T> extends ListenerList<QueueListener<T>> implements + QueueListener<T> { + @Override + public void itemEnqueued(Queue<T> queue, T item) { + forEach(listener -> listener.itemEnqueued(queue, item)); + } + + @Override + public void itemDequeued(Queue<T> queue, T item) { + forEach(listener -> listener.itemDequeued(queue, item)); + } + + @Override + public void queueCleared(Queue<T> queue) { + forEach(listener -> listener.queueCleared(queue)); + } + + @Override + public void comparatorChanged(Queue<T> queue, Comparator<T> previousComparator) { + forEach(listener -> listener.comparatorChanged(queue, previousComparator)); + } + } + + /** * QueueListener adapter. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ + @Deprecated public static class Adapter<T> implements QueueListener<T> { @Override public void itemEnqueued(Queue<T> queue, T item) { @@ -53,7 +82,8 @@ public interface QueueListener<T> { * @param queue The queue that has been modified. * @param item The item that was just added to the queue. */ - public void itemEnqueued(Queue<T> queue, T item); + default public void itemEnqueued(Queue<T> queue, T item) { + } /** * Called when an item has been removed from the head of a queue. @@ -61,14 +91,16 @@ public interface QueueListener<T> { * @param queue The queue in question. * @param item The item that was just removed from the head of the queue. */ - public void itemDequeued(Queue<T> queue, T item); + default public void itemDequeued(Queue<T> queue, T item) { + } /** * Called when a queue has been cleared. * * @param queue The newly cleared queue object. */ - public void queueCleared(Queue<T> queue); + default public void queueCleared(Queue<T> queue) { + } /** * Called when a queue's comparator has changed. @@ -76,5 +108,6 @@ public interface QueueListener<T> { * @param queue The queue that changed. * @param previousComparator Previous value of the queue's comparator (if any). */ - public void comparatorChanged(Queue<T> queue, Comparator<T> previousComparator); + default public void comparatorChanged(Queue<T> queue, Comparator<T> previousComparator) { + } } Modified: pivot/trunk/core/src/org/apache/pivot/collections/Set.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/Set.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/Set.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/Set.java Tue Jan 16 20:07:44 2018 @@ -25,32 +25,6 @@ import org.apache.pivot.util.ListenerLis */ public interface Set<E> extends Group<E>, Collection<E> { /** - * Set listener list. - */ - public static class SetListenerList<E> extends ListenerList<SetListener<E>> implements - SetListener<E> { - @Override - public void elementAdded(Set<E> set, E element) { - forEach(listener -> listener.elementAdded(set, element)); - } - - @Override - public void elementRemoved(Set<E> set, E element) { - forEach(listener -> listener.elementRemoved(set, element)); - } - - @Override - public void setCleared(Set<E> set) { - forEach(listener -> listener.setCleared(set)); - } - - @Override - public void comparatorChanged(Set<E> set, Comparator<E> previousComparator) { - forEach(listener -> listener.comparatorChanged(set, previousComparator)); - } - } - - /** * @see SetListener#elementAdded(Set, Object) */ @Override Modified: pivot/trunk/core/src/org/apache/pivot/collections/SetListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/SetListener.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/SetListener.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/SetListener.java Tue Jan 16 20:07:44 2018 @@ -17,14 +17,43 @@ package org.apache.pivot.collections; import java.util.Comparator; +import org.apache.pivot.util.ListenerList; /** * Set listener interface. */ public interface SetListener<E> { /** + * Set listeners. + */ + public static class Listeners<E> extends ListenerList<SetListener<E>> implements + SetListener<E> { + @Override + public void elementAdded(Set<E> set, E element) { + forEach(listener -> listener.elementAdded(set, element)); + } + + @Override + public void elementRemoved(Set<E> set, E element) { + forEach(listener -> listener.elementRemoved(set, element)); + } + + @Override + public void setCleared(Set<E> set) { + forEach(listener -> listener.setCleared(set)); + } + + @Override + public void comparatorChanged(Set<E> set, Comparator<E> previousComparator) { + forEach(listener -> listener.comparatorChanged(set, previousComparator)); + } + } + + /** * Set listener adapter. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ + @Deprecated public static class Adapter<E> implements SetListener<E> { @Override public void elementAdded(Set<E> set, E element) { @@ -53,7 +82,8 @@ public interface SetListener<E> { * @param set The source of the set event. * @param element The element that was added to the set. */ - public void elementAdded(Set<E> set, E element); + default public void elementAdded(Set<E> set, E element) { + } /** * Called when an element is removed from the set. @@ -61,14 +91,16 @@ public interface SetListener<E> { * @param set The source of the set event. * @param element The element that was removed from the set. */ - public void elementRemoved(Set<E> set, E element); + default public void elementRemoved(Set<E> set, E element) { + } /** * Called when set data has been reset. * * @param set The source of the set event. */ - public void setCleared(Set<E> set); + default public void setCleared(Set<E> set) { + } /** * Called when a set's comparator has changed. @@ -76,5 +108,6 @@ public interface SetListener<E> { * @param set The source of the event. * @param previousComparator The previous comparator value. */ - public void comparatorChanged(Set<E> set, Comparator<E> previousComparator); + default public void comparatorChanged(Set<E> set, Comparator<E> previousComparator) { + } } Modified: pivot/trunk/core/src/org/apache/pivot/collections/Stack.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/Stack.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/Stack.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/Stack.java Tue Jan 16 20:07:44 2018 @@ -26,32 +26,6 @@ import org.apache.pivot.util.ListenerLis */ public interface Stack<T> extends Collection<T> { /** - * Stack listener list. - */ - public static class StackListenerList<T> extends ListenerList<StackListener<T>> implements - StackListener<T> { - @Override - public void itemPushed(Stack<T> stack, T item) { - forEach(listener -> listener.itemPushed(stack, item)); - } - - @Override - public void itemPopped(Stack<T> stack, T item) { - forEach(listener -> listener.itemPopped(stack, item)); - } - - @Override - public void stackCleared(Stack<T> stack) { - forEach(listener -> listener.stackCleared(stack)); - } - - @Override - public void comparatorChanged(Stack<T> stack, Comparator<T> previousComparator) { - forEach(listener -> listener.comparatorChanged(stack, previousComparator)); - } - } - - /** * "Pushes" an item onto the stack. If the stack is unsorted, the item is * added at the top of the stack (<tt>getLength()</tt>). Otherwise, it is * inserted at the appropriate index. Modified: pivot/trunk/core/src/org/apache/pivot/collections/StackListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/StackListener.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/StackListener.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/StackListener.java Tue Jan 16 20:07:44 2018 @@ -17,14 +17,43 @@ package org.apache.pivot.collections; import java.util.Comparator; +import org.apache.pivot.util.ListenerList; /** * Stack listener interface. */ public interface StackListener<T> { /** + * Stack listeners. + */ + public static class Listeners<T> extends ListenerList<StackListener<T>> implements + StackListener<T> { + @Override + public void itemPushed(Stack<T> stack, T item) { + forEach(listener -> listener.itemPushed(stack, item)); + } + + @Override + public void itemPopped(Stack<T> stack, T item) { + forEach(listener -> listener.itemPopped(stack, item)); + } + + @Override + public void stackCleared(Stack<T> stack) { + forEach(listener -> listener.stackCleared(stack)); + } + + @Override + public void comparatorChanged(Stack<T> stack, Comparator<T> previousComparator) { + forEach(listener -> listener.comparatorChanged(stack, previousComparator)); + } + } + + /** * StackListener adapter. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ + @Deprecated public static class Adapter<T> implements StackListener<T> { @Override public void itemPushed(Stack<T> stack, T item) { @@ -53,7 +82,8 @@ public interface StackListener<T> { * @param stack The stack that has changed. * @param item The newly pushed item. */ - public void itemPushed(Stack<T> stack, T item); + default public void itemPushed(Stack<T> stack, T item) { + } /** * Called when an item has been popped off of a stack. @@ -61,14 +91,16 @@ public interface StackListener<T> { * @param stack The stack that has changed. * @param item The item newly popped from the stack. */ - public void itemPopped(Stack<T> stack, T item); + default public void itemPopped(Stack<T> stack, T item) { + } /** * Called when a stack has been cleared. * * @param stack The newly cleared stack. */ - public void stackCleared(Stack<T> stack); + default public void stackCleared(Stack<T> stack) { + } /** * Called when a stack's comparator has changed. @@ -76,5 +108,6 @@ public interface StackListener<T> { * @param stack The stack in question. * @param previousComparator The previous comparator for this stack (if any). */ - public void comparatorChanged(Stack<T> stack, Comparator<T> previousComparator); + default public void comparatorChanged(Stack<T> stack, Comparator<T> previousComparator) { + } } Modified: pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java Tue Jan 16 20:07:44 2018 @@ -37,7 +37,7 @@ public class MapAdapter<K, V> implements private static final long serialVersionUID = 4005649560306864969L; private java.util.Map<K, V> map = null; - private transient MapListenerList<K, V> mapListeners = new MapListenerList<>(); + private transient MapListener.Listeners<K, V> mapListeners = new MapListener.Listeners<>(); public MapAdapter(java.util.Map<K, V> map) { Utils.checkNull(map, "map"); Modified: pivot/trunk/core/src/org/apache/pivot/collections/adapter/SetAdapter.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/adapter/SetAdapter.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/adapter/SetAdapter.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/adapter/SetAdapter.java Tue Jan 16 20:07:44 2018 @@ -36,7 +36,7 @@ public class SetAdapter<E> implements Se private static final long serialVersionUID = -816891924416727900L; private java.util.Set<E> set = null; - private transient SetListenerList<E> setListeners = new SetListenerList<>(); + private transient SetListener.Listeners<E> setListeners = new SetListener.Listeners<>(); public SetAdapter(java.util.Set<E> set) { Utils.checkNull(set, "set"); Modified: pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java Tue Jan 16 20:07:44 2018 @@ -29,7 +29,7 @@ import org.apache.pivot.util.Utils; * Synchronized implementation of the {@link Map} interface. */ public class SynchronizedMap<K, V> implements Map<K, V> { - private static class SynchronizedMapListenerList<K, V> extends MapListenerList<K, V> { + private static class SynchronizedMapListenerList<K, V> extends MapListener.Listeners<K, V> { @Override public synchronized void add(MapListener<K, V> listener) { super.add(listener); Modified: pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedQueue.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedQueue.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedQueue.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedQueue.java Tue Jan 16 20:07:44 2018 @@ -29,7 +29,7 @@ import org.apache.pivot.util.Utils; * Synchronized implementation of the {@link Queue} interface. */ public class SynchronizedQueue<T> implements Queue<T> { - private static class SynchronizedQueueListenerList<T> extends QueueListenerList<T> { + private static class SynchronizedQueueListenerList<T> extends QueueListener.Listeners<T> { @Override public synchronized void add(QueueListener<T> listener) { super.add(listener); Modified: pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedSet.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedSet.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedSet.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedSet.java Tue Jan 16 20:07:44 2018 @@ -29,7 +29,7 @@ import org.apache.pivot.util.Utils; * Synchronized implementation of the {@link Set} interface. */ public class SynchronizedSet<E> implements Set<E> { - private static class SynchronizedSetListenerList<E> extends SetListenerList<E> { + private static class SynchronizedSetListenerList<E> extends SetListener.Listeners<E> { @Override public synchronized void add(SetListener<E> listener) { super.add(listener); Modified: pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedStack.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedStack.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedStack.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedStack.java Tue Jan 16 20:07:44 2018 @@ -29,7 +29,7 @@ import org.apache.pivot.util.Utils; * Synchronized implementation of the {@link Stack} interface. */ public class SynchronizedStack<T> implements Stack<T> { - private static class SynchronizedStackListenerList<T> extends StackListenerList<T> { + private static class SynchronizedStackListenerList<T> extends StackListener.Listeners<T> { @Override public synchronized void add(StackListener<T> listener) { super.add(listener); Modified: pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java Tue Jan 16 20:07:44 2018 @@ -31,7 +31,7 @@ import org.apache.pivot.util.Utils; public class ImmutableMap<K, V> implements Map<K, V> { private Map<K, V> map = null; - private MapListenerList<K, V> mapListeners = new MapListenerList<>(); + private MapListener.Listeners<K, V> mapListeners = new MapListener.Listeners<>(); public ImmutableMap(Map<K, V> map) { Utils.checkNull(map, "map"); Modified: pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableSet.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableSet.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableSet.java (original) +++ pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableSet.java Tue Jan 16 20:07:44 2018 @@ -31,7 +31,7 @@ import org.apache.pivot.util.Utils; public class ImmutableSet<E> implements Set<E> { private Set<E> set = null; - private SetListenerList<E> setListeners = new SetListenerList<>(); + private SetListener.Listeners<E> setListeners = new SetListener.Listeners<>(); public ImmutableSet(Set<E> set) { Utils.checkNull(set, "set"); Modified: pivot/trunk/core/test/org/apache/pivot/collections/test/QueueTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/collections/test/QueueTest.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/core/test/org/apache/pivot/collections/test/QueueTest.java (original) +++ pivot/trunk/core/test/org/apache/pivot/collections/test/QueueTest.java Tue Jan 16 20:07:44 2018 @@ -83,7 +83,7 @@ public class QueueTest { } } - private static class Listener extends QueueListener.Adapter<String> { + private static class Listener implements QueueListener<String> { public int queueCount = 0; @Override Modified: pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java (original) +++ pivot/trunk/demos/src/org/apache/pivot/demos/dnd/FileDropTargetDemo.java Tue Jan 16 20:07:44 2018 @@ -56,7 +56,7 @@ public class FileDropTargetDemo extends fileList = new FileList(); fileTableView.setTableData(fileList); - fileList.getListListeners().add(new ListListener.Adapter<File>() { + fileList.getListListeners().add(new ListListener<File>() { @Override public void itemInserted(List<File> list, int index) { uploadButton.setEnabled(list.getLength() > 0); @@ -72,7 +72,7 @@ public class FileDropTargetDemo extends } }); - fileTableView.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() { + fileTableView.getComponentKeyListeners().add(new ComponentKeyListener() { @Override public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { Modified: pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java (original) +++ pivot/trunk/examples/src/org/apache/pivot/examples/keyboard/ComponentKeyListenerExample.java Tue Jan 16 20:07:44 2018 @@ -32,7 +32,7 @@ public class ComponentKeyListenerExample @Override public void initialize(Map<String, Object> namespace, URL location, Resources resources) { TextInput textInput = (TextInput) namespace.get("textInput"); - textInput.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() { + textInput.getComponentKeyListeners().add(new ComponentKeyListener() { @Override public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { Modified: pivot/trunk/tests/src/org/apache/pivot/tests/CheckedListViewTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/CheckedListViewTest.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/CheckedListViewTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/CheckedListViewTest.java Tue Jan 16 20:07:44 2018 @@ -76,7 +76,7 @@ public class CheckedListViewTest extends } }); - listView.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() { + listView.getComponentKeyListeners().add(new ComponentKeyListener() { @Override public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calculator/Calculator.java URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calculator/Calculator.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calculator/Calculator.java (original) +++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calculator/Calculator.java Tue Jan 16 20:07:44 2018 @@ -71,7 +71,7 @@ public class Calculator serializer.readObject(Calculator.class, "calculator.bxml"); serializer.bind(this); - mainWindow.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() { + mainWindow.getComponentKeyListeners().add(new ComponentKeyListener() { @Override public boolean keyTyped(Component comp, char ch) { // Some keys don't give us virtual key mappings, so we need to @@ -86,7 +86,7 @@ public class Calculator case '%': ACTION.PERCENT.perform(comp); return true; - case '\u007F': + case '': ACTION.BACKSPACE.perform(comp); return true; default: Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java (original) +++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/StockTrackerWindow.java Tue Jan 16 20:07:44 2018 @@ -211,7 +211,7 @@ public class StockTrackerWindow extends } }); - stocksTableView.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() { + stocksTableView.getComponentKeyListeners().add(new ComponentKeyListener() { @Override public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { @@ -234,7 +234,7 @@ public class StockTrackerWindow extends } }); - symbolTextInput.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() { + symbolTextInput.getComponentKeyListeners().add(new ComponentKeyListener() { @Override public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java Tue Jan 16 20:07:44 2018 @@ -799,11 +799,11 @@ public class TerraFileBrowserSkin extend * the first item.<br> {@link KeyCode#ESCAPE ESCAPE} Clear the search * field. */ - searchTextInput.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() { + searchTextInput.getComponentKeyListeners().add(new ComponentKeyListener() { @Override public boolean keyPressed(Component componentArgument, int keyCode, Keyboard.KeyLocation keyLocation) { - boolean consumed = super.keyPressed(componentArgument, keyCode, keyLocation); + boolean consumed = false; if (keyCode == Keyboard.KeyCode.ESCAPE) { searchTextInput.setText(""); Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java Tue Jan 16 20:07:44 2018 @@ -105,7 +105,7 @@ public class TerraSuggestionPopupSkin ex } }; - private ComponentKeyListener textInputKeyListener = new ComponentKeyListener.Adapter() { + private ComponentKeyListener textInputKeyListener = new ComponentKeyListener() { /** * {@link KeyCode#DOWN DOWN} Transfer focus to the suggestion list and * select the first suggestion if no others are selected.<br> @@ -144,7 +144,7 @@ public class TerraSuggestionPopupSkin ex } }; - private ComponentKeyListener listViewKeyListener = new ComponentKeyListener.Adapter() { + private ComponentKeyListener listViewKeyListener = new ComponentKeyListener() { /** * {@link KeyCode#TAB TAB} Close the suggestion popup with a 'result' of * true, and transfer focus forwards from the TextInput.<br> Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java Tue Jan 16 20:07:44 2018 @@ -74,7 +74,7 @@ public class TerraTooltipSkin extends Wi } }; - private ComponentKeyListener displayKeyListener = new ComponentKeyListener.Adapter() { + private ComponentKeyListener displayKeyListener = new ComponentKeyListener() { /** * Close the Tooltip. */ Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java Tue Jan 16 20:07:44 2018 @@ -940,11 +940,11 @@ public class TerraVFSBrowserSkin extends * the first item.<br> {@link KeyCode#ESCAPE ESCAPE} Clear the search * field. */ - searchTextInput.getComponentKeyListeners().add(new ComponentKeyListener.Adapter() { + searchTextInput.getComponentKeyListeners().add(new ComponentKeyListener() { @Override public boolean keyPressed(Component componentArgument, int keyCode, Keyboard.KeyLocation keyLocation) { - boolean consumed = super.keyPressed(componentArgument, keyCode, keyLocation); + boolean consumed = false; if (keyCode == Keyboard.KeyCode.ESCAPE) { searchTextInput.setText(""); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Tue Jan 16 20:07:44 2018 @@ -509,36 +509,6 @@ public abstract class Component implemen } } - private static class ComponentKeyListenerList extends ListenerList<ComponentKeyListener> - implements ComponentKeyListener { - @Override - public boolean keyTyped(Component component, char character) { - BooleanResult consumed = new BooleanResult(); - - forEach(listener -> consumed.or(listener.keyTyped(component, character))); - - return consumed.get(); - } - - @Override - public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { - BooleanResult consumed = new BooleanResult(); - - forEach(listener -> consumed.or(listener.keyPressed(component, keyCode, keyLocation))); - - return consumed.get(); - } - - @Override - public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { - BooleanResult consumed = new BooleanResult(); - - forEach(listener -> consumed.or(listener.keyReleased(component, keyCode, keyLocation))); - - return consumed.get(); - } - } - private static class ComponentTooltipListenerList extends ListenerList<ComponentTooltipListener> implements ComponentTooltipListener { @Override @@ -659,7 +629,7 @@ public abstract class Component implemen private ComponentMouseListenerList componentMouseListeners = new ComponentMouseListenerList(); private ComponentMouseButtonListenerList componentMouseButtonListeners = new ComponentMouseButtonListenerList(); private ComponentMouseWheelListenerList componentMouseWheelListeners = new ComponentMouseWheelListenerList(); - private ComponentKeyListenerList componentKeyListeners = new ComponentKeyListenerList(); + private ComponentKeyListener.Listeners componentKeyListeners = new ComponentKeyListener.Listeners(); private ComponentTooltipListenerList componentTooltipListeners = new ComponentTooltipListenerList(); private ComponentDataListenerList componentDataListeners = new ComponentDataListenerList(); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentKeyListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentKeyListener.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentKeyListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ComponentKeyListener.java Tue Jan 16 20:07:44 2018 @@ -16,13 +16,51 @@ */ package org.apache.pivot.wtk; +import org.apache.pivot.util.BooleanResult; +import org.apache.pivot.util.ListenerList; + /** * Component key listener interface. */ public interface ComponentKeyListener { /** + * Component key listeners. + */ + public static class Listeners extends ListenerList<ComponentKeyListener> + implements ComponentKeyListener { + @Override + public boolean keyTyped(Component component, char character) { + BooleanResult consumed = new BooleanResult(); + + forEach(listener -> consumed.or(listener.keyTyped(component, character))); + + return consumed.get(); + } + + @Override + public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { + BooleanResult consumed = new BooleanResult(); + + forEach(listener -> consumed.or(listener.keyPressed(component, keyCode, keyLocation))); + + return consumed.get(); + } + + @Override + public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { + BooleanResult consumed = new BooleanResult(); + + forEach(listener -> consumed.or(listener.keyReleased(component, keyCode, keyLocation))); + + return consumed.get(); + } + } + + /** * Component key listener adapter. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ + @Deprecated public static class Adapter implements ComponentKeyListener { @Override public boolean keyTyped(Component component, char character) { @@ -49,7 +87,9 @@ public interface ComponentKeyListener { * @return <tt>true</tt> to consume the event; <tt>false</tt> to allow it to * propagate. */ - public boolean keyTyped(Component component, char character); + default public boolean keyTyped(Component component, char character) { + return false; + } /** * Called when a key has been pressed. @@ -60,7 +100,9 @@ public interface ComponentKeyListener { * @return <tt>true</tt> to consume the event; <tt>false</tt> to allow it to * propagate. */ - public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation); + default public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { + return false; + } /** * Called when a key has been released. @@ -71,5 +113,7 @@ public interface ComponentKeyListener { * @return <tt>true</tt> to consume the event; <tt>false</tt> to allow it to * propagate. */ - public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation); + default public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) { + return false; + } } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/RadioButtonGroup.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/RadioButtonGroup.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/RadioButtonGroup.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/RadioButtonGroup.java Tue Jan 16 20:07:44 2018 @@ -95,7 +95,7 @@ public class RadioButtonGroup extends Bu * some of the buttons contained within may not be focusable, or even * visible. */ - private final ComponentKeyListener componentKeyListener = new ComponentKeyListener.Adapter() { + private final ComponentKeyListener componentKeyListener = new ComponentKeyListener() { /** * Handle TAB & SHIFT+TAB focus traversal, HOME, END & arrow keys */ Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java Tue Jan 16 20:07:44 2018 @@ -63,7 +63,7 @@ public abstract class CalendarButtonSkin } }; - private ComponentKeyListener calendarPopupKeyListener = new ComponentKeyListener.Adapter() { + private ComponentKeyListener calendarPopupKeyListener = new ComponentKeyListener() { /** * {@link KeyCode#ESCAPE ESCAPE} Close the popup.<br> * {@link KeyCode#ENTER ENTER} Choose the selected date.<br> Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java Tue Jan 16 20:07:44 2018 @@ -69,7 +69,7 @@ public abstract class ColorChooserButton } } - private ComponentKeyListener colorChooserPopupKeyListener = new ComponentKeyListener.Adapter() { + private ComponentKeyListener colorChooserPopupKeyListener = new ComponentKeyListener() { /** * {@link KeyCode#ESCAPE ESCAPE} Close the popup.<br> * {@link KeyCode#ENTER ENTER} Choose the selected color.<br> Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java Tue Jan 16 20:07:44 2018 @@ -63,7 +63,7 @@ public abstract class ListButtonSkin ext } }; - private ComponentKeyListener listViewPopupKeyListener = new ComponentKeyListener.Adapter() { + private ComponentKeyListener listViewPopupKeyListener = new ComponentKeyListener() { /** * {@link KeyCode#ESCAPE ESCAPE} Close the popup.<br> * {@link KeyCode#ENTER ENTER} Choose the selected list item.<br> Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java Tue Jan 16 20:07:44 2018 @@ -38,7 +38,7 @@ public abstract class MenuBarItemSkin ex protected MenuPopup menuPopup = new MenuPopup(); private boolean closeMenuPopup = false; - private ComponentKeyListener menuPopupComponentKeyListener = new ComponentKeyListener.Adapter() { + private ComponentKeyListener menuPopupComponentKeyListener = new ComponentKeyListener() { /** * {@link KeyCode#LEFT LEFT} or {@link KeyCode#TAB TAB} + * {@link Keyboard.Modifier#SHIFT SHIFT} Activate the menu to the left Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java Tue Jan 16 20:07:44 2018 @@ -28,23 +28,12 @@ import org.apache.pivot.wtk.TextPane; import org.apache.pivot.wtk.content.BaseContent; /** - * Node representing a live pivot component. + * Node representing a live Pivot component to be inserted into a {@link TextPane}. */ public class ComponentNode extends Block { - - private static class ComponentNodeListenerList extends ListenerList<ComponentNodeListener> - implements ComponentNodeListener { - @Override - public void componentChanged(ComponentNode componentNode, Component previousComponent) { - for (ComponentNodeListener listener : this) { - listener.componentChanged(componentNode, previousComponent); - } - } - } - private Component component = null; - private ComponentNodeListenerList componentNodeListeners = new ComponentNodeListenerList(); + private ComponentNodeListener.Listeners componentNodeListeners = new ComponentNodeListener.Listeners(); public ComponentNode() { } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNodeListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNodeListener.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNodeListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNodeListener.java Tue Jan 16 20:07:44 2018 @@ -16,11 +16,23 @@ */ package org.apache.pivot.wtk.text; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.wtk.Component; /** * Component node listener interface. */ public interface ComponentNodeListener { + /** + * The component node listeners. + */ + public static class Listeners extends ListenerList<ComponentNodeListener> + implements ComponentNodeListener { + @Override + public void componentChanged(ComponentNode componentNode, Component previousComponent) { + forEach(listener -> listener.componentChanged(componentNode, previousComponent)); + } + } + public void componentChanged(ComponentNode componentNode, Component previousComponent); } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java Tue Jan 16 20:07:44 2018 @@ -21,23 +21,16 @@ import java.net.URL; import org.apache.pivot.util.ImageUtils; import org.apache.pivot.util.ListenerList; import org.apache.pivot.util.Utils; +import org.apache.pivot.wtk.TextPane; import org.apache.pivot.wtk.media.Image; /** - * Node representing an image. + * Node representing an image to be inserted into a {@link TextPane}. */ public class ImageNode extends Block { - private static class ImageNodeListenerList extends ListenerList<ImageNodeListener> implements - ImageNodeListener { - @Override - public void imageChanged(ImageNode imageNode, Image previousImage) { - forEach(listener -> listener.imageChanged(imageNode, previousImage)); - } - } - private Image image = null; - private ImageNodeListenerList imageNodeListeners = new ImageNodeListenerList(); + private ImageNodeListener.Listeners imageNodeListeners = new ImageNodeListener.Listeners(); public ImageNode() { } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNodeListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNodeListener.java?rev=1821299&r1=1821298&r2=1821299&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNodeListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNodeListener.java Tue Jan 16 20:07:44 2018 @@ -16,11 +16,23 @@ */ package org.apache.pivot.wtk.text; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.wtk.media.Image; /** * Image node listener interface. */ public interface ImageNodeListener { + /** + * The image node listeners. + */ + public static class Listeners extends ListenerList<ImageNodeListener> implements + ImageNodeListener { + @Override + public void imageChanged(ImageNode imageNode, Image previousImage) { + forEach(listener -> listener.imageChanged(imageNode, previousImage)); + } + } + public void imageChanged(ImageNode imageNode, Image previousImage); }