|
Re: Tree Representation: delete sub-element reference [message #1804544 is a reply to message #1804480] |
Thu, 28 March 2019 14:36 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.01950 seconds