dip.gui
Class PersistenceManager

java.lang.Object
  extended bydip.gui.PersistenceManager

public class PersistenceManager
extends java.lang.Object

Manages saving / opening of game files, and creation of new games, and exiting of the program.

Ensures user can save any changes (if changes were made) before committing to an action that cannot be undone.

Also sets the main frame title.


Constructor Summary
PersistenceManager(ClientFrame clientFrame)
          Creates a new PersistenceManager object.
 
Method Summary
 World acceptDrag(java.io.File selectedFile, World currentWorld)
          Given a file from a Drag operation, attempt to open it as a game file if it has an extension of SimpleFileFilter.SAVE_GAME_FILTER type.
 void close()
          Cleanup
 void exit()
          Exit from the program, after confirmation
 java.lang.ThreadGroup getPMThreadGroup()
          Threads added to this ThreadGroup will be joined() at exit (with a pre-defined timeout) such that they will complete before jDip exits.
 java.lang.String getSuggestedExportName()
          Gets a suggested export name.
 java.lang.String getSuggestedSaveName()
          Gets a suggested filename for a saved game.
 World importFloc()
          Imports a game from Floc.Net.
 World importJudge(java.io.File file, World currentWorld)
          Imports the given Judge file (no file requester dialog is displayed) Returns: null, if the current world has been updated, or a new world object
 World importJudge(World currentWorld)
          Lets the user choose the judge file to import
 boolean isChanged()
          If any change has occured singe the last time we saved.
 World newF2FGame()
          Creates a new game (Displays New Game dialog), after confirmation
 World newGame()
          Creates a new game (Displays New Game dialog), after confirmation
 World open()
          Opens a world, displaying a FileChooser dialog.
 World open(java.io.File file)
          Opens a World from the given File, after confirmation
 boolean save()
          Saves the current world, if changes have occured.
 boolean saveAs()
          Save As: Saves the world after requesting for the filename.
 void saveTo()
          Saves the current file to a new file, without changing the currently open file or current state.
 void updateTitle()
          Force an update of the game name / title bar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceManager

public PersistenceManager(ClientFrame clientFrame)
Creates a new PersistenceManager object.

Method Detail

close

public void close()
Cleanup


getPMThreadGroup

public java.lang.ThreadGroup getPMThreadGroup()
Threads added to this ThreadGroup will be joined() at exit (with a pre-defined timeout) such that they will complete before jDip exits.

This ensures that certain IO operations (e.g., Exports) will not be aborted at exit.


isChanged

public boolean isChanged()
If any change has occured singe the last time we saved.


updateTitle

public void updateTitle()
Force an update of the game name / title bar


exit

public void exit()
Exit from the program, after confirmation


open

public World open(java.io.File file)
Opens a World from the given File, after confirmation


open

public World open()
Opens a world, displaying a FileChooser dialog.
Returns null if no file is chosen, or an error occurs.


newGame

public World newGame()
Creates a new game (Displays New Game dialog), after confirmation


newF2FGame

public World newF2FGame()
Creates a new game (Displays New Game dialog), after confirmation


save

public boolean save()
Saves the current world, if changes have occured. Performs a 'Save As' if no file has been set. Returns 'true' if saved ok.


saveAs

public boolean saveAs()
Save As: Saves the world after requesting for the filename. Returns 'true' if saved ok.


saveTo

public void saveTo()
Saves the current file to a new file, without changing the currently open file or current state.


importJudge

public World importJudge(World currentWorld)
Lets the user choose the judge file to import


importJudge

public World importJudge(java.io.File file,
                         World currentWorld)
Imports the given Judge file (no file requester dialog is displayed) Returns: null, if the current world has been updated, or a new world object


importFloc

public World importFloc()
Imports a game from Floc.Net. User is prompted for required information.


acceptDrag

public World acceptDrag(java.io.File selectedFile,
                        World currentWorld)
Given a file from a Drag operation, attempt to open it as a game file if it has an extension of SimpleFileFilter.SAVE_GAME_FILTER type. Otherwise, attempt to import it.


getSuggestedSaveName

public java.lang.String getSuggestedSaveName()
Gets a suggested filename for a saved game. This will be:
GameName
VariantName [no GameName]
SaveFileName [if exists]
No extension is appended.
Assumes current World/TurnState are not null.


getSuggestedExportName

public java.lang.String getSuggestedExportName()
Gets a suggested export name. This will be: SaveFileName + Phase
GameName + Phase [if no save file name]
VariantName + Phase [if no gamename]
No extension is appended.
Assumes current World/TurnState are not null.



Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.