当前位置: 首页>>代码示例>>Java>>正文


Java IEditorReference.isDirty方法代码示例

本文整理汇总了Java中org.eclipse.ui.IEditorReference.isDirty方法的典型用法代码示例。如果您正苦于以下问题:Java IEditorReference.isDirty方法的具体用法?Java IEditorReference.isDirty怎么用?Java IEditorReference.isDirty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.IEditorReference的用法示例。


在下文中一共展示了IEditorReference.isDirty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: needsToSaveDirtyEditors

import org.eclipse.ui.IEditorReference; //导入方法依赖的package包/类
/**
 * Most SVN workspace actions modify the workspace and thus should
 * save dirty editors.
 * @see org.tigris.subversion.subclipse.ui.actions.SVNAction#needsToSaveDirtyEditors()
 */
protected boolean needsToSaveDirtyEditors() {

	IResource[] selectedResources = getSelectedResources();
	if (selectedResources != null && selectedResources.length > 0) {
		IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
		for (IEditorReference editorReference : editorReferences) {
			if (editorReference.isDirty()) {
				try {
					IEditorInput editorInput = editorReference.getEditorInput();
					if (editorInput instanceof IFileEditorInput) {
						IFile file = ((IFileEditorInput)editorInput).getFile();
						if (needsToSave(file, selectedResources)) {
							return true;
						}
					}
				} catch (PartInitException e) {}
			}
		}
	}
	
	return false;
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:28,代码来源:WorkspaceAction.java

示例2: showInEditor

import org.eclipse.ui.IEditorReference; //导入方法依赖的package包/类
private IEditorPart showInEditor(IWorkbenchPage page, IEditorInput input, String editorId) {
	IEditorPart editor= page.findEditor(input);
	if (editor != null) {
		page.bringToTop(editor);
		return editor;
	}
	IEditorReference reusedEditorRef= fReusedEditor;
	if (reusedEditorRef !=  null) {
		boolean isOpen= reusedEditorRef.getEditor(false) != null;
		boolean canBeReused= isOpen && !reusedEditorRef.isDirty() && !reusedEditorRef.isPinned();
		if (canBeReused) {
			boolean showsSameInputType= reusedEditorRef.getId().equals(editorId);
			if (!showsSameInputType) {
				page.closeEditors(new IEditorReference[] { reusedEditorRef }, false);
				fReusedEditor= null;
			} else {
				editor= reusedEditorRef.getEditor(true);
				if (editor instanceof IReusableEditor) {
					((IReusableEditor) editor).setInput(input);
					page.bringToTop(editor);
					return editor;
				}
			}
		}
	}
	// could not reuse
	try {
		editor= page.openEditor(input, editorId, false);
		if (editor instanceof IReusableEditor) {
			IEditorReference reference= (IEditorReference) page.getReference(editor);
			fReusedEditor= reference;
		} else {
			fReusedEditor= null;
		}
		return editor;
	} catch (PartInitException ex) {
		MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), SearchMessages.Search_Error_openEditor_title, SearchMessages.Search_Error_openEditor_message);
		return null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:41,代码来源:JavaSearchEditorOpener.java

示例3: showWithReuse

import org.eclipse.ui.IEditorReference; //导入方法依赖的package包/类
private IEditorPart showWithReuse(IFile file, IWorkbenchPage page, String editorId, boolean activate) throws PartInitException {
	IEditorInput input= new FileEditorInput(file);
	IEditorPart editor= page.findEditor(input);
	if (editor != null) {
		page.bringToTop(editor);
		if (activate) {
			page.activate(editor);
		}
		return editor;
	}
	IEditorReference reusedEditorRef= fReusedEditor;
	if (reusedEditorRef !=  null) {
		boolean isOpen= reusedEditorRef.getEditor(false) != null;
		boolean canBeReused= isOpen && !reusedEditorRef.isDirty() && !reusedEditorRef.isPinned();
		if (canBeReused) {
			boolean showsSameInputType= reusedEditorRef.getId().equals(editorId);
			if (!showsSameInputType) {
				page.closeEditors(new IEditorReference[] { reusedEditorRef }, false);
				fReusedEditor= null;
			} else {
				editor= reusedEditorRef.getEditor(true);
				if (editor instanceof IReusableEditor) {
					((IReusableEditor) editor).setInput(input);
					page.bringToTop(editor);
					if (activate) {
						page.activate(editor);
					}
					return editor;
				}
			}
		}
	}
	editor= page.openEditor(input, editorId, activate);
	if (editor instanceof IReusableEditor) {
		IEditorReference reference= (IEditorReference) page.getReference(editor);
		fReusedEditor= reference;
	} else {
		fReusedEditor= null;
	}
	return editor;
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:42,代码来源:EditorOpener.java


注:本文中的org.eclipse.ui.IEditorReference.isDirty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。