Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » TextEditor
TextEditor [message #212971] Thu, 18 March 2004 15:54 Go to next message
Eclipse UserFriend
Originally posted by: crscca.bol.net.in

Hi,

I am extending from org.eclipse.ui.editors.text.TextEditor.
At any time the user needs to save the contents afetr making changes the
user presses save in the appropriate menu.
Before the actual save I wish to intervene and make some checks.

Q1) How do I get the content that corresponds to what is being displayed
in the editor(- thats the text I need to validate before it actually gets
saved)?

I presume I must do all this inside the doSave(IProgressMonitor monitor)
method.

Q2) Should I use the documentProvider?How exactly?

Raster
Re: TextEditor [message #213076 is a reply to message #212971] Thu, 18 March 2004 17:47 Go to previous messageGo to next message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
TextEditor yourEditor;

IDocument document=
yourEditor.getDocumentProvider()
.getDocument(yourEditor.getEditorInput());

then, look at the document.

-tom

Raster wrote:
> Hi,
>
> I am extending from org.eclipse.ui.editors.text.TextEditor.
> At any time the user needs to save the contents afetr making changes the
> user presses save in the appropriate menu.
> Before the actual save I wish to intervene and make some checks.
>
> Q1) How do I get the content that corresponds to what is being displayed
> in the editor(- thats the text I need to validate before it actually gets
> saved)?
>
> I presume I must do all this inside the doSave(IProgressMonitor monitor)
> method.
>
> Q2) Should I use the documentProvider?How exactly?
>
> Raster
>
Re: TextEditor [message #213098 is a reply to message #213076] Thu, 18 March 2004 18:52 Go to previous messageGo to next message
Jean-Christophe Deprez is currently offline Jean-Christophe DeprezFriend
Messages: 133
Registered: July 2009
Senior Member
> Raster wrote:
> > Hi,
> >
> > I am extending from org.eclipse.ui.editors.text.TextEditor.
> > At any time the user needs to save the contents afetr making changes the
> > user presses save in the appropriate menu.
> > Before the actual save I wish to intervene and make some checks.
> >
> > Q1) How do I get the content that corresponds to what is being displayed
> > in the editor(- thats the text I need to validate before it actually gets
> > saved)?

Well if you implement a DocumentProvider you can override

DocumentProvider.doSave(IProgressMonitor monitor, Object element,
IDocument document, boolean overwrite)

and then perform validation there.

> > Q2) Should I use the documentProvider?How exactly?
> >

To implement just take a look at what the sample editor does. (
Basically
just subclass FileInputDocumentProvider. )

The make sure you go through the document provider when you
open,save,close documents.

If you want to make sure that if multiple editors open the same file they
use the
same document instance you will want to make sure your document provider
is
a singleton. To do this you will want to declare it as an extension and
then
make sure you only access it through the DocumentProviderRegistry.

-- Dan S
Re: TextEditor [message #213645 is a reply to message #213076] Fri, 19 March 2004 17:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: crscca.bol.net.in

Thanks that worked. I am now displaying a messagebox wherein I am giving
the user a warning and allowing the user to save if the user insists.

Q1) What are these methods meant for-"createStatusControl,
doRevertToSaved, sanityCheckState, updatePartControl, updateStatusField,
validateState, updateState, safelySanityCheckState,
handleExceptionOnSave"?

Q2) I am not using these methods should I? Am I missing out on something?



Tom Eicher wrote:

> TextEditor yourEditor;

> IDocument document=
> yourEditor.getDocumentProvider()
> .getDocument(yourEditor.getEditorInput());

> then, look at the document.

> -tom

> Raster wrote:
> > Hi,
> >
> > I am extending from org.eclipse.ui.editors.text.TextEditor.
> > At any time the user needs to save the contents afetr making changes the
> > user presses save in the appropriate menu.
> > Before the actual save I wish to intervene and make some checks.
> >
> > Q1) How do I get the content that corresponds to what is being displayed
> > in the editor(- thats the text I need to validate before it actually gets
> > saved)?
> >
> > I presume I must do all this inside the doSave(IProgressMonitor monitor)
> > method.
> >
> > Q2) Should I use the documentProvider?How exactly?
> >
> > Raster
> >
Re: TextEditor [message #307244 is a reply to message #213645] Thu, 17 August 2006 13:10 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Raster wrote:

>Thanks that worked. I am now displaying a messagebox wherein I am giving
>the user a warning and allowing the user to save if the user insists.
>
>Q1) What are these methods meant for-"createStatusControl,
>doRevertToSaved, sanityCheckState, updatePartControl, updateStatusField,
>validateState, updateState, safelySanityCheckState,
>handleExceptionOnSave"?
>
>
Read the Javadoc.

>Q2) I am not using these methods should I? Am I missing out on something?
>
>
Read the Javadoc and find out it applies to your code.

Dani

>
>
>Tom Eicher wrote:
>
>
>
>>TextEditor yourEditor;
>>
>>
>
>
>
>>IDocument document=
>> yourEditor.getDocumentProvider()
>> .getDocument(yourEditor.getEditorInput());
>>
>>
>
>
>
>>then, look at the document.
>>
>>
>
>
>
>>-tom
>>
>>
>
>
>
>>Raster wrote:
>>
>>
>>>Hi,
>>>
>>>I am extending from org.eclipse.ui.editors.text.TextEditor.
>>>At any time the user needs to save the contents afetr making changes the
>>>user presses save in the appropriate menu.
>>>Before the actual save I wish to intervene and make some checks.
>>>
>>>Q1) How do I get the content that corresponds to what is being displayed
>>>in the editor(- thats the text I need to validate before it actually gets
>>>saved)?
>>>
>>>I presume I must do all this inside the doSave(IProgressMonitor monitor)
>>>method.
>>>
>>>Q2) Should I use the documentProvider?How exactly?
>>>
>>>Raster
>>>
>>>
>>>
>
>
>
>
Previous Topic:Bundle.getSymbolicName()?
Next Topic:TextEditor
Goto Forum:
  


Current Time: Wed Aug 14 18:29:16 GMT 2024

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

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

Back to the top