package editor.util;

import java.util.function.Consumer;

import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;

/**
 * TODO
 */
public interface MenuListenerFactory
{
    public static MenuListener createCanceledListener(Consumer<MenuEvent> canceled)
    {
        return new MenuListener()
        {
            @Override
            public void menuCanceled(MenuEvent e)
            {
                canceled.accept(e);
            }

            @Override
            public void menuDeselected(MenuEvent e) {}

            @Override
            public void menuSelected(MenuEvent e) {}
        };
    }

    public static MenuListener createDeselectedListener(Consumer<MenuEvent> deselected)
    {
        return new MenuListener()
        {
            @Override
            public void menuCanceled(MenuEvent e) {}

            @Override
            public void menuDeselected(MenuEvent e)
            {
                deselected.accept(e);
            }

            @Override
            public void menuSelected(MenuEvent e) {}
        };
    }

    public static MenuListener createSelectedListener(Consumer<MenuEvent> selected)
    {
        return new MenuListener()
        {
            @Override
            public void menuCanceled(MenuEvent e) {}

            @Override
            public void menuDeselected(MenuEvent e) {}

            @Override
            public void menuSelected(MenuEvent e)
            {
                selected.accept(e);
            }
        };
    }
}
@@ -140,54 +140,459 @@
  * T
-ODO%0A */%0Apublic interface MenuListenerFactory%0A%7B
+his interface is a factory for creating menu listeners that don't listen for all%0A * three of a menu becoming selected, deselected, or canceled.%0A * %0A * @author Alec Roelke%0A */%0Apublic interface MenuListenerFactory%0A%7B%0A    /**%0A     * Create a new MenuListener that only listens for cancellation.%0A     * %0A     * @param canceled action to perform when a menu is canceled%0A     * @return a MenuListener that performs the action when a menu is canceled.%0A     */
 %0A   
@@ -1022,32 +1022,282 @@
       %7D;%0A    %7D%0A%0A
+    /**%0A     * Create a new MenuListener that listens for a menu to be deselected.%0A     * %0A     * @param deselected action to perform when a menu is deselected%0A     * @return a MenuListener that performs the action when a menu is deselected.%0A     */%0A
     public stati
@@ -1724,24 +1724,266 @@
   %7D;%0A    %7D%0A%0A
+    /**%0A     * Create a new MenuListener that listens for a menu to be selected.%0A     * %0A     * @param selected action to perform when a menu is selected%0A     * @return a MenuListener that performs the action when a menu is selected.%0A     */%0A
     public s

Comment MenuListenerFactory