bibliothek.gui.dock.station
Class DisplayerCollection

java.lang.Object
  extended by bibliothek.gui.dock.station.DisplayerCollection
All Implemented Interfaces:
java.lang.Iterable<DockableDisplayer>

public class DisplayerCollection
extends java.lang.Object
implements java.lang.Iterable<DockableDisplayer>

A set of DockableDisplayers. Clients may fetch a new displayer at any time, and the can release a displayer which is no longer used. The collection ensures that various properties of the displayers are set in the proper order.

Author:
Benjamin Sigg

Field Summary
private  DockController controller
          the current controller, all displayer should know this controller
private  java.util.List<DockableDisplayer> displayers
          the set of displayers that are fetched but not released
private  DisplayerFactory factory
          a factory used to create new displayers
private  DockStation station
          the station for which displayers are created
 
Constructor Summary
DisplayerCollection(DockStation station, DisplayerFactory factory)
          Creates a new collection
 
Method Summary
 DockableDisplayer fetch(Dockable dockable, DockTitle title)
          Creates a new DockableDisplayer using the factory of this collection.
 java.util.Iterator<DockableDisplayer> iterator()
           
 void release(DockableDisplayer displayer)
          Releases a displayer that was created by this collection.
 void setController(DockController controller)
          Sets the current DockController, that controller will be made known to all DockableDisplayer created by this collection.
 void setFactory(DisplayerFactory factory)
          Sets the factory that will create new DockableDisplayer when needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

station

private DockStation station
the station for which displayers are created


controller

private DockController controller
the current controller, all displayer should know this controller


factory

private DisplayerFactory factory
a factory used to create new displayers


displayers

private java.util.List<DockableDisplayer> displayers
the set of displayers that are fetched but not released

Constructor Detail

DisplayerCollection

public DisplayerCollection(DockStation station,
                           DisplayerFactory factory)
Creates a new collection

Parameters:
station - the station for which DockableDisplayer will be created
factory - the factory that is initially used to create displayers
Method Detail

iterator

public java.util.Iterator<DockableDisplayer> iterator()
Specified by:
iterator in interface java.lang.Iterable<DockableDisplayer>

fetch

public DockableDisplayer fetch(Dockable dockable,
                               DockTitle title)
Creates a new DockableDisplayer using the factory of this collection. This method also sets the title, station and the controller property of the displayer.
If the displayer is no longer needed, then it should be released

Parameters:
dockable - the Dockable which will be shown on the displayer.
title - the title which will be shown on the displayer, might be null
Returns:
the new displayer

release

public void release(DockableDisplayer displayer)
Releases a displayer that was created by this collection.

Parameters:
displayer - the displayer to release

setFactory

public void setFactory(DisplayerFactory factory)
Sets the factory that will create new DockableDisplayer when needed.

Parameters:
factory - the new factory, not null

setController

public void setController(DockController controller)
Sets the current DockController, that controller will be made known to all DockableDisplayer created by this collection.

Parameters:
controller - the new controller, can be null