Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Selection Listener
Selection Listener [message #1100758] Tue, 03 September 2013 14:56 Go to next message
Thomas Thonhofer is currently offline Thomas ThonhoferFriend
Messages: 25
Registered: July 2013
Junior Member
Hello

In my Graphiti editor I have a view, that should open, when a certain Shape is selected and change, when the user selects a different Shape. It should be similar to the behavior of a property sheet, but I cannot use a normal property sheet.
I tried to implement a selection Listener to achieve this. It looks like this:

private ISelectionListener listener = new ISelectionListener() {
		public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {

			StructuredSelection structuredSelection = (StructuredSelection) selection;	
			Object firstElement = structuredSelection.getFirstElement();
						
			if (firstElement instanceof ContainerShapeEditPart){

				if(((ContainerShapeEditPart)firstElement).getPictogramElement() instanceof ContainerShape){

					CustomContext cc = new CustomContext();
					ContainerShape cs = (ContainerShape) ((ContainerShapeEditPart)firstElement).getPictogramElement();

					

						PictogramElement[] pic = new PictogramElement[1];
						pic[0] = cs;
						cc.setPictogramElements(pic);

						...
						
												
					
				}

			}

		}
	};


For opening the View, this solution works.
The problem is: Apparently the Listener only reacts, when a different EditPart is selected. All my PictogramElements have the same EditPart, so nothing happens when selecting a different Shape.
Is there any kind of listener, provided by Graphiti, to achieve this?

I hope someone can help me find a way to solve this problem.

Thank you
Re: Selection Listener [message #1101423 is a reply to message #1100758] Wed, 04 September 2013 12:46 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Thomas,

DiagramEditor has a method selectionChanged that is called in that case.
Instead of writing your own listener you could subclass and hook yourself in
there.

Michael
Re: Selection Listener [message #1103025 is a reply to message #1101423] Fri, 06 September 2013 10:00 Go to previous message
Thomas Thonhofer is currently offline Thomas ThonhoferFriend
Messages: 25
Registered: July 2013
Junior Member
That's, what I was looking for. It works now.

Thank you Michael
Previous Topic:how to get file path created by wizard after the wizard execute
Next Topic:Property View - not refreshed after undo
Goto Forum:
  


Current Time: Thu Apr 25 23:23:08 GMT 2024

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

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

Back to the top