Getting the selected connection [message #1048319] |
Wed, 24 April 2013 06:02  |
Eclipse User |
|
|
|
I have a requirement where I need to delete the connector selected in diagram.
I have created the connections of type ManhattanConnection.
I have defined MenuSelectionListener for the ContextMenuProvider in which I check following to get the selected Connector:
final IStructuredSelection selection = (IStructuredSelection) this.viewer
.getSelection();
if (selection.isEmpty()) {
return;
}
if (selection.getFirstElement() instanceof ManhattanConnectionEditPart) {
final ManhattanConnectionEditPart editPart =(ManhattanConnectionEditPart) selection
.getFirstElement();
final DiagramFeatureProvider fp = (DiagramFeatureProvider) editPart
.getFeatureProvider();
final Object association = fp
.getBusinessObjectForPictogramElement(editPart
.getPictogramElement());
if (association instanceof BuisnessObject) {
//invoke the deletion mechanism
}
But doing this I do not always get the connector that is selected for deletion.
This sometimes gives me the other connector which is not selected.
I tried debugging the getSelection method from ToolBehaviourProvider.
Is it that getSelection() method gives all the active shapes on diagram.
How to get only the selected connector and ignore that is not selected?
Do I need to overide some method in ToolBehaviouProvider or something?
|
|
|
|
Powered by
FUDForum. Page generated in 0.07074 seconds