[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: Using editors from IEditorRegistry from another plugin
|
- From: jbognar@xxxxxxxxxx (James Bognar)
- Date: 17 Aug 2001 20:45:25 GMT
- Newsgroups: eclipse.tools
- Organization: http://www.eclipse.org
- User-agent: NewsPortal 0.23
Ignore this post. I figured out why it wasn't working. I was trying to
open up an IStorageEditorInput in the jdt java editor. The editor throws
an exception if you pass it anything other than an IFileEditorInput.
James Bognar wrote:
> I need to find out if it's possible to use an editor from the
> IEditorRegistry in my own plugin (I'm working on Asset Locator, if your
> interested).
> From the plugin's perspective, a user is going to be viewing the contents
> of a variety of file types. What I want is to be able to show the
> contents of a file using the current preferred editor for a given file
> type. If no preferred editor exists, I would display it using the
> org.eclipse.ui.DefaultTextEditor.
> Here's a sample of code of what I'm trying to do.
> ------------------------------------------------------------
> // Assume these are initialized...
> IWorkbenchPage workbenchPage;
> IEditorRegistry editorRegistry;
> IStorageEditorInput storageEditorInput;
> String fileName;
> IEditorDescriptor defaultEditor = editorRegistry.getDefaultEditor();
> IEditorDescriptor preferredEditor =
> editorRegistry.getDefaultEditor(fileName);
> workbenchPage.setEditorAreaVisible(true);
> if (preferredEditor != null)
> workbenchPage.openEditor(storageEditorInput, preferredEditor.getId());
> else
> workbenchPage.openEditor(storageEditorInput, defaultEditor.getId());
> ------------------------------------------------------------
> Here's the exception that I get when I try to use anything other
> than a org.eclipse.ui.DefaultTextEditor:
> ------------------------------------------------------------
> org.eclipse.ui.PartInitException: Invalid resource type for null.
> at
>
org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:1294)
> at
> org.eclipse.ui.internal.EditorManager$2.run(EditorManager.java:379)
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:9
> at
> org.eclipse.ui.internal.EditorManager.openInternalEditor(EditorMana
> at
> org.eclipse.ui.internal.EditorManager.openInternalEditor(EditorMana
> at
> org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java
> at
> org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java
> at
> com.ibm.etools.assetlocator.views.ContentView.setContent(ContentVie
> at
> com.ibm.etools.assetlocator.views.ResultViewer$SelectionChangedList
> at
> org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:1
> at
> org.eclipse.jface.viewers.StructuredViewer.updateSelection(Structur
> at
> org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredV
> at
> org.eclipse.jface.viewers.TableViewer$1.widgetSelected(TableViewer.
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.jav
> at
> org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java(Compil
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:622)
> at
> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1277
> at
> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1087)
> at
> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:639)
> at org.eclipse.ui.internal.Workbench.run(Workbench.java:622)
> at
> org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootL
> at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285)
> at java.lang.reflect.Method.invoke(Native Method)
> at org.eclipse.core.launcher.Main.basicRun(Main.java:119)
> at org.eclipse.core.launcher.Main.run(Main.java:401)
> at org.eclipse.core.launcher.UIMain.main(UIMain.java:52)
> ------------------------------------------------------------
> Any help would be appreciated....
> Thanx.