JaroslavTulach commented on a change in pull request #3262: URL: https://github.com/apache/netbeans/pull/3262#discussion_r742583135
########## File path: ide/projectui/test/unit/src/org/netbeans/modules/project/ui/test-layer.xml ########## @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd"> +<filesystem> + <folder name="Templates"> + <folder name="Test"> + <folder name="FolderTemplate"> + <folder name="${packagePath!"foo-bar"}"> + <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/> + <file name='${mainClassName!"App"}.java' url="nbres:/org/netbeans/modules/project/ui/AppTemplate.java.template"> Review comment: It is not that bad! ########## File path: platform/openide.filesystems/src/org/openide/filesystems/FileUtil.java ########## @@ -937,6 +938,23 @@ public static FileObject toFileObject(File file) { */ public static void copyAttributes(FileObject source, FileObject dest) throws IOException { + copyAttributes(source, dest, null); + } + + /** Copies attributes from one file to another. + * Note: several special attributes will not be copied, as they should + * semantically be transient. These include attributes used by the Review comment: I suggest to define field or function to let people access: ```java public static final BiFunction<String, Object, Object> DEFAULT_ATTR_TRANSFORMER; ``` then they can either: * use it as the 3rd parameter to get behavior of the two args method * delegate to it from own transformer as a last resort * skip it by not delegating from own transformer I never really liked the hard-coded list of attributes, but they are useful. Exposing them as `BiFunction` keeps the concept of important attributes on, but puts the full control into the hands of `attrTransformer` writer. ########## File path: platform/api.templates/src/org/netbeans/api/templates/CreateFromTemplateHandler.java ########## @@ -59,4 +63,169 @@ CreateDescriptor desc ) throws IOException; + /** + * Replaces ${param} tokens in a String. The parameter reference has syntax "${" paramName [":" defaultValue ] "}". + * Parameters are replaced recursively. "${" can be escaped by \, so "\${" will not act as parameter reference start. + * @param expression string template + * @param parameters parameter values + * @return evaluated string. + */ + static String mapParameters(String expression, Map<String, ?> parameters) { Review comment: I was hoping this _in-house mapping_ can now be removed when we can use the Freemarker based one (with `'...'`) easily. But I can live with both variants. Up to you. ########## File path: ide/projectui/test/unit/src/org/netbeans/modules/project/ui/test-layer.xml ########## @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd"> +<filesystem> + <folder name="Templates"> + <folder name="Test"> + <folder name="FolderTemplate"> + <folder name="${packagePath!"foo-bar"}"> Review comment: Ugly. The variant with `'.."..."..'` is nicer. ########## File path: java/maven/src/org/netbeans/modules/maven/layer.xml ########## @@ -35,7 +35,7 @@ <attr name="position" intvalue="100"/> <!-- Simple Java project structure --> - <folder name="JavaApplication2"> + <folder name="JavaApp"> Review comment: OK. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
