org.openbp.jaspira.gui.plugin
Class PluginPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.openbp.jaspira.gui.plugin.PluginPanel
All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.event.FocusListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, DragOrigin, InteractionClient, PluginHolder

public class PluginPanel
extends javax.swing.JPanel
implements PluginHolder, InteractionClient, DragOrigin, java.awt.event.FocusListener, java.awt.event.ComponentListener, java.awt.event.MouseListener

A plugin panel displays a plugin. It contains the plugin component as 'content pane' and a gradient title bar showing the name of the plugin and a toolbar.
If the toolbar doesn't fit into the title bar, a small icon is displayed that pops up the toolbar.
A plugin panel is always contained in a TabbedPluginContainer or a PluginDivider

Author:
Stephan Moritz
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PluginPanel(VisiblePlugin plugin)
          Constructor.
 
Method Summary
protected  void addListeners()
          Initializes various listeners.
protected  void buildToolBar(boolean fullRebuild)
          Rebuilds the title bar.
 boolean canDrag()
          If this returns false, no dragging is permitted.
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 void dragActionTriggered(java.lang.Object regionId, java.awt.Point p)
          We do not react to any action events per default.
 void dragEnded(java.awt.datatransfer.Transferable transferable)
          We do not react to any drag events per default.
 void dragStarted(java.awt.datatransfer.Transferable transferable)
          We do not react to any drag events per default.
 void dropAccepted(java.awt.datatransfer.Transferable t)
          Called when the drag has been accepted by a InteractionClient, but before it is actually imported.
 void dropCanceled(java.awt.datatransfer.Transferable t)
          Called when the drag action has been aborted, either by dropping upon a non- qualifying target or because the target reported an unsuccessful drop.
 void dropPerformed(java.awt.datatransfer.Transferable t)
          Called when the drop has been performed and the object has been inserted.
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 java.util.List getAllDropRegions(java.util.List flavors, java.awt.datatransfer.Transferable data, java.awt.event.MouseEvent mouseEvent)
          Returns a list of all regions of this client AND possible sub clients.
 java.util.List getAllImportersAt(java.awt.Point p)
          Returns all importers which will be accepted at the given point by this client or one of its sub clients.
 java.lang.String getDescription()
          Gets the description of the plugin.
 MultiIcon getDragImage()
          Gets the image for the construction of the drag cursor.
 java.util.List getDropRegions(java.util.List flavors, java.awt.datatransfer.Transferable data, java.awt.event.MouseEvent mouseEvent)
          Standard region for a plugin panel is the center of the panel.
 MultiIcon getIcon()
          Gets the icon of the plugin.
 java.util.List getImportersAt(java.awt.Point p)
          Returns all importers which will be accepted at the given point by this client.
 VisiblePlugin getPlugin()
          Returns the current plugin of this plugin holder.
 java.util.List getSubClients()
          Returns all sub clients.
 java.lang.String getSubTitle()
          Returns the sub title of this plugin of the plugin.
 TabbedPluginContainer getTabbedContainer()
          Returns the tabbed container this holder belongs to.
 java.lang.String getTitle()
          Gets the title of the plugin.
 java.awt.datatransfer.Transferable getTranferableAt(java.awt.Point p)
          Returns the Transferable for a drag Operation starting at .
 boolean importData(java.lang.Object regionId, java.awt.datatransfer.Transferable data, java.awt.Point p)
          Imports the data from the given DragAwareRegion.
protected  void initTitleBar()
          Initializes the title bar of the panel.
 void mouseClicked(java.awt.event.MouseEvent e)
          Used to recognize clicks on the panel or title bar and get the focus.
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          Used to recognize clicks on the panel or title bar and get the focus.
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void removeListeners()
          Removes all listeners.
 void requestFocus()
          The component requests the focus.
protected  boolean requiresToolbarRebuildOnSizeChange()
          Checks if a toolbar rebuild due to a size change of the panel is required.
protected  boolean shouldDisplayToolbarPopup()
          Checks if a toolbar popup button instead of the entire toolbar should be displayed.
 void showHolder(boolean changePage)
          Requests the plugin holder to become visible.
 java.lang.String toString()
          Returns a string representation of this object.
 void unlinkHolder()
          Removes the plugin panel from its container.
 void updateHolder(boolean fullRebuild)
          Rebuilds the title, tool and menu bars of the holder.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PluginPanel

public PluginPanel(VisiblePlugin plugin)
Constructor.

Parameters:
plugin - Plugin that should be held by this panel
Method Detail

initTitleBar

protected final void initTitleBar()
Initializes the title bar of the panel.


addListeners

protected final void addListeners()
Initializes various listeners.


removeListeners

protected final void removeListeners()
Removes all listeners.


toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.awt.Component

getPlugin

public VisiblePlugin getPlugin()
Returns the current plugin of this plugin holder.

Returns:
The plugin or null if the plugin panel is empty

getTabbedContainer

public TabbedPluginContainer getTabbedContainer()
Returns the tabbed container this holder belongs to.

Returns:
The container or null if the holder is not contained in a TabbedPluginContainer

buildToolBar

protected void buildToolBar(boolean fullRebuild)
Rebuilds the title bar. The title bar consists of:
- Name and Icon
- User toolbar
- close button

Parameters:
fullRebuild - true Causes a full container environment including toolbar rebuild
false Updates the container title only Also check if this would cause any change in the toolbar before rebuilding. When rebuilding, the plugin will use the cached toolbar.

requiresToolbarRebuildOnSizeChange

protected boolean requiresToolbarRebuildOnSizeChange()
Checks if a toolbar rebuild due to a size change of the panel is required.


shouldDisplayToolbarPopup

protected boolean shouldDisplayToolbarPopup()
Checks if a toolbar popup button instead of the entire toolbar should be displayed.

Returns:
true The panel is too small, display just the single button to pop it open.
false The panel is large enough to display the entire toolbar.

updateHolder

public void updateHolder(boolean fullRebuild)
Description copied from interface: PluginHolder
Rebuilds the title, tool and menu bars of the holder.

Specified by:
updateHolder in interface PluginHolder
Parameters:
fullRebuild - true Causes a full environment rebuild including menu and toolbar rebuild
false Updates the holder's title only and checks for toolbar size change

unlinkHolder

public void unlinkHolder()
Removes the plugin panel from its container.

Specified by:
unlinkHolder in interface PluginHolder

showHolder

public void showHolder(boolean changePage)
Requests the plugin holder to become visible.

Specified by:
showHolder in interface PluginHolder
Parameters:
changePage - true Switches the page if the container is not a part of the current page.
false Makes the container the active container on its page, but does not switch to the new page.

requestFocus

public void requestFocus()
The component requests the focus. A plugin container can't have the focus - forward the request to the plugin.

Overrides:
requestFocus in class javax.swing.JComponent

getTitle

public java.lang.String getTitle()
Gets the title of the plugin.


getSubTitle

public java.lang.String getSubTitle()
Returns the sub title of this plugin of the plugin.


getDescription

public java.lang.String getDescription()
Gets the description of the plugin.


getIcon

public MultiIcon getIcon()
Gets the icon of the plugin.


dragStarted

public void dragStarted(java.awt.datatransfer.Transferable transferable)
We do not react to any drag events per default.

Specified by:
dragStarted in interface InteractionClient
Parameters:
transferable - Transferable to be dragged

dragEnded

public void dragEnded(java.awt.datatransfer.Transferable transferable)
We do not react to any drag events per default.

Specified by:
dragEnded in interface InteractionClient
Parameters:
transferable - Transferable that has been dragged

dragActionTriggered

public void dragActionTriggered(java.lang.Object regionId,
                                java.awt.Point p)
We do not react to any action events per default.

Specified by:
dragActionTriggered in interface InteractionClient
Parameters:
regionId - Id of the region to import into (see BasicDropRegion.getId)
p - Current mouse position in screen coordinates

getDropRegions

public java.util.List getDropRegions(java.util.List flavors,
                                     java.awt.datatransfer.Transferable data,
                                     java.awt.event.MouseEvent mouseEvent)
Standard region for a plugin panel is the center of the panel. In order to register your own zones, do not override this, override getUserRegions () instead.

Specified by:
getDropRegions in interface InteractionClient
Parameters:
flavors - List of data flavors to check
data - Transferable to be imported
mouseEvent - Mouse event that initiated the drag action
Returns:
A list of DragAwareRegion object or null if the drop client cannot satisfy at least one of the supplied data flavors.
The list will contain only regions that belong directly to this drop client.
See Also:
InteractionClient.getDropRegions(List, Transferable, MouseEvent)

getAllDropRegions

public final java.util.List getAllDropRegions(java.util.List flavors,
                                              java.awt.datatransfer.Transferable data,
                                              java.awt.event.MouseEvent mouseEvent)
Description copied from interface: InteractionClient
Returns a list of all regions of this client AND possible sub clients.

Specified by:
getAllDropRegions in interface InteractionClient
Parameters:
flavors - List of data flavors to check
data - Transferable to import
mouseEvent - Mouse event that initiated the drag action
Returns:
A list of DragAwareRegion object or null if the drop client or one of its sub clients cannot satisfy at least one of the supplied data flavors
See Also:
InteractionClient.getAllDropRegions(List, Transferable, MouseEvent)

getImportersAt

public java.util.List getImportersAt(java.awt.Point p)
Description copied from interface: InteractionClient
Returns all importers which will be accepted at the given point by this client.

Specified by:
getImportersAt in interface InteractionClient
Parameters:
p - Current mouse position in screen coordinates
Returns:
A list of Importer objects or null

getAllImportersAt

public java.util.List getAllImportersAt(java.awt.Point p)
Description copied from interface: InteractionClient
Returns all importers which will be accepted at the given point by this client or one of its sub clients.

Specified by:
getAllImportersAt in interface InteractionClient
Parameters:
p - Current mouse position in screen coordinates
Returns:
A list of Importer objects or null

importData

public final boolean importData(java.lang.Object regionId,
                                java.awt.datatransfer.Transferable data,
                                java.awt.Point p)
Imports the data from the given DragAwareRegion. Handles imports from the plugin's standard regions.

Specified by:
importData in interface InteractionClient
Parameters:
regionId - Id of the region to import into (see BasicDropRegion.getId)
data - Transferable to import
p - Drop point in glass coordinates
Returns:
true The data was successfully imported.
false An error occured while importing the data.

getSubClients

public java.util.List getSubClients()
Returns all sub clients.

Specified by:
getSubClients in interface InteractionClient
Returns:
A list of InteractionClient objects or null if this drop client doesn't have sub drop clients.
Returns the sub clients of the plugin contained within this panel.

canDrag

public boolean canDrag()
Description copied from interface: DragOrigin
If this returns false, no dragging is permitted.

Specified by:
canDrag in interface DragOrigin

dropAccepted

public void dropAccepted(java.awt.datatransfer.Transferable t)
Description copied from interface: DragOrigin
Called when the drag has been accepted by a InteractionClient, but before it is actually imported.

Specified by:
dropAccepted in interface DragOrigin
Parameters:
t - Dragged transferable

dropCanceled

public void dropCanceled(java.awt.datatransfer.Transferable t)
Description copied from interface: DragOrigin
Called when the drag action has been aborted, either by dropping upon a non- qualifying target or because the target reported an unsuccessful drop.

Specified by:
dropCanceled in interface DragOrigin
Parameters:
t - Dragged transferable

dropPerformed

public void dropPerformed(java.awt.datatransfer.Transferable t)
Description copied from interface: DragOrigin
Called when the drop has been performed and the object has been inserted.

Specified by:
dropPerformed in interface DragOrigin
Parameters:
t - Dragged transferable

getTranferableAt

public java.awt.datatransfer.Transferable getTranferableAt(java.awt.Point p)
Description copied from interface: DragOrigin
Returns the Transferable for a drag Operation starting at .

Specified by:
getTranferableAt in interface DragOrigin
Parameters:
p - The location at which the drag started in component local coordinates
Returns:
The Transferable to drag

getDragImage

public MultiIcon getDragImage()
Description copied from interface: DragOrigin
Gets the image for the construction of the drag cursor.

Specified by:
getDragImage in interface DragOrigin
Returns:
The image or null if no special drag image is to be constructed

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener
See Also:
ComponentListener.componentHidden(java.awt.event.ComponentEvent)

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener
See Also:
ComponentListener.componentMoved(java.awt.event.ComponentEvent)

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener
See Also:
ComponentListener.componentResized(java.awt.event.ComponentEvent)

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener
See Also:
ComponentListener.componentShown(java.awt.event.ComponentEvent)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Used to recognize clicks on the panel or title bar and get the focus.

Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Used to recognize clicks on the panel or title bar and get the focus.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)


Copyright © 2011. All Rights Reserved.