Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BPMN 2.0 Modeler » A subtype of ScriptTask
A subtype of ScriptTask [message #1236564] Mon, 27 January 2014 09:50 Go to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
Hi.


I need to have a new subtype of ScriptTask - called for instance. MyScriptTask.

The difference is that the script task is persisted with an additional attribute:

<bpmn2:scriptTask mynamespace:type="mine">


I see what I have to do to persist it the way I want, but I don't know how to create a new element in the Pallete that will also correspond to a Script task.

How do I manage to do this?

I believe I must to implement a new feature container for script task where the script icon or "my" icon is choosen accordingly with the existence of mynamespace:type="mine" property. I also believe I shold not in this case to implement a custom Task. Am I wrong?

But how should I proceed in what concerns to palette??

Thanks
rui
Re: A subtype of ScriptTask [message #1236580 is a reply to message #1236564] Mon, 27 January 2014 10:31 Go to previous messageGo to next message
Robert Brodt is currently offline Robert Brodt
Messages: 577
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

I believe everything you're trying to do is covered in the Custom Task example plug-in. To experiment with this plug-in, import the project from ~/examples/org.eclipse.bpmn2.modeler.examples.customtask into your development workbench. After launching a new eclipse workbench, create a new project and set its Target Runtime to "Custom Task Example Runtime Extension" from the project properties. Now when you create a new Process file in that project, it will use the Custom Task plug-in.

Follow the code that implements "My Task" in the "My Tools" category of the Tool Palette - this should get you started.

If you're still lost, please ask Wink

Cheers,
Bob
Re: A subtype of ScriptTask [message #1236619 is a reply to message #1236580] Mon, 27 January 2014 12:31 Go to previous messageGo to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
Hi Bob. Thanks for replying.

I'checked on that plugin https://github.com/reg-bas/CustomTaskExample/blob/master/org.eclipse.bpmn2.modeler.examples.customtask/plugin.xml
but in plugin.xml there is no palette configuration. Is there any way to configure the Palette for this element?
<category id="com.sinfic.agora.configurator.bpmn2.modeler.toolpalette.simple.Activities" name="%category.name">
				<tool name="%tool.name" object="AdHocSubProcess"/>
				<tool name="%tool.name.0" object="SubProcess"/>
				<tool name="%tool.name.1" object="CallActivity"/>
				<tool name="%tool.name.2" object="ManualTask"/>
				<tool name="%tool.name.3" object="UserTask"/>
				<tool name="%tool.name.4" object="ScriptTask"/>
				<tool name="%tool.name.5" object="BusinessRuleTask"/>
				<tool name="%tool.name.6" object="SendTask"/>
				<tool name="%tool.name.7" object="ReceiveTask"/>
                             <<<IF I want my custom task to show up here>>>	

		</category>


Is it possible?
Re: A subtype of ScriptTask [message #1236626 is a reply to message #1236619] Mon, 27 January 2014 12:49 Go to previous messageGo to next message
Robert Brodt is currently offline Robert Brodt
Messages: 577
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

You can specify the toolpalette category in your <customTask> definition like so:

<customTask category="%category.name" .../>

and it will be added to that category.
Re: A subtype of ScriptTask [message #1236655 is a reply to message #1236626] Mon, 27 January 2014 14:26 Go to previous messageGo to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
Hi. Thanks for replying.

I've managed to do everything I want. But I think there are still two bugs: Can you check please:
-First, The description in palette remains the same as in " Create Task" . I tried to override the methods but the result is the same.
-Second: firstly I extended from scriptTask, setting type="ScriptTask".
This way the little icon in the left corner is not replaced by my one. If I set type="Task" as in Custom Task example, it is replaced. Is this the expected behaviour?

 	<customTask
            category="%category.name"
            description="This is a Mail Task."
	            
            featureContainer="c.m.bpmn2.modeler.runtime.extension.features.AgoraMailMessageFeatureContainer"
            icon="email.png"
            id="com.my.agora.tasks.mail"
            name="Mail Task"
            propertyTabs="c.m.runtime.extension.property.AgoraEmptyPropertySection"
            runtimeId="c.m.bpmn2.modeler.runtime.extension"
            type="ScriptTask">
            
         <property
               name="type"
               value="mail">
         </property>
			
      </customTask>
		


Thanks
Re: A subtype of ScriptTask [message #1236746 is a reply to message #1236655] Mon, 27 January 2014 20:17 Go to previous messageGo to next message
Robert Brodt is currently offline Robert Brodt
Messages: 577
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

Hmm, these are probably bugs. I'll have a look at this tomorrow to confirm.
Re: A subtype of ScriptTask [message #1236908 is a reply to message #1236746] Tue, 28 January 2014 06:09 Go to previous messageGo to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
Thanks.

The second problem occurs because in org.eclipse.bpmn2.modeler.ui.features.activity.task.CustomShapeFeatureContainer

the icon is added only if addFeatureDelegate hasn't added one yet.

@Override
public PictogramElement add(IAddContext context) {
 PictogramElement pe = addFeatureDelegate.add(context);
 // make sure everyone knows that this PE is a custom task
 if (pe!=null)
	Graphiti.getPeService().setPropertyValue(pe,CUSTOM_ELEMENT_ID,getId());
	// add an icon to the top-left corner if applicable, and if the implementing
	// addFeatureDelegate hasn't already done so.
	String icon = customTaskDescriptor.getIcon();
	if (icon!=null && pe instanceof ContainerShape) {
	  boolean addImage = true;
	  ContainerShape containerShape = (ContainerShape)pe;
	  GraphicsAlgorithm ga =  
GraphicsAlgorithm)AbstractBpmn2AddFeature.getGraphicsAlgorithm(containerShape);
				for (PictogramElement child : containerShape.getChildren()) {
if (child.getGraphicsAlgorithm() instanceof Image) {
						addImage = false;
						break;
					}
				}
				if (ga!=null) {
					for (GraphicsAlgorithm g : ga.getGraphicsAlgorithmChildren()) {
						if (g instanceof Image) {
							addImage = false;
							break;
						}
					}
				}
				else
					addImage = false;
				
				if (addImage) {
					Image img = CustomTaskImageProvider.createImage(customTaskDescriptor, ga, icon, 24, 24);
					Graphiti.getGaService().setLocationAndSize(img, 2, 2, 24, 24);
				}
			}
			return pe;
		}


Thanks again
Re: A subtype of ScriptTask [message #1237093 is a reply to message #1236908] Tue, 28 January 2014 16:07 Go to previous messageGo to next message
Robert Brodt is currently offline Robert Brodt
Messages: 577
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

OK.

For the first issue you brought up (description in toolpalette) is a documentation problem: the "description" attribute in your plugin.xml is the text displayed in the "Description" tab for the Custom Task object, and not the tooltip text in for the toolpalette item. Unfortunately there is currently no way to change the toolpalette tooltip text, it will always be "Create <some object type>".

For the second issue: I'm assuming you can code your way around this?
Re: A subtype of ScriptTask [message #1237097 is a reply to message #1237093] Tue, 28 January 2014 16:25 Go to previous message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
1.Yes, I noticed that the description was the one shown in the Tab. And not the one used to instantiate create feature.
2.Yes I can code around that somehow. For now I've just hacked the plugin code. I'll try later to work around that in feature container if it is possible.

Thanks Bob
Previous Topic:Manipulate model when MessageStartEvent is created
Next Topic:How to change the target runtime and the color of events
Goto Forum:
  


Current Time: Wed Jul 23 20:29:40 EDT 2014

Powered by FUDForum. Page generated in 0.01749 seconds