java - 简单的 Eclipse 插件打开新文档

标签 java eclipse eclipse-plugin

当用户切换到其视角时,如何使 Eclipse 插件在主视图中打开新生成的文档(类似于 hello.txt 文件)?

最佳答案

类似这样的代码是此任务的典型代码:

String fileContents = ...;
IFile file = ...;
file.create(new ByteArrayInputStream(fileContents.getBytes()), true, null);
FileEditorInput input = new FileEditorInput(file);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().
    getActivePage().openEditor(input, THE_EDITOR_ID);

关于java - 简单的 Eclipse 插件打开新文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5640976/

相关文章:

android - 将 Android SDK 更新到 API 级别 17 时出错

Hadoop eclipse 插件 2.6 - 在 : "Map/Reduce location status updater". java.lang.NullPointerException 期间发生内部错误

java - 如何在 Robot Framework 中实现 java 库

java - Harmonyos 中 view.postDelayed(Runnable action, long delayMillis) 的等价物是什么?

java - 通过直接评估 lambda 来初始化变量

java - 如何在不同的包中正确组织一组实现接口(interface)的具体类?

java - 如何使用 Eclipse 开发 Java Servlet?

java - 将现有项目导入eclipse时,Maven根pom.xml标记为红色

java - Eclipse 的 Swing GUI 控件插件

java - 如何将模块安装为服务 - Android