diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/LibrariesNodeFactory.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/LibrariesNodeFactory.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/LibrariesNodeFactory.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/LibrariesNodeFactory.java @@ -61,6 +61,7 @@ import org.netbeans.spi.project.support.ant.ReferenceHelper; import org.netbeans.spi.project.ui.support.NodeFactory; import org.netbeans.spi.project.ui.support.NodeList; +import org.netbeans.spi.project.ui.support.RegisteredNodeFactory; import org.openide.nodes.Node; import org.openide.util.ChangeSupport; import org.openide.util.NbBundle; @@ -69,6 +70,7 @@ * * @author mkleint */ +@RegisteredNodeFactory(projectType="org-netbeans-modules-java-j2seproject", position=300) public final class LibrariesNodeFactory implements NodeFactory { /** Creates a new instance of LibrariesNodeFactory */ diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/SourceNodeFactory.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/SourceNodeFactory.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/SourceNodeFactory.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/SourceNodeFactory.java @@ -60,6 +60,7 @@ import org.netbeans.spi.java.project.support.ui.PackageView; import org.netbeans.spi.project.ui.support.NodeFactory; import org.netbeans.spi.project.ui.support.NodeList; +import org.netbeans.spi.project.ui.support.RegisteredNodeFactory; import org.openide.filesystems.FileObject; import org.openide.nodes.FilterNode; import org.openide.nodes.Node; @@ -70,6 +71,7 @@ * * @author mkleint */ +@RegisteredNodeFactory(projectType="org-netbeans-modules-java-j2seproject", position=200) public final class SourceNodeFactory implements NodeFactory { public SourceNodeFactory() { } diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SECompositePanelProvider.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SECompositePanelProvider.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SECompositePanelProvider.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SECompositePanelProvider.java @@ -148,30 +148,37 @@ } + @ProjectCustomizer.RegisteredCategory(projectType="org-netbeans-modules-java-j2seproject", position=100, id="Sources") public static J2SECompositePanelProvider createSources() { return new J2SECompositePanelProvider(SOURCES); } + @ProjectCustomizer.RegisteredCategory(projectType="org-netbeans-modules-java-j2seproject", position=200, id="Libraries") public static J2SECompositePanelProvider createLibraries() { return new J2SECompositePanelProvider(LIBRARIES); } + @ProjectCustomizer.RegisteredCategory(projectType="org-netbeans-modules-java-j2seproject", position=100, id="BuildCategory/Build") public static J2SECompositePanelProvider createBuild() { return new J2SECompositePanelProvider(BUILD); } + @ProjectCustomizer.RegisteredCategory(projectType="org-netbeans-modules-java-j2seproject", position=200, id="BuildCategory/Jar") public static J2SECompositePanelProvider createJar() { return new J2SECompositePanelProvider(JAR); } + @ProjectCustomizer.RegisteredCategory(projectType="org-netbeans-modules-java-j2seproject", position=300, id="BuildCategory/Javadoc") public static J2SECompositePanelProvider createJavadoc() { return new J2SECompositePanelProvider(JAVADOC); } + @ProjectCustomizer.RegisteredCategory(projectType="org-netbeans-modules-java-j2seproject", position=400, id="Run") public static J2SECompositePanelProvider createRun() { return new J2SECompositePanelProvider(RUN); } + @ProjectCustomizer.RegisteredCategory(projectType="org-netbeans-modules-java-j2seproject", position=0, id="Application/Self") public static J2SECompositePanelProvider createApplication() { return new J2SECompositePanelProvider(APPLICATION); } diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/resources/layer.xml b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/resources/layer.xml --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/resources/layer.xml +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/resources/layer.xml @@ -94,50 +94,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/projectuiapi/nbproject/project.properties b/projectuiapi/nbproject/project.properties --- a/projectuiapi/nbproject/project.properties +++ b/projectuiapi/nbproject/project.properties @@ -43,4 +43,4 @@ is.autoload=true javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml - +cp.extra=${nb_all}/libs.javacapi/external/javac-api-nb-7.0-b07.jar diff --git a/projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectCustomizerCategoryProcessor.java b/projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectCustomizerCategoryProcessor.java new file mode 100644 --- /dev/null +++ b/projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectCustomizerCategoryProcessor.java @@ -0,0 +1,80 @@ +/* + * 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 javax.tools.Diagnostic.Kind; +import org.netbeans.spi.project.ui.support.ProjectCustomizer.CompositeCategoryProvider; +import org.netbeans.spi.project.ui.support.ProjectCustomizer.RegisteredCategory; +import org.openide.filesystems.annotations.LayerBuilder; +import org.openide.filesystems.annotations.LayerGeneratingProcessor; +import org.openide.util.lookup.Service; + +@Service(Processor.class) +@SupportedSourceVersion(SourceVersion.RELEASE_6) +@SupportedAnnotationTypes("org.netbeans.spi.project.ui.support.ProjectCustomizer.RegisteredCategory") +public class ProjectCustomizerCategoryProcessor extends LayerGeneratingProcessor { + + @Override + protected boolean doProcess(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + return false; + } + for (Element e : roundEnv.getElementsAnnotatedWith(RegisteredCategory.class)) { + RegisteredCategory rc = e.getAnnotation(RegisteredCategory.class); + try { + new LayerBuilder(layer(e)).instanceFile(e, "Projects/" + rc.projectType() + "/Customizer", rc.id(), + CompositeCategoryProvider.class, processingEnv).position(rc.position()).write(); + } catch (IllegalArgumentException x) { + processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage()); + continue; + } + } + return true; + } + +} diff --git a/projectuiapi/src/org/netbeans/modules/project/uiapi/RegisteredNodeFactoryProcessor.java b/projectuiapi/src/org/netbeans/modules/project/uiapi/RegisteredNodeFactoryProcessor.java new file mode 100644 --- /dev/null +++ b/projectuiapi/src/org/netbeans/modules/project/uiapi/RegisteredNodeFactoryProcessor.java @@ -0,0 +1,80 @@ +/* + * 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 javax.tools.Diagnostic.Kind; +import org.netbeans.spi.project.ui.support.NodeFactory; +import org.netbeans.spi.project.ui.support.RegisteredNodeFactory; +import org.openide.filesystems.annotations.LayerBuilder; +import org.openide.filesystems.annotations.LayerGeneratingProcessor; +import org.openide.util.lookup.Service; + +@Service(Processor.class) +@SupportedSourceVersion(SourceVersion.RELEASE_6) +@SupportedAnnotationTypes("org.netbeans.spi.project.ui.support.RegisteredNodeFactory") +public class RegisteredNodeFactoryProcessor extends LayerGeneratingProcessor { + + @Override + protected boolean doProcess(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + return false; + } + for (Element e : roundEnv.getElementsAnnotatedWith(RegisteredNodeFactory.class)) { + RegisteredNodeFactory rnf = e.getAnnotation(RegisteredNodeFactory.class); + try { + new LayerBuilder(layer(e)).instanceFile(e, "Projects/" + rnf.projectType() + "/Nodes", null, NodeFactory.class, processingEnv). + position(rnf.position()).write(); + } catch (IllegalArgumentException x) { + processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage()); + continue; + } + } + return true; + } + +} diff --git a/projectuiapi/src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java b/projectuiapi/src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java --- a/projectuiapi/src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java +++ b/projectuiapi/src/org/netbeans/spi/project/ui/support/ProjectCustomizer.java @@ -322,6 +322,12 @@ */ JComponent createComponent (Category category, Lookup context ); } + + public @interface RegisteredCategory { + String projectType(); + String id(); + int position() default Integer.MAX_VALUE; + } /** Describes category of properties to be customized by given component */ diff --git a/projectuiapi/src/org/netbeans/spi/project/ui/support/RegisteredNodeFactory.java b/projectuiapi/src/org/netbeans/spi/project/ui/support/RegisteredNodeFactory.java new file mode 100644 --- /dev/null +++ b/projectuiapi/src/org/netbeans/spi/project/ui/support/RegisteredNodeFactory.java @@ -0,0 +1,57 @@ +/* + * 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.spi.project.ui.support; + +/** + * Annotation to register a {@link NodeFactory} among a project type's nodes. + */ +public @interface RegisteredNodeFactory { + + /** + * Project type identifier, e.g. {@code "org-netbeans-modules-java-j2seproject"} + */ + String projectType(); + + /** + * Optional position to order this factory. + */ + int position() default Integer.MAX_VALUE; + +}