Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 95399 - After switching to FreeMarker default package name is no longer replaced by one from wizard
After switching to FreeMarker default package name is no longer replaced by o...
Product: java
Classification: Unclassified
Component: Unsupported
All All
: P2 (vote)
: 6.x
Assigned To: Jan Pokorsky
Depends on: 97974 98011 98874
Blocks: 92595 99232 99233 99234 99235 105744
  Show dependency treegraph
Reported: 2007-02-13 13:43 UTC by Martin Adamek
Modified: 2011-08-16 13:54 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT

Proposed Class template (309 bytes, text/plain)
2007-03-01 16:12 UTC, Jan Pokorsky
prototype (45.10 KB, text/plain)
2007-03-16 00:06 UTC, Jan Pokorsky

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Adamek 2007-02-13 13:43:11 UTC
After switching my wizard to FreeMarker template engine, the default package
name defined in template is not replaced by package name actually defined in the
wizard. Java infrastructure should take care of this operation.
Comment 1 Jaroslav Tulach 2007-02-13 14:16:06 UTC
Maybe we need some meeting to discuss the future of templating support for 
Java files and Java based projects. Original plan for java/project module was 
to provide an implementation of
that would add the Java related properties - package, classname, etc.
Comment 2 Jan Pokorsky 2007-03-01 10:52:27 UTC
I have done some prototyping and here are my observations:

JP1: IMO CreateFromTemplateAttributesProvider should be placed into the
java/source module where is the JavaDataLoader. package, classname, ... has
nothing to do with project.

JP2: java/project should provide template attribute like licence.

JP3: Jardo, are you going to provide some editor support(own loader?) for
freemaker templates? Nowadays it is an editor taken from e.g. JavaDataLoader.
But freemaker templates are not regular java sources so I will have to prevent
to recognize them by the JavaDataLoader. The template editor could offer
available template attributes via
syntax highlighting, ...

JP4: Is there any naming convention for template attributes like
${package}|${java.package}|${}? Should
attributes be exported as API? The arch has not supported this yet.

JP5: Compatibility. I guess there will be none. Modified templates will not be
copied from previous release. Otherwise we would have to provide a transformer.

JP6: Present refactoring post-processing will be replaced with template attributes.

Comment 3 Jaroslav Tulach 2007-03-01 14:25:40 UTC
JP1 - ok.

JP2 - I have prototyped but it 
needs few changes. A few ideas would include - we might write an 
CreateFromTemplateAttributesProvider that would make all properties in 
nbproject/ available to the scripting engine. Then the users 
could specify license=GPL in their and then the license.txt 
file would contain if (${project.license} == GPL) { 
#include("license-gpl.txt" }. We might predefine few most common licenses GPL, 
CDDL, apache, bsd - the users could of course define their own and modify 
license.txt to suite their needs. How does this sound?

JP3 - Imho your loader shall check for javax.script.ScriptEngine attribute of 
the file and if present then set mime type to "text/x-freemarker". Hanz 
promised to deliver syntax coloring for it. Mixed coloring (java + freemarker) 
is out of scope for 6.0 according to Hrebejk.

JP4 - java.package is the best imho.

JP5 - no import, imho. keep that in mind for list of files to skip/include for 
6.0 or just change ide/upgrader 

JP6 - I've heard about problems with guarded blocks - imho solution should not 
overcomplicate the templates itself, as that is an API we expose to end users 
and we should not scare them. Better to enhance indentation engine, imho.
Comment 4 Jan Pokorsky 2007-03-01 16:08:30 UTC
JP2 - I like the idea of licence from

JP3 - I could register MIME Resolver for java + freemarker

JP4 - I tend rather to just package. It should not clash in java world. I was
asking if there will be some recommendation like for system properties.
So java will introduce just 'package' attribute and reuse 'name' attribute as
the class name.

JP6 - Yep, I mentioned guarded blocks use case. You can read more about the
problem in issue #72396. AFAIK this relates just to some mobility templates
where //GEN tag follows straight '{'. The template would look like

public void mobile() <#if !nlbeforebrace>{// GEN-LINE:head<#else>//GEN-BEGIN:head

${nlbeforebrace} would represent JavaIndentEngine option. Not nice but it is a
way for them now. Later we can tweak the java indent engine.
Comment 5 Jan Pokorsky 2007-03-01 16:12:19 UTC
Created attachment 39061 [details]
Proposed Class template
Comment 6 Jan Pokorsky 2007-03-01 17:01:51 UTC
JP2 - I think the licence.txt template should be placed in openide/loaders. It
is a kind of default like name, date, time, ...
Comment 7 Jan Pokorsky 2007-03-02 11:39:51 UTC
DK1 - dkaspar proposes not to include the constructor in Class template. I
agree.   Any objections? 
Comment 8 Martin Adamek 2007-03-02 12:21:23 UTC
I don't have strong opinion on presence of constructor, but if it is going to
stay, at least the comment: /** Creates a new instance of ${name} */ should be
Comment 9 Jaroslav Tulach 2007-03-12 16:37:14 UTC
JP2 - openide/loaders does not have any layer.xml and it should not have as it 
is an autoload module. The license has to be somewhere else. Imho potentially 
in ide cluster and not platform cluster as licenses are more IDE oriented then 
something for every platform user.
Comment 10 Jan Pokorsky 2007-03-13 14:01:16 UTC
JP2 - what is appropriate then? ide/defaults, core/ide, ...? I would have to
declare a dependency on such a module, right?
Comment 11 Jaroslav Tulach 2007-03-14 00:25:34 UTC
JP2 - btw. the license has to be in ide cluster, as the freemarker engine is 
in ide cluster as well. I am not sure what module is the best. Here are 
possible candidates:

org-netbeans-core-ide.jar - I do not like that, we want to vanish the module
org-netbeans-libs-freemarker.jar - actually it is freemarker template, so it 
could be in freemarker itself!?
org-netbeans-modules-editor-plain.jar - probably not, it does not have 
knowledge of templates
org-netbeans-modules-projectuiapi.jar - my preferred, the templates are 
project related (especially if we parse the to find 
preferred license), and this is the lowest module that deals with projects and 
provides some API and is related to UI
org-netbeans-modules-utilities.jar - brrrr... usual place where to put garbage

I am unsure, my advice is, please try to prototype solution with projectuiapi 
or freemarker itself.
Comment 12 Jan Pokorsky 2007-03-16 00:05:19 UTC
Follows the java templates prototype.
* I chose org-netbeans-modules-projectui.jar to place license templates as
* org-netbeans-modules-java-j2seproject.jar registers the template attributes
provider for ${project.license} attribute. Other project types should provide
the same.
* org-netbeans-modules-java-project.jar contains rewritten java templates.
* org-netbeans-modules-java-source.jar registers provider for ${package} attribute.

Blocker is issue #98011 since freemarker is not customized properly to handle
file paths.
Comment 13 Jan Pokorsky 2007-03-16 00:06:27 UTC
Created attachment 39569 [details]
Comment 14 Jan Pokorsky 2007-03-20 11:08:37 UTC
There are no objections so I am going to integrate it. Thanks for review.
Comment 15 Jaroslav Tulach 2007-03-20 16:48:20 UTC
Y01 Add arch.xml documentation for locations of layer files (content of 
Licences folder), for properties that one can use and expect (project.license, 
package, etc.)

Y02 Increment spec version of java/project, write apichange.xml 

Otherwise very nice.
Comment 16 Jan Pokorsky 2007-03-26 22:08:18 UTC
implemented in

/cvs/ide/golden/cluster-deps.txt,v  <--  cluster-deps.txt
new revision: 1.81; previous revision: 1.80
/cvs/ide/golden/deps.txt,v  <--  deps.txt
new revision: 1.489; previous revision: 1.488
new revision: 1.80; previous revision: 1.79
initial revision: 1.1
/cvs/java/project/,v  <--
new revision: 1.23; previous revision: 1.22
/cvs/java/project/nbproject/project.xml,v  <--  project.xml
new revision: 1.36; previous revision: 1.35
/cvs/java/project/src/org/netbeans/modules/java/project/layer.xml,v  <--  layer.xml
new revision: 1.26; previous revision: 1.25
 <--  AnnotationType.template
new revision: 1.5; previous revision: 1.4
 <--  Applet.template
new revision: 1.2; previous revision: 1.1
 <--  Class.template
new revision: 1.2; previous revision: 1.1
 <--  Enum.template
new revision: 1.5; previous revision: 1.4
 <--  Exception.template
new revision: 1.2; previous revision: 1.1
 <--  Interface.template
new revision: 1.2; previous revision: 1.1
 <--  JApplet.template
new revision: 1.2; previous revision: 1.1
 <--  Main.template
new revision: 1.2; previous revision: 1.1
 <--  package-info.template
new revision: 1.2; previous revision: 1.1
/cvs/java/source/apichanges.xml,v  <--  apichanges.xml
new revision: 1.5; previous revision: 1.4
/cvs/java/source/arch.xml,v  <--  arch.xml
new revision: 1.5; previous revision: 1.4
/cvs/java/source/nbproject/,v  <--
new revision: 1.13; previous revision: 1.12
/cvs/java/source/src/org/netbeans/modules/java/,v  <--
new revision: 1.4; previous revision: 1.3
initial revision: 1.1
 <--  org.openide.loaders.CreateFromTemplateAttributesProvider
initial revision: 1.1
initial revision: 1.1
 <--  license-cddl.txt
initial revision: 1.1
 <--  license-default.txt
initial revision: 1.1
 <--  layer.xml
new revision: 1.75; previous revision: 1.74
 <--  org.openide.loaders.CreateFromTemplateAttributesProvider
initial revision: 1.1
initial revision: 1.1
new revision: 1.87; previous revision: 1.86
/cvs/projects/projectuiapi/apichanges.xml,v  <--  apichanges.xml
new revision: 1.30; previous revision: 1.29
/cvs/projects/projectuiapi/arch.xml,v  <--  arch.xml
new revision: 1.17; previous revision: 1.16
/cvs/projects/projectuiapi/nbproject/,v  <--
new revision: 1.31; previous revision: 1.30
Comment 17 Jesse Glick 2007-03-27 22:59:17 UTC
Just reopening temporarily as a reminder that this fix only handled j2seproject.
Please file issues for other project types and then reclose.
Comment 18 Tomas Zezula 2007-03-28 08:50:21 UTC
Agree with Jesse. I found the same problems on JPanel template. I've fixed the
IndentEntry to use encoding, probably fixes Jesse's problems. But for JPanel
having the guarded section it doesn't help since form editor overrides the
readFromStreamToKit and uses GuardedSectionsProvider.createGuardedReader which
takes InputStream and returns a Reader, it should be changed to Reader -> Reader.
Comment 19 Jan Pokorsky 2007-03-28 11:17:29 UTC
And what do you agree with? Jesse wants me to file issues for other project
types. They should provide project.license content in their lookup. JPanel
template (from module) has not been migrated to scripting so it cannot relate to
this issue. It does not use FreeMarker at all.
Comment 20 Jan Pokorsky 2007-03-28 12:50:58 UTC
I filed issues for project types in apisupport/project, j2ee, mobility,
web/project and made them dependent on this issue. If you know about others feel
free to add them.
Comment 21 Quality Engineering 2011-08-16 13:54:49 UTC
Integrated into 'main-golden'
User: Jesse Glick <>
Log: Removing noisy comment blurb from form templates which was long ago (#95399) removed from other Java templates.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo