public class MapMenu
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MapMenu.DeletedNode
Result value consisting of a
TreeNode and its location
(directory). |
Constructor and Description |
---|
MapMenu(@NotNull java.lang.String key,
@NotNull PathManager pathManager)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
@NotNull javax.swing.tree.TreePath |
addMapMenuEntry(@NotNull java.lang.String directory,
@NotNull javax.swing.tree.DefaultMutableTreeNode treeNode)
Adds a
DefaultMutableTreeNode to this menu. |
void |
addMapMenuEntry(@NotNull java.lang.String directory,
@NotNull MapMenuEntry mapMenuEntry)
Adds a
MapMenuEntry to this menu. |
@Nullable MapMenu.DeletedNode |
getDeletedNode(boolean delete)
Returns the last deleted node.
|
@NotNull javax.swing.tree.DefaultMutableTreeNode |
getOrCreateDirectory(@NotNull javax.swing.tree.MutableTreeNode this2,
@NotNull java.lang.String path)
Returns the
MapMenuEntryDir for a given path. |
@NotNull javax.swing.tree.DefaultMutableTreeNode |
getRoot()
Returns the root node.
|
@NotNull javax.swing.tree.TreePath |
insertNodeInto(@NotNull MapMenuEntry mapEntry,
@NotNull javax.swing.tree.DefaultMutableTreeNode parent,
int index)
Inserts a new node into the tree.
|
void |
load()
Loads the contents from preferences.
|
@NotNull javax.swing.JTree |
newTree()
Creates a new
JTree for this map menu. |
void |
removeNode(@NotNull javax.swing.tree.DefaultMutableTreeNode treeNode)
Removes a node from the tree.
|
void |
save()
Saves the contents to preferences if modified since last save.
|
void |
saveAlways()
Saves the contents to preferences.
|
int |
size()
Returns the number of entries in this menu.
|
public MapMenu(@NotNull @NotNull java.lang.String key, @NotNull @NotNull PathManager pathManager)
key
- the preferences key prefixpathManager
- the path manager instancepublic void load()
public void save()
public void saveAlways()
public void addMapMenuEntry(@NotNull @NotNull java.lang.String directory, @NotNull @NotNull MapMenuEntry mapMenuEntry)
MapMenuEntry
to this menu.directory
- the directory to add tomapMenuEntry
- the map menu entry@NotNull public @NotNull javax.swing.tree.TreePath addMapMenuEntry(@NotNull @NotNull java.lang.String directory, @NotNull @NotNull javax.swing.tree.DefaultMutableTreeNode treeNode)
DefaultMutableTreeNode
to this menu.directory
- the directory to add totreeNode
- the tree node@NotNull public @NotNull javax.swing.tree.DefaultMutableTreeNode getOrCreateDirectory(@NotNull @NotNull javax.swing.tree.MutableTreeNode this2, @NotNull @NotNull java.lang.String path)
MapMenuEntryDir
for a given path. If more than one
matching path exists the last one is returned.this2
- the tree node to insert intopath
- the path; must not contain '/'@NotNull public @NotNull javax.swing.tree.TreePath insertNodeInto(@NotNull @NotNull MapMenuEntry mapEntry, @NotNull @NotNull javax.swing.tree.DefaultMutableTreeNode parent, int index)
mapEntry
- the map entry to addparent
- the parent node to add toindex
- the index to add atpublic void removeNode(@NotNull @NotNull javax.swing.tree.DefaultMutableTreeNode treeNode)
treeNode
- the tree node to remove@Nullable public @Nullable MapMenu.DeletedNode getDeletedNode(boolean delete)
delete
- whether to delete the returned nodenull
public int size()
@NotNull public @NotNull javax.swing.JTree newTree()
JTree
for this map menu.@NotNull public @NotNull javax.swing.tree.DefaultMutableTreeNode getRoot()