bibliothek.gui.dock.station
Class AbstractDockStation

java.lang.Object
  extended by bibliothek.gui.dock.station.AbstractDockStation
All Implemented Interfaces:
DockElement, DockStation
Direct Known Subclasses:
ScreenDockStation

public abstract class AbstractDockStation
extends Object
implements DockStation

An abstract implementation of DockStation. This station has the ability to send events to registered DockStationListeners.

Author:
Benjamin Sigg

Field Summary
protected  DockStationListenerManager listeners
          The list of DockStationListeners which can be used to send events to all listeners.
 
Constructor Summary
AbstractDockStation()
           
 
Method Summary
 boolean accept(Dockable child)
          Tells whether this station accepts child as a new child, or refuses child.
 void addDockStationListener(DockStationListener listener)
          Adds a listener to this station.
protected abstract  void callDockUiUpdateTheme()
          Calls the method DockUI.
 boolean canCompare(DockStation station)
          Tells whether this station knows a rule how to compare itself with station.
 void changed(Dockable dockable, DockTitle title, boolean active)
          Called by the DockController of this station to indicate that the active-state of title has been changed.
 int compare(DockStation station)
          Compares this station with station.
 DockController getController()
          Gets the controller that currently is associated with this DockElement.
 DockTheme getTheme()
          Gets the current theme of this station.
 boolean isStationVisible()
          Tells whether this station is visible or not.
 boolean isVisible(Dockable dockable)
          Tells whether the child dockable is visible or not.
 void removeDockStationListener(DockStationListener listener)
          Removes a listener from this station.
 void requestChildDockTitle(DockTitleRequest request)
          Provides a DockTitle for a child of this station.
 void setController(DockController controller)
          Sets the controller of this station.
 void updateTheme()
          Updates the DockTheme of this station.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.DockStation
canDrag, canReplace, drag, draw, drop, drop, drop, forget, getDirectActionOffers, getDockable, getDockableCount, getDockableProperty, getFrontDockable, getIndirectActionOffers, getPlaceholders, getStationBounds, isInOverrideZone, move, move, prepareDrop, prepareMove, replace, replace, setFrontDockable, setPlaceholders
 
Methods inherited from interface bibliothek.gui.dock.DockElement
asDockable, asDockStation, getFactoryID
 

Field Detail

listeners

protected DockStationListenerManager listeners
The list of DockStationListeners which can be used to send events to all listeners.

Constructor Detail

AbstractDockStation

public AbstractDockStation()
Method Detail

setController

public void setController(DockController controller)
Description copied from interface: DockStation
Sets the controller of this station. If the station wants to show any DockTitle, then the titles have to be replaced by new instances (assuming the controller is really new). The title has to get new DockTitleVersions through the DockTitleManager of controller.
An argument of null means that this station is currently not shown.

Specified by:
setController in interface DockStation
Parameters:
controller - the owner of this station, can be null

getController

public DockController getController()
Description copied from interface: DockElement
Gets the controller that currently is associated with this DockElement.

Specified by:
getController in interface DockElement
Specified by:
getController in interface DockStation
Returns:
the controller or null
See Also:
DockStation.setController(DockController)

getTheme

public DockTheme getTheme()
Description copied from interface: DockStation
Gets the current theme of this station. The theme can be null, but that means that the station is not fully initialized, and might not work correct.

Specified by:
getTheme in interface DockStation
Returns:
the theme of this station or null.

updateTheme

public void updateTheme()
Description copied from interface: DockStation
Updates the DockTheme of this station. The new theme has to be read from the controller of this station. If the controller is null, this method should return immediately.
You may use DockUI.updateTheme(DockStation, DockFactory) to implement this method.

Specified by:
updateTheme in interface DockStation

callDockUiUpdateTheme

protected abstract void callDockUiUpdateTheme()
                                       throws IOException
Calls the method DockUI.DockUI.updateTheme(DockStation, DockFactory) with this as the first argument, and an appropriate factory as the second argument.

Throws:
IOException - if the DockUI throws an exception

addDockStationListener

public void addDockStationListener(DockStationListener listener)
Description copied from interface: DockStation
Adds a listener to this station. The station has to invoke the methods of the listener such that its requirements are full filled.

Specified by:
addDockStationListener in interface DockStation
Parameters:
listener - the listener to add

removeDockStationListener

public void removeDockStationListener(DockStationListener listener)
Description copied from interface: DockStation
Removes a listener from this station.

Specified by:
removeDockStationListener in interface DockStation
Parameters:
listener - the listener to remove

isVisible

public boolean isVisible(Dockable dockable)
Description copied from interface: DockStation
Tells whether the child dockable is visible or not. Visible means that the component of dockable can be seen by the user. The result must be false if this station is not visible.

Specified by:
isVisible in interface DockStation
Parameters:
dockable - the child whose visibility-state is questioned
Returns:
whether dockable is visible or not
See Also:
DockStation.isStationVisible()

isStationVisible

public boolean isStationVisible()
Description copied from interface: DockStation
Tells whether this station is visible or not. For example a station on a JFrame is not visible if the frame is minimized.

Specified by:
isStationVisible in interface DockStation
Returns:
whether this station is visible

accept

public boolean accept(Dockable child)
Description copied from interface: DockStation
Tells whether this station accepts child as a new child, or refuses child. The user will not be able to drop a Dockable onto this station if this method returns false.

Specified by:
accept in interface DockStation
Parameters:
child - a Dockable which may become a child
Returns:
true if child is accepted

canCompare

public boolean canCompare(DockStation station)
Description copied from interface: DockStation
Tells whether this station knows a rule how to compare itself with station. See DockStation.compare(DockStation) for more details.

Specified by:
canCompare in interface DockStation
Parameters:
station - another station
Returns:
true if a call to compare will not end in an exception and return another value than 0

compare

public int compare(DockStation station)
Description copied from interface: DockStation
Compares this station with station. The comparison is needed if the stations bounds of the two station have common points. On a drag-event, the controller needs a way to decide which station is more important (and receives the opportunity to get a new child first). The controller will use the method compare to do this. This method works like Comparable.compareTo(Object).

Specified by:
compare in interface DockStation
Parameters:
station - another station
Returns:
a number less/equal/higher than zero, if this station has higher/equal/lesser priority than station.

changed

public void changed(Dockable dockable,
                    DockTitle title,
                    boolean active)
Description copied from interface: DockStation
Called by the DockController of this station to indicate that the active-state of title has been changed. This station should call the method title.changed with an appropriate event. The station may add some additional information to this call.

Specified by:
changed in interface DockStation
Parameters:
dockable - the child whose title is changed
title - the changed title, may not be bound
active - the new state of the title

requestChildDockTitle

public void requestChildDockTitle(DockTitleRequest request)
Description copied from interface: DockStation
Provides a DockTitle for a child of this station. This method must call DockTitleRequest.answer(DockTitle) to set the result.
Most DockStations won't have the need to implement this method, leaving it empty will advice the framework to use another source for new DockTitles.

Specified by:
requestChildDockTitle in interface DockStation
Parameters:
request - the request to answer, not null