Gridarta Editor
net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Reference

Default FileControl implementation. More...

+ Inheritance diagram for net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
+ Collaboration diagram for net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:

Public Member Functions

boolean closeAllMaps ()
 Invoked when the user wants to close all maps. More...
 
boolean confirmSaveChanges (@NotNull final MapControl< G, A, R > mapControl)
 Asks the user whether to save changes of a map. More...
 
 DefaultFileControl (@NotNull final ProjectSettings projectSettings, @NotNull final VolatileSettings volatileSettings, @NotNull final MapImageCache< G, A, R > mapImageCache, @NotNull final MapManager< G, A, R > mapManager, @NotNull final MapViewsManager< G, A, R > mapViewsManager, @NotNull final Component parent, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final NewMapDialogFactory< G, A, R > newMapDialogFactory, @NotNull final String scriptExtension, @NotNull final ScriptEditControl scriptEditControl, @NotNull final PathManager pathManager)
 Creates a new instance. More...
 
void openFile (final boolean mapFile)
 The user wants to edit a file. More...
 
void reportLoadError (@Nullable final File file, @NotNull final String message)
 
void reportOutOfMapBoundsDeleted (@NotNull final File file, final int outOfMapBoundsDeleted, @NotNull final StringBuilder outOfMapBoundsObjects)
 
void reportOutOfMemory (@NotNull final File file)
 
void reportSaveError (@NotNull final MapControl< G, A, R > mapControl, @NotNull final String message)
 Reports an error while saving a map file to the user. More...
 
void reportSaveError (@NotNull final File mapFile, @NotNull final String message)
 Reports an error while saving a map file to the user. More...
 
void reportTeleportCharacterError (@NotNull final String mapPath, @NotNull final String message)
 Reports an error while teleporting a character to the current map. More...
 
boolean save (@NotNull final MapControl< G, A, R > mapControl)
 Save one map. More...
 
void saveAllMaps ()
 Saves all maps. More...
 
boolean saveAs (@NotNull final MapControl< G, A, R > mapControl)
 Asks the user for a filename, then saves the map. More...
 

Private Member Functions

JFileChooser createFileChooser ()
 Creates the JFileChooser for opening a file. More...
 
File saveMapAs (@NotNull final MapControl< G, A, R > mapControl)
 Displays a "save as" dialog. More...
 

Private Attributes

JFileChooser fileChooser
 The JFileChooser for opening a file. More...
 
final FileFilter mapFileFilter
 The FileFilter for selecting map files. More...
 
final MapImageCache< G, A, R > mapImageCache
 The MapImageCache. More...
 
final MapManager< G, A, R > mapManager
 The MapManager. More...
 
final MapViewsManager< G, A, R > mapViewsManager
 The MapViewsManager. More...
 
final NewMapDialogFactory< G, A, R > newMapDialogFactory
 The NewMapDialogFactory. More...
 
final Component parent
 The parent component for showing dialog boxes. More...
 
final PathManager pathManager
 The PathManager for creating MapFile instances. More...
 
final ProjectSettings projectSettings
 The ProjectSettings. More...
 
final ScriptEditControl scriptEditControl
 The ScriptEditControl to forward to. More...
 
final String scriptExtension
 The file extension for script files. More...
 
final FileFilter scriptFileFilter
 The FileFilter for selecting script files. More...
 
final VolatileSettings volatileSettings
 The VolatileSettings. More...
 

Static Private Attributes

static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
 The ActionBuilder. More...
 

Detailed Description

Default FileControl implementation.

Asks the user for directions.

Author
Andreas Kirschbaum

Definition at line 55 of file DefaultFileControl.java.

Constructor & Destructor Documentation

◆ DefaultFileControl()

net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.DefaultFileControl ( @NotNull final ProjectSettings  projectSettings,
@NotNull final VolatileSettings  volatileSettings,
@NotNull final MapImageCache< G, A, R >  mapImageCache,
@NotNull final MapManager< G, A, R >  mapManager,
@NotNull final MapViewsManager< G, A, R >  mapViewsManager,
@NotNull final Component  parent,
@NotNull final FileFilter  mapFileFilter,
@NotNull final FileFilter  scriptFileFilter,
@NotNull final NewMapDialogFactory< G, A, R >  newMapDialogFactory,
@NotNull final String  scriptExtension,
@NotNull final ScriptEditControl  scriptEditControl,
@NotNull final PathManager  pathManager 
)

Creates a new instance.

Parameters
projectSettingsthe project settings instance
volatileSettingsthe volatile settings instance
mapImageCachethe map image cache
mapManagerthe map manager
mapViewsManagerthe map views manager
parentthe parent component for showing dialog boxes
mapFileFilterthe file filter for selecting map files
scriptFileFilterthe file filter for selecting script files
newMapDialogFactorythe new map dialog factory
scriptExtensionthe file extension for script files
scriptEditControlthe script edit control to forward to
pathManagerthe path manager for creating map file instances

Definition at line 157 of file DefaultFileControl.java.

Member Function Documentation

◆ closeAllMaps()

boolean net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.closeAllMaps ( )

Invoked when the user wants to close all maps.

Returns
true
if all maps closed,
false
if user cancelled.

Implements net.sf.gridarta.model.mapmanager.FileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.

Definition at line 257 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.action.CloseAllMapsAction< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.closeAllMaps().

+ Here is the caller graph for this function:

◆ confirmSaveChanges()

boolean net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.confirmSaveChanges ( @NotNull final MapControl< G, A, R >  mapControl)

Asks the user whether to save changes of a map.

Returns

true

(and does not ask the user) if the map is unmodified.

Parameters
mapControlthe map
Returns
whether closing the map is allowed

Implements net.sf.gridarta.model.mapmanager.FileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.

Definition at line 333 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.closeAllMaps().

+ Here is the caller graph for this function:

◆ createFileChooser()

JFileChooser net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.createFileChooser ( )
private

Creates the JFileChooser for opening a file.

Returns
the new file chooser

Definition at line 177 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.openFile().

+ Here is the caller graph for this function:

◆ openFile()

◆ reportLoadError()

◆ reportOutOfMapBoundsDeleted()

void net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.reportOutOfMapBoundsDeleted ( @NotNull final File  file,
final int  outOfMapBoundsDeleted,
@NotNull final StringBuilder  outOfMapBoundsObjects 
)

◆ reportOutOfMemory()

◆ reportSaveError() [1/2]

void net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.reportSaveError ( @NotNull final MapControl< G, A, R >  mapControl,
@NotNull final String  message 
)

Reports an error while saving a map file to the user.

Parameters
mapControlthe map control that failed saving
messagethe error message

Implements net.sf.gridarta.model.mapmanager.FileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.

Definition at line 349 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.reportSaveError(), net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.save(), and net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.saveAs().

+ Here is the caller graph for this function:

◆ reportSaveError() [2/2]

void net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.reportSaveError ( @NotNull final File  mapFile,
@NotNull final String  message 
)

Reports an error while saving a map file to the user.

Parameters
mapFilethe map file that failed saving
messagethe error message

Implements net.sf.gridarta.model.mapmanager.FileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.

Definition at line 356 of file DefaultFileControl.java.

◆ reportTeleportCharacterError()

void net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.reportTeleportCharacterError ( @NotNull final String  mapPath,
@NotNull final String  message 
)

Reports an error while teleporting a character to the current map.

Parameters
mapPaththe map path to teleport to
messagethe error message

Implements net.sf.gridarta.model.mapmanager.FileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.

Definition at line 376 of file DefaultFileControl.java.

◆ save()

boolean net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.save ( @NotNull final MapControl< G, A, R >  mapControl)

◆ saveAllMaps()

◆ saveAs()

boolean net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.saveAs ( @NotNull final MapControl< G, A, R >  mapControl)

Asks the user for a filename, then saves the map.

Parameters
mapControlthe map
Returns
false
if the user cancelled the save or if saving failed,
true
otherwise

Implements net.sf.gridarta.model.mapmanager.FileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.

Definition at line 275 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.save().

+ Here is the caller graph for this function:

◆ saveMapAs()

File net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.saveMapAs ( @NotNull final MapControl< G, A, R >  mapControl)
private

Displays a "save as" dialog.

Parameters
mapControlthe map control for the dialog
Returns
the selected file or
null
if cancelled

Definition at line 297 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.saveAs().

+ Here is the caller graph for this function:

Member Data Documentation

◆ ACTION_BUILDER

final ActionBuilder net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
staticprivate

The ActionBuilder.

Definition at line 61 of file DefaultFileControl.java.

◆ fileChooser

JFileChooser net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.fileChooser
private

The JFileChooser for opening a file.

Set to

null

if not yet created.

Definition at line 140 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.openFile().

◆ mapFileFilter

final FileFilter net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapFileFilter
private

The FileFilter for selecting map files.

Definition at line 103 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.DefaultFileControl().

◆ mapImageCache

final MapImageCache<G, A, R> net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapImageCache
private

◆ mapManager

final MapManager<G, A, R> net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapManager
private

◆ mapViewsManager

final MapViewsManager<G, A, R> net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapViewsManager
private

◆ newMapDialogFactory

final NewMapDialogFactory<G, A, R> net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.newMapDialogFactory
private

◆ parent

final Component net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.parent
private

The parent component for showing dialog boxes.

Definition at line 97 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.DefaultFileControl().

◆ pathManager

final PathManager net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.pathManager
private

◆ projectSettings

final ProjectSettings net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.projectSettings
private

◆ scriptEditControl

final ScriptEditControl net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.scriptEditControl
private

◆ scriptExtension

final String net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.scriptExtension
private

The file extension for script files.

Definition at line 121 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.DefaultFileControl().

◆ scriptFileFilter

final FileFilter net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.scriptFileFilter
private

The FileFilter for selecting script files.

Definition at line 109 of file DefaultFileControl.java.

Referenced by net.sf.gridarta.gui.misc.DefaultFileControl< G, A, R >.DefaultFileControl().

◆ volatileSettings

final VolatileSettings net.sf.gridarta.gui.misc.DefaultFileControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.volatileSettings
private

The documentation for this class was generated from the following file: