Bug 54815 - [KeyBindings] [Contexts] Retarget fixed set of command for a shell
Summary: [KeyBindings] [Contexts] Retarget fixed set of command for a shell
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 55349 (view as bug list)
Depends on: 31731
Blocks: 126342
  Show dependency tree
 
Reported: 2004-03-15 09:35 EST by Dani Megert CLA
Modified: 2007-06-20 14:05 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2004-03-15 09:35:56 EST
I20040310

I need to define (retarget) an existing command but don't want to inherit all
other commands. Currently I can either get all commands (see
registerForKeyBindings) or only the ones for text editing.

The problem can be seen easily when using the debugger's new inspect pop-ups: if
you press Ctrl+H it opens the Search dialog because Ctrl+H is in the global context.

Note: I don't like to define a new key binding context since the user should be
able to invoke the command with its predefined key sequence and should not be
forced to redefine the same key sequence for the same command but in a different
context.
Comment 1 Dani Megert CLA 2004-03-16 08:59:56 EST
Is this covered by bug 31731 which is targeted for 3.0 M8?

I guess even if I define a new context it will automatically inherit from
global, right? So the question is: how can I disable the global context?
Comment 2 Dani Megert CLA 2004-03-19 07:55:21 EST
*** Bug 55349 has been marked as a duplicate of this bug. ***
Comment 3 Dani Megert CLA 2004-03-19 08:04:53 EST
Chris, can you give us an ETA for this? If it doesn't make it into M8 then we
need to take out the key binding support for the Quick Outline (Ctrl+F10 to show
the view menu) due to bug 55349.
Comment 4 Dani Megert CLA 2004-03-23 09:50:46 EST
The new key binding code released for I20040322 broke the existing support to
open the view menu using Ctrl+F10.

For now I removed all corresponding code.
Comment 5 Douglas Pollock CLA 2004-03-25 10:08:13 EST
I don't feel like I have a complete understanding of what you're doing, but the 
following might work.  If it doesn't, can you provide more details?  Thanks.... 
 
1.) Define a context for your key binding to exist in. 
2.) Make a submission through WorkbenchContextSupport binding the context to 
your shell, as well as in whatever other situations you need (?) it. 
3.) Define a handler, and submit the handler through WorkbenchCommandSupport.  
It is currently not possible to restrict a handler to a particular shell, 
though I'm considering that support for M9.  If it is important for you, please 
say so. 
 
You can also try messaging me on Sametime or IRC (irc.freenode.net#eclipse-dev) 
-- IRC is preferred. 
 
Comment 6 Dani Megert CLA 2004-03-25 11:33:37 EST
Concrete use case: I want to hook an action to the show view menu command

I didn't want to define a new context (at least not visible to the user).
Let's say someone defines a command X in some context and the user configured a
key sequence for it. Let's assume I have no influence over that context i.e. I
cannot ask to change the context(s) for command X. Now, I would still like to
use that command and its sequence in my dialog without giving the user the
burden to know about some special "QuickControl" context.
Comment 7 Douglas Pollock CLA 2005-11-11 10:30:54 EST
 (In reply to comment #6)  
> I didn't want to define a new context (at least not visible to the user).  
> Let's say someone defines a command X in some context and the user  
> configured a key sequence for it. Let's assume I have no influence over that  
> context i.e. I cannot ask to change the context(s) for command X. Now, I  
> would still like to use that command and its sequence in my dialog without  
> giving the user the burden to know about some special "QuickControl"  
> context.  
  
This does make sense to me.  Commands are not defined in a context.  Bindings  
are defined in contexts.  You always have influence over contexts: anyone can 
activate and deactive contexts.  In your dialog, activate the context 
containing the binding you wish to use. 
 
Comment 8 Markus Keller CLA 2005-11-11 10:54:58 EST
(In reply to comment #7)
> In your dialog, activate the context containing the binding you wish to use. 

That's exactly the point of this bug. The binding looks like this:
      <key
            sequence="M1+O"
            contextId="org.eclipse.jdt.ui.javaEditorScope"
            commandId="org.eclipse.jdt.ui.edit.text.java.show.outline"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>

Now, when the dialog is active, we don't wan't to activate all commands from the
javaEditorScope (which would not work anyway, since it inherits
org.eclipse.ui.contexts.window and not dialogAndWindow (bug 115460 comment 4)).

We only want to activate the particular command
"org.eclipse.jdt.ui.edit.text.java.show.outline" with the keybinding it has in
javaEditorScope.
Comment 9 Douglas Pollock CLA 2005-11-11 11:05:12 EST
The way to do this is to do the following: 
 
    <key 
        sequence="M1+O" 
        contextId="org.eclipse.ui.contexts.dialogAndWindow" 
        commandId="org.eclipse.jdt.ui.edit.text.java.show.outline" 
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" /> 
 
Comment 10 Michael Van Meekeren CLA 2006-04-21 13:14:46 EDT
Moving Dougs bugs
Comment 11 Paul Webster CLA 2006-09-28 15:13:08 EDT
Is this still a problem in 3.3?

PW
Comment 12 Markus Keller CLA 2006-09-29 09:07:41 EDT
> Is this still a problem in 3.3?
Yes.
Comment 13 Paul Webster CLA 2006-09-29 09:23:46 EDT
(In reply to comment #9)
> The way to do this is to do the following: 
>  
>     <key 
>         sequence="M1+O" 
>         contextId="org.eclipse.ui.contexts.dialogAndWindow" 
>         commandId="org.eclipse.jdt.ui.edit.text.java.show.outline" 
>         schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" /> 
>  

If I read Doug's reply correctly, there's no way to use the javaEditorScope keybindings individually in a dialog.  He's suggesting just moving your keybinding into dialogAndWindow.

For finer control,  you could create a javaCommonScope context (probably parented off of org.eclipse.ui.contexts.dialogAndWindow) and place the common keybindings you want in there ... then activating that context with the java editor and your dialog would allow them to continue working.

PW
Comment 14 Markus Keller CLA 2006-09-29 09:58:43 EDT
Dani, is that an option?
Comment 15 Dani Megert CLA 2006-10-11 10:52:42 EDT
Paul, I tried that:
>     <key 
>         sequence="M1+O" 
>         contextId="org.eclipse.ui.contexts.dialogAndWindow" 
>         commandId="org.eclipse.jdt.ui.edit.text.java.show.outline" 
>         schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" /> 

and as you remember I also tried your patch from bug 126044, comment 7 and see also bug 126342. For some strange reason the context for Ctrl+O's shell is still the java editor scope and even if I do this:

IContextService contextService=   
    (IContextService)site.getService(IContextService.class);
contextService.activateContext(IContextService.CONTEXT_ID_WINDOW);
IHandlerService service=
    (IHandlerService)site.getService(IHandlerService.class);
service.activateHandler(invokingCommandId, getToggleHandler(invokingCommandId));
service.activateHandler(fShowViewMenuAction.getActionDefinitionId(), new org.eclipse.jface.commands.ActionHandler(fShowViewMenuAction));

Neither F10 or Ctrl+O work in the dialog.

So - any help to make this work is really appreciated i.e. I don't absolutely require this bug to get resolved but a solution to remove the deprecated code out of AbstractInformationControl and its subclasses.
Comment 16 Paul Webster CLA 2006-10-25 13:26:53 EDT
Hi Dani, I'm investigating.

Which dialog class are you working with right now?  And you want CTRL+F10 to be fShowViewMenuAction for the dialog, and CTRL+O to be "org.eclipse.jdt.ui.edit.text.java.show.outline" for the dialog?

Is it InspectPopupDialog?

PW
Comment 17 Dani Megert CLA 2006-10-26 02:51:53 EDT
>Which dialog class are you working with right now?
The concrete class is JavaOutlineInformationControl which extends AbstractInformationControl (used in JDT UI for the Quick views) extends PopupDialog from Platform UI (JFace).

>and you want CTRL+F10 to be
>fShowViewMenuAction for the dialog,
Correct.
> and CTRL+O to be "org.eclipse.jdt.ui.edit.text.java.show.outline" for the
> dialog?
It does two things:
- while editor is active it opens the Quick Outline
- while Quick Outline is active it toggles its input

>Is it InspectPopupDialog?
No, that's from Debug.
Comment 18 Paul Webster CLA 2007-06-20 14:05:00 EDT
There are no plans to provide other scoping options in keybindings.

There are either the hierarchical set of contexts and/or the selected scheme and its parent schemes.

PW