调用EditorPart的doSaveAs比较容易,调用doSave方法稍微复杂一些,因为需要传入IProgressMonitor参数,如下声明
@Override
public void doSave(IProgressMonitor monitor) {
// Do the Save operation
}
@Override
public void doSaveAs() {
// Do the Save As operation
}IWorkbenchPage.closeEditor声明如下。
/** * Closes the given editor. The editor must belong to this workbench page. * <p> * If the editor has unsaved content and <code>save</code> is * <code>true</code>, the user will be given the opportunity to save it. * </p> * * @param editor * the editor to close * @param save * <code>true</code> to save the editor contents if required * (recommended), and <code>false</code> to discard any unsaved * changes * @return <code>true</code> if the editor was successfully closed, and * <code>false</code> if the editor is still open */ public boolean closeEditor(IEditorPart editor, boolean save);调用代码如下,关闭时是否保存根据实际需要设置save值即可
IWorkbenchPage page = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); page.closeEditor(page.getActiveEditor(), true);
RCP EditorPart 调用doSave的方法,布布扣,bubuko.com
原文:http://blog.csdn.net/jaysuper/article/details/25207611