Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » How to avoid linking of diagram to the model object to be part of the command stack(How to avoid linking of diagram to the model object to be part of the command stack)
How to avoid linking of diagram to the model object to be part of the command stack [message #1130109] Wed, 09 October 2013 08:33 Go to next message
PALANI SANKAR is currently offline PALANI SANKAR
Messages: 35
Registered: April 2013
Member
Hi All

I am working on a scenario where in there are many tree objects, on selection of tree objects am removing elements from diagram and adding new elements(clearing and re-painting new diagram).

So on selection of tree am linking the diagram with selected tree object.
But the linking can happen only using command stack.

public void linkSelectedNodeToDiagram(final AbstractDiagramTypeProvider diagramTypeProvider, final Object selectedObject) {
TransactionalEditingDomain editingDomain = diagramTypeProvider.getDiagramBehavior().getEditingDomain();
CommandStack cStack = editingDomain.getCommandStack();
cStack.execute(new RecordingCommand(editingDomain, "Link Diagram to EObject", false) { //$NON-NLS-1$

@Override
protected void commandExecute() {
diagramTypeProvider.getFeatureProvider().link(diagramTypeProvider.getDiagram(), (EObject) selectedObject);
}

@Override
public void refreshUI() {

}

});

So i want a way to do this without command stack, because this is adding to undo and even if i set undo false, it is creating issues on each selection.

So can any one suggest a best way of linking without command stack.


Thanks
Palani


Thanks
Palani
Re: How to avoid linking of diagram to the model object to be part of the command stack [message #1130132 is a reply to message #1130109] Wed, 09 October 2013 08:49 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Palani,

I'm afraid that is not possible, at least not from inside an editor.
Graphiti uses EMF Transactions so every change to the model must be done in
a transaction which is recorded and ends on the command stack. Chaging the
model from inside an editor omitting the transaction will cause an
exception.

You may of course do that outside if the editor using your own means to
load, modify and save the EMF model.

Michael
Re: How to avoid linking of diagram to the model object to be part of the command stack [message #1130143 is a reply to message #1130132] Wed, 09 October 2013 08:58 Go to previous messageGo to next message
PALANI SANKAR is currently offline PALANI SANKAR
Messages: 35
Registered: April 2013
Member
Michael,

Can i use custom feature to achieve the same?Linking of diagram to selected tree object.I tried using custom feature but i dont know how to get the object inside custom feature.

Palani


Thanks
Palani
Re: How to avoid linking of diagram to the model object to be part of the command stack [message #1132774 is a reply to message #1130143] Fri, 11 October 2013 11:34 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Palani,

yes, this can also be done inside a custom feature. Retrieving the objects
might be tricky depending on your object hierarchy. You will have to
browse/navigate through it (possibly starting from the object the custom
feature is registered for or the diagram/your root object).

Michael
Previous Topic:Update diagram after business object has been deleted
Next Topic:Reusing EMF.Edit property sheet
Goto Forum:
  


Current Time: Mon Sep 22 00:13:29 GMT 2014

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

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