Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tree view drag and drop. #61

Closed
wants to merge 1 commit into from

Conversation

tsmaeder
Copy link
Collaborator

@tsmaeder tsmaeder commented Jan 8, 2023

Signed-off-by: Thomas Mäder t.s.maeder@gmail.com

What it does

Adds support for contributing drag and drop controller in the tree view plugin API. The code tries to mimick the behaviour described in https://code.visualstudio.com/api/references/vscode-api#TreeDragAndDropController<T> as well as possible. I have also refactored some of the "drag into editor area" code to work with the new code (and fixed dragging external files into electron on windows as a "drive-by")

Contributed on behalf of ST Microelectronics

Fixes eclipse-theia#11778, Fixes eclipse-theia#11776

How to test

I have adapted the VS Code tree view sample to exercise the code added in the PR. The extension & source is attached to this PR.
The extension contributes a view called "Test View Drag and Drop", which you need to open.

The example implement multiple features:

  1. Drag and drop within the tree
    The dropped element should be moved under the element where it was dropped.
    Note that there seems to be a bug in our tree-view refresh code where the UI goes into an endless loop when you reparent the elements of the tree: It seems the parent field of the tree items is not properly updated when an item is reparented. I am pretty convinced this is not related to the changes in this PR.
  2. Drag an element to the editor area:
    This should open a *.js file from the extension itself: note that the cursor will be placed at line 10, column 6.
  3. Exercise the current drag and drop to the editor area. Drag from the file navigator and from the OS file explorer
  4. Exercise dropping files to the example view: the extension will show the first couple of bytes of the file content.

Review checklist

Reminder for reviewers

@tsmaeder
Copy link
Collaborator Author

tsmaeder commented Jan 8, 2023

Here's the extension to test:

custom-view-samples-0.0.1.zip

and here's the corresponding source:

tree-view-sample.zip

@sgraband sgraband self-requested a review January 9, 2023 08:27
Copy link

@sgraband sgraband left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes! From testing i have 3 comments/questions:

Minor: The link to the API in the description should be https://code.visualstudio.com/api/references/vscode-api#TreeDragAndDropController<T> i believe.

Should i be able to drag a local file into the editor frame in the browser variant? (Does not work for me on Ubuntu 20.04)

Should it be possible to drag a TreeItem to the root of the Tree or is this not supported? (This does also not work for me)

@tsmaeder
Copy link
Collaborator Author

Thank you for the changes! From testing i have 3 comments/questions:

Minor: The link to the API in the description should be https://code.visualstudio.com/api/references/vscode-api#TreeDragAndDropController<T> i believe.
yup

Should i be able to drag a local file into the editor frame in the browser variant? (Does not work for me on Ubuntu 20.04)
No, I don't think that should work: the editor drop works with URI's and we don't have that from the native DnD API.

Should it be possible to drag a TreeItem to the root of the Tree or is this not supported? (This does also not work for me)

Not sure, I'll check: by "root" you mean for example dragging to an empty space at the bottom of the view, right?

@sgraband
Copy link

Yes exactly. Thank you for checking!

@tsmaeder
Copy link
Collaborator Author

The VS Code doc says:

The target tree element that the drop is occurring on. When undefined, the target is the root.

so yes, dragging to an unoccupied area should work. Grr...

Copy link

@sgraband sgraband left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes! Looks good and works great!

…ipse-theia#11776

Adds support for contributing drag and drop controller in the tree view
plugin API

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
@tsmaeder tsmaeder force-pushed the 11778_tree_view_dnd branch from 5da9fe6 to 6789039 Compare January 12, 2023 13:54
@tsmaeder
Copy link
Collaborator Author

Opened eclipse-theia#11778

@tsmaeder tsmaeder closed this Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants