Class AbstractPlugin
- All Implemented Interfaces:
SHTMLPlugin
Defines some common methods for reuse in plug-ins. All
settings such as dockLocation or activation state
of a plug-in are stored persistently in a preferences file
with the help of class Prefs. The preferences
file is valid for the current user, so each user has own
plug-in settings.
Menus are constructed with the help of class
DynamicResource. This class needs menu definitions
accessible in a .properties file as described in the API docs
of DynamicResource. I.e., methods of class
AbstractPlugin only work as defined herein when
accompanied by such .properties file accordingly.
- See Also:
-
DynamicResource
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatus of plug-inprotected JComponentcomponent of this plug-inprotected intcurrent dock locationprotected JFrameJFrame for dockLocation=noneprotected Stringthe id in the ResourceFile for the help menu of this plug-inprotected JMenuItemthe help menu provided by this plug-inprotected Stringthe internal name of this plug-inprotected SHTMLPanelImplthe owner of this plug inprotected Stringthe id in the ResourceFile for the menu of this plug-inprotected JMenuItemthe plug-in menu provided by this plug-inprotected Preferencesreference for user preferences for this classstatic final Stringconstant for active setting in preferences filestatic final Stringconstant for dock location setting in preferences filestatic UIResourcesTextResources of plug-inFields inherited from interface com.lightdev.app.shtm.SHTMLPlugin
DOCK_LOCATION_BOTTOM, DOCK_LOCATION_LEFT, DOCK_LOCATION_NONE, DOCK_LOCATION_RIGHT, DOCK_LOCATION_TOP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreate a frame for the component of this plug-in, if it has a JComponent to display.protected voidcreateFrameAsNeeded(int location) create, show or hide frame as needed, depending on a given dock locationprotected voidcreate the help menuprotected voidcreate the plug-in menuget the component that this plug-in produces, if anyintget the location the component returned by getDockComponent() shall be docked at.get the name of the plug-in as it shall appear on a GUI.get a menu item providing documentation about this plug-in.get the name used internally for this plug-ingetOwner()get the owner of this plug-ingetOwnerAction(String cmd) get an action from the resource bundle of the owner of this plug-inget a string from the resource bundle of the owner of this plug-inget a menu of actions this plug-in provides.voidvoidinitPlugin(SHTMLPanelImpl owner) init the plug-in this is called by the PluginManager directly after instantiating the plug-invoidinitPlugin(SHTMLPanel owner, String internalName, String pluginMenuId, String helpMenuId) initialize the pluginbooleanisActive()get the status of the plug-invoidsetDockLocation(int location) set the location the component returned by getDockComponent() shall be docked at.voidsetOwner(SHTMLPanelImpl owner) set the owner of this plug-invoidsetStatus(boolean isActive) set status of plug-in and persistently store setting in a preferences fileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.lightdev.app.shtm.SHTMLPlugin
initPlugin, showInitialInfo
-
Field Details
-
textResources
TextResources of plug-in -
PREFSID_PLUGIN_ACTIVE
constant for active setting in preferences file- See Also:
-
PREFSID_PLUGIN_DOCK_LOCATION
constant for dock location setting in preferences file- See Also:
-
internalName
the internal name of this plug-in -
pluginMenuId
the id in the ResourceFile for the menu of this plug-in -
helpMenuId
the id in the ResourceFile for the help menu of this plug-in -
pMenu
the plug-in menu provided by this plug-in -
hMenu
the help menu provided by this plug-in -
active
protected boolean activestatus of plug-in -
dockLocation
protected int dockLocationcurrent dock location -
c
component of this plug-in -
frame
JFrame for dockLocation=none -
prefs
reference for user preferences for this class -
owner
the owner of this plug in
-
-
Constructor Details
-
AbstractPlugin
public AbstractPlugin()construct an AbstractPluginConstructor may not have parameters so that java.lang.Class.newInstance can be used on it.
-
-
Method Details
-
initPlugin
init the plug-in this is called by the PluginManager directly after instantiating the plug-in -
createPluginMenu
protected void createPluginMenu()create the plug-in menu -
createHelpMenu
protected void createHelpMenu()create the help menu -
initHelpMenu
public void initHelpMenu()- Specified by:
initHelpMenuin interfaceSHTMLPlugin
-
createFrame
protected void createFrame()create a frame for the component of this plug-in, if it has a JComponent to display. -
createFrameAsNeeded
protected void createFrameAsNeeded(int location) create, show or hide frame as needed, depending on a given dock location- Parameters:
location- the dock location of the plug-in, one of DOCK_LOCATION_TOP, DOCK_LOCATION_BOTTOM, DOCK_LOCATION.LEFT, DOCK_LOCATION_RIGHT or DOCK_LOCATION_NONE, if the component shall not dock.
-
initPlugin
public void initPlugin(SHTMLPanel owner, String internalName, String pluginMenuId, String helpMenuId) initialize the plugin- Parameters:
owner- the owner of this plug-ininternalName- the internal name this plug-in shall havepluginMenuId- the id of the plug-in menu in the TextResources, or null if no plugin-in menu is to be createdhelpMenuId- the id of the help menu for this plug-in in the TextResources, or null if no help menu is to be created
-
setOwner
set the owner of this plug-in- Specified by:
setOwnerin interfaceSHTMLPlugin- Parameters:
owner- the main frame of the instance of SimplyHTML creating the plug-in
-
getOwner
get the owner of this plug-in- Specified by:
getOwnerin interfaceSHTMLPlugin- Returns:
- the owner of this plug-in
-
setStatus
public void setStatus(boolean isActive) set status of plug-in and persistently store setting in a preferences file- Specified by:
setStatusin interfaceSHTMLPlugin- Parameters:
isActive- indicates whether or not the plug-in shall be activated
-
setDockLocation
public void setDockLocation(int location) set the location the component returned by getDockComponent() shall be docked at. Persistently store setting in a preferences file.- Specified by:
setDockLocationin interfaceSHTMLPlugin- Parameters:
location- the dock location, one of DOCK_LOCATION_TOP, DOCK_LOCATION_BOTTOM, DOCK_LOCATION.LEFT, DOCK_LOCATION_RIGHT or DOCK_LOCATION_NONE, if the component shall not dock.
-
getPluginMenu
get a menu of actions this plug-in provides.JMenuis a decendant ofJMenuItemso this method may return a single menu item up to a whole structure of submenus in its return value.- Specified by:
getPluginMenuin interfaceSHTMLPlugin- Returns:
- the plug-in menu
-
getHelpMenu
get a menu item providing documentation about this plug-in.JMenuis a decendant ofJMenuItemso this method may return a single menu item up to a whole structure of submenus in its return value.- Specified by:
getHelpMenuin interfaceSHTMLPlugin- Returns:
- a menu item with help for this plug-in
-
getGUIName
get the name of the plug-in as it shall appear on a GUI.- Specified by:
getGUINamein interfaceSHTMLPlugin- Returns:
- the name of the plug-in
-
getInternalName
get the name used internally for this plug-in- Specified by:
getInternalNamein interfaceSHTMLPlugin- Returns:
- the internal name of this plug-in
-
getDockLocation
public int getDockLocation()get the location the component returned by getDockComponent() shall be docked at.- Specified by:
getDockLocationin interfaceSHTMLPlugin- Returns:
- the dock location, one of DOCK_LOCATION_TOP, DOCK_LOCATION_BOTTOM, DOCK_LOCATION.LEFT, DOCK_LOCATION_RIGHT or DOCK_LOCATION_NONE, if the component shall not dock.
-
getComponent
get the component that this plug-in produces, if any- Specified by:
getComponentin interfaceSHTMLPlugin- Returns:
- the component produced by this plug-in, or null if none is produced
-
isActive
public boolean isActive()get the status of the plug-in- Specified by:
isActivein interfaceSHTMLPlugin- Returns:
- true, if activated, false if not
-
getOwnerResString
get a string from the resource bundle of the owner of this plug-in- Specified by:
getOwnerResStringin interfaceSHTMLPlugin- Parameters:
nm- the name of the string resource to get- Returns:
- the string with the given name or null, if none is found
-
getOwnerAction
get an action from the resource bundle of the owner of this plug-in- Specified by:
getOwnerActionin interfaceSHTMLPlugin- Parameters:
cmd- the name of the action to get- Returns:
- the action with the given name or null, if none is found
-