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>>
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 and Description |
---|
MapFolder(@Nullable MapFolder<G,A,R> parent,
@NotNull java.lang.String name,
@NotNull java.io.File baseDir,
@NotNull MapViewsManager<G,A,R> mapViewsManager)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addFolderListener(@NotNull MapFolderListener<G,A,R> listenerMap)
Adds a
MapFolderListener to be notified of events. |
PickmapState<G,A,R> |
addPickmap(@NotNull java.lang.String name,
@NotNull MapReaderFactory<G,A> mapReaderFactory,
@NotNull MapManager<G,A,R> pickmapManager)
Adds a new
PickmapState to this folder. |
void |
firePickmapReverted(@NotNull PickmapState<G,A,R> pickmapState,
@NotNull MapControl<G,A,R> oldPickmap)
Notifies all listeners about a reverted pickmap.
|
@NotNull java.io.File |
getDir()
Returns the base directory.
|
@NotNull java.lang.String |
getName()
Returns the name.
|
@Nullable MapFolder<G,A,R> |
getParent()
Returns the parent folder.
|
int |
getPickmaps()
Returns the number of pickmaps in this folder.
|
void |
getUnsavedPickmaps(@NotNull java.util.Collection<MapControl<G,A,R>> unsavedPickmaps)
Returns all unsaved
MapFiles in this folder. |
java.util.Iterator<PickmapState<G,A,R>> |
iterator()
Returns an
Iterator returning all pickmaps of this folder in
arbitrary order. |
void |
removeAllPickmaps(boolean deleteFile)
Removes all
PickmapState from this folder. |
void |
removeFolderListener(@NotNull MapFolderListener<G,A,R> listenerMap)
Removes a
MapFolderListener to be notified of events. |
void |
removePickmap(@NotNull PickmapState<G,A,R> pickmapState,
boolean deleteFile)
Removes a
PickmapState from this folder. |
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
parent
- the parent folder, or null
if it is a top-level
foldername
- the namebaseDir
- the base directory for folder file namesmapViewsManager
- the map viewsInvalidNameException
- if name
is not valid@Nullable public @Nullable MapFolder<G,A,R> getParent()
null
if this folder is a top-level
folder@NotNull public @NotNull java.lang.String getName()
@NotNull public @NotNull java.io.File getDir()
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
PickmapState
to this folder.name
- the map file namemapReaderFactory
- the map reader factory instancepickmapManager
- the map manager for loading pickmapsInvalidNameException
- if the pickmap name is invalidpublic void removePickmap(@NotNull @NotNull PickmapState<G,A,R> pickmapState, boolean deleteFile)
PickmapState
from this folder.pickmapState
- the pickmap to removedeleteFile
- if set, also remove the map filespublic void removeAllPickmaps(boolean deleteFile)
PickmapState
from this folder.deleteFile
- if set, also remove the map filepublic java.util.Iterator<PickmapState<G,A,R>> iterator()
Iterator
returning all pickmaps of this folder in
arbitrary order.iterator
in interface java.lang.Iterable<PickmapState<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>>
public int getPickmaps()
public void addFolderListener(@NotNull @NotNull MapFolderListener<G,A,R> listenerMap)
MapFolderListener
to be notified of events.listenerMap
- the listener to addpublic void removeFolderListener(@NotNull @NotNull MapFolderListener<G,A,R> listenerMap)
MapFolderListener
to be notified of events.listenerMap
- the listener to removepublic void getUnsavedPickmaps(@NotNull @NotNull java.util.Collection<MapControl<G,A,R>> unsavedPickmaps)
MapFiles
in this folder.unsavedPickmaps
- the collection to add the unsaved pickmaps topublic void firePickmapReverted(@NotNull @NotNull PickmapState<G,A,R> pickmapState, @NotNull @NotNull MapControl<G,A,R> oldPickmap)
pickmapState
- the pickmap that was revertedoldPickmap
- the map control of the pickmap before reverting