Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Can i Create a new instance of a Handler.(I know that we can trigger execution of hanlder using Command.ExecuteWithChecks)
Can i Create a new instance of a Handler. [message #651235] Fri, 28 January 2011 13:46 Go to next message
Saurabh Mising name is currently offline Saurabh Mising name
Messages: 21
Registered: October 2010
Junior Member
I have an abstract handler which extends AbstractHandler. I want to be able to create an anonymous class which extends this abstract handler. In this anonymous class, i want to give implmentation for the abstract methods. However, to do this, i need to call the constructor of the handler.

Is it okay to instantiate a new Handler? I am asking this because I am aware that handlers can be invoked using Command.ExecuteWithChecks() method. I dont know if instantiating a handler and calling activateHandler() is a good thing to do?

Any thoughts on this will be appreciated.
Re: Can i Create a new instance of a Handler. [message #651254 is a reply to message #651235] Fri, 28 January 2011 15:09 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 01/28/2011 08:46 AM, Saurabh wrote:
> I have an abstract handler which extends AbstractHandler. I want to be
> able to create an anonymous class which extends this abstract handler.
> In this anonymous class, i want to give implmentation for the abstract
> methods. However, to do this, i need to call the constructor of the
> handler.

While creating a view an acceptable pattern is:
IHandlerService hs
= (IHandlerService) getSite().getService(IHandlerService.class);
IHandler handler = new AbstractHandler() {
public Object execute(ExecutionEvent event)
throws ExecutionException {
// do whatever
return null;
}
};
hs.activateHandler("command.id", handler);

Is this what you mean?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:Building RCP application bundle jdk instead of jre
Next Topic:Internationalization of combobox values from database
Goto Forum:
  


Current Time: Tue Sep 16 19:40:22 GMT 2014

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

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