|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.event.WindowAdapter
zinger.bsheet.PersistenceManager
public class PersistenceManager
Persistence manager for a single table model.
Field Summary | |
---|---|
protected java.io.File |
dataFile
File the model currently persists to. |
protected boolean |
documentChanged
|
protected static java.util.Set |
instances
|
protected java.util.Set |
listeners
|
protected java.util.Map<javax.swing.filechooser.FileFilter,Persistence> |
persistenceMap
|
protected javax.swing.JTable |
table
|
Constructor Summary | |
---|---|
PersistenceManager(javax.swing.JTable table)
|
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent ev)
Handles menu item events. |
void |
addPersistence(Persistence persistence)
|
void |
addPersistenceListener(PersistenceListener listener)
|
static void |
closeAll()
Steps through all instances and calls saveOnClose() on each. |
protected static void |
disposed(PersistenceManager impexp)
Removes specified instance from non-disposed instance set. |
protected void |
disposeWindow()
Convenience method for finding the window component containing the table and disposing of that window. |
protected boolean |
doLoad(Persistence persistence)
Attempts to load specified data file. |
protected Persistence |
findPersistenceForFile(java.io.File file)
|
protected void |
fireEvent(PersistenceEvent ev)
|
protected Persistence |
getChosenPersistence()
|
protected javax.swing.JFileChooser |
getFileChooser()
|
protected boolean |
load()
Loads table model data from a picked file. |
boolean |
load(java.io.File dataFile)
|
protected int |
needsSave()
Determines if the data needs to be saved. |
protected static void |
opened(PersistenceManager impexp)
Adds specified instance to the non-disposed instance set. |
void |
removePersistence(Persistence persistence)
|
void |
removePersistenceListener(PersistenceListener listener)
|
protected boolean |
save()
Persists table model data into a picked file. |
void |
saveOnClose()
Determines if the data needs to be saved and saves it if it does. |
void |
tableChanged(javax.swing.event.TableModelEvent ev)
|
protected void |
updateFrameTitle()
Sets the title of the frame that contains the table to the name of the persistence file. |
void |
windowClosing(java.awt.event.WindowEvent ev)
Handles window closing events. |
Methods inherited from class java.awt.event.WindowAdapter |
---|
windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.util.Set instances
protected final javax.swing.JTable table
protected final java.util.Map<javax.swing.filechooser.FileFilter,Persistence> persistenceMap
protected java.io.File dataFile
null
, a file must be chosen or created prior to saving.
protected final java.util.Set listeners
protected boolean documentChanged
Constructor Detail |
---|
public PersistenceManager(javax.swing.JTable table)
Method Detail |
---|
public void actionPerformed(java.awt.event.ActionEvent ev)
actionPerformed
in interface java.awt.event.ActionListener
public void tableChanged(javax.swing.event.TableModelEvent ev)
tableChanged
in interface javax.swing.event.TableModelListener
protected void updateFrameTitle()
protected Persistence getChosenPersistence()
protected Persistence findPersistenceForFile(java.io.File file)
protected boolean load()
load(File)
.
Persistence.load(javax.swing.JTable, java.io.File)
protected boolean doLoad(Persistence persistence)
findPersistenceForFile(java.io.File)
.
public boolean load(java.io.File dataFile)
protected boolean save()
save(File)
.
Persistence.save(javax.swing.JTable, java.io.File)
protected int needsSave()
public void windowClosing(java.awt.event.WindowEvent ev)
windowClosing
in interface java.awt.event.WindowListener
windowClosing
in class java.awt.event.WindowAdapter
public void saveOnClose()
needsSave()
,
save()
public static void closeAll()
saveOnClose()
on each.
protected void disposeWindow()
saveOnClose()
protected static void disposed(PersistenceManager impexp)
System.exit(0)
is called.
opened(zinger.bsheet.PersistenceManager)
protected static void opened(PersistenceManager impexp)
disposed(zinger.bsheet.PersistenceManager)
protected javax.swing.JFileChooser getFileChooser()
public void addPersistence(Persistence persistence)
public void removePersistence(Persistence persistence)
public void addPersistenceListener(PersistenceListener listener)
public void removePersistenceListener(PersistenceListener listener)
protected void fireEvent(PersistenceEvent ev)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |