Community
Participate
Working Groups
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.
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.
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).
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.
Created attachment 243180 [details] Here is my simple patch
- 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).
This contribution complies with http://www.eclipse.org/legal/CoO.php
(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.
Created attachment 243928 [details] New patch including Noopur's comments
(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.
(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.
Created attachment 243984 [details] New patch including latest Noopur's comments
(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.
Created attachment 244035 [details] New patch including latest Noopur's comments
(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