/** * Reads <code>in</code> and returns the map of {@link DockLayoutComposition}s that was * stored. * @param in the stream to read from * @return the roots of the layout * @throws IOException if an I/O-error occurs */ public Map<String, DockLayoutComposition> readCompositions( DataInputStream in ) throws IOException{ Version version = Version.read( in ); version.checkCurrent(); int count = in.readInt(); Map<String, DockLayoutComposition> result = new HashMap<String, DockLayoutComposition>(); for( int i = 0; i < count; i++ ){ String key = in.readUTF(); DockLayoutComposition composition = readComposition( in ); if( composition != null ){ result.put( key, composition ); } } return result; }
/** * Reads a set of {@link DockLayoutComposition}s that were stored earlier. * @param root the xml element from which to read * @return the set of compositions */ public Map<String, DockLayoutComposition> readCompositionsXML( XElement root ){ Map<String, DockLayoutComposition> result = new HashMap<String, DockLayoutComposition>(); for( XElement xelement : root.getElements( "element" )){ String name = xelement.getString( "name" ); DockLayoutComposition composition = readCompositionXML( xelement ); if( composition != null ){ result.put( name, composition ); } } return result; }
/** * Reads the contents of <code>in</code> and returns them in a map. * @param in the stream to read from * @return the content of <code>in</code> * @throws IOException if an I/O-error ocurrs */ public Map<String, PerspectiveStation> read( DataInputStream in ) throws IOException { Map<String, DockLayoutComposition> map = situation.readCompositions( in ); Map<String, PerspectiveStation> result = new HashMap<String, PerspectiveStation>(); for( Map.Entry<String, DockLayoutComposition> entry : map.entrySet() ){ PerspectiveElement element = convert( entry.getValue() ); PerspectiveStation station = element == null ? null : element.asStation(); if( station != null ){ result.put( entry.getKey(), station ); } } return result; }
/** * Writes all locations and relationships of the {@link DockStation}s * <code>stations</code> and their children as xml. * @param stations The stations to store, only the roots are needed. * @param element the element to write into, attributes of <code>element</code> will * not be changed */ public void writeXML( Map<String, DockStation> stations, XElement element ) { Map<String, DockLayoutComposition> map = new HashMap<String, DockLayoutComposition>(); for( Map.Entry<String, DockStation> entry : stations.entrySet() ){ DockLayoutComposition composition = convert( entry.getValue() ); if( composition != null ){ map.put( entry.getKey(), composition ); } } writeCompositionsXML( map, element ); }
/** * Writes all locations and relationships of the {@link DockStation DockStations} * <code>stations</code> and their children into the stream <code>out</code>. * @param stations The stations to store, only the roots are needed. * @param out the stream to write in * @throws IOException if the stream throws an exception */ public void write( Map<String, DockStation> stations, DataOutputStream out ) throws IOException{ Map<String, DockLayoutComposition> map = new HashMap<String, DockLayoutComposition>(); for( Map.Entry<String, DockStation> entry : stations.entrySet() ){ DockLayoutComposition composition = convert( entry.getValue() ); if( composition != null ){ map.put( entry.getKey(), composition ); } } writeCompositions( map, out ); }
/** * Reads a set of {@link DockStation}s that were stored earlier. * @param root the xml element from which to read * @return the set of station */ public Map<String, DockStation> readXML( XElement root ){ Map<String, DockStation> result = new HashMap<String, DockStation>(); for( XElement xelement : root.getElements( "element" )){ String name = xelement.getString( "name" ); DockLayoutComposition composition = readCompositionXML( xelement ); DockElement element = composition == null ? null : convert( composition ); DockStation station = element == null ? null : element.asDockStation(); if( station != null ) result.put( name, station ); } return result; }
conversion.getSituation().add( new CommonMultipleDockableFactory( item.getKey(), item.getValue(), control, perspective ) ); Map<String, DockLayoutComposition> stations = conversion.getSituation().readCompositions( in ); factory.setStations( stations ); DockLayoutComposition composition = null; if( in.readBoolean() ){ composition = conversion.getSituation().readComposition( in );
conversion.getSituation().add( new CommonMultipleDockableFactory( item.getKey(), item.getValue(), control, perspective ) ); Map<String, DockLayoutComposition> stations = conversion.getSituation().readCompositionsXML( xstations ); factory.setStations( stations ); 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();
conversion.getSituation().writeCompositionsXML( stations, root.addElement( "stations" ) ); conversion.getSituation().writeCompositionXML( conversion.convert( dockable.intern() ), xdockable.addElement( "content" ) );
conversion.getSituation().writeCompositions( stations, out ); conversion.getSituation().writeComposition( conversion.convert( dockable.intern() ), out );
DockLayout<?> layout = info.getDataLayout(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( layout.getFactoryID() ); if( factory == null ) throw new IllegalArgumentException( "Missing factory: " + layout.getFactoryID() ); xfactory.addString( "factory", getID( factory ) ); Path placeholder = info.getPlaceholder(); if( placeholder != null ){ AdjacentDockFactory<Object> adjacentFactory = (AdjacentDockFactory<Object>)getAdjacentFactory( adjacentLayout.getFactoryID() ); if( adjacentFactory == null ) throw new IllegalArgumentException( "Missing adjacent factory: " + adjacentLayout.getFactoryID() ); xlayout.addString( "factory", getAdjacentID( adjacentFactory ) ); adjacentFactory.write( adjacentLayout.getData(), xlayout ); writeCompositionXML( child, xchild );
public DockLayoutComposition readCompositionXML( XElement element ){ XElement xfactory = element.getElement( "layout" ); DockLayoutInfo layout = readEntry( xfactory ); AdjacentDockFactory<Object> adjacentFactory = (AdjacentDockFactory<Object>)getAdjacentFactory( factoryId ); if( adjacentFactory != null ){ Object data = adjacentFactory.read( xlayout, intermediatePlaceholders ); Object data = missingAdjacent.readXML( getAdjacentFactoryID( factoryId ), xlayout ); if( data != null ){ adjacentLayouts.add( new DockLayout<Object>( factoryId, data ) ); ignore = xchildren.getBoolean( "ignore" ); for( XElement xchild : xchildren.getElements( "child" )){ children.add( readCompositionXML( xchild ));
/** * Writes the contents of <code>station</code> into <code>element</code>. * @param stations the items to write * @param element the element to write into, the attributes of <code>element</code> * will not be changed */ public void writeCompositionsXML( Map<String, DockLayoutComposition> stations, XElement element ) { for( Map.Entry<String, DockLayoutComposition> entry : stations.entrySet() ){ XElement xchild = element.addElement( "element" ); xchild.addString( "name", entry.getKey() ); writeCompositionXML( entry.getValue(), xchild ); } }
/** * Writes all information stored in <code>stations</code> to <code>out</code>. * @param stations Representations of the root-stations. * @param out the stream to write in * @throws IOException if the stream throws an exception */ public void writeCompositions( Map<String, DockLayoutComposition> stations, DataOutputStream out ) throws IOException{ Version.write( out, Version.VERSION_1_0_4 ); out.writeInt( stations.size() ); for( Map.Entry<String, DockLayoutComposition> entry : stations.entrySet() ){ out.writeUTF( entry.getKey() ); writeComposition( entry.getValue(), out ); } }
/** * Reads <code>in</code> and returns the roots of the * {@link DockElement DockElements} which were found. * @param in the stream to read * @return the roots of all elements that were found * @throws IOException if the stream can't be read */ public Map<String, DockStation> read( DataInputStream in ) throws IOException{ Version version = Version.read( in ); version.checkCurrent(); int count = in.readInt(); Map<String, DockStation> result = new HashMap<String, DockStation>(); for( int i = 0; i < count; i++ ){ String key = in.readUTF(); DockLayoutComposition composition = readComposition( in ); DockElement element = composition == null ? null : convert( composition ); DockStation station = element == null ? null : element.asDockStation(); if( station != null ){ result.put( key, station ); } } return result; }
/** * Creates a new {@link DockFrontendPerspective} which uses the settings from <code>perspective</code> to read * and write layouts. This method adds {@link CommonSingleDockableFactory}, {@link CommonMultipleDockableFactory} and * {@link CommonDockStationFactory} to the perspective.<br> * Clients usually have no need to call this method. * @param perspective the perspective whose settings should be used for reading or writing a layout * @param includeWorkingAreas whether the contents of {@link CStation#isWorkingArea() working areas} * should be included in the layout or not * @return the new builder */ @FrameworkOnly public DockFrontendPerspective conversion( CPerspective perspective, boolean includeWorkingAreas ){ DockFrontendPerspective conversion = wrap( perspective, includeWorkingAreas ); DockSituation situation = conversion.getPerspective().getSituation(); for( Map.Entry<String, MultipleCDockableFactory<?, ?>> item : control.getRegister().getFactories().entrySet() ){ situation.add( new CommonMultipleDockableFactory( item.getKey(), item.getValue(), control, perspective ) ); } return conversion; }
/** * Converts the content of <code>stations</code> to XML. * @param stations the items to write * @param element the element to write into */ public void writeXML( Map<String, PerspectiveStation> stations, XElement element ){ Map<String, DockLayoutComposition> map = new HashMap<String, DockLayoutComposition>(); for( Map.Entry<String, PerspectiveStation> entry : stations.entrySet() ){ DockLayoutComposition composition = convert( entry.getValue() ); if( composition != null ){ map.put( entry.getKey(), composition ); } } situation.writeCompositionsXML( map, element ); }
/** * Reads the contents of <code>root</code> and returns them in a map. * @param root the data to read * @return the content of <code>root</code> */ public Map<String, PerspectiveStation> readXML( XElement root ){ Map<String, DockLayoutComposition> map = situation.readCompositionsXML( root ); Map<String, PerspectiveStation> result = new HashMap<String, PerspectiveStation>(); for( Map.Entry<String, DockLayoutComposition> entry : map.entrySet() ){ PerspectiveElement element = convert( entry.getValue() ); PerspectiveStation station = element == null ? null : element.asStation(); if( station != null ){ result.put( entry.getKey(), station ); } } return result; }
/** * Writes the layout created by <code>stations</code> to <code>out</code>. The data written * by this method can be read by {@link DockSituation#read(DataInputStream)} * @param stations the root-stations to store * @param out the stream to write into * @throws IOException if an I/O-error occurred */ public void write( Map<String, PerspectiveStation> stations, DataOutputStream out ) throws IOException { Map<String, DockLayoutComposition> map = new HashMap<String, DockLayoutComposition>(); for( Map.Entry<String, PerspectiveStation> entry : stations.entrySet() ){ DockLayoutComposition composition = convert( entry.getValue() ); if( composition != null ){ map.put( entry.getKey(), composition ); } } situation.writeCompositions( map, out ); }
layout = situation.fillMissing( layout ); situation.convert( layout ); info.setLayout( null );