| I have tried but can't get hold of ISourceViewer() [message #540] | 
Mon, 21 April 2003 00:25   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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] | 
Wed, 23 April 2003 20:48    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 01:20    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 10:11   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 
> > > > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> 
> 
> 
> 
>
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.03927 seconds