Bug 470237 - Set model operation do a add for multi-valued references
Summary: Set model operation do a add for multi-valued references
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2015-06-16 04:08 EDT by Esteban DUGUEPEROUX CLA
Modified: 2015-06-16 05:17 EDT (History)
1 user (show)

See Also:


Attachments
Example to reproduce. (8.99 KB, application/zip)
2015-06-16 04:08 EDT, Esteban DUGUEPEROUX CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Esteban DUGUEPEROUX CLA 2015-06-16 04:08:03 EDT
Created attachment 254458 [details]
Example to reproduce.

Using a Set model operation do a addAll() for multi-valued references instead of a set.
Scenario to reproduce :
1. Using the attached project, open the "new DiagramForBug467663Bis" diagram
2. Reconnect target edge from c1 to c2 => the original edge is always here because the Set model operation has kept c1 in the Component.references list.

The Sirius documentation doesn't specify this strange behaviour : "The expression’s result is then set as the new value" see https://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.html#set
Comment 1 Pierre-Charles David CLA 2015-06-16 05:17:56 EDT
While I agree the current behavior is strange, it is not possible to change it: it would cause hard to understand breakage on existing modelers which rely on it (perhaps unknowingly). We could provide an alternate operation, or a boolean option to the existing one.

Proposal:
* add a boolean SetValue.clearPreviousValue, which would be false by default (thus not requiring any migration of existing VSMs);
* in the UI, present it as a checkbox "Append to the existing values". It would be the inverse of the boolean, because I think it makes more sense at the UI level than the opposite wording.
* in the code, if SetValue is executed on a multi-valued feature *and* if clearPreviousValue is true, do the equivalent of a object.eGet(featureName).clear() before the normal add (or be a little smarter to avoid sending too many notifications).

In the meantime, this does not prevent improving the current documentation to make the current behavior explicit.