Skip to main content

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 MirajkarFriend
Messages: 31
Registered: August 2012
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

        if (selection.isEmpty()) {

        if (selection.getFirstElement() instanceof ManhattanConnectionEditPart) {

            final ManhattanConnectionEditPart editPart =(ManhattanConnectionEditPart) selection
            final DiagramFeatureProvider fp = (DiagramFeatureProvider) editPart

            final Object association = fp

            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 WenzFriend
Messages: 1921
Registered: July 2009
Location: Walldorf, Germany
Senior Member

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

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

Current Time: Tue Aug 04 20:26:39 GMT 2020

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

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

Back to the top