Class MapMenu


  • public class MapMenu
    extends java.lang.Object
    Manages the contents of a recent or bookmark menu.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  MapMenu.DeletedNode
      Result value consisting of a TreeNode and 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.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MapMenu

        public MapMenu​(@NotNull
                       @NotNull java.lang.String key,
                       @NotNull
                       @NotNull PathManager pathManager)
        Creates a new instance.
        Parameters:
        key - the preferences key prefix
        pathManager - 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 a MapMenuEntry to this menu.
        Parameters:
        directory - the directory to add to
        mapMenuEntry - 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 a DefaultMutableTreeNode to this menu.
        Parameters:
        directory - the directory to add to
        treeNode - 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 the MapMenuEntryDir for a given path. If more than one matching path exists the last one is returned.
        Parameters:
        this2 - the tree node to insert into
        path - 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 add
        parent - the parent node to add to
        index - 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 new JTree for this map menu.
        Returns:
        the tree
      • getRoot

        @NotNull
        public @NotNull javax.swing.tree.DefaultMutableTreeNode getRoot()
        Returns the root node.
        Returns:
        the root node