Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How JavaEditor example can extend CompilationUnitEditor
How JavaEditor example can extend CompilationUnitEditor [message #9236] Wed, 30 April 2003 14:11 Go to next message
Syed Rizvi is currently offline Syed RizviFriend
Messages: 145
Registered: July 2009
Senior Member
Hi all,

I am using the javaeditor example to test my plugin work.I am trying to
get hold of ISourceViewer through the following methodby pressing a button
on the messageDialog after teh editor has been created.

public void setEditable(boolean editable) {
ISourceViewer viewer = getSourceViewer();
if (viewer != null) {
viewer.setEditable(editable);
}
}

But I am having some difficulty as I always get a null value for
"viewer".I read a hack for this problem that is:

if (part instanceof CompilationUnitEditor) {
CompilationUnitEditor editor = (CompilationUnitEditor)part;
ITextViewer viewer =
(ITextViewer)editor.getAdapter(ITextOperationTarget.class);
}

I get "part" from this code
IEditorPart part = page.getActiveEditor();
System.out.println("part");

The "part" value I get here says
org.eclipse.internal.jdt.ui.javaeditor.compilationuniteditor .

But my editor extends TextEditor not CompilatioUunitEditor,because of
which the code doesn't run.If I change it to "part instanceof TextEditor"
it won't work as the part value is different.
On the other hand if I try to extends the javaeditor from
CompilationUnitEditor I can't do that as I get an error "can't resolve it".

Any help would be appreciated.

Syed
Re: How JavaEditor example can extend CompilationUnitEditor [message #11021 is a reply to message #9236] Thu, 01 May 2003 17:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

It can't. This is telling you that the active editor in the page is the
standard Java editor, not your editor.

Bob

"Syed Rizvi" <sma_r@hotmail.com> wrote in message
news:b8olih$2g4$1@rogue.oti.com...
> Hi all,
>
> I am using the javaeditor example to test my plugin work.I am trying to
> get hold of ISourceViewer through the following methodby pressing a button
> on the messageDialog after teh editor has been created.
>
> public void setEditable(boolean editable) {
> ISourceViewer viewer = getSourceViewer();
> if (viewer != null) {
> viewer.setEditable(editable);
> }
> }
>
> But I am having some difficulty as I always get a null value for
> "viewer".I read a hack for this problem that is:
>
> if (part instanceof CompilationUnitEditor) {
> CompilationUnitEditor editor = (CompilationUnitEditor)part;
> ITextViewer viewer =
> (ITextViewer)editor.getAdapter(ITextOperationTarget.class);
> }
>
> I get "part" from this code
> IEditorPart part = page.getActiveEditor();
> System.out.println("part");
>
> The "part" value I get here says
> org.eclipse.internal.jdt.ui.javaeditor.compilationuniteditor .
>
> But my editor extends TextEditor not CompilatioUunitEditor,because of
> which the code doesn't run.If I change it to "part instanceof TextEditor"
> it won't work as the part value is different.
> On the other hand if I try to extends the javaeditor from
> CompilationUnitEditor I can't do that as I get an error "can't resolve
it".
>
> Any help would be appreciated.
>
> Syed
>
Re: How JavaEditor example can extend CompilationUnitEditor [message #11639 is a reply to message #11021] Fri, 02 May 2003 03:46 Go to previous messageGo to next message
Syed Rizvi is currently offline Syed RizviFriend
Messages: 145
Registered: July 2009
Senior Member
:-( That is weird sort of,I have been working with that editor for such a
long time knowing that it is my editor.Is there any way I can cjheck if my
editor is really working as it is suppose to.

Syed


Bob Foster wrote:

> It can't. This is telling you that the active editor in the page is the
> standard Java editor, not your editor.

> Bob

> "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> news:b8olih$2g4$1@rogue.oti.com...
> > Hi all,
> >
> > I am using the javaeditor example to test my plugin work.I am trying to
> > get hold of ISourceViewer through the following methodby pressing a button
> > on the messageDialog after teh editor has been created.
> >
> > public void setEditable(boolean editable) {
> > ISourceViewer viewer = getSourceViewer();
> > if (viewer != null) {
> > viewer.setEditable(editable);
> > }
> > }
> >
> > But I am having some difficulty as I always get a null value for
> > "viewer".I read a hack for this problem that is:
> >
> > if (part instanceof CompilationUnitEditor) {
> > CompilationUnitEditor editor = (CompilationUnitEditor)part;
> > ITextViewer viewer =
> > (ITextViewer)editor.getAdapter(ITextOperationTarget.class);
> > }
> >
> > I get "part" from this code
> > IEditorPart part = page.getActiveEditor();
> > System.out.println("part");
> >
> > The "part" value I get here says
> > org.eclipse.internal.jdt.ui.javaeditor.compilationuniteditor .
> >
> > But my editor extends TextEditor not CompilatioUunitEditor,because of
> > which the code doesn't run.If I change it to "part instanceof TextEditor"
> > it won't work as the part value is different.
> > On the other hand if I try to extends the javaeditor from
> > CompilationUnitEditor I can't do that as I get an error "can't resolve
> it".
> >
> > Any help would be appreciated.
> >
> > Syed
> >
Re: How JavaEditor example can extend CompilationUnitEditor [message #12342 is a reply to message #11639] Fri, 02 May 2003 15:16 Go to previous message
Eclipse UserFriend
Originally posted by: bob.objfac.com

You can always set a breakpoint in your editor. If the debugger stops there,
your editor is running. (But I thought part of your problem was that
breakpoints are mysteriously not being hit?)

Bob

"Syed Rizvi" <sma_r@hotmail.com> wrote in message
news:b8splr$1gv$1@rogue.oti.com...
> :-( That is weird sort of,I have been working with that editor for such a
> long time knowing that it is my editor.Is there any way I can cjheck if my
> editor is really working as it is suppose to.
>
> Syed
>
>
> Bob Foster wrote:
>
> > It can't. This is telling you that the active editor in the page is the
> > standard Java editor, not your editor.
>
> > Bob
>
> > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > news:b8olih$2g4$1@rogue.oti.com...
> > > Hi all,
> > >
> > > I am using the javaeditor example to test my plugin work.I am trying
to
> > > get hold of ISourceViewer through the following methodby pressing a
button
> > > on the messageDialog after teh editor has been created.
> > >
> > > public void setEditable(boolean editable) {
> > > ISourceViewer viewer = getSourceViewer();
> > > if (viewer != null) {
> > > viewer.setEditable(editable);
> > > }
> > > }
> > >
> > > But I am having some difficulty as I always get a null value for
> > > "viewer".I read a hack for this problem that is:
> > >
> > > if (part instanceof CompilationUnitEditor) {
> > > CompilationUnitEditor editor = (CompilationUnitEditor)part;
> > > ITextViewer viewer =
> > > (ITextViewer)editor.getAdapter(ITextOperationTarget.class);
> > > }
> > >
> > > I get "part" from this code
> > > IEditorPart part = page.getActiveEditor();
> > > System.out.println("part");
> > >
> > > The "part" value I get here says
> > > org.eclipse.internal.jdt.ui.javaeditor.compilationuniteditor .
> > >
> > > But my editor extends TextEditor not CompilatioUunitEditor,because of
> > > which the code doesn't run.If I change it to "part instanceof
TextEditor"
> > > it won't work as the part value is different.
> > > On the other hand if I try to extends the javaeditor from
> > > CompilationUnitEditor I can't do that as I get an error "can't resolve
> > it".
> > >
> > > Any help would be appreciated.
> > >
> > > Syed
> > >
>
>
>
>
>
Previous Topic:Upgrade from Eclipse 2.0 to 2.1 loses JUnit
Next Topic:How to make Ant errors/warnings appear in Tasks?
Goto Forum:
  


Current Time: Sun Oct 06 11:17:47 GMT 2024

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

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

Back to the top