eclipse-platform / eclipse.platform.ui

Eclipse Platform
https://projects.eclipse.org/projects/eclipse.platform
Eclipse Public License 2.0
81 stars 184 forks source link

Cheat Sheets - No menu item for reattaching a detached cheat sheet #273

Open smazzara opened 2 years ago

smazzara commented 2 years ago

Cheat Sheets have a "Detach" menu item, but after a cheat sheet is detached, there is no "Attach" menu item for reattaching it to the workbench window. The screen capture shows the tab menu for a detached cheat sheet.

Resetting the perspective does not reattach the cheat sheets either.

CheatSheetMenu
trancexpress commented 2 years ago

I believe detached views can be dragged into a part stack (similar to how you can re-order view tabs). Unfortunately I'm not familiar with Cheat Sheets, this doesn't work there?

smazzara commented 2 years ago

No, it does not. I am attaching an animated GIF illustrating this. Reattach

smazzara commented 2 years ago

So, it looks like I have to select a cheat sheet before I can reattach. I'm finding this to be poor design because there are two different models of interacting with the UI for detach (menu item) and reattach (drag and drop, but not until you have dismissed a modal window).

trancexpress commented 2 years ago

No, it does not. I am attaching an animated GIF illustrating this.

I assume the workflow here is:

  1. You interact with the main menu.
  2. A dialog is opened, that lets you choose a view.
  3. A view is opened after you are done with the dialog.

A view (in your screenshot: Properties, Outline, Git Repositories, Remote Systems) is a "special" concept in Eclipse. A view implements a specific interface and is contributed to Eclipse via a plug-in. A modal dialog such as the one you are dragging will not "fit" in a part stack (the areas that contain view tabs). A view can be detached and reattached, that is extra view functionality.

I'm finding this to be poor design because there are two different models of interacting with the UI for detach (menu item) and reattach (drag and drop, but not until you have dismissed a modal window).

The only way I know if re-attaching views is drag & drop (I might be missing knowledge here of course). Maybe someone will be interested in adding a menu item that allows a re-attach. Without looking into code I can't say how complicated that is. I see the detach menu item remains after the view is detached, likely a good opportunity to replace it with an "Attach" button. If I find time to check the code, I might make a crude patch suggestion. Might take a while though.

You can also detach views with drag & drop, for this you must drag the tab outside the Eclipse window (I'm not sure how that works if Eclipse is maximized and you have a single display). So technically only the detach is "asymmetric"; but I understand what you mean.

trancexpress commented 2 years ago

I checked the code, detaching is done via: org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.detach(MPartSashContainerElement, int, int, int, int)

Docking is done via: org.eclipse.e4.ui.workbench.addons.dndaddon.StackDropAgent.dock(MUIElement, int) (this will need to be moved, if we are implementing the attach)

To add an "attach" menu entry, we would need to remember which part stack the view was detached from (assuming upon attaching the part stack still exists). And attaching will not work after a restart (maybe some Eclipse 4.x model expert knows how the stored parent part stack could be persisted over a restart).

What I've not found yet is where the "docking" (on drag) code is closing the detached window. My quick hack attaches the view back, but leaves the detached window around...

Overall it doesn't seem to be that difficult to add an attach button, in terms of the attach functionality itself. Any changes will have to be checked by someone with good e4 knowledge though, personally I'm not knowledgeable enough about e4.

MarioMarinatoSTech commented 1 year ago

The Detach command on tabs used to have a toggle state, and could be used to reattach a view back to the main Window. But it changed when Eclipse 4 was introduced.

This is specially troublesome when you develop a RCP application with no Editor area. In this case, if the user detaches all views, there's no way to attach them back to the main window. This used to be possible, either by un-toggling the Detach command or by dragging the view into the main windows.

I always wondered why that decision was made.