本文整理汇总了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;
}
示例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;
}
}
示例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;
}