Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [bpmn2-modeler-dev] BPMN Extension - Error

Hi Ralph,

It worked. 

So I created a custom task and now I want to play around with the shape of it, but it isn't working.

I have attached files, please let me know if there is something wrong with it?

Regards,
Abdul

Date: Wed, 17 Jun 2015 22:27:07 +0200
From: ralph.soika@xxxxxxxxx
To: bpmn2-modeler-dev@xxxxxxxxxxx
Subject: Re: [bpmn2-modeler-dev] BPMN Extension - Error

Hi Abdul,

yes this tutorial did not show the perfect way to implement a runtime extension. I learned a lot during writing this tutorial ;-)
But we added the results of this work to the Wiki Page of the Eclipse BPMN framework with a lot of additional information:

https://wiki.eclipse.org/BPMN2-Modeler/DeveloperTutorials

Here you will find the more accurate tutorials which will help you to develop an extension.
Also a good starting point is to take a look on the BPMN example plugins here:
https://github.com/eclipse/bpmn2-modeler/tree/master/examples/plugins

I think this can help you to get started with you own extension.


Best regards
Ralph

On 17.06.2015 15:02, Abdul Wahab wrote:
Hi,

I am following the below link for the extension of BPMN 2.0 Eclipse plugin. It's a simple extension to add new property/ies for the task element.


I have Eclipse Luna (4.4.2) and BPMN Modeler (1.1.4) installed.

After following all those steps which have been mentioned in the link, I got an error at the end when I am trying to create a new BPMN 2.0 model file. (Please find attached files, screenshots of the steps and classes)

Any help in this regard will be highly appreciated. Looking forward to hear from you.

Regards,
Abdul Wahab


_______________________________________________
bpmn2-modeler-dev mailing list
bpmn2-modeler-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/bpmn2-modeler-dev


--
Imixs...extends the way people work together
We are an open source company, read more at: www.imixs.org

Imixs Software Solutions GmbH
Agnes-Pockels-Bogen 1, 80992 München
Web: www.imixs.com
Office: +49 (0)89-452136 16 Mobil: +49-177-4128245
Registergericht: Amtsgericht Muenchen, HRB 136045
Geschaeftsfuehrer: Gaby Heinle u. Ralph Soika

_______________________________________________ bpmn2-modeler-dev mailing list bpmn2-modeler-dev@xxxxxxxxxxx To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/bpmn2-modeler-dev

Attachment: TaskShape.png
Description: PNG image

package firstextension;

import org.eclipse.bpmn2.modeler.core.features.CustomShapeFeatureContainer;
import org.eclipse.emf.ecore.*;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.bpmn2.modeler.core.features.ShowPropertiesFeature;
import org.eclipse.bpmn2.modeler.core.model.ModelDecorator;
import org.eclipse.bpmn2.modeler.ui.features.activity.task.TaskFeatureContainer;
import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.IntermediateCatchEvent;
import org.eclipse.bpmn2.modeler.core.features.MultiUpdateFeature;
import org.eclipse.bpmn2.modeler.core.features.*;
import org.eclipse.bpmn2.modeler.core.features.label.UpdateLabelFeature;
import org.eclipse.bpmn2.modeler.core.preferences.ShapeStyle;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
import org.eclipse.bpmn2.modeler.core.utils.StyleUtil;
import org.eclipse.bpmn2.modeler.ui.features.event.IntermediateCatchEventFeatureContainer;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.features.ICreateFeature;
import org.eclipse.graphiti.features.IUpdateFeature;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
import org.eclipse.bpmn2.FlowElementsContainer;
import org.eclipse.bpmn2.Task;
import org.eclipse.bpmn2.Activity;
import org.eclipse.bpmn2.modeler.core.features.activity.AbstractAddActivityFeature;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
import org.eclipse.graphiti.mm.algorithms.MultiText;
import org.eclipse.graphiti.mm.algorithms.styles.Orientation;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeService;
import org.eclipse.graphiti.mm.algorithms.Rectangle;

public class TestTaskElementFeatureContainer1 extends
		CustomShapeFeatureContainer {
	 // these values must match what's in the plugin.xml
	 private final static String TYPE_VALUE = "TestTask";
	 private final static String CUSTOM_TASK_ID = "Imixs-BPMN2.customTask1";

	 public TestTaskElementFeatureContainer1() {
	 
	 }

	 @Override
	 public String getId(EObject object) {
	 // This is where we inspect the object to determine what its custom task ID should be.
	 // In this case, the "type" attribute will have a value of "MyTask".
	 // If found, return the CUSTOM_TASK_ID string.
	 //
	 // Note that the object inspection can be arbitrarily complex and may include several
	 // object features. This simple case just demonstrates what needs to happen here.
	 EStructuralFeature f = ModelDecorator.getAnyAttribute(object, "type");
	 if (f!=null) {
	 Object id = object.eGet(f);
	 if (TYPE_VALUE.equals(id))
	 return CUSTOM_TASK_ID;
	 }
	 
	 return null;
	 }


	 @Override
	 public ICustomFeature[] getCustomFeatures(IFeatureProvider fp) {
	 return new ICustomFeature[] {new ShowPropertiesFeature(fp)};
	 }
	 
	 @Override
	 protected TaskFeatureContainer createFeatureContainer(IFeatureProvider fp) {
		return new TaskFeatureContainer() {
			@Override
			public IAddFeature getAddFeature(IFeatureProvider fp) {
				return new AddTaskFeature(fp) {
				@Override
				protected void decorateShape(IAddContext context, ContainerShape containerShape, Task businessObject) {
					super.decorateShape(context, containerShape, businessObject);
					Rectangle selectionRect = (Rectangle)containerShape.getGraphicsAlgorithm();
					int width = 160;
					int height = 90;
					selectionRect.setWidth(width);
					selectionRect.setHeight(height);
						
					Task ta = BusinessObjectUtil.getFirstElementOfType(containerShape, Task.class);
					if (ta!=null) {
						Shape shape = containerShape.getChildren().get(0);
						ShapeStyle ss = new ShapeStyle();
						ss.setDefaultColors(new ColorConstant(144, 176, 224));
						StyleUtil.applyStyle(shape.getGraphicsAlgorithm(), ta, ss);
					}						
				}
				};
			}
	 };
	 }
}

Back to the top