Difference: DpHipePluginsDeveloperManual (20 vs. 21)

Revision 212011-11-15 - PaulBalm

Line: 1 to 1
 
META TOPICPARENT name="DpHipePlugins"

Plug-in Author Manual

Line: 102 to 102
  For information on how to create a JAR file with your Java code, see the JAR Documentation.
Changed:
<
<

How to create a plug-in with a Task Red star, highlightNEW

>
>

How to create a plug-in with a Task

 
Changed:
<
<
To easiest way to avoid the hassle that is involved in "making a new task work in HIPE", is to create a plug-in with the task inside. This section will show you how that's done. First, I'll make the assumption that the Task is written in Jython. (If your Task is in Java, do not despair, it's actually easier. Hints will be provided at the end of this section.)

  • Decide on a new for your plug-in. Say you call your plug-in SmartTask and the task it contains is called MyTask.
  • Create a new directory and cd into it
  • Save your task to a separate file in this directory, for example myTask.py.
  • In the same directory, create a file called plugin.py with the following contents (edit as needed):

### EDIT here
name='SmartTask'
taskFileName='myTask.py'
### End section for the you to edit

# Imports
from herschel.ia.gui.apps.plugin import PluginRegistry
from herschel.ia.gui.kernel.Tool import Category
from herschel.ia.task.views import TaskToolRegistry 

# Find the basedirectory of the plugin
pluginRegistry = PluginRegistry.getInstance()
plugin = pluginRegistry.get(name)
basedir = plugin.pluginDir

# "Import" the task
execfile(basedir.absolutePath + '/' + taskFileName)

# Register task in HIPE session -- EDIT next two lines as needed
myTask = MyTask()
TaskToolRegistry.getInstance().register(myTask, [Category.SPIRE])

# Clean up
del(name, taskFileName)
del(pluginRegistry, plugin, basedir)

  • Create the plug-in with the following command: jar cf ../SmartTask_0.1.jar *
  • Test drive:
    • Remove or comment properties and other settings you had to get your task into HIPE
    • Start HIPE and verify that the task isn't there
    • Select Tools --> Plug-ins --> Install New
    • Click the browse icon and look for your SmartTask_0.1.jar. Install it.
    • You're done! Restart HIPE to see your Task in action.

If you thought that was easy, have a look at the slightly more advanced topics to find out how to automatically enable and disable your plug-in, depending on the HIPE version the user is running at the time (for compatibility reasons) and how to allow your users to get automatic notifications of new versions of your plug-in.

If that wasn't easy, please do let me know.

So... What if your task was in Java? You apply the above recipe with the following changes:

  • Create a JAR file with the .class files for your task inside (this might be only one file if you have only one class).
  • Create a subdirectory called jars and copy the JAR file there.
  • Modify the plugin.py as follows:
    • Remove the sections "Find the base directory of the plug-in" and "Import the task"
    • Instead, import the task as you would in Java (from my.package.name import MyTask)
  • That's all.
>
>
To easiest way to avoid the hassle that is involved in "making a new task work in HIPE", is to create a plug-in with the task inside. If your Task is in Java, please refer to MyFirstJavaTask and if it's in Jython, see MyFirstJythonTask. Both these pages start by explaining how to write a task in their respective language, and both pages contain a section "Turning the task into a HIPE plug-in".
 

Combinations of the above

 
This site is powered by the TWiki collaboration platform Powered by Perl