Package jaxx.runtime.swing.session
Class SwingSession
java.lang.Object
jaxx.runtime.swing.session.SwingSession
public class SwingSession
extends java.lang.Object
Use to store and restore position and size of application. Default supported widgets are:
- java.awt.Window (and subclasses)
- javax.swing.JTabbedPane (and subclasses)
- javax.swing.JSplitPane (and subclasses)
- org.jdesktop.swingx.JXTable (and subclasses)
- javax.swing.JTable (and subclasses)
- create SwingSession object
- add component that you want save
- explicite call to save
- Since:
- 2.5.16
- Author:
- poussin, kmorin
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSwingSession.Actionstatic classSwingSession.RestoreStateActionstatic classSwingSession.SaveStateAction -
Field Summary
Fields Modifier and Type Field Description protected booleanautoSaveprotected java.io.Filefileprotected java.util.Set<java.awt.Component>registeredComponentprotected java.util.Map<java.lang.Class,State>stateManagerState object registered to get and set State.protected java.util.Map<java.lang.String,State>statesstate of all component added with add method. -
Constructor Summary
Constructors Constructor Description SwingSession(java.io.File file, boolean autoSave)SwingSession(java.io.File file, boolean autoSave, java.util.Map<java.lang.Class,State> additionalStates) -
Method Summary
Modifier and Type Method Description voidadd(java.awt.Component c)voidadd(java.awt.Component c, boolean replace)voidaddToStateManager(java.lang.Class component, State state)protected voidfinalize()protected java.lang.StringgetComponentName(java.awt.Component c)java.io.FilegetFile()StategetStateManager(java.lang.Class clazz)StategetStates(java.lang.String path)voidloadSafeStates()Loads safely the states from thefile.java.util.Map<java.lang.String,State>loadStates(java.io.File file)Loads the states from the filestatic SwingSessionnewSession(java.io.File file, boolean autoSave)Deprecated.since 2.10, the default behaviour is now to safely load the incoming filestatic SwingSessionnewSession(java.io.File file, boolean autoSave, java.util.Map<java.lang.Class,State> additionalStates)Deprecated.since 2.10, the default behaviour is now to safely load the incoming filevoidremove(java.awt.Component c)Remove component from component to savevoidsave()voidsetFile(java.io.File file)voidsetStates(java.lang.String path, State state)voidupdateState()protected voidwalkThroughComponent(java.lang.String path, java.util.Collection<java.awt.Component> roots, SwingSession.Action action)Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
file
protected java.io.File file -
autoSave
protected boolean autoSave -
registeredComponent
protected java.util.Set<java.awt.Component> registeredComponent -
stateManager
State object registered to get and set State. key: class of component managed by the state; value: the state -
states
state of all component added with add method. key: path of compoenent; value: State
-
-
Constructor Details
-
SwingSession
public SwingSession(java.io.File file, boolean autoSave) -
SwingSession
public SwingSession(java.io.File file, boolean autoSave, java.util.Map<java.lang.Class,State> additionalStates)
-
-
Method Details
-
newSession
Deprecated.since 2.10, the default behaviour is now to safely load the incoming fileCreate a new swing session with the given parameters. If it fails to read the given file, then it will delete it from the fs and starts with a new empty file.- Returns:
- the new swing session
- Since:
- 2.8.6
-
newSession
@Deprecated public static SwingSession newSession(java.io.File file, boolean autoSave, java.util.Map<java.lang.Class,State> additionalStates)Deprecated.since 2.10, the default behaviour is now to safely load the incoming fileCreate a new swing session with the given parameters. If it fails to read the given file, then it will delete it from the fs and starts with a new empty file.- Returns:
- the new swing session
- Since:
- 2.8.6
-
getFile
public java.io.File getFile() -
setFile
public void setFile(java.io.File file) -
loadSafeStates
public void loadSafeStates()Loads safely the states from thefile. If could not read the internal file, then will try to delete it.- Since:
- 2.10
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
save
public void save() throws java.io.IOException- Throws:
java.io.IOException
-
loadStates
public java.util.Map<java.lang.String,State> loadStates(java.io.File file) throws java.io.IOExceptionLoads the states from the file- Throws:
java.io.IOException
-
updateState
public void updateState() -
add
public void add(java.awt.Component c) -
add
public void add(java.awt.Component c, boolean replace) -
remove
public void remove(java.awt.Component c)Remove component from component to save- Parameters:
c-
-
getComponentName
protected java.lang.String getComponentName(java.awt.Component c) -
getStateManager
-
addToStateManager
-
getStates
-
setStates
-
walkThroughComponent
protected void walkThroughComponent(java.lang.String path, java.util.Collection<java.awt.Component> roots, SwingSession.Action action)
-