如何以编程方式在eclipse插件开发中调用save方法 [英] How can I call save method in eclipse plugin development programmatically

查看:186
本文介绍了如何以编程方式在eclipse插件开发中调用save方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个插件,点击一个按钮,我想调用eclipse的保存方法或者调用eclipse工具栏上的保存按钮。



有什么方法。

解决方案

  org.eclipse.ui.PlatformUI .getWorkbench()。saveAll(..)

应该做的伎俩。



如果要保存活动编辑器,请尝试

  IWorkbenchPage page = PlatformUI.getWorkbench ().getActiveWorkbenchWindow()getActivePage(); 
IEditorPart editor = page.getActiveEditor();
page.saveEditor(editor,true / * confirm * /);

请注意,导航路径中的元素可能为null。


I am developing a plug-in and on clicking a button, I'd like to call the save method of eclipse or call the save button on eclipse toolbar.

What is the way to do it.

解决方案

org.eclipse.ui.PlatformUI.getWorkbench().saveAll(..) 

should do the trick.

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插件开发中调用save方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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