简体   繁体   English

以编程方式将文本添加到编辑器eclipse插件

[英]Programmatically adding text to the editor eclipse plugin

I'm developing an eclipse plugin , and at some point in my plugin , a jframe is opened , and inside the jframe, there is a button . 我正在开发一个eclipse插件,并且在插件中的某个点上,打开了一个jframe,并且在jframe中有一个button。 I have added a mouselistener to the button , and when pressed , I want some code to be added to the editor at caret point . 我在按钮上添加了一个鼠标侦听器,当按下该按钮时,我希望在插入符处将一些代码添加到编辑器中。 but, I get null pointer exception here: 但是,我在这里得到空指针异常:
IWorkbenchPage page = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage();

It appears you don't have an active page. 看来您没有活动页面。 Maybe your Swing based code is displaying a separate window? 也许基于Swing的代码正在显示一个单独的窗口?

Use IWorkbenchWindow.getPages() to get an array of IWorkbenchPage containing all the pages and look through the pages for the one containing the editor you want. 使用IWorkbenchWindow.getPages()获得包含所有页面的IWorkbenchPage数组,并浏览页面以查找包含所需编辑器的页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM