# HG changeset patch # User Milos Kleint # Date 1226484728 -3600 # Node ID 690fffa4fb6ee823c5549d0d0d252f6ab96dc5cd # Parent 6b1b3d4b9708b04a651792f6826ccd391e35ea3a #153015 add annotation to register NodeFactory instances diff -r 6b1b3d4b9708 -r 690fffa4fb6e projectuiapi/apichanges.xml --- a/projectuiapi/apichanges.xml Wed Nov 12 08:23:00 2008 +0100 +++ b/projectuiapi/apichanges.xml Wed Nov 12 11:12:08 2008 +0100 @@ -104,6 +104,21 @@ + + + Add annotation @NodeFactory.Registration + + + + + +

+ Add annotation @NodeFactory.Registration to replace registration in layer files. +

+
+ + +
diff -r 6b1b3d4b9708 -r 690fffa4fb6e projectuiapi/nbproject/project.properties --- a/projectuiapi/nbproject/project.properties Wed Nov 12 08:23:00 2008 +0100 +++ b/projectuiapi/nbproject/project.properties Wed Nov 12 11:12:08 2008 +0100 @@ -39,8 +39,9 @@ javac.compilerargs=-Xlint -Xlint:-serial javac.source=1.5 -spec.version.base=1.32.0 +spec.version.base=1.33.0 is.autoload=true javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml +cp.extra=${nb_all}/apisupport.harness/external/openjdk-javac-6-b12.jar diff -r 6b1b3d4b9708 -r 690fffa4fb6e projectuiapi/src/org/netbeans/modules/project/uiapi/NodeFactoryAnnotationProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/projectuiapi/src/org/netbeans/modules/project/uiapi/NodeFactoryAnnotationProcessor.java Wed Nov 12 11:12:08 2008 +0100 @@ -0,0 +1,79 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, 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-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.project.uiapi; + +import java.util.Set; +import javax.annotation.processing.Processor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import org.netbeans.spi.project.ui.support.NodeFactory; +import org.openide.filesystems.annotations.LayerGeneratingProcessor; +import org.openide.filesystems.annotations.LayerGenerationException; +import org.openide.util.lookup.ServiceProvider; + +/** + * processor for NodeFactory.Registration annotation. + * @author mkleint + */ +@ServiceProvider(service=Processor.class) +@SupportedSourceVersion(SourceVersion.RELEASE_6) +@SupportedAnnotationTypes("org.netbeans.spi.project.ui.support.NodeFactory.Registration") +public class NodeFactoryAnnotationProcessor extends LayerGeneratingProcessor { + + @Override + protected boolean handleProcess(Set annotations, RoundEnvironment roundEnv) throws LayerGenerationException { + if (roundEnv.processingOver()) { + return false; + } + for (Element e : roundEnv.getElementsAnnotatedWith(NodeFactory.Registration.class)) { + NodeFactory.Registration lpr = e.getAnnotation(NodeFactory.Registration.class); + for (String type : lpr.projectType()) { + layer(e).instanceFile("Projects/" + type + "/Nodes", null, NodeFactory.class). + intvalue("position", lpr.position()).write(); + } + } + return true; + } + +} diff -r 6b1b3d4b9708 -r 690fffa4fb6e projectuiapi/src/org/netbeans/spi/project/ui/support/NodeFactory.java --- a/projectuiapi/src/org/netbeans/spi/project/ui/support/NodeFactory.java Wed Nov 12 08:23:00 2008 +0100 +++ b/projectuiapi/src/org/netbeans/spi/project/ui/support/NodeFactory.java Wed Nov 12 11:12:08 2008 +0100 @@ -72,5 +72,19 @@ NodeList createNodes(Project p); // Node findPath(Project p, Node root, Object target); + /** + * annotation to register NodeFactory instances. + * @since org.netbeans.modules.projectuiapi 1.33 + */ + public @interface Registration { + /** + * token(s) denoting one or more project types, eg. org-netbeans-modules-maven or org-netbeans-modules-java-j2seproject + * @return + */ + String[] projectType(); + + int position() default Integer.MAX_VALUE; +; + } }