# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/honza/development/netbeans/retouche_main_trunk # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: java/project/manifest.mf *** /home/honza/development/netbeans/retouche_main_trunk/java/project/manifest.mf Base (1.22) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/manifest.mf Locally Modified (Based On 1.22) *************** *** 2,7 **** --- 2,7 ---- OpenIDE-Module: org.netbeans.modules.java.project/1 OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties + OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker OpenIDE-Module-Specification-Version: 1.12 Index: java/source/src/META-INF/services/org.openide.loaders.CreateFromTemplateAttributesProvider *** /home/honza/development/netbeans/retouche_main_trunk/java/source/src/META-INF/services/org.openide.loaders.CreateFromTemplateAttributesProvider No Base Revision --- /home/honza/development/netbeans/retouche_main_trunk/java/source/src/META-INF/services/org.openide.loaders.CreateFromTemplateAttributesProvider Locally New *************** *** 1,0 **** --- 1,1 ---- + org.netbeans.modules.java.JavaTemplateAttributesProvider Index: java/project/src/org/netbeans/modules/java/project/resources/Class.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Class.template Base (1.1) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Class.template Locally Modified (Based On 1.1) *************** *** 1,22 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; /** * ! * @author __USER__ */ ! public class Class { ! /** Creates a new instance of __NAME__ */ ! public Class() { } } --- 1,19 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; + /** * ! * @author ${user} */ ! public class ${name} { ! public ${name}() { } } Index: java/project/src/org/netbeans/modules/java/project/resources/package-info.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/package-info.template Base (1.1) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/package-info.template Locally Modified (Based On 1.1) *************** *** 1,14 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; --- 1,13 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; ! ! Index: projects/projectui/src/org/netbeans/modules/project/ui/resources/license-default.txt *** /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/resources/license-default.txt No Base Revision --- /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/resources/license-default.txt Locally New *************** *** 1,0 **** --- 1,8 ---- + ${licenseFirst} + ${licensePrefix}${name}.java + ${licensePrefix} + ${licensePrefix}Created on ${date}, ${time} + ${licensePrefix} + ${licensePrefix}To change this template, choose Tools | Template Manager + ${licensePrefix}and open the template in the editor. + ${licenseLast} Index: java/source/test/unit/src/org/netbeans/modules/java/JavaTemplateAttributesProviderTest.java *** /home/honza/development/netbeans/retouche_main_trunk/java/source/test/unit/src/org/netbeans/modules/java/JavaTemplateAttributesProviderTest.java No Base Revision --- /home/honza/development/netbeans/retouche_main_trunk/java/source/test/unit/src/org/netbeans/modules/java/JavaTemplateAttributesProviderTest.java Locally New *************** *** 1,0 **** --- 1,102 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.java; + + import java.io.File; + import java.util.HashMap; + import java.util.Map; + import org.netbeans.api.java.classpath.ClassPath; + import org.netbeans.junit.MockServices; + import org.netbeans.junit.NbTestCase; + import org.netbeans.spi.java.classpath.ClassPathProvider; + import org.netbeans.spi.java.classpath.support.ClassPathSupport; + import org.openide.filesystems.FileObject; + import org.openide.filesystems.FileUtil; + import org.openide.loaders.DataFolder; + import org.openide.loaders.DataObject; + + /** + * + * @author Jan Pokorsky + */ + public class JavaTemplateAttributesProviderTest extends NbTestCase { + + public JavaTemplateAttributesProviderTest(String testName) { + super(testName); + } + + protected void setUp() throws Exception { + super.setUp(); + CPP.clear(); + MockServices.setServices(JavaDataLoader.class, CPP.class, JavaTemplateAttributesProvider.class); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testAttributesFor() throws Exception { + this.clearWorkDir(); + File wd = this.getWorkDir(); + FileObject froot = FileUtil.toFileObject(wd); + + FileObject ftarget = FileUtil.createFolder(froot, "pkg"); + CPP.register(ftarget, ClassPath.SOURCE, ClassPathSupport.createClassPath(new FileObject[] {froot})); + FileObject ftemplate = FileUtil.createData(ftarget, "EmptyClass.java"); + ftemplate.setAttribute("javax.script.ScriptEngine", "freemarker"); + + + DataObject template = DataObject.find(ftemplate); + DataFolder target = DataFolder.findFolder(ftarget); + String name = "TargetClass"; + JavaTemplateAttributesProvider instance = new JavaTemplateAttributesProvider(); + Map result = instance.attributesFor(template, target, name); + + assertEquals("pkg", result.get("package")); + } + + public static class CPP implements ClassPathProvider { + + private static final Map> data = new HashMap>(); + + static void clear () { + data.clear(); + } + + static void register (FileObject fo, String type, ClassPath cp) { + Map m = data.get (fo); + if (m == null) { + m = new HashMap(); + data.put (fo,m); + } + m.put (type,cp); + } + + public ClassPath findClassPath(FileObject file, String type) { + + Map m = data.get (file); + if (m == null) { + return null; + } + return m.get (type); + } + } + + } Index: java/project/src/org/netbeans/modules/java/project/layer.xml *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/layer.xml Base (1.25) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/layer.xml Locally Modified (Based On 1.25) *************** *** 14,20 **** "Portions Copyrighted [year] [name of copyright owner]" The Original Software is NetBeans. The Initial Developer of the Original ! Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. --> --- 14,20 ---- "Portions Copyrighted [year] [name of copyright owner]" The Original Software is NetBeans. The Initial Developer of the Original ! Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. --> *************** *** 61,66 **** --- 61,67 ---- + *************** *** 69,74 **** --- 70,76 ---- + *************** *** 77,82 **** --- 79,85 ---- + *************** *** 85,90 **** --- 88,94 ---- + *************** *** 93,98 **** --- 97,103 ---- + *************** *** 101,106 **** --- 106,112 ---- + *************** *** 109,114 **** --- 115,121 ---- + *************** *** 123,128 **** --- 130,136 ---- + *************** *** 131,136 **** --- 139,145 ---- + *************** *** 140,145 **** --- 149,155 ---- + Index: java/project/nbproject/project.xml *** /home/honza/development/netbeans/retouche_main_trunk/java/project/nbproject/project.xml Base (1.35) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/nbproject/project.xml Locally Modified (Based On 1.35) *************** *** 14,20 **** "Portions Copyrighted [year] [name of copyright owner]" The Original Software is NetBeans. The Initial Developer of the Original ! Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. --> --- 14,20 ---- "Portions Copyrighted [year] [name of copyright owner]" The Original Software is NetBeans. The Initial Developer of the Original ! Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. --> *************** *** 110,115 **** --- 110,121 ---- + org.netbeans.modules.templates + + 1.0 + + + org.openide.actions Index: java/project/src/org/netbeans/modules/java/project/resources/JApplet.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/JApplet.template Base (1.1) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/JApplet.template Locally Modified (Based On 1.1) *************** *** 1,26 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; /** * ! * @author __USER__ */ ! public class JApplet extends javax.swing.JApplet { ! /** Creates a new instance of __NAME__ */ ! public JApplet() { } } --- 1,36 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; + + import javax.swing.JApplet; + /** * ! * @author ${user} */ ! public class ${name} extends JApplet { ! /** Creates a new instance of ${name} */ ! public ${name}() { } + /** + * Initialization method that will be called after the applet is loaded + * into the browser. + */ + public void init() { + // TODO start asynchronous download of heavy resources } + + // TODO overwrite start(), stop() and destroy() methods + + } Index: projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml *** /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml Base (1.73) --- /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml Locally Modified (Based On 1.73) *************** *** 224,230 **** --- 224,243 ---- + + + + + + + + + + + + + Index: projects/projectui/src/org/netbeans/modules/project/ui/ProjectTemplateAttributesProvider.java *** /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/ProjectTemplateAttributesProvider.java No Base Revision --- /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/ProjectTemplateAttributesProvider.java Locally New *************** *** 1,0 **** --- 1,86 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.project.ui; + + import java.lang.reflect.InvocationTargetException; + import java.lang.reflect.Method; + import java.util.Map; + import org.netbeans.api.project.FileOwnerQuery; + import org.netbeans.api.project.Project; + import org.openide.loaders.CreateFromTemplateAttributesProvider; + import org.openide.loaders.DataFolder; + import org.openide.loaders.DataObject; + import org.openide.util.Exceptions; + + /** + * Provides attributes that can be used inside scripting templates. It delegates + * attributes query to providers registered in project lookups. + * + * @author Jan Pokorsky + */ + public final class ProjectTemplateAttributesProvider extends CreateFromTemplateAttributesProvider { + + + protected Map attributesFor( + DataObject template, DataFolder target, String name) { + + Project prj = FileOwnerQuery.getOwner(target.getPrimaryFile()); + if (prj != null) { + CreateFromTemplateAttributesProvider attrs = prj.getLookup().lookup(CreateFromTemplateAttributesProvider.class); + if (attrs != null) { + return delegateAttributesFor(attrs, template, target, name); + } + } + + return null; + } + + /** + * workaround permitting delegation to CreateFromTemplateAttributesProvider.attributesFor + * @see issue #97974 + */ + private static Map delegateAttributesFor( + CreateFromTemplateAttributesProvider attrs, + DataObject template, + DataFolder target, + String name) { + + try { + Method m = attrs.getClass().getDeclaredMethod( + "attributesFor", + DataObject.class, + DataFolder.class, + String.class); + m.setAccessible(true); + return (Map) m.invoke(attrs, template, target, name); + } catch (IllegalAccessException ex) { + Exceptions.printStackTrace(ex); + } catch (IllegalArgumentException ex) { + Exceptions.printStackTrace(ex); + } catch (InvocationTargetException ex) { + Exceptions.printStackTrace(ex); + } catch (NoSuchMethodException ex) { + Exceptions.printStackTrace(ex); + } catch (SecurityException ex) { + Exceptions.printStackTrace(ex); + } + return null; + } + } Index: projects/projectui/src/org/netbeans/modules/project/ui/resources/license-cddl.txt *** /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/resources/license-cddl.txt No Base Revision --- /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/resources/license-cddl.txt Locally New *************** *** 1,0 **** --- 1,17 ---- + ${licenseFirst} + ${licensePrefix}The contents of this file are subject to the terms of the Common Development + ${licensePrefix}and Distribution License (the License). You may not use this file except in + ${licensePrefix}compliance with the License. + ${licensePrefix} + ${licensePrefix}You can obtain a copy of the License at http://www.netbeans.org/cddl.html + ${licensePrefix}or http://www.netbeans.org/cddl.txt. + ${licensePrefix} + ${licensePrefix}When distributing Covered Code, include this CDDL Header Notice in each file + ${licensePrefix}and include the License file at http://www.netbeans.org/cddl.txt. + ${licensePrefix}If applicable, add the following below the CDDL Header, with the fields + ${licensePrefix}enclosed by brackets [] replaced by your own identifying information: + ${licensePrefix}"Portions Copyrighted [year] [name of copyright owner]" + ${licensePrefix} + ${licensePrefix}To change this template, choose Tools | Template Manager + ${licensePrefix}and open the template in the editor. + ${licenseLast} Index: java/project/src/org/netbeans/modules/java/project/resources/Enum.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Enum.template Base (1.4) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Enum.template Locally Modified (Based On 1.4) *************** *** 1,22 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; /** * ! * @author __USER__ */ ! public enum Enum { } --- 1,20 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; + /** * ! * @author ${user} */ ! public enum ${name} { } Index: java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SETemplateAttributesProvider.java *** /home/honza/development/netbeans/retouche_main_trunk/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SETemplateAttributesProvider.java No Base Revision --- /home/honza/development/netbeans/retouche_main_trunk/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SETemplateAttributesProvider.java Locally New *************** *** 1,0 **** --- 1,72 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.java.j2seproject; + + import java.util.Collections; + import java.util.Map; + import org.netbeans.spi.project.support.ant.AntProjectHelper; + import org.netbeans.spi.project.support.ant.EditableProperties; + import org.openide.loaders.CreateFromTemplateAttributesProvider; + import org.openide.loaders.DataFolder; + import org.openide.loaders.DataObject; + + /** + * Provides attributes that can be used inside scripting templates. + *
project.license
+ *
attribute containing license name. + * The provider reads project.license property from build.properties + * and returns it as the template attribute. In case the property is not available + * the attribute is filled with "default" value.
+ *
+ * + * @author Jan Pokorsky + */ + public final class J2SETemplateAttributesProvider extends CreateFromTemplateAttributesProvider { + + private final AntProjectHelper helper; + + public J2SETemplateAttributesProvider(AntProjectHelper helper) { + this.helper = helper; + } + + protected Map attributesFor( + DataObject template, DataFolder target, String name) { + + EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); + String license = props.getProperty("project.license"); // NOI18N + + return findEntry(license); + } + + private static Map findEntry(String license) { + if (license == null) { + license = "default"; // NOI18N + } else { + license = license.trim().toLowerCase(); + } + + // a cache might be introduced if needed here + Map entry = Collections.singletonMap( + "project", // NOI18N + Collections.singletonMap("license", license)); // NOI18N + + return entry; + } + } Index: projects/projectui/src/META-INF/services/org.openide.loaders.CreateFromTemplateAttributesProvider *** /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/META-INF/services/org.openide.loaders.CreateFromTemplateAttributesProvider No Base Revision --- /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/META-INF/services/org.openide.loaders.CreateFromTemplateAttributesProvider Locally New *************** *** 1,0 **** --- 1,1 ---- + org.netbeans.modules.project.ui.ProjectTemplateAttributesProvider Index: java/project/src/org/netbeans/modules/java/project/resources/Exception.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Exception.template Base (1.1) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Exception.template Locally Modified (Based On 1.1) *************** *** 1,32 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; /** * ! * @author __USER__ */ ! public class Exception extends java.lang.Exception { /** ! * Creates a new instance of __NAME__ without detail message. */ ! public Exception() { } /** ! * Constructs an instance of __NAME__ with the specified detail message. * @param msg the detail message. */ ! public Exception(String msg) { super(msg); } } --- 1,30 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; + /** * ! * @author ${user} */ ! public class ${name} extends Exception { /** ! * Creates a new instance of ${name} without detail message. */ ! public ${name}() { } /** ! * Constructs an instance of ${name} with the specified detail message. * @param msg the detail message. */ ! public ${name}(String msg) { super(msg); } } Index: java/project/src/org/netbeans/modules/java/project/resources/AnnotationType.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/AnnotationType.template Base (1.4) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/AnnotationType.template Locally Modified (Based On 1.4) *************** *** 1,22 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; /** * ! * @author __USER__ */ ! public @interface AnnotationType { } --- 1,20 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; + /** * ! * @author ${user} */ ! public @interface ${name} { } Index: java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java *** /home/honza/development/netbeans/retouche_main_trunk/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java Base (1.77) --- /home/honza/development/netbeans/retouche_main_trunk/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java Locally Modified (Based On 1.77) *************** *** 256,261 **** --- 256,262 ---- UILookupMergerSupport.createRecommendedTemplatesMerger(), LookupProviderSupport.createSourcesMerger(), new J2SEPropertyEvaluatorImpl(evaluator()), + new J2SETemplateAttributesProvider(this.helper), new BinaryForSourceQueryImpl(this.sourceRoots, this.testRoots, this.helper, this.eval) //Does not use APH to get/put properties/cfgdata }); return LookupProviderSupport.createCompositeLookup(base, "Projects/org-netbeans-modules-java-j2seproject/Lookup"); //NOI18N Index: java/source/src/org/netbeans/modules/java/JavaDataLoader.java *** /home/honza/development/netbeans/retouche_main_trunk/java/source/src/org/netbeans/modules/java/JavaDataLoader.java Base (1.3) --- /home/honza/development/netbeans/retouche_main_trunk/java/source/src/org/netbeans/modules/java/JavaDataLoader.java Locally Modified (Based On 1.3) *************** *** 13,19 **** * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original ! * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. */ --- 13,19 ---- * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original ! * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ *************** *** 24,29 **** --- 24,30 ---- import java.util.Date; import java.util.HashMap; import java.util.Map; + import java.util.logging.Logger; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.loaders.JavaDataSupport; import org.openide.ErrorManager; *************** *** 91,96 **** --- 92,102 ---- protected FileObject findPrimaryFile (FileObject fo) { // never recognize folders. if (fo.isFolder()) return null; + + // ignore templates using scripting + if (fo.getAttribute("template") != null && fo.getAttribute("javax.script.ScriptEngine") != null) // NOI18N + return null; + if (fo.getExt().equals(JAVA_EXTENSION)) return fo; return null; *************** *** 242,247 **** --- 248,257 ---- @Override public FileObject createFromTemplate(FileObject f, String name) throws IOException { + Logger.getLogger(JavaDataLoader.class.getName()).warning( + "Please replace template " + this.getFile().toString() + //NOI18N + " with the new scripting support. See " + //NOI18N + "http://www.netbeans.org/download/dev/javadoc/org-openide-loaders/apichanges.html#scripting"); //NOI18N if (name == null) { // special case: name is null (unspecified or from one-parameter createFromTemplate) name = FileUtil.findFreeFileName(f, f.getName(), "java"); // NOI18N Index: java/project/src/org/netbeans/modules/java/project/resources/Interface.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Interface.template Base (1.1) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Interface.template Locally Modified (Based On 1.1) *************** *** 1,22 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; /** * ! * @author __USER__ */ ! public interface Interface { } --- 1,20 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; + /** * ! * @author ${user} */ ! public interface ${name} { } Index: java/project/src/org/netbeans/modules/java/project/resources/Main.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Main.template Base (1.1) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Main.template Locally Modified (Based On 1.1) *************** *** 1,22 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; /** * ! * @author __USER__ */ ! public class Main { ! /** Creates a new instance of __NAME__ */ ! public Main() { } /** --- 1,19 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; + /** * ! * @author ${user} */ ! public class ${name} { ! public ${name}() { } /** Index: java/source/src/org/netbeans/modules/java/JavaTemplateAttributesProvider.java *** /home/honza/development/netbeans/retouche_main_trunk/java/source/src/org/netbeans/modules/java/JavaTemplateAttributesProvider.java No Base Revision --- /home/honza/development/netbeans/retouche_main_trunk/java/source/src/org/netbeans/modules/java/JavaTemplateAttributesProvider.java Locally New *************** *** 1,0 **** --- 1,55 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.java; + + import java.util.Collections; + import java.util.Map; + import org.netbeans.api.java.classpath.ClassPath; + import org.openide.filesystems.FileObject; + import org.openide.loaders.CreateFromTemplateAttributesProvider; + import org.openide.loaders.DataFolder; + import org.openide.loaders.DataObject; + + /** + * Provides attributes that can be used inside scripting templates. + *
package
+ *
attribute containing target folder as package.
+ * + * @author Jan Pokorsky + */ + public final class JavaTemplateAttributesProvider extends CreateFromTemplateAttributesProvider { + + protected Map attributesFor(DataObject template, + DataFolder target, + String name) { + FileObject templateFO = template.getPrimaryFile(); + if (!JavaDataLoader.JAVA_EXTENSION.equals(templateFO.getExt()) || templateFO.isFolder()) { + return null; + } + + FileObject targetFO = target.getPrimaryFile(); + ClassPath cp = ClassPath.getClassPath(targetFO, ClassPath.SOURCE); + if (cp == null) { + throw new IllegalStateException("No classpath was found for folder: " + target.getPrimaryFile()); // NOI18N + } + return Collections.singletonMap("package", cp.getResourceName(targetFO, '.', false)); // NOI18N + } + + } Index: java/project/src/org/netbeans/modules/java/project/resources/Applet.template *** /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Applet.template Base (1.1) --- /home/honza/development/netbeans/retouche_main_trunk/java/project/src/org/netbeans/modules/java/project/resources/Applet.template Locally Modified (Based On 1.1) *************** *** 1,22 **** ! /* ! * __NAME__.java ! * ! * Created on __DATE__, __TIME__ ! * ! * To change this template, choose Tools | Template Manager ! * and open the template in the editor. ! */ ! package Templates.Classes; /** * ! * @author __USER__ */ ! public class Applet extends java.applet.Applet { ! /** Initialization method that will be called after the applet is loaded ! * into the browser. */ public void init() { // TODO start asynchronous download of heavy resources --- 1,23 ---- ! <#assign licenseFirst = "/*"> ! <#assign licensePrefix = " * "> ! <#assign licenseLast = " */"> ! <#include "../Licenses/license-${project.license}.txt"> ! <#if package?? && package != ""> ! package ${package}; + + import java.applet.Applet; + /** * ! * @author ${user} */ ! public class ${name} extends Applet { ! /** ! * Initialization method that will be called after the applet is loaded ! * into the browser. */ public void init() { // TODO start asynchronous download of heavy resources Index: projects/projectui/src/org/netbeans/modules/project/ui/Bundle.properties *** /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/Bundle.properties Base (1.85) --- /home/honza/development/netbeans/retouche_main_trunk/projects/projectui/src/org/netbeans/modules/project/ui/Bundle.properties Locally Modified (Based On 1.85) *************** *** 12,18 **** # "Portions Copyrighted [year] [name of copyright owner]" # # The Original Software is NetBeans. The Initial Developer of the Original ! # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. OpenIDE-Module-Name=Project UI --- 12,18 ---- # "Portions Copyrighted [year] [name of copyright owner]" # # The Original Software is NetBeans. The Initial Developer of the Original ! # Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun # Microsystems, Inc. All Rights Reserved. OpenIDE-Module-Name=Project UI *************** *** 90,95 **** --- 90,98 ---- Templates/Project=Project Templates/Project/Import=Projects with Existing Sources Templates/Project/Samples=Samples + Templates/Project/Licenses=Licenses + Templates/Project/Licenses/license-default.txt=Default License + Templates/Project/Licenses/license-cddl.txt=CDDL Toolbars/Build=Build # PhysicalViewFactoryImpl