com.fullspan.pwkeep
Interface IPwkAppState

All Known Implementing Classes:
PwkApp

public interface IPwkAppState

Represents the current state of the PWKeep application. Currently, there is a one-to-one relationship between the application, the user interface, and the current file. That is, it is not possible to have more than one main window or more than one file open in the same application instance. To open multiple windows/files, you need to run multiple instances of the application.

The reason for this interface is so that lower-level components (such as the user interface) can have access to application-wide state without having direct access to the implementation.

Version:
$Revision: 1.3 $, $Date: 2004/01/15 08:13:28 $
Author:
Mitch Stuart, $Author: mitch $

Field Summary
static int LOAD_FILE_STATUS_BAD_PASSPHRASE
           
static int LOAD_FILE_STATUS_OK
           
static int SAVE_FILE_STATUS_FILE_EXISTS
           
static int SAVE_FILE_STATUS_NEED_FILENAME
           
static int SAVE_FILE_STATUS_NEED_PASSPHRASE
           
static int SAVE_FILE_STATUS_OK
           
 
Method Summary
 void exit()
          Exits the application.
 java.io.File getFile()
           
 boolean getIsFileModified()
           
 boolean getIsPassphraseSet()
           
 com.fullspan.util.swing.TreeNodeListModel getListModel()
           
 PwkModel getModel()
           
 PwkTreeModel getTreeModel()
           
 int loadFile(java.io.File file, java.lang.String passphrase)
          Loads a file.
 void newFile()
           
 int saveFile()
          Saves the current file.
 int saveFileAs(java.io.File file, boolean okToOverwrite)
          Saves the current file under a new name (or for the first time)
 void setIsFileModified(boolean isFileModified)
          The user interface should call this with true when the file has been modified
 void setPassphrase(java.lang.String passphrase)
          Set the passphrase for the current file.
 boolean validatePassphrase(java.lang.String passphrase)
          Validate the passphrase for the current file.
 

Field Detail

LOAD_FILE_STATUS_OK

static final int LOAD_FILE_STATUS_OK
See Also:
Constant Field Values

LOAD_FILE_STATUS_BAD_PASSPHRASE

static final int LOAD_FILE_STATUS_BAD_PASSPHRASE
See Also:
Constant Field Values

SAVE_FILE_STATUS_OK

static final int SAVE_FILE_STATUS_OK
See Also:
Constant Field Values

SAVE_FILE_STATUS_NEED_PASSPHRASE

static final int SAVE_FILE_STATUS_NEED_PASSPHRASE
See Also:
Constant Field Values

SAVE_FILE_STATUS_NEED_FILENAME

static final int SAVE_FILE_STATUS_NEED_FILENAME
See Also:
Constant Field Values

SAVE_FILE_STATUS_FILE_EXISTS

static final int SAVE_FILE_STATUS_FILE_EXISTS
See Also:
Constant Field Values
Method Detail

exit

void exit()
Exits the application. Prior to calling this method, the user interface should check if the current file is modified and prompt the user to save it.

This method saves the current option settings before exiting.


getFile

java.io.File getFile()
Returns:
the current file, or null if the current data has not been saved to a file yet

getIsFileModified

boolean getIsFileModified()
Returns:
true if the current file has been modified since the last save

getIsPassphraseSet

boolean getIsPassphraseSet()

getListModel

com.fullspan.util.swing.TreeNodeListModel getListModel()

getModel

PwkModel getModel()

getTreeModel

PwkTreeModel getTreeModel()

loadFile

int loadFile(java.io.File file,
             java.lang.String passphrase)
             throws PwkException
Loads a file.

Parameters:
file - the file to load
passphrase - the user-supplied passphrase for the file
Returns:
one of the IPwkAppState.LOAD_FILE_STATUS_* constants
Throws:
PwkException

newFile

void newFile()

saveFile

int saveFile()
             throws PwkException
Saves the current file.

Returns:
one of the IPwkAppState.SAVE_FILE_STATUS_* constants
Throws:
PwkException

saveFileAs

int saveFileAs(java.io.File file,
               boolean okToOverwrite)
               throws PwkException
Saves the current file under a new name (or for the first time)

Parameters:
file -
okToOverwrite - true if it's OK to overwrite the file if it already exists; false to return SAVE_FILE_STATUS_FILE_EXISTS if it already exists
Returns:
one of the IPwkAppState.SAVE_FILE_STATUS_* constants
Throws:
PwkException

setIsFileModified

void setIsFileModified(boolean isFileModified)
The user interface should call this with true when the file has been modified

Parameters:
isFileModified - true if the file has been modified (if the user has made a change)

setPassphrase

void setPassphrase(java.lang.String passphrase)
Set the passphrase for the current file.

Parameters:
passphrase -

validatePassphrase

boolean validatePassphrase(java.lang.String passphrase)
Validate the passphrase for the current file.

Parameters:
passphrase -
Returns:
true if the passphrase matches the passphrase for the current file
Throws:
java.lang.IllegalStateException - if no passphrase has yet been set for the current file