Class AbstractPlugin
- java.lang.Object
-
- com.lightdev.app.shtm.AbstractPlugin
-
- All Implemented Interfaces:
SHTMLPlugin
public abstract class AbstractPlugin extends java.lang.Object implements SHTMLPlugin
Base class for plug-ins of application SimplyHTML.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 ofDynamicResource
. I.e., methods of classAbstractPlugin
only work as defined herein when accompanied by such .properties file accordingly.- See Also:
DynamicResource
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
active
status of plug-inprotected javax.swing.JComponent
c
component of this plug-inprotected int
dockLocation
current dock locationprotected javax.swing.JFrame
frame
JFrame for dockLocation=noneprotected java.lang.String
helpMenuId
the id in the ResourceFile for the help menu of this plug-inprotected javax.swing.JMenuItem
hMenu
the help menu provided by this plug-inprotected java.lang.String
internalName
the internal name of this plug-inprotected SHTMLPanelImpl
owner
the owner of this plug inprotected java.lang.String
pluginMenuId
the id in the ResourceFile for the menu of this plug-inprotected javax.swing.JMenuItem
pMenu
the plug-in menu provided by this plug-inprotected java.util.prefs.Preferences
prefs
reference for user preferences for this classstatic java.lang.String
PREFSID_PLUGIN_ACTIVE
constant for active setting in preferences filestatic java.lang.String
PREFSID_PLUGIN_DOCK_LOCATION
constant for dock location setting in preferences filestatic UIResources
textResources
TextResources of plug-in-
Fields 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 Constructor Description AbstractPlugin()
construct an AbstractPlugin
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createFrame()
create a frame for the component of this plug-in, if it has a JComponent to display.protected void
createFrameAsNeeded(int location)
create, show or hide frame as needed, depending on a given dock locationprotected void
createHelpMenu()
create the help menuprotected void
createPluginMenu()
create the plug-in menujavax.swing.JComponent
getComponent()
get the component that this plug-in produces, if anyint
getDockLocation()
get the location the component returned by getDockComponent() shall be docked at.java.lang.String
getGUIName()
get the name of the plug-in as it shall appear on a GUI.javax.swing.JMenuItem
getHelpMenu()
get a menu item providing documentation about this plug-in.java.lang.String
getInternalName()
get the name used internally for this plug-inSHTMLPanelImpl
getOwner()
get the owner of this plug-injavax.swing.Action
getOwnerAction(java.lang.String cmd)
get an action from the resource bundle of the owner of this plug-injava.lang.String
getOwnerResString(java.lang.String nm)
get a string from the resource bundle of the owner of this plug-injavax.swing.JMenuItem
getPluginMenu()
get a menu of actions this plug-in provides.void
initHelpMenu()
void
initPlugin(SHTMLPanelImpl owner)
init the plug-in this is called by the PluginManager directly after instantiating the plug-invoid
initPlugin(SHTMLPanel owner, java.lang.String internalName, java.lang.String pluginMenuId, java.lang.String helpMenuId)
initialize the pluginboolean
isActive()
get the status of the plug-invoid
setDockLocation(int location)
set the location the component returned by getDockComponent() shall be docked at.void
setOwner(SHTMLPanelImpl owner)
set the owner of this plug-invoid
setStatus(boolean isActive)
set status of plug-in and persistently store setting in a preferences file-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.lightdev.app.shtm.SHTMLPlugin
initPlugin, showInitialInfo
-
-
-
-
Field Detail
-
textResources
public static UIResources textResources
TextResources of plug-in
-
PREFSID_PLUGIN_ACTIVE
public static final java.lang.String PREFSID_PLUGIN_ACTIVE
constant for active setting in preferences file- See Also:
- Constant Field Values
-
PREFSID_PLUGIN_DOCK_LOCATION
public static final java.lang.String PREFSID_PLUGIN_DOCK_LOCATION
constant for dock location setting in preferences file- See Also:
- Constant Field Values
-
internalName
protected java.lang.String internalName
the internal name of this plug-in
-
pluginMenuId
protected java.lang.String pluginMenuId
the id in the ResourceFile for the menu of this plug-in
-
helpMenuId
protected java.lang.String helpMenuId
the id in the ResourceFile for the help menu of this plug-in
-
pMenu
protected javax.swing.JMenuItem pMenu
the plug-in menu provided by this plug-in
-
hMenu
protected javax.swing.JMenuItem hMenu
the help menu provided by this plug-in
-
active
protected boolean active
status of plug-in
-
dockLocation
protected int dockLocation
current dock location
-
c
protected javax.swing.JComponent c
component of this plug-in
-
frame
protected javax.swing.JFrame frame
JFrame for dockLocation=none
-
prefs
protected java.util.prefs.Preferences prefs
reference for user preferences for this class
-
owner
protected SHTMLPanelImpl owner
the owner of this plug in
-
-
Method Detail
-
initPlugin
public void initPlugin(SHTMLPanelImpl owner)
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:
initHelpMenu
in 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, java.lang.String internalName, java.lang.String pluginMenuId, java.lang.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
public void setOwner(SHTMLPanelImpl owner)
set the owner of this plug-in- Specified by:
setOwner
in interfaceSHTMLPlugin
- Parameters:
owner
- the main frame of the instance of SimplyHTML creating the plug-in
-
getOwner
public SHTMLPanelImpl getOwner()
get the owner of this plug-in- Specified by:
getOwner
in 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:
setStatus
in 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:
setDockLocation
in 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
public javax.swing.JMenuItem getPluginMenu()
get a menu of actions this plug-in provides.JMenu
is a decendant ofJMenuItem
so this method may return a single menu item up to a whole structure of submenus in its return value.- Specified by:
getPluginMenu
in interfaceSHTMLPlugin
- Returns:
- the plug-in menu
-
getHelpMenu
public javax.swing.JMenuItem getHelpMenu()
get a menu item providing documentation about this plug-in.JMenu
is a decendant ofJMenuItem
so this method may return a single menu item up to a whole structure of submenus in its return value.- Specified by:
getHelpMenu
in interfaceSHTMLPlugin
- Returns:
- a menu item with help for this plug-in
-
getGUIName
public java.lang.String getGUIName()
get the name of the plug-in as it shall appear on a GUI.- Specified by:
getGUIName
in interfaceSHTMLPlugin
- Returns:
- the name of the plug-in
-
getInternalName
public java.lang.String getInternalName()
get the name used internally for this plug-in- Specified by:
getInternalName
in 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:
getDockLocation
in 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
public javax.swing.JComponent getComponent()
get the component that this plug-in produces, if any- Specified by:
getComponent
in 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:
isActive
in interfaceSHTMLPlugin
- Returns:
- true, if activated, false if not
-
getOwnerResString
public java.lang.String getOwnerResString(java.lang.String nm)
get a string from the resource bundle of the owner of this plug-in- Specified by:
getOwnerResString
in 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
public javax.swing.Action getOwnerAction(java.lang.String cmd)
get an action from the resource bundle of the owner of this plug-in- Specified by:
getOwnerAction
in interfaceSHTMLPlugin
- Parameters:
cmd
- the name of the action to get- Returns:
- the action with the given name or null, if none is found
-
-