Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Editor for Non-File Input
Editor for Non-File Input [message #153881] Thu, 06 November 2003 18:02 Go to next message
Eclipse UserFriend
Originally posted by: donald.hughes.algx.com

Does anyone know if there is a comprehensive resource describing how to
create an editor for non-file input? My input will be coming from a
database query. I assume I need to create a custom implementation of
either IEditorInput or IStorageEditorInput, which I did. But I don't have
any idea how to reference that in my calling code. I created an action
that calls the following code:

///////////////////////////////////////////////
IWorkbenchPage page = getSite().getPage();
IStructuredSelection selection = null;
IEditorPart editor = null;

// "MyEditorInput" implements IStorageEditorInput,
// but contains no custom code at this point
// "TestEditor" is the id of the form
try {
MyEditorInput ei = new MyEditorInput();
editor = page.openEditor(ei,"TestEditor");
} catch (PartInitException e) {
e.printStackTrace();
}

if (editor != null) {
showMessage("Editor Not Null");
page.bringToTop(editor);
return;
}
///////////////////////////////////////////////

The result is a null pointer exception. Can anyone tell what to do or
point to a resource that can explain it?
Re: Editor for Non-File Input [message #153934 is a reply to message #153881] Fri, 07 November 2003 00:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

It depends on what you want to do. If all you want is an editor to view some
text, then you can just implement IStorageEditorInput and call openEditor on
it specifying the id of the editor you want to open.

Notice that IStorageEditorInput has no provision for saving data, so the
editor will be read-only.

If you want to implement a non-text editor, I haven't done it and will have
to defer to someone with more experience.

Bob Foster

"Donald Hughes" <donald.hughes@algx.com> wrote in message
news:boejub$5k0$1@eclipse.org...
> Does anyone know if there is a comprehensive resource describing how to
> create an editor for non-file input? My input will be coming from a
> database query. I assume I need to create a custom implementation of
> either IEditorInput or IStorageEditorInput, which I did. But I don't have
> any idea how to reference that in my calling code. I created an action
> that calls the following code:
>
> ///////////////////////////////////////////////
> IWorkbenchPage page = getSite().getPage();
> IStructuredSelection selection = null;
> IEditorPart editor = null;
>
> // "MyEditorInput" implements IStorageEditorInput,
> // but contains no custom code at this point
> // "TestEditor" is the id of the form
> try {
> MyEditorInput ei = new MyEditorInput();
> editor = page.openEditor(ei,"TestEditor");
> } catch (PartInitException e) {
> e.printStackTrace();
> }
>
> if (editor != null) {
> showMessage("Editor Not Null");
> page.bringToTop(editor);
> return;
> }
> ///////////////////////////////////////////////
>
> The result is a null pointer exception. Can anyone tell what to do or
> point to a resource that can explain it?
>
Re: Editor for Non-File Input [message #154020 is a reply to message #153934] Fri, 07 November 2003 10:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: donald.hughes.algx.com

Thanks for the reply. What I want to accomplish is to create a form to
display data from a query. All saving would be handled through a save
button on the form. If I implement IStorageEditorInput, what would I need
to add to the implementation?
Re: Editor for Non-File Input [message #154129 is a reply to message #153881] Fri, 07 November 2003 12:50 Go to previous message
Eclipse UserFriend
Originally posted by: donald.hughes.algx.com

I finally got this to work. Once I get things more fleshed out, I
translate my notes into an article so others can benefit.



Donald Hughes wrote:

> Does anyone know if there is a comprehensive resource describing how to
> create an editor for non-file input? My input will be coming from a
> database query. I assume I need to create a custom implementation of
> either IEditorInput or IStorageEditorInput, which I did. But I don't have
> any idea how to reference that in my calling code. I created an action
> that calls the following code:

> ///////////////////////////////////////////////
> IWorkbenchPage page = getSite().getPage();
> IStructuredSelection selection = null;
> IEditorPart editor = null;

> // "MyEditorInput" implements IStorageEditorInput,
> // but contains no custom code at this point
> // "TestEditor" is the id of the form
> try {
> MyEditorInput ei = new MyEditorInput();
> editor = page.openEditor(ei,"TestEditor");
> } catch (PartInitException e) {
> e.printStackTrace();
> }

> if (editor != null) {
> showMessage("Editor Not Null");
> page.bringToTop(editor);
> return;
> }
> ///////////////////////////////////////////////

> The result is a null pointer exception. Can anyone tell what to do or
> point to a resource that can explain it?
Previous Topic:How to change menu item's text from still not activated plugin?
Next Topic:JRE Woes .. or method of attack
Goto Forum:
  


Current Time: Mon May 12 19:18:52 EDT 2025

Powered by FUDForum. Page generated in 0.03265 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top