Bug 497742 - Drag and drop of protocol in model explorer leads to bogus result
Summary: Drag and drop of protocol in model explorer leads to bogus result
Status: CLOSED FIXED
Alias: None
Product: Papyrus-rt
Classification: Modeling
Component: tool (show other bugs)
Version: 0.7.2   Edit
Hardware: PC Windows 7
: P3 normal
Target Milestone: 0.8.0   Edit
Assignee: Christian Damus CLA
QA Contact: Peter Cigehn CLA
URL:
Whiteboard:
Keywords: ui, usability
Depends on:
Blocks:
 
Reported: 2016-07-12 07:25 EDT by Adam Darvas CLA
Modified: 2016-09-29 14:52 EDT (History)
3 users (show)

See Also:


Attachments
setup (3.51 KB, image/png)
2016-07-12 07:29 EDT, Adam Darvas CLA
no flags Details
1st bug situation (5.56 KB, image/png)
2016-07-12 07:29 EDT, Adam Darvas CLA
no flags Details
2nd bug situation (5.54 KB, image/png)
2016-07-12 07:30 EDT, Adam Darvas CLA
no flags Details
3rd bug situation (5.15 KB, image/png)
2016-07-12 07:30 EDT, Adam Darvas CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Darvas CLA 2016-07-12 07:25:07 EDT

    
Comment 1 Adam Darvas CLA 2016-07-12 07:29:14 EDT
Created attachment 263051 [details]
setup
Comment 2 Adam Darvas CLA 2016-07-12 07:29:54 EDT
Created attachment 263052 [details]
1st bug situation
Comment 3 Adam Darvas CLA 2016-07-12 07:30:12 EDT
Created attachment 263053 [details]
2nd bug situation
Comment 4 Adam Darvas CLA 2016-07-12 07:30:47 EDT
Created attachment 263054 [details]
3rd bug situation
Comment 5 Adam Darvas CLA 2016-07-12 07:36:03 EDT
The tool behaves strangely when drag and dropping a protocol into a package that contains another protocol. 
Assume we have a model as depicted on attachment 'setup.pmg': protocol p1 resides in package Protocols, and another protocol p2 resides in package Structure. Each protocol having a single message.
Then drag and dropping p2 into package Protocols:

1) as captured on attachment '1st bug situation', results in p2 not moving but losing its declared message p2Msg.

2) as captured on attachment '2nd bug situation', results in p1 being overwritten by p2, and p1 seems to be lost from model. Furthermore, in model explorer it seems that p2's message is lost, while p1's message is kept. However, looking at the properties of the protocol (Real Time tab), p1's original message appears. So what is being displayed in the model explorer and what is displayed in the properties tab is inconsistent.

3) as captured on attachment '3rd bug situation', results in p2 being lost from the model.

Note: if the target of the DnD operation is the package icon of the Protocols package then the result is as expected.

Note: removing the 'UML-RT Protocols customization' helps in better seeing what is going on in the background and what causes this bug.
Comment 6 Charles Rivet CLA 2016-09-22 10:53:58 EDT
Confirmed by Peter via email.

Moving to new.
Comment 7 Eclipse Genie CLA 2016-09-26 18:28:25 EDT
New Gerrit change created: https://git.eclipse.org/r/81954
Comment 9 Christian Damus CLA 2016-09-27 14:28:02 EDT
(In reply to Eclipse Genie from comment #8)
> Gerrit change https://git.eclipse.org/r/81954 was merged to [master].

Note that this fix is in the element-type advice for the protocol-container.  Therefore, it will also be in effect when dragging and dropping stuff explicitly into protocol-containers when the protocol customization in Model Explorer is not active.  But, that seems sensible, as protocol-containers are not interesting as general-purpose packages and the particular kind of SetRequests that Model Explorer's drop assistant processes are only useful in the context of the Model Explorer.  (wholesale setting of a containment reference is, almost always, an odd thing to do)
Comment 10 Peter Cigehn CLA 2016-09-28 04:28:17 EDT
I have tested this in the latest Papyrus-RT build. It looks like case 2 and case 3 now works. 

Case 2 causes p2 to be moved inside the Protocols package and it is ordered before p1 as expected. 

Case 3 causes nothing to happen since it does not make sense to move p2 inside of p1. You do however get a dirty indicator on the model, even though nothing should have been changed. Not sure if this is expected or not.

But case 1, still seem to mess things up. Case 1 is really a "no-op", i.e. the semantic should be to still have p2 in the Structure package ordered after the Protocols package, i.e. basically it should stay "as-is". But when you do this drag-and-drop, what seem to happen is that the <<Protocol>> Collaboration of p2 gets dragged outside of its <<ProtocolContainer>> Package, which seemingly makes it loose its protocol message when you have the protocol customization enabled. Checking the .uml-file directly in the UML editor reveals that the Structure package now as packagedElements the <Package> Protocols, <<Protocol>> <Collaboration> p2 and <<ProtocolContainer>> <Package> p2, and the <<ProtocolContainer>> <Package> p2 does not contain its Collaboration.

PS. When testing this I initially got very confused also that we had some naming issues of the internal elements, apart from that things moved around in a wrong way. But I discovered that using F2 to rename the protocol only renamed the collaboration. Only when renaming the protocol in the properties view you get the correct name on all relevant internal elements of the protocol. I will write a separate Bugzilla for this. DS.
Comment 11 Eclipse Genie CLA 2016-09-28 16:01:31 EDT
New Gerrit change created: https://git.eclipse.org/r/82116
Comment 12 Christian Damus CLA 2016-09-28 16:03:56 EDT
(In reply to Peter Cigehn from comment #10)
> 
> But case 1, still seem to mess things up. Case 1 is really a "no-op", i.e.
> the semantic should be to still have p2 in the Structure package ordered
> after the Protocols package, i.e. basically it should stay "as-is". But when

Yes, this is subtly different:  the object relative to which the protocol is being dropped is not a another protocol but some other kind of element, so that Model Explorer finds the correct package to drop into but still has the wrong kind of object to drop.

(In reply to Eclipse Genie from comment #11)
> New Gerrit change created: https://git.eclipse.org/r/82116

This fixes that case #1, with a JUnit test for it.
Comment 14 Eclipse Genie CLA 2016-09-28 16:41:04 EDT
New Gerrit change created: https://git.eclipse.org/r/82120
Comment 15 Christian Damus CLA 2016-09-28 16:44:39 EDT
(In reply to Peter Cigehn from comment #10)
> 
> Case 3 causes nothing to happen since it does not make sense to move p2
> inside of p1. You do however get a dirty indicator on the model, even though
> nothing should have been changed. Not sure if this is expected or not.

This happens because the Model Explorer tries to drop the protocol into the nestedClassifier property of the message-set interface containing the operation, but it finds that the operation is not in the nestedClassifier property and so doesn't know where to position the dropped protocol in the nested classifiers list, and so just sets the already empty nested classifiers list to an empty list.  That's okay, but it is a useless command.

The same happens, btw, on attempt to drop a protocol next to a port or a part in a capsule.

(In reply to Eclipse Genie from comment #14)
> New Gerrit change created: https://git.eclipse.org/r/82120

This ensures that any attempt to drop a protocol into the nested classifiers of a class or interface in a UML-RT model is blocked.
Comment 17 Christian Damus CLA 2016-09-28 16:47:05 EDT
(In reply to Eclipse Genie from comment #13)
> Gerrit change https://git.eclipse.org/r/82116 was merged to [master].

(In reply to Eclipse Genie from comment #16)
> Gerrit change https://git.eclipse.org/r/82120 was merged to [master].
Comment 18 Peter Cigehn CLA 2016-09-29 07:00:37 EDT
I've tested this in the latest Papyrus-RT build and all the three originally reported cases now seem to work as expected.

Now when these basic ones are working, I played around a bit more with a few more cases, which did not behave as one would expect.

1) Two protocols contained in the same package. Try to reorder them by moving the first one after the other, i.e. the "head" of the move indicator should be at the same nesting level as the protocol itself and not nested inside the protocol. Nothing happens when you do this. Sure, when the "head" indicator is nested inside the protocol nothing should happen since you cannot move a protocol inside another protocol. But when you have the "head" nested at the same level I would have expected that you did a re-order of the protocols in the same package.

After some more testing with 3 protocols in a package, it looks to be the border case when trying to drop and move the protocol last in the package. If you drop the first protocol after the second then you are able to reorder. But not dropping the first after the third (and last) protocol in the package.

2) Two protocols contained in the same package. If you drop the first protocol directly after itself, i.e. basically perform a "no-op" since you move to the position in the containing package that it already have, then the protocols change order. This actually seem to be also some general issue, because I can see the same kind of behavior for ordinary model elements, e.g. a class. But for classes the behavior with swapping order, when it shouldn't, happens "random". Sometimes it performs the swap (when it shouldn't) and sometimes it works as expected, i.e. nothing happens since the drop shouldn't change order. For protocols though it is consistently changing the order, even if there should be a "no-op".

3) If you have three protocols in a package and drop the the second protocol before itself, i.e. basically perform a "no-op" since dropping before itself should not change the order, then the second and third protocol in the package changes order.

I am not sure if we shall try to fix these additional border cases within the scope of this Bugzilla, or if shall track them in new Bugzillas. Since there seem to be some issues also in base Papyrus with ordinary model elements, maybe there are some general issues needed to be fixed there.
Comment 19 Christian Damus CLA 2016-09-29 07:52:51 EDT
(In reply to Peter Cigehn from comment #18)
> 
> I am not sure if we shall try to fix these additional border cases within
> the scope of this Bugzilla, or if shall track them in new Bugzillas. Since
> there seem to be some issues also in base Papyrus with ordinary model
> elements, maybe there are some general issues needed to be fixed there.

Yes, the drag-and-drop implementation in Model Explorer in Papyrus needs work.  I don't like that it

* is not extensible to support DSML-specific drag-and-drop needs
* assumes dropping into the eContainer, without regard for its own facet
  customizations of the tree structure
* does not account for the fact that a dropped object may not be contained
  in the same EReference as the one it is dropped next to

Basically, it needs some overhaul in Papyrus to address the residual problems that you're seeing.  The issues raised by the OP are now fixed, so the rest should be tracked separately.
Comment 20 Peter Cigehn CLA 2016-09-29 08:33:34 EDT
I wrote Bug 502556 to track the issues identified in Comment 17 and the proposed improvements in Papyrus in Commen 18.

Putting this Bugzilla into verified, since the three original issues identified in Comment 5, all have been fixed in the latest Papyrus-RT build.
Comment 21 Charles Rivet CLA 2016-09-29 14:52:32 EDT
Closing in preparation of v0.8 release