public CPerspective readXML( XElement root, boolean includeWorkingAreas ) throws XException{
CPerspective perspective = createEmptyPerspective();
PerspectiveElementFactory factory = new PerspectiveElementFactory( perspective );
DockFrontendPerspective frontend = wrap( perspective, includeWorkingAreas, factory );
Perspective conversion = frontend.getPerspective();
for( Map.Entry<String, MultipleCDockableFactory<?, ?>> item : control.getRegister().getFactories().entrySet() ){
conversion.getSituation().add( new CommonMultipleDockableFactory( item.getKey(), item.getValue(), control, perspective ) );
}
XElement xstations = root.getElement( "stations" );
if( xstations == null ){
throw new XException( "missing element 'stations'" );
}
Map<String, DockLayoutComposition> stations = conversion.getSituation().readCompositionsXML( xstations );
factory.setStations( stations );
for( DockLayoutComposition composition : stations.values() ){
PerspectiveElement station = conversion.convert( composition );
if( station instanceof CommonElementPerspective ){
CStationPerspective stationPerspective = ((CommonElementPerspective)station).getElement().asStation();
if( stationPerspective != null ){
perspective.addStation( stationPerspective );
}
}
}
perspective.storeLocations();
// read the last known location of all elements
XElement xinvisible = root.getElement( "invisible" );
if( xinvisible != null ){
PropertyTransformer transformer = frontend.getPropertyTransformer();
for( XElement xdockable : xinvisible.getElements( "dockable" )){
String key = xdockable.getString( "key" );
CDockablePerspective dockable = perspective.getDockable( key );
if( dockable == null ){
XElement xcontent = xdockable.getElement( "content" );
if( xcontent != null ){
PerspectiveElement element = conversion.convert( conversion.getSituation().readCompositionXML( xcontent ) );
if( element instanceof CommonElementPerspective ){
dockable = ((CommonElementPerspective)element).getElement().asDockable();
if( dockable != null ){
perspective.putDockable( dockable );
}