IContextService in dialogs [message #317674] |
Wed, 11 July 2007 13:24  |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
I want to enable some keybindings in a dialog. Is there a IContextService for a Dialog?
Regards,
Teddy
|
|
|
|
|
Re: IContextService in dialogs [message #317741 is a reply to message #317724] |
Thu, 12 July 2007 09:00   |
Eclipse User |
|
|
|
Teddy W. wrote:
> Thanks. Yes, I mean a dialog on top of the workbench.
>
> But it doesn't work.
> I get the services and can set activateContext(..) and activateHandler(...), but the keys/contexts doesn't work in the dialog.
> The keyboard shortcuts work only, if the are added to the "dialog context". So the activation of the command handlers works.
What specifically are you trying to do?
If you open a dialog, you would get all keybindings that are in the
org.eclipse.ui.contexts.dialogAndWindow and
org.eclipse.ui.contexts.dialog contexts. If you want to have other
keybindings available, you can create another context off of
org.eclipse.ui.contexts.dialog and activate that with the
ActiveShellExpression or contribute your keybindings into the
org.eclipse.ui.contexts.dialog context.
If you have dialog specific handlers for a command that you want to
activate, you can do that with the IHandlerService and the
ActiveShellExpression. ex:
handlerActivation = handlerService.activateHandler(commandId, handler,
new ActiveShellExpression(getShell()));
When you close the dialog, don't forget to deactivate the context and
any handlers. For example:
if (handlerActivation!=null) {
handlerService.deactivateHandler(handlerActivation);
handlerActivation.getHandler().dispose();
handlerActivation = null;
}
Later,
PW
|
|
|
Re: IContextService in dialogs [message #317771 is a reply to message #317741] |
Thu, 12 July 2007 11:30  |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
I wanted to enable the "org.eclipse.ui.textEditorScope" context. Perhaps, this was a stupid idea:
a) it is a child of windows context and have so a lot of command at the wrong place.
b) if I understand you correctly, the context for the dialog have to me a child of the dialog context.
I wanted to provide some more text editing actions in a dialog (not only cut and paste), but it seems too complicated, to bind them to keys. I think,
- Adding all keybindings another time for a dialog context would confuse the user.
- Copying the required keybindings from textEditorScope to a dummy context is impossible or complicated. (?)
If this is right, I will discard my idea.
|
|
|
Powered by
FUDForum. Page generated in 0.04086 seconds