Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » I have tried but can't get hold of ISourceViewer()
I have tried but can't get hold of ISourceViewer() [message #540] Mon, 21 April 2003 04:25 Go to next message
Syed Rizvi is currently offline Syed RizviFriend
Messages: 145
Registered: July 2009
Senior Member
HI all,

I am using the following method to make the viewer uneditable,but I always
get a NULL value from viewer.But if I use the createPartControl I can get
it to work,but in my case I have to call this method with a button from
MessageDialog after the editor has been created.Is there any way I can get
it to work.


public void setEditable(boolean editable) {
ISourceViewer viewer = getSourceViewer();
if (viewer != null) {
viewer.setEditable(editable);
}
}
I get viewer as NULL,I have tried to use the same line
(ISourceViewer viewer = this.getSourceViwer();) in another code but It
also doesnot work.
While using the above method with createPartControl I can call this from
another class but I get a NullPointerException on the
super.createPartControl(composite parent).
I would really apprecaite any pointer.

Syed
Re: I have tried but can't get hold of ISourceViewer() [message #552 is a reply to message #540] Mon, 21 April 2003 08:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

The sourceViewer is created in createPartControl(). The value is not
available until super.createPartControl() has completed.

Bob

"Syed Rizvi" <sma_r@hotmail.com> wrote in message
news:b7vrrp$nau$1@rogue.oti.com...
> HI all,
>
> I am using the following method to make the viewer uneditable,but I always
> get a NULL value from viewer.But if I use the createPartControl I can get
> it to work,but in my case I have to call this method with a button from
> MessageDialog after the editor has been created.Is there any way I can get
> it to work.
>
>
> public void setEditable(boolean editable) {
> ISourceViewer viewer = getSourceViewer();
> if (viewer != null) {
> viewer.setEditable(editable);
> }
> }
> I get viewer as NULL,I have tried to use the same line
> (ISourceViewer viewer = this.getSourceViwer();) in another code but It
> also doesnot work.
> While using the above method with createPartControl I can call this from
> another class but I get a NullPointerException on the
> super.createPartControl(composite parent).
> I would really apprecaite any pointer.
>
> Syed
>
Re: I have tried but can't get hold of ISourceViewer() [message #640 is a reply to message #552] Mon, 21 April 2003 15:14 Go to previous messageGo to next message
Syed Rizvi is currently offline Syed RizviFriend
Messages: 145
Registered: July 2009
Senior Member
Bob,
Alright that is what read also,but can you tell me how to get rid of the
runtime error "Argument can't be null" at line super.createPartControl
that I get after calling createPartControl from another class.I need to
get the sourceViewer for my method.Is there any other way to get this
done.

Thanks

Syed



Bob Foster wrote:

> The sourceViewer is created in createPartControl(). The value is not
> available until super.createPartControl() has completed.

> Bob

> "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> news:b7vrrp$nau$1@rogue.oti.com...
> > HI all,
> >
> > I am using the following method to make the viewer uneditable,but I always
> > get a NULL value from viewer.But if I use the createPartControl I can get
> > it to work,but in my case I have to call this method with a button from
> > MessageDialog after the editor has been created.Is there any way I can get
> > it to work.
> >
> >
> > public void setEditable(boolean editable) {
> > ISourceViewer viewer = getSourceViewer();
> > if (viewer != null) {
> > viewer.setEditable(editable);
> > }
> > }
> > I get viewer as NULL,I have tried to use the same line
> > (ISourceViewer viewer = this.getSourceViwer();) in another code but It
> > also doesnot work.
> > While using the above method with createPartControl I can call this from
> > another class but I get a NullPointerException on the
> > super.createPartControl(composite parent).
> > I would really apprecaite any pointer.
> >
> > Syed
> >
Re: I have tried but can't get hold of ISourceViewer() [message #1643 is a reply to message #640] Tue, 22 April 2003 07:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

Huh? This is in an editor plugin, right? You can't call createPartControl().
It gets called by the framework.

Bob

"Syed Rizvi" <sma_r@hotmail.com> wrote in message
news:b811si$cso$1@rogue.oti.com...
> Bob,
> Alright that is what read also,but can you tell me how to get rid of the
> runtime error "Argument can't be null" at line super.createPartControl
> that I get after calling createPartControl from another class.I need to
> get the sourceViewer for my method.Is there any other way to get this
> done.
>
> Thanks
>
> Syed
>
>
>
> Bob Foster wrote:
>
> > The sourceViewer is created in createPartControl(). The value is not
> > available until super.createPartControl() has completed.
>
> > Bob
>
> > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > news:b7vrrp$nau$1@rogue.oti.com...
> > > HI all,
> > >
> > > I am using the following method to make the viewer uneditable,but I
always
> > > get a NULL value from viewer.But if I use the createPartControl I can
get
> > > it to work,but in my case I have to call this method with a button
from
> > > MessageDialog after the editor has been created.Is there any way I can
get
> > > it to work.
> > >
> > >
> > > public void setEditable(boolean editable) {
> > > ISourceViewer viewer = getSourceViewer();
> > > if (viewer != null) {
> > > viewer.setEditable(editable);
> > > }
> > > }
> > > I get viewer as NULL,I have tried to use the same line
> > > (ISourceViewer viewer = this.getSourceViwer();) in another code but It
> > > also doesnot work.
> > > While using the above method with createPartControl I can call this
from
> > > another class but I get a NullPointerException on the
> > > super.createPartControl(composite parent).
> > > I would really apprecaite any pointer.
> > >
> > > Syed
> > >
>
>
>
>
>
Is there a solution for this [message #5391 is a reply to message #1643] Wed, 23 April 2003 03:53 Go to previous messageGo to next message
Syed Rizvi is currently offline Syed RizviFriend
Messages: 145
Registered: July 2009
Senior Member
Bob,

There must be a way to go around this or do something else to get the same
functionality.I would really appreciate any pointers

Thanks

Syed



Foster wrote:

> Huh? This is in an editor plugin, right? You can't call createPartControl().
> It gets called by the framework.

> Bob

> "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> news:b811si$cso$1@rogue.oti.com...
> > Bob,
> > Alright that is what read also,but can you tell me how to get rid of the
> > runtime error "Argument can't be null" at line super.createPartControl
> > that I get after calling createPartControl from another class.I need to
> > get the sourceViewer for my method.Is there any other way to get this
> > done.
> >
> > Thanks
> >
> > Syed
> >
> >
> >
> > Bob Foster wrote:
> >
> > > The sourceViewer is created in createPartControl(). The value is not
> > > available until super.createPartControl() has completed.
> >
> > > Bob
> >
> > > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > > news:b7vrrp$nau$1@rogue.oti.com...
> > > > HI all,
> > > >
> > > > I am using the following method to make the viewer uneditable,but I
> always
> > > > get a NULL value from viewer.But if I use the createPartControl I can
> get
> > > > it to work,but in my case I have to call this method with a button
> from
> > > > MessageDialog after the editor has been created.Is there any way I can
> get
> > > > it to work.
> > > >
> > > >
> > > > public void setEditable(boolean editable) {
> > > > ISourceViewer viewer = getSourceViewer();
> > > > if (viewer != null) {
> > > > viewer.setEditable(editable);
> > > > }
> > > > }
> > > > I get viewer as NULL,I have tried to use the same line
> > > > (ISourceViewer viewer = this.getSourceViwer();) in another code but It
> > > > also doesnot work.
> > > > While using the above method with createPartControl I can call this
> from
> > > > another class but I get a NullPointerException on the
> > > > super.createPartControl(composite parent).
> > > > I would really apprecaite any pointer.
> > > >
> > > > Syed
> > > >
> >
> >
> >
> >
> >
Re: Is there a solution for this [message #8851 is a reply to message #5391] Thu, 24 April 2003 00:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob.objfac.com

What's your hurry? The viewer isn't editable before it is created. Just set
a flag in your editor and when the part control is created, do whatever you
need to the source viewer.

Bob

"Syed Rizvi" <sma_r@hotmail.com> wrote in message
news:b852ne$aop$1@rogue.oti.com...
> Bob,
>
> There must be a way to go around this or do something else to get the same
> functionality.I would really appreciate any pointers
>
> Thanks
>
> Syed
>
>
>
> Foster wrote:
>
> > Huh? This is in an editor plugin, right? You can't call
createPartControl().
> > It gets called by the framework.
>
> > Bob
>
> > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > news:b811si$cso$1@rogue.oti.com...
> > > Bob,
> > > Alright that is what read also,but can you tell me how to get rid of
the
> > > runtime error "Argument can't be null" at line super.createPartControl
> > > that I get after calling createPartControl from another class.I need
to
> > > get the sourceViewer for my method.Is there any other way to get this
> > > done.
> > >
> > > Thanks
> > >
> > > Syed
> > >
> > >
> > >
> > > Bob Foster wrote:
> > >
> > > > The sourceViewer is created in createPartControl(). The value is not
> > > > available until super.createPartControl() has completed.
> > >
> > > > Bob
> > >
> > > > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > > > news:b7vrrp$nau$1@rogue.oti.com...
> > > > > HI all,
> > > > >
> > > > > I am using the following method to make the viewer uneditable,but
I
> > always
> > > > > get a NULL value from viewer.But if I use the createPartControl I
can
> > get
> > > > > it to work,but in my case I have to call this method with a button
> > from
> > > > > MessageDialog after the editor has been created.Is there any way I
can
> > get
> > > > > it to work.
> > > > >
> > > > >
> > > > > public void setEditable(boolean editable) {
> > > > > ISourceViewer viewer = getSourceViewer();
> > > > > if (viewer != null) {
> > > > > viewer.setEditable(editable);
> > > > > }
> > > > > }
> > > > > I get viewer as NULL,I have tried to use the same line
> > > > > (ISourceViewer viewer = this.getSourceViwer();) in another code
but It
> > > > > also doesnot work.
> > > > > While using the above method with createPartControl I can call
this
> > from
> > > > > another class but I get a NullPointerException on the
> > > > > super.createPartControl(composite parent).
> > > > > I would really apprecaite any pointer.
> > > > >
> > > > > Syed
> > > > >
> > >
> > >
> > >
> > >
> > >
>
>
>
>
>
Re: Is there a solution for this [message #8957 is a reply to message #8851] Thu, 24 April 2003 05:20 Go to previous messageGo to next message
Syed Rizvi is currently offline Syed RizviFriend
Messages: 145
Registered: July 2009
Senior Member
I understand what you are saying but I invoke setEditable method after the
editor is created,then according to what you are saying I should have the
viewer(I Think).
What actually happens is that I open up the editor frist then through the
Dialog I invoke this method.So if the editor has been opened up then there
should be a viewer.I tried to do the same for retriving text from the
editor and I was having the same problem then.
Or am I missing something here.

Thanks for all your help

Syed

Bob Foster wrote:

> What's your hurry? The viewer isn't editable before it is created. Just set
> a flag in your editor and when the part control is created, do whatever you
> need to the source viewer.

> Bob

> "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> news:b852ne$aop$1@rogue.oti.com...
> > Bob,
> >
> > There must be a way to go around this or do something else to get the same
> > functionality.I would really appreciate any pointers
> >
> > Thanks
> >
> > Syed
> >
> >
> >
> > Foster wrote:
> >
> > > Huh? This is in an editor plugin, right? You can't call
> createPartControl().
> > > It gets called by the framework.
> >
> > > Bob
> >
> > > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > > news:b811si$cso$1@rogue.oti.com...
> > > > Bob,
> > > > Alright that is what read also,but can you tell me how to get rid of
> the
> > > > runtime error "Argument can't be null" at line super.createPartControl
> > > > that I get after calling createPartControl from another class.I need
> to
> > > > get the sourceViewer for my method.Is there any other way to get this
> > > > done.
> > > >
> > > > Thanks
> > > >
> > > > Syed
> > > >
> > > >
> > > >
> > > > Bob Foster wrote:
> > > >
> > > > > The sourceViewer is created in createPartControl(). The value is not
> > > > > available until super.createPartControl() has completed.
> > > >
> > > > > Bob
> > > >
> > > > > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > > > > news:b7vrrp$nau$1@rogue.oti.com...
> > > > > > HI all,
> > > > > >
> > > > > > I am using the following method to make the viewer uneditable,but
> I
> > > always
> > > > > > get a NULL value from viewer.But if I use the createPartControl I
> can
> > > get
> > > > > > it to work,but in my case I have to call this method with a button
> > > from
> > > > > > MessageDialog after the editor has been created.Is there any way I
> can
> > > get
> > > > > > it to work.
> > > > > >
> > > > > >
> > > > > > public void setEditable(boolean editable) {
> > > > > > ISourceViewer viewer = getSourceViewer();
> > > > > > if (viewer != null) {
> > > > > > viewer.setEditable(editable);
> > > > > > }
> > > > > > }
> > > > > > I get viewer as NULL,I have tried to use the same line
> > > > > > (ISourceViewer viewer = this.getSourceViwer();) in another code
> but It
> > > > > > also doesnot work.
> > > > > > While using the above method with createPartControl I can call
> this
> > > from
> > > > > > another class but I get a NullPointerException on the
> > > > > > super.createPartControl(composite parent).
> > > > > > I would really apprecaite any pointer.
> > > > > >
> > > > > > Syed
> > > > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> >
> >
> >
> >
> >
Re: Is there a solution for this [message #10323 is a reply to message #8957] Thu, 24 April 2003 14:11 Go to previous message
Eclipse UserFriend
Originally posted by: bob.objfac.com

Notwithstanding Andrew's response, I believe the source viewer is not
available until after createPartControl() has been called. If you are trying
to get it beforehand, you can solve your problem with a hack like this:

private Boolean deferSetEditable = null;

public void setEditable(boolean editable) {
ISourceViewer viewer = getSourceViewer();
if (viewer != null)
viewer.setEditable(editable);
else
deferSetEditable = editable ? Boolean.TRUE : Boolean.FALSE;
}

public void createPartControl(Composite parent) {
super.createPartControl(parent);
if (deferSetEditable != null && getSourceViewer() != null) {
getSourceViewer.setEditable(deferSetEditable.booleanValue()) ;
deferSetEditable = null;
}
}

Bob

"Syed Rizvi" <sma_r@hotmail.com> wrote in message
news:b87s7n$926$1@rogue.oti.com...
> I understand what you are saying but I invoke setEditable method after the
> editor is created,then according to what you are saying I should have the
> viewer(I Think).
> What actually happens is that I open up the editor frist then through the
> Dialog I invoke this method.So if the editor has been opened up then there
> should be a viewer.I tried to do the same for retriving text from the
> editor and I was having the same problem then.
> Or am I missing something here.
>
> Thanks for all your help
>
> Syed
>
> Bob Foster wrote:
>
> > What's your hurry? The viewer isn't editable before it is created. Just
set
> > a flag in your editor and when the part control is created, do whatever
you
> > need to the source viewer.
>
> > Bob
>
> > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > news:b852ne$aop$1@rogue.oti.com...
> > > Bob,
> > >
> > > There must be a way to go around this or do something else to get the
same
> > > functionality.I would really appreciate any pointers
> > >
> > > Thanks
> > >
> > > Syed
> > >
> > >
> > >
> > > Foster wrote:
> > >
> > > > Huh? This is in an editor plugin, right? You can't call
> > createPartControl().
> > > > It gets called by the framework.
> > >
> > > > Bob
> > >
> > > > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > > > news:b811si$cso$1@rogue.oti.com...
> > > > > Bob,
> > > > > Alright that is what read also,but can you tell me how to get rid
of
> > the
> > > > > runtime error "Argument can't be null" at line
super.createPartControl
> > > > > that I get after calling createPartControl from another class.I
need
> > to
> > > > > get the sourceViewer for my method.Is there any other way to get
this
> > > > > done.
> > > > >
> > > > > Thanks
> > > > >
> > > > > Syed
> > > > >
> > > > >
> > > > >
> > > > > Bob Foster wrote:
> > > > >
> > > > > > The sourceViewer is created in createPartControl(). The value is
not
> > > > > > available until super.createPartControl() has completed.
> > > > >
> > > > > > Bob
> > > > >
> > > > > > "Syed Rizvi" <sma_r@hotmail.com> wrote in message
> > > > > > news:b7vrrp$nau$1@rogue.oti.com...
> > > > > > > HI all,
> > > > > > >
> > > > > > > I am using the following method to make the viewer
uneditable,but
> > I
> > > > always
> > > > > > > get a NULL value from viewer.But if I use the
createPartControl I
> > can
> > > > get
> > > > > > > it to work,but in my case I have to call this method with a
button
> > > > from
> > > > > > > MessageDialog after the editor has been created.Is there any
way I
> > can
> > > > get
> > > > > > > it to work.
> > > > > > >
> > > > > > >
> > > > > > > public void setEditable(boolean editable) {
> > > > > > > ISourceViewer viewer = getSourceViewer();
> > > > > > > if (viewer != null) {
> > > > > > > viewer.setEditable(editable);
> > > > > > > }
> > > > > > > }
> > > > > > > I get viewer as NULL,I have tried to use the same line
> > > > > > > (ISourceViewer viewer = this.getSourceViwer();) in another
code
> > but It
> > > > > > > also doesnot work.
> > > > > > > While using the above method with createPartControl I can
call
> > this
> > > > from
> > > > > > > another class but I get a NullPointerException on the
> > > > > > > super.createPartControl(composite parent).
> > > > > > > I would really apprecaite any pointer.
> > > > > > >
> > > > > > > Syed
> > > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
> > >
> > >
>
>
>
>
>
Previous Topic:Malformed file transmission
Next Topic:Does Eclipse provide a rich text widget that can display HTML?
Goto Forum:
  


Current Time: Tue Nov 12 19:42:23 GMT 2024

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

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

Back to the top