以编程方式保存 Eclipse 编辑器 [英] Save an Eclipse editor programmatically

查看:22
本文介绍了以编程方式保存 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 编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆