This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 302758 - [UI] Add Drag and Drop
Summary: [UI] Add Drag and Drop
Status: RESOLVED WORKSFORME
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Eric Moffatt CLA
QA Contact: Eric Moffatt CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-12 14:37 EST by Eric Moffatt CLA
Modified: 2013-06-06 13:58 EDT (History)
4 users (show)

See Also:
emoffatt: review?
emoffatt: review? (susan)


Attachments
Patch that updates DnD to handle placeholders (2.98 KB, patch)
2010-05-26 15:33 EDT, Eric Moffatt CLA
no flags Details | Diff
Don't allow drops onto elements not in the same top level window (2.72 KB, patch)
2010-06-25 16:14 EDT, Eric Moffatt CLA
no flags Details | Diff
Fix DnD issues (13.33 KB, patch)
2010-07-20 16:15 EDT, Eric Moffatt CLA
no flags Details | Diff
Revised patch... (17.07 KB, patch)
2010-07-21 09:33 EDT, Eric Moffatt CLA
no flags Details | Diff
Ooops, last patch contained some unfinished TrimStack work... (13.13 KB, patch)
2010-07-21 09:37 EDT, Eric Moffatt CLA
no flags Details | Diff
Patch revised according to feedback (15.39 KB, patch)
2010-07-21 15:48 EDT, Eric Moffatt CLA
no flags Details | Diff
stippled position marker (6.19 KB, image/png)
2010-07-21 16:03 EDT, Stefan Mücke CLA
no flags Details
screenshot of stippled marker with patch (win7) (28.52 KB, image/png)
2010-07-21 16:21 EDT, Susan McCourt CLA
no flags Details
screenshot (108.27 KB, image/png)
2010-07-21 16:32 EDT, Susan McCourt CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Moffatt CLA 2010-02-12 14:37:36 EST
We need to support the same level of customization as the legacy workbench window. This defect will track the work for this item.

Need to be able to (at least):

- Drag a part from one stack to another, including insertion at a particular index

- Drag ToolItems from one Toolbar to another, including insertion

- Insert a Part or Stack into a newly created slot in the sash structure, includes the creation of new PartSashContainers if necessary.

- Move any trim element to any other place in the trim. This has to include the ability to drop onto 'virtual' trim sides (i.e. ones that haven't actually been added to the model yet. Note that ToolBars are trim elements so this covers moving TB's as well.

- Click and drag to start; ESC to cancel
Comment 1 Eric Moffatt CLA 2010-02-12 15:13:53 EST
Committed in >20100212. Added the ability to drag parts between stacks and items between toolbars. Note that the element being dragged is still contained within the model so that it can be 'live' (i.e. it still has access to the Window's context...).

Susan, the code is essentially broken into 4 classes and I'm pretty sure they'll change somewhat over time...;-)

DragAndDropUtil: Contains code that will gather up model-related information from the current cursor position. I suspect that this functionality may end up in the model service.

DnDManger: This is the SWT listener logic. It controls the DnD gesture's start and finish as well as controlling the feedback during a drag. This feedback currently comes in three independent manners:

- cursor feedback (currently a 'hand' for a valid drop location and a 'no' if the location is not valid)
- through a specialized MWindow that contains the element being dragged and tracks with the cursor (see DragHost below).
- through graphics on an 'Overlay' shell. Currently this just does a bad job of drawing rects around the current tab 'item'.

DragHost: this is a class that creates a special type of 'MWindow' (identified by being tagged with DragHostId). The actual creation of the shell is done in the WBWRenderer which is where you can see the 'Alpha' value being set. Note that we could likely set the alpha value using CSS if that's better. We can also mess with any number of funky values (scaling, rotation, fades) to get the look we want.

Overlay: This is another form of feedback. This is a specialized shell that sits on top of the 'base' window and allows *any* type of graphics to be drawn on it. We have to be careful to match the 'Region' to the actual displayed graphics since this allows the underlying shell to be shown 'though' the overlay.
Comment 2 Eric Moffatt CLA 2010-02-12 15:37:49 EST
Adding Susan.
Comment 3 Eric Moffatt CLA 2010-02-12 15:39:10 EST
Remy, if you synch this should allow dragging of parts from one stack to another in the compatibility IDE as well.
Comment 4 Eric Moffatt CLA 2010-05-26 15:33:32 EDT
Created attachment 170080 [details]
Patch that updates DnD to handle placeholders
Comment 5 Eric Moffatt CLA 2010-06-21 09:52:17 EDT
Still need to add support for dragging stacks (mostly to facilitate detached windows...
Comment 6 Eric Moffatt CLA 2010-06-25 16:14:59 EDT
Created attachment 172809 [details]
Don't allow drops onto elements not in the same top level window
Comment 7 Eric Moffatt CLA 2010-06-25 16:16:16 EDT
Committed in >20100625. Applied the patch.
Comment 8 Remy Suen CLA 2010-07-08 09:24:57 EDT
Eric, do you want to close this bug? I think the major work has been completed, yes?
Comment 9 Stefan Mücke CLA 2010-07-16 16:05:29 EDT
DnD functionality is not yet complete:

1. Open a fresh e4 workbench
2. Detach the Package Explorer
3. Try to restore the original layout by dragging
   the Package Explorer back to its previous position

Result: Not possible.

Also missing:
- Dragging a whole stack by dragging the stack header
- Dragging trim bars
- Dragging a part out of a trim bar
- Dragging a part into a trim bar
- Reordering of parts inside a trim bar

I think this should be fixed for 4.0, if possible (at least the above scenario with the Package Explorer).
Comment 10 Eric Moffatt CLA 2010-07-20 10:50:48 EDT
Stefan, I'm re-working the DnD right now to at least address the ability to drag views back into the main layout...

Most of the rest of the scenarios you mention will likely have to wait until post release...
Comment 11 Eric Moffatt CLA 2010-07-20 16:15:31 EDT
Created attachment 174791 [details]
Fix DnD issues


This patch has three parts:

Wire up the StackDropAgent for special handling to allow dragging Views back into an empty editor area (while still allowing them to be added to the stack itself if desired..drag near the top).

Change the SplitDropTarget to correctly create a stack of the correct type depending on the type of part being dragged as well as ensuring that if we are splitting the editor area with a *view* that we ensure that the split occurs in the main layout (not the EA).

Change the CleanupAddon to handle removing empty Editor stacks (except for the last one).

The change in LazyStackRenderer is just some safety code that I want to leave in because anything that sets a part's Context parent to 'null' is guaranteed bad...;-).
Comment 12 Eric Moffatt CLA 2010-07-20 16:17:27 EDT
Susan, you may want to try some of the other scenarios you were mentioning to see if there are still any holes...
Comment 13 Stefan Mücke CLA 2010-07-20 16:24:15 EDT
Eric, can you have a look at bug 320344. This bug still exists after the patch.
Comment 14 Stefan Mücke CLA 2010-07-20 17:15:16 EDT
(In reply to comment #13)
> Eric, can you have a look at bug 320344. This bug still exists after the patch.

Oops. Sorry for the missing question mark. This was unintentional.
Comment 15 Susan McCourt CLA 2010-07-20 17:38:21 EDT
I played with the patch a bit.  

I verified that the Package Explorer scenario in comment 9 is now working (whereas before it was not).  There is a big improvement in the ability to get detached windows back into a new spot, so I think this fix is worth doing.

Also verified that you can drag a view into an empty editor area and it creates a new stack next to it.

There are still some holes, but nothing I see as stop-ship.  I do think we should describe the limitations on the missing features page.  Note that I'm just listing problems I found, I did not check to see how the behavior was before the patch.  

1.  Open two files (two editors in the EA).
2.  Try to drag one of the editors as a detached view.
->Doesn't work.  Known issue.  We should doc this.
3.  Now drag one of the editors into its own stack (I created one to the right of the outliner).
4.  From the new stack, try to drag the editor as a detached window
->You get an empty detached window and the editor is gone.


1.  Open two files (two editors in the EA).
2.  Drag one of the editors into the outliner stack.
3.  From the outliner stack, try to drag the editor as a detached window
->You get an empty detached window and the editor is gone.

These empty floaters are a nuisance because you can't close them and they appear on top, but reset perspective seemed to clear it up (at least until bug 320320).
Comment 16 Eric Moffatt CLA 2010-07-21 09:33:34 EDT
Created attachment 174848 [details]
Revised patch...


1) Prevents directly detaching an Editor

2) Only makes stacks inside the Editor Area 'EditorStacks'. This is to prevent the having 'maximize' buttons on stacks that aren't in the EA.
Comment 17 Eric Moffatt CLA 2010-07-21 09:37:32 EDT
Created attachment 174849 [details]
Ooops, last patch contained some unfinished TrimStack work...
Comment 18 Boris Bokowski CLA 2010-07-21 13:03:19 EDT
- do we need a try..finally in DnDManager.startDrag so that the cleanup code is guaranteed to be run?
- there's a sysout in DnDManager.startDrag
- look for visble children (instead of all children) when checking if you're dropping into the same stack
Comment 19 Boris Bokowski CLA 2010-07-21 13:10:34 EDT
One more thing Eric and I realized while testing the patch: we're creating "an endless hall of mirrors (erm, part sash containers) over time. Tracked by bug 320344 .
Comment 20 Boris Bokowski CLA 2010-07-21 13:37:09 EDT
Yet another thing (but not related to the patch): On the Mac, I sometimes don't get the rectangle feedback (only the drag cursors).
Comment 21 Boris Bokowski CLA 2010-07-21 13:58:59 EDT
We need a tracker.dispose()
Comment 22 Susan McCourt CLA 2010-07-21 14:58:10 EDT
(In reply to comment #21)
> We need a tracker.dispose()

see also bug 320341 (awaiting Eric review) as it will touch the same code.

I'm still testing this patch.

Source review is a bit hard to follow for me for the hairy stuff (SplitDropAgent, etc.).

One nit:
I was initially confused by this comment in StackDropAgent (line 61)

	// If we're in the 'tab area' then allow the drop, else split
			
Presumably the "else split" is handled by virtue of returning false and letting the SplitDropAgent handle it.  So I prefer:

	// If we're in the 'tab area' then allow the drop, else assume another
        // agent, such as split, will handle it.
Comment 23 Eric Moffatt CLA 2010-07-21 15:48:25 EDT
Created attachment 174903 [details]
Patch revised according to feedback


This also contains the fix for 320344 as well as a change to where the DetachedDropAgent places the rect relative to the cursor.

I've included some CleanupAddon work as well this time that will remove empty editor stacks unless it's the last one...
Comment 24 Eric Moffatt CLA 2010-07-21 15:57:19 EDT
BTW, setting the stippled to true seems to have trashed the feedback when dragging in the tab area (what used to be a vertical line is now just two dots).

We can either revert this or I can see if there's a rectangle width that works...
Comment 25 Stefan Mücke CLA 2010-07-21 16:03:41 EDT
Created attachment 174906 [details]
stippled position marker

For me, the stippled position marker works fine on Windows 7 (before patch). See screenshot.
Comment 26 Stefan Mücke CLA 2010-07-21 16:12:58 EDT
(In reply to comment #24)
> BTW, setting the stippled to true seems to have trashed the feedback when
> dragging in the tab area (what used to be a vertical line is now just two
> dots).

Eric, I have just tested your patch. I works fine for me. Rectangle is as before the patch.
Comment 27 Susan McCourt CLA 2010-07-21 16:21:15 EDT
Created attachment 174913 [details]
screenshot of stippled marker with patch (win7)

looks ok for me with patch on win 7.
If this proves troublesome on other platforms we should remove it and punt the stipple bug to post 4.0.

Testing latest patch...
Comment 28 Stefan Mücke CLA 2010-07-21 16:22:42 EDT
Eric, after the patch I have just discovered a bug (don't know if it existed
before):

1. Detach the Package Explorer
2. Detach the Package Explorer again, i.e.,
   drag it off the detached window and drop
   it outside the workbench window.

Result: Package Explorer will disappear. Detached container window empty. NPE on the console.
Comment 29 Susan McCourt CLA 2010-07-21 16:32:00 EDT
Created attachment 174916 [details]
screenshot

maximizing an editor area caused two editor areas to get maximized.  I created the second one in the course of dragging an editor to a new stack.  Is this maximize behavior expected?
Comment 30 Stefan Mücke CLA 2010-07-21 16:35:33 EDT
This is how it works in 3.6. I find this useful.
Comment 31 Susan McCourt CLA 2010-07-21 16:37:02 EDT
(In reply to comment #28)
> Eric, after the patch I have just discovered a bug (don't know if it existed
> before):
> 
> 1. Detach the Package Explorer
> 2. Detach the Package Explorer again, i.e.,
>    drag it off the detached window and drop
>    it outside the workbench window.
> 
> Result: Package Explorer will disappear. Detached container window empty. NPE
> on the console.

Same result before the patch.  Package Explorer will disappear.
On 3.6, it realizes that this is just a move (the cursor changes accordingly to indicate it's not a stack manipulation, just a move).
Comment 32 Susan McCourt CLA 2010-07-21 16:39:41 EDT
(In reply to comment #30)
> This is how it works in 3.6. I find this useful.

you are right.  
For some reason, having the view stuck in there is confusing me.  I was thinking we have two editor stacks, not a split, and therefore only the one stack should maximize.  But this is an implementor's point of view...to the end user that distinction doesn't matter anyway.
Comment 33 Boris Bokowski CLA 2010-07-21 16:58:47 EDT
(In reply to comment #32)
> (In reply to comment #30)
> > This is how it works in 3.6. I find this useful.
> 
> you are right.  
> For some reason, having the view stuck in there is confusing me.  I was
> thinking we have two editor stacks, not a split, and therefore only the one
> stack should maximize.  But this is an implementor's point of view...to the end
> user that distinction doesn't matter anyway.

Well, the appearance is not quite right (both editor stacks have a maximize button) but at least we know exactly what's going on. This should go on the list of things to go over once 4.0 has shipped.
Comment 34 Boris Bokowski CLA 2010-07-21 17:00:16 EDT
(In reply to comment #31)
> Same result before the patch.  Package Explorer will disappear.

Stefan, could you please open a new bug for this, since it is not a regression introduced by the current patch?
Comment 35 Stefan Mücke CLA 2010-07-21 17:04:05 EDT
(In reply to comment #34)
> Stefan, could you please open a new bug for this, since it is not a regression
> introduced by the current patch?

I'll open a bug for this.

Another bug: When dropping a view into a split editor area, the preview rectangle will appear only on one of the editors, but the view will be dropped alongside both editors. In other words, the rectangle should cover the whole editor area.
Comment 36 Stefan Mücke CLA 2010-07-21 17:23:08 EDT
(In reply to comment #35)
> Another bug: When dropping a view into a split editor area, the preview
> rectangle will appear only on one of the editors, but the view will be dropped
> alongside both editors. In other words, the rectangle should cover the whole
> editor area.

I have opened bug 320557 for that.
Comment 37 Eric Moffatt CLA 2010-07-21 17:25:22 EDT
Nice feedback!

We know we need an actual 'editor area' visual container to cover off the button issues and removing the confusion as to what's 'in' or 'out'...later (I'm gonna beg bodgan for a special CTF (superclass?) that draws a border and manages the min/max buttons...tb?)

I'll certainly look into the detach a detached case (wire it off if it gets too deep).

Nice piclup on the rectangle for the dragging a view into a split editor area, fix should be just to base the rect calculation of of what would be the 'relTo' on the drop (i.e. make a 'getRelTo' method and use it in the rect calcs).
Comment 38 Boris Bokowski CLA 2010-07-21 17:44:26 EDT
+1
Comment 39 Eric Moffatt CLA 2010-07-21 17:59:32 EDT
Committed in >20100722. Applied the patch.

I'll wait a bit before marking this 'fixed' ;-)
Comment 40 Boris Bokowski CLA 2010-07-24 18:58:22 EDT
(In reply to comment #39)
> Committed in >20100722. Applied the patch.
> 
> I'll wait a bit before marking this 'fixed' ;-)

Time to mark this fixed.
Comment 41 Eric Moffatt CLA 2011-02-24 14:11:08 EST
Re-opening for polish work...
Comment 42 Eric Moffatt CLA 2011-02-24 14:14:27 EST
Committed in >20110224. Checked in changes for a new approach to DnD...at least some more work will be needed before M6 ends but at least I can start with this code...
Comment 43 Dani Megert CLA 2013-06-05 10:57:00 EDT
Removing outdated target milestone.
Comment 44 Eric Moffatt CLA 2013-06-06 13:58:55 EDT
I'm going to close this defect. We already have a few others open for Luna work...