Bug 115460 - [key binding] Move keybindings for word caret moving to dialogAndWindow context
Summary: [key binding] Move keybindings for word caret moving to dialogAndWindow context
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 184502
  Show dependency tree
 
Reported: 2005-11-08 06:31 EST by Markus Keller CLA
Modified: 2007-05-24 10:56 EDT (History)
3 users (show)

See Also:


Attachments
Patch for org.eclipse.ui.workbench.texteditor (2.22 KB, patch)
2005-11-08 06:34 EST, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-11-08 06:31:54 EST
I20051102-1600

To allow a fix for bug 64665 (JDT controls with symbol names should be
camel-case aware), several keybindings for org.eclipse.ui.edit.text.*word*
actions should be moved to the "org.eclipse.ui.contexts.dialogAndWindow" scope
(otherwise, they are not available in dialogs.

I have a working implementation for bug 64665, which will be released as soon as
the keybindings have been moved. I'll attach a patch.
Comment 1 Markus Keller CLA 2005-11-08 06:34:31 EST
Created attachment 29519 [details]
Patch for org.eclipse.ui.workbench.texteditor
Comment 2 Dani Megert CLA 2005-11-08 07:31:42 EST
Platform Text should not define text widget commands.

I see two solutions here:
1) Platform UI adopts the commands (ID must be kept as is) and moves them to
   the dialogAndWindow context. If so, the content assist commands should be
   moved as well (they might be useful when resolving bug 106199).

2) in your dialog activate the following two scopes:
      "org.eclipse.ui.contexts.dialog"
      "org.eclipse.ui.textEditorScope"

Doug, would 2) work? Markus said he tried this but it did not work. Personally I
think 1) is the correct solution.
Comment 3 Markus Keller CLA 2005-11-08 09:09:02 EST
I tried 2) in TextFieldNavigationHandler (in the jdt.ui project):

    IContextService contextService= (IContextService)
        PlatformUI.getWorkbench().getAdapter(IContextService.class);
    contextService.activateContext(IContextService.CONTEXT_ID_DIALOG);
    contextService.activateContext("org.eclipse.ui.textEditorScope");

This didn't enable the keybinding. However, when I activated context 
    contextService.activateContext(IContextService.CONTEXT_ID_WINDOW);
in the dialog, then it suddenly worked.

Is this a bug in the context service story?

[To use the TextFieldNavigationHandler in e.g. the rename refactoring dialogs,
add the line 
    TextFieldNavigationHandler.install(fTextField);
to the end of TextInputWizardPage#createTextInputField(..).]
Comment 4 Douglas Pollock CLA 2005-11-08 10:09:00 EST
The key binding architecture ignores the text scope because it is a child of  
the window context.  The dialog context is active.  You would need to put the 
binding in the dialogAndWindow context.  
  
I am willing to do the following: take camel-case and a bunch of camel-case  
commands into a new UI plugin, let's say "org.eclipse.ui.camelcase".  Then, we 
can make "org.eclipse.ui.ide" dependent on this.  This is roughly outlined in 
Bug 113096.  Also, this would allow us to address Bug 90170. 
 
I don't feel that adding it to "org.eclipse.ui.workbench", for example, is a  
good idea.  It would increase the size of all RCP applications, when the  
functionality is only useful to a subset of RCP applications.  
 
Platform/UI does not have any time to commit to this (outside of code 
reviews). 
 
Comment 5 Dani Megert CLA 2005-11-08 10:23:03 EST
Word navigation isn't related to camel case and simply because these commands
would have to be retargeted for camel case support does not mean they belong to
the camel case plug-in / support.

>The key binding architecture ignores the text scope because it is a child of  
>the window context. 
Mmh, wasn't aware of this and the Javadoc doesn't tell about this either.
Comment 6 Douglas Pollock CLA 2005-11-08 10:57:05 EST
Okay, sorry I misunderstood.  Then this is just an extension of Bug 43102. 
  
Either way, I'd be willing to take these commands and any code to support them 
into a separate plug-in, and make "org.eclipse.ui.ide" depend on it. 
Comment 7 Michael Van Meekeren CLA 2005-11-08 11:03:24 EST
oops, removing the helpwanted keyword.
Comment 8 Dani Megert CLA 2005-11-08 12:37:38 EST
Just to confirm: is the implementation that makes cut, copy, paste commands work
in JFace dialogs done via o.e.u.ide's TextActionHandler?

I think a separate plug-in for just those commands would be overkill and in fact
they would be hard to implement for the Text widget since word navigation isn't
supported through the API, hence adding those commands to the dialog space might
be confusion for users since they won't affect most text widgets.

What's the reason to block context activation internally? As mentioned before
it's not mentioned in the API of activateContext(...) that this might be
overridden/ignored. Can you also comment on comment 3, especially why it works
when Markus activates the IContextService.CONTEXT_ID_WINDOW context.
Comment 9 Douglas Pollock CLA 2005-11-08 15:10:26 EST
(In reply to comment #8) 
> Just to confirm: is the implementation that makes cut, copy, paste commands 
> work in JFace dialogs done via o.e.u.ide's TextActionHandler? 
 
No, it is done using WidgetMethodHandler. 
 
 
> I think a separate plug-in for just those commands would be overkill and in 
> fact they would be hard to implement for the Text widget since word 
> navigation isn't supported through the API, hence adding those commands to 
> the dialog space might be confusion for users since they won't affect most 
> text widgets. 
 
getSelection, setSelection, getText and setText.  I think it would be possible 
to do most everything using only those methods. 
 
 
> What's the reason to block context activation internally? As mentioned 
> before it's not mentioned in the API of activateContext(...) that this might 
> be overridden/ignored. Can you also comment on comment 3, especially why it 
> works when Markus activates the IContextService.CONTEXT_ID_WINDOW context. 
 
Context activation is not blocked, the binding service simply ignores the 
context.  This is done so that -- when a dialog is open -- some key bindings 
do not unexpectedly work. 
Comment 10 Dani Megert CLA 2005-11-09 04:08:33 EST
>getSelection, setSelection, getText and setText.  I think it would be possible 
>to do most everything using only those methods. 
I don't think this smoothly works because you don't know what the native
behavior does i.e.  the user might get different behavior when assigning his own
key sequence to "word next" than he'd get when using e.g. Ctrl+Arrow_Right.
Unless of course we override the platform key sequences for "word next" with our
implementation as well.

>This is done so that -- when a dialog is open -- some key bindings 
>do not unexpectedly work
Why does it then work when Markus activates the
IContextService.CONTEXT_ID_WINDOW context?
Comment 11 Douglas Pollock CLA 2005-11-09 10:02:01 EST
(In reply to comment #10) 
> I don't think this smoothly works because you don't know what the native 
> behavior does i.e.  the user might get different behavior when assigning his 
> own key sequence to "word next" than he'd get when using e.g. 
> Ctrl+Arrow_Right. Unless of course we override the platform key sequences 
> for "word next" with our implementation as well. 
 
I'm not sure what is best here, but we might want to consider overriding 
native behaviour.  As it stands right now, there are several different text 
behaviours.  If I type in a Java editor, Ctrl+Arrow stops on capital letters.  
In a dialog, however, Ctrl+Arrow stops after spaces.  Double-clicking on some 
text also has different behaviour between a Java editor, a dialog and the 
plugin.xml text editor.  These differences cause me to make mistakes 
sometimes. 
 
 
> Why does it then work when Markus activates the 
> IContextService.CONTEXT_ID_WINDOW context? 
 
He is overriding the behaviour, and forcing both window and dialog contexts to 
be active.  I could detect (and block) that case, if you'd prefer. 
 
Comment 12 Dani Megert CLA 2005-11-09 17:03:27 EST
We do not plan to provide those commands in the Platform Text layer.
Comment 13 Dani Megert CLA 2005-11-09 17:05:03 EST
>We do not plan to provide those commands in the Platform Text layer.
Should have added: "for the org.eclipse.ui.contexts.dialogAndWindow scope
Comment 14 Dani Megert CLA 2007-05-24 09:20:35 EDT
This plan still holds but I'm open to move them to Platform UI (org.eclipse.ui) and change it there. This might be a smart move as we could in the future also push down the improved navigation code.

Paul, what do you think?
Comment 15 Dani Megert CLA 2007-05-24 09:24:25 EDT
The questions is which set and that's where it becomes ugly ;-)
So - probably rather not start to move them.
Comment 16 Paul Webster CLA 2007-05-24 10:26:52 EDT
(In reply to comment #15)
> The questions is which set and that's where it becomes ugly ;-)
> So - probably rather not start to move them.

I have no objections to moving what sound like global navigation commands down to org.eclipse.ui ... but once you are comfortable with the selection of navigation commands that make sense.

PW
Comment 17 Markus Keller CLA 2007-05-24 10:56:19 EDT
We should look at this in 3.4, in connection with supporting CamelCase in the Platform (bug 113096 etc.).