Class SwingSession
- java.lang.Object
-
- org.nuiton.jaxx.runtime.swing.session.SwingSession
-
public class SwingSession extends 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 Filefileprotected Set<Component>registeredComponentprotected Map<Class,State>stateManagerState object registered to get and set State.protected Map<String,State>statesstate of all component added with add method.
-
Constructor Summary
Constructors Constructor Description SwingSession(File file, boolean autoSave)SwingSession(File file, boolean autoSave, Map<Class,State> additionalStates)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(Component c)voidadd(Component c, boolean replace)voidaddToStateManager(Class component, State state)protected voidfinalize()protected StringgetComponentName(Component c)FilegetFile()StategetStateManager(Class clazz)StategetStates(String path)voidloadSafeStates()Loads safely the states from thefile.Map<String,State>loadStates(File file)Loads the states from the filestatic SwingSessionnewSession(File file, boolean autoSave)Deprecated.since 2.10, the default behaviour is now to safely load the incoming filestatic SwingSessionnewSession(File file, boolean autoSave, Map<Class,State> additionalStates)Deprecated.since 2.10, the default behaviour is now to safely load the incoming filevoidremove(Component c)Remove component from component to savevoidsave()voidsetFile(File file)voidsetStates(String path, State state)voidupdateState()protected voidwalkThrowComponent(String path, Collection<Component> roots, SwingSession.Action action)
-
-
-
Method Detail
-
newSession
@Deprecated public static SwingSession newSession(File file, boolean autoSave)
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(File file, boolean autoSave, Map<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 File getFile()
-
setFile
public void setFile(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 Throwable
-
save
public void save() throws IOException- Throws:
IOException
-
loadStates
public Map<String,State> loadStates(File file) throws IOException
Loads the states from the file- Throws:
IOException
-
updateState
public void updateState()
-
add
public void add(Component c)
-
add
public void add(Component c, boolean replace)
-
remove
public void remove(Component c)
Remove component from component to save- Parameters:
c-
-
walkThrowComponent
protected void walkThrowComponent(String path, Collection<Component> roots, SwingSession.Action action)
-
-