Eclipse 工作台选择
我编写了一段代码来获取源代码并选择 Eclipse 的部分。如果我们单击视图或编辑器,它将显示该对象,如果我们选择某些内容,它将显示所选项目。同样的方式也可以用于对话和其他操作。例如,如果我单击一个对话框,它应该是对话框名称或对象。对于我在工作台上单击的任何对象,同样的方式它应该是什么对象。包括动作。以下是我的代码。
private ISelectionListener listener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
System.out.println(sourcepart, selection);
}
};
我得到了命令。我们可以将 IExecutionListener 用于它们附加到工作台的任何命令。现在我想要动作、对话等等。
I have written one code for getting the source and selected of the part of the eclipse. If we click on the view or editor it will display the object and if we select something it will displayed the selected item.The same way is it possible to get for dialogues and others actions. For example if I click on one dialog it should the dialog name or object. The same way for whate ever object i clicked on the wokbench its hould whats the object.including actions. Following is my code.
private ISelectionListener listener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
System.out.println(sourcepart, selection);
}
};
I got the for the commands. we can use IExecutionListener for the what ever the command they have attached to the workbench. Now I want for actions,dialogues,etc..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的回答是:工作量很大。
查看插件间谍代码 (ALT+SHIFT+F1)。它查看 SWT 事件并使用事件中的小部件作为起点。然后,它必须利用其关于如何构造各种结构(视图、向导对话框、首选项对话框、属性对话框、编辑器、菜单、工具栏)的知识来确定是否有任何有用的信息。
要执行类似的操作,您必须查看构建特定对话框或操作的内容,并尝试找出如何提取该信息。对您关心的每个对话框重复此操作。
请参阅 org.eclipse.pde.internal.runtime.spy.SpyFormToolkit 以及 org.eclipse.pde.runtime 中的周边类。
The short answer: it's a lot of work.
Have a look at Plug-in Spy code (ALT+SHIFT+F1). It looks at SWT events and uses the widget in the event as a starting point. It then has to use its knowledge of how various structures are constructed (views, wizards dialogs, preference dialogs, property dialogs, editors, menus, toolbars) to figure out if there is any useful information.
To do something similar, you would have to look at what builds a specific dialog, or action, and try and figure out how to extract that information. Repeat for each dialog that you care about.
See
org.eclipse.pde.internal.runtime.spy.SpyFormToolkit
and surrounding classes inorg.eclipse.pde.runtime
.