|
|
Re: Diagram editor for Non-emf model [message #899981 is a reply to message #899835] |
Fri, 03 August 2012 10:38 |
Saniya Mirajkar 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03425 seconds