public abstract class EditPlugin
extends java.lang.Object
EBPlugin
to automatically receive EditBus messages.
The following properties are required for jEdit to load the plugin:
plugin.className.activate
- set this to
defer
if your plugin only needs to be loaded when it is first
invoked; set it to startup
if your plugin must be loaded at
startup regardless; set it to a whitespace-separated list of property names
if your plugin should be loaded if at least one of these properties is set.
Note that if this property is not set, the plugin will not work with
jEdit 4.3final.
plugin.className.name
plugin.className.version
plugin.className.jars
- only needed if your plugin
bundles external JAR files. Contains a whitespace-separated list of JAR
file names. Without this property, the plugin manager will leave behind the
external JAR files when removing the plugin.plugin.className.files
- only needed if your plugin
bundles external files like libraries which MUST reside in the local
filesystem. Contains a whitespace-separated list of file names.
Without this property, the plugin manager will leave behind the
external files when removing the plugin.plugin.className.description
- the short description
associated with the plugin. The short description is used by the Plugin
Manager and on the list pages on Plugin Central. plugin.className.author
plugin.className.usePluginHome
- whether
the plugin uses the EditPlugin.getPluginHome API or not. Even
if the plugin doesn't store any data, this property should be set
so that the plugin manager can tell that there is no data stored.plugin.className.docs
- the path to plugin
documentation in HTML format. plugin.className.longdescription
- the path to
the long description in XHTML (no fancy stuff here, please - just proper
XHTML subset with the basic tags: html, h1, h2, p, li, ul, ol, a href,b ,i, u, br/ )
The long description is extracted from the plugin at various times, primarily at plugin packaging time to update the data on the plugin detail pages of Plugin Central.
If this property is left out, the default will be to look in a file called <description.html>.
For the previous two properties, if a relative path is supplied, it should be both
Both conditions are easily satisfied if the .props file as well as description.html are both located in the root directory of the plugin, as well as the generated JAR.
Plugin dependencies are also specified using properties.
Each dependency is defined in a property named with
plugin.className.depend.
followed by a number.
Dependencies must be numbered in order, starting from zero.
This determines the order that dependent plugins get loaded and activated,
so order is very important.
The value of a dependency property has one of the following forms:
jdk minimumJavaVersion
jedit minimumjEditVersion
- note that this must be
a version number in the form returned by jEdit.getBuild()
,
not jEdit.getVersion()
. Note that the documentation here describes
the jEdit 4.2 plugin API, so this dependency must be set to at least
04.02.99.00
(4.2final).pluginClassName pluginVersion
- the fully quailified
plugin class name with package must be specified.optional plugin pluginClassName pluginVersion
-
an optional dependency, indicating that the plugin will work without it,
but that the dependency should be loaded before this plugin. In this example, the ProjectViewer plugin is an optional dependency of the Console, beacause the Console only listens to events from the ProjectViewer. It requires Jedit 4.2 final.
plugin.console.ConsolePlugin.depend.0=jedit 04.02.99.00 plugin.console.ConsolePlugin.depend.1=jdk 1.5 plugin.console.ConsolePlugin.depend.2=plugin errorlist.ErrorListPlugin 1.4 plugin.console.ConsolePlugin.depend.3=optional plugin projectviewer.ProjectPlugin 2.1.0.92
To add your plugin to the view's Plugins menu, define one of these two properties:
plugin.className.menu-item
- if this is defined,
the action named by this property is added to the Plugins menu.plugin.className.menu
- if this is defined,
a sub-menu is added to the Plugins menu whose content is the
whitespace-separated list of action names in this property. A separator may
be added to the sub-menu by listing -
in the property.If you want the plugin's menu items to be determined at runtime, define a
property plugin.className.menu.code
to be BeanShell
code that evaluates to an implementation of
DynamicMenuProvider
.
To add your plugin to the file system browser's Plugins menu, define one of these two properties:
plugin.className.browser-menu-item
- if this is
defined, the action named by this property is added to the Plugins
menu.plugin.className.browser-menu
- if this is defined,
a sub-menu is added to the Plugins menu whose content is the
whitespace-separated list of action names in this property. A separator may
be added to the sub-menu by listing -
in the property.Again, if the browser menu items need to be determined at runtime, define a
property plugin.className.browser-menu.code
to be BeanShell
code that evaluates to an implementation of
DynamicMenuProvider
.
In all cases, each action's
menu item label is taken from the actionName.label
property. View actions are defined in an actions.xml
file, file system browser actions are defined in a
browser.actions.xml
file; see ActionSet
.
To add your plugin to the Plugin Options dialog box, define one of these two properties:
plugin.className.option-pane=paneName
- if this is defined,
a single option pane with this name is added to the Plugin Options
menu.plugin.className.option-group=paneName1 [paneName2 paneName3 ...]
- if this is defined,
a branch node is added to the Plugin Options dialog box whose content
is the whitespace-separated list of paneNames in this property.options.paneName.label
- the label to show
for the pane in the dialog box.options.paneName.code
- BeanShell code that
evaluates to an instance of the OptionPane
class.# jEdit only needs to load the plugin the first time the user accesses it # the presence of this property also tells jEdit the plugin is using the new API plugin.QuickNotepadPlugin.activate=defer plugin.QuickNotepadPlugin.name=QuickNotepad plugin.QuickNotepadPlugin.author=John Gellene plugin.QuickNotepadPlugin.usePluginHome=true plugin.QuickNotepadPlugin.version=4.5 plugin.QuickNotepadPlugin.docs=index.html # see jEdit.getBuild() to understand jEdit's version convention: plugin.QuickNotepadPlugin.depend.0=jedit 04.05.99.00 plugin.QuickNotepadPlugin.depend.1=jdk 1.7 plugin.QuickNotepadPlugin.description=This plugin provides a dockable "scratch pad" for writing and displaying notes, to do lists or similar items as unformatted text. # plugin menu plugin.QuickNotepadPlugin.menu=quicknotepad \ - \ quicknotepad.choose-file \ quicknotepad.save-file \ quicknotepad.copy-to-buffer quicknotepad.label=QuickNotepad plugin.QuickNotepadPlugin.option-pane=quicknotepad options.quicknotepad.code=new QuickNotepadOptionPane(); options.quicknotepad.label=QuickNotepadNote that action and option pane labels are not shown in the above example.
Modifier and Type | Class and Description |
---|---|
static class |
EditPlugin.Broken
A placeholder for a plugin that didn't load.
|
static class |
EditPlugin.Deferred
A placeholder for a plugin that hasn't been loaded yet.
|
Constructor and Description |
---|
EditPlugin() |
Modifier and Type | Method and Description |
---|---|
javax.swing.JMenuItem |
createBrowserMenuItems()
Called by the filesystem browser when constructing its
Plugins menu.
|
javax.swing.JMenuItem |
createMenuItems()
Called by the view when constructing its Plugins menu.
|
java.lang.String |
getClassName() |
java.io.File |
getPluginHome()
Returns the home of your plugin.
|
static java.io.File |
getPluginHome(java.lang.Class<? extends EditPlugin> clazz)
Returns the home of the specified plugin.
|
static java.io.File |
getPluginHome(EditPlugin plugin)
Returns the home of the specified plugin.
|
PluginJAR |
getPluginJAR() |
static java.io.OutputStream |
getResourceAsOutputStream(java.lang.Class<? extends EditPlugin> clazz,
java.lang.String path)
Returns an output stream to the specified resource, or
null
if access to that resource is denied. |
static java.io.OutputStream |
getResourceAsOutputStream(EditPlugin plugin,
java.lang.String path)
Returns an output stream to the specified resource, or
null if access
to that resource is denied. |
static java.io.InputStream |
getResourceAsStream(java.lang.Class<? extends EditPlugin> clazz,
java.lang.String path)
Returns an input stream to the specified resource, or
null
if none is found. |
static java.io.InputStream |
getResourceAsStream(EditPlugin plugin,
java.lang.String path)
Returns an input stream to the specified resource, or
null
if none is found. |
static java.io.File |
getResourcePath(java.lang.Class<? extends EditPlugin> clazz,
java.lang.String path)
Returns the full path of the specified plugin resource.
|
static java.io.File |
getResourcePath(EditPlugin plugin,
java.lang.String path)
Returns the full path of the specified plugin resource.
|
void |
start()
jEdit calls this method when the plugin is being activated, either
during startup or at any other time.
|
void |
stop()
jEdit calls this method when the plugin is being unloaded.
|
public void start()
activate
property set to
startup
, in which case it will always be loaded at
startup.activate
property is set to true
,
in which case it will always be loaded at startup.When this method is being called for plugins written for jEdit 4.1 and below, no views or buffers are open. However, this is not the case for plugins using the new API. For example, if your plugin adds tool bars to views, make sure you correctly handle the case where views are already open when the plugin is loaded.
If your plugin must be loaded on startup, take care to have this method return as quickly as possible.
The default implementation of this method does nothing.
public void stop()
If a plugin uses state information or other persistent data that should be stored in a special format, this would be a good place to write the data to storage. If the plugin uses jEdit's properties API to hold settings, no special processing is needed for them on exit, since they will be saved automatically.
With plugins written for jEdit 4.1 and below, this method is only called when the program is exiting. However, this is not the case for plugins using the new API. For example, if your plugin adds tool bars to views, make sure you correctly handle the case where views are still open when the plugin is unloaded.
To avoid memory leaks, this method should ensure that no references to any objects created by this plugin remain in the heap. In the case of actions, dockable windows and services, jEdit ensures this automatically. For other objects, your plugin must clean up maually.
The default implementation of this method does nothing.
@Nullable public java.io.File getPluginHome()
getResourceAsStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourceAsOutputStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
@Nullable public static java.io.File getPluginHome(java.lang.Class<? extends EditPlugin> clazz)
Returns the home of the specified plugin.
Since the first parameter is a reference to the
Class
instance for the plugin,
this method requires the plugin to be activated.
See getPluginHome(EditPlugin)
method, as
an alternate, for when the plugin doesn't need
to be activated, or when you do not have the
Class
instance available.
clazz
- the class of the plugingetPluginHome(EditPlugin)
,
getResourceAsStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourceAsOutputStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
@Nullable public static java.io.File getPluginHome(EditPlugin plugin)
Returns the home of the specified plugin.
This method doesn't need the plugin to be activated. You can pass
an EditPlugin.Deferred
instance that you get from
jEdit.getPlugin(String)
or jEdit.getPlugins()
if
the plugin in question is not activated yet and this method doesn't
cause the plugin to get activated. If you have a reference to the
plugins Class
instance available, consider using the
Class
method.
plugin
- the plugingetPluginHome(Class)
,
getResourceAsStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourceAsOutputStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
public static java.io.InputStream getResourceAsStream(java.lang.Class<? extends EditPlugin> clazz, java.lang.String path)
Returns an input stream to the specified resource, or null
if none is found.
Since the first parameter is a reference to the
Class
instance for the plugin,
this method requires the plugin to be activated.
See getResourceAsStream(EditPlugin,String)
method, as
an alternate, for when the plugin doesn't need
to be activated, or when you do not have the
Class
instance available.
clazz
- the plugin classpath
- The path to the resource to be returned, relative to
the plugin's resource path.null
.getPluginHome()
,
getResourceAsStream(EditPlugin,String)
,
getResourceAsOutputStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
public static java.io.InputStream getResourceAsStream(EditPlugin plugin, java.lang.String path)
Returns an input stream to the specified resource, or null
if none is found.
This method doesn't need the plugin to be activated. You can pass
an EditPlugin.Deferred
instance that you get from
jEdit.getPlugin(String)
or jEdit.getPlugins()
if
the plugin in question is not activated yet and this method doesn't
cause the plugin to get activated. If you have a reference to the
plugins Class
instance available, consider using the
Class
method.
plugin
- the pluginpath
- The path to the resource to be returned, relative to
the plugin's resource path.null
.getPluginHome()
,
getResourceAsStream(Class,String)
,
getResourceAsOutputStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
public static java.io.OutputStream getResourceAsOutputStream(java.lang.Class<? extends EditPlugin> clazz, java.lang.String path)
Returns an output stream to the specified resource, or null
if access to that resource is denied.
Since the first parameter is a reference to the
Class
instance for the plugin,
this method requires the plugin to be activated.
See getResourceAsOutputStream(EditPlugin,String)
method, as
an alternate, for when the plugin doesn't need
to be activated, or when you do not have the
Class
instance available.
clazz
- the plugin classpath
- The path to the resource to be returned, relative to
the plugin's resource path.null
.getPluginHome()
,
getResourceAsOutputStream(EditPlugin,String)
,
getResourceAsStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
public static java.io.OutputStream getResourceAsOutputStream(EditPlugin plugin, java.lang.String path)
Returns an output stream to the specified resource, or null
if access
to that resource is denied.
This method doesn't need the plugin to be activated. You can pass
an EditPlugin.Deferred
instance that you get from
jEdit.getPlugin(String)
or jEdit.getPlugins()
if
the plugin in question is not activated yet and this method doesn't
cause the plugin to get activated. If you have a reference to the
plugins Class
instance available, consider using the
Class
method.
plugin
- the pluginpath
- The path to the resource to be returned, relative to
the plugin's resource path.null
.getPluginHome()
,
getResourceAsOutputStream(Class,String)
,
getResourceAsStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
public static java.io.File getResourcePath(java.lang.Class<? extends EditPlugin> clazz, java.lang.String path)
Returns the full path of the specified plugin resource.
Since the first parameter is a reference to the
Class
instance for the plugin,
this method requires the plugin to be activated.
See getResourcePath(EditPlugin,String)
method, as
an alternate, for when the plugin doesn't need
to be activated, or when you do not have the
Class
instance available.
clazz
- the plugin classpath
- The relative path to the resource from the plugin's
resource path.getPluginHome()
,
getResourceAsOutputStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourceAsStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(EditPlugin,String)
public static java.io.File getResourcePath(EditPlugin plugin, java.lang.String path)
Returns the full path of the specified plugin resource.
This method doesn't need the plugin to be activated. You can pass
an EditPlugin.Deferred
instance that you get from
jEdit.getPlugin(String)
or jEdit.getPlugins()
if
the plugin in question is not activated yet and this method doesn't
cause the plugin to get activated. If you have a reference to the
plugins Class
instance available, consider using the
Class
method.
plugin
- the pluginpath
- The relative path to the resource from the plugin's
resource path.getPluginHome()
,
getResourceAsOutputStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourceAsStream(java.lang.Class<? extends org.gjt.sp.jedit.EditPlugin>, java.lang.String)
,
getResourcePath(Class,String)
public java.lang.String getClassName()
EditPlugin
instance, for
example if the plugin is not loaded yet.public PluginJAR getPluginJAR()
public final javax.swing.JMenuItem createMenuItems()
public final javax.swing.JMenuItem createBrowserMenuItems()