bibliothek.gui.dock.util
Class WindowProviderWrapper

java.lang.Object
  extended by bibliothek.gui.dock.util.WindowProviderWrapper
All Implemented Interfaces:
WindowProvider

public class WindowProviderWrapper
extends Object
implements WindowProvider

A wrapper around another WindowProvider, allows to exchange providers without the need to reattach WindowProviderListeners.

Author:
Benjamin Sigg

Constructor Summary
WindowProviderWrapper()
           
 
Method Summary
 void addWindowProviderListener(WindowProviderListener listener)
          Adds a new listener to this provider.
protected  void fireVisibilityChanged(boolean showing)
          Informs all listeners that the windows visibility has changed.
protected  void fireWindowChanged(Window window)
          Informs all listeners that the window has changed.
 WindowProvider getDelegate()
          Gets the provider which is be used by this to find a window.
 boolean isShowing()
          Tells whether this window represents a window that is visible.
protected  WindowProviderListener[] listeners()
          Gets all currently registered listeners.
 void removeWindowProviderListener(WindowProviderListener listener)
          Removes a listener from this provider
 Window searchWindow()
          Tries to find a window.
 void setDelegate(WindowProvider delegate)
          Sets the provider which will be used to find a window.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindowProviderWrapper

public WindowProviderWrapper()
Method Detail

addWindowProviderListener

public void addWindowProviderListener(WindowProviderListener listener)
Description copied from interface: WindowProvider
Adds a new listener to this provider. The listener should be called when the window provided by this object changes.

Specified by:
addWindowProviderListener in interface WindowProvider
Parameters:
listener - the new listener

removeWindowProviderListener

public void removeWindowProviderListener(WindowProviderListener listener)
Description copied from interface: WindowProvider
Removes a listener from this provider

Specified by:
removeWindowProviderListener in interface WindowProvider
Parameters:
listener - the listener to remove

listeners

protected WindowProviderListener[] listeners()
Gets all currently registered listeners.

Returns:
the list of listeners.

fireWindowChanged

protected void fireWindowChanged(Window window)
Informs all listeners that the window has changed.

Parameters:
window - the new window, might be null

fireVisibilityChanged

protected void fireVisibilityChanged(boolean showing)
Informs all listeners that the windows visibility has changed.

Parameters:
showing - the new visibility state

setDelegate

public void setDelegate(WindowProvider delegate)
Sets the provider which will be used to find a window.

Parameters:
delegate - the new provider, can be null

getDelegate

public WindowProvider getDelegate()
Gets the provider which is be used by this to find a window.

Returns:
the provider, can be null

searchWindow

public Window searchWindow()
Description copied from interface: WindowProvider
Tries to find a window. The result should either be a Frame or a Dialog, and a plain Window only as last resort. If possible the main-frame or another important window that will not be closed soon should be returned. Visible windows are preferred over non visible ones. This method is not guaranteed to have success, null is a valid result. This method is not required to return always the same window, however the WindowProviderListeners should be informed when the result changes.

Specified by:
searchWindow in interface WindowProvider
Returns:
if possible a visible Frame which won't be closed in the near future, any window which does not fulfill the requirements or null if no window is available at all.

isShowing

public boolean isShowing()
Description copied from interface: WindowProvider
Tells whether this window represents a window that is visible. Under normal circumstances this method would return:
Window window = sarchWindow();
return window == null ? false : window.isShowing();

This method is explicitly allowed to return any value it likes. The result of this method does not have to correspond with reality.

Specified by:
isShowing in interface WindowProvider
Returns:
whether this providers window is visible or not