Package adams.gui.goe

Class Favorites

    • Field Detail

      • m_Properties

        protected Properties m_Properties
        the properties.
      • m_Modified

        protected boolean m_Modified
        whether the favorites were modified.
      • m_AutoSave

        protected boolean m_AutoSave
        whether to save the properties whenever a change happened.
      • m_Singleton

        protected static Favorites m_Singleton
        the singleton.
    • Constructor Detail

      • Favorites

        public Favorites()
        Initializes the favorites with immediate saving enabled.
      • Favorites

        public Favorites​(boolean autosave)
        Initializes the favorites.
        Parameters:
        autosave - whether to save the favorites immediately whenever modified
    • Method Detail

      • setAutoSave

        public void setAutoSave​(boolean value)
        Sets auto save to on or off.
        Parameters:
        value - if true then auto save is on
      • isAutoSave

        public boolean isAutoSave()
        Returns whether the favorites get immediately saved whenever modified.
        Returns:
        true if autosave is on
      • setModified

        public void setModified​(boolean value)
        Sets the modified state.
        Parameters:
        value - the modified state
      • isModified

        public boolean isModified()
        Returns whether the favorites are modified.
        Returns:
        true if modified
      • setProperties

        public void setProperties​(Properties value)
        Sets the properties containing the favorites to use.
        Parameters:
        value - the properties to use
      • getProperties

        public Properties getProperties()
        Returns the properties of the favorites.
        Returns:
        the properties
      • load

        protected void load()
        Loads the favorites.
      • clear

        public void clear()
        Removes all favorites.
      • getFavorites

        public List<Favorites.Favorite> getFavorites​(String classname)
        Returns the favorites for the specified class.
        Parameters:
        classname - the class to get the favorites for
        Returns:
        the favorites
      • getFavorites

        public List<Favorites.Favorite> getFavorites​(Class cls)
        Returns the favorites for the specified class.
        Parameters:
        cls - the class to get the favorites for
        Returns:
        the favorites
      • getSuperclasses

        public List<String> getSuperclasses()
        Returns all the current superclasses.
        Returns:
        the classnames of the superclasses
      • fixName

        protected String fixName​(String name)
        Fixes the name by replacing all "|" with "/".
        Parameters:
        name - the name to fix
        Returns:
        the fixed name
      • getFavorite

        public Favorites.Favorite getFavorite​(Class cls,
                                              String name)
        Returns the named favorite for the specified class.
        Parameters:
        cls - the class to get the favorite for
        name - the name of the favorite
        Returns:
        the favorite, null if not available
      • addFavorite

        public void addFavorite​(Class cls,
                                Object obj,
                                String name)
        Adds a favorite for a class.
        Parameters:
        cls - the class to add the favorite for
        obj - the favorite
        name - the name of the favorite
      • removeFavorites

        public void removeFavorites​(String classname)
        Removes the favorites for the specified class.
        Parameters:
        classname - the class to remove the favorites for
      • removeFavorites

        public void removeFavorites​(Class cls)
        Removes the favorites for the specified class.
        Parameters:
        cls - the class to remove the favorites for
      • removeFavorite

        public void removeFavorite​(String classname,
                                   String name)
        Removes a favorite for a class.
        Parameters:
        classname - the class to remove the favorite for
        name - the name of the favorite
      • removeFavorite

        public void removeFavorite​(Class cls,
                                   String name)
        Removes a favorite for a class.
        Parameters:
        cls - the class to remove the favorite for
        name - the name of the favorite
      • getFilename

        public String getFilename()
        Returns the filename the favorites will be saved as.
        Returns:
        the filename
      • updateFavorites

        public boolean updateFavorites()
        Updates the favorites, i.e., stores the properties on disk.
        Returns:
        true if successfully saved
      • customizePopupMenu

        public void customizePopupMenu​(JPopupMenu menu,
                                       Class cls,
                                       Object current,
                                       Favorites.FavoriteSelectionListener listener)
        Adds a menu item with the favorites to the popup menu.
        Parameters:
        menu - the menu to add the favorites to
        cls - the class the favorites are for
        current - the current object
        listener - the listener to attach to the menu items' ActionListener
      • compareTo

        public int compareTo​(Object o)
        Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Specified by:
        compareTo in interface Comparable
        Parameters:
        o - the object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Throws:
        ClassCastException - if the specified object's type prevents it from being compared to this object.
      • equals

        public boolean equals​(Object obj)
        Indicates whether some other object is "equal to" this one.
        Overrides:
        equals in class Object
        Parameters:
        obj - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj argument; false otherwise.
      • removeTemporaryFavorites

        protected boolean removeTemporaryFavorites()
        Removes all the temporary favorites from the properties.
        Returns:
        true if modified
      • getSingleton

        public static Favorites getSingleton()
        Returns the singleton (and initializes it, if necessary).
        Returns:
        the singleton
      • reload

        public static void reload()
        Reloads the system-wide favorites.