【发布时间】:2017-03-05 19:32:58
【问题描述】:
我为 Intellij Idea 开发了包含代码编辑器的插件。而且我想使用 Intellij idea 内部编辑器 ui 实现,但我不知道如何将它添加到我的窗口中。 这是 XML:
<extensions defaultExtensionNs="com.intellij">
<toolWindow id="Playground" anchor="right" factoryClass="PlaygroundEditor" secondary="true"/>
</extensions>
代码:
public class PlaygroundEditor implements ToolWindowFactory {
private JPanel basePanel;
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
toolWindow.getContentManager().addContent(
ContentFactory.SERVICE.getInstance().createContent(basePanel, "", false)
);
Document document = EditorFactory.getInstance().createDocument("public static void main(String... args) {\n}");
document.setReadOnly(false);
EditorFactory.getInstance().createEditor(document);
EditorComponentImpl editorComponent = new EditorComponentImpl((EditorImpl) EditorFactory.getInstance().createEditor(document));
basePanel.add(editorComponent, new GridConstraints());
}
结果:
它不起作用,我不能在这里输入。你能帮我解决一下吗,也许你有使用 intellij idea api 的经验,因为当前的 api 描述太差了。
【问题讨论】:
标签: java swing intellij-idea plugins