Package net.sf.gridarta.gui.misc
Class DefaultFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.gui.misc.DefaultFileControl<G,A,R>
-
- All Implemented Interfaces:
FileControl<G,A,R>
public class DefaultFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements FileControl<G,A,R>
DefaultFileControlimplementation. Asks the user for directions.
-
-
Constructor Summary
Constructors Constructor Description DefaultFileControl(@NotNull ProjectSettings projectSettings, @NotNull VolatileSettings volatileSettings, @NotNull MapImageCache<G,A,R> mapImageCache, @NotNull MapManager<G,A,R> mapManager, @NotNull MapViewsManager<G,A,R> mapViewsManager, @NotNull java.awt.Component parent, @NotNull javax.swing.filechooser.FileFilter mapFileFilter, @NotNull javax.swing.filechooser.FileFilter scriptFileFilter, @NotNull NewMapDialogFactory<G,A,R> newMapDialogFactory, @NotNull java.lang.String scriptExtension, @NotNull ScriptEditControl scriptEditControl, @NotNull PathManager pathManager)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancloseAllMaps()Invoked when the user wants to close all maps.booleanconfirmSaveChanges(@NotNull MapControl<G,A,R> mapControl)Asks the user whether to save changes of a map.voidopenFile(boolean mapFile)The user wants to edit a file.voidreportLoadError(@Nullable java.io.File file, @NotNull java.lang.String message)voidreportOutOfMapBoundsDeleted(@NotNull java.io.File file, int outOfMapBoundsDeleted, @NotNull java.lang.StringBuilder outOfMapBoundsObjects)voidreportOutOfMemory(@NotNull java.io.File file)voidreportSaveError(@NotNull java.io.File mapFile, @NotNull java.lang.String message)Reports an error while saving a map file to the user.voidreportSaveError(@NotNull MapControl<G,A,R> mapControl, @NotNull java.lang.String message)Reports an error while saving a map file to the user.voidreportTeleportCharacterError(@NotNull java.lang.String mapPath, @NotNull java.lang.String message)Reports an error while teleporting a character to the current map.booleansave(@NotNull MapControl<G,A,R> mapControl)Save one map.voidsaveAllMaps()Saves all maps.booleansaveAs(@NotNull MapControl<G,A,R> mapControl)Asks the user for a filename, then saves the map.
-
-
-
Constructor Detail
-
DefaultFileControl
public DefaultFileControl(@NotNull @NotNull ProjectSettings projectSettings, @NotNull @NotNull VolatileSettings volatileSettings, @NotNull @NotNull MapImageCache<G,A,R> mapImageCache, @NotNull @NotNull MapManager<G,A,R> mapManager, @NotNull @NotNull MapViewsManager<G,A,R> mapViewsManager, @NotNull @NotNull java.awt.Component parent, @NotNull @NotNull javax.swing.filechooser.FileFilter mapFileFilter, @NotNull @NotNull javax.swing.filechooser.FileFilter scriptFileFilter, @NotNull @NotNull NewMapDialogFactory<G,A,R> newMapDialogFactory, @NotNull @NotNull java.lang.String scriptExtension, @NotNull @NotNull ScriptEditControl scriptEditControl, @NotNull @NotNull PathManager pathManager)Creates a new instance.- Parameters:
projectSettings- the project settings instancevolatileSettings- the volatile settings instancemapImageCache- the map image cachemapManager- the map managermapViewsManager- the map views managerparent- the parent component for showing dialog boxesmapFileFilter- the file filter for selecting map filesscriptFileFilter- the file filter for selecting script filesnewMapDialogFactory- the new map dialog factoryscriptExtension- the file extension for script filesscriptEditControl- the script edit control to forward topathManager- the path manager for creating map file instances
-
-
Method Detail
-
openFile
public void openFile(boolean mapFile)
Description copied from interface:FileControlThe user wants to edit a file.- Specified by:
openFilein interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapFile-truefor map files,falsefor script files
-
save
public boolean save(@NotNull @NotNull MapControl<G,A,R> mapControl)Description copied from interface:FileControlSave one map.- Specified by:
savein interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapControl- the map- Returns:
falseif saving failed,trueotherwise
-
saveAllMaps
public void saveAllMaps()
Description copied from interface:FileControlSaves all maps.- Specified by:
saveAllMapsin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
closeAllMaps
public boolean closeAllMaps()
Description copied from interface:FileControlInvoked when the user wants to close all maps.- Specified by:
closeAllMapsin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
trueif all maps closed,falseif user cancelled.
-
saveAs
public boolean saveAs(@NotNull @NotNull MapControl<G,A,R> mapControl)Description copied from interface:FileControlAsks the user for a filename, then saves the map.- Specified by:
saveAsin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapControl- the map- Returns:
falseif the user cancelled the save or if saving failed,trueotherwise
-
confirmSaveChanges
public boolean confirmSaveChanges(@NotNull @NotNull MapControl<G,A,R> mapControl)Description copied from interface:FileControlAsks the user whether to save changes of a map. Returnstrue(and does not ask the user) if the map is unmodified.- Specified by:
confirmSaveChangesin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapControl- the map- Returns:
- whether closing the map is allowed
-
reportSaveError
public void reportSaveError(@NotNull @NotNull MapControl<G,A,R> mapControl, @NotNull @NotNull java.lang.String message)Description copied from interface:FileControlReports an error while saving a map file to the user.- Specified by:
reportSaveErrorin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapControl- the map control that failed savingmessage- the error message
-
reportSaveError
public void reportSaveError(@NotNull @NotNull java.io.File mapFile, @NotNull @NotNull java.lang.String message)Description copied from interface:FileControlReports an error while saving a map file to the user.- Specified by:
reportSaveErrorin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapFile- the map file that failed savingmessage- the error message
-
reportLoadError
public void reportLoadError(@Nullable @Nullable java.io.File file, @NotNull @NotNull java.lang.String message)- Specified by:
reportLoadErrorin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
reportOutOfMapBoundsDeleted
public void reportOutOfMapBoundsDeleted(@NotNull @NotNull java.io.File file, int outOfMapBoundsDeleted, @NotNull @NotNull java.lang.StringBuilder outOfMapBoundsObjects)- Specified by:
reportOutOfMapBoundsDeletedin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
reportOutOfMemory
public void reportOutOfMemory(@NotNull @NotNull java.io.File file)- Specified by:
reportOutOfMemoryin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
reportTeleportCharacterError
public void reportTeleportCharacterError(@NotNull @NotNull java.lang.String mapPath, @NotNull @NotNull java.lang.String message)Description copied from interface:FileControlReports an error while teleporting a character to the current map.- Specified by:
reportTeleportCharacterErrorin interfaceFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapPath- the map path to teleport tomessage- the error message
-
-