如何在eclipse中保存打开的编辑? [英] How to save opened editors in eclipse?

查看:165
本文介绍了如何在eclipse中保存打开的编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个eclipse插件,用于保存打开的编辑器。
我知道扩展VS演示是好的,但还有其他更好的插件?

解决方案

此代码应该保存所有在eclipse中打开(脏)编辑器:

  IEditorReference [] editorReferences = PlatformUI.getWorkbench()。getActiveWorkbenchWindow()。getActivePage() .getEditorReferences(); 
NullProgressMonitor monitor = new NullProgressMonitor();
if(editorReferences!= null){
for(IEditorReference iEditorReference:editorReferences){
IEditorPart editor = iEditorReference.getEditor(false);
if(editor.isDirty())
editor.doSave(monitor);
}
}

在较新版本的eclipse中,您可以做一个小快捷方式:

  IEditorPart [] dirtyEditors = PlatformUI.getWorkbench()。getActiveWorkbenchWindow()。getActivePage()。getDirtyEditors() 
(IEditorPart iEditorPart:dirtyEditors){
iEditorPart.doSave(monitor);
}

希望有帮助...


I need an eclipse plug-in, used to save opened editors. I know that Extended VS Presentation is good, but are there other better plugins?

解决方案

This code should save all open (dirty) editors in eclipse:

IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
NullProgressMonitor monitor = new NullProgressMonitor();
if ( editorReferences != null ){ 
    for (IEditorReference iEditorReference : editorReferences) {
        IEditorPart editor = iEditorReference.getEditor(false);
        if ( editor.isDirty() )
            editor.doSave(monitor);
    }
}

In newer versions of eclipse, you can make a small shortcut:

IEditorPart[] dirtyEditors = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getDirtyEditors();
for (IEditorPart iEditorPart : dirtyEditors) {
    iEditorPart.doSave(monitor);
}

Hope that helps ...

这篇关于如何在eclipse中保存打开的编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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