|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.swing.AbstractLayoutPersistence com.jidesoft.swing.LayoutPersistenceManager
public class LayoutPersistenceManager
LayoutPersistenceManager
can manage multiple LayoutPersistences as one unit. Right now
DockingManager
and DockableBarManager
are both LayoutPersistence. If user call saveLayout
on both managers, you will end up with two layout files (or two entries in registry). If user didn't set profile key
correctly, the two could even step on each other. That's why introduce LayoutPersistenceManager
.
DefaultDockableBarHolder
(for Action Framework only) or DefaultDockableHolder
(for Docking Framework only) as your JFrame, there is no change to the way you load/save layout.
If you are using DefaultDockableBarDockableHolder
, you should call all layout related methods on
getLayoutPersistence(). For example, frame.getLayoutPersistence().saveLayoutData()
,
frame.getLayoutPersistence().setProfileKey()
If you are not using DefaultDockableBarDockableHolder
for some reason, you need to add some code to make
it happen.
First, create a new field call LayoutPersistenceManager _layoutPersistence. After initiaization of DockingManager and
DockableBarManager, call the code below.
_layoutPersistence = new LayoutPersistenceManager();
_layoutPersistence.addLayoutPersistence(getDockableBarManager());
_layoutPersistence.addLayoutPersistence(getDockingManager());
public LayoutPersistence getLayoutPersistence() {
return _layoutPersistence;
}
Now in your code to use layout, call those layout methods use getLayoutPersistence() you just added. For example,
when you save layout, call getLayoutPersistence().saveLayoutData(). When loading layout, call
getLayoutPersistence().loadLayoutData(). Or if you want to change profile key, call
getLayoutPersistence().setProfileKey(newKey).
A2. SampleVsnet example is such an example using DefaultDockableBarDockableHolder
. You can always refer
to its source code to find out how to use the class.
Field Summary | |
---|---|
static String |
NODE_DOCKABLE_BAR_MANAGER
|
static String |
NODE_DOCKING_MANAGER
|
static String |
NODE_DOCUMENT_PANE
|
Fields inherited from class com.jidesoft.swing.AbstractLayoutPersistence |
---|
_layoutDirectory, _loadingLayoutData, _profileKey, _useFrameBounds, _useFrameBoundsSet, _useFrameState, _useFrameStateSet, _usePref, _version, DEFAULT_PROFILE_NAME, LAYOUT_COUNT_STRING, LAYOUT_POSTFIX, MAX_PREF_BYTE_ARRAY_LENGTH, PROPERTY_PROFILE_KEY, PROPERTY_USE_PREF, PROPERTY_VERSION, V2004, V2005_09 |
Fields inherited from interface com.jidesoft.swing.LayoutPersistence |
---|
ATTRIBUTE_PERSISTENCE_NAME, NODE_LAYOUT_PERSISTENCE |
Constructor Summary | |
---|---|
LayoutPersistenceManager()
|
Method Summary | |
---|---|
void |
addLayoutPersistence(LayoutPersistence layoutPersistence)
|
void |
beginLoadLayoutData()
Starts a process to add/remove frame or dockable bar without showing on screen immediately. |
void |
clear()
|
boolean |
isLast()
Checks if it is the last one during when loading several several LayoutPersistence s. |
boolean |
isLoadDataSuccessful()
Did the loadLayoutFrom(InputStream in) method load successfully from the input stream (false indicates that it called resetToDefault to load the layout.) This method can be called immediately after the loadLayoutFrom(InputStream in) call to determine if a specific LayoutPersistence was forced to call resetToDefault. |
void |
loadInitialLayout(Document layoutDocument)
Load initial layout from an initial layout file designed by Visual Designer. |
void |
loadInitialLayout(InputStream layoutStream)
Load initial layout from an initial layout file designed by Visual Designer. |
void |
loadInitialLayout(String layoutFile)
Load initial layout from an initial layout file designed by Visual Designer. |
boolean |
loadLayoutFrom(Document document)
Load layout data from an Node that specified as node parameter. |
boolean |
loadLayoutFrom(InputStream in)
Load layout data from an InputStream that specified as in parameter. |
void |
removeLayoutPersistence(LayoutPersistence layoutPersistence)
|
void |
resetToDefault()
Resets layout. |
void |
saveLayoutTo(Document document)
Save layout data to a Document that specified as document parameter. |
void |
saveLayoutTo(OutputStream out)
Save layout data to an OutputStream that specified as out parameter. |
void |
setLast(boolean last)
Sets the LayoutPersistence as the last one (or not the last one) when loading several LayoutPersistences. |
void |
setLayoutDirectory(String layoutDirectory)
Sets the layout directory. |
void |
setProfileKey(String profileKey)
Sets the profile key to be used to store layout information. |
void |
setUseFrameBounds(boolean useFrameBounds)
If true, the bounds of main frame will be persisted in layout data. |
void |
setUseFrameState(boolean useFrameState)
If true, the state of main frame will be persisted in layout data. |
void |
setUsePref(boolean usePref)
If true, use javax.util.pref to store frames layout data. |
void |
setVersion(short version)
Sets version number of profile. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String NODE_DOCKING_MANAGER
public static final String NODE_DOCKABLE_BAR_MANAGER
public static final String NODE_DOCUMENT_PANE
Constructor Detail |
---|
public LayoutPersistenceManager()
Method Detail |
---|
public void addLayoutPersistence(LayoutPersistence layoutPersistence)
public void removeLayoutPersistence(LayoutPersistence layoutPersistence)
public void clear()
public boolean loadLayoutFrom(Document document)
LayoutPersistence
Node
that specified as node
parameter. If any exception
happens during the read, it will call resetLayout() to use default layout.
document
- the Document where the layout data will be read from
public boolean loadLayoutFrom(InputStream in)
in
parameter. If any exception happens during
the read, it will call resetLayout() to use default layout.
in
- the InputStream where the layout data will be read from.
public boolean isLoadDataSuccessful()
public void saveLayoutTo(Document document) throws ParserConfigurationException
LayoutPersistence
document
parameter.
document
- the Document where the layout data will be written to
ParserConfigurationException
- if any parser exception happens when writing to the document
.public void saveLayoutTo(OutputStream out) throws IOException
LayoutPersistence
out
parameter.
out
- the OutputStream where the layout data will be written to.
IOException
- if any IO exception happens when writing to the OutputStream
.public void resetToDefault()
LayoutPersistence
public void beginLoadLayoutData()
LayoutPersistence
public void loadInitialLayout(String layoutFile) throws ParserConfigurationException, SAXException, IOException
LayoutPersistence
loadInitialLayout
in interface LayoutPersistence
loadInitialLayout
in class AbstractLayoutPersistence
layoutFile
- the full file path to the .ilayout file.
ParserConfigurationException
- when DocumentBuilder cannot be created which satisfies the configuration
requested.
SAXException
- when DocumentBuilder has trouble parsing the initial layout xml file.
IOException
- when DocumetnBuilder encounters any errors when reading the initial layout
xml file.public void loadInitialLayout(InputStream layoutStream) throws ParserConfigurationException, SAXException, IOException
LayoutPersistence
loadInitialLayout
in interface LayoutPersistence
loadInitialLayout
in class AbstractLayoutPersistence
layoutStream
- an input stream containing an initial layout.
ParserConfigurationException
- when DocumentBuilder cannot be created which satisfies the configuration
requested.
SAXException
- when DocumentBuilder has trouble parsing the initial layout xml file.
IOException
- when DocumetnBuilder encounters any errors when reading the initial layout
xml file.public void loadInitialLayout(Document layoutDocument)
LayoutPersistence
layoutDocument
- the Document contains an initial layout.public void setUseFrameBounds(boolean useFrameBounds)
AbstractLayoutPersistence
setUseFrameBounds
in interface LayoutPersistence
setUseFrameBounds
in class AbstractLayoutPersistence
useFrameBounds
- true if the bounds of main frame will be persisted in layout data.LayoutPersistence.setUseFrameState(boolean)
public void setUseFrameState(boolean useFrameState)
AbstractLayoutPersistence
setUseFrameState
in interface LayoutPersistence
setUseFrameState
in class AbstractLayoutPersistence
useFrameState
- true if the state of main frame will be persisted in layout data.LayoutPersistence.setUseFrameBounds(boolean)
public void setLayoutDirectory(String layoutDirectory)
LayoutPersistence
usePref
is false.
setLayoutDirectory
in interface LayoutPersistence
setLayoutDirectory
in class AbstractLayoutPersistence
layoutDirectory
- the layout directory.public void setVersion(short version)
AbstractLayoutPersistence
setVersion
in interface LayoutPersistence
setVersion
in class AbstractLayoutPersistence
version
- new versionpublic void setUsePref(boolean usePref)
AbstractLayoutPersistence
setUsePref
in interface LayoutPersistence
setUsePref
in class AbstractLayoutPersistence
usePref
- use javax pref or not. Default is truepublic void setProfileKey(String profileKey)
AbstractLayoutPersistence
setProfileKey
in interface LayoutPersistence
setProfileKey
in class AbstractLayoutPersistence
profileKey
- profile keypublic boolean isLast()
LayoutPersistence
LayoutPersistence
s. Only the last
LayoutPersistence
will restore the main window's state and bounds and make the main window visible.
isLast
in interface LayoutPersistence
isLast
in class AbstractLayoutPersistence
public void setLast(boolean last)
LayoutPersistence
setLast
in interface LayoutPersistence
setLast
in class AbstractLayoutPersistence
last
- true if the layout persistence is the last one in the LayoutPersistenceManager
.
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |