Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Tree Representation: delete sub-element reference(How to 'delete' sub-node from super-node, when super-node is not the container?)
Tree Representation: delete sub-element reference [message #1804480] Tue, 26 March 2019 16:36 Go to next message
Mars Keez is currently offline Mars KeezFriend
Messages: 16
Registered: January 2015
Junior Member
Hi All

I have an "Entity" inside a "SubSpace" within a tree representation (as in the pic enclosed). The Subspace is not the Container of the entity, it only refers to it. Now I want to "delete" the Entity from the Subspace, i.e. I want to remove the reference from SubSpace to Entity by an unset of the refering variable of SubSpace.

How can I achieve this, when I only have the (semantic) "element" and "root" variables in the delete tool?

In other tools I have additionaly a container variable, that would make this an easy thing to do. But in delete I don't have this - for some reason?

Thx in advance
make

PS
best solution so far: disable Delete and write Creation tool to unassign Entity

index.php/fa/35131/0/
Re: Tree Representation: delete sub-element reference [message #1804544 is a reply to message #1804480] Thu, 28 March 2019 14:36 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Mars,

Unfortunately, these containerView or view variables are not present in the context of a Tree Item Delete Tool.
I suggest you to create a bugzilla there: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Sirius

The following workaround should work: you need to implement your tool with a java service.

Then you will be able to get the DTreeItem which is currently deleted:

ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
 if (selection instanceof TreeSelection && ((IStructuredSelection) selection).size() == 1) {  //IStructuredSelection
          Object firstElement = ((IStructuredSelection) selection).getFirstElement();
 


Then you should check that it is an instanceof DTreeItem:
- getContainer() will allow you to get the parent element (tree item or tree)
- getOwnedTreeItems() returns the list of DTreeItem children
- getTarget allows you to get the corresponding domain element (for the current selection, it will correspond to the value of the element variable)

Then you should be able to retrieve your SubSpace and remove the entity from the wanted reference.

Regards,


Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Tree Representation: delete sub-element reference [message #1804561 is a reply to message #1804544] Thu, 28 March 2019 18:01 Go to previous message
Mars Keez is currently offline Mars KeezFriend
Messages: 16
Registered: January 2015
Junior Member
Hi Maxime

That's great help.

Many thx!
make

PS
just submitted bug 545938

[Updated on: Fri, 29 March 2019 16:54]

Report message to a moderator

Previous Topic:Automatic creation diagram
Next Topic:Filter EObject-Tree shown in aird Editor
Goto Forum:
  


Current Time: Fri Apr 19 10:45:50 GMT 2024

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

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

Back to the top