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


Java IReusableEditor类代码示例

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


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

示例1: openInCompare

import org.eclipse.ui.IReusableEditor; //导入依赖的package包/类
private void openInCompare(ITypedElement ancestor, ITypedElement left,
		ITypedElement right) {
	IWorkbenchPage workBenchPage = getTargetPage();
	CompareEditorInput input = new SaveablesCompareEditorInput(ancestor,
			left, right, workBenchPage);
	IEditorPart editor = CompareRevisionAction.findReusableCompareEditor(
			input, workBenchPage);
	if (editor != null) {
		IEditorInput otherInput = editor.getEditorInput();
		if (otherInput.equals(input)) {
			// simply provide focus to editor
			workBenchPage.activate(editor);
		} else {
			// if editor is currently not open on that input either re-use
			// existing
			CompareUI.reuseCompareEditor(input, (IReusableEditor) editor);
			workBenchPage.activate(editor);
		}
	} else {
		CompareUI.openCompareEditor(input);
	}
}
 
开发者ID:sakim,项目名称:eclipse-utility,代码行数:23,代码来源:OpenComparablesHandler.java

示例2: openExistingCompareEditor

import org.eclipse.ui.IReusableEditor; //导入依赖的package包/类
/**
 * Displays the given input in an existing compare editor, if there is already one. Otherwise, a new compare editor is
 * opened.
 * 
 * @param input
 *          the {@link GitFileDiffEditorInput} to be shown in the compare editor
 */
public static void openExistingCompareEditor(final GitFileDiffEditorInput input) {
  final IEditorPart existingEditor = findExistingCompareEditor();
  if (existingEditor != null) {
    CompareUI.reuseCompareEditor(input, (IReusableEditor) existingEditor);
    WorkbenchUtil.activePage().activate(existingEditor);
  }
  else {
    openNewCompareEditor(input);
  }
}
 
开发者ID:sealuzh,项目名称:Permo,代码行数:18,代码来源:CompareUtil.java

示例3: findExistingCompareEditor

import org.eclipse.ui.IReusableEditor; //导入依赖的package包/类
private static IEditorPart findExistingCompareEditor() {
  final IEditorReference[] editorRefs = WorkbenchUtil.activePage().getEditorReferences();
  for (final IEditorReference editorRef : editorRefs) {
    final IEditorPart part = editorRef.getEditor(false);
    if (part != null && part.getEditorInput() instanceof GitFileDiffEditorInput && part instanceof IReusableEditor) {
      return part;
    }
  }
  return null;
}
 
开发者ID:sealuzh,项目名称:Permo,代码行数:11,代码来源:CompareUtil.java

示例4: openEntryEditor

import org.eclipse.ui.IReusableEditor; //导入依赖的package包/类
private EntryEditor openEntryEditor(TreeNode en) throws PartInitException {
    final EditorInput input = new EditorInput(this, en);
    final IWorkbenchPage activePage = Helper.getActiveWBPage();
    IEditorPart editor = activePage.findEditor(input);
    if(editor != null && editor instanceof IReusableEditor) {
        editor.setFocus();
        return (EntryEditor)editor;
    }
    else {
        editor = activePage.openEditor(input, EntryEditor.ID);
        final IEditorPart entryEditor = editor;
        editor.addPropertyListener(new IPropertyListener() {
               
               @Override
               public void propertyChanged(Object source, int propId) {
                   if(propId == EntryEditor.PROP_DIRTY) {
                       if(entryEditor.isDirty()) {
                           markDirty();
                       }
                       firePropertyChange(PROP_DIRTY);
                   }
               }
           });

        if(editor instanceof EntryEditor) {
            ((EntryEditor)editor).initExpand();
        }

        return (EntryEditor)editor;
    }
}
 
开发者ID:insweat,项目名称:hssd,代码行数:32,代码来源:HSSDEditor.java

示例5: setPageInputs

import org.eclipse.ui.IReusableEditor; //导入依赖的package包/类
/**
 * For each editor page, set the new input.
 * Auxiliary to setInput()
 * @param input the new editor input; may be null
 */
protected void setPageInputs(IEditorInput input) {
	for (int i = 0; i < getPageCount(); i++) {
		IEditorPart editorPart = getEditor(i);
		if (editorPart instanceof IReusableEditor) {
			((IReusableEditor) editorPart).setInput(input);
		} else {
			// should be an illegal state since we want all of our editors to be reusable
			throw new IllegalStateException("All editors in the multi page plan editor must implement IReusableEditor");
		}
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:MultiPagePlanEditor.java

示例6: showInEditor

import org.eclipse.ui.IReusableEditor; //导入依赖的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

示例7: openTextEditor

import org.eclipse.ui.IReusableEditor; //导入依赖的package包/类
public static ITextEditor openTextEditor(ITextEditor currentEditor, String editorId, IEditorInput newInput,
		OpenNewEditorMode openNewEditor) throws PartInitException, CoreException {
	IWorkbenchPage page;
	if(currentEditor == null) {
		page = WorkbenchUtils.getActivePage();
		openNewEditor = OpenNewEditorMode.ALWAYS;
	} else {
		page = currentEditor.getEditorSite().getWorkbenchWindow().getActivePage();
	}
	
	if(openNewEditor == OpenNewEditorMode.NEVER) {
		if(currentEditor.getEditorInput().equals(newInput)) {
			return currentEditor;
		} else if(currentEditor instanceof IReusableEditor) {
			IReusableEditor reusableEditor = (IReusableEditor) currentEditor;
			reusableEditor.setInput(newInput);
			return currentEditor;
		} else {
			openNewEditor = OpenNewEditorMode.ALWAYS;
		}
	}
	
	int matchFlags = openNewEditor == OpenNewEditorMode.ALWAYS ? 
		IWorkbenchPage.MATCH_NONE : IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID;
	IEditorPart editor = page.openEditor(newInput, editorId, true, matchFlags);
	ITextEditor targetEditor = tryCast(editor, ITextEditor.class);
	if(targetEditor == null) {
		throw EclipseCore.createCoreException("Not a text editor", null);
	}
	return targetEditor;
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:32,代码来源:EditorUtils.java

示例8: showWithReuse

import org.eclipse.ui.IReusableEditor; //导入依赖的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

示例9: showWithReuse

import org.eclipse.ui.IReusableEditor; //导入依赖的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:fabioz,项目名称:Pydev,代码行数:43,代码来源:EditorOpener.java


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