本文整理了Java中org.eclipse.ui.ide.IDE.getEditorDescriptor()
方法的一些代码示例,展示了IDE.getEditorDescriptor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IDE.getEditorDescriptor()
方法的具体详情如下:
包路径:org.eclipse.ui.ide.IDE
类名称:IDE
方法名:getEditorDescriptor
[英]Returns an editor descriptor appropriate for opening a file resource with the given name.
The editor descriptor is determined using a multi-step process. This method will attempt to infer content type from the file name.
IEditorRegistry.getDefaultEditor(String)
.IEditorRegistry.getDefaultEditor(String)
。代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
public static IEditorDescriptor getEditorDescriptor(String name)
throws PartInitException {
return getEditorDescriptor(name, true);
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
private static String getEditorID(IEditorInput input) throws PartInitException {
Assert.isNotNull(input);
IEditorDescriptor editorDescriptor;
if (input instanceof IFileEditorInput)
editorDescriptor= IDE.getEditorDescriptor(((IFileEditorInput)input).getFile());
else {
String name= input.getName();
if (name == null)
throwPartInitException(JavaEditorMessages.EditorUtility_could_not_find_editorId);
editorDescriptor= IDE.getEditorDescriptor(name);
}
return editorDescriptor.getId();
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.debug.ui
/**
* @see IDebugModelPresentation#getEditorId(IEditorInput, Object)
*/
public String getEditorId(IEditorInput input, Object inputObject) {
try {
IEditorDescriptor descriptor= IDE.getEditorDescriptor(input.getName());
return descriptor.getId();
} catch (PartInitException e) {
return null;
}
}
代码示例来源:origin: org.apache.uima/ruta-ep-ide-ui
public String getEditorId(IEditorInput input, Object inputObject) {
try {
IEditorDescriptor descriptor = IDE.getEditorDescriptor(input.getName());
return descriptor.getId();
} catch (PartInitException e) {
return null;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui
/**
* Opens an editor on the buildfile of the provided node and selects that node in the editor.
*
* @param page
* the page to open the editor in
* @param node
* the node from the buildfile to open and then select in the editor
*/
public static void openInEditor(IWorkbenchPage page, AntElementNode node) {
IFile file = node.getIFile();
IEditorDescriptor editorDesc;
try {
editorDesc = IDE.getEditorDescriptor(file, true, true);
}
catch (PartInitException e) {
return;
}
openInEditor(page, editorDesc, node);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
public static String getEditorID(IEditorInput input) throws PartInitException {
Assert.isNotNull(input);
if (input instanceof IFileEditorInput)
return IDE.getEditorDescriptor(((IFileEditorInput)input).getFile()).getId();
String name= input.getName();
if (input instanceof IClassFileEditorInput) {
boolean hasSource;
try {
hasSource= ((IClassFileEditorInput) input).getClassFile().getSourceRange() != null;
} catch (JavaModelException e) {
hasSource= false;
}
if (!hasSource)
name= "*.class without source"; //$NON-NLS-1$
}
return IDE.getEditorDescriptor(name).getId();
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
public static String getEditorID(IEditorInput input) throws PartInitException {
Assert.isNotNull(input);
if (input instanceof IFileEditorInput)
return IDE.getEditorDescriptor(((IFileEditorInput)input).getFile()).getId();
String name= input.getName();
if (input instanceof IClassFileEditorInput) {
boolean hasSource;
try {
hasSource= ((IClassFileEditorInput) input).getClassFile().getSourceRange() != null;
} catch (JavaModelException e) {
hasSource= false;
}
if (!hasSource) {
if (JavaModelUtil.MODULE_INFO_CLASS.equals(name)) {
name= "module-info.class without source"; //$NON-NLS-1$
} else {
name= "*.class without source"; //$NON-NLS-1$
}
}
}
return IDE.getEditorDescriptor(name).getId();
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.team.ui
public static IEditorDescriptor getDefaultEditor(IFileRevision revision) {
String name= revision.getName();
// so far only the revision name is used to find the default editor
try {
return IDE.getEditorDescriptor(name);
} catch (PartInitException e) {
// Fallback to old way of getting the editor
IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
return registry.getDefaultEditor(name);
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
editorDesc = getEditorDescriptor(input, true, true);
} catch (OperationCanceledException ex) {
return null;
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.api.tools.ui
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IEditorDescriptor edesc = null;
try {
edesc = IDE.getEditorDescriptor(index.getName());
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IDE.openEditor(window.getActivePage(), index.toURI(), edesc.getId(), true);
} catch (PartInitException e) {
e.printStackTrace();
}
return Status.OK_STATUS;
}
};
代码示例来源:origin: org.eclipse.pde.api.tools/ui
public IStatus runInUIThread(IProgressMonitor monitor) {
IEditorDescriptor edesc = null;
try {
edesc = IDE.getEditorDescriptor(index.getName());
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IDE.openEditor(window.getActivePage(),
index.toURI(),
edesc.getId(),
true);
} catch (PartInitException e) {
e.printStackTrace();
}
return Status.OK_STATUS;
}
};
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
/**
* Opens editors on given file resources.
* <p>
* If the page already has an editor open on the target object then that
* editor is brought to front; otherwise, a new editor is opened. The editor created
* for the first input will be activated.
* </p>
* @param page the page in which the editor will be opened
* @param inputs the inputs for the editors
* @return references to the editors opened; the corresponding editors might not be materialized
* @exception MultiPartInitException if at least one of the editors could not be initialized
* @since 3.5
*/
public static IEditorReference[] openEditors(IWorkbenchPage page, IFile[] inputs) throws MultiPartInitException {
if ((page == null) || (inputs == null))
throw new IllegalArgumentException();
String[] editorDescriptions = new String[inputs.length];
IEditorInput[] editorInputs = new IEditorInput[inputs.length];
for(int i = 0 ; i < inputs.length; i++) {
editorInputs[i] = new FileEditorInput(inputs[i]);
try {
editorDescriptions[i] = getEditorDescriptor(inputs[i]).getId();
} catch (PartInitException e) {
PartInitException[] exceptions = new PartInitException[inputs.length];
exceptions[i] = e;
throw new MultiPartInitException(new IWorkbenchPartReference[inputs.length], exceptions);
}
}
return page.openEditors(editorInputs, editorDescriptions, IWorkbenchPage.MATCH_INPUT);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
private String getEditorID(IFile file) throws PartInitException {
IEditorDescriptor desc= IDE.getEditorDescriptor(file);
if (desc == null)
return JavaPlugin.getDefault().getWorkbench().getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).getId();
else
return desc.getId();
}
代码示例来源:origin: org.eclipse/org.eclipse.search
private String getEditorID(IFile file) throws PartInitException {
IEditorDescriptor desc= IDE.getEditorDescriptor(file);
if (desc == null)
return SearchPlugin.getDefault().getWorkbench().getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).getId();
return desc.getId();
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.search
private String getEditorID(IFile file) throws PartInitException {
IEditorDescriptor desc = IDE.getEditorDescriptor(file, true, true);
if (desc == null)
return SearchPlugin.getDefault().getWorkbench().getEditorRegistry().findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID).getId();
return desc.getId();
}
代码示例来源:origin: org.eclipse.egit/ui
/**
* Opens external file, the editor that is used is based on best guess from
* file name.
*
* @param file
* the external file
*/
protected void openExternalFile(File file) {
try {
boolean activate = OpenStrategy.activateOnOpen();
IEditorDescriptor desc = IDE.getEditorDescriptor(file.getName());
IDE.openEditor(getWorkbenchPage(), file.toURI(), desc.getId(),
activate);
} catch (PartInitException e) {
ErrorDialog.openError(getWorkbenchPage().getWorkbenchWindow()
.getShell(),
UIText.OpenWorkingFileAction_openWorkingFileShellTitle, e
.getMessage(), e.getStatus());
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.search
public IEditorPart openAndSelect(IWorkbenchPage wbPage, IFile file, int offset, int length, boolean activate) throws PartInitException {
String editorId= null;
IEditorDescriptor desc = IDE.getEditorDescriptor(file, true, true);
if (desc == null || !desc.isInternal()) {
editorId= "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
} else {
editorId= desc.getId();
}
IEditorPart editor;
if (NewSearchUI.reuseEditor()) {
editor= showWithReuse(file, wbPage, editorId, activate);
} else {
editor= showWithoutReuse(file, wbPage, editorId, activate);
}
if (editor instanceof ITextEditor) {
ITextEditor textEditor= (ITextEditor) editor;
textEditor.selectAndReveal(offset, length);
} else if (editor != null) {
showWithMarker(editor, file, offset, length);
}
return editor;
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xml.ui
public void open() {
if (fHyperlinkFile != null) {
IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile);
IEditorDescriptor descriptor;
try {
descriptor = IDE.getEditorDescriptor(input.getName(), true);
if (descriptor != null) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, input, descriptor.getId(), true);
}
}
catch (PartInitException e) {
Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
}
}
}
}
代码示例来源:origin: ajermakovics/eclipse-instasearch
/**
* @param doc
* @param selectedLineMatches
* @param contentProvider
* @param workbenchPage
* @throws Exception
*/
public MatchHighlightJob(SearchResultDoc doc, MatchLine selectedLineMatches, ResultContentProvider contentProvider, Job searchJob, IWorkbenchPage workbenchPage) throws Exception
{
super("Highlight Matches");
this.doc = doc;
this.selectedLineMatches = selectedLineMatches;
this.contentProvider = contentProvider;
this.searchJob = searchJob;
this.workbenchPage = workbenchPage;
IEditorInput input = contentProvider.getEditorInput(doc);
IEditorDescriptor editorDesc = IDE.getEditorDescriptor(doc.getFileName());
IEditorPart editorPart = IDE.openEditor(workbenchPage, input, editorDesc.getId());
this.editor = getTextEditor(input, editorPart);
this.document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
IStorage storage = contentProvider.getStorage(doc);
this.file = null;
if( storage instanceof IFile )
file = (IFile) storage;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide
IDE.setDefaultEditor(file, null);
try {
openEditor(IDE.getEditorDescriptor(file, true, true), false);
} catch (PartInitException e) {
DialogUtil.openError(page.getWorkbenchWindow()
内容来源于网络,如有侵权,请联系作者删除!