Package net.sf.gridarta.gui.mapmenu
Class MapMenu
- java.lang.Object
-
- net.sf.gridarta.gui.mapmenu.MapMenu
-
public class MapMenu extends java.lang.ObjectManages the contents of a recent or bookmark menu.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMapMenu.DeletedNodeResult value consisting of aTreeNodeand its location (directory).
-
Constructor Summary
Constructors Constructor Description MapMenu(@NotNull java.lang.String key, @NotNull PathManager pathManager)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull javax.swing.tree.TreePathaddMapMenuEntry(@NotNull java.lang.String directory, @NotNull javax.swing.tree.DefaultMutableTreeNode treeNode)Adds aDefaultMutableTreeNodeto this menu.voidaddMapMenuEntry(@NotNull java.lang.String directory, @NotNull MapMenuEntry mapMenuEntry)Adds aMapMenuEntryto this menu.@Nullable MapMenu.DeletedNodegetDeletedNode(boolean delete)Returns the last deleted node.@NotNull javax.swing.tree.DefaultMutableTreeNodegetOrCreateDirectory(@NotNull javax.swing.tree.MutableTreeNode this2, @NotNull java.lang.String path)Returns theMapMenuEntryDirfor a given path.@NotNull javax.swing.tree.DefaultMutableTreeNodegetRoot()Returns the root node.@NotNull javax.swing.tree.TreePathinsertNodeInto(@NotNull MapMenuEntry mapEntry, @NotNull javax.swing.tree.DefaultMutableTreeNode parent, int index)Inserts a new node into the tree.voidload()Loads the contents from preferences.@NotNull javax.swing.JTreenewTree()Creates a newJTreefor this map menu.voidremoveNode(@NotNull javax.swing.tree.DefaultMutableTreeNode treeNode)Removes a node from the tree.voidsave()Saves the contents to preferences if modified since last save.voidsaveAlways()Saves the contents to preferences.intsize()Returns the number of entries in this menu.
-
-
-
Constructor Detail
-
MapMenu
public MapMenu(@NotNull @NotNull java.lang.String key, @NotNull @NotNull PathManager pathManager)Creates a new instance.- Parameters:
key- the preferences key prefixpathManager- the path manager instance
-
-
Method Detail
-
load
public void load()
Loads the contents from preferences.
-
save
public void save()
Saves the contents to preferences if modified since last save.
-
saveAlways
public void saveAlways()
Saves the contents to preferences.
-
addMapMenuEntry
public void addMapMenuEntry(@NotNull @NotNull java.lang.String directory, @NotNull @NotNull MapMenuEntry mapMenuEntry)Adds aMapMenuEntryto this menu.- Parameters:
directory- the directory to add tomapMenuEntry- the map menu entry
-
addMapMenuEntry
@NotNull public @NotNull javax.swing.tree.TreePath addMapMenuEntry(@NotNull @NotNull java.lang.String directory, @NotNull @NotNull javax.swing.tree.DefaultMutableTreeNode treeNode)Adds aDefaultMutableTreeNodeto this menu.- Parameters:
directory- the directory to add totreeNode- the tree node- Returns:
- the tree path for the inserted node
-
getOrCreateDirectory
@NotNull public @NotNull javax.swing.tree.DefaultMutableTreeNode getOrCreateDirectory(@NotNull @NotNull javax.swing.tree.MutableTreeNode this2, @NotNull @NotNull java.lang.String path)Returns theMapMenuEntryDirfor a given path. If more than one matching path exists the last one is returned.- Parameters:
this2- the tree node to insert intopath- the path; must not contain '/'- Returns:
- the entry
-
insertNodeInto
@NotNull public @NotNull javax.swing.tree.TreePath insertNodeInto(@NotNull @NotNull MapMenuEntry mapEntry, @NotNull @NotNull javax.swing.tree.DefaultMutableTreeNode parent, int index)Inserts a new node into the tree.- Parameters:
mapEntry- the map entry to addparent- the parent node to add toindex- the index to add at- Returns:
- the tree path for the inserted node
-
removeNode
public void removeNode(@NotNull @NotNull javax.swing.tree.DefaultMutableTreeNode treeNode)Removes a node from the tree.- Parameters:
treeNode- the tree node to remove
-
getDeletedNode
@Nullable public @Nullable MapMenu.DeletedNode getDeletedNode(boolean delete)
Returns the last deleted node.- Parameters:
delete- whether to delete the returned node- Returns:
- the deleted node or
null
-
size
public int size()
Returns the number of entries in this menu.- Returns:
- the number of entries
-
newTree
@NotNull public @NotNull javax.swing.JTree newTree()
Creates a newJTreefor this map menu.- Returns:
- the tree
-
getRoot
@NotNull public @NotNull javax.swing.tree.DefaultMutableTreeNode getRoot()
Returns the root node.- Returns:
- the root node
-
-