org.openbp.jaspira.gui.plugin
Class TabbedPluginContainer

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.TabbedPluginContainer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, DragOrigin, InteractionClient, PluginContainer

public class TabbedPluginContainer
extends javax.swing.JPanel
implements PluginContainer, InteractionClient, DragOrigin, javax.swing.event.ChangeListener

A tabbed plugin container displays plugins in a combination of tabbed panes and tabs themselves. It supports DnD of tabs to other plugin containers.

Author:
Stephan Moritz
See Also:
Serialized Form

Nested Class Summary
static class TabbedPluginContainer.ChangeAction
          Action that selects the next component to the left.
static class TabbedPluginContainer.NumberAction
          Action that selects the component with the given number.
 
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
static TabbedPluginContainer.NumberAction[] numberActions
          Contains the actions for selecting a given tab.
protected  javax.swing.JTabbedPane tabbedPane
          The TabbedPane which holds the actual data.
 
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 org.openbp.jaspira.gui.plugin.PluginContainer
CENTER, EAST, NORTH, REGION_CENTER, REGION_EAST, REGION_NORTH, REGION_SOUTH, REGION_WEST, SOUTH, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TabbedPluginContainer()
          Constructor.
TabbedPluginContainer(PluginState state)
          Constructor.
TabbedPluginContainer(VisiblePlugin plugin)
          Constructor.
 
Method Summary
 void addContainer(PluginContainer pc)
          Adds all Plugins of the given Container to this pane.
 void addPlugin(VisiblePlugin p)
          Adds a plugin as last tab and show it.
 void addPlugin(VisiblePlugin p, boolean activateplugin)
          Adds a plugin as the last tab.
 void addPlugin(VisiblePlugin p, int slot)
          Adds a plugin to a given slot, i\.e\. at a certain tabindex.
 boolean canDrag()
          If this returns false, no dragging is permitted.
protected  void createTabPane()
          Creates the tab pane if not done yet.
 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.
 VisiblePlugin getActivePlugin()
          Returns the currently active plugin, which is incidently the visible plugin.
 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.
 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 regions for a plugin container are regions at the four corners as well as the on the plugin itself.
 java.util.List getImportersAt(java.awt.Point p)
          Returns all importers which will be accepted at the given point by this client.
 int getNumberOfPlugins()
          Returns the number of plugins in this container.
 JaspiraPage getPage()
          Returns the page level parent plugin of this plugin.
 PluginContainer getParentContainer()
          Returns the parent Container of this tabbed pane (always a PluginDivider).
 java.util.List getPlugins()
          Returns the list of plugins held by this container.
 VisiblePlugin getSelectedPlugin()
          Returns the plugin that is currently visible.
 java.util.List getSubClients()
          Returns all sub clients.
 java.awt.datatransfer.Transferable getTranferableAt(java.awt.Point p)
          Returns the Transferable for a drag Operation starting at .
 java.util.List getVisiblePlugins()
          Returns a list containing the currently visible plugin.
 boolean importData(java.lang.Object regionId, java.awt.datatransfer.Transferable data, java.awt.Point p)
          Imports the data from the given DragAwareRegion.
 boolean isAlwaysTabs()
          Gets the flag if the container should always show tabs, even if only one plugin is showed.
 boolean isSolid()
          Gets the flag if the container is solid, i\.e\. doesn't remove itself if it is empty.
 void removePlugin(VisiblePlugin p)
          Remove a plugin from this container.
 void setAlwaysTabs(boolean alwaysTabs)
          Sets the flag if the container should always show tabs, even if only one plugin is showed.
 void setSelectedPlugin(VisiblePlugin plugin)
          Makes the given plugin visible.
 void setSolid(boolean solid)
          Sets the flag if the container is solid, i\.e\. doesn't remove itself if it is empty.
 void sliceContainer(PluginContainer toInsert, PluginContainer currentContainer, java.lang.String constraint)
          Hand the slice request up to the parent.
 void stateChanged(javax.swing.event.ChangeEvent e)
          Request the focus for the newly activated plugin on tab change by the user.
protected  void synchronizeComponents(VisiblePlugin pluginToActivate, boolean preventFocusChange)
          Synchronizes the components of the container with the list of plugins.
 java.lang.String toString()
          Returns a string representation of this object.
 void updateContainer(boolean fullRebuild)
          Rebuilds the enviroment of the container (title, toolbar, menu).
 
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, 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
 

Field Detail

numberActions

public static final TabbedPluginContainer.NumberAction[] numberActions
Contains the actions for selecting a given tab. Can be static since the corresponding ActionEvent contains the source.


tabbedPane

protected javax.swing.JTabbedPane tabbedPane
The TabbedPane which holds the actual data.

Constructor Detail

TabbedPluginContainer

public TabbedPluginContainer()
Constructor.


TabbedPluginContainer

public TabbedPluginContainer(VisiblePlugin plugin)
Constructor.

Parameters:
plugin - Plugin to add to the container

TabbedPluginContainer

public TabbedPluginContainer(PluginState state)
Constructor.

Parameters:
state - Creates a container that contains a new plugin that will be constructed from the given plugin state using the PluginMgr
Method Detail

toString

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

Overrides:
toString in class java.awt.Component

createTabPane

protected void createTabPane()
Creates the tab pane if not done yet.


isSolid

public boolean isSolid()
Gets the flag if the container is solid, i\.e\. doesn't remove itself if it is empty.


setSolid

public void setSolid(boolean solid)
Sets the flag if the container is solid, i\.e\. doesn't remove itself if it is empty.


isAlwaysTabs

public boolean isAlwaysTabs()
Gets the flag if the container should always show tabs, even if only one plugin is showed.


setAlwaysTabs

public void setAlwaysTabs(boolean alwaysTabs)
Sets the flag if the container should always show tabs, even if only one plugin is showed.


addContainer

public void addContainer(PluginContainer pc)
Adds all Plugins of the given Container to this pane.


addPlugin

public void addPlugin(VisiblePlugin p)
Adds a plugin as last tab and show it.

Specified by:
addPlugin in interface PluginContainer
Parameters:
p - Plugin to add

addPlugin

public void addPlugin(VisiblePlugin p,
                      boolean activateplugin)
Adds a plugin as the last tab. If activateplugin is true the plugin will be shown.


addPlugin

public void addPlugin(VisiblePlugin p,
                      int slot)
Adds a plugin to a given slot, i\.e\. at a certain tabindex. Calling this should only be necessary during initialization.


sliceContainer

public void sliceContainer(PluginContainer toInsert,
                           PluginContainer currentContainer,
                           java.lang.String constraint)
Hand the slice request up to the parent. Should never be called.

Specified by:
sliceContainer in interface PluginContainer
Parameters:
constraint - PluginContainer.NORTH/PluginContainer.SOUTH/PluginContainer.EAST/PluginContainer.WEST
toInsert - Containert to insert
currentContainer - Currrent container that shall be replaced

removePlugin

public void removePlugin(VisiblePlugin p)
Remove a plugin from this container.

Specified by:
removePlugin in interface PluginContainer
Parameters:
p - Plugin to remove

synchronizeComponents

protected void synchronizeComponents(VisiblePlugin pluginToActivate,
                                     boolean preventFocusChange)
Synchronizes the components of the container with the list of plugins.

Parameters:
pluginToActivate - Plugin to active after the synchronization or null
preventFocusChange - true Does not change the currently focused plugin.
false Changes the focused plugin to the currently selected plugin.

getParentContainer

public PluginContainer getParentContainer()
Returns the parent Container of this tabbed pane (always a PluginDivider).

Specified by:
getParentContainer in interface PluginContainer
Returns:
The parent container or null

getSelectedPlugin

public VisiblePlugin getSelectedPlugin()
Returns the plugin that is currently visible.


setSelectedPlugin

public void setSelectedPlugin(VisiblePlugin plugin)
Makes the given plugin visible.

Parameters:
plugin - Plugin to show

getNumberOfPlugins

public int getNumberOfPlugins()
Returns the number of plugins in this container.


getPlugins

public java.util.List getPlugins()
Returns the list of plugins held by this container.

Specified by:
getPlugins in interface PluginContainer
Returns:
A list of VisiblePlugin objects

getVisiblePlugins

public java.util.List getVisiblePlugins()
Returns a list containing the currently visible plugin.

Specified by:
getVisiblePlugins in interface PluginContainer
Returns:
A list of VisiblePlugin objects or null

getActivePlugin

public VisiblePlugin getActivePlugin()
Returns the currently active plugin, which is incidently the visible plugin.

Specified by:
getActivePlugin in interface PluginContainer
Returns:
The plugin or null if the container does not contain a plugin

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Request the focus for the newly activated plugin on tab change by the user.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

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 regions for a plugin container are regions at the four corners as well as the on the plugin itself. 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 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 containing the active plugin of this container or null

updateContainer

public void updateContainer(boolean fullRebuild)
Rebuilds the enviroment of the container (title, toolbar, menu).

Parameters:
fullRebuild - true Causes a full container environment including menu and toolbar rebuild
false Updates the container title only

getPage

public JaspiraPage getPage()
Returns the page level parent plugin of this plugin.

Specified by:
getPage in interface PluginContainer
Returns:
The page that holds this plugin or null

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


Copyright © 2011. All Rights Reserved.