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 97327 - Sample Project generated code could be more reusable
Summary: Sample Project generated code could be more reusable
Status: NEW
Alias: None
Product: apisupport
Classification: Unclassified
Component: Templates (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Martin Kozeny
URL:
Keywords:
Depends on:
Blocks: 70605 187756
  Show dependency tree
 
Reported: 2007-03-07 00:22 UTC by _ tboudreau
Modified: 2013-02-14 13:18 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2007-03-07 00:22:20 UTC
If you bundle multiple sample projects, you will probably create multiple wizard
iterators/panels/etc. for them.  However, you can easily use one set of
generated wizard code for multiple sample projects.  The only problem with the
code as currently generated is that the visual panel will have the hardcoded
name of the original project template.

Adding the following to the generated code in *WizardIterator.initialize enables
one iterator to be reused for multiple projects.  It would be nice if the
template automatically did this:
        FileObject template = Templates.getTemplate(wiz);
        String name = template.getName();
        wiz.putProperty ("name", name);

or if you really want to get fancy

        FileObject template = Templates.getTemplate(wiz);
        String name = DataObject.find(template).getNodeDelegate().getDisplayName();
        wiz.putProperty ("name", name);
Comment 1 _ tboudreau 2010-01-14 10:26:01 UTC
Something to consider if we ever redo project template generation:

simple.project.templates in nbsrc defines a microformat inside properties files 
(example from Java Card here - http://hg.netbeans.org/main/raw-file/0850e3245ad2/javacard.project/src/org/netbeans/modules/javacard/templates/cap-project-template.properties )

Basically the format is 

relative/path/in/project=path/to/template/in/sfs

with substitutions (you pass a map into the factory), e.g.

src/{{packagepath}}/{{classname}}.java*=Templates/javacard/ClassicApplet.java

(the asterisk denotes that the file should be opened on project creation - or at any rate, part of the set of FileObjects returned to whatever wizard called it).

The microformat part is two prefixes:
pp.foo={{somevalue}}
means this is a property (with the pp. stripped) for project.properties;
pvp.foo={{somevalue}} (with the pvp. stripped) for private.properties.

or you can subclass FileCreator and pass as many as you want into the factory to create whatever you want (such as the initial project.xml).

Ought to be fairly straightforward to generate this stuff, and much more flexible and saner than processing names in a zip file as it's unzipped, which is what you have to do now if you just want to give a generated java file the same name the user entered for the project.