码迷,mamicode.com
首页 > 其他好文 > 详细

RCP EditorPart 调用doSave的方法

时间:2014-05-07 15:08:58      阅读:348      评论:0      收藏:0      [点我收藏+]

标签:rcp

调用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的方法

标签:rcp

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!