Bug 469903 - [DND] improve the initial dnd framework to allow to manipulate multiple commands for one strategy
Summary: [DND] improve the initial dnd framework to allow to manipulate multiple comma...
Status: UNCONFIRMED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Diagram (show other bugs)
Version: 1.1.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 469719 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-06-11 03:39 EDT by Francois Le Fevre CLA
Modified: 2017-08-18 12:19 EDT (History)
2 users (show)

See Also:


Attachments
Test execution screenshot (82.27 KB, image/jpeg)
2015-07-21 11:11 EDT, Camille Letavernier CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Francois Le Fevre CLA 2015-06-11 03:39:20 EDT
initial DnD allows to retrieve only one command per strategy.
some strategies could retrieve multiple possible commands
Comment 1 Francois Le Fevre CLA 2015-06-11 05:11:31 EDT
*** Bug 469719 has been marked as a duplicate of this bug. ***
Comment 3 Camille Letavernier CLA 2015-07-21 11:10:03 EDT
> Gerrit change https://git.eclipse.org/r/49990 was merged to [master].

This commit causes UI Freeze by opening the Drag/Drop dialog during test execution

The following jobs are affected:

https://hudson.eclipse.org/papyrus/job/Papyrus-Master-Tests-Failures/ (Fails since this commit)
https://hudson.eclipse.org/papyrus/job/Papyrus-Master-Tests/ (Was already failing before, but now fails on this issue)
Comment 4 Camille Letavernier CLA 2015-07-21 11:11:26 EDT
Created attachment 255339 [details]
Test execution screenshot

Screenshot from the frozen Hudson job (Master-Tests-Failure)
Comment 5 Camille Letavernier CLA 2015-08-24 09:58:31 EDT
The current status of this task is definitely not satisfying:

- The CustomizableDropStrategy relies on a lot of highly restrictive "instanceof". The contract for the extension point is the "DropStrategy" interface. Most methods from CustomizableDropStrategy only handle "TransactionalCommandDropStrategy". I don't understand the various "return null" instructions for TransactionalCommandsDropStrategy, and implementations that are not transactional are simply ignored
- TransactionalCommandsDropStrategy offers a new API for handling multiple commands, but it is not an Interface. Developers cannot implement non-transactional drop strategies using multiple commands
- I couldn't find any example implementation of TransactionalCommandsDropStrategy in Papyrus, so this new feature that introduces so many regressions isn't even used

In the current state, I would rather revert these changes entirely, until a complete, clean and regression-free feature can be proposed
Comment 6 Francois Le Fevre CLA 2015-08-24 10:52:17 EDT
These code modifications are used in an extra plugins here:
https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/tree/extraplugins/uml/org.eclipse.papyrus.uml.diagram.dnd.smart

Perhaps I miss understand something because I have used "instanceof" in CustomizableDropEditPolicy after a meeting we had together where you have highlight that my previous implementation break the initial API.

There are only a few modifications (3 files), so perhaps you can create an additional bug with the additional requirements?
May we make a small meeting on the subject?

Francois
Comment 7 Camille Letavernier CLA 2015-08-25 03:50:26 EDT
> Perhaps I miss understand something because I have used "instanceof" in CustomizableDropEditPolicy after a meeting we had together where you have highlight that my previous implementation break the initial API.

Indeed; the issue is not the usage of "instanceof" as such; it is that it has been used in a highly restrictive way, allowing only two specific implementation classes to be used (While the contract from the extension point is that any class implementing DropStrategy is valid)

The right pattern would look like:

public interface MultipleDropStrategy extends DropStrategy {
	//new methods
}

Then in the runtime:

if (contribution instanceof MultipleDropStrategy) {
	//New behavior
} else {
	//Standard behavior
}

Which would work for any implementation of DropStrategy or MultipleDropStrategy. And in this case, we never rely on implementation-specific code (TransactionalDropStrategies are only provided as a helper implementation to simplify usage of transactions within Papyrus; they are absolutely not mandatory, and shouldn't be).
Comment 8 Francois Le Fevre CLA 2015-12-07 11:49:42 EST
A patch has been submitted here [1]

[1] https://git.eclipse.org/c/papyrus/org.eclipse.papyrus.git/commit/?id=4b1361f7269cf0db9ce94494de959859a64a1435