Class SendToActionUtils


  • public class SendToActionUtils
    extends Object
    Helper class for SendTo actions.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • SendToActionUtils

        public SendToActionUtils()
    • Method Detail

      • getAcceptedCache

        protected static Hashtable<Class,​ArrayList<Class>> getAcceptedCache()
        Returns the cache of what sendto actions can accept what classes.
        Returns:
        the cache
      • getActions

        public static AbstractSendToAction[] getActions​(SendToActionSupporter owner)
        Returns all the actions that can handle the specified class.
        Parameters:
        owner - the owner
        Returns:
        the available actions
      • createSubmenu

        protected static boolean createSubmenu​(SendToActionSupporter owner,
                                               JMenu submenu)
        Adds all the available sendto actions for the specified class to the submenu.
        Parameters:
        owner - the owner to get the item to send from
        submenu - the menu to add the "Send to" submenu to if available
        Returns:
        true if submenu was added
      • addSubmenu

        protected static boolean addSubmenu​(SendToActionSupporter owner,
                                            JMenu submenu)
        Attaches a listener to the top-level menu that triggers the generation of the send-to submenu.
        Parameters:
        owner - the owner to get the item to send from
        submenu - the menu to add the "Send to" submenu to if available
        Returns:
        true if submenu was added
      • addSendToSubmenu

        public static boolean addSendToSubmenu​(SendToActionSupporter owner,
                                               JPopupMenu menu)
        Adds all the available sendto actions for the specified class to the
        Parameters:
        owner - the owner to get the item to send from
        menu - the menu to add the "Send to" submenu to if available
        Returns:
        true if submenu was added
      • addSendToSubmenu

        public static boolean addSendToSubmenu​(SendToActionSupporter owner,
                                               JMenu menu)
        Adds all the available sendto actions for the specified class to the
        Parameters:
        owner - the owner to get the item to send from
        menu - the menu to add the "Send to" submenu to if available
        Returns:
        true if submenu was added
      • nextTmpFile

        public static PlaceholderFile nextTmpFile​(String prefix,
                                                  String extension)
        Generates a new temporary file, which will get deleted when the JVM exits.
        Parameters:
        prefix - the prefix for the filename (within the TMP directory)
        extension - the file extension to use (without dot!)
        Returns:
        the generated file
      • isAvailable

        public static boolean isAvailable​(Class needle,
                                          Class[] haystack)
        Checks whether a class (needle) is among a list of classes (haystack).
        Parameters:
        needle - the class to look for
        haystack - the available classes
      • isAvailable

        public static boolean isAvailable​(Class[] needles,
                                          Class[] haystack)
        Checks whether at least one class (of the needles) is among a list of classes (haystack).
        Parameters:
        needles - the classes to look for
        haystack - the available classes