Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » a toolEntry that call a method
a toolEntry that call a method [message #144571] Tue, 27 July 2004 13: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 04:29 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
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 11: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 17: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: Thu Apr 25 13:19:15 GMT 2024

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

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

Back to the top