org.das2.util
Class PersistentStateSupport

java.lang.Object
  extended by org.das2.util.PersistentStateSupport

public class PersistentStateSupport
extends java.lang.Object


Nested Class Summary
static interface PersistentStateSupport.SerializationStrategy
           
 
Field Summary
static java.lang.String PROPERTY_CURRENT_FILE
           
static java.lang.String PROPERTY_DIRTY
           
static java.lang.String PROPERTY_OPENING
           
static java.lang.String PROPERTY_SAVING
           
 
Constructor Summary
PersistentStateSupport()
          Creates a new instance of PersistentStateSupport
PersistentStateSupport(java.awt.Component parent, PersistentStateSupport.SerializationStrategy strategy, java.lang.String extension)
           
PersistentStateSupport(DasCanvas canvas, java.lang.String extension)
          Provides a means for saving the application persistently, undo/redo support (TODO).
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a PropertyChangeListener to the listener list.
 void close()
           
 javax.swing.JLabel createCurrentFileLabel()
           
 javax.swing.Action createOpenAction()
           
 javax.swing.JMenu createOpenRecentMenu()
           
 javax.swing.Action createQuitAction()
          In the future, this should prompt for save if the app is dirty.
 javax.swing.Action createSaveAction()
           
 javax.swing.Action createSaveAsAction()
           
 javax.swing.JMenuItem createSaveMenuItem()
           
 java.io.File getCurrentFile()
           
 boolean isCurrentFileOpened()
          Property currentFileOpened indicates if the current file has ever been opened.
 boolean isDirty()
          Getter for property dirty.
 boolean isOpening()
          Property loading is true when a load operation is being performed.
 boolean isSaving()
          Property saving is true when a save operation is being performed.
 void markDirty()
           
protected  void openImpl(java.io.File file)
          override me.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a PropertyChangeListener from the listener list.
 void saveAs()
           
protected  void saveImpl(java.io.File f)
          override me
 void setCurrentFile(java.io.File currentFile)
           
 void setCurrentFileOpened(boolean currentFileOpened)
          Setter for property currentFileOpened.
 void setDirty(boolean dirty)
          Setter for property dirty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_OPENING

public static final java.lang.String PROPERTY_OPENING
See Also:
Constant Field Values

PROPERTY_SAVING

public static final java.lang.String PROPERTY_SAVING
See Also:
Constant Field Values

PROPERTY_DIRTY

public static final java.lang.String PROPERTY_DIRTY
See Also:
Constant Field Values

PROPERTY_CURRENT_FILE

public static final java.lang.String PROPERTY_CURRENT_FILE
See Also:
Constant Field Values
Constructor Detail

PersistentStateSupport

public PersistentStateSupport(DasCanvas canvas,
                              java.lang.String extension)
Provides a means for saving the application persistently, undo/redo support (TODO). canvas is the canvas to be serialized, extension identifies the application. Note that internal changes to das may break saved files.


PersistentStateSupport

public PersistentStateSupport(java.awt.Component parent,
                              PersistentStateSupport.SerializationStrategy strategy,
                              java.lang.String extension)

PersistentStateSupport

public PersistentStateSupport()
Creates a new instance of PersistentStateSupport

Method Detail

createSaveAsAction

public javax.swing.Action createSaveAsAction()

saveAs

public void saveAs()

saveImpl

protected void saveImpl(java.io.File f)
                 throws java.lang.Exception
override me

Throws:
java.lang.Exception

createSaveAction

public javax.swing.Action createSaveAction()

createQuitAction

public javax.swing.Action createQuitAction()
In the future, this should prompt for save if the app is dirty.


createSaveMenuItem

public javax.swing.JMenuItem createSaveMenuItem()

createOpenRecentMenu

public javax.swing.JMenu createOpenRecentMenu()

createCurrentFileLabel

public javax.swing.JLabel createCurrentFileLabel()

createOpenAction

public javax.swing.Action createOpenAction()

openImpl

protected void openImpl(java.io.File file)
                 throws java.lang.Exception
override me. If open fails, throw an exception.

Throws:
java.lang.Exception

close

public void close()

markDirty

public void markDirty()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener to the listener list.

Parameters:
l - The listener to add.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener from the listener list.

Parameters:
l - The listener to remove.

isDirty

public boolean isDirty()
Getter for property dirty.

Returns:
Value of property dirty.

setDirty

public void setDirty(boolean dirty)
Setter for property dirty.

Parameters:
dirty - New value of property dirty.

getCurrentFile

public java.io.File getCurrentFile()

setCurrentFile

public void setCurrentFile(java.io.File currentFile)

isOpening

public boolean isOpening()
Property loading is true when a load operation is being performed.

Returns:
Value of property loading.

isSaving

public boolean isSaving()
Property saving is true when a save operation is being performed.

Returns:
Value of property saving.

isCurrentFileOpened

public boolean isCurrentFileOpened()
Property currentFileOpened indicates if the current file has ever been opened. This is to handle the initial state where the current file is set, but should not be displayed because it has not been opened.

Returns:
Value of property currentFileOpened.

setCurrentFileOpened

public void setCurrentFileOpened(boolean currentFileOpened)
Setter for property currentFileOpened.

Parameters:
currentFileOpened - New value of property currentFileOpened.