Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to create a customized Editor Input?
How to create a customized Editor Input? [message #79174] Fri, 20 June 2003 08:31 Go to next message
Eclipse UserFriend
Originally posted by: michael.renz.web.de

Hello,
I have been looking for some information about customizing the editor
input but I couldn't find anything that goes to what I want to do.

I want to create a pure form-based editor. The input data is supposed to
come directly from a file input stream which I am going to parse with a
XML-parser to get a DOM. I don't want to open the XML-document from the
workspace. The DOM-object shall be the data object for the editor.

When doSave() or doSaveAs() is called, the parser is going to serialize
the DOM-object directly to a file.

How can I invoke an editor using a DOM-object as input source?

Are there any similar samples or tutorials?

Thanks
Michael
Re: How to create a customized Editor Input? [message #79214 is a reply to message #79174] Fri, 20 June 2003 09:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mccull1.does.not.like.spam.us.ibm.com

The easiest thing to do is to stick to the normal IFileEditorInput. Once
you're inside the editor, read the file and parse it into your in-memory
model (DOM or otherwise). This also makes it easier to maintain a reference
to the IFile when it is time to save modifications.

Here is some sample code from Insectivore's form editor.
(http://www.zclipse.org/projects/insectivore/). Note that the init method
creates an in memory model of the file contents, (new FileTeamTask(..)).
From that point forward, all interaction is through this memory model.

-Andrew


/* (non-Javadoc)
* @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput)
*/
public void init(IEditorSite site, IEditorInput input) throws
PartInitException {

InsectivorePlugin.debug("Initializing Editor");

if(!(input instanceof IFileEditorInput)) {
throw new PartInitException("Invalid Input: Must be IFileEditorInput");
}

super.setSite(site);
super.setInput(input);

IFile file = ((IFileEditorInput)input).getFile();

file.refreshLocal(1, null);
teamtask = new FileTeamTask(file);
^^^^^^^^^^^^^^^^^^^^^^^^^^^

setTitle(file.getName());
}


"Michael" <michael.renz@web.de> wrote in message
news:bcuuqj$l6i$1@rogue.oti.com...
> Hello,
> I have been looking for some information about customizing the editor
> input but I couldn't find anything that goes to what I want to do.
>
> I want to create a pure form-based editor. The input data is supposed to
> come directly from a file input stream which I am going to parse with a
> XML-parser to get a DOM. I don't want to open the XML-document from the
> workspace. The DOM-object shall be the data object for the editor.
>
> When doSave() or doSaveAs() is called, the parser is going to serialize
> the DOM-object directly to a file.
>
> How can I invoke an editor using a DOM-object as input source?
>
> Are there any similar samples or tutorials?
>
> Thanks
> Michael
>
Re: How to create a customized Editor Input? [message #80259 is a reply to message #79214] Sun, 22 June 2003 17:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michael.renz.web.de

Thanks for the hint. I don't have any problem starting the editor from the
workspace and working on the generated DOM now.

But I am still struggling a bit with the editor lifecycle (recognizing
modifications).
Is there a way that I can fire an event to inform all necessary listeners,
that the editor's content has been modified so that the save and save as
menus will be enabled?

Thanks.

Michael


Andrew McCullough wrote:


> The easiest thing to do is to stick to the normal IFileEditorInput. Once
> you're inside the editor, read the file and parse it into your in-memory
> model (DOM or otherwise). This also makes it easier to maintain a reference
> to the IFile when it is time to save modifications.

> Here is some sample code from Insectivore's form editor.
> (http://www.zclipse.org/projects/insectivore/). Note that the init method
> creates an in memory model of the file contents, (new FileTeamTask(..)).
> From that point forward, all interaction is through this memory model.

> -Andrew


> /* (non-Javadoc)
> * @see org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput)
> */
> public void init(IEditorSite site, IEditorInput input) throws
> PartInitException {

> InsectivorePlugin.debug("Initializing Editor");

> if(!(input instanceof IFileEditorInput)) {
> throw new PartInitException("Invalid Input: Must be IFileEditorInput");
> }

> super.setSite(site);
> super.setInput(input);

> IFile file = ((IFileEditorInput)input).getFile();

> file.refreshLocal(1, null);
> teamtask = new FileTeamTask(file);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^

> setTitle(file.getName());
> }


> "Michael" <michael.renz@web.de> wrote in message
> news:bcuuqj$l6i$1@rogue.oti.com...
> > Hello,
> > I have been looking for some information about customizing the editor
> > input but I couldn't find anything that goes to what I want to do.
> >
> > I want to create a pure form-based editor. The input data is supposed to
> > come directly from a file input stream which I am going to parse with a
> > XML-parser to get a DOM. I don't want to open the XML-document from the
> > workspace. The DOM-object shall be the data object for the editor.
> >
> > When doSave() or doSaveAs() is called, the parser is going to serialize
> > the DOM-object directly to a file.
> >
> > How can I invoke an editor using a DOM-object as input source?
> >
> > Are there any similar samples or tutorials?
> >
> > Thanks
> > Michael
> >
Re: How to create a customized Editor Input? [message #80624 is a reply to message #80259] Mon, 23 June 2003 10:19 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.NOSPAM.us.ibm.com

If you are inheriting from WorkbenchPart, the class, then you should do
firePropertyChange(IEditorPart.PROP_DIRTY) whenever the state of dirty
changes, either from dirty to not dirty (i.e. after a save or saveAs),
or from not dirty to dirty (i.e. after a change). This tells the
workbench to enable or disable the Save. However SaveAs should always be
enabled for a writable file, that has nothing to do with it being dirty.

If you are not inheriting from WorkbenchPart, then you will need to
duplicate that code and do the firing yourself.

Rich
Previous Topic:unable to read .classpath file
Next Topic:CVS Dialog Trouble
Goto Forum:
  


Current Time: Fri Apr 25 01:42:19 EDT 2025

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

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

Back to the top