Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339055 - [Property view] selection in the diagram is not taken in account in the property view
Summary: [Property view] selection in the diagram is not taken in account in the prope...
Status: RESOLVED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 0.8.0   Edit
Hardware: PC Windows XP
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: Patrick Tessier CLA
QA Contact: Yann Tanguy CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-07 03:36 EST by Patrick Tessier CLA
Modified: 2011-03-17 11:21 EDT (History)
2 users (show)

See Also:


Attachments
tempory patch (738 bytes, text/plain)
2011-03-07 03:37 EST, Patrick Tessier CLA
no flags Details
Patch that a postlistener on a DiagramGraphcialViewer (1.52 KB, text/plain)
2011-03-07 05:38 EST, Patrick Tessier CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Tessier CLA 2011-03-07 03:36:00 EST
1. select a n element in the diagram
	--> the property sheet page is updated
2. select another element in the diagram
	--> the property view is not updated.
	
The property sheet page has now post listener, before it was only a listener.
But the event for the post listener during the selection of diagram is not send.

So  I have added a small patch, the is only a tempory patch in order to refresh the property view.
Comment 1 Patrick Tessier CLA 2011-03-07 03:37:24 EST
Created attachment 190517 [details]
tempory patch

This not a solution only to allow developer working with the property view
Comment 2 Patrick Tessier CLA 2011-03-07 05:09:14 EST
the property view is refresh by a post listener:

In a normal case:
the DiagramGraphicalViewer has postListener given by  the PageSelectionService.

But in the case of papyrus the mutlieditpageSite cannot add a postlistener to the DiagramGraphicalViewer because the DiagramGraphicalViewer do not Implement IPostSelectionProvider. 

if(selectionProvider != null) {
			selectionProvider.addSelectionChangedListener(getSelectionChangedListener());
			if(selectionProvider instanceof IPostSelectionProvider) {
				((IPostSelectionProvider)selectionProvider).addPostSelectionChangedListener(getPostSelectionChangedListener());
			}
		}

So I will study why and How, in the case of a simple editor, the PageSelectionListener add a postListener to the graphicalViewer
Comment 3 Patrick Tessier CLA 2011-03-07 05:17:52 EST
 Code that comes from WindowSelectionService (line287):
 
 
  if (newPart != null) {
            activeProvider = selectionProvider;
            // Fire an event if there's an active provider
            activeProvider.addSelectionChangedListener(selListener);
            ISelection sel = activeProvider.getSelection();
            fireSelection(newPart, sel);
            if (activeProvider instanceof IPostSelectionProvider) {
				((IPostSelectionProvider) activeProvider)
                        .addPostSelectionChangedListener(postSelListener);
			} else {
				activeProvider.addSelectionChangedListener(postSelListener);
			}
            firePostSelection(newPart, sel);
            
            
Here we see the PsotListener is always added as a PostListenr or normal listerner.
I will propose a patch to apply the same machanism.
Comment 4 Patrick Tessier CLA 2011-03-07 05:38:21 EST
Created attachment 190531 [details]
Patch that a postlistener on a DiagramGraphcialViewer

I'm waiting for your opinion before committing
Comment 5 Cedric Dumoulin CLA 2011-03-09 09:50:05 EST
More details about the problem:
- We have 3 main entities:
	- The PropertyView, listening on selectionChangedEvents from Papyrus
	- The DiagramGraphicalViewer, implementing ISelectionProvider, and throwing selectionChangedEvents
	- Papyrus, contains multiple DiagramGraphicalViewer. It also provide a main selectionProvider implementing ISelectionChanged and IPostSelectionChanged (by the way of its site and MultiPageSelectionProvider)
	
- The PropertyView ask to Papyrus its selectionProvider and listen on selection changed events. As MultiPageSelectionProvider implements both ISelectionChanged and IPostSelectionChanged, the PropertyView only listen on postSelectionChangedEvent.
- Each DiagramGraphicalViewer is registered to the nested editor site as a selectionChanged provider. The DiagramGraphicalViewer only send selectionChangedEvent (and not postSelectionChangedEvents)
- Papyrus (by the way of MultiPageEditorSite and MultiPageSelectionProvider) relay any selection changed events from nested editors to listeners registered to Papyrus main selectionProvider.

So, a DiagramGraphicalViewer send a selectionChangedEvent, which is relayed by Papyrus but the PropertyView only listen postSelectionChangedEvent. So it never see the event :-(.

The  patch propose to send  a second event of type postSelectionChangedEvent if the nested editor doesn't implements IPostSelectionChanged. This is implemented in org.eclipse.papyrus.sasheditor.internal.eclipsecopy.MultiPageEditorSite.
Comment 6 Patrick Tessier CLA 2011-03-17 11:20:25 EDT
patch apply in the branch
 done in the revision 4337
Comment 7 Patrick Tessier CLA 2011-03-17 11:21:35 EDT
Patch applied in the head (revision 4338)