|
|
|
|
|
|
|
Re: Iterating GMF diagram [message #725088 is a reply to message #725087] |
Tue, 13 September 2011 22:30 |
janpojer Messages: 40 Registered: July 2011 |
Member |
|
|
Right, I can see the structure... i have there the emf domain elements:
core.fn.impl.RequiredPortImpl@1c4fe21 (name: Challenge/Response CAS/DME_Signal_RQ_0, id: 996f0adc-2337-4524-976c-c8264d11978f)
and the gmf elements (the notation):
org.eclipse.gmf.runtime.notation.impl.NodeImpl@15687d9 (visible: true, type: 2003, mutable: false)
My question is how to remove both the notation and the domain element at once.
Or in oder words how to remove the domain element along with its gmf notation in the diagram...
[Updated on: Tue, 13 September 2011 22:31] Report message to a moderator
|
|
|
|
|
|
Re: Iterating GMF diagram [message #725200 is a reply to message #725059] |
Wed, 14 September 2011 08:14 |
|
On 13/09/2011 22:18, janpojer wrote:
> This is how I iterate the diagram resource:
>
>
> try {
> for (Iterator<Object> iter = EcoreUtil.getAllContents(res, true);
> iter.hasNext();) {
> EObject eObject = (EObject) iter.next();
> sw.doSwitch(eObject);
> }
> } catch (RuntimeException e) {
> FnDiagramEditorPlugin.getInstance().logError("Element initialization
> failed", e); }
I think you'd rather first get your root semantic element by retrieving
it from DiagramEditPart.resolveSemanticElement() - you can access the
DiagramEditPart either using iterating on getParent from any EditPart,
either by retrieving it from your GraphicalViewer - and then process it.
> And I am trying to figure out how to remove certain items from the
> resource (or add) based on some external conditions.
You should use the DeleteCommand for that, otherwise, you may cause
inconsistencies.
If you are trying to achieve it without opening an Editor, you should
use the OffscreenEditPartFactory that allows you to perform "normal" GMF
operations without seeing an editor open.
--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
|
|
|
|
Re: Iterating GMF diagram [message #725472 is a reply to message #725451] |
Wed, 14 September 2011 21:08 |
janpojer Messages: 40 Registered: July 2011 |
Member |
|
|
Ok,
so I got it. All what needs to be done is to remove the underlaying domain model element with following:
DeleteAction del = new DeleteAction( TransactionUtil.getEditingDomain(toDelete), true);
org.eclipse.emf.common.command.Command dCmd = del.createCommand(objToDelete);
TransactionUtil.getEditingDomain(toDelete).getCommandStack().execute(dCmd);
And it will remove all needed dependencies.
Thanks to all that helped me out.
[Updated on: Wed, 14 September 2011 21:08] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04801 seconds