Bug 391389 - [ltk] Rename refactoring should give more control over new file name
Summary: [ltk] Rename refactoring should give more control over new file name
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: 4.5 M1   Edit
Assignee: Jerome Cambon CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday
Depends on:
Blocks: 437398
  Show dependency tree
 
Reported: 2012-10-09 02:15 EDT by Peter Severin CLA
Modified: 2014-06-13 13:03 EDT (History)
6 users (show)

See Also:
noopur_gupta: review+


Attachments
Here is my simple patch (1.10 KB, patch)
2014-05-16 10:06 EDT, Jerome Cambon CLA
no flags Details | Diff
New patch including Noopur's comments (2.17 KB, patch)
2014-06-04 10:16 EDT, Jerome Cambon CLA
no flags Details | Diff
New patch including latest Noopur's comments (2.21 KB, patch)
2014-06-05 06:29 EDT, Jerome Cambon CLA
no flags Details | Diff
New patch including latest Noopur's comments (2.19 KB, patch)
2014-06-06 06:31 EDT, Jerome Cambon CLA
jerome.cambon: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Severin CLA 2012-10-09 02:15:10 EDT
When using rename resource refactoring via resource rename dialog (see RenameResourceProcessor and RenameResourceWizard classes) my users frequently fail to keep the file extension. For example they rename "Screen1.screen" to "Screen2" which breaks things down the way.

I'd like to have a say over the file name. Ideally it should be possible to append the required extension automatically. Another option would be to allow custom validations of the file name.

If none of the above is possible then at least pre-select the file-name part (before the dot) the way Gnome does. This makes changing the name and leaving the extension in place a little easier.

My current fix is to make check this condition in checkConditions method in my rename participant. However this is not ideal because the error is only shown on the next page and user has to return to fix the problem.
Comment 1 Francis Upton IV CLA 2012-10-09 10:13:04 EDT
I have a similar issue; my product displays objects in the Project Explorer without the extension, but using the standard rename they have to specify the extension. It would be nice to control both the display and editing of this.
Comment 2 Dani Megert CLA 2012-10-10 06:30:31 EDT
I don't see us giving more control over this but only selecting the name before the extension like it is also done on Windows looks good (at least if on Windows).
Comment 3 Jerome Cambon CLA 2014-04-09 13:00:40 EDT
I agree with Dani's suggestion: this is how it is implemented in Windows Explorer and Mac OS Finder when renaming files.
I have a (very simple) fix for this.
Comment 4 Jerome Cambon CLA 2014-05-16 10:06:21 EDT
Created attachment 243180 [details]
Here is my simple patch
Comment 5 Noopur Gupta CLA 2014-05-29 08:21:50 EDT
- Add an explicit CoO sign-off comment with the patch. See:
http://wiki.eclipse.org/Development_Resources/Contributing_via_Git#via_Bugzilla

Review comments:

- Take care of the formatting (additional rules used in JDT UI) and update the file header (year and contributors list). See: https://wiki.eclipse.org/JDT_UI/How_to_Contribute#Coding_Conventions

- fNameField.setSelection(0, resourceName.lastIndexOf('.'));

* The last segment of a resource name should be considered as an extension only if the resource is a file. See bug 151668 comment #8 also.

* Also, add a check and do not pass -1 as 'end' value to Text#setSelection(int start, int end).
Comment 6 Jerome Cambon CLA 2014-06-04 09:09:07 EDT
This contribution complies with http://www.eclipse.org/legal/CoO.php
Comment 7 Jerome Cambon CLA 2014-06-04 10:14:33 EDT
(In reply to Noopur Gupta from comment #5)

Thanks for the Review.

> - Add an explicit CoO sign-off comment with the patch. See:
> http://wiki.eclipse.org/Development_Resources/
> Contributing_via_Git#via_Bugzilla
Done

> 
> Review comments:
> 
> - Take care of the formatting (additional rules used in JDT UI) and update
> the file header (year and contributors list). See:
> https://wiki.eclipse.org/JDT_UI/How_to_Contribute#Coding_Conventions
Done

> 
> - fNameField.setSelection(0, resourceName.lastIndexOf('.'));
> 
> * The last segment of a resource name should be considered as an extension
> only if the resource is a file. See bug 151668 comment #8 also.
Done

> 
> * Also, add a check and do not pass -1 as 'end' value to
> Text#setSelection(int start, int end).
Good catch! Done.
Comment 8 Jerome Cambon CLA 2014-06-04 10:16:04 EDT
Created attachment 243928 [details]
New patch including Noopur's comments
Comment 9 Noopur Gupta CLA 2014-06-05 04:46:25 EDT
(In reply to Jerome Cambon from comment #8)
> Created attachment 243928 [details] [diff]
> New patch including Noopur's comments

Thanks. Please also handle the files like .gitignore, .project etc where the entire text should be selected.
Comment 10 Jerome Cambon CLA 2014-06-05 06:27:44 EDT
(In reply to Noopur Gupta from comment #9)
> Thanks. Please also handle the files like .gitignore, .project etc where the
> entire text should be selected.
Indeed. Done.
Comment 11 Jerome Cambon CLA 2014-06-05 06:29:18 EDT
Created attachment 243984 [details]
New patch including latest Noopur's comments
Comment 12 Noopur Gupta CLA 2014-06-06 05:11:48 EDT
(In reply to Jerome Cambon from comment #11)
> Created attachment 243984 [details] [diff]
> New patch including latest Noopur's comments

"(lastIndexOfDot != -1) && (lastIndexOfDot != 0)" can be replaced with "(lastIndexOfDot > 0)". Rest looks good.
Comment 13 Jerome Cambon CLA 2014-06-06 06:31:46 EDT
Created attachment 244035 [details]
New patch including latest Noopur's comments
Comment 14 Noopur Gupta CLA 2014-06-13 09:59:32 EDT
(In reply to Jerome Cambon from comment #13)
> Created attachment 244035 [details] [diff]
> New patch including latest Noopur's comments

Released with:
http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=50846baef125a4cf5ac7b1665e6a8d26e89efffd