This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 178346 - Templates are not actually renamed on disk
Summary: Templates are not actually renamed on disk
Status: RESOLVED DUPLICATE of bug 163534
Alias: None
Product: platform
Classification: Unclassified
Component: Templates (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Assignee: David Simonek
URL:
Keywords:
: 178345 178737 (view as bug list)
Depends on:
Blocks: 188170
  Show dependency tree
 
Reported: 2009-12-09 02:30 UTC by jmborer
Modified: 2010-08-02 23:42 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Rename bug screenshot (9.43 KB, image/png)
2009-12-09 02:37 UTC, jmborer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jmborer 2009-12-09 02:30:09 UTC
When you create a new entry or duplicate an existing entry in the Templates dialog, the file that will be created on your local disk will not be renamed even though the dialog displays the new name.

I ran into this issue with licenses. I created a new license by duplicating the default Apache 2.0 license, renamed it for LGPL 2.1 to license-lgpl-2.1.txt. The new name appeared in the dialog, but on the disk, the name was still the one created during the copy: license-apach20_1.txt. So when I want to use the new license in a project and create a new Java file with the wizard, instead of getting a nice header I get an error text reading: "Error loading file..."
Comment 1 jmborer 2009-12-09 02:37:42 UTC
Created attachment 92320 [details]
Rename bug screenshot

As you can see, the file was renamed to license-toto.txt but the hint shows the old name license-apache20_1.txt
Comment 2 Marian Mirilovic 2009-12-09 03:09:16 UTC
Not a stopper for NB 6.8
Comment 3 Jiri Rechtacek 2009-12-09 03:23:56 UTC
IMHO it's intentional. Rename changes just display name of template, e.g. shown in New File wizard. Rename in the disk caused several serious problems (compare issue 152973 in NB6.5).
Comment 4 Geertjan Wielenga 2009-12-09 03:27:55 UTC
But this is a serious problem for people working with project licenses. To anyone, "rename" means "rename", not something half way, like "display name rename". I think this should be fixed somehow.
Comment 5 jmborer 2009-12-09 05:01:42 UTC
That's true: renaming halfway just breaks use of licenses in with code templates. Even worse, if I didn't know well NB, I would never have known whats going wrong and how to fix it. Very bad NB experience. If actually renaming a file on disk leads to other problems, then the templating engine should look for the name that is displayed in the "Template" dialog and use the file pointed whatever the name. Honestly this doesn't look like a good idea though: difficult to understand, what if you share the license among developer groups and hard to support to third party like the templating engine(s) that would like to include the resource.
Comment 6 jmborer 2009-12-09 05:16:22 UTC
Well, I read through issue 152973. It is not the point here. The discussion there is renaming an existing default template. 

Here I complain that when I create a new template or duplicate an existing a one, I expect it to be actually renamed especially if it was obtained by "Duplicate". When you tweak the content of say the Java class template, NB is not going to modify the original file, instead it copies the file into my home folder where it can be modified. From then it superseeds the original file. Nothing is broken.

So using the same logic, one should not be allowed to rename a "default" template (one that it provided by modules). Their name should be read-only, because they should always exist, otherwise the new file wizard might not work. 

I would expect from the templates UI:

1) default templates have their name read-only. The content should remain editable.
2) I need a custom template? Then just duplicate the file and rename (actualy) the copy.
Comment 7 jmborer 2009-12-09 05:17:31 UTC
It is maybe not a P1 bug, but certainly a very important one.
Comment 8 jmborer 2009-12-09 05:23:32 UTC
Sorry but this one cannot just not be fixed! It is a bug. The templating functionality is BROKEN!
Comment 9 rmichalsky 2009-12-09 05:52:53 UTC
I agree that it deserves to be solved, however it seems like P3 to me, templates manager behaves this way since beginning and IIRC this issue has already been closed at least once before (I cannot find the duplicate, though). 

> I need a custom template? Then just duplicate the file and rename (actualy)
> the copy.

If it is about renaming duplicate files, 'Duplicate' action could offer renaming before creating the copy. I recall that generic fix for renaming arbitrary action was problematic.
Comment 10 jmborer 2009-12-09 05:59:42 UTC
This really suprises me. Has ever someone used this functionality out there? She should have noticed the problem immediately. It is just plain broken and unusable. For example most licenses are not available from the Templates today. You have to put your one and this just don't work because of the file naming issue. Maybe no one reported it until now. Thos who have seen the problem and were not able to find a solution, just don't use the feature anymore...
Comment 11 Geertjan Wielenga 2009-12-09 06:03:27 UTC
+1

Have a look at the comments in this blog entry to see the frustration that this one specific issue is causing:

http://blogs.sun.com/geertjan/entry/project_level_license_settings_in
Comment 12 jmborer 2009-12-09 06:12:53 UTC
Excellent! Now there is a way to rename the file on disk from within NetBeans. As explained in the comments http://blogs.sun.com/geertjan/entry/project_level_license_settings_in you can change the file name from the properties dialog. Just right click on your template file, choose properties and then you see both the display and the file name. Changing the file name renames the file on disk. However the dialog throws an error if you try to replace an existing file. Not a big deal. 

Still, the "Rename" button should really do what it means and users expect.
Comment 13 rmichalsky 2009-12-16 09:03:27 UTC
*** Bug 178737 has been marked as a duplicate of this bug. ***
Comment 14 Jesse Glick 2010-08-02 23:41:13 UTC
*** Bug 178345 has been marked as a duplicate of this bug. ***
Comment 15 Jesse Glick 2010-08-02 23:42:08 UTC

*** This bug has been marked as a duplicate of bug 163534 ***