vscode extension CustomTextEditor Drag'n Drop - drag-and-drop

I want to drop TreeViewItem into my CustomEditor.
I've implemented a DocumentDropEditProvider that is working well for a "normal" text editor.
But I don't know how to make it work on my CustomTextEditor or its webView.
I couldn't find anything in the documentation.
I've cloned the vscode and run it in debug mode and I don't see any place where a Drag and Drop Listener would have been registered for the CustomTextEditor (besides the one that handles the shift key/editor open).
Is it something that one can do or should I look into using webView instead of treeView to have a better control of Drag and Drop listener ?

Related

How to detect VSCode panel visibility from the extension code?

I would like to create an extension to toggle all the currently visible panels by a single shortcut. So something like the command "Hide/show All Tool Windows" from JetBrains IDEs, which I think is still missing in VS Code.
VS Code can have up to 3 panels visible:
Sidebar (the left-side panel)
Panel (the bottom panel)
AuxiliaryBar (the new right-side panel)
For that purpose, I need to detect the current state of all the panels from the extension code, so I can toggle only the panel(s) which are currently visible.
But alas I can't find it anywhere in the documentation. This page (https://code.visualstudio.com/api/references/when-clause-contexts) contains several variables like sideBarVisible, but I really don't get how to access those context variables from the vscode namespace which you can access from the extension.
import * as vscode from 'vscode';
So, is there a way how to detect if the panel is open or closed from the extension code?
Do you really need to know whether they are open or closed? Can't you just toggle them all?
vscode.commands.executeCommand('workbench.action.toggleSidebarVisibility')
vscode.commands.executeCommand('workbench.action.togglePanel')
vscode.commands.executeCommand('workbench.action.toggleAuxiliaryBar')

Detecting a click on Grid while row editor is opened in buffered mode

I want to show the dialog box by clicking on a different row (with options to save changes or cancel).
When Editor is open, it will catch the click and is stoping the event propagation, thus underlying Grid does not get the click event and ItemClickEvent is not being fired.
Is it possible to detect a click on the grid row through extensions or another way?
Is it possible to detect a click on the grid row through extensions or another way?
Technically speaking yes. E.g. GridFastNavigation add-on does this trick in order to make possible single click editor opening.
But you could also listen to Editor opening, see (https://vaadin.com/download/release/8.3/8.3.1/docs/api/com/vaadin/ui/components/grid/Editor.html#addOpenListener-com.vaadin.ui.components.grid.EditorOpenListener- ) when you are in unbuffered mode Editor already open, editor will re-open on the row you click. This catching this event could help you find a way.

How to make GraphicalEditorWithFlyoutPalette's PaletteView visible on first start

My GEF editor (extending GraphicalEditorWithFlyoutPalette) always opens the editor with the palette hidden on first start of the application / first opening of the editor (after a build for example).
As this will potentially bewilder users who'll need to go in search of the flyout icon first, I'd like to have the palette view shown whenever the editor is opened. The user can then choose to close it on his/her preferences.
How can I achieve this? The API doesn't seem to give any clues, or I'm unable to find them...
The state of the palette defines if it is open or closed. This state is accessible using the getPalettePreferences().setPaletteState() method that is accessible in the GraphicalEditorWithFlyoutPalette. To open the palette, you must set it to the FlyoutPaletteComposite.STATE_PINNED_OPEN, like this:
getPalettePreferences().setPaletteState(FlyoutPaletteComposite.STATE_PINNED_OPEN);
If you want to ALWAYS override the state so that the palette is always opened with the editor, you have to add the line to the constructor of your editor. If you only want to do this once, and then leave the state as it was last selected by the user... No idea how to do this :-(

Adding menu listener for Paste option in SWT Browser

I have a org.eclipse.swt.browser.Browser instance created in a composite. I would like to know when some content is pasted in the browser using the (platform specific) right click context menu and selecting the paste option.
In the menuDetected() of MenuDetectListener, I get a notification when the context menu is detected in the browser.
How can I know if the Paste option is selected from the context menu?
Regards,
Noopur
No you can't access the selected context menu item. There is no direct provision for that. At least not in eclipse 3.7. Although, you could try different combinations of events for determining the menu item. For example, in windows the internet explorer populates the status bar with 'inserts the clipboard...' when your mouse pointer hovers over the Paste menu item, you can capture this using StatusTextListener event.
Note: The hack is not an elegant solution, even if you get it working, there is still some possibility that it may break with new or older releases of SWT or in fact its behavior may vary with operating systems !!

Eclipse Back/Forward navigation using mouse buttons

There is an addin for Visual Studio called MouseNavi that allows you to use mouse thumb buttons to navigate your history.
Does a similar extension exist for Eclipse?
I don't know of any Eclipse plugin that does this, but assuming you're using Windows:
This one should enable you to do what you want: http://www.highrez.co.uk/downloads/XMouseButtonControl.htm
With that tool you can assign each mouse button a sequence of keys (Alt+Left for example) and because it can be made application specific it won't interfere with other programs where you don't want that mapping.
Alt+Left and Alt+Right to navigate through the latest opened editors.
Also, Alt+L to open up the shortcuts popup, so you can see what's available.
No real mouse navigation control though (not that I know of... at least). Although, should not be very difficult to create one and attach it to the same handlers that deal with the navigation commands.
^Q takes you to last edited location. You can cycle using it. No mouse bindings.