bibliothek.gui.dock.control.focus
Class RepeatingFocusRequest

java.lang.Object
  extended by bibliothek.gui.dock.control.focus.RepeatingFocusRequest
All Implemented Interfaces:
FocusRequest

public class RepeatingFocusRequest
extends Object
implements FocusRequest

Ensures that a specific Component is focused by calling Component.requestFocus() multiple times.

Author:
Benjamin Sigg

Constructor Summary
RepeatingFocusRequest(DockElementRepresentative source, Component component)
          Creates a new request
RepeatingFocusRequest(DockElementRepresentative source, Component component, int delay, int attempts)
          Creates a new request
 
Method Summary
 boolean acceptable(Component component)
          Tells whether component would be an acceptable Component to receive the focus.
 Component getComponent()
          Gets the Component which may receive the focus.
 int getDelay()
          Gets a delay in milliseconds, the FocusController will wait executing this request until the delay has passed.
 DockElementRepresentative getSource()
          Gets the source of this request.
 FocusRequest grant(Component component)
          Called once this FocusRequest is granted, this request must now call a method like Component.requestFocusInWindow() on component.
 boolean validate(FocusController controller)
          Invoked by controller right before this request is processed.
 void veto(FocusVetoListener.FocusVeto veto)
          Informs this request of the result of calling the FocusVetoListeners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepeatingFocusRequest

public RepeatingFocusRequest(DockElementRepresentative source,
                             Component component)
Creates a new request

Parameters:
source - the element that gets focused, not null
component - the Component that actually gains the focus, not null

RepeatingFocusRequest

public RepeatingFocusRequest(DockElementRepresentative source,
                             Component component,
                             int delay,
                             int attempts)
Creates a new request

Parameters:
source - the element that gets focused, can be null
component - the Component that actually gains the focus, not null
delay - how long to wait until requesting the focus, at least 1
attempts - how often to try and gain the focus, at least 1
Method Detail

validate

public boolean validate(FocusController controller)
Description copied from interface: FocusRequest
Invoked by controller right before this request is processed. The method checks whether this request is still valid, e.g. a request may no longer be valid because it points to a Dockable that is no longer visible.

Specified by:
validate in interface FocusRequest
Parameters:
controller - the controller which will process this request
Returns:
true if this request is valid, false if this request is invalid and should be ignored

getDelay

public int getDelay()
Description copied from interface: FocusRequest
Gets a delay in milliseconds, the FocusController will wait executing this request until the delay has passed.

Specified by:
getDelay in interface FocusRequest
Returns:
the delay in milliseconds, can be 0

getSource

public DockElementRepresentative getSource()
Description copied from interface: FocusRequest
Gets the source of this request. The source may be the Dockable which receives the focus, or the Component which received a MouseEvent. The source will be used to ask the FocusVetoListeners whether to accept this request or not.

Specified by:
getSource in interface FocusRequest
Returns:
the source of this request, may be null

getComponent

public Component getComponent()
Description copied from interface: FocusRequest
Gets the Component which may receive the focus. This is no necessarily the Component that gains the focus because the FocusStrategy may choose another Component. This Component may be not focusable, not visible, not showing, or not valid in any other respect. It is the FocusController's job to correct such issues.

Specified by:
getComponent in interface FocusRequest
Returns:
the Component which may receive the focus, can be null

acceptable

public boolean acceptable(Component component)
Description copied from interface: FocusRequest
Tells whether component would be an acceptable Component to receive the focus. This method usually is called when FocusRequest.getComponent() returned an invalid Component (e.g. null or a component that is not focusable) and that Component gets replaced.

Specified by:
acceptable in interface FocusRequest
Parameters:
component - the component that might gain the focus
Returns:
true if this request approves on component replacing the result of FocusRequest.getComponent()

veto

public void veto(FocusVetoListener.FocusVeto veto)
Description copied from interface: FocusRequest
Informs this request of the result of calling the FocusVetoListeners. This method is called after FocusRequest.validate(FocusController).

Specified by:
veto in interface FocusRequest
Parameters:
veto - the veto that was cast, including no veto

grant

public FocusRequest grant(Component component)
Description copied from interface: FocusRequest
Called once this FocusRequest is granted, this request must now call a method like Component.requestFocusInWindow() on component.

Specified by:
grant in interface FocusRequest
Parameters:
component - the Component which gains the focus. Usually this Component is valid in the sense of that it is focusable, visible and showing. There are no guarantees for this properties tough.
Returns:
a new FocusRequest that will be executed. If the result of FocusRequest.getSource() of this and of the result matches, and if the result of FocusRequest.getComponent() is the same as component, then the FocusController will accept the request without calling neither FocusVetoListener nor FocusStrategy. In any other case the request will be treated like a completely new request. The result of this method can also be null. The result of this method can also by this.