|
|
Re: Diagram editor for Non-emf model [message #899981 is a reply to message #899835] |
Fri, 03 August 2012 06:38   |
Eclipse User |
|
|
|
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 05:08] by Moderator
|
|
|
Re: Diagram editor for Non-emf model [message #900773 is a reply to message #899981] |
Wed, 08 August 2012 08:48  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02890 seconds