bibliothek.gui.dock.common.intern
Class AbstractCStation<S extends CommonDockStation<?,?>>

java.lang.Object
  extended by bibliothek.gui.dock.common.intern.AbstractCStation<S>
Type Parameters:
S - the kind of station this CStation is built upon
All Implemented Interfaces:
CStation<S>
Direct Known Subclasses:
CExternalizeArea

public abstract class AbstractCStation<S extends CommonDockStation<?,?>>
extends Object
implements CStation<S>

A simple implementation of CStation. This class adds a install(CControlAccess) and uninstall(CControlAccess) method, subclasses do not have to track or store the CControlAccess that is given in setControlAccess(CControlAccess).

Author:
Benjamin Sigg

Constructor Summary
protected AbstractCStation()
          Creates a new station but does not yet initialize its fields.
  AbstractCStation(S station, String id, CLocation location)
          Creates a new station.
 
Method Summary
 CDockable asDockable()
          If this station is a CDockable as well, then this method returns the representation of this station as CDockable.
protected  CControlAccess getControl()
          Gets the currently used CControlAccess.
 CLocation getDropLocation()
          Creates a CLocation that can be used to drop a new CDockable on this station or one of its children stations.
 S getStation()
          Gets the internal representation of this CStation.
 CLocation getStationLocation()
          Gets a location which represents directly CStation.getStation().
 String getUniqueId()
          Gets a unique and constant identifier for this station
protected  void init(S station, String id, CLocation location)
          Initializes the fields of this station.
protected abstract  void install(CControlAccess access)
          Called when this station is added to a CControl.
 boolean isWorkingArea()
          Tells whether this station is a special working area or not.
 void setControlAccess(CControlAccess access)
          Called by CControl when this CStation is added or removed.
protected abstract  void uninstall(CControlAccess access)
          Called when this station is removed from a CControl.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.common.CStation
createPerspective, getTypeId
 

Constructor Detail

AbstractCStation

public AbstractCStation(S station,
                        String id,
                        CLocation location)
Creates a new station.

Parameters:
station - the internal representation of this station
id - the unique id of this station
location - a location that points directly to this station

AbstractCStation

protected AbstractCStation()
Creates a new station but does not yet initialize its fields. Subclasses should call init(CommonDockStation, String, CLocation).

Method Detail

init

protected void init(S station,
                    String id,
                    CLocation location)
Initializes the fields of this station.

Parameters:
station - the internal representation of this station
id - the unique id of this station
location - a location that points directly to this station

getStationLocation

public CLocation getStationLocation()
Description copied from interface: CStation
Gets a location which represents directly CStation.getStation().

Specified by:
getStationLocation in interface CStation<S extends CommonDockStation<?,?>>
Returns:
the location that will always represent the station

getDropLocation

public CLocation getDropLocation()
Description copied from interface: CStation
Creates a CLocation that can be used to drop a new CDockable on this station or one of its children stations. This method returns the "optimal spot", where the definition of "optimal spot" is up to the station itself. The default implementations however call CLocationModeManager.getDropLocation(CStation).

Specified by:
getDropLocation in interface CStation<S extends CommonDockStation<?,?>>
Returns:
the optimal spot for dropping a new CDockable or null if this station is not able to calculate the optimal spot (e.g. because the station is not visible)

getUniqueId

public String getUniqueId()
Description copied from interface: CStation
Gets a unique and constant identifier for this station

Specified by:
getUniqueId in interface CStation<S extends CommonDockStation<?,?>>
Returns:
the unique identifier

getStation

public S getStation()
Description copied from interface: CStation
Gets the internal representation of this CStation.

Specified by:
getStation in interface CStation<S extends CommonDockStation<?,?>>
Returns:
the internal representation

setControlAccess

public void setControlAccess(CControlAccess access)
Description copied from interface: CStation
Called by CControl when this CStation is added or removed. There are two actions which most stations might want to do:

Specified by:
setControlAccess in interface CStation<S extends CommonDockStation<?,?>>
Parameters:
access - access to the internals of the CControl that uses this station or null to remove all ties from a control

getControl

protected CControlAccess getControl()
Gets the currently used CControlAccess.

Returns:
access to the current CControl, can be null

isWorkingArea

public boolean isWorkingArea()
Description copied from interface: CStation
Tells whether this station is a special working area or not. It is not possible drag a child from a working area if it is registered there, or to drop a child onto a working area if it is not registered there.
Working areas must either be registered as root-station (see CControl.addStation(CStation, boolean)) or must be a SingleCDockable.

Specified by:
isWorkingArea in interface CStation<S extends CommonDockStation<?,?>>
Returns:
true if this is a working area, false otherwise

asDockable

public CDockable asDockable()
Description copied from interface: CStation
If this station is a CDockable as well, then this method returns the representation of this station as CDockable.

Specified by:
asDockable in interface CStation<S extends CommonDockStation<?,?>>
Returns:
this as dockable or null

install

protected abstract void install(CControlAccess access)
Called when this station is added to a CControl.

Parameters:
access - access to the internals of the new owner

uninstall

protected abstract void uninstall(CControlAccess access)
Called when this station is removed from a CControl.

Parameters:
access - access to the internals of the old owner