Skip to main content



      Home
Home » Eclipse Projects » GEF » a toolEntry that call a method
a toolEntry that call a method [message #144571] Tue, 27 July 2004 09:46 Go to next message
Eclipse UserFriend
Originally posted by: jerome.lafon.bull.net

Hi,
I need to add a button in my palette, that call a method from an other
object.
So I have created a object "GenerateEntry" that extends ToolEntry and I
have redefined the createTool() method:
public Tool createTool() {
root.generate();
return null;
}

after that I have added generate to the palette:
List entries = new ArrayList();
PaletteGroup controlGroup
GenerateEntry generateEntry=new GenerateEntry("generate", "generate
files", null,null);
entries.add(generate);
controlGroup.addAll(entries);

I can click the toolEntry but it stays pushed and I have an error:
Unhandled event loop exception
Reason:
java.lang.NullPointerException

I think the problem is the return of createTool() but I don't know what
object to return.

thanks for your answers
Re: a toolEntry that call a method [message #145390 is a reply to message #144571] Thu, 29 July 2004 00:29 Go to previous messageGo to next message
Eclipse UserFriend
I think what you want is a custom tool. The tool and template entries are
meant for creating new items (and hence dreateTool() should return a
CreationTool). If you want your item to just be a button that does
something (as opposed to an item that can be created by dragging and
dropping on the diagram), you'd be better off creating your own tool. And
then you could do whatever you want in activate() or handleButtonDown() or
some such method.

--

Pratik Shah
"jerome lafon" <jerome.lafon@bull.net> wrote in message
news:41065CBB.33A3800D@bull.net...
> Hi,
> I need to add a button in my palette, that call a method from an other
> object.
> So I have created a object "GenerateEntry" that extends ToolEntry and I
> have redefined the createTool() method:
> public Tool createTool() {
> root.generate();
> return null;
> }
>
> after that I have added generate to the palette:
> List entries = new ArrayList();
> PaletteGroup controlGroup
> GenerateEntry generateEntry=new GenerateEntry("generate", "generate
> files", null,null);
> entries.add(generate);
> controlGroup.addAll(entries);
>
> I can click the toolEntry but it stays pushed and I have an error:
> Unhandled event loop exception
> Reason:
> java.lang.NullPointerException
>
> I think the problem is the return of createTool() but I don't know what
> object to return.
>
> thanks for your answers
>
>
>
>
Re: a toolEntry that call a method [message #145452 is a reply to message #145390] Thu, 29 July 2004 07:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

Pratik Shah wrote:

> I think what you want is a custom tool. The tool and template entries are
> meant for creating new items (and hence dreateTool() should return a
> CreationTool). If you want your item to just be a button that does
> something (as opposed to an item that can be created by dragging and
> dropping on the diagram), you'd be better off creating your own tool. And
> then you could do whatever you want in activate() or handleButtonDown() or
> some such method.

I have to invent a palette tool myself, too.
Are there any examples/tutorials for creating own palette tools? The GEF
API is not very meaningful.

Thanks,
Martin.
Re: a toolEntry that call a method [message #145546 is a reply to message #144571] Thu, 29 July 2004 13:05 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Are you talking about putting a generic action in the palette? This is not
the intended use of the palette and is not supported. You could try to fake
it by placing a bogus tool in the palette, and doing something when it is
activated and the restoring the previous tool.

"jerome lafon" <jerome.lafon@bull.net> wrote in message
news:41065CBB.33A3800D@bull.net...
> Hi,
> I need to add a button in my palette, that call a method from an other
> object.
> So I have created a object "GenerateEntry" that extends ToolEntry and I
> have redefined the createTool() method:
> public Tool createTool() {
> root.generate();
> return null;
> }
>
> after that I have added generate to the palette:
> List entries = new ArrayList();
> PaletteGroup controlGroup
> GenerateEntry generateEntry=new GenerateEntry("generate", "generate
> files", null,null);
> entries.add(generate);
> controlGroup.addAll(entries);
>
> I can click the toolEntry but it stays pushed and I have an error:
> Unhandled event loop exception
> Reason:
> java.lang.NullPointerException
>
> I think the problem is the return of createTool() but I don't know what
> object to return.
>
> thanks for your answers
>
>
>
>
Previous Topic:REPOST: Marquee + bendpoint selection/move
Next Topic:Let label get focus when its parent gets created?
Goto Forum:
  


Current Time: Mon Oct 27 19:14:52 EDT 2025

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

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

Back to the top