Package de.sciss.gui

Class PathList


  • public class PathList
    extends java.lang.Object
    Manages a list of paths and allows conversion to / from preferences value strings. This is used to manage the list of recently opened files.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String KEY_USERPATHS
      Value: Prefs key string representing the path list of a user's set favourite directories.
    • Constructor Summary

      Constructors 
      Constructor Description
      PathList​(int capacity)
      Creates a new empty PathList.
      PathList​(int capacity, java.util.prefs.Preferences prefs, java.lang.String prefsKey)
      Creates a new PathList reflecting a value in a Preferences object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addPathToHead​(java.io.File path)
      Inserts a new path at the head of the list.
      boolean addPathToTail​(java.io.File path)
      Adds a new path to the tail of the list.
      void clear()
      Removes all paths from the list.
      boolean contains​(java.io.File path)
      Determines whether a particular path is included in the list
      int getCapacity()  
      java.io.File getPath​(int index)
      Returns a path at some index in the list
      int getPathCount()
      Returns the number of paths stored in the list
      int indexOf​(java.io.File path)
      Determines whether a particular path is included in the list
      void remove​(int index)
      Removes a path at some index in the list
      void remove​(java.io.File path)
      Removes a path
      void setPath​(int index, java.io.File path)
      Replaces a path at some index in the list
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • KEY_USERPATHS

        public static final java.lang.String KEY_USERPATHS
        Value: Prefs key string representing the path list of a user's set favourite directories. See PathList and PathField documentation.
        Has default value: no!
        Node: root
        See Also:
        Constant Field Values
    • Constructor Detail

      • PathList

        public PathList​(int capacity)
        Creates a new empty PathList.
        Parameters:
        capacity - maximum number of paths
      • PathList

        public PathList​(int capacity,
                        java.util.prefs.Preferences prefs,
                        java.lang.String prefsKey)
        Creates a new PathList reflecting a value in a Preferences object. The list is initially filled with the paths stored in the preference entry (if present). All modifications like adding or removing paths are immediately reflected in the provided Preferences.
        Parameters:
        capacity - maximum number of paths
    • Method Detail

      • getCapacity

        public int getCapacity()
      • getPathCount

        public int getPathCount()
        Returns the number of paths stored in the list
        Returns:
        number of stored paths (which can be smaller than the capacity)
      • getPath

        public java.io.File getPath​(int index)
        Returns a path at some index in the list
        Parameters:
        index - of the path to query, must be smaller than getPathCount()
        Returns:
        the path at that index
      • setPath

        public void setPath​(int index,
                            java.io.File path)
        Replaces a path at some index in the list
        Parameters:
        index - in the list whose path should be replaced. must be smaller than getPathCount()
      • remove

        public void remove​(int index)
        Removes a path at some index in the list
        Parameters:
        index - in the list whose path should deleted. Paths following in the list will be shifted accordingly. Must be smaller than getPathCount()
      • remove

        public void remove​(java.io.File path)
        Removes a path
        Parameters:
        path - path which should deleted. Paths following in the list will be shifted accordingly.
      • addPathToHead

        public boolean addPathToHead​(java.io.File path)
        Inserts a new path at the head of the list. If this would cause the capacity to overflow, the tail path is removed
        Parameters:
        path - the path to insert
        Returns:
        true if the tail had to be removed
      • addPathToTail

        public boolean addPathToTail​(java.io.File path)
        Adds a new path to the tail of the list. If this would cause the capacity to overflow, the head path is removed
        Parameters:
        path - the path to insert
        Returns:
        true if the head had to be removed
      • clear

        public void clear()
        Removes all paths from the list.
      • contains

        public boolean contains​(java.io.File path)
        Determines whether a particular path is included in the list
        Parameters:
        path - path to look for
        Returns:
        true if the path is contained in the list
      • indexOf

        public int indexOf​(java.io.File path)
        Determines whether a particular path is included in the list
        Parameters:
        path - path to look for
        Returns:
        the index of the path in the list or -1 if not in the list