return null; return new CommonDockStationLayout( id, root, factoryId, new DockLayout<Object>( factoryId, data ) );
BackupFactoryData<Object> data = (BackupFactoryData<Object>)backup.read( in, getPlaceholderStrategy() ); if( data != null && data.getData() != null ){ info = new DockLayoutInfo( new DockLayout<Object>( factoryId, data.getData() )); Object delegate = factory.read( in, getPlaceholderStrategy() ); if( delegate != null ){ info = new DockLayoutInfo( new DockLayout<Object>( factoryId, delegate ));
/** * 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 ); } }
@SuppressWarnings("unchecked") public PredefinedLayout getLayout( DockElement element, Map<Dockable, Integer> children ) { if( shouldLayout( element )){ String factoryId = UNKNOWN + PredefinedDockSituation.super.getID( element ); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ) throw new IllegalStateException( "Missing factory: " + factoryId ); Object data = factory.getLayout( element, children ); DockLayout<Object> layout = new DockLayout<Object>( factoryId, data ); return new PredefinedLayout( elementToString.get( element ), new DockLayoutInfo( layout )); } else{ return new PredefinedLayout( elementToString.get( element ), new DockLayoutInfo() ); } }
@SuppressWarnings("unchecked") public PredefinedLayout getPerspectiveLayout( PerspectiveElement element, Map<PerspectiveDockable, Integer> children ){ if( perspective == null ){ throw new IllegalStateException( "the perspective of this factory is not set, meaning this factory cannot be used handling perspective dependent tasks" ); } DockLayoutInfo info; if( shouldLayout( element, perspective )){ String factoryId = UNKNOWN + PredefinedDockSituation.super.getID( element ); DockFactory factory = getFactory( factoryId ); if( factory == null ) throw new IllegalStateException( "Missing factory: " + factoryId ); Object data = factory.getPerspectiveLayout( element, children ); DockLayout<Object> layout = new DockLayout<Object>( factoryId, data ); info = new DockLayoutInfo( layout ); } else{ info = new DockLayoutInfo(); } String key = perspective.get( element ); if( key == null ){ throw new IllegalStateException( "Expected a key for an element, the element should be known to the perspective, otherwise this method would not have been called: '" + element +"'" ); } return new PredefinedLayout( key, info ); }
@SuppressWarnings("unchecked") public PredefinedLayout getLayout( DockElement element, Map<Dockable, Integer> children ) { if( shouldLayout( element )){ String factoryId = UNKNOWN + PredefinedDockSituation.super.getID( element ); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ) throw new IllegalStateException( "Missing factory: " + factoryId ); Object data = factory.getLayout( element, children ); DockLayout<Object> layout = new DockLayout<Object>( factoryId, data ); return new PredefinedLayout( elementToString.get( element ), new DockLayoutInfo( layout )); } else{ return new PredefinedLayout( elementToString.get( element ), new DockLayoutInfo() ); } }
@SuppressWarnings("unchecked") public PredefinedLayout getPerspectiveLayout( PerspectiveElement element, Map<PerspectiveDockable, Integer> children ){ if( perspective == null ){ throw new IllegalStateException( "the perspective of this factory is not set, meaning this factory cannot be used handling perspective dependent tasks" ); } DockLayoutInfo info; if( shouldLayout( element, perspective )){ String factoryId = UNKNOWN + PredefinedDockSituation.super.getID( element ); DockFactory factory = getFactory( factoryId ); if( factory == null ) throw new IllegalStateException( "Missing factory: " + factoryId ); Object data = factory.getPerspectiveLayout( element, children ); DockLayout<Object> layout = new DockLayout<Object>( factoryId, data ); info = new DockLayoutInfo( layout ); } else{ info = new DockLayoutInfo(); } String key = perspective.get( element ); if( key == null ){ throw new IllegalStateException( "Expected a key for an element, the element should be known to the perspective, otherwise this method would not have been called: '" + element +"'" ); } return new PredefinedLayout( key, info ); }
@SuppressWarnings("unchecked") public CommonDockStationLayout getPerspectiveLayout( CommonDockStationPerspective element, Map<PerspectiveDockable, Integer> children ){ String factoryId = element.getConverterID(); DockFactory<?, PerspectiveElement, Object> dockFactory = (DockFactory<?, PerspectiveElement, Object>)control.intern().getDockFactory( factoryId ); DockFactory<?, PerspectiveElement, Object> factory = dockFactory; if( factory == null ){ return null; } Object data = factory.getPerspectiveLayout( element, children ); if( data == null ){ return null; } CElementPerspective celement = element.getElement(); CStationPerspective station = celement.asStation(); String id = station.getUniqueId(); return new CommonDockStationLayout( id, station.isRoot(), factoryId, new DockLayout<Object>( factoryId, data ) ); }
@SuppressWarnings("unchecked") public CommonDockStationLayout getPerspectiveLayout( CommonDockStationPerspective element, Map<PerspectiveDockable, Integer> children ){ String factoryId = element.getConverterID(); DockFactory<?, PerspectiveElement, Object> dockFactory = (DockFactory<?, PerspectiveElement, Object>)control.intern().getDockFactory( factoryId ); DockFactory<?, PerspectiveElement, Object> factory = dockFactory; if( factory == null ){ return null; } Object data = factory.getPerspectiveLayout( element, children ); if( data == null ){ return null; } CElementPerspective celement = element.getElement(); CStationPerspective station = celement.asStation(); String id = station.getUniqueId(); return new CommonDockStationLayout( id, station.isRoot(), factoryId, new DockLayout<Object>( factoryId, data ) ); }
@SuppressWarnings("unchecked") public CommonDockStationLayout getLayout( CommonDockStation<?, ?> element, Map<Dockable, Integer> children ){ String factoryId = element.getConverterID(); DockFactory<DockElement, ?, ?> factory = (DockFactory<DockElement, ?, ?>)control.intern().getDockFactory( factoryId ); if( factory == null ){ return null; } Object layout = factory.getLayout( element, children ); if( layout == null ){ return null; } CDockable dockable = element.getStation().asDockable(); String id = null; if( dockable instanceof SingleCDockable ){ id = ((SingleCDockable)dockable).getUniqueId(); } boolean root = control.isRootStation( element.getStation() ); return new CommonDockStationLayout( id, root, factoryId, new DockLayout<Object>( factoryId, layout ) ); }
@SuppressWarnings("unchecked") public CommonDockStationLayout getLayout( CommonDockStation<?, ?> element, Map<Dockable, Integer> children ){ String factoryId = element.getConverterID(); DockFactory<DockElement, ?, ?> factory = (DockFactory<DockElement, ?, ?>)control.intern().getDockFactory( factoryId ); if( factory == null ){ return null; } Object layout = factory.getLayout( element, children ); if( layout == null ){ return null; } CDockable dockable = element.getStation().asDockable(); String id = null; if( dockable instanceof SingleCDockable ){ id = ((SingleCDockable)dockable).getUniqueId(); } boolean root = control.isRootStation( element.getStation() ); return new CommonDockStationLayout( id, root, factoryId, new DockLayout<Object>( factoryId, layout ) ); }
@Override protected DockLayoutInfo fillMissing( DockLayoutInfo info ) { DockLayout<?> layout = info.getDataLayout(); if( KNOWN.equals( layout.getFactoryID() )){ PredefinedLayout preloaded = (PredefinedLayout)layout.getData(); DockLayoutInfo delegate = preloaded.getDelegate(); DockLayoutInfo newDelegate = null; if( delegate.getKind() == DockLayoutInfo.Data.BYTE ){ newDelegate = fillMissingStream( preloaded ); } else if( delegate.getKind() == DockLayoutInfo.Data.XML ){ newDelegate = fillMissingXML( preloaded ); } if( newDelegate != null ){ info = new DockLayoutInfo( new DockLayout<PredefinedLayout>( KNOWN, new PredefinedLayout( preloaded.getPredefined(), newDelegate ))); } } return info; }
@Override protected DockLayoutInfo fillMissing( DockLayoutInfo info ) { DockLayout<?> layout = info.getDataLayout(); if( KNOWN.equals( layout.getFactoryID() )){ PredefinedLayout preloaded = (PredefinedLayout)layout.getData(); DockLayoutInfo delegate = preloaded.getDelegate(); DockLayoutInfo newDelegate = null; if( delegate.getKind() == DockLayoutInfo.Data.BYTE ){ newDelegate = fillMissingStream( preloaded ); } else if( delegate.getKind() == DockLayoutInfo.Data.XML ){ newDelegate = fillMissingXML( preloaded ); } if( newDelegate != null ){ info = new DockLayoutInfo( new DockLayout<PredefinedLayout>( KNOWN, new PredefinedLayout( preloaded.getPredefined(), newDelegate ))); } } return info; }
/** * 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 ) ); }
@SuppressWarnings("unchecked") public CommonDockStationLayout read( XElement element, PlaceholderStrategy placeholders ){ String id = null; XElement xid = element.getElement( "id" ); if( xid != null ){ id = xid.getString(); } boolean root = element.getElement( "root" ).getBoolean(); XElement xcontent = element.getElement( "content" ); if( xcontent == null ){ throw new XException( "missing content element" ); } String factoryId = xcontent.getString( "delegate" ); DockFactory<DockElement, ?, Object> factory = (DockFactory<DockElement, ?, Object>)control.intern().getDockFactory( factoryId ); if( factory == null ){ return new CommonDockStationLayout( id, root, factoryId, xcontent ); } else{ Object data = factory.read( xcontent, placeholders ); if( data == null ){ return null; } return new CommonDockStationLayout( id, root, factoryId, new DockLayout<Object>( factoryId, data ) ); } }
@SuppressWarnings("unchecked") public CommonDockStationLayout read( XElement element, PlaceholderStrategy placeholders ){ String id = null; XElement xid = element.getElement( "id" ); if( xid != null ){ id = xid.getString(); } boolean root = element.getElement( "root" ).getBoolean(); XElement xcontent = element.getElement( "content" ); if( xcontent == null ){ throw new XException( "missing content element" ); } String factoryId = xcontent.getString( "delegate" ); DockFactory<DockElement, ?, Object> factory = (DockFactory<DockElement, ?, Object>)control.intern().getDockFactory( factoryId ); if( factory == null ){ return new CommonDockStationLayout( id, root, factoryId, xcontent ); } else{ Object data = factory.read( xcontent, placeholders ); if( data == null ){ return null; } return new CommonDockStationLayout( id, root, factoryId, new DockLayout<Object>( factoryId, data ) ); } }
/** * 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 ) ); }
DockLayout<Object> layout = new DockLayout<Object>( factoryId, delegate ); return new PredefinedLayout( preload, new DockLayoutInfo( layout ) );
DockLayout<Object> layout = new DockLayout<Object>( factoryId, delegate ); return new PredefinedLayout( preload, new DockLayoutInfo( layout ) );