org.openbp.jaspira.gui.plugin
Class AbstractVisiblePlugin

java.lang.Object
  extended by org.openbp.jaspira.plugin.AbstractPlugin
      extended by org.openbp.jaspira.gui.plugin.AbstractVisiblePlugin
All Implemented Interfaces:
java.awt.event.HierarchyListener, java.util.EventListener, VisiblePlugin, Plugin
Direct Known Subclasses:
AboutBoxPlugin, ColorChooserPlugin, FinderResultPlugin, InfoPanelPlugin, InspectorPlugin, ItemBrowserPlugin, JaspiraPage, MiniViewPlugin, Modeler, NodeItemEditorPlugin, PluginMgrPlugin, PropertyBrowserPlugin, StackTracePlugin, StatusBarPlugin, ToolBoxPlugin, VariablesPlugin

public abstract class AbstractVisiblePlugin
extends AbstractPlugin
implements VisiblePlugin, java.awt.event.HierarchyListener

Basic implementation of a visible plugin.

Author:
Stephan Moritz

Nested Class Summary
 class AbstractVisiblePlugin.StandardVisiblePluginEvents
          Event module.
 
Nested classes/interfaces inherited from class org.openbp.jaspira.plugin.AbstractPlugin
AbstractPlugin.StandardPluginEvents
 
Field Summary
 
Fields inherited from class org.openbp.jaspira.plugin.AbstractPlugin
PROPERTY_CONDITION, PROPERTY_DESCRIPTION, PROPERTY_ICON, PROPERTY_NAME, PROPERTY_SEQUENCE, PROPERTY_TITLE, PROPERTY_VENDOR, PROPERTY_VERSION
 
Fields inherited from interface org.openbp.jaspira.gui.plugin.VisiblePlugin
GER, GEU, SIZE_VARIABLE_BOTH, SIZE_VARIABLE_HEIGHT, SIZE_VARIABLE_NONE, SIZE_VARIABLE_WIDTH, TOOLBAR_DYNAMIC, TOOLBAR_EVENTS, TOOLBAR_NONE
 
Fields inherited from interface org.openbp.jaspira.plugin.Plugin
ID_DELIMETER, LEVEL_APPLICATION, LEVEL_FRAME, LEVEL_PAGE, LEVEL_PLUGIN
 
Constructor Summary
AbstractVisiblePlugin()
          Constructor.
 
Method Summary
 void addPluginFocusListener(java.awt.event.FocusListener listener)
          Adds a focus listener to the listener list.
 void applicationReady()
          Called after the application has been initialized AND the plugin initialization is finished.
 boolean canCopy()
          Checks if the plugin can copy the selected data to the clipboard.
 boolean canCut()
          Checks if the plugin can cut the selected data to the clipboard.
 boolean canDelete()
          Checks if the plugin can delete the selected data.
 boolean canDrag()
          Checks if the plugin can be dragged.
protected  boolean canPageChange(JaspiraPage oldPage, JaspiraPage newPage)
          This method is called before a page change takes place.
 boolean canPaste(java.awt.datatransfer.Transferable transferable)
          Checks if the plugin can paste the data of the given transferable object.
 java.awt.datatransfer.Transferable copy()
          Copies the selected data from the plugin to the clipboard.
 JaspiraToolbar createToolbar()
          Creates the toolbar of this plugin.
 java.awt.datatransfer.Transferable cut()
          Cuts the selected data from the plugin to the clipboard.
 void delete()
          Deletes the selected data, if any.
 void firePluginFocusGained()
          Fires a 'focus gained' message to all registered focus listeners.
 void firePluginFocusLost()
          Fires a 'focus lost' message to all registered focus listeners.
 void focusPlugin()
          Requests the focus for this plugin from the plugin manager and brings it to the front.
 javax.swing.JPanel getContentPane()
          Returns the plugin content pane.
 JaspiraPage getPage()
          Returns the page level parent plugin of this plugin.
 javax.swing.JComponent getPluginComponent()
          Gets the component this plugin contains.
 java.awt.Component getPluginFocusComponent()
          Returns the focus component of this plugin, i\.e\. the component that is to initially receive the focus.
static VisiblePlugin getPluginFromComponentHierarchy(java.awt.Component c)
          Searches backwards in the component hierarchy of the given component and returns the plugin that is associated with a parent of the component.
 PluginHolder getPluginHolder()
          Returns the holder of this plugin.
 PluginPanel getPluginPanel()
          Gets the panel that holds the title bar of the plugin and the content panel.
 int getSizeBehavior()
          Returns the behavior of the plugin size.
 java.util.List getSubClients()
          Gets the Dnd sub clients of this plugin.
 int getToolbarType()
          Gets the type of the plugin toolbar.
 boolean hasCloseButton()
          Returns true if the plugin should have a close button in its title bar.
 void hierarchyChanged(java.awt.event.HierarchyEvent e)
          Called when a hierarchyChanged event is received, i\.e\. something in the hierarchy has changed.
protected abstract  void initializeComponents()
          This template method is called after internal Components (i\.e\. title bar etc\.)
protected  void initializeResources()
          Loads the plugin resources.
 void installPlugin()
          Installs the plugin and all its modules.
protected  void installPluginContent()
          Installs the contents of the plugin.
 boolean isPluginFocused()
          Checks if the plugin is currently focused.
 boolean isPluginVisible()
          Checks if the plugin is currently visible.
 void paste(java.awt.datatransfer.Transferable transferable)
          Pastes the given data into the plugin.
 void pluginHidden()
          Called after the plugin has been hidden.
 void pluginShown()
          Called after the plugin has been displayed.
 void postPluginContainerUpdate(boolean fullRebuild)
          Posts an update request of the plugin's holder.
 void removePluginFocusListener(java.awt.event.FocusListener listener)
          Removes a focus listener from the listener list.
 void setPluginHolder(PluginHolder holder)
          Sets the holder of this plugin.
 void showPlugin(boolean changePage)
          Brings the plugin to the front, but does not request the focus.
 void stackEvent(JaspiraEvent je)
          Ensures that there are not multiple GEUs or GERs stacked.
 void uninstallPlugin()
          Uninstalls the plugin and all of its modules.
 void updatePluginContainer(boolean fullRebuild)
          Forces the holder of this plugin to update its title bar.
 
Methods inherited from class org.openbp.jaspira.plugin.AbstractPlugin
addActionKeySequence, addPlugin, addToPeerGroup, canClose, closeCanceled, containsStackedEvent, fireEvent, fireEvent, fireEvent, getAction, getChildPlugins, getClassName, getCondition, getDescendantPlugins, getDescription, getEventActionNames, getEventModules, getExternalActions, getExternalEventModuleClasses, getExternalOptionModuleClasses, getIcon, getIcon, getLevel, getName, getOptionModules, getParentPlugin, getPeerGroup, getPeerGroupNames, getPeerGroups, getPluginResourceCollection, getPluginState, getResourceCollectionContainerName, getSubTitle, getTitle, getUniqueId, getVendor, getVersion, handleEvent, handleKeySequence, inheritEvent, initializeFromPluginProfile, initializePlugin, installFirstPlugin, matchesPeerGroup, matchesPeerGroups, passDown, pluginInstalled, pluginUninstalled, preClose, receiveEvent, removeFromPeerGroup, removePlugin, removeStackedEvent, requestClose, setDescription, setIcon, setName, setParentPlugin, setPluginState, setResourceCollection, setTitle, toString, uninstallLastPlugin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openbp.jaspira.plugin.Plugin
addPlugin, addToPeerGroup, canClose, containsStackedEvent, fireEvent, fireEvent, fireEvent, getAction, getChildPlugins, getClassName, getCondition, getDescendantPlugins, getDescription, getEventActionNames, getIcon, getLevel, getName, getParentPlugin, getPeerGroup, getPeerGroupNames, getPeerGroups, getPluginResourceCollection, getPluginState, getSubTitle, getTitle, getUniqueId, getVendor, getVersion, handleEvent, inheritEvent, initializePlugin, installFirstPlugin, matchesPeerGroup, matchesPeerGroups, receiveEvent, removeFromPeerGroup, removePlugin, requestClose, setParentPlugin, setPluginState, uninstallLastPlugin
 

Constructor Detail

AbstractVisiblePlugin

public AbstractVisiblePlugin()
Constructor.

Method Detail

initializeResources

protected void initializeResources()
Loads the plugin resources.

Overrides:
initializeResources in class AbstractPlugin

installPlugin

public void installPlugin()
Installs the plugin and all its modules. Should only be called by the plugin manager.

Specified by:
installPlugin in interface Plugin
Overrides:
installPlugin in class AbstractPlugin

installPluginContent

protected void installPluginContent()
Installs the contents of the plugin.

Overrides:
installPluginContent in class AbstractPlugin

applicationReady

public void applicationReady()
Called after the application has been initialized AND the plugin initialization is finished.


uninstallPlugin

public final void uninstallPlugin()
Uninstalls the plugin and all of its modules. Never call this method directly, use PluginMgr.removeInstance(Plugin) instead.

Specified by:
uninstallPlugin in interface Plugin
Overrides:
uninstallPlugin in class AbstractPlugin

initializeComponents

protected abstract void initializeComponents()
This template method is called after internal Components (i\.e\. title bar etc\.) have been initialized. It shoud be used to initialize plugin specific components.


stackEvent

public void stackEvent(JaspiraEvent je)
Ensures that there are not multiple GEUs or GERs stacked.

Specified by:
stackEvent in interface Plugin
Overrides:
stackEvent in class AbstractPlugin
Parameters:
je - The event to stack

pluginShown

public void pluginShown()
Called after the plugin has been displayed.

Specified by:
pluginShown in interface VisiblePlugin

pluginHidden

public void pluginHidden()
Called after the plugin has been hidden.

Specified by:
pluginHidden in interface VisiblePlugin

canPageChange

protected boolean canPageChange(JaspiraPage oldPage,
                                JaspiraPage newPage)
This method is called before a page change takes place. It allows the plugin to veto the change by returning false. Override this to check for veto conditions.

Parameters:
oldPage - Current page
newPage - Page that should be made the new current page
Returns:
true If the plugin accepts the page change
false Otherwise

getPluginPanel

public PluginPanel getPluginPanel()
Gets the panel that holds the title bar of the plugin and the content panel.

Specified by:
getPluginPanel in interface VisiblePlugin

getContentPane

public javax.swing.JPanel getContentPane()
Returns the plugin content pane.

Returns:
A panel that uses the border layout

getPluginComponent

public javax.swing.JComponent getPluginComponent()
Gets the component this plugin contains.

Specified by:
getPluginComponent in interface VisiblePlugin
Returns:
The content pane

getPluginFocusComponent

public java.awt.Component getPluginFocusComponent()
Returns the focus component of this plugin, i\.e\. the component that is to initially receive the focus.

Specified by:
getPluginFocusComponent in interface VisiblePlugin
Returns:
The return value defaults to the first component below the content pane of the plugin. If this component is a scroll pane, the method returns the view component of the pane. If there is no focusable component, the method returns null.

setPluginHolder

public void setPluginHolder(PluginHolder holder)
Sets the holder of this plugin.

Specified by:
setPluginHolder in interface VisiblePlugin
Parameters:
holder - The plugin holder

getPluginHolder

public PluginHolder getPluginHolder()
Returns the holder of this plugin.

Specified by:
getPluginHolder in interface VisiblePlugin
Returns:
The plugin holder

getPage

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

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

getToolbarType

public int getToolbarType()
Gets the type of the plugin toolbar. This will determine how the toolbar of the plugin will be constructed.

Specified by:
getToolbarType in interface VisiblePlugin
Returns:
VisiblePlugin.TOOLBAR_NONE/VisiblePlugin.TOOLBAR_EVENTS/VisiblePlugin.TOOLBAR_DYNAMIC
Default: TOOLBAR_EVENTS

hasCloseButton

public boolean hasCloseButton()
Returns true if the plugin should have a close button in its title bar. Override this method to customize the plugin.

Specified by:
hasCloseButton in interface VisiblePlugin

getSizeBehavior

public int getSizeBehavior()
Returns the behavior of the plugin size. Override this method if you want to constrain the sizing of the plugin.

Specified by:
getSizeBehavior in interface VisiblePlugin
Returns:
VisiblePlugin.SIZE_VARIABLE_NONE/VisiblePlugin.SIZE_VARIABLE_WIDTH/VisiblePlugin.SIZE_VARIABLE_HEIGHT/VisiblePlugin.SIZE_VARIABLE_BOTH

postPluginContainerUpdate

public void postPluginContainerUpdate(boolean fullRebuild)
Posts an update request of the plugin's holder.

Specified by:
postPluginContainerUpdate in interface VisiblePlugin
Parameters:
fullRebuild - true Causes a full holder update including menu and toolbar rebuild
false Updates the holder title only

updatePluginContainer

public void updatePluginContainer(boolean fullRebuild)
Forces the holder of this plugin to update its title bar.

Specified by:
updatePluginContainer in interface VisiblePlugin
Parameters:
fullRebuild - true Causes a full holder update including menu and toolbar rebuild
false Updates the holder title only

createToolbar

public JaspiraToolbar createToolbar()
Creates the toolbar of this plugin. The toolbar will be constructed according to the return value of the method. If you want to construct your own custom toolbar, override this method.

Specified by:
createToolbar in interface VisiblePlugin
Returns:
The toolbar or null if the plugin does not have a toolbar

hierarchyChanged

public void hierarchyChanged(java.awt.event.HierarchyEvent e)
Called when a hierarchyChanged event is received, i\.e\. something in the hierarchy has changed. Calls the pluginShown() or pluginHidden() methods.

Specified by:
hierarchyChanged in interface java.awt.event.HierarchyListener

showPlugin

public void showPlugin(boolean changePage)
Brings the plugin to the front, but does not request the focus.

Specified by:
showPlugin in interface VisiblePlugin
Parameters:
changePage - true Shows the JaspiraPage this holder belongs to if it not the active page.
false Do not flip pages.

isPluginVisible

public boolean isPluginVisible()
Checks if the plugin is currently visible.

Specified by:
isPluginVisible in interface VisiblePlugin

focusPlugin

public void focusPlugin()
Requests the focus for this plugin from the plugin manager and brings it to the front. The focus is being set to the focus component (getPluginFocusComponent()) of the plugin or to the plugin's component.

Specified by:
focusPlugin in interface VisiblePlugin

isPluginFocused

public boolean isPluginFocused()
Checks if the plugin is currently focused.

Specified by:
isPluginFocused in interface VisiblePlugin

firePluginFocusGained

public void firePluginFocusGained()
Fires a 'focus gained' message to all registered focus listeners.

Specified by:
firePluginFocusGained in interface VisiblePlugin

firePluginFocusLost

public void firePluginFocusLost()
Fires a 'focus lost' message to all registered focus listeners.

Specified by:
firePluginFocusLost in interface VisiblePlugin

addPluginFocusListener

public void addPluginFocusListener(java.awt.event.FocusListener listener)
Adds a focus listener to the listener list. The listener is registered for all properties as a WEAK listener, i. e. it may be garbage-collected if not referenced otherwise.
ATTENTION: Never add an automatic class (i. e new FocusListener () { ... }) or an inner class that is not referenced otherwise as a weak listener to the list. These objects will be cleared by the garbage collector during the next gc run!

Specified by:
addPluginFocusListener in interface VisiblePlugin
Parameters:
listener - The listener to be added

removePluginFocusListener

public void removePluginFocusListener(java.awt.event.FocusListener listener)
Removes a focus listener from the listener list.

Specified by:
removePluginFocusListener in interface VisiblePlugin
Parameters:
listener - The listener to be removed

getSubClients

public java.util.List getSubClients()
Description copied from class: AbstractPlugin
Gets the Dnd sub clients of this plugin.

Specified by:
getSubClients in interface VisiblePlugin
Overrides:
getSubClients in class AbstractPlugin
Returns:
A list containing this object if it is a InteractionClient or null otherwise

canDrag

public boolean canDrag()
Description copied from interface: VisiblePlugin
Checks if the plugin can be dragged.

Specified by:
canDrag in interface VisiblePlugin

canCopy

public boolean canCopy()
Description copied from interface: VisiblePlugin
Checks if the plugin can copy the selected data to the clipboard.

Specified by:
canCopy in interface VisiblePlugin
Returns:
true if the plugin can provide clipboard data.

canCut

public boolean canCut()
Description copied from interface: VisiblePlugin
Checks if the plugin can cut the selected data to the clipboard.

Specified by:
canCut in interface VisiblePlugin
Returns:
true if the plugin can provide clipboard data that can be deleted.

canPaste

public boolean canPaste(java.awt.datatransfer.Transferable transferable)
Description copied from interface: VisiblePlugin
Checks if the plugin can paste the data of the given transferable object.

Specified by:
canPaste in interface VisiblePlugin
Returns:
true if the plugin accepts the given transferable.

canDelete

public boolean canDelete()
Description copied from interface: VisiblePlugin
Checks if the plugin can delete the selected data.

Specified by:
canDelete in interface VisiblePlugin
Returns:
If the data can be deleted.

copy

public java.awt.datatransfer.Transferable copy()
Description copied from interface: VisiblePlugin
Copies the selected data from the plugin to the clipboard.

Specified by:
copy in interface VisiblePlugin
Returns:
The copied data

cut

public java.awt.datatransfer.Transferable cut()
Description copied from interface: VisiblePlugin
Cuts the selected data from the plugin to the clipboard.

Specified by:
cut in interface VisiblePlugin
Returns:
The copied data

paste

public void paste(java.awt.datatransfer.Transferable transferable)
Description copied from interface: VisiblePlugin
Pastes the given data into the plugin.

Specified by:
paste in interface VisiblePlugin
Parameters:
transferable - Content to paste

delete

public void delete()
Description copied from interface: VisiblePlugin
Deletes the selected data, if any.

Specified by:
delete in interface VisiblePlugin

getPluginFromComponentHierarchy

public static VisiblePlugin getPluginFromComponentHierarchy(java.awt.Component c)
Searches backwards in the component hierarchy of the given component and returns the plugin that is associated with a parent of the component. Note that this works only if the parent is an AbstractVisiblePlugin

Parameters:
c - We will start the search with the parent component of this component
Returns:
The plugin or null if no ancestor of the component is a plugin's content panel


Copyright © 2011. All Rights Reserved.