Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364046 - [regression] Perspective switcher does not allow to reorder prespectives
Summary: [regression] Perspective switcher does not allow to reorder prespectives
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.1   Edit
Hardware: PC Linux
: P3 normal with 22 votes (vote)
Target Milestone: 4.4 M2   Edit
Assignee: Eric Moffatt CLA
QA Contact: Eric Moffatt CLA
URL:
Whiteboard:
Keywords: helpwanted
: 347371 404182 424883 (view as bug list)
Depends on:
Blocks: 415234
  Show dependency tree
 
Reported: 2011-11-17 10:37 EST by Oded Arbel CLA
Modified: 2014-05-30 11:49 EDT (History)
30 users (show)

See Also:


Attachments
partial patch (4.86 KB, patch)
2013-05-14 10:39 EDT, Piotr Aniola CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oded Arbel CLA 2011-11-17 10:37:11 EST
In Eclipse 3, when you have multiple perspectives in the perspective switcher (at the top right of the UI), then one can reorder the perspectives at will - for example bring the most used perspective closer to where its easy to click, or maybe order them in a manner logical to the work flow (Java followed by Java Debugging followed by Planning for the workflow "write -> test -> close ticket").

This is a very useful feature but currently in Eclipse 4, the order of the perspecives in the switcher is fixed to the order in which the user first opened them. As a result either the user has to preplan the order ahead of time or they are left with an eclectic order which is likely not comfortable to use.


-- Configuration Details --
Product: Eclipse 1.5.0.20110817-2116 (org.eclipse.epp.package.jee.product)
Installed Features:
 org.eclipse.platform 4.1.0.v20111028-9JF75H9DFrrFObSrtuR0yq-G6-r5Khfz0qGI_gBYI4vQg
Comment 1 Remy Suen CLA 2011-11-17 11:22:29 EST
Trim dragging is not supported yet at the moment.
Comment 2 Alexander Wessel CLA 2012-05-21 10:40:48 EDT
I guess it's too late for Juno, but a workaround might be to allow sorting of perspectives in the Preferences/General/Perspectives and get that into 4.2.1 or 4.3M1? I reckon this might be easier to implement and would allow users to have a more desirable/predictable behaviour when closing and opening perspectives frequently.

To me personally this is quite a "pet peeve" in 4.2 as of now, even though I mostly run with the same set of opened perspectives most of the time, with the "absolute ordering" being stable. That is, I don't need drag & drop if, for example, the debug perspective will always open between the java and firebug perspectives, if you know what I mean. ;)
Comment 3 Eric Moffatt CLA 2012-05-21 13:52:20 EDT
Thanks for the suggestion. Having 'Up' and 'Down' buttons on the pref page is a good idea. It might turn out to be even easier to do this the 'e4' way:

Add a command that will move a given perspective forwards or backwards in the list. I think we need two commands to allow is to have two bindings.

Make  sure that the Perspective Switcher correctly updates.

Make sure that no spurious rendering or activation is taking place.

The idea was to do this at the same time that we implement the ability to drag tool items around but it looks like that will have to wait to 4.3...
Comment 4 Paul Webster CLA 2012-05-22 09:36:08 EDT
(In reply to comment #3)
> Thanks for the suggestion. Having 'Up' and 'Down' buttons on the pref page is a
> good idea. It might turn out to be even easier to do this the 'e4' way:
> 

Eric, in the short term will re-ordering the perspectives in the model update the perspective switcher?  If so, it could possibly be done with the live model editor.

PW
Comment 5 Paul Webster CLA 2012-06-28 09:53:12 EDT
*** Bug 347371 has been marked as a duplicate of this bug. ***
Comment 6 Nobody - feel free to take it CLA 2012-07-05 20:19:55 EDT
I figured out you can actually reorder them by using the up and down arrows in the  perspectives in the live application model view. Took it to the limit and spawned some IAE from o.e.ui.internal but I actually reordered them by my needs.
Comment 7 Eric Moffatt CLA 2012-07-09 14:57:58 EDT
If the current implementation can't handle reordering it can easily be made to do so...

How about this for the first pass ?

We supply two commands which can be used to moves a perspective forwards / backwards through the list of perspectives. If no perspective is specified then the currently active perspective is used (so that folks can use this through Quick Access).
Comment 8 Alexander Wessel CLA 2012-11-14 22:01:39 EST
(In reply to comment #7)
> How about this for the first pass ?
> 
> We supply two commands which can be used to moves a perspective forwards /
> backwards through the list of perspectives. If no perspective is specified
> then the currently active perspective is used (so that folks can use this
> through Quick Access).

I'd +1 this, I'd really appreciate it. And it should easy enough to implement (and test) for 4.3M4 even? In fact, if this was possible, then drag & drop could be seen as something to redo whenever there's time, even post-4.3 IMHO.
Comment 9 Stevo Slavic CLA 2013-01-16 04:36:07 EST
+1
Comment 10 Tomasz Zarna CLA 2013-01-16 06:01:32 EST
(In reply to comment #9)
> +1

Please cast your vote.
Comment 11 Eric Moffatt CLA 2013-01-16 13:41:22 EST
Anybody up for doing a patch ? Basically make a command that:

1) Finds the MPerspectiveStack
2) Gets the current selected element
3) Moves the element that is *next to* the selectedElement before or after the selected element depending on which direction we're moving the current perspective

NOTE: Coding this up to move the non-selected element will result in a much smoother transition since removing / adding the currently selected element is likely to flicker even if you reset it afterwards...
Comment 12 Piotr Aniola CLA 2013-03-01 11:10:26 EST
I will try to create a patch for this.
Comment 13 Paul Webster CLA 2013-03-24 16:10:00 EDT
*** Bug 404182 has been marked as a duplicate of this bug. ***
Comment 14 Sergey Prigogin CLA 2013-03-30 17:21:15 EDT
This is a regression from 3.x. Please give it high priority.
Comment 15 Piotr Aniola CLA 2013-04-22 08:46:43 EDT
Any ideas how I can access the MPerspectiveStack from the command handler?
I tried having it @Inject-ed, but apparently, it's not in the command's event context.
Comment 16 Paul Webster CLA 2013-04-22 08:51:07 EDT
(In reply to comment #15)
> Any ideas how I can access the MPerspectiveStack from the command handler?
> I tried having it @Inject-ed, but apparently, it's not in the command's
> event context.

Where's the command handler?  At the Window level, or Application level?  Is it an Eclipse4 command handler or a subclass of AbstractHandler?

PW
Comment 17 Piotr Aniola CLA 2013-04-22 10:09:15 EDT
I added the handler in org.eclipse.ui.internal.
The handler is a Eclipse 3.x-style handler, subclassing AbstractHandler.
Comment 18 Paul Webster CLA 2013-04-22 10:29:13 EDT
(In reply to comment #17)
> I added the handler in org.eclipse.ui.internal.
> The handler is a Eclipse 3.x-style handler, subclassing AbstractHandler.

IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);

Then 

MWindow model = window.getService(MWindow.class);
EModelService modelService = window.getService(EModelService.class);
MPerspectiveStack perspectiveStack = modelService.findElements(model, null, MPerspectiveStack.class, null);

PW
Comment 19 Eric Moffatt CLA 2013-04-29 09:47:49 EDT
We'll fix this one in luna...
Comment 20 Sergey Prigogin CLA 2013-04-29 12:36:19 EDT
(In reply to comment #19)
> We'll fix this one in luna...

This is very very unfortunate since this is a regression from 3.8. Please reconsider.
Comment 21 Paul Webster CLA 2013-04-29 12:48:50 EDT
http://wiki.eclipse.org/Platform_UI/Plan/4.3 describes the priority list of what we're trying to fix for 4.3.  This just isn't high enough priority.

PW
Comment 22 Piotr Aniola CLA 2013-05-14 10:39:01 EDT
Created attachment 230945 [details]
partial patch

I created a patch that flips the perspectives in the MPerspectiveStack (so far only flipping "forward"). 
The perspectives being switched are not the ones I would expect - the order of MPerspective objects in the MPerspectiveStack does not match the order displayed on the screen.
What is the mapping between the objects in the model and their screen representation? I checked the classes PerspectiveStackRenderer and StackLayout, but no methods from these classes are invoked when the perspectives are swapped on the screen.
Comment 23 Sergey Prigogin CLA 2013-05-31 14:00:35 EDT
Please consider fixing this in 4.3.1.
Comment 24 Eric Moffatt CLA 2013-06-18 11:01:45 EDT
I'll tag it for the service release but no promises...if there are other gating defects this may get pushed back...
Comment 25 Roberto Marin CLA 2013-08-15 19:23:05 EDT
Eclipse Kepler also has the same problem.
Comment 26 Paul Webster CLA 2013-08-15 19:55:49 EDT
Wojtek, it looks like Eric has a solution for this problem.

PW
Comment 27 Eric Moffatt CLA 2013-08-16 10:13:37 EDT
Changing milestone since the first commit will be to master...
Comment 28 Eric Moffatt CLA 2013-08-16 10:33:08 EDT
Committed

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=29cfa0e28e182fe7fdbf42512452f183afa1828f

This implements a (fake) drag and drop to move the perspectives around. There are currently two issues we've seen:

1) If you drag the active perspective then the drop causes a flicker as the main toolbar recalculates its state (fairly minor IMO)

2) We've seen a *very* strange effect where the image for an item will change into some other image (like the drop-down triangle or some other toolbar's button's image). I can't seem to get this using the current code but please re-open the defect if you see this or other issues...

Once this gets into a build we should try it on all the platforms to ensure its behavior is OK.
Comment 29 Eric Moffatt CLA 2013-08-21 10:15:35 EDT
I'll likely want to make a couple of tweaks before we back port this:

1) It turns out that we do get a 'DragDetect' event from a ToolBar, we should use this rather than my current hard-coded 'DRAG_TOLERANCE' approach

2) The reason that the text appears below the image on the drag image is that the ToolBar I construct needs the SWT.RIGHT flag set...
Comment 30 Christopher Barber CLA 2013-09-03 15:06:28 EDT
(In reply to Sopot Cela from comment #6)
> I figured out you can actually reorder them by using the up and down arrows
> in the  perspectives in the live application model view. Took it to the
> limit and spawned some IAE from o.e.ui.internal but I actually reordered
> them by my needs.

In Kepler (4.3) I didn't see the Live Application Model View in the list of Views, but it did show up with Ctrl-3. I found the perspectives under Windows -> Trimmed Window -> Controls -> PartSashContainer -> Perspective Stack. I had to restart Eclipse for the changes to take effect.
Comment 31 Eric Moffatt CLA 2013-09-16 14:09:20 EDT
Committed:

http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=2a9641a52fcc58703882ed492852437f52d24313

Applies the tweaks outlined in comment #29.

There are still some remaining issues on Linux that Paul and I will look at tomorrow...
Comment 32 Daniel Rolka CLA 2013-09-17 05:27:18 EDT
Verified in the build: I20130916-2330-win32
Comment 33 Sergey Prigogin CLA 2013-10-18 01:32:48 EDT
With this fix reordering of perspectives provides much better visual feedback on GTK than reordering of editor tabs (bug 404684) or reordering of toolbars (bug 419803). Maybe the other dragging operations can be improved based the ideas used for the perspective switcher.
Comment 34 Eric Moffatt CLA 2013-11-22 14:12:59 EST
After re-testing on Paul's machine the issues we were seeing have gone away...
Comment 35 Wojciech Sudol CLA 2014-01-04 12:20:37 EST
*** Bug 424883 has been marked as a duplicate of this bug. ***
Comment 36 Wojciech Sudol CLA 2014-05-30 11:49:44 EDT
Verified in I20140528-2000.