Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Best strategy to bind handler to a control
Best strategy to bind handler to a control [message #327855] Tue, 06 May 2008 09:46 Go to next message
Eclipse UserFriend
What is the best strategy to activate command handlers for a single
control? For example, bind a special handler for the copy command to
each control in a form or a dialog. Three ideas:

1) Use IServiceLocatorCreator to create a handler service for each
control and activate/deactivate the ServiceLocator on focus change
- internal code, will it be public in future versions?
- it works

2) Create an expression for each control, use it when register the
handlers and reevaluate it on focus change
- does this work?

3) Write a "wrapper handler" selecting the handler of the control which
has the focus
- requires most new code


Teddy
Re: Best strategy to bind handler to a control [message #327958 is a reply to message #327855] Fri, 09 May 2008 09:45 Go to previous messageGo to next message
Eclipse UserFriend
Within one context (like your dialog or form), one common pattern is to
activate one handler and have it delegate to different controls in
focus. Similar to org.eclipse.ui.actions.TextActionHandler for actions.

Another way would be to use the IFocusService to register the controls
that can accept focus, and then use IHandlerService to activate the
handlers for those controls (also available declaratively while using
org.eclipse.ui.handlers)

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Best strategy to bind handler to a control [message #328257 is a reply to message #327958] Tue, 20 May 2008 08:04 Go to previous message
Eclipse UserFriend
Hi Paul,

thank you very much. I didn't know IFocusService - it works fine!

Teddy


Paul Webster wrote [2008-05-09 15:45]:
> Within one context (like your dialog or form), one common pattern is to
> activate one handler and have it delegate to different controls in
> focus. Similar to org.eclipse.ui.actions.TextActionHandler for actions.
>
> Another way would be to use the IFocusService to register the controls
> that can accept focus, and then use IHandlerService to activate the
> handlers for those controls (also available declaratively while using
> org.eclipse.ui.handlers)
>
> PW
>
>
Previous Topic:Tableviewer with databinding and inline edit support for boolean
Next Topic:Launching 3.4M7 as PDE runtime workbench from Eclipse 3.3.2
Goto Forum:
  


Current Time: Fri May 02 04:53:56 EDT 2025

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

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

Back to the top