Class MapFolder<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>

  • All Implemented Interfaces:
    java.lang.Iterable<PickmapState<G,​A,​R>>

    public class MapFolder<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>
    extends java.lang.Object
    implements java.lang.Iterable<PickmapState<G,​A,​R>>
    Model class representing a folder of MapFiles. A folder has a name and a base directory. The name is a unique identifier in the model; the base directory is the directory where all contained pickmaps are stored.
    • Constructor Detail

      • MapFolder

        public MapFolder​(@Nullable
                         @Nullable MapFolder<G,​A,​R> parent,
                         @NotNull
                         @NotNull java.lang.String name,
                         @NotNull
                         @NotNull java.io.File baseDir,
                         @NotNull
                         @NotNull MapViewsManager<G,​A,​R> mapViewsManager)
                  throws InvalidNameException
        Creates a new instance.
        Parameters:
        parent - the parent folder, or null if it is a top-level folder
        name - the name
        baseDir - the base directory for folder file names
        mapViewsManager - the map views
        Throws:
        InvalidNameException - if name is not valid
    • Method Detail

      • getParent

        @Nullable
        public @Nullable MapFolder<G,​A,​R> getParent()
        Returns the parent folder.
        Returns:
        the parent folder, or null if this folder is a top-level folder
      • getName

        @NotNull
        public @NotNull java.lang.String getName()
        Returns the name.
        Returns:
        the name
      • getDir

        @NotNull
        public @NotNull java.io.File getDir()
        Returns the base directory.
        Returns:
        the base directory
      • addPickmap

        public PickmapState<G,​A,​R> addPickmap​(@NotNull
                                                          @NotNull java.lang.String name,
                                                          @NotNull
                                                          @NotNull MapReaderFactory<G,​A> mapReaderFactory,
                                                          @NotNull
                                                          @NotNull MapManager<G,​A,​R> pickmapManager)
                                                   throws InvalidNameException
        Adds a new PickmapState to this folder.
        Parameters:
        name - the map file name
        mapReaderFactory - the map reader factory instance
        pickmapManager - the map manager for loading pickmaps
        Returns:
        the newly created pickmap
        Throws:
        InvalidNameException - if the pickmap name is invalid
      • removePickmap

        public void removePickmap​(@NotNull
                                  @NotNull PickmapState<G,​A,​R> pickmapState,
                                  boolean deleteFile)
        Removes a PickmapState from this folder.
        Parameters:
        pickmapState - the pickmap to remove
        deleteFile - if set, also remove the map files
      • removeAllPickmaps

        public void removeAllPickmaps​(boolean deleteFile)
        Removes all PickmapState from this folder.
        Parameters:
        deleteFile - if set, also remove the map file
      • iterator

        public java.util.Iterator<PickmapState<G,​A,​R>> iterator()
        Returns an Iterator returning all pickmaps of this folder in arbitrary order.
        Specified by:
        iterator in interface java.lang.Iterable<G extends GameObject<G,​A,​R>>
        Returns:
        the iterator
      • getPickmaps

        public int getPickmaps()
        Returns the number of pickmaps in this folder.
        Returns:
        the number of pickmaps
      • addFolderListener

        public void addFolderListener​(@NotNull
                                      @NotNull MapFolderListener<G,​A,​R> listenerMap)
        Adds a MapFolderListener to be notified of events.
        Parameters:
        listenerMap - the listener to add
      • removeFolderListener

        public void removeFolderListener​(@NotNull
                                         @NotNull MapFolderListener<G,​A,​R> listenerMap)
        Removes a MapFolderListener to be notified of events.
        Parameters:
        listenerMap - the listener to remove
      • getUnsavedPickmaps

        public void getUnsavedPickmaps​(@NotNull
                                       @NotNull java.util.Collection<MapControl<G,​A,​R>> unsavedPickmaps)
        Returns all unsaved MapFiles in this folder.
        Parameters:
        unsavedPickmaps - the collection to add the unsaved pickmaps to
      • firePickmapReverted

        public void firePickmapReverted​(@NotNull
                                        @NotNull PickmapState<G,​A,​R> pickmapState,
                                        @NotNull
                                        @NotNull MapControl<G,​A,​R> oldPickmap)
        Notifies all listeners about a reverted pickmap.
        Parameters:
        pickmapState - the pickmap that was reverted
        oldPickmap - the map control of the pickmap before reverting