![]() |
Gridarta Editor
|
Manages the contents of a recent or bookmark menu. More...
Classes | |
class | DeletedNode |
Result value consisting of a TreeNode and its location (directory). More... | |
Public Member Functions | |
TreePath | addMapMenuEntry (@NotNull final String directory, @NotNull final DefaultMutableTreeNode treeNode) |
Adds a DefaultMutableTreeNode to this menu. More... | |
void | addMapMenuEntry (@NotNull final String directory, @NotNull final MapMenuEntry mapMenuEntry) |
Adds a MapMenuEntry to this menu. More... | |
DeletedNode | getDeletedNode (final boolean delete) |
Returns the last deleted node. More... | |
DefaultMutableTreeNode | getOrCreateDirectory (@NotNull final MutableTreeNode this2, @NotNull final String path) |
Returns the MapMenuEntryDir for a given path. More... | |
DefaultMutableTreeNode | getRoot () |
Returns the root node. More... | |
TreePath | insertNodeInto (@NotNull final MapMenuEntry mapEntry, @NotNull final DefaultMutableTreeNode parent, final int index) |
Inserts a new node into the tree. More... | |
void | load () |
Loads the contents from preferences. More... | |
MapMenu (@NotNull final String key, @NotNull final PathManager pathManager) | |
Creates a new instance. More... | |
JTree | newTree () |
Creates a new JTree for this map menu. More... | |
void | removeNode (@NotNull final DefaultMutableTreeNode treeNode) |
Removes a node from the tree. More... | |
void | save () |
Saves the contents to preferences if modified since last save. More... | |
void | saveAlways () |
Saves the contents to preferences. More... | |
int | size () |
Returns the number of entries in this menu. More... | |
Private Member Functions | |
String | getDirectory (@NotNull final TreeNode treeNode) |
Returns the directory of a TreeNode. More... | |
int | saveEntries (@NotNull final DefaultMutableTreeNode treeNode, final int startIndex, @NotNull final String directory) |
Saves a TreeNode instance's contents to preferences. More... | |
int | size (@NotNull final TreeNode root) |
Returns the number of entries in a sub-tree. More... | |
Private Attributes | |
final Deque< DeletedNode > | deletedNodes = new ArrayDeque<>() |
Recently deleted nodes. More... | |
final MapMenuLoader | mapMenuLoader |
The MapMenuLoader for loading/storing the menu contents. More... | |
final DefaultMutableTreeNode | root = new DefaultMutableTreeNode(new MapMenuEntryDir("Bookmarks"), true) |
The root node of treeModel. More... | |
final DefaultTreeModel | treeModel = new DefaultTreeModel(root) |
The DefaultTreeModel that contains all menu entries. More... | |
final TreeModelListener | treeModelListener |
The TreeModelListener attached to treeModel for detecting modifications. More... | |
boolean | treeModelModified |
Whether treeModel has been modified since last save. More... | |
Static Private Attributes | |
static final Category | LOG = Logger.getLogger(MapMenu.class) |
The Logger for printing log messages. More... | |
Manages the contents of a recent or bookmark menu.
Definition at line 46 of file MapMenu.java.
net.sf.gridarta.gui.mapmenu.MapMenu.MapMenu | ( | @NotNull final String | key, |
@NotNull final PathManager | pathManager | ||
) |
Creates a new instance.
key | the preferences key prefix |
pathManager | the path manager instance |
Definition at line 117 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.LOG, net.sf.gridarta.gui.mapmenu.MapMenu.mapMenuLoader, net.sf.gridarta.gui.mapmenu.MapMenu.treeModel, and net.sf.gridarta.gui.mapmenu.MapMenu.treeModelListener.
TreePath net.sf.gridarta.gui.mapmenu.MapMenu.addMapMenuEntry | ( | @NotNull final String | directory, |
@NotNull final DefaultMutableTreeNode | treeNode | ||
) |
Adds a DefaultMutableTreeNode to this menu.
directory | the directory to add to |
treeNode | the tree node |
Definition at line 222 of file MapMenu.java.
References directory, net.sf.gridarta.gui.mapmenu.MapMenu.getOrCreateDirectory(), net.sf.gridarta.gui.mapmenu.MapMenu.LOG, net.sf.gridarta.utils.StringUtils.PATTERN_SLASH, net.sf.gridarta.gui.mapmenu.MapMenu.root, and net.sf.gridarta.gui.mapmenu.MapMenu.treeModel.
void net.sf.gridarta.gui.mapmenu.MapMenu.addMapMenuEntry | ( | @NotNull final String | directory, |
@NotNull final MapMenuEntry | mapMenuEntry | ||
) |
Adds a MapMenuEntry to this menu.
directory | the directory to add to |
mapMenuEntry | the map menu entry |
Definition at line 210 of file MapMenu.java.
References directory.
Referenced by net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.doUnDeleteBookmark(), net.sf.gridarta.gui.mapmenu.MapMenu.load(), and net.sf.gridarta.gui.mapmenu.MapMenuPreferencesTest.test3().
DeletedNode net.sf.gridarta.gui.mapmenu.MapMenu.getDeletedNode | ( | final boolean | delete | ) |
Returns the last deleted node.
delete | whether to delete the returned node |
Definition at line 342 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.deletedNodes.
Referenced by net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.doUnDeleteBookmark().
|
private |
Returns the directory of a TreeNode.
treeNode | the tree node |
Definition at line 319 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenuEntry.getTitle(), net.sf.gridarta.gui.mapmenu.MapMenuEntry.toString(), and net.sf.gridarta.gui.mapmenu.MapMenu.treeModel.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.removeNode().
DefaultMutableTreeNode net.sf.gridarta.gui.mapmenu.MapMenu.getOrCreateDirectory | ( | @NotNull final MutableTreeNode | this2, |
@NotNull final String | path | ||
) |
Returns the MapMenuEntryDir for a given path.
If more than one matching path exists the last one is returned.
this2 | the tree node to insert into |
path | the path; must not contain '/' |
Definition at line 245 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenuEntry.allowsChildren(), net.sf.gridarta.gui.mapmenu.MapMenuEntry.getTitle(), net.sf.gridarta.gui.mapmenu.MapMenuEntryDir.isValidDirectory(), net.sf.gridarta.gui.mapmenu.MapMenu.LOG, and net.sf.gridarta.gui.mapmenu.MapMenu.treeModel.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.addMapMenuEntry(), net.sf.gridarta.gui.mapmenu.MapMenuTest.testSubDir1(), and net.sf.gridarta.gui.mapmenu.MapMenuTest.testSubDir2().
DefaultMutableTreeNode net.sf.gridarta.gui.mapmenu.MapMenu.getRoot | ( | ) |
Returns the root node.
Definition at line 389 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.root.
Referenced by net.sf.gridarta.gui.mapmenu.TestMapMenuPreferences.addEntry(), net.sf.gridarta.gui.mapmenu.BookmarksMapMenuPreferences.addEntry(), net.sf.gridarta.gui.mapmenu.RecentMapMenuPreferences.addEntry(), net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.doEditBookmark(), net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.doNewDirectory(), net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.doRemoveBookmark(), net.sf.gridarta.gui.mapmenu.MapMenuPreferencesTest.test2(), net.sf.gridarta.gui.mapmenu.MapMenuPreferencesTest.test3(), net.sf.gridarta.gui.mapmenu.MapMenuTest.testSubDir1(), and net.sf.gridarta.gui.mapmenu.MapMenuTest.testSubDir2().
TreePath net.sf.gridarta.gui.mapmenu.MapMenu.insertNodeInto | ( | @NotNull final MapMenuEntry | mapEntry, |
@NotNull final DefaultMutableTreeNode | parent, | ||
final int | index | ||
) |
Inserts a new node into the tree.
mapEntry | the map entry to add |
parent | the parent node to add to |
index | the index to add at |
Definition at line 280 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.LOG, net.sf.gridarta.gui.mapmenu.MapMenu.save(), and net.sf.gridarta.gui.mapmenu.MapMenu.treeModel.
Referenced by net.sf.gridarta.gui.mapmenu.TestMapMenuPreferences.addEntry(), net.sf.gridarta.gui.mapmenu.BookmarksMapMenuPreferences.addEntry(), net.sf.gridarta.gui.mapmenu.RecentMapMenuPreferences.addEntry(), and net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.doNewDirectory().
void net.sf.gridarta.gui.mapmenu.MapMenu.load | ( | ) |
Loads the contents from preferences.
Definition at line 129 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.addMapMenuEntry(), net.sf.gridarta.gui.mapmenu.MapMenuLoader.Result.getDirectory(), net.sf.gridarta.gui.mapmenu.MapMenuLoader.Result.getMapMenuEntry(), net.sf.gridarta.gui.mapmenu.MapMenuLoader.loadEntry(), net.sf.gridarta.gui.mapmenu.MapMenuLoader.loadNumEntries(), net.sf.gridarta.gui.mapmenu.MapMenu.LOG, net.sf.gridarta.gui.mapmenu.MapMenu.mapMenuLoader, net.sf.gridarta.gui.mapmenu.MapMenu.root, and net.sf.gridarta.gui.mapmenu.MapMenu.treeModelModified.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenuManager< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.initRecent(), net.sf.gridarta.gui.mapmenu.MapMenuPreferencesTest.test2(), and net.sf.gridarta.gui.mapmenu.MapMenuPreferencesTest.test3().
JTree net.sf.gridarta.gui.mapmenu.MapMenu.newTree | ( | ) |
Creates a new JTree for this map menu.
Definition at line 380 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.treeModel.
Referenced by net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.ManageBookmarksDialog().
void net.sf.gridarta.gui.mapmenu.MapMenu.removeNode | ( | @NotNull final DefaultMutableTreeNode | treeNode | ) |
Removes a node from the tree.
treeNode | the tree node to remove |
Definition at line 294 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.deletedNodes, directory, net.sf.gridarta.gui.mapmenu.MapMenu.getDirectory(), net.sf.gridarta.gui.mapmenu.MapMenu.LOG, net.sf.gridarta.gui.mapmenu.MapMenu.root, net.sf.gridarta.gui.mapmenu.MapMenu.save(), and net.sf.gridarta.gui.mapmenu.MapMenu.treeModel.
Referenced by net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.doRemoveBookmark().
void net.sf.gridarta.gui.mapmenu.MapMenu.save | ( | ) |
Saves the contents to preferences if modified since last save.
Definition at line 151 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.saveAlways(), and net.sf.gridarta.gui.mapmenu.MapMenu.treeModelModified.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.insertNodeInto(), net.sf.gridarta.gui.mapmenu.MapMenu.removeNode(), and net.sf.gridarta.gui.dialog.bookmarks.ManageBookmarksDialog< G, A, R >.setValue().
void net.sf.gridarta.gui.mapmenu.MapMenu.saveAlways | ( | ) |
Saves the contents to preferences.
Definition at line 163 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenuLoader.loadNumEntries(), net.sf.gridarta.gui.mapmenu.MapMenu.mapMenuLoader, net.sf.gridarta.gui.mapmenu.MapMenuLoader.removeEntry(), net.sf.gridarta.gui.mapmenu.MapMenu.root, net.sf.gridarta.gui.mapmenu.MapMenu.saveEntries(), and net.sf.gridarta.gui.mapmenu.MapMenuLoader.saveNumEntries().
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.save(), net.sf.gridarta.gui.mapmenu.MapMenuPreferencesTest.test2(), and net.sf.gridarta.gui.mapmenu.MapMenuPreferencesTest.test3().
|
private |
Saves a TreeNode instance's contents to preferences.
treeNode | the tree node instance |
startIndex | the preference index for saving the first entry |
directory | the directory of the tree node |
Definition at line 179 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenuLoader.Type.DIR, directory, net.sf.gridarta.model.mapmodel.MapFile.getFile(), net.sf.gridarta.gui.mapmenu.MapMenuEntryMap.getMapFile(), net.sf.gridarta.gui.mapmenu.MapMenuEntry.getTitle(), net.sf.gridarta.gui.mapmenu.MapMenuLoader.Type.MAP, net.sf.gridarta.gui.mapmenu.MapMenu.mapMenuLoader, net.sf.gridarta.gui.mapmenu.MapMenuLoader.saveEntry(), net.sf.gridarta.gui.mapmenu.MapMenu.treeModel, and net.sf.gridarta.gui.mapmenu.MapMenuEntry.visit().
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.saveAlways().
int net.sf.gridarta.gui.mapmenu.MapMenu.size | ( | ) |
Returns the number of entries in this menu.
Definition at line 350 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenu.root.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.size(), net.sf.gridarta.gui.mapmenu.MapMenuPreferencesTest.test2(), and net.sf.gridarta.gui.mapmenu.MapMenuManagerTest.testSaveBookmarks().
|
private |
Returns the number of entries in a sub-tree.
root | the root of the sub-tree |
Definition at line 359 of file MapMenu.java.
References net.sf.gridarta.gui.mapmenu.MapMenuEntry.allowsChildren(), net.sf.gridarta.gui.mapmenu.MapMenu.LOG, net.sf.gridarta.gui.mapmenu.MapMenu.root, net.sf.gridarta.gui.mapmenu.MapMenu.size(), and net.sf.gridarta.gui.mapmenu.MapMenu.treeModel.
|
private |
Recently deleted nodes.
The first node is the last deleted node.
Definition at line 76 of file MapMenu.java.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.getDeletedNode(), and net.sf.gridarta.gui.mapmenu.MapMenu.removeNode().
|
staticprivate |
The Logger for printing log messages.
Definition at line 52 of file MapMenu.java.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.addMapMenuEntry(), net.sf.gridarta.gui.mapmenu.MapMenu.getOrCreateDirectory(), net.sf.gridarta.gui.mapmenu.MapMenu.insertNodeInto(), net.sf.gridarta.gui.mapmenu.MapMenu.load(), net.sf.gridarta.gui.mapmenu.MapMenu.MapMenu(), net.sf.gridarta.gui.mapmenu.MapMenu.removeNode(), and net.sf.gridarta.gui.mapmenu.MapMenu.size().
|
private |
The MapMenuLoader for loading/storing the menu contents.
Definition at line 58 of file MapMenu.java.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.load(), net.sf.gridarta.gui.mapmenu.MapMenu.MapMenu(), net.sf.gridarta.gui.mapmenu.MapMenu.saveAlways(), and net.sf.gridarta.gui.mapmenu.MapMenu.saveEntries().
|
private |
The root node of treeModel.
Definition at line 64 of file MapMenu.java.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.addMapMenuEntry(), net.sf.gridarta.gui.mapmenu.MapMenu.getRoot(), net.sf.gridarta.gui.mapmenu.MapMenu.load(), net.sf.gridarta.gui.mapmenu.MapMenu.removeNode(), net.sf.gridarta.gui.mapmenu.MapMenu.saveAlways(), and net.sf.gridarta.gui.mapmenu.MapMenu.size().
|
private |
The DefaultTreeModel that contains all menu entries.
Definition at line 70 of file MapMenu.java.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.addMapMenuEntry(), net.sf.gridarta.gui.mapmenu.MapMenu.getDirectory(), net.sf.gridarta.gui.mapmenu.MapMenu.getOrCreateDirectory(), net.sf.gridarta.gui.mapmenu.MapMenu.insertNodeInto(), net.sf.gridarta.gui.mapmenu.MapMenu.MapMenu(), net.sf.gridarta.gui.mapmenu.MapMenu.newTree(), net.sf.gridarta.gui.mapmenu.MapMenu.removeNode(), net.sf.gridarta.gui.mapmenu.MapMenu.saveEntries(), and net.sf.gridarta.gui.mapmenu.MapMenu.size().
|
private |
The TreeModelListener attached to treeModel for detecting modifications.
Definition at line 88 of file MapMenu.java.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.MapMenu().
|
private |
Whether treeModel has been modified since last save.
Definition at line 81 of file MapMenu.java.
Referenced by net.sf.gridarta.gui.mapmenu.MapMenu.load(), and net.sf.gridarta.gui.mapmenu.MapMenu.save().