Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Getting the selected connection
Getting the selected connection [message #1048319] Wed, 24 April 2013 10:02 Go to next message
Saniya Mirajkar is currently offline Saniya Mirajkar
Messages: 30
Registered: August 2012
Member
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?
Re: Getting the selected connection [message #1051828 is a reply to message #1048319] Mon, 29 April 2013 09:00 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1618
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Saniya,

you can get the current selection from the DiagramEditor using
getSelectedPictogramElements(). Have you tried that method instead of
installing the listener?

Michael
Previous Topic:Image resize and rotate
Next Topic:Shape resize behaviour
Goto Forum:
  


Current Time: Tue Oct 21 16:53:03 GMT 2014

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

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