Author: rwhitcomb Date: Wed Jan 17 01:40:26 2018 New Revision: 1821340 URL: http://svn.apache.org/viewvc?rev=1821340&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/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java pivot/trunk/tests/src/org/apache/pivot/tests/SheetTest.java pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot765.java pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot800.java pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspector.java pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorListener.java pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLogger.java pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerListener.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowActionMappingListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowClassListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.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/skin/MenuButtonSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java Modified: pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java (original) +++ pivot/trunk/examples/src/org/apache/pivot/examples/sheets/SheetSlideDirectionWindow.java Wed Jan 17 01:40:26 2018 @@ -105,7 +105,7 @@ public class SheetSlideDirectionWindow e }; // Add/remove the mouse handler based on the Sheet's state - sheet.getWindowStateListeners().add(new WindowStateListener.Adapter() { + sheet.getWindowStateListeners().add(new WindowStateListener() { @Override public void windowOpened(Window window) { window.getDisplay().getContainerMouseListeners().add(displayMouseHandler); Modified: pivot/trunk/tests/src/org/apache/pivot/tests/SheetTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/SheetTest.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/SheetTest.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/SheetTest.java Wed Jan 17 01:40:26 2018 @@ -137,7 +137,7 @@ public class SheetTest extends Applicati } }); - sheet.getWindowStateListeners().add(new WindowStateListener.Adapter() { + sheet.getWindowStateListeners().add(new WindowStateListener() { @Override public void windowOpened(Window window) { closeButton.requestFocus(); Modified: pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot765.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot765.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot765.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot765.java Wed Jan 17 01:40:26 2018 @@ -42,7 +42,7 @@ public class Pivot765 extends Applicatio button.setButtonData("Populate menu and open!"); Window window = new Window(button); - button.getListPopup().getWindowStateListeners().add(new WindowStateListener.Adapter() { + button.getListPopup().getWindowStateListeners().add(new WindowStateListener() { @Override public Vote previewWindowOpen(Window windowArgument) { Menu menu = new Menu(); Modified: pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot800.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot800.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot800.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot800.java Wed Jan 17 01:40:26 2018 @@ -40,7 +40,7 @@ public class Pivot800 extends Applicatio sheet.open(window); } - private class SelectFileListener extends WindowStateListener.Adapter { + private class SelectFileListener implements WindowStateListener { @Override public void windowOpened(Window window) { File homeFolder = new File(System.getProperty("user.home")); Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java (original) +++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindow.java Wed Jan 17 01:40:26 2018 @@ -35,46 +35,7 @@ import org.apache.pivot.wtk.media.Image; @DefaultProperty("content") public class FakeWindow extends Container { - private static class FakeWindowListenerList extends ListenerList<FakeWindowListener> - implements FakeWindowListener { - @Override - public void titleChanged(FakeWindow window, String previousTitle) { - for (FakeWindowListener listener : this) { - listener.titleChanged(window, previousTitle); - } - } - - @Override - public void iconAdded(FakeWindow window, Image addedIcon) { - for (FakeWindowListener listener : this) { - listener.iconAdded(window, addedIcon); - } - } - - @Override - public void iconInserted(FakeWindow window, Image addedIcon, int index) { - for (FakeWindowListener listener : this) { - listener.iconInserted(window, addedIcon, index); - } - } - - @Override - public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed) { - for (FakeWindowListener listener : this) { - listener.iconsRemoved(window, index, removed); - } - } - - @Override - public void contentChanged(FakeWindow window, Component previousContent) { - for (FakeWindowListener listener : this) { - listener.contentChanged(window, previousContent); - } - } - - } - - private FakeWindowListenerList windowListeners = new FakeWindowListenerList(); + private FakeWindowListener.Listeners windowListeners = new FakeWindowListener.Listeners(); private Component content = null; Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java (original) +++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowListener.java Wed Jan 17 01:40:26 2018 @@ -17,37 +17,39 @@ package org.apache.pivot.tutorials.bxmlexplorer; import org.apache.pivot.collections.Sequence; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.wtk.Component; import org.apache.pivot.wtk.media.Image; public interface FakeWindowListener { /** - * Window listener adapter. + * Fake window listeners. */ - public static class Adapter implements FakeWindowListener { + public static class Listeners extends ListenerList<FakeWindowListener> + implements FakeWindowListener { @Override public void titleChanged(FakeWindow window, String previousTitle) { - // empty block + forEach(listener -> listener.titleChanged(window, previousTitle)); } @Override public void iconAdded(FakeWindow window, Image addedIcon) { - // empty block + forEach(listener -> listener.iconAdded(window, addedIcon)); } @Override public void iconInserted(FakeWindow window, Image addedIcon, int index) { - // empty block + forEach(listener -> listener.iconInserted(window, addedIcon, index)); } @Override public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed) { - // empty block + forEach(listener -> listener.iconsRemoved(window, index, removed)); } @Override public void contentChanged(FakeWindow window, Component previousContent) { - // empty block + forEach(listener -> listener.contentChanged(window, previousContent)); } } @@ -58,7 +60,8 @@ public interface FakeWindowListener { * @param window * @param previousTitle */ - public void titleChanged(FakeWindow window, String previousTitle); + default public void titleChanged(FakeWindow window, String previousTitle) { + } /** * Called when a window's icon has changed. @@ -66,7 +69,8 @@ public interface FakeWindowListener { * @param window * @param addedIcon */ - public void iconAdded(FakeWindow window, Image addedIcon); + default public void iconAdded(FakeWindow window, Image addedIcon) { + } /** * Called when a window's icon has changed. @@ -74,7 +78,8 @@ public interface FakeWindowListener { * @param window * @param addedIcon */ - public void iconInserted(FakeWindow window, Image addedIcon, int index); + default public void iconInserted(FakeWindow window, Image addedIcon, int index) { + } /** * Called when a window's icon has changed. @@ -83,7 +88,8 @@ public interface FakeWindowListener { * @param index * @param removed */ - public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed); + default public void iconsRemoved(FakeWindow window, int index, Sequence<Image> removed) { + } /** * Called when a window's content component has changed. @@ -91,6 +97,7 @@ public interface FakeWindowListener { * @param window * @param previousContent */ - public void contentChanged(FakeWindow window, Component previousContent); + default public void contentChanged(FakeWindow window, Component previousContent) { + } } Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspector.java URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspector.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspector.java (original) +++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspector.java Wed Jan 17 01:40:26 2018 @@ -25,19 +25,9 @@ import org.apache.pivot.wtk.Container; * component (its "source"). */ public abstract class ComponentInspector extends Container { - private static class ComponentInspectorListenerList extends - ListenerList<ComponentInspectorListener> implements ComponentInspectorListener { - @Override - public void sourceChanged(ComponentInspector componentInspector, Component previousSource) { - for (ComponentInspectorListener listener : this) { - listener.sourceChanged(componentInspector, previousSource); - } - } - } - private Component source = null; - private ComponentInspectorListenerList componentInspectorListeners = new ComponentInspectorListenerList(); + private ComponentInspectorListener.Listeners componentInspectorListeners = new ComponentInspectorListener.Listeners(); public Component getSource() { return source; Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorListener.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorListener.java (original) +++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/ComponentInspectorListener.java Wed Jan 17 01:40:26 2018 @@ -16,6 +16,7 @@ */ package org.apache.pivot.tutorials.explorer.tools; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.wtk.Component; /** @@ -23,6 +24,17 @@ import org.apache.pivot.wtk.Component; */ public interface ComponentInspectorListener { /** + * The component inspector listeners. + */ + public static class Listeners extends + ListenerList<ComponentInspectorListener> implements ComponentInspectorListener { + @Override + public void sourceChanged(ComponentInspector componentInspector, Component previousSource) { + forEach(listener -> listener.sourceChanged(componentInspector, previousSource)); + } + } + + /** * Called when an component inspector's source component has changed. * * @param componentInspector Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLogger.java URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLogger.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLogger.java (original) +++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLogger.java Wed Jan 17 01:40:26 2018 @@ -157,40 +157,6 @@ public class EventLogger extends Contain } } - /** - * Event logger listener list. - */ - private static class EventLoggerListenerList extends ListenerList<EventLoggerListener> - implements EventLoggerListener { - @Override - public void sourceChanged(EventLogger eventLogger, Component previousSource) { - for (EventLoggerListener listener : this) { - listener.sourceChanged(eventLogger, previousSource); - } - } - - @Override - public void eventIncluded(EventLogger eventLogger, Method event) { - for (EventLoggerListener listener : this) { - listener.eventIncluded(eventLogger, event); - } - } - - @Override - public void eventExcluded(EventLogger eventLogger, Method event) { - for (EventLoggerListener listener : this) { - listener.eventExcluded(eventLogger, event); - } - } - - @Override - public void eventFired(EventLogger eventLogger, Method event, Object[] arguments) { - for (EventLoggerListener listener : this) { - listener.eventFired(eventLogger, event, arguments); - } - } - } - private Component source = null; private HashMap<Class<?>, Object> eventListenerProxies = new HashMap<>(); @@ -202,7 +168,7 @@ public class EventLogger extends Contain private HashSet<Method> includeEvents = new HashSet<>(); private IncludeEventGroup includeEventGroup = new IncludeEventGroup(); - private EventLoggerListenerList eventLoggerListeners = new EventLoggerListenerList(); + private EventLoggerListener.Listeners eventLoggerListeners = new EventLoggerListener.Listeners(); /** * Creates a new event logger that is not tied to any source component. Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerListener.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerListener.java (original) +++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/explorer/tools/EventLoggerListener.java Wed Jan 17 01:40:26 2018 @@ -18,6 +18,7 @@ package org.apache.pivot.tutorials.explo import java.lang.reflect.Method; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.wtk.Component; /** @@ -25,27 +26,28 @@ import org.apache.pivot.wtk.Component; */ public interface EventLoggerListener { /** - * Event logger listener adapter. + * Event logger listeners. */ - public static class Adapter implements EventLoggerListener { + public static class Listeners extends ListenerList<EventLoggerListener> + implements EventLoggerListener { @Override public void sourceChanged(EventLogger eventLogger, Component previousSource) { - // empty block + forEach(listener -> listener.sourceChanged(eventLogger, previousSource)); } @Override - public void eventIncluded(EventLogger eventLogger, Method method) { - // empty block + public void eventIncluded(EventLogger eventLogger, Method event) { + forEach(listener -> listener.eventIncluded(eventLogger, event)); } @Override - public void eventExcluded(EventLogger eventLogger, Method method) { - // empty block + public void eventExcluded(EventLogger eventLogger, Method event) { + forEach(listener -> listener.eventExcluded(eventLogger, event)); } @Override public void eventFired(EventLogger eventLogger, Method event, Object[] arguments) { - // empty block + forEach(listener -> listener.eventFired(eventLogger, event, arguments)); } } @@ -55,7 +57,8 @@ public interface EventLoggerListener { * @param eventLogger * @param previousSource */ - public void sourceChanged(EventLogger eventLogger, Component previousSource); + default public void sourceChanged(EventLogger eventLogger, Component previousSource) { + } /** * Called when a declared event has been included in the list of logged @@ -64,7 +67,8 @@ public interface EventLoggerListener { * @param eventLogger * @param event */ - public void eventIncluded(EventLogger eventLogger, Method event); + default public void eventIncluded(EventLogger eventLogger, Method event) { + } /** * Called when a declared event has been excluded from the list of logged @@ -73,7 +77,8 @@ public interface EventLoggerListener { * @param eventLogger * @param event */ - public void eventExcluded(EventLogger eventLogger, Method event); + default public void eventExcluded(EventLogger eventLogger, Method event) { + } /** * Called when an included event has been fired by the event logger's @@ -83,5 +88,6 @@ public interface EventLoggerListener { * @param event * @param arguments */ - public void eventFired(EventLogger eventLogger, Method event, Object[] arguments); + default public void eventFired(EventLogger eventLogger, Method event, Object[] arguments) { + } } Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java Wed Jan 17 01:40:26 2018 @@ -52,7 +52,7 @@ import org.apache.pivot.wtk.skin.Calenda * Terra calendar button skin. <p> TODO Calendar pass-through styles. */ public class TerraCalendarButtonSkin extends CalendarButtonSkin { - private WindowStateListener calendarPopupStateListener = new WindowStateListener.Adapter() { + private WindowStateListener calendarPopupStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { CalendarButton calendarButton = (CalendarButton) getComponent(); Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java Wed Jan 17 01:40:26 2018 @@ -51,7 +51,7 @@ import org.apache.pivot.wtk.skin.ColorCh * Terra color chooser button skin. */ public class TerraColorChooserButtonSkin extends ColorChooserButtonSkin { - private WindowStateListener colorChooserPopupStateListener = new WindowStateListener.Adapter() { + private WindowStateListener colorChooserPopupStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { ColorChooserButton colorChooserButton = (ColorChooserButton) getComponent(); Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java Wed Jan 17 01:40:26 2018 @@ -381,7 +381,7 @@ public class TerraFormSkin extends Conta } flagMessageWindow.getDecorators().add(new PopupFieldIndicatorDecorator()); - flagMessageWindow.getWindowStateListeners().add(new WindowStateListener.Adapter() { + flagMessageWindow.getWindowStateListeners().add(new WindowStateListener() { private ApplicationContext.ScheduledCallback scheduledHideFlagMessageCallback = null; @Override Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java Wed Jan 17 01:40:26 2018 @@ -57,7 +57,7 @@ import org.apache.pivot.wtk.skin.ListBut * Terra list button skin. */ public class TerraListButtonSkin extends ListButtonSkin { - private WindowStateListener listViewPopupStateListener = new WindowStateListener.Adapter() { + private WindowStateListener listViewPopupStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { // Adjust for list size Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java (original) +++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java Wed Jan 17 01:40:26 2018 @@ -67,7 +67,7 @@ public class TerraMenuButtonSkin extends private static final int CORNER_RADIUS = 4; - private WindowStateListener menuPopupWindowStateListener = new WindowStateListener.Adapter() { + private WindowStateListener menuPopupWindowStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { MenuButton menuButton = (MenuButton) getComponent(); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java Wed Jan 17 01:40:26 2018 @@ -1141,7 +1141,7 @@ public abstract class ApplicationContext menuPopup = new MenuPopup(menu); menuPopup.getWindowStateListeners().add( - new WindowStateListener.Adapter() { + new WindowStateListener() { @Override public void windowClosed(Window window, Display displayArgument, Window owner) { Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java Wed Jan 17 01:40:26 2018 @@ -90,7 +90,7 @@ public final class DesktopApplicationCon private transient Window rootOwner = null; private transient Runnable updateHostWindowTitleBarCallback = null; - private transient WindowListener rootOwnerListener = new WindowListener.Adapter() { + private transient WindowListener rootOwnerListener = new WindowListener() { @Override public void titleChanged(Window window, String previousTitle) { updateFrameTitleBar(); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java Wed Jan 17 01:40:26 2018 @@ -144,13 +144,8 @@ public class Window extends Container { throw new IllegalArgumentException("Action mapping already has a window."); } - if (actionMapping.keyStroke == null) { - throw new IllegalArgumentException("Keystroke is undefined."); - } - - if (actionMapping.action == null) { - throw new IllegalArgumentException("Action is undefined."); - } + Utils.checkNull(actionMapping.keyStroke, "Keystroke"); + Utils.checkNull(actionMapping.action, "Action"); if (actionMap.containsKey(actionMapping.keyStroke)) { throw new IllegalArgumentException("A mapping for " + actionMapping.keyStroke @@ -282,118 +277,6 @@ public class Window extends Container { } } - private static class WindowListenerList extends ListenerList<WindowListener> implements - WindowListener { - @Override - public void titleChanged(Window window, String previousTitle) { - forEach(listener -> listener.titleChanged(window, previousTitle)); - } - - @Override - public void iconAdded(Window window, Image addedIcon) { - forEach(listener -> listener.iconAdded(window, addedIcon)); - } - - @Override - public void iconInserted(Window window, Image addedIcon, int index) { - forEach(listener -> listener.iconInserted(window, addedIcon, index)); - } - - @Override - public void iconsRemoved(Window window, int index, Sequence<Image> removed) { - forEach(listener -> listener.iconsRemoved(window, index, removed)); - } - - @Override - public void contentChanged(Window window, Component previousContent) { - forEach(listener -> listener.contentChanged(window, previousContent)); - } - - @Override - public void activeChanged(Window window, Window obverseWindow) { - forEach(listener -> listener.activeChanged(window, obverseWindow)); - } - - @Override - public void maximizedChanged(Window window) { - forEach(listener -> listener.maximizedChanged(window)); - } - } - - private static class WindowStateListenerList extends ListenerList<WindowStateListener> - implements WindowStateListener { - @Override - public void windowOpened(Window window) { - forEach(listener -> listener.windowOpened(window)); - } - - @Override - public Vote previewWindowClose(Window window) { - VoteResult result = new VoteResult(); - - forEach(listener -> result.tally(listener.previewWindowClose(window))); - - return result.get(); - } - - @Override - public void windowCloseVetoed(Window window, Vote reason) { - forEach(listener -> listener.windowCloseVetoed(window, reason)); - } - - @Override - public Vote previewWindowOpen(Window window) { - VoteResult result = new VoteResult(); - - forEach(listener -> result.tally(listener.previewWindowOpen(window))); - - return result.get(); - } - - @Override - public void windowOpenVetoed(Window window, Vote reason) { - forEach(listener -> listener.windowOpenVetoed(window, reason)); - } - - @Override - public void windowClosed(Window window, Display display, Window owner) { - forEach(listener -> listener.windowClosed(window, display, owner)); - } - } - - private static class WindowActionMappingListenerList extends - ListenerList<WindowActionMappingListener> implements WindowActionMappingListener { - @Override - public void actionMappingAdded(Window window) { - forEach(listener -> listener.actionMappingAdded(window)); - } - - @Override - public void actionMappingsRemoved(Window window, int index, - Sequence<Window.ActionMapping> removed) { - forEach(listener -> listener.actionMappingsRemoved(window, index, removed)); - } - - @Override - public void keyStrokeChanged(Window.ActionMapping actionMapping, - Keyboard.KeyStroke previousKeyStroke) { - forEach(listener -> listener.keyStrokeChanged(actionMapping, previousKeyStroke)); - } - - @Override - public void actionChanged(Window.ActionMapping actionMapping, Action previousAction) { - forEach(listener -> listener.actionChanged(actionMapping, previousAction)); - } - } - - private static class WindowClassListenerList extends ListenerList<WindowClassListener> - implements WindowClassListener { - @Override - public void activeWindowChanged(Window previousActiveWindow) { - forEach(listener -> listener.activeWindowChanged(previousActiveWindow)); - } - } - private Window owner = null; private ArrayList<Window> ownedWindows = new ArrayList<>(); @@ -413,11 +296,11 @@ public class Window extends Container { private Point restoreLocation = null; - private WindowListenerList windowListeners = new WindowListenerList(); - private WindowStateListenerList windowStateListeners = new WindowStateListenerList(); - private WindowActionMappingListenerList windowActionMappingListeners = new WindowActionMappingListenerList(); + private WindowListener.Listeners windowListeners = new WindowListener.Listeners(); + private WindowStateListener.Listeners windowStateListeners = new WindowStateListener.Listeners(); + private WindowActionMappingListener.Listeners windowActionMappingListeners = new WindowActionMappingListener.Listeners(); - private static WindowClassListenerList windowClassListeners = new WindowClassListenerList(); + private static WindowClassListener.Listeners windowClassListeners = new WindowClassListener.Listeners(); private static Window activeWindow = null; Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowActionMappingListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowActionMappingListener.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowActionMappingListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowActionMappingListener.java Wed Jan 17 01:40:26 2018 @@ -17,12 +17,41 @@ package org.apache.pivot.wtk; import org.apache.pivot.collections.Sequence; +import org.apache.pivot.util.ListenerList; /** * Window action mapping listener interface. */ public interface WindowActionMappingListener { /** + * Window action mapping listeners. + */ + public static class Listeners extends ListenerList<WindowActionMappingListener> + implements WindowActionMappingListener { + @Override + public void actionMappingAdded(Window window) { + forEach(listener -> listener.actionMappingAdded(window)); + } + + @Override + public void actionMappingsRemoved(Window window, int index, + Sequence<Window.ActionMapping> removed) { + forEach(listener -> listener.actionMappingsRemoved(window, index, removed)); + } + + @Override + public void keyStrokeChanged(Window.ActionMapping actionMapping, + Keyboard.KeyStroke previousKeyStroke) { + forEach(listener -> listener.keyStrokeChanged(actionMapping, previousKeyStroke)); + } + + @Override + public void actionChanged(Window.ActionMapping actionMapping, Action previousAction) { + forEach(listener -> listener.actionChanged(actionMapping, previousAction)); + } + } + + /** * Called when an action mapping has been added to a window. * * @param window The source of this event. Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowClassListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowClassListener.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowClassListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowClassListener.java Wed Jan 17 01:40:26 2018 @@ -16,11 +16,24 @@ */ package org.apache.pivot.wtk; +import org.apache.pivot.util.ListenerList; + /** * Window class listener interface. */ public interface WindowClassListener { /** + * Window class listeners. + */ + public static class Listeners extends ListenerList<WindowClassListener> + implements WindowClassListener { + @Override + public void activeWindowChanged(Window previousActiveWindow) { + forEach(listener -> listener.activeWindowChanged(previousActiveWindow)); + } + } + + /** * Called when the active window has changed. * * @param previousActiveWindow The window that was previously the active window. Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowListener.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowListener.java Wed Jan 17 01:40:26 2018 @@ -17,6 +17,7 @@ package org.apache.pivot.wtk; import org.apache.pivot.collections.Sequence; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.wtk.media.Image; /** @@ -24,8 +25,51 @@ import org.apache.pivot.wtk.media.Image; */ public interface WindowListener { /** + * Window listeners. + */ + public static class Listeners extends ListenerList<WindowListener> implements + WindowListener { + @Override + public void titleChanged(Window window, String previousTitle) { + forEach(listener -> listener.titleChanged(window, previousTitle)); + } + + @Override + public void iconAdded(Window window, Image addedIcon) { + forEach(listener -> listener.iconAdded(window, addedIcon)); + } + + @Override + public void iconInserted(Window window, Image addedIcon, int index) { + forEach(listener -> listener.iconInserted(window, addedIcon, index)); + } + + @Override + public void iconsRemoved(Window window, int index, Sequence<Image> removed) { + forEach(listener -> listener.iconsRemoved(window, index, removed)); + } + + @Override + public void contentChanged(Window window, Component previousContent) { + forEach(listener -> listener.contentChanged(window, previousContent)); + } + + @Override + public void activeChanged(Window window, Window obverseWindow) { + forEach(listener -> listener.activeChanged(window, obverseWindow)); + } + + @Override + public void maximizedChanged(Window window) { + forEach(listener -> listener.maximizedChanged(window)); + } + } + + /** * Window listener adapter. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ + @Deprecated public static class Adapter implements WindowListener { @Override public void titleChanged(Window window, String previousTitle) { @@ -69,7 +113,8 @@ public interface WindowListener { * @param window The window whose title has changed. * @param previousTitle What the title was previously (can be {@code null}). */ - public void titleChanged(Window window, String previousTitle); + default public void titleChanged(Window window, String previousTitle) { + } /** * Called when an icon has been added to a window. @@ -77,7 +122,8 @@ public interface WindowListener { * @param window The window that has changed. * @param addedIcon The icon that was added. */ - public void iconAdded(Window window, Image addedIcon); + default public void iconAdded(Window window, Image addedIcon) { + } /** * Called when a window has had an icon inserted. @@ -87,7 +133,8 @@ public interface WindowListener { * @param index The index where this icon was inserted in the * window's icon sequence.. */ - public void iconInserted(Window window, Image addedIcon, int index); + default public void iconInserted(Window window, Image addedIcon, int index) { + } /** * Called when one or more of the window's icons were removed. @@ -97,7 +144,8 @@ public interface WindowListener { * the window's icon sequence. * @param removed The sequence of icons that were actually removed. */ - public void iconsRemoved(Window window, int index, Sequence<Image> removed); + default public void iconsRemoved(Window window, int index, Sequence<Image> removed) { + } /** * Called when a window's content component has changed. @@ -105,7 +153,8 @@ public interface WindowListener { * @param window The window whose content has changed. * @param previousContent What the window's content was previously. */ - public void contentChanged(Window window, Component previousContent); + default public void contentChanged(Window window, Component previousContent) { + } /** * Called when a window's active state has changed. @@ -113,12 +162,14 @@ public interface WindowListener { * @param window The window that has changed its active state. * @param obverseWindow The "other" window that is affected. */ - public void activeChanged(Window window, Window obverseWindow); + default public void activeChanged(Window window, Window obverseWindow) { + } /** * Called when a window's maximized state has changed. * * @param window The window whose state has changed. */ - public void maximizedChanged(Window window); + default public void maximizedChanged(Window window) { + } } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java Wed Jan 17 01:40:26 2018 @@ -16,15 +16,63 @@ */ package org.apache.pivot.wtk; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.util.Vote; +import org.apache.pivot.util.VoteResult; /** * Window state listener interface. */ public interface WindowStateListener { /** + * Window state listeners. + */ + public static class Listeners extends ListenerList<WindowStateListener> + implements WindowStateListener { + @Override + public void windowOpened(Window window) { + forEach(listener -> listener.windowOpened(window)); + } + + @Override + public Vote previewWindowClose(Window window) { + VoteResult result = new VoteResult(); + + forEach(listener -> result.tally(listener.previewWindowClose(window))); + + return result.get(); + } + + @Override + public void windowCloseVetoed(Window window, Vote reason) { + forEach(listener -> listener.windowCloseVetoed(window, reason)); + } + + @Override + public Vote previewWindowOpen(Window window) { + VoteResult result = new VoteResult(); + + forEach(listener -> result.tally(listener.previewWindowOpen(window))); + + return result.get(); + } + + @Override + public void windowOpenVetoed(Window window, Vote reason) { + forEach(listener -> listener.windowOpenVetoed(window, reason)); + } + + @Override + public void windowClosed(Window window, Display display, Window owner) { + forEach(listener -> listener.windowClosed(window, display, owner)); + } + } + + /** * Window state listener adapter. + * @deprecated Since 2.1 and Java 8 the interface itself has default implementations. */ + @Deprecated public static class Adapter implements WindowStateListener { @Override public void windowOpened(Window window) { @@ -62,7 +110,8 @@ public interface WindowStateListener { * * @param window The newly opened window. */ - public void windowOpened(Window window); + default public void windowOpened(Window window) { + } /** * Called to preview a window close event. @@ -70,7 +119,9 @@ public interface WindowStateListener { * @param window The window that wants to close. * @return The vote from each listener as to whether to allow the close. */ - public Vote previewWindowClose(Window window); + default public Vote previewWindowClose(Window window) { + return Vote.APPROVE; + } /** * Called to preview a window open event. @@ -78,7 +129,9 @@ public interface WindowStateListener { * @param window The window that wants to open. * @return The vote from the listener as to whether to allow the open. */ - public Vote previewWindowOpen(Window window); + default public Vote previewWindowOpen(Window window) { + return Vote.APPROVE; + } /** * Called when a window close event has been vetoed. @@ -87,7 +140,8 @@ public interface WindowStateListener { * @param reason The accumulated vote from all the listeners that * vetoed this event. */ - public void windowCloseVetoed(Window window, Vote reason); + default public void windowCloseVetoed(Window window, Vote reason) { + } /** * Called when a window open event has been vetoed. @@ -96,7 +150,8 @@ public interface WindowStateListener { * @param reason The accumulated vote from all the listeners that * vetoed this event. */ - public void windowOpenVetoed(Window window, Vote reason); + default public void windowOpenVetoed(Window window, Vote reason) { + } /** * Called when a window has closed. @@ -105,5 +160,6 @@ public interface WindowStateListener { * @param display The display in which the window was shown. * @param owner The owner of this window (which could be {@code null}). */ - public void windowClosed(Window window, Display display, Window owner); + default public void windowClosed(Window window, Display display, Window owner) { + } } 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=1821340&r1=1821339&r2=1821340&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 Wed Jan 17 01:40:26 2018 @@ -107,7 +107,7 @@ public abstract class CalendarButtonSkin } }; - private WindowStateListener calendarPopupWindowStateListener = new WindowStateListener.Adapter() { + private WindowStateListener calendarPopupWindowStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { Display display = window.getDisplay(); 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=1821340&r1=1821339&r2=1821340&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 Wed Jan 17 01:40:26 2018 @@ -112,7 +112,7 @@ public abstract class ColorChooserButton } }; - private WindowStateListener colorChooserPopupWindowStateListener = new WindowStateListener.Adapter() { + private WindowStateListener colorChooserPopupWindowStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { Display display = window.getDisplay(); 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=1821340&r1=1821339&r2=1821340&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 Wed Jan 17 01:40:26 2018 @@ -117,7 +117,7 @@ public abstract class ListButtonSkin ext } }; - private WindowStateListener listViewPopupWindowStateListener = new WindowStateListener.Adapter() { + private WindowStateListener listViewPopupWindowStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { Display display = window.getDisplay(); 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=1821340&r1=1821339&r2=1821340&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 Wed Jan 17 01:40:26 2018 @@ -67,7 +67,7 @@ public abstract class MenuBarItemSkin ex } }; - private WindowStateListener menuPopupWindowStateListener = new WindowStateListener.Adapter() { + private WindowStateListener menuPopupWindowStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { Display display = window.getDisplay(); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java Wed Jan 17 01:40:26 2018 @@ -40,7 +40,7 @@ public abstract class MenuButtonSkin ext protected boolean pressed = false; protected MenuPopup menuPopup = new MenuPopup(); - private WindowStateListener menuPopupWindowStateListener = new WindowStateListener.Adapter() { + private WindowStateListener menuPopupWindowStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { Display display = window.getDisplay(); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java?rev=1821340&r1=1821339&r2=1821340&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java Wed Jan 17 01:40:26 2018 @@ -36,7 +36,7 @@ import org.apache.pivot.wtk.WindowStateL public abstract class MenuItemSkin extends ButtonSkin implements Menu.ItemListener { protected MenuPopup menuPopup = new MenuPopup(); - private WindowStateListener menuPopupWindowStateListener = new WindowStateListener.Adapter() { + private WindowStateListener menuPopupWindowStateListener = new WindowStateListener() { @Override public void windowOpened(Window window) { Display display = window.getDisplay();