Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Diagram editor for Non-emf model
icon4.gif  Diagram editor for Non-emf model [message #899810] Thu, 02 August 2012 12:23 Go to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 31
Registered: August 2012
Member
We have model represented in tree view in jface viewer, now we need to invoke graphical editor on right click of tree view node . Model is non-emf object.

When we invoke editor initially , it should display model entity in simple graphical form (eg. rectangle).

We dont want to persist graphical layout of model diagram, we just need to display in default shape whenever user opens an editor, after that user will be able to edit model using graphical editor.



Please suggest exact steps we need to follow to open graphical editor for non-emf model.
Is there any tutorial Confused available for non-emf based model example ?
Re: Diagram editor for Non-emf model [message #899835 is a reply to message #899810] Thu, 02 August 2012 14:01 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
There is a "Graphiti Developer Guide" under the eclipse help available.

This guide contains a tutorial and there is also a chapter for non-EMF models.
Re: Diagram editor for Non-emf model [message #899981 is a reply to message #899835] Fri, 03 August 2012 10:38 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 31
Registered: August 2012
Member
Thanks Matthias for reply.

We have defined an action class in which we are trying to invoke the graphical editor.
We need to draw simple shape on this editor.

We are getting the following error when trying to invoke the add feature for the domain object:

"[ERROR] Cannot modify resource set without a write transaction"

We are using following code to create and open the graphiti editor:

final String diagramTypeId = "test.graphiti.nonemf.diagram";
			
			final Diagram diagram = Graphiti.getPeCreateService()
					.createDiagram(diagramTypeId,
							"test.graphiti.nonemf.diagram.DiagramType", false);

			final String editorID = NonEmfDiagramEditor.DIAGRAM_EDITOR_ID;

			IFile diagramFile = project.getFile("Test" + "." + "diagram");

			URI uri = URI.createPlatformResourceURI(diagramFile.getFullPath()
					.toString(), true);

			TransactionalEditingDomain editingDomain = FileService
					.createEmfFileForDiagram(uri, diagram);
			String providerId = "test.graphiti.nonemf.diagram.DiagramTypeProvider";
			DiagramEditorInput editorInput = new DiagramEditorInput(
					EcoreUtil.getURI(diagram), editingDomain, providerId, true);

			PlatformUI.getWorkbench().getActiveWorkbenchWindow()
					.getActivePage().openEditor(editorInput, editorID);


We have defined an Add feature corresponding to our domain object.

Now I try to invoke the add feature using following function :

private void createExampleStructure(final IDiagramTypeProvider ddtp,
			final TransactionalEditingDomain editingDomain,
			final Diagram diagram, DomainObject domainObject) {

		int x = 20;
		int y = 20;

		AddContext addcontext = new AddContext();
		IFeatureProvider featureprovider = ddtp.getFeatureProvider();

		AddVariableFeature addFvFeature = new AddVariableFeature(
				featureprovider);

		addcontext.setNewObject(domainObject);
		addcontext.setTargetContainer(diagram);

		addcontext.setX(x);
		addcontext.setY(y);

		if (addFvFeature.canAdd(addcontext)) {
			addFvFeature.add(addcontext);
		}

	}



Please let me know if this is correct way to invoke the add feature.Also need some inputs for in-memory diagrams.

[Updated on: Thu, 09 August 2012 09:08]

Report message to a moderator

Re: Diagram editor for Non-emf model [message #900773 is a reply to message #899981] Wed, 08 August 2012 12:48 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
You need to run any model modification code from within a transaction of the
current TransactionalEditingDomain (EMF Transactions are used within
Graphiti). For an example of that and how to fill a diagram while creating
it, see the classes in the package o.e.g.examples.tutorial.handlers in the
Graphiti tutorial plugin. The define an Eclipse handler and command that all
all existing EClasses of the project into a new diagram; also note the
additional entries in plugin.xml.

Michael
Previous Topic:Diagram Layout
Next Topic:Updating a diagram after saving its business model to database
Goto Forum:
  


Current Time: Fri Apr 26 10:14:36 GMT 2024

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

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

Back to the top