Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [bpmn2-modeler-dev] Adding custom tasks

Hmm...I just tried the same thing and I'm able to get my custom task to show up in the "Custom Task" drawer in the toolpalette.
Here's what I did (working exclusively in the "org.eclipse.bpmn2.modeler.extras" plugin):

1. create a new class called MyCustomTaskFeatureContainer and copy/paste the methods from LogTaskFeatureContainer
2. change the name and other strings to MyCustom as appropriate. The class looks like this:

public class MyCustomTaskFeatureContainer extends TaskFeatureContainer {
   
    public ICreateFeature getCreateFeature(IFeatureProvider fp) {
        return new CreateTaskFeature(fp);
    }

    public static class CreateTaskFeature extends AbstractCreateTaskFeature {

        public CreateTaskFeature(IFeatureProvider fp) {
            super(fp, "MyCustom Task", "Create MyCustom Task");
        }

        protected Task createFlowElement(ICreateContext context) {
            Task task = ModelHandler.FACTORY.createTask();
            task.setName("MyCustom Task");
            ArrayList<EStructuralFeature> attributes = Bpmn2Preferences
                    .getAttributes(task.eClass());
            for (EStructuralFeature eStructuralFeature : attributes) {
                if (eStructuralFeature.getName().equals("taskName"))
                    task.eSet(eStructuralFeature, "mycustom");
            }
            return task;
        }

        @Override
        protected String getStencilImageId() {
            return ImageProvider.IMG_16_ACTION;
        }
    }
}

3. edit plugin.xml in "extras" plugin: copy/paste the <task> definition for the Log Task (BTW, the "taskName" for this is "send" - it should be "log"). The extension point definition should look like this:

   <extension
         point="org.eclipse.bpmn2.modeler.custom_task">
      <task
            createFeature="org.eclipse.bpmn2.modeler.extras.EmailTaskFeatureContainer"
            name="Email Task"
            taskName="send">
      </task>
      <task
            createFeature="org.eclipse.bpmn2.modeler.extras.LogTaskFeatureContainer"
            name="Log Task"
            taskName="log">
      </task>
      <task
            createFeature="org.eclipse.bpmn2.modeler.extras.MyCustomTaskFeatureContainer"
            name="MyCustom Task"
            taskName="mycustom">
      </task>
   </extension>

4. rebuild all projects and run

HTH
_______________________________________
Robert ("Bob") Brodt
Senior Software Engineer, JBoss Riftsaw
JBoss by Red Hat


Hi all.
before bothering you just let me introduce myself, so next time you already know who is writing and you can filter the message as spam :D (don't do that pls!) . 
Anyway i'm stefano and for a project  i have to extend and modify a BPMN editor (also the runtime but this is another story) and actually this one seems to be the best solution (i need OpenSource one. do you know something else?).


so, back to business:

I'm trying to modify the editor and i started trying to add a new task to the pallete.
before doing that i tried simply modifications like: change the names and icons on existing tasks to see if it works, and actually it works (!!)

So, i tried to add my task and this is what i did:

- add a class (cut & paste of the LogTaskFeatureContainer) and insert my parameter for name & icon.

and here i'm blocked :D

for what i understood by looking at the code (it is full of comments as usual :D) i've (well, i guess so) to edit the conf file to let the editor know about this new class.
this because in BpmnToolBehaviourFeature there's the loading of custom tasks (am i right?) and if i have understood right the conf file is here: org.eclipse.bpmn2.modeler.custom_task (is the parameter inside ICustomTaskEditor).
Basically the probem is: i cannot find where this file is located.

Anyway did i do the right steps? or do i have to do something different?

ciao.
--
Stefano


Back to the top