/** * Gets the layout information as xml element, assuming that the layout information is stored * in xml. * @return the layout information or <code>null</code> if not stored in xml format */ public XElement getLayoutXML(){ return layout.getDataXML(); }
/** * Gets the layout information as xml element, assuming that the layout information is stored * in xml. * @return the layout information or <code>null</code> if not stored in xml format */ public XElement getLayoutXML(){ return layout.getDataXML(); }
return info.getDataXML().getString( "factory" );
/** * Updates the contents of the internal {@link DockLayoutInfo} using <code>factory</code> to read * a byte array or an {@link XElement}. * @param factory the factory used to read the layout * @param placeholders the placeholders that may be used */ public void updateLayout( DockFactory<?, ?, Object> factory, PlaceholderStrategy placeholders ){ try{ Object data = null; switch( layout.getKind() ){ case BYTE: data = factory.read( new DataInputStream( new ByteArrayInputStream( layout.getDataByte() ) ), placeholders ); break; case XML: data = factory.read( layout.getDataXML(), placeholders ); break; } if( data != null ){ layout.setData( new DockLayout<Object>( factory.getID(), data ) ); } } catch( IOException e ){ // since a ByteArrayInputStream never throws an IOException this should never happen throw new IllegalStateException( e ); } }
/** * Updates the contents of the internal {@link DockLayoutInfo} using <code>factory</code> to read * a byte array or an {@link XElement}. * @param factory the factory used to read the layout * @param placeholders the placeholders that may be used */ public void updateLayout( DockFactory<?, ?, Object> factory, PlaceholderStrategy placeholders ){ try{ Object data = null; switch( layout.getKind() ){ case BYTE: data = factory.read( new DataInputStream( new ByteArrayInputStream( layout.getDataByte() ) ), placeholders ); break; case XML: data = factory.read( layout.getDataXML(), placeholders ); break; } if( data != null ){ layout.setData( new DockLayout<Object>( factory.getID(), data ) ); } } catch( IOException e ){ // since a ByteArrayInputStream never throws an IOException this should never happen throw new IllegalStateException( e ); } }
info = readEntry( info.getDataXML() ); if( info != null && info.getKind() == DockLayoutInfo.Data.XML ){ info = original;
@SuppressWarnings("unchecked") public void write( PredefinedLayout layout, XElement element ) { element.addElement( "replacement" ).addString( "id", layout.getPredefined() ); DockLayoutInfo info = layout.getDelegate(); if( info.getKind() == DockLayoutInfo.Data.XML ){ element.addElement( info.getDataXML() ); } else if( info.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT ){ DockLayout<?> delegate = layout.getDelegate().getDataLayout(); String factoryId = delegate.getFactoryID(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ) throw new XException( "Missing factory: " + factoryId ); XElement xdelegate = element.addElement( "delegate" ); xdelegate.addString( "id", factoryId ); factory.write( delegate.getData(), xdelegate ); } else if( info.getKind() == DockLayoutInfo.Data.NULL ){ // nothing to store } else{ throw new IllegalArgumentException( "Cannot store information as xml, it is neither present as raw xml nor in an understandable format" ); } }
@SuppressWarnings("unchecked") public void write( PredefinedLayout layout, XElement element ) { element.addElement( "replacement" ).addString( "id", layout.getPredefined() ); DockLayoutInfo info = layout.getDelegate(); if( info.getKind() == DockLayoutInfo.Data.XML ){ element.addElement( info.getDataXML() ); } else if( info.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT ){ DockLayout<?> delegate = layout.getDelegate().getDataLayout(); String factoryId = delegate.getFactoryID(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ) throw new XException( "Missing factory: " + factoryId ); XElement xdelegate = element.addElement( "delegate" ); xdelegate.addString( "id", factoryId ); factory.write( delegate.getData(), xdelegate ); } else if( info.getKind() == DockLayoutInfo.Data.NULL ){ // nothing to store } else{ throw new IllegalArgumentException( "Cannot store information as xml, it is neither present as raw xml nor in an understandable format" ); } }
/** * Tries to read the xml data in <code>layout</code>. * @param layout the layout to read * @return either a new info or <code>null</code> if the data could * not be read */ @SuppressWarnings("unchecked") private DockLayoutInfo fillMissingXML( PredefinedLayout layout ){ XElement xdelegate = layout.getDelegate().getDataXML(); String factoryId = xdelegate.getString( "id" ); Object delegate = null; DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ){ DockFactory<?,?,BackupFactoryData<?>> backup = getBackup( factoryId ); if( backup != null ){ BackupFactoryData<Object> data = (BackupFactoryData<Object>)backup.read( xdelegate, getPlaceholderStrategy() ); if( data != null ) delegate = data.getData(); } } else{ delegate = factory.read( xdelegate, getPlaceholderStrategy() ); } if( delegate == null ){ return null; } return new DockLayoutInfo( new DockLayout<Object>( factoryId, delegate ) ); }
/** * Tries to read the xml data in <code>layout</code>. * @param layout the layout to read * @return either a new info or <code>null</code> if the data could * not be read */ @SuppressWarnings("unchecked") private DockLayoutInfo fillMissingXML( PredefinedLayout layout ){ XElement xdelegate = layout.getDelegate().getDataXML(); String factoryId = xdelegate.getString( "id" ); Object delegate = null; DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ){ DockFactory<?,?,BackupFactoryData<?>> backup = getBackup( factoryId ); if( backup != null ){ BackupFactoryData<Object> data = (BackupFactoryData<Object>)backup.read( xdelegate, getPlaceholderStrategy() ); if( data != null ) delegate = data.getData(); } } else{ delegate = factory.read( xdelegate, getPlaceholderStrategy() ); } if( delegate == null ){ return null; } return new DockLayoutInfo( new DockLayout<Object>( factoryId, delegate ) ); }
DockLayoutInfo info = composition.getLayout(); if( info.getKind() == DockLayoutInfo.Data.XML ){ element.addElement( info.getDataXML() );