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 - Need way to customize name pattern for new files
Summary: Need way to customize name pattern for new files
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Projects UI (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Milos Kleint
Keywords: API
Depends on:
Reported: 2006-12-26 18:32 UTC by Torbjorn Norbye
Modified: 2013-03-08 12:08 UTC (History)
1 user (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
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