control.save(“HHH”); = Create HHH Perspective?
Well, yes. It saves the current layout and names it “HHH”. Later you can use “control.getPerspectives().getPerspective(“HHH”)” to get the layout as perspective.
but
private void loadLastLayout() {
try {
this.control.readXML(new File(LocalStore.getLoginUserPath() + "/HHH.xml"));
this.control.load("HHH");
System.err.println("HHH======"+this.control.getPerspectives().getPerspective("HHH"));
logger.info("????????");
} catch (FileNotFoundException ex) {
} catch (Exception ex) {
logger.warn("????????", ex);
}
}
private void saveCurrentLayout() {
try {
this.control.save("HHH");
System.err.println("HHH======"+this.control.getPerspectives().getPerspective("HHH"));
this.control.writeXML(new File(LocalStore.getLoginUserPath() + "/HHH.xml"));
} catch (Exception ex) {
logger.warn("????????", ex);
}
}
loadLastLayout is java.lang.NullPointerException: null
What is the stacktrace of the exception?
How does the XML file look like?
Which object is null?
Hint: the problem is solved much faster if you write more than 5 words per post
[XML]
<?xml version='1.0'?> false dock.single.com\.mt\.wms\.portfolio\.purchase_redemption\.PRDataManagerViewWMS dock.single.com\.mt\.wms\.portfolio\.cashType\.CashTypeDataManagerViewWMS 0 dock.PlaceholderList dock.single.com\.mt\.wms\.portfolio\.cashType\.CashTypeDataManagerViewWMS true dock.single.com\.mt\.wms\.portfolio\.purchase_redemption\.PRDataManagerViewWMS true 0 0 dock.PlaceholderList dock.single.com\.mt\.wms\.portfolio\.cashType\.CashTypeDataManagerViewWMS true id index placeholder 0 0 dock.single.com\.mt\.wms\.portfolio\.cashType\.CashTypeDataManagerViewWMS dock.single.com\.mt\.wms\.portfolio\.purchase_redemption\.PRDataManagerViewWMS true id index placeholder 1 1 dock.single.com\.mt\.wms\.portfolio\.purchase_redemption\.PRDataManagerViewWMS com.mt.wms.portfolio.cashType.CashTypeDataManagerViewWMS com.mt.wms.portfolio.purchase_redemption.PRDataManagerViewWMS 0 dock.PlaceholderList 0 dock.PlaceholderList 0 dock.PlaceholderList 0 dock.PlaceholderList 0 dock.PlaceholderList dock.single.com\.mt\.functions\.info\.bondInfo\.BondViewFIS 0 dock.single.com\.mt\.functions\.info\.bondInfo\.BondViewFIS dock.mode.normal dock.mode.normal ccontrol center dock.single.com\.mt\.wms\.portfolio\.maintain\.portfolio\.PortfolioManagerViewWMS 0 dock.single.com\.mt\.wms\.portfolio\.maintain\.portfolio\.PortfolioManagerViewWMS dock.mode.normal dock.mode.normal ccontrol center dock.single.com\.mt\.wms\.instrumentManager\.customBond\.CustomBondViewWMS dock.mode.normal dock.mode.normal ccontrol center 0.0 0.0 1.0 1.0 0 dock.mode.normal dock.mode.normal ccontrol center dock.single.com\.mt\.functions\.info\.bondInfo\.BondViewFIS 0 dock.single.com\.mt\.functions\.info\.bondInfo\.BondViewFIS dock.mode.normal dock.mode.normal ccontrol center 0.0 0.0 1.0 1.0 0 false dock.single.com\.mt\.wms\.portfolio\.purchase_redemption\.PRDataManagerViewWMS dock.single.com\.mt\.wms\.portfolio\.cashType\.CashTypeDataManagerViewWMS 0 dock.PlaceholderList dock.single.com\.mt\.wms\.portfolio\.cashType\.CashTypeDataManagerViewWMS true dock.single.com\.mt\.wms\.portfolio\.purchase_redemption\.PRDataManagerViewWMS true 0 0 dock.PlaceholderList dock.single.com\.mt\.wms\.portfolio\.cashType\.CashTypeDataManagerViewWMS true id index placeholder 0 0 dock.single.com\.mt\.wms\.portfolio\.cashType\.CashTypeDataManagerViewWMS dock.single.com\.mt\.wms\.portfolio\.purchase_redemption\.PRDataManagerViewWMS true id index placeholder 1 1 dock.single.com\.mt\.wms\.portfolio\.purchase_redemption\.PRDataManagerViewWMS com.mt.wms.portfolio.cashType.CashTypeDataManagerViewWMS…
[/XML]
The xml file seems to be fine. The stacktrace of the exception would probably help the most.
java.lang.NullPointerException: null
at bibliothek.gui.dock.common.perspective.CControlPerspective$PerspectiveElementFactory.get(CControlPerspective.java:221) ~[dockingFramesCommon.jar:na]
at bibliothek.gui.dock.frontend.DefaultLayoutChangeStrategy$3.get(DefaultLayoutChangeStrategy.java:205) ~[dockingFramesCore.jar:na]
at bibliothek.gui.dock.perspective.PredefinedPerspective.get(PredefinedPerspective.java:112) ~[dockingFramesCore.jar:na]
at bibliothek.gui.dock.layout.PredefinedDockSituation$PreloadFactory.layoutPerspective(PredefinedDockSituation.java:755) ~[dockingFramesCore.jar:na]
at bibliothek.gui.dock.layout.PredefinedDockSituation$PreloadFactory.layoutPerspective(PredefinedDockSituation.java:587) ~[dockingFramesCore.jar:na]
at bibliothek.gui.dock.perspective.Perspective.convert(Perspective.java:240) ~[dockingFramesCore.jar:na]
at bibliothek.gui.dock.common.perspective.CControlPerspective.convert(CControlPerspective.java:166) ~[dockingFramesCommon.jar:na]
at bibliothek.gui.dock.common.perspective.CControlPerspective.getPerspective(CControlPerspective.java:113) ~[dockingFramesCommon.jar:na]
control.load(“HHH”) = control.getPerspectives().setPerspective(“HHH”,perspective)?
Hm, ok. That bug seems to be pretty deep in the framework. I’ll have to experiment a bit for my own, but I should be able to upload a fix in the evening.
Just one last question: what version of the framework are you using?
One method loads an existing layout, the other replaces the layout (which can later be loaded).
Oh, one thing to check for you: ensure that you register all root stations and dockables (or factories) before loading the xml file. Because a missing root-station would cause this exception.
1.1.0p6g , Latest
.......................................
control = new CControl(frame);
...................................
loadLastLayout();
control.getContentArea()
...............................
The order in question?
Yes. Because the CContentArea is created lazily in the moment you access it the first time. You at least need to switch lines 4 and 5. It would also be a good idea to call all the “addDockable…/addFactory…” methods before “loadLastLayout”.
ok,Thanks.
I admit, this behavior is not intuitive. It should not be necessary to register root-stations in order to access the perspectives. I’ll keep this in mind and maybe choose another solution.