Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 437398

Summary: [ccp] Don't select extension when asking for new file name on paste
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: UIAssignee: Noopur Gupta <noopur_gupta>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jerome.cambon, markus.kell.r, noopur_gupta
Version: 4.4Flags: markus.kell.r: review+
Target Milestone: 4.5 M1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 391389    
Bug Blocks:    
Attachments:
Description Flags
Patch none

Description Markus Keller CLA 2014-06-13 13:03:59 EDT
Follow-up to bug 391389. There are other scenarios where Eclipse asks for a new file name, and those should behave the same as the Rename dialog.

E.g. when you copy/paste a file in the Package Explorer, the dialog should also pre-select the file name without the extension.
Comment 1 Markus Keller CLA 2014-06-13 13:07:54 EDT
Please think about other cases where should add this as well for consistency. I didn't find anything right away, but maybe you do.
Comment 2 Noopur Gupta CLA 2014-06-16 04:24:45 EDT
I couldn't find any place other than comment #0 where file name is pre-filled with extension.
Comment 3 Jerome Cambon CLA 2014-06-26 05:06:43 EDT
For copy/paste, the selection of the text to change is done from org.eclipse.jface.dialogs.InputDialog class.
The selectAll() call on the text field is hardcoded on this dialog.

So it seems an important refactoring would be needed to fix this one (for instance define a specific wizard, as done with RenameResourceWizard).
No sure I want to jump into this now, so unless there is a simple solution, perhaps it is better to assign to somebody else.
Comment 4 Noopur Gupta CLA 2014-06-26 08:17:06 EDT
Created attachment 244547 [details]
Patch

(In reply to Jerome Cambon from comment #3)
> For copy/paste, the selection of the text to change is done from
> org.eclipse.jface.dialogs.InputDialog class.
> The selectAll() call on the text field is hardcoded on this dialog.

We can override InputDialog#createButtonsForButtonBar which calls Text.selectAll() and set the selection as required.

Markus, please have a look at the attached patch.
Comment 5 Markus Keller CLA 2014-07-16 14:09:22 EDT
(In reply to Noopur Gupta from comment #4)
> We can override InputDialog#createButtonsForButtonBar which calls
> Text.selectAll() and set the selection as required.

Yes, that works. But the choice of InputDialog to set/select the text in #createButtonsForButtonBar(Composite) is questionable. We better override #createContents(Composite).

Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=e3acadde6670cb99e73585d381037e12bf2af2cd
Comment 6 Markus Keller CLA 2014-07-16 14:26:24 EDT
Applied the same fix to org.eclipse.ui.actions.CopyFilesAndFoldersOperation#getNewNameFor(..): http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=5420fb1b4fc1a364dee872c2f469c8712e2b5e5e

Resurrected bug 200444 to make it follow the behavior from bug 151668.