Skip to main content



      Home
Home » Eclipse Projects » GEF » selectAddedObject() throws NullPointerException only on Linux
selectAddedObject() throws NullPointerException only on Linux [message #160102] Thu, 02 December 2004 09:32 Go to next message
Eclipse UserFriend
Originally posted by: bandrews.nospam_bphnx.com

Hello,
I think this is probably a bug, but I would like to confirm with the
experts here before logging. I have overridden CreationTool to provide
additional functionality to performCreation() method. My class looks
like this:

public class DECreationTool extends CreationTool
{
/**
*
*/
public DECreationTool()
{
super();
}

/**
* @param aFactory
*/
public DECreationTool(CreationFactory aFactory)
{
super(aFactory);
}


/* (non-Javadoc)
* @see org.eclipse.gef.tools.CreationTool#performCreation(int)
*/
protected void performCreation(int button)
{
CreateCommand command = (CreateCommand)this.getCommand();

if(command.preExecute())
{
this.setCurrentCommand(command);
try
{
super.performCreation(button);
}
catch(NullPointerException $ne)
{
//TODO I only get this problem on Linux. It happens when
// selectAddedObject() is called.
;
}
}
}
}

All the preExecute() method does is gets some information from the user
via a dialog and returns true/false based on whether or not the
information was valid.

The problem is when selectAddedObject() method is called, the
EditPartViewer from getCurrentViewer() is null.

This only happens on Linux. It works fine on Windows. Is it obvious I am
doing something wrong here, or is it a bug in the framework?

many thanks,

Barry
Re: selectAddedObject() throws NullPointerException only on Linux [message #160127 is a reply to message #160102] Thu, 02 December 2004 11:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Sounds like the tool is getting a FocusLost event on Linux, and setting the
current view to NULL. If you are going to override performCreation(), you
probably shouldn't call super in this case.

"Barry Andrews" <bandrews@nospam_bphnx.com> wrote in message
news:con94b$bpn$1@www.eclipse.org...
> Hello,
> I think this is probably a bug, but I would like to confirm with the
> experts here before logging. I have overridden CreationTool to provide
> additional functionality to performCreation() method. My class looks
> like this:
>
> public class DECreationTool extends CreationTool
> {
> /**
> *
> */
> public DECreationTool()
> {
> super();
> }
>
> /**
> * @param aFactory
> */
> public DECreationTool(CreationFactory aFactory)
> {
> super(aFactory);
> }
>
>
> /* (non-Javadoc)
> * @see org.eclipse.gef.tools.CreationTool#performCreation(int)
> */
> protected void performCreation(int button)
> {
> CreateCommand command = (CreateCommand)this.getCommand();
>
> if(command.preExecute())
> {
> this.setCurrentCommand(command);
> try
> {
> super.performCreation(button);
> }
> catch(NullPointerException $ne)
> {
> //TODO I only get this problem on Linux. It happens when
> // selectAddedObject() is called.
> ;
> }
> }
> }
> }
>
> All the preExecute() method does is gets some information from the user
> via a dialog and returns true/false based on whether or not the
> information was valid.
>
> The problem is when selectAddedObject() method is called, the
> EditPartViewer from getCurrentViewer() is null.
>
> This only happens on Linux. It works fine on Windows. Is it obvious I am
> doing something wrong here, or is it a bug in the framework?
>
> many thanks,
>
> Barry
Re: selectAddedObject() throws NullPointerException only on Linux [message #160180 is a reply to message #160127] Thu, 02 December 2004 14:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bandrews.nospam_bphnx.com

Thanks Randy! Yes, the FocusLost happens when I pop up the Dialog. Makes
sense. I still need to call super because I do like the figure to get
selected after it is created so I just save the viewer before bringing
up the dialog then set it back afterwards. Works like a charm!

So in case anyone is interested, my performCreation() method looks like
this:

protected void performCreation(int button)
{
CreateCommand command = (CreateCommand)this.getCommand();
EditPartViewer viewer = getCurrentViewer();
if(command.preExecute())
{
this.setCurrentCommand(command);
setViewer(viewer);
super.performCreation(button);
}
}



Randy Hudson wrote:
> Sounds like the tool is getting a FocusLost event on Linux, and setting the
> current view to NULL. If you are going to override performCreation(), you
> probably shouldn't call super in this case.
>
> "Barry Andrews" <bandrews@nospam_bphnx.com> wrote in message
> news:con94b$bpn$1@www.eclipse.org...
>
>>Hello,
>>I think this is probably a bug, but I would like to confirm with the
>>experts here before logging. I have overridden CreationTool to provide
>>additional functionality to performCreation() method. My class looks
>>like this:
>>
>>public class DECreationTool extends CreationTool
>>{
>> /**
>> *
>> */
>> public DECreationTool()
>> {
>> super();
>> }
>>
>> /**
>> * @param aFactory
>> */
>> public DECreationTool(CreationFactory aFactory)
>> {
>> super(aFactory);
>> }
>>
>>
>> /* (non-Javadoc)
>> * @see org.eclipse.gef.tools.CreationTool#performCreation(int)
>> */
>> protected void performCreation(int button)
>> {
>> CreateCommand command = (CreateCommand)this.getCommand();
>>
>> if(command.preExecute())
>> {
>> this.setCurrentCommand(command);
>> try
>> {
>> super.performCreation(button);
>> }
>> catch(NullPointerException $ne)
>> {
>> //TODO I only get this problem on Linux. It happens when
>> // selectAddedObject() is called.
>> ;
>> }
>> }
>> }
>>}
>>
>>All the preExecute() method does is gets some information from the user
>>via a dialog and returns true/false based on whether or not the
>>information was valid.
>>
>>The problem is when selectAddedObject() method is called, the
>>EditPartViewer from getCurrentViewer() is null.
>>
>>This only happens on Linux. It works fine on Windows. Is it obvious I am
>>doing something wrong here, or is it a bug in the framework?
>>
>>many thanks,
>>
>>Barry
>
>
>
Re: selectAddedObject() throws NullPointerException only on Linux [message #160210 is a reply to message #160180] Thu, 02 December 2004 15:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Perhaps on windows, the Canvas gains focus again soon enough to restore the
current viewer.

"Barry Andrews" <bandrews@nospam_bphnx.com> wrote in message
news:conqt6$o0e$1@www.eclipse.org...
> Thanks Randy! Yes, the FocusLost happens when I pop up the Dialog. Makes
> sense. I still need to call super because I do like the figure to get
> selected after it is created so I just save the viewer before bringing
> up the dialog then set it back afterwards. Works like a charm!
>
> So in case anyone is interested, my performCreation() method looks like
> this:
Re: selectAddedObject() throws NullPointerException only on Linux [message #161457 is a reply to message #160210] Mon, 13 December 2004 12:39 Go to previous message
Eclipse UserFriend
Hi guys,

I have experienced the same problem, when I was running my plugin under
Linux.

Barry, I was thinking of exactly the same solution you have provided
(store and re-set current viewer.)

My code looked more or less like this:

protected void performCreation(int button) {
if (getCurrentCommand().canExecute()) {
InputDialog dlg = ...;
if (dlg.open() == Window.OK) {
CreateComponentCommand cmd = (CreateComponentCommand)
getCurrentCommand();
cmd.setComponentName(dlg.getValue());
super.performCreation(button);
}
}
}

So now I know how to fix it.

Thanks,
Milos

Randy Hudson wrote:
> Perhaps on windows, the Canvas gains focus again soon enough to restore the
> current viewer.
>
> "Barry Andrews" <bandrews@nospam_bphnx.com> wrote in message
> news:conqt6$o0e$1@www.eclipse.org...
>
>>Thanks Randy! Yes, the FocusLost happens when I pop up the Dialog. Makes
>>sense. I still need to call super because I do like the figure to get
>>selected after it is created so I just save the viewer before bringing
>>up the dialog then set it back afterwards. Works like a charm!
>>
>>So in case anyone is interested, my performCreation() method looks like
>>this:
>
>
>
Previous Topic:REQ_OPEN and DirectEdit
Next Topic:how to add points to a connection
Goto Forum:
  


Current Time: Sun Jul 27 06:40:05 EDT 2025

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

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

Back to the top