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 91580

Summary: Need way to customize name pattern for new files
Product: projects Reporter: Torbjorn Norbye <tor>
Component: Generic Projects UIAssignee: Milos Kleint <mkleint>
Severity: blocker CC: mkrauskopf
Priority: P3 Keywords: API
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description Torbjorn Norbye 2006-12-26 18:32:48 UTC
I have some file templates in my project. When the user opens the New File
dialog, the proposed name is always prefixed with "new". This constant appears
to be hardcoded in SimpleTargetChooserPanelGui.

For some of my file templates, I'd like to use a different prefix.

For example, for Ruby unit tests, the convention is tc_<name>, and for Ruby test
suites, ts_<name>.

The way to accomplish this for myself appears to be to register my own templace
wizard iterator, and replicate all the code in SimpleTargetChooserPanelGui.

I think it would be much better if I could simply add an additional attribute on
the templateFile (just like the existing instantiatingIterator,
instantiatingWizardUrl, etc.

Here's an example:
             <file name="suite.rb" url="suite.rb">
                 <attr name="template" boolvalue="true"/>
                 <attr name="SystemFileSystem.localizingBundle" stringvalue=.../>
                <attr name="templateNamePrefix" stringvalue="ts_"/>

The following diff to projects/projectui/**/SimpleTargetChooserPanelGui would
accomplish it (although I presume there would need to be additional
documentation of this in some arch documents, and perhaps similar
implementations in other Wizard panels serving the same purpose, such as

RCS file:
retrieving revision 1.30
diff -u -u -r1.30
    13 Jul 2006 08:04:01 -0000      1.30
    26 Dec 2006 18:24:44 -0000
@@ -134,7 +134,12 @@
         if (template != null) {
             if (documentName == null) {
-                documentName = NEW_FILE_PREFIX + template.getName ();
+                String prefix = NEW_FILE_PREFIX;
+                Object customPrefix = template.getAttribute("templateNamePrefix");
+                if (customPrefix != null) {
+                    prefix = customPrefix.toString();
+                }
+                documentName = prefix + template.getName ();
             documentNameTextField.setText (documentName);
             documentNameTextField.selectAll ();
Comment 1 Milos Kleint 2012-09-03 08:07:54 UTC
is this still needed?
Comment 2 Milos Kleint 2013-03-08 12:08:51 UTC
I suppose not