--- a/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 @@ -51,37 +51,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties +++ a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/Bundle.properties @@ -38,10 +38,10 @@ # made subject to such option by the copyright holder. #System file system -Templates/Project/Standard/emptyJ2SE.xml=Java Application -Templates/Project/Standard/emptyJ2SElibrary.xml=Java Class Library Templates/Project/Standard=Java -Templates/Project/Standard/existingJ2SE.xml= Java Project with Existing Sources +emptyJ2SE=Java Application +emptyJ2SElibrary=Java Class Library +existingJ2SE= Java Project with Existing Sources #New project wizard TXT_DefaultPackageName=mypkg --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/NewJ2SEProjectWizardIterator.java +++ a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/wizards/NewJ2SEProjectWizardIterator.java @@ -69,6 +69,12 @@ /** * Wizard to create a new J2SE project. */ +@WizardDescriptor.RegisteredInstantiatingIterator( + templateCategory="Project/Standard", + displayName="#emptyJ2SE", + position=100, + iconResource="org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", + descriptionResource="org/netbeans/modules/java/j2seproject/ui/resources/emptyProject.html") public class NewJ2SEProjectWizardIterator implements WizardDescriptor.ProgressInstantiatingIterator { enum WizardType {APP, LIB, EXT} @@ -90,10 +96,22 @@ this.type = type; } + @WizardDescriptor.RegisteredInstantiatingIterator( + templateCategory="Project/Standard", + displayName="#emptyJ2SElibrary", + position=200, + iconResource="org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", + descriptionResource="org/netbeans/modules/java/j2seproject/ui/resources/emptyLibrary.html") public static NewJ2SEProjectWizardIterator library() { return new NewJ2SEProjectWizardIterator(WizardType.LIB); } + @WizardDescriptor.RegisteredInstantiatingIterator( + templateCategory="Project/Standard", + displayName="#existingJ2SE", + position=300, + iconResource="org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", + descriptionResource="org/netbeans/modules/java/j2seproject/ui/resources/existingProject.html") public static NewJ2SEProjectWizardIterator existing() { return new NewJ2SEProjectWizardIterator(WizardType.EXT); } --- a/openide.dialogs/nbproject/project.properties +++ a/openide.dialogs/nbproject/project.properties @@ -43,4 +43,4 @@ #javadoc.main.page=org/openide/doc-files/api.html javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml - +cp.extra=${nb_all}/libs.javacapi/external/javac-api-nb-7.0-b07.jar --- a/openide.dialogs/nbproject/project.xml +++ a/openide.dialogs/nbproject/project.xml @@ -73,6 +73,14 @@ + org.openide.filesystems + + + + 7.13 + + + org.openide.util --- a/openide.dialogs/src/org/netbeans/modules/dialogs/InstantiatingIteratorProcessor.java +++ a/openide.dialogs/src/org/netbeans/modules/dialogs/InstantiatingIteratorProcessor.java @@ -0,0 +1,109 @@ +/* + * 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.dialogs; + +import java.net.MalformedURLException; +import java.net.URL; +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.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic.Kind; +import org.openide.WizardDescriptor.InstantiatingIterator; +import org.openide.WizardDescriptor.RegisteredInstantiatingIterator; +import org.openide.filesystems.annotations.LayerBuilder; +import org.openide.filesystems.annotations.LayerGeneratingProcessor; +import org.openide.util.Exceptions; +import org.openide.util.lookup.ServiceProvider; + +@ServiceProvider(service=Processor.class) +@SupportedSourceVersion(SourceVersion.RELEASE_6) +@SupportedAnnotationTypes("org.openide.WizardDescriptor.RegisteredInstantiatingIterator") +public class InstantiatingIteratorProcessor extends LayerGeneratingProcessor { + + @Override + protected boolean doProcess(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + return false; + } + for (Element e : roundEnv.getElementsAnnotatedWith(RegisteredInstantiatingIterator.class)) { + RegisteredInstantiatingIterator ric = e.getAnnotation(RegisteredInstantiatingIterator.class); + try { + String name; + switch (e.getKind()) { + case CLASS: + name = e.toString(); + break; + case METHOD: + name = e.getEnclosingElement() + "." + ((ExecutableElement) e).getSimpleName(); + break; + default: + throw new IllegalArgumentException(e.toString()); + } + LayerBuilder.File f = new LayerBuilder(layer(e)).file("Templates/" + ric.templateCategory() + "/" + name); + f.instanceAttribute("instantiatingIterator", e, InstantiatingIterator.class, processingEnv); + f.bundlevalue("displayName", ric.displayName(), e, processingEnv.getFiler()); + if (ric.iconResource().length() > 0) { + f.stringvalue("iconBase", ric.iconResource()); + } + if (ric.descriptionResource().length() > 0) { + try { + f.urlvalue("instantiatingWizardURL", new URL("nbresloc:/" + ric.descriptionResource())); + } catch (MalformedURLException ex) { + Exceptions.printStackTrace(ex); + } + } + f.position(ric.position()); + f.boolvalue("template", true); + f.write(); + } catch (IllegalArgumentException x) { + processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage()); + continue; + } + } + return true; + } + +} --- a/openide.dialogs/src/org/openide/WizardDescriptor.java +++ a/openide.dialogs/src/org/openide/WizardDescriptor.java @@ -64,6 +64,10 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.net.URL; import java.text.MessageFormat; import java.util.Arrays; @@ -1758,6 +1762,16 @@ */ public void uninitialize(WizardDescriptor wizard); } + + @Retention(RetentionPolicy.SOURCE) + @Target({ElementType.TYPE, ElementType.METHOD}) + public @interface RegisteredInstantiatingIterator { + String templateCategory(); + String displayName(); + String iconResource() default ""; + String descriptionResource() default ""; + int position() default Integer.MAX_VALUE; + } /** * Iterator for a wizard that needs to somehow instantiate new objects outside ATW queue.