Bug 67930 - [Keybindings] Wrong behaviour when triggering Code Assist in "Rename Field"-Dialog
Summary: [Keybindings] Wrong behaviour when triggering Code Assist in "Rename Field"-D...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P1 major (vote)
Target Milestone: 3.0 RC4   Edit
Assignee: Douglas Pollock CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-19 11:01 EDT by Nico Seessle CLA
Modified: 2004-06-23 15:16 EDT (History)
1 user (show)

See Also:


Attachments
Patch to "org.eclipse.ui.workbench" (3.74 KB, patch)
2004-06-21 13:13 EDT, Douglas Pollock CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Seessle CLA 2004-06-19 11:01:02 EDT
I200406190041

I wanted to rename the field "listeners" in the following code: 

import java.util.EventListener;
import javax.swing.event.EventListenerList;

public class Test1 {
    EventListenerList listeners = new EventListenerList();
    public void addEventListener(EventListener eventListener) {
        listeners.add(EventListener.class, eventListener);
    }
}

Steps: 
- Trigger Rename Field Refactoring (using Ctrl-Shift-R) while Cursor is on
"listeners"
- Rename Field-Dialog opens
- Type "ev" in "New Name" and trigger Code Assistant using "Ctrl-Space"

Actual Result: 
A popup opens suggesting some field-names, *but* this popup is triggered on the
editor, and not on the dialog. If you press "Enter" to select a suggestion the
field is renamed to "ev", and the popup remains open.

Expected Result: 
Popup closes and selection is inserted into the "New Name"-Field.
Comment 1 Dirk Baeumer CLA 2004-06-20 09:42:24 EDT
This is actuall the same problem as described in bug 67611. The keyboard short 
cuts target the widget of the application window not the dialog. 

I tested this on build I200406191600 and could reproduce. To better see the 
bahaviour, open the rename dialog and move it to the lower right corner and 
press Ctrl+Space in the dialog. You see the code assist opening on the editor.

Marking as critical since this is a regression.

Moving to platform UI since 67611 was fixed there.
Comment 2 Erich Gamma CLA 2004-06-21 06:05:03 EDT
Some additional info...

When pressing ctrl+space in a dialog which offers code assist in a field (e.g. 
New Class>Superclass, Refactoring>Change Method Signature) then the code 
assist dialog shows up as expected, i.e., it targets the dialog.

In the case of Rename Field we don't offer code assist in the dialog (but we 
should bug# 67974).

This means that pressing ctrl+space in any dialog which doesn't offer code 
assist will pop-up the code assist targetting the editor (e.g. Open Type).
Comment 3 Douglas Pollock CLA 2004-06-21 10:20:39 EDT
I see this problem as well.  This is likely a handler submission somewhere that 
is not specifying a shell. 
 
Downgrading to major, as this does not cause crashes or loss of data. 
Comment 4 Markus Keller CLA 2004-06-21 10:28:43 EDT
Note that this seems to be a problem with all commands with "When:" set to "In
Dialogs".

When I change 'Text Editing > Select Next Word' from 'Editing Text' to 'In
Dialogs and Windows', I see the same behavior in any dialog.
Comment 5 Douglas Pollock CLA 2004-06-21 10:35:55 EDT
Is this dialog supposed to support content assist? 
Comment 6 Douglas Pollock CLA 2004-06-21 10:44:03 EDT
The problem is likely as follows: 
+ Fall back support was added to dialogs to support detached views.  Detached 
views look like dialogs, but want the regular workbench window handlers.  So, 
if no handler is defined for the active shell, the command mechanism checks to 
see if there is a handler for the active workbench window. 
+ Code assist has a hander on the workbench window, the key binding is defined 
as dialog+window, but the handler does not handle the case where a dialog is 
open. 
 
Would it be possible to change the content assist action (the one registered on 
the workbench window) to include a line "if 
(!workbenchWindow.getShell().equals(display.getActiveShell())) return;"? 
 
Comment 7 Markus Keller CLA 2004-06-21 10:54:15 EDT
> Is this dialog supposed to support content assist? 
No! The original poster thought it should, and maybe we'll add it post 3.0.
Currently it doesn't support content assist and the shortcut should behave as
every other unbound shortcut (do nothing).

As said in my comment 4, the problem is not about content assist. It's a general
problem of all commands which are assigned to the 'In Dialogs and Windows'
context. Users and plugin providers can run into this problem whenever they
define a command to be active in the d&w context.

Another example: Assign Ctrl+Alt+A to Views > Ant. Close the Prefs dialog and
re-open it. Pressing Ctrl+Alt+A now opens the Ant view in the Workbench Win.

=> I don't think we should have to change something with the content assist handler.
Comment 8 Douglas Pollock CLA 2004-06-21 13:13:11 EDT
Created attachment 12581 [details]
Patch to "org.eclipse.ui.workbench"

This fixes the problem in two ways:
1.) Actions register through the key binding service are assigned a shell
2.) If a dialog is open, then the fallback to window won't be allowed.
Comment 9 Douglas Pollock CLA 2004-06-22 13:28:33 EDT
Patch is reviewed by Tod Creasey and Kim Horne.  It has been committed to CVS.  
It should appear in I200406221600. 
Comment 10 Douglas Pollock CLA 2004-06-23 15:16:21 EDT
Verified in I200406230010, GTK+ 2.4.1, KDE 3.2.2, Linux 2.6.6.