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.
Summary: | After switching to FreeMarker default package name is no longer replaced by one from wizard | ||
---|---|---|---|
Product: | java | Reporter: | Martin Adamek <madamek> |
Component: | Unsupported | Assignee: | Jan Pokorsky <jpokorsky> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | apireviews, dkaspar, issues, jtulach, pjiricka, tzezula |
Priority: | P2 | Keywords: | API_REVIEW_FAST |
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 97974, 98011, 98874 | ||
Bug Blocks: | 92595, 99232, 99233, 99234, 99235, 105744 | ||
Attachments: |
Proposed Class template
prototype |
Description
Martin Adamek
2007-02-13 13:43:11 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 http://www.netbeans.org/download/dev/javadoc/org-openide-loaders/org/openide/loaders/CreateFromTemplateAttributesProvider.html that would add the Java related properties - package, classname, etc. 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 Map<String/*name*/,String/*html_description*/>CreateFromTemplateAttributesProvider.availableAttributes(FileObject), syntax highlighting, ... JP4: Is there any naming convention for template attributes like ${package}|${java.package}|${org.netbeans.modules.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. JP1 - ok. JP2 - I have prototyped http://www.netbeans.org/nonav/issues/showattachment.cgi/37844/X.diff but it needs few changes. A few ideas would include - we might write an CreateFromTemplateAttributesProvider that would make all properties in nbproject/project.properties available to the scripting engine. Then the users could specify license=GPL in their project.properties 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. JP2 - I like the idea of licence from project.properties 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 {//GEN-END:head</#if> } ${nlbeforebrace} would represent JavaIndentEngine option. Not nice but it is a way for them now. Later we can tweak the java indent engine. Created attachment 39061 [details]
Proposed Class template
JP2 - I think the licence.txt template should be placed in openide/loaders. It is a kind of default like name, date, time, ... DK1 - dkaspar proposes not to include the constructor in Class template. I agree. Any objections? 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 removed. 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. JP2 - what is appropriate then? ide/defaults, core/ide, ...? I would have to declare a dependency on such a module, right? 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 project.properties 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. Follows the java templates prototype. * I chose org-netbeans-modules-projectui.jar to place license templates as Licenses/license-[default|cddl|...].txt. * 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. Created attachment 39569 [details]
prototype
There are no objections so I am going to integrate it. Thanks for review. 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. 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 /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java,v <-- J2SEProject.java new revision: 1.80; previous revision: 1.79 /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SETemplateAttributesProvider.java,v <-- J2SETemplateAttributesProvider.java initial revision: 1.1 /cvs/java/project/manifest.mf,v <-- manifest.mf 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 /cvs/java/project/src/org/netbeans/modules/java/project/resources/AnnotationType.template,v <-- AnnotationType.template new revision: 1.5; previous revision: 1.4 /cvs/java/project/src/org/netbeans/modules/java/project/resources/Applet.template,v <-- Applet.template new revision: 1.2; previous revision: 1.1 /cvs/java/project/src/org/netbeans/modules/java/project/resources/Class.template,v <-- Class.template new revision: 1.2; previous revision: 1.1 /cvs/java/project/src/org/netbeans/modules/java/project/resources/Enum.template,v <-- Enum.template new revision: 1.5; previous revision: 1.4 /cvs/java/project/src/org/netbeans/modules/java/project/resources/Exception.template,v <-- Exception.template new revision: 1.2; previous revision: 1.1 /cvs/java/project/src/org/netbeans/modules/java/project/resources/Interface.template,v <-- Interface.template new revision: 1.2; previous revision: 1.1 /cvs/java/project/src/org/netbeans/modules/java/project/resources/JApplet.template,v <-- JApplet.template new revision: 1.2; previous revision: 1.1 /cvs/java/project/src/org/netbeans/modules/java/project/resources/Main.template,v <-- Main.template new revision: 1.2; previous revision: 1.1 /cvs/java/project/src/org/netbeans/modules/java/project/resources/package-info.template,v <-- 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/project.properties,v <-- project.properties new revision: 1.13; previous revision: 1.12 /cvs/java/source/src/org/netbeans/modules/java/JavaDataLoader.java,v <-- JavaDataLoader.java new revision: 1.4; previous revision: 1.3 /cvs/java/source/src/org/netbeans/modules/java/JavaTemplateAttributesProvider.java,v <-- JavaTemplateAttributesProvider.java initial revision: 1.1 /cvs/java/source/src/META-INF/services/org.openide.loaders.CreateFromTemplateAttributesProvider,v <-- org.openide.loaders.CreateFromTemplateAttributesProvider initial revision: 1.1 /cvs/java/source/test/unit/src/org/netbeans/modules/java/JavaTemplateAttributesProviderTest.java,v <-- JavaTemplateAttributesProviderTest.java initial revision: 1.1 /cvs/projects/projectui/src/org/netbeans/modules/project/ui/resources/license-cddl.txt,v <-- license-cddl.txt initial revision: 1.1 /cvs/projects/projectui/src/org/netbeans/modules/project/ui/resources/license-default.txt,v <-- license-default.txt initial revision: 1.1 /cvs/projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml,v <-- layer.xml new revision: 1.75; previous revision: 1.74 /cvs/projects/projectuiapi/src/META-INF/services/org.openide.loaders.CreateFromTemplateAttributesProvider,v <-- org.openide.loaders.CreateFromTemplateAttributesProvider initial revision: 1.1 /cvs/projects/projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectTemplateAttributesProvider.java,v <-- ProjectTemplateAttributesProvider.java initial revision: 1.1 /cvs/projects/projectui/src/org/netbeans/modules/project/ui/Bundle.properties,v <-- Bundle.properties 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/project.properties,v <-- project.properties new revision: 1.31; previous revision: 1.30 Just reopening temporarily as a reminder that this fix only handled j2seproject. Please file issues for other project types and then reclose. 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. 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. 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. Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/ce2877ccc1d4 User: Jesse Glick <jglick@netbeans.org> Log: Removing noisy comment blurb from form templates which was long ago (#95399) removed from other Java templates. |