/** * Given a set of <code>Dockable</code>s this method * estimates which of them will be visible once <code>composition</code> * is applied. * @param <D> the kind of elements to check * @param base a collection of <code>Dockable</code>s in no specific * order and with no restrictions * @param composition location information for various elements * @return A subset of <code>base</code> with those elements which will * be visible once this situation converts <code>composition</code> */ public <D extends DockElement> Set<D> listVisible( Collection<D> base, DockLayoutComposition composition ){ Set<D> result = new HashSet<D>(); listVisible( base, composition, result ); return result; }
@Override protected PredefinedDockSituation createSituation( DockFrontendInternals frontend, boolean entry, boolean onSetLayout ){ PredefinedDockSituation situation = super.createSituation( frontend, entry, onSetLayout ); if( onSetLayout ){ situation.add( new ReplacementDockFactory() ); } situation.setPlaceholderStrategy( control.getProperty( PlaceholderStrategy.PLACEHOLDER_STRATEGY ) ); return situation; }
public CSettingAccess( DockFrontendInternals frontend, Setting setting ){ super( setting ); this.frontend = frontend; Map<String, MultipleCDockableFactory<?, ?>> factories = control.getRegister().getFactories(); this.factories = new HashMap<String, MultipleCDockableFactory<?,?>>(); for( Map.Entry<String, MultipleCDockableFactory<?, ?>> entry : factories.entrySet() ){ this.factories.put( PredefinedDockSituation.convertFactoryID( entry.getKey() ), entry.getValue() ); } remainingDockables = new HashMap<String, List<MultipleCDockable>>(); for( MultipleCDockable dockable : control.getRegister().getMultipleDockables() ){ for( Map.Entry<String, MultipleCDockableFactory<?, ?>> entry : factories.entrySet() ){ if( entry.getValue() == dockable.getFactory() ){ String key = PredefinedDockSituation.convertFactoryID( entry.getKey() ); List<MultipleCDockable> list = remainingDockables.get( key ); if( list == null ){ list = new LinkedList<MultipleCDockable>(); remainingDockables.put( key, list ); } list.add( dockable ); break; } } } }
/** * Lists for all keys that can be found in <code>composition</code> its * estimated location.<br> * Note: This method will call {@link #estimateLocations(DockLayoutComposition)} * to get the most recent locations * @param composition some composition to search for keys and locations * @param location the location of <code>composition</code> itself * @param missingOnly if set, then only locations of keys for which * no {@link DockLayout} is set are reported. This are the keys which most * likely will be ignored when calling {@link #convert(DockLayoutComposition)} * @return the map of keys and positions, might be empty */ public Map<String, DockableProperty> listEstimatedLocations( DockLayoutComposition composition, DockableProperty location, boolean missingOnly ){ estimateLocations( composition, location ); Map<String, DockableProperty> map = new HashMap<String, DockableProperty>(); listEstimatedLocations( composition, missingOnly, map ); if( location != null ){ String key = getKey( composition, missingOnly ); if( key != null ){ map.put( key, location ); } } return map; }
@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() ); } }
/** * 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 ) ); }
situation.put( DockFrontend.ROOT_KEY_PREFIX + info.getName(), info.getStation() ); situation.put( DockFrontend.DOCKABLE_KEY_PREFIX + info.getKey(), info.getDockable() ); situation.add( factory ); situation.addBackup( new RegisteringDockFactory( frontend.getFrontend(), backup ) ); situation.addAdjacent( factory ); situation.setIgnore( frontend.getFrontend().getIgnoreForEntry() ); else situation.setIgnore( frontend.getFrontend().getIgnoreForFinal() );
private DockFrontendPerspective wrap( CPerspective perspective, boolean includeWorkingAreas, PerspectiveElementFactory factory ){ DockFrontendPerspective frontend = control.getOwner().intern().getPerspective( !includeWorkingAreas, factory ); PredefinedPerspective inner = frontend.getPerspective(); factory.setBasePerspective( inner ); CommonSingleDockableFactory singleDockableFactory = new CommonSingleDockableFactory( control.getOwner(), perspective ); inner.getSituation().add( singleDockableFactory ); inner.getSituation().addBackup( new RegisteringDockFactory<CommonDockable, CommonElementPerspective, CommonSingleDockableLayout>( control.getOwner().intern(), singleDockableFactory ) ); inner.getSituation().add( new CommonDockStationFactory( control.getOwner(), factory, singleDockableFactory ) ); return frontend; }
String factoryId = in.readUTF(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ){ DockFactory backup = getBackup( factoryId ); if( backup != null ){ BackupFactoryData<Object> data = (BackupFactoryData<Object>)backup.read( in, placeholders );
protected DockFactory<?, ?, ?> getFactory( String id ){ DockFactory<?, ?, ?> factory = PredefinedDockSituation.this.getFactory( id ); if( factory == PredefinedDockSituation.this.factory ){ return preload; } return factory; } };
@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; }
public DockElement layout( PredefinedLayout layout, Map<Integer, Dockable> children, PlaceholderStrategy placeholders ) { DockLayoutInfo delegate = layout.getDelegate(); boolean isLayout = delegate.getKind() == DockLayoutInfo.Data.DOCK_LAYOUT; boolean isNull = delegate.getKind() == DockLayoutInfo.Data.NULL; if( !isLayout && !isNull ){ return null; } DockElement element = stringToElement.get( layout.getPredefined() ); if( element == null && isLayout ){ String factoryId = delegate.getDataLayout().getFactoryID(); DockFactory<?, ?, BackupFactoryData<?>> factory = getBackup( factoryId ); if( factory != null ){ return factory.layout( new BackupFactoryData<Object>( layout.getPredefined(), delegate.getDataLayout().getData()), children, placeholders ); } return null; } setLayout( element, layout, children, placeholders ); return element; }
protected String getID( PerspectiveElement element ){ return PredefinedDockSituation.this.getID( element, this ); }
public void estimateLocations( DockFrontendInternals frontend, DockSituation situation, DockLayoutComposition layout ){ if( situation instanceof PredefinedDockSituation ){ ((PredefinedDockSituation)situation).estimateLocations( layout ); } }
@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() ); } }
/** * 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 ) ); }
private DockFrontendPerspective wrap( CPerspective perspective, boolean includeWorkingAreas, PerspectiveElementFactory factory ){ DockFrontendPerspective frontend = control.getOwner().intern().getPerspective( !includeWorkingAreas, factory ); PredefinedPerspective inner = frontend.getPerspective(); factory.setBasePerspective( inner ); CommonSingleDockableFactory singleDockableFactory = new CommonSingleDockableFactory( control.getOwner(), perspective ); inner.getSituation().add( singleDockableFactory ); inner.getSituation().addBackup( new RegisteringDockFactory<CommonDockable, CommonElementPerspective, CommonSingleDockableLayout>( control.getOwner().intern(), singleDockableFactory ) ); inner.getSituation().add( new CommonDockStationFactory( control.getOwner(), factory, singleDockableFactory ) ); return frontend; }
/** * Lists for all keys that can be found in <code>composition</code> its * estimated location.<br> * Note: This method will call {@link #estimateLocations(DockLayoutComposition)} * to get the most recent locations * @param composition some composition to search for keys and locations * @param location the location of <code>composition</code> itself * @param missingOnly if set, then only locations of keys for which * no {@link DockLayout} is set are reported. This are the keys which most * likely will be ignored when calling {@link #convert(DockLayoutComposition)} * @return the map of keys and positions, might be empty */ public Map<String, DockableProperty> listEstimatedLocations( DockLayoutComposition composition, DockableProperty location, boolean missingOnly ){ estimateLocations( composition, location ); Map<String, DockableProperty> map = new HashMap<String, DockableProperty>(); listEstimatedLocations( composition, missingOnly, map ); if( location != null ){ String key = getKey( composition, missingOnly ); if( key != null ){ map.put( key, location ); } } return map; }
String factoryId = in.readUTF(); DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( factoryId ); if( factory == null ){ DockFactory backup = getBackup( factoryId ); if( backup != null ){ BackupFactoryData<Object> data = (BackupFactoryData<Object>)backup.read( in, placeholders );
protected DockFactory<?, ?, ?> getFactory( String id ){ DockFactory<?, ?, ?> factory = PredefinedDockSituation.this.getFactory( id ); if( factory == PredefinedDockSituation.this.factory ){ return preload; } return factory; } };