Package net.sf.gridarta.gui.mapfiles
Class MapFolder<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.gui.mapfiles.MapFolder<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 ofMapFiles. 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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFolderListener(@NotNull MapFolderListener<G,A,R> listenerMap)Adds aMapFolderListenerto 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 newPickmapStateto this folder.voidfirePickmapReverted(@NotNull PickmapState<G,A,R> pickmapState, @NotNull MapControl<G,A,R> oldPickmap)Notifies all listeners about a reverted pickmap.@NotNull java.io.FilegetDir()Returns the base directory.@NotNull java.lang.StringgetName()Returns the name.@Nullable MapFolder<G,A,R>getParent()Returns the parent folder.intgetPickmaps()Returns the number of pickmaps in this folder.voidgetUnsavedPickmaps(@NotNull java.util.Collection<MapControl<G,A,R>> unsavedPickmaps)Returns all unsavedMapFilesin this folder.java.util.Iterator<PickmapState<G,A,R>>iterator()Returns anIteratorreturning all pickmaps of this folder in arbitrary order.voidremoveAllPickmaps(boolean deleteFile)Removes allPickmapStatefrom this folder.voidremoveFolderListener(@NotNull MapFolderListener<G,A,R> listenerMap)Removes aMapFolderListenerto be notified of events.voidremovePickmap(@NotNull PickmapState<G,A,R> pickmapState, boolean deleteFile)Removes aPickmapStatefrom this folder.
-
-
-
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 InvalidNameExceptionCreates a new instance.- Parameters:
parent- the parent folder, ornullif it is a top-level foldername- the namebaseDir- the base directory for folder file namesmapViewsManager- the map views- Throws:
InvalidNameException- ifnameis not valid
-
-
Method Detail
-
getParent
@Nullable public @Nullable MapFolder<G,A,R> getParent()
Returns the parent folder.- Returns:
- the parent folder, or
nullif 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 newPickmapStateto this folder.- Parameters:
name- the map file namemapReaderFactory- the map reader factory instancepickmapManager- 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 aPickmapStatefrom this folder.- Parameters:
pickmapState- the pickmap to removedeleteFile- if set, also remove the map files
-
removeAllPickmaps
public void removeAllPickmaps(boolean deleteFile)
Removes allPickmapStatefrom this folder.- Parameters:
deleteFile- if set, also remove the map file
-
iterator
public java.util.Iterator<PickmapState<G,A,R>> iterator()
Returns anIteratorreturning all pickmaps of this folder in arbitrary order.- Specified by:
iteratorin interfacejava.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 aMapFolderListenerto be notified of events.- Parameters:
listenerMap- the listener to add
-
removeFolderListener
public void removeFolderListener(@NotNull @NotNull MapFolderListener<G,A,R> listenerMap)Removes aMapFolderListenerto 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 unsavedMapFilesin 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 revertedoldPickmap- the map control of the pickmap before reverting
-
-