[英]How to open a new editor using dnd in Eclipse RCP 3
I need to create drag and drop for my app. 我需要为我的应用创建拖放。
I have a tree in the left part of the window and empty editor area in the right part of the window. 我在窗口的左侧有一棵树,在窗口的右侧有一个空的编辑器区域。 I want to drag an element from the tree and drop to the right part. 我想从树中拖动一个元素并拖放到右侧。 Editor tab should opens after that. 之后,编辑器标签将打开。
What I have already done: I created the button to open editor of selected tree item and it works. 我已经完成的工作:我创建了打开所选树项目的编辑器的按钮,并且该按钮起作用了。 When I drag item and drop it to the existed editor a new editor opens. 当我将项目拖放到现有的编辑器中时,将打开一个新的编辑器。 But I can't to do the same when I don't have any editor (only empty editor area) 但是当我没有任何编辑器(只有空的编辑器区域)时,我无法做同样的事情
Please tell me what should I do or what should I specify like target for drop action. 请告诉我该怎么做或应该指定什么,例如放置动作的目标。 Thanks in advance! 提前致谢!
In your RCP's worbench window advisor class you need to set up the editor area drag/drop transfer types and the drop adapter in the preWindowOpen
method. 在RCP的worbench窗口顾问程序类中,需要在preWindowOpen
方法中设置编辑器区域的拖放传输类型和放置适配器。
For example Eclipse itself uses: 例如,Eclipse本身使用:
public void preWindowOpen() {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance());
configurer.addEditorAreaTransfer(ResourceTransfer.getInstance());
configurer.addEditorAreaTransfer(FileTransfer.getInstance());
configurer.addEditorAreaTransfer(MarkerTransfer.getInstance());
configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter(
configurer.getWindow()));
Note that EditorAreaDropAdapter
is an internal class so you can't use it, you will have to write your own drop adapter. 请注意, EditorAreaDropAdapter
是一个内部类,因此您无法使用它,您将必须编写自己的放置适配器。 This is likely to end up calling IWorbenchPage.openEditor
这很可能最终调用IWorbenchPage.openEditor
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.