Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BPMN 2.0 Modeler » Create Elements Programmatically
Create Elements Programmatically [message #1775421] Mon, 30 October 2017 07:39 Go to next message
Umut Kazan is currently offline Umut KazanFriend
Messages: 25
Registered: February 2017
Junior Member
Hello,

I want to create my elements programmatically. I have a Unity(C#) editor and when user drag and drop an element such as start event in Unity editor, text should be sent by socket to the my bpmn editor and start event should be created. How can i achieve this?

Regards
Umut Kazan

[Updated on: Mon, 30 October 2017 07:40]

Report message to a moderator

Re: Create Elements Programmatically [message #1775660 is a reply to message #1775421] Thu, 02 November 2017 21:01 Go to previous messageGo to next message
Ralph Soika is currently offline Ralph SoikaFriend
Messages: 192
Registered: July 2009
Senior Member
I am not sure if this is possible, because Eclipse BPMN2 is based on EMF and the Eclipse Graphiti project. The editor is based on visual editing only (I think). So even when you change the underlying BPMN file with your data send from your Editor this will not effect the graphical representation. This would only happen if you change EMF Object structure (by adding new or modifying existing objects).
So if you just change the bpmn file you need to close and reopen the editor.
Re: Create Elements Programmatically [message #1775661 is a reply to message #1775660] Thu, 02 November 2017 21:04 Go to previous messageGo to next message
Ralph Soika is currently offline Ralph SoikaFriend
Messages: 192
Registered: July 2009
Senior Member
Mybe you can take a look at this tutorial pages:
https://wiki.eclipse.org/BPMN2-Modeler/DeveloperTutorials/ModelExtension
https://wiki.eclipse.org/BPMN2-Modeler/DeveloperTutorials/Adapters

===
Ralph
Re: Create Elements Programmatically [message #1775851 is a reply to message #1775661] Tue, 07 November 2017 09:23 Go to previous messageGo to next message
Umut Kazan is currently offline Umut KazanFriend
Messages: 25
Registered: February 2017
Junior Member
Thank you Ralph,

I have figured how to do it :)

Umut
Re: Create Elements Programmatically [message #1776722 is a reply to message #1775851] Mon, 20 November 2017 18:28 Go to previous messageGo to next message
Ralph Soika is currently offline Ralph SoikaFriend
Messages: 192
Registered: July 2009
Senior Member
Great! Ban you share a code snippet how you solved it?
Re: Create Elements Programmatically [message #1776756 is a reply to message #1776722] Tue, 21 November 2017 08:46 Go to previous message
Umut Kazan is currently offline Umut KazanFriend
Messages: 25
Registered: February 2017
Junior Member
                IWorkbench wb = PlatformUI.getWorkbench();
		IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
		IWorkbenchPage page = window.getActivePage();
		IEditorPart editor = page.getActiveEditor();
		final SbpMultiPageEditor sbpMPE = (SbpMultiPageEditor) editor;
		IFeature createTask = (IFeature) getCreateFeature(shape.getType(), sbpMPE.getDesignEditor().getDiagramTypeProvider().getFeatureProvider());
		CreateContext createCon = new CreateContext();
		createCon.setX(shape.getX());
		createCon.setY(shape.getY());
		createCon.setHeight(-1);
		createCon.setWidth(-1);
		createCon.setTargetContainer(sbpMPE.getDesignEditor().getDiagramTypeProvider().getFeatureProvider().getDiagramTypeProvider().getDiagram());

		AbstractCreateFlowElementFeature createTaskFeature = (AbstractCreateFlowElementFeature) createTask;
		FlowElement element = (FlowElement) createBusinessObject(createCon, createTaskFeature.getBusinessObjectClass());
		element.setId(shape.getId());
		element.setName(shape.getName());
		if (element != null)
		{
			try
			{
				final ModelHandler handler = ModelHandler.getInstance(sbpMPE.getDesignEditor().getDiagramTypeProvider().getFeatureProvider()
						.getDiagramTypeProvider().getDiagram());
				final FlowElement finalElement = element;
				// System.out.println(finalElement);
				// handleProperties(finalElement);
				final CreateContext finalCreateCon = createCon;
				EditorUtil.ExecuteInTransactionalDomain(new IExecutable()
				{

					@Override
					public void execute()
					{

						handler.addFlowElement(BusinessObjectUtil.getBusinessObjectForPictogramElement(finalCreateCon.getTargetContainer()),
								finalElement);
						AddContext addContext = new AddContext(finalCreateCon, finalElement);
						sbpMPE.getDesignEditor().getDiagramTypeProvider().getFeatureProvider().addIfPossible(addContext);
					}
				}, sbpMPE.getDesignEditor().getEditingDomain());
			}
			catch (IOException e)
			{
				Activator.logError(e);
			}

		}


I don't know if this will help anybody because there are several custom methods and class but the idea is create the context and business object(flow element). Then add it to editor.

Umut
Previous Topic:I want to add an customxml editor.
Next Topic:Creating more than one extension
Goto Forum:
  


Current Time: Tue Apr 16 23:03:16 GMT 2024

Powered by FUDForum. Page generated in 3.59807 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top