Package org.opensourcephysics.tools
Class Library
java.lang.Object
org.opensourcephysics.tools.Library
A Library for a LibraryBrowser. Maintains lists of collection paths and
imported sub-libraries.
- Author:
- Douglas Brown
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LibraryBrowser
protected String
protected int
protected String
protected String[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCollection
(String path, String name) Adds a collection to this library.boolean
addComPADRECollection
(String path, String name) Adds a comPADRE collection.boolean
addOSPLibrary
(String path) Adds an OSP-sponsored library.protected void
Adds a path to the list of recently opened tabs.boolean
addSubLibrary
(String path) Adds a sublibrary.protected boolean
containsPath
(String path, boolean allLists) Returns true if this library contains a collection path.Returns all collection paths in this Library and sub-libraries.protected Library
Gets a clone of this library that is suitable for exporting.static XML.ObjectLoader
Returns an ObjectLoader to save and load data for this class.protected String
getName()
Gets the name of this library.Returns a Map of path-to-tabname.protected Collection<String>
getNames()
Gets the names of all collections maintained by this library.boolean
importLibrary
(String path) Imports a library.protected boolean
importLibrary
(String path, Library library) Imports a Library if not already imported.protected boolean
isEmpty()
Returns true if this library has no collections.protected void
Loads this library from an xml file.protected void
removeRecent
(String filename) Removes a path from the list of recently opened tabs.protected void
renameCollection
(String path, String newName) Renames a collection.protected void
Saves this library in an xml file.protected void
Sets the name of this library.toString()
Returns a string representation of this library.
-
Field Details
-
name
-
pathList
-
pathToNameMap
-
comPADREPathList
-
comPADREPathToNameMap
-
ospLibraryPathList
-
ospPathToLibraryMap
-
importedPathList
-
importedPathToLibraryMap
-
subPathList
-
subPathToLibraryMap
-
allPathsToNameMap
-
noSearchSet
-
openTabPaths
-
recentTabs
-
maxRecentTabCount
protected int maxRecentTabCount -
chooserDir
-
browser
-
-
Constructor Details
-
Library
public Library()
-
-
Method Details
-
addOSPLibrary
Adds an OSP-sponsored library. OSP libraries are not under user control.- Parameters:
path
- the library path- Returns:
- true if successfully added
-
importLibrary
Imports a library. Imported libraries are managed by the user.- Parameters:
path
- the library path- Returns:
- true if successfully imported
-
addComPADRECollection
Adds a comPADRE collection. ComPADRE collections are not under user control.- Parameters:
path
- the comPADRE queryname
- the name of the collection- Returns:
- true if successfully added
-
addSubLibrary
Adds a sublibrary. Sublibraries are shown as submenus in a Library's Collections menu. Sublibraries are not under user control.- Parameters:
path
- the path to the sublibrary- Returns:
- true if successfully added
-
toString
Returns a string representation of this library. -
setName
Sets the name of this library.- Parameters:
name
- the name
-
getName
Gets the name of this library.- Returns:
- the name
-
save
Saves this library in an xml file.- Parameters:
path
- the path to the saved file
-
load
Loads this library from an xml file.- Parameters:
path
- the path to the file
-
getNames
Gets the names of all collections maintained by this library.- Returns:
- a collection of names
-
isEmpty
protected boolean isEmpty()Returns true if this library has no collections.- Returns:
- true if empty
-
containsPath
Returns true if this library contains a collection path.- Parameters:
path
- the collection pathallLists
- true to search in all collection lists- Returns:
- true if this contains the path
-
addCollection
Adds a collection to this library.- Parameters:
path
- the path to the collectionname
- the menu item name for the collection
-
renameCollection
Renames a collection.- Parameters:
path
- the path to the collectionnewName
- the new name
-
getAllPaths
Returns all collection paths in this Library and sub-libraries.- Returns:
- array of paths
-
getNameMap
Returns a Map of path-to-tabname.- Returns:
- path-to-name map
-
getCloneForExport
Gets a clone of this library that is suitable for exporting. The exported library has no OSP libraries, ComPADRE collections or imported libraries.- Returns:
- a Library for export
-
importLibrary
Imports a Library if not already imported.- Parameters:
path
- the path to the librarylibrary
- the library- Returns:
- true if imported
-
addRecent
Adds a path to the list of recently opened tabs.- Parameters:
filename
- the absolute path to a recently opened or saved file.atEnd
- true to add at end of the list
-
removeRecent
Removes a path from the list of recently opened tabs.- Parameters:
filename
- the path to remove.
-
getLoader
Returns an ObjectLoader to save and load data for this class.- Returns:
- the object loader
-