Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » help with default java editor
help with default java editor [message #16641] Wed, 07 May 2003 13:34 Go to next message
Eclipse UserFriend
Originally posted by: rpenner.cs.usask.ca

Hello, I am trying to watch for changes occuring in my default java editor
and am having some trouble figuring out how to add a listener and what
type of listener to add. I have the following code which will give me the
handle to the current active
org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor . Where abouts
can I hook into an IEditorPart to be notified of text level changes?

IEditorPart e = TemplatePlugin.getActiveEditor();
IContentOutlinePage outlinePage = (IContentOutlinePage)
e.getAdapter(IContentOutlinePage.class);
if (outlinePage != null) {
// editor wishes to contribute outlinePage to content outline view
System.out.println("the current selection is:
"+outlinePage.getSelection());
}

Basically what I am after is notification when users are editing a file
that they have opened up in the default java editor. So I thought that if
I could get the "CompilationUnitEditor" that I should be able to somehow
watch or listen to it. But I cannot see any thing that will allow me to do
this.

Your help on this issue is much appreciated, I have tried asking this
question before and no one seems interested, a reply would be nice.

thanks in advance ........ Reagan
Re: help with default java editor [message #16720 is a reply to message #16641] Wed, 07 May 2003 15:40 Go to previous message
Eclipse UserFriend
Originally posted by: mccull1.does.not.like.spam.us.ibm.com

You need to get the IDocument associated with the editor and add your
liseteners to the document.

You can do:

("approved way")
IDocumentProvider provider = editor.getDocumentProvider();
IEditorInput input = editor.getEditorInput();
IDocument doc = provider.getDocument(input);

Once you have the document, you can add all sorts of listeners to it.

-Andrew

"Reagan Penner" <rpenner@cs.usask.ca> wrote in message
news:b9bg42$go0$1@rogue.oti.com...
> Hello, I am trying to watch for changes occuring in my default java editor
> and am having some trouble figuring out how to add a listener and what
> type of listener to add. I have the following code which will give me the
> handle to the current active
> org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor . Where abouts
> can I hook into an IEditorPart to be notified of text level changes?
>
> IEditorPart e = TemplatePlugin.getActiveEditor();
> IContentOutlinePage outlinePage = (IContentOutlinePage)
> e.getAdapter(IContentOutlinePage.class);
> if (outlinePage != null) {
> // editor wishes to contribute outlinePage to content outline view
> System.out.println("the current selection is:
> "+outlinePage.getSelection());
> }
>
> Basically what I am after is notification when users are editing a file
> that they have opened up in the default java editor. So I thought that if
> I could get the "CompilationUnitEditor" that I should be able to somehow
> watch or listen to it. But I cannot see any thing that will allow me to do
> this.
>
> Your help on this issue is much appreciated, I have tried asking this
> question before and no one seems interested, a reply would be nice.
>
> thanks in advance ........ Reagan
>
Previous Topic:CVS HEAD Folder does not open
Next Topic:some ?
Goto Forum:
  


Current Time: Mon May 12 04:55:53 EDT 2025

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

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

Back to the top