KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > java > project > support > ui > templates > JavaTemplates


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.java.project.support.ui.templates;
21
22 import org.netbeans.api.project.Project;
23 import org.netbeans.modules.java.project.JavaTargetChooserPanel;
24 import org.netbeans.modules.java.project.NewJavaFileWizardIterator;
25 import org.netbeans.api.project.SourceGroup;
26 import org.netbeans.spi.project.ui.templates.support.Templates;
27 import org.openide.WizardDescriptor;
28 import org.openide.filesystems.FileObject;
29
30 /**
31  * Default implementations of Java-specific template UI.
32  * @author Jesse Glick
33  */

34 public class JavaTemplates {
35
36     private JavaTemplates() {}
37     
38     /**
39      * Create a Java-oriented target chooser suitable for templates which are Java
40      * sources or otherwise intended to reside in a Java package.
41      * The user is prompted to choose a package location for the new file and a (base) name.
42      * @param project the project which the template will be created in
43      * @param folders a list of possible Java package roots to create the new file in (must be nonempty)
44      * @return a wizard panel prompting the user to choose a name and package
45      * @throws IllegalArgumentException if folders is empty
46      */

47     public static WizardDescriptor.Panel createPackageChooser(Project project, SourceGroup[] folders) throws IllegalArgumentException JavaDoc {
48         return createPackageChooser(project, folders, null);
49     }
50     
51     /**
52      * Create a Java-oriented target chooser suitable for templates which are Java
53      * sources or otherwise intended to reside in a Java package.
54      * The user is prompted to choose a package location for the new file and a (base) name.
55      * Resulting panel can be decorated with additional panel. Which will
56      * be placed below the standard package chooser.
57      * @param project the project which the template will be created in
58      * @param folders a list of possible Java package roots to create the new file in (must be nonempty)
59      * @param bottomPanel panel which should be placed underneth the default chooser
60      * @return a wizard panel prompting the user to choose a name and package
61      * @throws IllegalArgumentException if folders is empty
62      */

63     public static WizardDescriptor.Panel createPackageChooser(Project project, SourceGroup[] folders, WizardDescriptor.Panel bottomPanel) throws IllegalArgumentException JavaDoc {
64         return createPackageChooser(project, folders, bottomPanel, false);
65     }
66     
67     /**
68      * Create a Java-oriented target chooser suitable for templates which are Java
69      * sources or otherwise intended to reside in a Java package.
70      * The user is prompted to choose a package location for the new file and a (base) name;
71      * this method allows to specify whether a valid (non-empty) package is required.
72      * Resulting panel can be decorated with additional panel. Which will
73      * be placed below the standard package chooser.
74      * @param project the project which the template will be created in
75      * @param folders a list of possible Java package roots to create the new file in (must be nonempty)
76      * @param bottomPanel panel which should be placed underneth the default chooser
77      * @param validPackageRequired indicates whether a only a valid (non-empty) package is accepted
78      * @return a wizard panel prompting the user to choose a name and package
79      * @throws IllegalArgumentException if folders is empty
80      * @since org.netbeans.modules.java.project/1 1.3
81      */

82     public static WizardDescriptor.Panel createPackageChooser(Project project, SourceGroup[] folders,
83         WizardDescriptor.Panel bottomPanel, boolean validPackageRequired) throws IllegalArgumentException JavaDoc {
84         if (folders.length == 0) {
85             throw new IllegalArgumentException JavaDoc("No folders selected"); // NOI18N
86
}
87         return new JavaTargetChooserPanel(project, folders, bottomPanel, NewJavaFileWizardIterator.TYPE_FILE, validPackageRequired);
88     }
89     
90     /** Creates new WizardIterator containing standard Package chooser
91      * @return WizardIterator consisting of one panel containing package chooser
92      */

93     public static WizardDescriptor.InstantiatingIterator createJavaTemplateIterator () {
94         return new NewJavaFileWizardIterator ();
95     }
96     
97 }
98
Popular Tags