cancel
Showing results for 
Search instead for 
Did you mean: 

Adaption of the Designer

norberts
Champ in-the-making
Champ in-the-making
Heyho Folks,

I'm totally new to Activiti and just started 2 days ago to even look closely at it so please forgive me if I don't have the total insight yet.
So the thing is, I'm supposed to adapt Activiti for my thesis. For that I have to customize the palette and extend the designer itself through verification, own diagram models and so on.

The first question that came to my mind after reading the user guide about adapting was:
Can I customize the palette using a plugin and not just library dependencies? Just because it's more convenient to just install the plugin and not set the customization jar additionally. So I looked at the extension points, found it (dependency org.activiti.designer.integration), customized it and tried to run it. But nothing happened, I guess because there is no schema for the extension point org.activiti.designer.eclipse.extension.PaletteExtensionProvider (if that is the right one)?

Secondly I just tried to write my own verifier since I guess I'll need it later on. After seeing that this one is also not called (and the schema for the validation extension point is also not found) I found that topic here: http://forums.activiti.org/en/viewtopic.php?f=8&t=6186, so far so good. I have some time but it would be a shame if I have to change Activiti myself, just to have that feature inside of my thesis time. So please activate that again!  Smiley Wink

Thirdly, I have to transform the diagram into an internal representation to run analyses on it later on. Any suggestions on that? I mean, I can write an exportMarshaller but that doesn't seem so good since it's supposed to be totally internally. And I can transform the diagram every time in a verifier (if used for analyses) or just do it once through a command handler and then run the verifiers on that somehow manually.

I also searched for coloring or kind of marking of diagram elements and found an old thread (I think from 2011) where someone wanted it but then nothing happened. I guess that guy had no time or not the mood to do it. Is there any progress on that? I would need to color the diagram dynamically after running an analyses to mark the wrong elements. Surely can I do that just through the provided info/warning/error markers but graphically would be neat to.

I think that's for the questions so far. As I've said, I just started to take a look at it and the requirements are kind of fuzzy so far but I just wanted to raise these questions to get an idea about with what I'm dealing here. Smiley Happy
10 REPLIES 10

tiesebarrell
Champ in-the-making
Champ in-the-making
NorbertS,

1) at the moment we don't support extensions besides the library approach. I plan to add a similar way to do it using extensions, because I agree with you I would rather write a plugin and package that with Designer than write a JAR file and have to link it. However, this means an overhaul of what we have at the moment and I don't expect to add it soon. We also don't have an extension point for the PaletteExtensionProvider.

By the way, you're not the first person to request this. The customization was initially added as a sideline feature and we wanted to make it as easy as possible to create an extension, without requiring knowledge of developing plugins. We had never anticipated so many people wanting to use this Smiley Happy

2) As you found yourself, validators are currently not invoked. Another vote to re-add this, though.

3) That depends entirely on what you mean by internal representation. The model for the diagrams is an all-java model, so you can easily transform to anything else if you build a hook to get hold of the model held in memory.

4) No, there has been no progress on that particular subject. I suppose it only makes sense if we re-enable the validators to be invoked in the first place.

norberts
Champ in-the-making
Champ in-the-making
Hey Tiese,

1)
You don't support ANY extension right now (as it seems to me) or just not that combination of the customization (despite the verification and exportation)?
The funny thing here is, that if I try to do your "tutorial" out of the user guide the first thing that there seems to be a mistake in the first pom.xml snippet:
<project

  <name>Acme Corporation Money Tasks</name>

</pom>
I guess it's supposed to be </project> and not </pom>. Just pointing this out. Smiley Happy Furthermore, Maven can't find the latest dependency jar. If you enter 5.12 or lower it results in an error until the 5.7 is there again (referencing the following line).
<version>5.7</version> <!– Current Activiti Designer Version –>Anyway, that's not the main thing I wanted to ask about. The disabling of elements through my own Customizer works, but to add new tasks seems not to work. I extended the AbstractCustomServiceTask as presented with the example, overwrote the getName and contributeToPaletteDrawer methods, tried it out… and nothing happened. I also had the icons and tried to find out if it is even called but couldn't succeed for sure.
You can download my small project here (can't upload it for some reason) if you want to take a look at it:
https://dl.dropbox.com/u/3336025/addingTask.zip

Can I assume that this part is also disabled right now? If yes, I might have to create my own editor 'cause Activiti is then extremely limited when it comes to extendability.

2+3) That's a shame since I would need it critically, I think. At least to transform the Diagram into my own model on saving.
Speaking of the Diagram, I tried to reach the Activiti diagram today via code and kind of succeeded and at the same time not. I got the active editor, got the diagram from it through the graphiti methods and tried to access the elements. They are there, but only as ContainerShapeImpl classes. I can't distinguish between the Activiti elements (e.g. instanceof StartEvent is never true). I saw in the verificator example that this should be possible and searched the Activiti source code only to end up with the same code as I used. What would be the right way to get the diagram with the correct classes? Or is that somehow done through the disabled verification extension point?
ActivitiDiagramEditor editor = (ActivitiDiagramEditor) PlatformUI
  .getWorkbench().getActiveWorkbenchWindow().getActivePage()
  .getActiveEditor();
Diagram diagram = editor.getDiagramTypeProvider().getDiagram();
final EList<EObject> contents = diagram.eResource().getContents();

I hope I don't annoy you with all these questions. Smiley Happy
Greetings

groopk
Champ in-the-making
Champ in-the-making
Hey Tiese,
Anyway, that's not the main thing I wanted to ask about. The disabling of elements through my own Customizer works, but to add new tasks seems not to work. I extended the AbstractCustomServiceTask as presented with the example, overwrote the getName and contributeToPaletteDrawer methods, tried it out… and nothing happened. I also had the icons and tried to find out if it is even called but couldn't succeed for sure.

We were able to do this with 5.12, so I can confirm it works. We didn't use maven though, we just setup the eclipse project directly. We made a User Library in eclipse and had to restart eclipse for it to pick it up.

briefly comparing yours to ours, the main difference I see is you don't have the Runtime annotation on your MyTask, i.e. @Runtime(javaDelegateClass = "org.acme.runtime.AcmeMoneyJavaDelegation")

tiesebarrell
Champ in-the-making
Champ in-the-making
Hi NorbertS,

first of all, questions aren't annoying; happy to help where I can.

Second, good catch on the userguide examples. Obviously in source code the examples are correct, but the userguide had that typo. I've fixed it: https://github.com/Activiti/Activiti/commit/58bcc191996084a00c78d4e8d9cc4891e3e6ace1

1) Yes, we support extending the palette with new CustomServiceTasks and disabling default shapes. Currently not available are the ExportMarshallers and ProcessValidators, which are the extension possibilities the extension points exist for. Creating your own ServiceTasks is done using a standard JAR and still works.

We haven't had a 1-on-1 release of the integration JAR for every version of Designer, only when there was something new in the integration lib itself. A list of versions available can be looked up in Nexus, here:
https://maven.alfresco.com/nexus/content/groups/public/org/activiti/designer/org.activiti.designer.i...

There you can also see the 5.12 version that goes with the current release of Designer. The 5.7 in the userguide is just an example, that's why the comment is there.

Adding shapes should work. Have you tried checking out the examples, compiling those and adding them to Designer? Those should work. Otherwise, you're probably doing something wrong which leads to no new items in the palette. Also, remember to re-open any open editors to see new items in the palette - these are only loaded when you open a diagram. Let me know if you figure this out. If not, I might have time this weekend to look at your example - let me know if that's necessary.

So no, that assumption is wrong for the current state of Designer. For the other extension capabilities we used to have, I can only say I want to re-add them myself soon, but I can't make any promises when I'll get around to it.

2) The items you have there are the graphical items, not the model. The stuff you're after is in the Bpmn2MemoryModel. Take a look at the ActivitiDiagramEditor class where the save actions are performed. If you create a hook there, you can create custom code using the model. Graphiti does maintain links between graphical and model elements so you can get from one to the other and there are examples of that in Designer's internal code, but I'd go straight for the model itself.

norberts
Champ in-the-making
Champ in-the-making
About the designer integration jar of the version 5.12 in the maven repository. The provided repository in the pom.xml out of the user guide doesn't contain the 5.12 version (https://maven.alfresco.com/nexus/content/repositories/activiti/) and it has a different naming policy compared to the repository you pointed out (https://maven.alfresco.com/nexus/content/groups/public/org/activiti/designer/org.activiti.designer.i...).
It's called org.activiti.designer.integration-5.12.0.jar instead of activiti-designer-integration-5.12.jar.
Through that it's hard for maven to find it. I'm not an expert in maven so I just downloaded the jar, packed it into my maven repository cache and just fiddled around with the pom.xml until maven could find it.
In the future I will just use a normal eclipse project as groopk did, since I don't have to fetch the dependency jar anymore.

But still, my problem exists. If I download the example code from https://github.com/Activiti/Activiti-Designer/tree/master/examples and pack that stuff into a maven project, I first of all get compile errors due to the package naming. Which was surprising for me but clear to see, because src/main/java/org/acme… can't be matched onto just org/acme… I don't know if that's a problem of my maven settings (although I did everything as it was said in the user guide) or just a mistake. But why would you put something like that into github, if it doesn't work.
Anyway, I can't even open the editor anymore because of a null pointer on image loading (see stacktrace below). I saw that before on the release 5.9 where someone didn't overwrite the getSmallIconPath method. But I did. Even overwrote the getLargeIconPath method. And just to clarify that, I use Eclipse Indigo (3.7), not Helios or something else, so that shouldn't be the problem.

I just tried it with a simple java project with the designer-integration jar as referenced lib. I left the main/java and main/resources out and just created a src/org/acme… and src/resources/icons structure. And still can't open the editor. It can be that my path to the icon is wrong, but I don't think so. A deletion of all Tasks except the MoneyTask didn't help either.

I made a screenshot, accessible here: https://dl.dropbox.com/u/3336025/moneytask.jpg.
And yes, I restarted eclipse, closed the editor everytime it failed and so on so the jar is loaded again every time.

As a next try I tried to track down the stack trace. I looked at the ActivitiToolBehaviorProvider and found no line 682 in the latest source code. That left me even more puzzled so here I am again. Smiley Very Happy

I'm getting really confused here. Maybe someone could just provide me with an example that definitely works? The moneytask-example is fine, but it is not an importable project. So maybe I'm just configuring it wrong, although I don't know what is configurable except for the pom.

Unable to create editor ID org.activiti.designer.editor.diagramEditor: An exception was thrown during initialization

java.lang.IllegalArgumentException: Argument cannot be null
at org.eclipse.swt.SWT.error(SWT.java:4263)
at org.eclipse.swt.SWT.error(SWT.java:4197)
at org.eclipse.swt.SWT.error(SWT.java:4168)
at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:128)
at org.eclipse.swt.graphics.ImageDataLoader.load(ImageDataLoader.java:22)
at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:331)
at org.eclipse.swt.graphics.Image.<init>(Image.java:545)
at org.activiti.designer.diagram.ActivitiToolBehaviorProvider.getPalette(ActivitiToolBehaviorProvider.java:682)
at org.eclipse.graphiti.ui.internal.editor.GFPaletteRoot.updatePaletteEntries(GFPaletteRoot.java:104)
at org.eclipse.graphiti.ui.internal.editor.GFPaletteRoot.<init>(GFPaletteRoot.java:80)
at org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior.createPaletteRoot(DefaultPaletteBehavior.java:103)
at org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior.getPaletteRoot(DefaultPaletteBehavior.java:115)
at org.eclipse.graphiti.ui.editor.DiagramEditor.getPaletteRoot(DiagramEditor.java:940)
at org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette.setEditDomain(GraphicalEditorWithFlyoutPalette.java:145)
at org.eclipse.graphiti.ui.editor.DiagramEditor.setConfigurationProvider(DiagramEditor.java:1890)
at org.eclipse.graphiti.ui.editor.DiagramEditor.setInput(DiagramEditor.java:553)
at org.activiti.designer.eclipse.editor.ActivitiDiagramEditor.setInput(ActivitiDiagramEditor.java:278)
at org.eclipse.graphiti.ui.editor.DiagramEditor.init(DiagramEditor.java:447)
at org.activiti.designer.eclipse.editor.ActivitiDiagramEditor.init(ActivitiDiagramEditor.java:131)

tiesebarrell
Champ in-the-making
Champ in-the-making
NorbertS,

you're right, the userguide is wrong. This is the old (probably from version 5.7 Smiley Happy) dependency and the GAV has changed. I've fixed the userguide in this regard (https://github.com/Activiti/Activiti/commit/85aa43ce36547254300842775c782b854f1ee03c). You shouldn't download the lib yourself, but just change it to the way it's specified in the money-tasks example project. Then Maven should just find it automatically.

AFAIK, there's nothing wrong with the money-tasks project. src/main/java is not a package structure, but the Maven convention for the root of Java sources. The packages start from that directory downward. You shouldn't have to change anything. If you run mvn eclipse:eclipse on the project, it should set all the source directories automatically and it will compile. Or if you have the m2eclipse plugin installed, just convert the project to a Maven project. And if you install the project using mvn clean install, you'll see that the Jar gets created just fine.

Using a custom directory to load resources such as resources/icons will not work, because when the Jar is built by Maven, that directory is not considered a source directory. If you built it with Maven, open up the Jar and you'll probably see the icons aren't really in the Jar. That's what probably gets you that NPE. Yes, you can use custom source directories in Maven but there's really no need in this case. If I were you, I'd go back to the defaults and try to get those working, because they require less tinkering.

This all has very little to do with Designer, but is mainly about getting the Maven stuff right. I understand it's frustrating but there's little I can say other than try to build the money-tasks example with Maven and then create something similar.

tiesebarrell
Champ in-the-making
Champ in-the-making
I've uploaded a default install of the Money Tasks JAR, which should work out of the box.

http://dl.dropbox.com/u/24350392/money-tasks-1.1.0-SNAPSHOT.jar

norberts
Champ in-the-making
Champ in-the-making
Alright. It works. Seems like I used Maven wrong the whole time. For example didn't I build the jar with maven but just exported the project as jar. And also I used the source-folder definition wrong. I created packages src.main.java and src.main.resources and not source folder src/main/java and so on.
Thanks for the time and help. It works. Now I can finally play around. Smiley Very Happy

But one more thing. I needed to change the pom.xml again. I had to alter the version definition to 5.12.0. Otherwise Maven couldn't find it.

m2spring
Champ in-the-making
Champ in-the-making
Norbert,
I've done a Designer extension which is registered via the palette extension provider extension point.
This lets you avoid the library path approach.
See
https://github.com/jenkinsci/jenkow-plugin/tree/master/jenkow-designer-extension
https://github.com/jenkinsci/jenkow-plugin/blob/master/eclipse/com.cisco.surf.jenkow.ide.config/src/...
Not fully sure whether this is what you're looking for.
Regards,
-Max