bibliothek.gui.dock.util
Class SimpleDockElementRepresentative

java.lang.Object
  extended by bibliothek.gui.dock.util.SimpleDockElementRepresentative
All Implemented Interfaces:
DockElementRepresentative

public class SimpleDockElementRepresentative
extends Object
implements DockElementRepresentative

A very simplistic implementation of DockElementRepresentative, it just adds a listener to a Component.

Author:
Benjamin Sigg

Constructor Summary
SimpleDockElementRepresentative(DockElement element, Component component)
          Creates a new SimpleDockElementRepresentative.
 
Method Summary
 void addMouseInputListener(MouseInputListener listener)
          Adds a listener to this representative, it is not defined what to do with that listener, but most subclasses would just add the listener to their component.
 Component getComponent()
          Gets the Component which represents the element.
 DockElement getElement()
          Gets the element which is represented by this.
 Point getPopupLocation(Point click, boolean popupTrigger)
          Tells whether a popup menu should be opened when the user clicks at click with the mouse.
 boolean isUsedAsTitle()
          Tells whether this DockElementRepresentative is used as title.
 void removeMouseInputListener(MouseInputListener listener)
          Removes a listener from this representative.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDockElementRepresentative

public SimpleDockElementRepresentative(DockElement element,
                                       Component component)
Creates a new SimpleDockElementRepresentative.

Parameters:
element - the element which is represented by this
component - the component to which this adds listeners
Method Detail

addMouseInputListener

public void addMouseInputListener(MouseInputListener listener)
Description copied from interface: DockElementRepresentative
Adds a listener to this representative, it is not defined what to do with that listener, but most subclasses would just add the listener to their component. It is valid to do nothing.

Specified by:
addMouseInputListener in interface DockElementRepresentative
Parameters:
listener - the new listener

getComponent

public Component getComponent()
Description copied from interface: DockElementRepresentative
Gets the Component which represents the element. The result of this method must not change.

Specified by:
getComponent in interface DockElementRepresentative
Returns:
the component, never null

getElement

public DockElement getElement()
Description copied from interface: DockElementRepresentative
Gets the element which is represented by this. The result of this method must not change.

Specified by:
getElement in interface DockElementRepresentative
Returns:
the element, never null

getPopupLocation

public Point getPopupLocation(Point click,
                              boolean popupTrigger)
Description copied from interface: DockElementRepresentative
Tells whether a popup menu should be opened when the user clicks at click with the mouse. If yes, then the top left edge of the popup should be returned, otherwise null should be returned.

Specified by:
getPopupLocation in interface DockElementRepresentative
Parameters:
click - the location where the user clicked with the mouse
popupTrigger - whether the invocation is the systems popup trigger or not. Many implementations of this method will return click in case of true, and null in case of false
Returns:
the preferred location of a popup or null if no popup-menu should be opened

isUsedAsTitle

public boolean isUsedAsTitle()
Description copied from interface: DockElementRepresentative
Tells whether this DockElementRepresentative is used as title.
Some modules grant more rights to titles than to non-titles, i.e. a DockRelocator can allow drag & drop only for titles.
Normally a Dockable should have only one element that is a title, so if in doubt return false.

Specified by:
isUsedAsTitle in interface DockElementRepresentative
Returns:
true if this representative should be seen as title

removeMouseInputListener

public void removeMouseInputListener(MouseInputListener listener)
Description copied from interface: DockElementRepresentative
Removes a listener from this representative.

Specified by:
removeMouseInputListener in interface DockElementRepresentative
Parameters:
listener - the listener to remove