首页 > 其他 > 详细

RCP EditorPart 调用doSave的方法

时间:2014-05-07 15:09:17      阅读:544      评论:0      收藏:0      [点我收藏+]

调用EditorPart的doSaveAs比较容易,调用doSave方法稍微复杂一些,因为需要传入IProgressMonitor参数,如下声明

@Override
	public void doSave(IProgressMonitor monitor) {
		// Do the Save operation
	}

	@Override
	public void doSaveAs() {
		// Do the Save As operation
	}

可以通过获取IWorkbenchPage,利用IWorkbenchPage作为管理工具进行EditorPart中doSave的调用。

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

RCP EditorPart 调用doSave的方法

原文:http://blog.csdn.net/jaysuper/article/details/25207611

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!