Save an Eclipse editor programmatically(以编程方式保存 Eclipse 编辑器)
本文介绍了以编程方式保存 Eclipse 编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个插件.
单击按钮时,我想调用 Eclipse 的保存方法或调用 Eclipse 工具栏上的保存按钮.
On clicking a button, I'd like to call the save method of Eclipse or call the save button on Eclipse toolbar.
有什么办法呢?
推荐答案
org.eclipse.ui.PlatformUI.getWorkbench().saveAll(..)
应该可以解决问题.
如果您想保存活动编辑器,请尝试
If you want to save the active editor, please try
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = page.getActiveEditor();
page.saveEditor(editor, true /* confirm */);
注意导航路径中的元素可能为空.
Note that the elements in the navigation path may be null.
这篇关于以编程方式保存 Eclipse 编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:以编程方式保存 Eclipse 编辑器


基础教程推荐
猜你喜欢
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- Java Swing计时器未清除 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 大摇大摆的枚举 2022-01-01