Package de.sciss.gui
Class PathList
- java.lang.Object
-
- de.sciss.gui.PathList
-
public class PathList extends java.lang.ObjectManages 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.StringKEY_USERPATHSValue: Prefs key string representing the path list of a user's set favourite directories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddPathToHead(java.io.File path)Inserts a new path at the head of the list.booleanaddPathToTail(java.io.File path)Adds a new path to the tail of the list.voidclear()Removes all paths from the list.booleancontains(java.io.File path)Determines whether a particular path is included in the listintgetCapacity()java.io.FilegetPath(int index)Returns a path at some index in the listintgetPathCount()Returns the number of paths stored in the listintindexOf(java.io.File path)Determines whether a particular path is included in the listvoidremove(int index)Removes a path at some index in the listvoidremove(java.io.File path)Removes a pathvoidsetPath(int index, java.io.File path)Replaces a path at some index in the list
-
-
-
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
-
-