bibliothek.gui.dock.title
Class DockTitleRequest

java.lang.Object
  extended by bibliothek.gui.dock.title.DockTitleRequest

public abstract class DockTitleRequest
extends Object

Set of information and callback used to obtain a DockTitle from a DockTitleFactory.

Author:
Benjamin Sigg

Constructor Summary
DockTitleRequest(DockStation parent, Dockable target, DockTitleVersion version)
          Creates a new request.
 
Method Summary
 void answer(DockTitle title)
          Informs this request that title should be shown.
protected abstract  void answer(DockTitle previous, DockTitle title)
          Called whenever a new title should be shown.
protected  void executeRequestList()
          Asks all sources for a DockTitle, stops as soon as one source called answer(DockTitle).
 DockTitle getAnswer()
          Gets the last answer made to this request.
 DockStation getParent()
          Gets the station that will show the title.
 Dockable getTarget()
          Gets the Dockable for which the title is requested.
 DockTitleVersion getVersion()
          Gets the usage of the new title.
 void install()
          Makes this request active.
protected  boolean isAnswered()
          Tells whether answer(DockTitle) was called since the last request().
 boolean isInstalled()
          Tells whether this request is currently installed on its version.
 void request()
          Asks for a new title and may trigger answer(DockTitle, DockTitle).
 void requestDockTitle(DockTitleRequest request)
          May answer a request for a title.
 void requestNull()
          Asks this request to simulate a call to request() which is answered with null
 void uninstall()
          Makes this request inactive, calls to answer(DockTitle, DockTitle) will no longer happen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DockTitleRequest

public DockTitleRequest(DockStation parent,
                        Dockable target,
                        DockTitleVersion version)
Creates a new request.

Parameters:
parent - the element which will show the title, can be null
target - the element for which the title will be shown, not null
version - what kind of title is requested, not null
Method Detail

install

public void install()
Makes this request active. After installation the method answer(DockTitle, DockTitle) may be called anytimes. Please note that installing does not automatically trigger a call to request().


uninstall

public void uninstall()
Makes this request inactive, calls to answer(DockTitle, DockTitle) will no longer happen.


isInstalled

public boolean isInstalled()
Tells whether this request is currently installed on its version.

Returns:
true if this request is active

getTarget

public Dockable getTarget()
Gets the Dockable for which the title is requested.

Returns:
the target element

getParent

public DockStation getParent()
Gets the station that will show the title. The result might be null if the title is shown outside any station.

Returns:
the parent of getTarget() or null

getVersion

public DockTitleVersion getVersion()
Gets the usage of the new title.

Returns:
the usage, not null

answer

protected abstract void answer(DockTitle previous,
                               DockTitle title)
Called whenever a new title should be shown.

Parameters:
previous - the title that was used previously, can be null
title - the new title, may be null

request

public void request()
Asks for a new title and may trigger answer(DockTitle, DockTitle). This method may be called from anyone, not just the owner of this request.


isAnswered

protected boolean isAnswered()
Tells whether answer(DockTitle) was called since the last request().

Returns:
true if there is an answer

executeRequestList

protected void executeRequestList()
Asks all sources for a DockTitle, stops as soon as one source called answer(DockTitle).


requestDockTitle

public void requestDockTitle(DockTitleRequest request)
May answer a request for a title. Normally request will be this, but subclasses may forward the request to other DockTitleRequest. The default behavior of this method is to do nothing.

Parameters:
request - the request to answer

requestNull

public void requestNull()
Asks this request to simulate a call to request() which is answered with null


answer

public void answer(DockTitle title)
Informs this request that title should be shown. This method can be called more than once to show different titles.
An answer must fulfill some rules:

Parameters:
title - the new title or null to show no title at all
Throws:
IllegalArgumentException - if the title does not met the specifications described above
IllegalStateException - if request() is not currently executing

getAnswer

public DockTitle getAnswer()
Gets the last answer made to this request.

Returns:
the last answer, may be null