Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Listening selection change
Listening selection change [message #632511] Wed, 13 October 2010 09:13 Go to next message
VincentL is currently offline VincentLFriend
Messages: 88
Registered: July 2009
Member
Hi,

How could I listen selection change in graphiti ? (I mean when pictogram element are
clicked/selected in the diagram, or unselected)

I would like to change visibility of some shape when items are selected.

Thanks

Regards,
Re: Listening selection change [message #632568 is a reply to message #632511] Wed, 13 October 2010 13:30 Go to previous message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Vincent,

you may do that using the workbench's selection service:

ISelectionService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
service.addSelectionListener(new ISelectionListener() {

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection sel = (IStructuredSelection) selection;
			if (!sel.isEmpty() 
                              && sel.getFirstElement() instanceof EditPart) {
				EditPart ep = (EditPart) sel.getFirstElement();
				if (ep.getModel() instanceof PictogramElement) {
					// do your thing
                                        System.out.println(ep.getModel());
				}
			}
		}

	}
});

Best, Tim
Re: Listening selection change [message #632570 is a reply to message #632511] Wed, 13 October 2010 13:20 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1915
Registered: July 2009
Location: Walldorf, Germany
Senior Member
You can subclass DiagramEditor and override any of the initialization
methods (e.g. initializeGraphicalViewer). There you can add a
ISelectionChangedListener to the graphical viewer (getGraphicalViewer()).

Michael


"Vincent L." <lapointe_vincent_1975@hotmail.com> wrote in message
news:i93t17$ck$1@news.eclipse.org...
> Hi,
>
> How could I listen selection change in graphiti ? (I mean when pictogram
> element are clicked/selected in the diagram, or unselected)
>
> I would like to change visibility of some shape when items are selected.
>
> Thanks
>
> Regards,
>
>
>
>
>
Previous Topic:Property sheet integration when domain objects not emf based
Next Topic:dealing with canceled commands (or ones that didn't apply changes)
Goto Forum:
  


Current Time: Tue Apr 07 20:43:36 GMT 2020

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

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

Back to the top