public abstract class AbstractPlugin extends java.lang.Object implements 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.
DynamicResource
Modifier and Type | Field and Description |
---|---|
protected boolean |
active
status of plug-in
|
protected javax.swing.JComponent |
c
component of this plug-in
|
protected int |
dockLocation
current dock location
|
protected javax.swing.JFrame |
frame
JFrame for dockLocation=none
|
protected java.lang.String |
helpMenuId
the id in the ResourceFile for the help menu of this plug-in
|
protected javax.swing.JMenuItem |
hMenu
the help menu provided by this plug-in
|
protected java.lang.String |
internalName
the internal name of this plug-in
|
protected com.lightdev.app.shtm.SHTMLPanelImpl |
owner
the owner of this plug in
|
protected java.lang.String |
pluginMenuId
the id in the ResourceFile for the menu of this plug-in
|
protected javax.swing.JMenuItem |
pMenu
the plug-in menu provided by this plug-in
|
protected java.util.prefs.Preferences |
prefs
reference for user preferences for this class
|
static java.lang.String |
PREFSID_PLUGIN_ACTIVE
constant for active setting in preferences file
|
static java.lang.String |
PREFSID_PLUGIN_DOCK_LOCATION
constant for dock location setting in preferences file
|
static TextResources |
textResources
TextResources of plug-in
|
DOCK_LOCATION_BOTTOM, DOCK_LOCATION_LEFT, DOCK_LOCATION_NONE, DOCK_LOCATION_RIGHT, DOCK_LOCATION_TOP
Constructor and Description |
---|
AbstractPlugin()
construct an AbstractPlugin
|
Modifier and Type | Method and 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 location
|
protected void |
createHelpMenu()
create the help menu
|
protected void |
createPluginMenu()
create the plug-in menu
|
javax.swing.JComponent |
getComponent()
get the component that this plug-in produces, if any
|
int |
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-in
|
com.lightdev.app.shtm.SHTMLPanelImpl |
getOwner()
get the owner of this plug-in
|
javax.swing.Action |
getOwnerAction(java.lang.String cmd)
get an action from the resource bundle of the owner of this plug-in
|
java.lang.String |
getOwnerResString(java.lang.String nm)
get a string from the resource bundle of the owner of this plug-in
|
javax.swing.JMenuItem |
getPluginMenu()
get a menu of actions this plug-in provides.
|
void |
initHelpMenu() |
void |
initPlugin(com.lightdev.app.shtm.SHTMLPanelImpl owner)
init the plug-in
this is called by the PluginManager directly after instantiating the plug-in
|
void |
initPlugin(SHTMLPanel owner,
java.lang.String internalName,
java.lang.String pluginMenuId,
java.lang.String helpMenuId)
initialize the plugin
|
boolean |
isActive()
get the status of the plug-in
|
void |
setDockLocation(int location)
set the location the component returned by getDockComponent()
shall be docked at.
|
void |
setOwner(com.lightdev.app.shtm.SHTMLPanelImpl owner)
set the owner of this plug-in
|
void |
setStatus(boolean isActive)
set status of plug-in and persistently store setting in
a preferences file
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initPlugin, showInitialInfo
public static TextResources textResources
public static final java.lang.String PREFSID_PLUGIN_ACTIVE
public static final java.lang.String PREFSID_PLUGIN_DOCK_LOCATION
protected java.lang.String internalName
protected java.lang.String pluginMenuId
protected java.lang.String helpMenuId
protected javax.swing.JMenuItem pMenu
protected javax.swing.JMenuItem hMenu
protected boolean active
protected int dockLocation
protected javax.swing.JComponent c
protected javax.swing.JFrame frame
protected java.util.prefs.Preferences prefs
protected com.lightdev.app.shtm.SHTMLPanelImpl owner
public AbstractPlugin()
Constructor may not have parameters so that java.lang.Class.newInstance can be used on it.
public void initPlugin(com.lightdev.app.shtm.SHTMLPanelImpl owner)
protected void createPluginMenu()
protected void createHelpMenu()
public void initHelpMenu()
initHelpMenu
in interface SHTMLPlugin
protected void createFrame()
protected void createFrameAsNeeded(int location)
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.public void initPlugin(SHTMLPanel owner, java.lang.String internalName, java.lang.String pluginMenuId, java.lang.String helpMenuId)
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 createdpublic void setOwner(com.lightdev.app.shtm.SHTMLPanelImpl owner)
setOwner
in interface SHTMLPlugin
owner
- the main frame of the instance of SimplyHTML creating the plug-inpublic com.lightdev.app.shtm.SHTMLPanelImpl getOwner()
getOwner
in interface SHTMLPlugin
public void setStatus(boolean isActive)
setStatus
in interface SHTMLPlugin
isActive
- indicates whether or not the plug-in shall be activatedpublic void setDockLocation(int location)
setDockLocation
in interface SHTMLPlugin
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.public javax.swing.JMenuItem getPluginMenu()
JMenu
is a decendant of JMenuItem
so this method may return a single menu item up to a whole
structure of submenus in its return value.
getPluginMenu
in interface SHTMLPlugin
public javax.swing.JMenuItem getHelpMenu()
JMenu
is a decendant of JMenuItem
so this method may return a single menu item up to a whole
structure of submenus in its return value.
getHelpMenu
in interface SHTMLPlugin
public java.lang.String getGUIName()
getGUIName
in interface SHTMLPlugin
public java.lang.String getInternalName()
getInternalName
in interface SHTMLPlugin
public int getDockLocation()
getDockLocation
in interface SHTMLPlugin
public javax.swing.JComponent getComponent()
getComponent
in interface SHTMLPlugin
public boolean isActive()
isActive
in interface SHTMLPlugin
public java.lang.String getOwnerResString(java.lang.String nm)
getOwnerResString
in interface SHTMLPlugin
nm
- the name of the string resource to getpublic javax.swing.Action getOwnerAction(java.lang.String cmd)
getOwnerAction
in interface SHTMLPlugin
cmd
- the name of the action to get