Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 153655 | Differences between
and this patch

Collapse All | Expand All

(-)apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java (-1 / +14 lines)
 Lines 112-117    Link Here 
112
import org.netbeans.modules.apisupport.project.universe.LocalizedBundleInfo;
112
import org.netbeans.modules.apisupport.project.universe.LocalizedBundleInfo;
113
import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
113
import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
114
import org.netbeans.spi.project.support.LookupProviderSupport;
114
import org.netbeans.spi.project.support.LookupProviderSupport;
115
import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration;
115
import org.netbeans.spi.project.ui.RecommendedTemplates;
116
import org.netbeans.spi.project.ui.RecommendedTemplates;
116
import org.netbeans.spi.project.ui.support.UILookupMergerSupport;
117
import org.netbeans.spi.project.ui.support.UILookupMergerSupport;
117
import org.openide.modules.SpecificationVersion;
118
import org.openide.modules.SpecificationVersion;
 Lines 121-126    Link Here 
121
 * A NetBeans module project.
122
 * A NetBeans module project.
122
 * @author Jesse Glick
123
 * @author Jesse Glick
123
 */
124
 */
125
@AntBasedProjectRegistration(
126
    type=NbModuleProjectType.TYPE,
127
    iconResource="org/netbeans/modules/apisupport/project/resources/module.png", // NOI18N
128
    sharedConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
129
        name=NbModuleProjectType.NAME_SHARED,
130
        namespace= NbModuleProjectType.NAMESPACE_SHARED
131
    ),
132
    privateConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
133
        name=NbModuleProjectType.NAME_PRIVATE,
134
        namespace= NbModuleProjectType.NAMESPACE_PRIVATE
135
    )
136
)
124
public final class NbModuleProject implements Project {
137
public final class NbModuleProject implements Project {
125
    
138
    
126
    public static final String NB_PROJECT_ICON_PATH =
139
    public static final String NB_PROJECT_ICON_PATH =
 Lines 139-145    Link Here 
139
    private final GeneratedFilesHelper genFilesHelper;
152
    private final GeneratedFilesHelper genFilesHelper;
140
    private final NbModuleProviderImpl typeProvider;
153
    private final NbModuleProviderImpl typeProvider;
141
    
154
    
142
    NbModuleProject(AntProjectHelper helper) throws IOException {
155
    public NbModuleProject(AntProjectHelper helper) throws IOException {
143
        AuxiliaryConfiguration aux = helper.createAuxiliaryConfiguration();
156
        AuxiliaryConfiguration aux = helper.createAuxiliaryConfiguration();
144
        for (int v = 4; v < 10; v++) {
157
        for (int v = 4; v < 10; v++) {
145
            if (aux.getConfigurationFragment("data", "http://www.netbeans.org/ns/nb-module-project/" + v, true) != null) { // NOI18N
158
            if (aux.getConfigurationFragment("data", "http://www.netbeans.org/ns/nb-module-project/" + v, true) != null) { // NOI18N
(-)apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProjectType.java (-35 / +5 lines)
 Lines 41-88    Link Here 
41
41
42
package org.netbeans.modules.apisupport.project;
42
package org.netbeans.modules.apisupport.project;
43
43
44
import java.io.IOException;
45
import javax.swing.Icon;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.spi.project.support.ant.AntBasedProjectType2;
48
import org.netbeans.spi.project.support.ant.AntProjectHelper;
49
import org.openide.util.ImageUtilities;
50
51
/**
44
/**
52
 * Factory for NetBeans module projects.
45
 * Constants.
53
 * @author Jesse Glick
46
 * @author Jesse Glick
54
 */
47
 */
55
@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.project.support.ant.AntBasedProjectType.class)
48
public final class NbModuleProjectType {
56
public final class NbModuleProjectType implements AntBasedProjectType2 {
57
49
58
    static final String TYPE = "org.netbeans.modules.apisupport.project"; // NOI18N
50
    static final String TYPE = "org.netbeans.modules.apisupport.project"; // NOI18N
59
    static final String NAME_SHARED = "data"; // NOI18N
51
    static final String NAME_SHARED = "data"; // NOI18N
60
    public static final String NAMESPACE_SHARED = "http://www.netbeans.org/ns/nb-module-project/3"; // NOI18N
52
    public static final String NAMESPACE_SHARED = "http://www.netbeans.org/ns/nb-module-project/3"; // NOI18N
61
    public static final String NAMESPACE_SHARED_2 = "http://www.netbeans.org/ns/nb-module-project/2"; // NOI18N
53
    public static final String NAMESPACE_SHARED_2 = "http://www.netbeans.org/ns/nb-module-project/2"; // NOI18N
62
    private static final String NAME_PRIVATE = "data"; // NOI18N
54
    static final String NAME_PRIVATE = "data"; // NOI18N
63
    private static final String NAMESPACE_PRIVATE = "http://www.netbeans.org/ns/nb-module-project-private/1"; // NOI18N
55
    static final String NAMESPACE_PRIVATE = "http://www.netbeans.org/ns/nb-module-project-private/1"; // NOI18N
64
    
56
    
65
    /** Default constructor for lookup. */
57
    private NbModuleProjectType() {}
66
    public NbModuleProjectType() {}
67
    
68
    public String getType() {
69
        return TYPE;
70
    }
71
    
72
    public Project createProject(AntProjectHelper helper) throws IOException {
73
        return new NbModuleProject(helper);
74
    }
75
    
76
    public String getPrimaryConfigurationDataElementName(boolean shared) {
77
        return shared ? NAME_SHARED : NAME_PRIVATE;
78
    }
79
    
80
    public String getPrimaryConfigurationDataElementNamespace(boolean shared) {
81
        return shared ? NAMESPACE_SHARED : NAMESPACE_PRIVATE;
82
    }
83
84
    public Icon getIcon() {
85
        return ImageUtilities.image2Icon(ImageUtilities.loadImage("org/netbeans/modules/apisupport/project/resources/module.png", true));
86
    }
87
    
88
}
58
}
(-)apisupport.project/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java (+13 lines)
 Lines 67-72    Link Here 
67
import org.netbeans.modules.apisupport.project.ui.customizer.SuiteProperties;
67
import org.netbeans.modules.apisupport.project.ui.customizer.SuiteProperties;
68
import org.netbeans.modules.apisupport.project.universe.NbPlatform;
68
import org.netbeans.modules.apisupport.project.universe.NbPlatform;
69
import org.netbeans.spi.project.support.LookupProviderSupport;
69
import org.netbeans.spi.project.support.LookupProviderSupport;
70
import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration;
70
import org.netbeans.spi.project.support.ant.AntProjectEvent;
71
import org.netbeans.spi.project.support.ant.AntProjectEvent;
71
import org.netbeans.spi.project.support.ant.AntProjectHelper;
72
import org.netbeans.spi.project.support.ant.AntProjectHelper;
72
import org.netbeans.spi.project.support.ant.AntProjectListener;
73
import org.netbeans.spi.project.support.ant.AntProjectListener;
 Lines 93-98    Link Here 
93
 * Represents one module suite project.
94
 * Represents one module suite project.
94
 * @author Jesse Glick
95
 * @author Jesse Glick
95
 */
96
 */
97
@AntBasedProjectRegistration(
98
    type=SuiteProjectType.TYPE,
99
    iconResource="org/netbeans/modules/apisupport/project/suite/resources/suite.png", // NOI18N
100
    sharedConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
101
        name=SuiteProjectType.NAME_SHARED,
102
        namespace= SuiteProjectType.NAMESPACE_SHARED
103
    ),
104
    privateConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
105
        name=SuiteProjectType.NAME_PRIVATE,
106
        namespace= SuiteProjectType.NAMESPACE_PRIVATE
107
    )
108
)
96
public final class SuiteProject implements Project {
109
public final class SuiteProject implements Project {
97
    
110
    
98
    public static final String SUITE_ICON_PATH =
111
    public static final String SUITE_ICON_PATH =
(-)apisupport.project/src/org/netbeans/modules/apisupport/project/suite/SuiteProjectType.java (-33 / +4 lines)
 Lines 41-87    Link Here 
41
41
42
package org.netbeans.modules.apisupport.project.suite;
42
package org.netbeans.modules.apisupport.project.suite;
43
43
44
import java.io.IOException;
45
import javax.swing.Icon;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.spi.project.support.ant.AntBasedProjectType2;
48
import org.netbeans.spi.project.support.ant.AntProjectHelper;
49
import org.openide.util.ImageUtilities;
50
51
/**
44
/**
52
 * Factory for NetBeans module suite projects.
45
 * Factory for NetBeans module suite projects.
53
 * @author Jesse Glick
46
 * @author Jesse Glick
54
 */
47
 */
55
@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.project.support.ant.AntBasedProjectType.class)
48
public final class SuiteProjectType {
56
public final class SuiteProjectType implements AntBasedProjectType2 {
57
49
58
    public static final String TYPE = "org.netbeans.modules.apisupport.project.suite"; // NOI18N
50
    public static final String TYPE = "org.netbeans.modules.apisupport.project.suite"; // NOI18N
59
    static final String NAME_SHARED = "data"; // NOI18N
51
    static final String NAME_SHARED = "data"; // NOI18N
60
    public static final String NAMESPACE_SHARED = "http://www.netbeans.org/ns/nb-module-suite-project/1"; // NOI18N
52
    public static final String NAMESPACE_SHARED = "http://www.netbeans.org/ns/nb-module-suite-project/1"; // NOI18N
61
    private static final String NAME_PRIVATE = "data"; // NOI18N
53
    static final String NAME_PRIVATE = "data"; // NOI18N
62
    private static final String NAMESPACE_PRIVATE = "http://www.netbeans.org/ns/nb-module-suite-project-private/1"; // NOI18N
54
    static final String NAMESPACE_PRIVATE = "http://www.netbeans.org/ns/nb-module-suite-project-private/1"; // NOI18N
63
    
55
    
64
    /** Default constructor for lookup. */
56
    /** Default constructor for lookup. */
65
    public SuiteProjectType() {}
57
    private SuiteProjectType() {}
66
    
67
    public String getType() {
68
        return TYPE;
69
    }
70
    
71
    public Project createProject(AntProjectHelper helper) throws IOException {
72
        return new SuiteProject(helper);
73
    }
74
    
75
    public String getPrimaryConfigurationDataElementName(boolean shared) {
76
        return shared ? NAME_SHARED : NAME_PRIVATE;
77
    }
78
    
79
    public String getPrimaryConfigurationDataElementNamespace(boolean shared) {
80
        return shared ? NAMESPACE_SHARED : NAMESPACE_PRIVATE;
81
    }
82
83
    public Icon getIcon() {
84
        return ImageUtilities.image2Icon(ImageUtilities.loadImage("org/netbeans/modules/apisupport/project/suite/resources/suite.png", true));
85
    }
86
    
87
}
58
}
(-)java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java (-1 / +14 lines)
 Lines 98-103    Link Here 
98
import org.netbeans.spi.project.ant.AntBuildExtenderFactory;
98
import org.netbeans.spi.project.ant.AntBuildExtenderFactory;
99
import org.netbeans.spi.project.support.LookupProviderSupport;
99
import org.netbeans.spi.project.support.LookupProviderSupport;
100
import org.netbeans.spi.project.ant.AntBuildExtenderImplementation;
100
import org.netbeans.spi.project.ant.AntBuildExtenderImplementation;
101
import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration;
101
import org.netbeans.spi.project.support.ant.AntProjectEvent;
102
import org.netbeans.spi.project.support.ant.AntProjectEvent;
102
import org.netbeans.spi.project.support.ant.AntProjectHelper;
103
import org.netbeans.spi.project.support.ant.AntProjectHelper;
103
import org.netbeans.spi.project.support.ant.AntProjectListener;
104
import org.netbeans.spi.project.support.ant.AntProjectListener;
 Lines 139-144    Link Here 
139
 * Represents one plain J2SE project.
140
 * Represents one plain J2SE project.
140
 * @author Jesse Glick, et al.
141
 * @author Jesse Glick, et al.
141
 */
142
 */
143
@AntBasedProjectRegistration(
144
    type=J2SEProjectType.TYPE,
145
    iconResource="org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", // NOI18N
146
    sharedConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
147
        name=J2SEProjectType.PROJECT_CONFIGURATION_NAME,
148
        namespace= J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE
149
    ),
150
    privateConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
151
        name=J2SEProjectType.PRIVATE_CONFIGURATION_NAME,
152
        namespace= J2SEProjectType.PRIVATE_CONFIGURATION_NAMESPACE
153
    )
154
)
142
public final class J2SEProject implements Project, AntProjectListener {
155
public final class J2SEProject implements Project, AntProjectListener {
143
    
156
    
144
    private static final Icon J2SE_PROJECT_ICON = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png")); // NOI18N
157
    private static final Icon J2SE_PROJECT_ICON = new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png")); // NOI18N
 Lines 159-165    Link Here 
159
172
160
    private AntBuildExtender buildExtender;
173
    private AntBuildExtender buildExtender;
161
174
162
    J2SEProject(AntProjectHelper helper) throws IOException {
175
    public J2SEProject(AntProjectHelper helper) throws IOException {
163
        this.helper = helper;
176
        this.helper = helper;
164
        eval = createEvaluator();
177
        eval = createEvaluator();
165
        aux = helper.createAuxiliaryConfiguration();
178
        aux = helper.createAuxiliaryConfiguration();
(-)java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProjectType.java (-39 / +5 lines)
 Lines 41-87    Link Here 
41
41
42
package org.netbeans.modules.java.j2seproject;
42
package org.netbeans.modules.java.j2seproject;
43
43
44
import java.io.IOException;
45
import javax.swing.Icon;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.spi.project.support.ant.AntBasedProjectType2;
48
import org.netbeans.spi.project.support.ant.AntProjectHelper;
49
import org.openide.util.ImageUtilities;
50
51
/**
44
/**
52
 * Factory for simple J2SE projects.
45
 * Constants.
53
 * @author Jesse Glick
54
 */
46
 */
55
@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.project.support.ant.AntBasedProjectType.class)
47
public final class J2SEProjectType {
56
public final class J2SEProjectType implements AntBasedProjectType2 {
57
58
    public static final String TYPE = "org.netbeans.modules.java.j2seproject"; // NOI18N
48
    public static final String TYPE = "org.netbeans.modules.java.j2seproject"; // NOI18N
59
    private static final String PROJECT_CONFIGURATION_NAME = "data"; // NOI18N
49
    static final String PROJECT_CONFIGURATION_NAME = "data"; // NOI18N
60
    public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2se-project/3"; // NOI18N
50
    public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2se-project/3"; // NOI18N
61
    private static final String PRIVATE_CONFIGURATION_NAME = "data"; // NOI18N
51
    static final String PRIVATE_CONFIGURATION_NAME = "data"; // NOI18N
62
    private static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2se-project-private/1"; // NOI18N
52
    static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2se-project-private/1"; // NOI18N
63
    
64
    /** Do nothing, just a service. */
65
    public J2SEProjectType() {}
66
    
67
    public String getType() {
68
        return TYPE;
69
    }
70
    
71
    public Project createProject(AntProjectHelper helper) throws IOException {
72
        return new J2SEProject(helper);
73
    }
74
75
    public String getPrimaryConfigurationDataElementName(boolean shared) {
76
        return shared ? PROJECT_CONFIGURATION_NAME : PRIVATE_CONFIGURATION_NAME;
77
    }
78
    
79
    public String getPrimaryConfigurationDataElementNamespace(boolean shared) {
80
        return shared ? PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
81
    }
82
83
    public Icon getIcon() {
84
        return ImageUtilities.image2Icon(ImageUtilities.loadImage("org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", true));
85
    }
86
    
87
}
53
}
(-)project.ant/src/org/netbeans/modules/project/ant/AntBasedGenericType.java (+129 lines)
Added Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.project.ant;
41
42
import java.io.IOException;
43
import java.lang.reflect.Constructor;
44
import java.lang.reflect.Method;
45
import java.util.Map;
46
import javax.swing.Icon;
47
import org.netbeans.api.project.Project;
48
import org.netbeans.spi.project.support.ant.AntBasedProjectType;
49
import org.netbeans.spi.project.support.ant.AntProjectHelper;
50
import org.openide.util.ImageUtilities;
51
import org.openide.util.Lookup;
52
import org.openide.util.Parameters;
53
54
/** Generic implementation of {@link AntBasedGenericType} that feeds itself
55
 * from an layer data.
56
 *
57
 * @author Jaroslav Tulach <jtulach@netbeans.org>
58
 */
59
final class AntBasedGenericType implements AntBasedProjectType {
60
    private final String iconResource;
61
    private final String type;
62
    private final String className;
63
    private final String methodName;
64
    private final String[] configNames;
65
    private final String[] configNamespaces;
66
67
    public AntBasedGenericType(Map map) {
68
        iconResource = (String)map.get("iconResource"); // NOI18N
69
        type = (String)map.get("type"); // NOI18N
70
        className = (String)map.get("className"); // NOI18N
71
        methodName = (String)map.get("methodName"); // NOI18N
72
        configNames = new String[] {
73
            (String)map.get("sharedName"), // NOI18N
74
            (String)map.get("privateName"), // NOI18N
75
        };
76
        configNamespaces = new String[] {
77
            (String)map.get("sharedNamespace"), // NOI18N
78
            (String)map.get("privateNamespace"), // NOI18N
79
        };
80
        Parameters.notNull("iconResource", iconResource); // NOI18N
81
        Parameters.notNull("type", type); // NOI18N
82
        Parameters.notNull("className", className); // NOI18N
83
        Parameters.notNull("sharedName", configNames[0]); // NOI18N
84
        Parameters.notNull("privateName", configNames[1]); // NOI18N
85
        Parameters.notNull("sharedNamespace", configNamespaces[0]); // NOI18N
86
        Parameters.notNull("privateNamespace", configNamespaces[1]); // NOI18N
87
    }
88
89
    public Icon getIcon() {
90
        return ImageUtilities.image2Icon(ImageUtilities.loadImage(iconResource, true));
91
    }
92
93
    public String getType() {
94
        return type;
95
    }
96
97
    public String getPrimaryConfigurationDataElementName(boolean shared) {
98
        return shared ? configNames[0] : configNames[1];
99
    }
100
101
    public String getPrimaryConfigurationDataElementNamespace(boolean shared) {
102
        return shared ? configNamespaces[0] : configNamespaces[1];
103
    }
104
105
106
    public Project createProject(AntProjectHelper helper) throws IOException {
107
        ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
108
        if (l == null) {
109
            l = Thread.currentThread().getContextClassLoader();
110
        }
111
        if (l == null) {
112
            l = AntBasedGenericType.class.getClassLoader();
113
        }
114
        try {
115
            Class<?> clazz = l.loadClass(className);
116
            if (methodName != null) {
117
                Method m = clazz.getDeclaredMethod(methodName, AntProjectHelper.class);
118
                return (Project)m.invoke(null, helper);
119
            } else {
120
                Constructor c = clazz.getConstructor(AntProjectHelper.class);
121
                return (Project) c.newInstance(helper);
122
            }
123
        } catch (RuntimeException ex) {
124
            throw ex;
125
        } catch (Exception ex) {
126
            throw (IllegalArgumentException)new IllegalArgumentException().initCause(ex);
127
        }
128
    }
129
}
(-)project.ant/src/org/netbeans/modules/project/ant/AntBasedProcessor.java (+156 lines)
Added Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.project.ant;
41
42
import java.util.Set;
43
import javax.annotation.processing.Processor;
44
import javax.annotation.processing.RoundEnvironment;
45
import javax.annotation.processing.SupportedAnnotationTypes;
46
import javax.annotation.processing.SupportedSourceVersion;
47
import javax.lang.model.SourceVersion;
48
import javax.lang.model.element.Element;
49
import javax.lang.model.element.ElementKind;
50
import javax.lang.model.element.ExecutableElement;
51
import javax.lang.model.element.Modifier;
52
import javax.lang.model.element.TypeElement;
53
import javax.lang.model.type.TypeMirror;
54
import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration;
55
import org.netbeans.spi.project.support.ant.AntBasedProjectType;
56
import org.netbeans.spi.project.support.ant.AntProjectHelper;
57
import org.openide.filesystems.annotations.LayerBuilder.File;
58
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
59
import org.openide.filesystems.annotations.LayerGenerationException;
60
import org.openide.util.lookup.ServiceProvider;
61
62
/**
63
 * processor for {@link AntBasedProjectRegistration} annotation.
64
 * @author Jaroslav Tulach
65
 */
66
@ServiceProvider(service=Processor.class)
67
@SupportedSourceVersion(SourceVersion.RELEASE_6)
68
@SupportedAnnotationTypes("org.netbeans.spi.project.support.ant.AntBasedProjectRegistration")//NOI18N
69
public class AntBasedProcessor extends LayerGeneratingProcessor {
70
71
    @Override
72
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
73
        if (roundEnv.processingOver()) {
74
            return false;
75
        }
76
        TypeMirror antHelper = processingEnv.getElementUtils().getTypeElement(AntProjectHelper.class.getName()).asType();
77
        for (Element e : roundEnv.getElementsAnnotatedWith(AntBasedProjectRegistration.class)) {
78
            AntBasedProjectRegistration reg = e.getAnnotation(AntBasedProjectRegistration.class);
79
            String name;
80
            String classname;
81
            String methodname;
82
            switch (e.getKind()) {
83
                case CLASS:
84
                    classname = processingEnv.getElementUtils().getBinaryName((TypeElement)e).toString();
85
                    name = classname.replace('.', '-');
86
                    methodname = null;
87
                    if (!e.getModifiers().contains(Modifier.PUBLIC)) {
88
                        throw new LayerGenerationException("Class needs to be public"); // NOI18N
89
                    }
90
                    boolean found = false;
91
                    for (Element cns : processingEnv.getElementUtils().getAllMembers((TypeElement)e)) {
92
                        if (cns.getKind() != ElementKind.CONSTRUCTOR) {
93
                            continue;
94
                        }
95
                        ExecutableElement exec = (ExecutableElement)cns;
96
                        if (!exec.getModifiers().contains(Modifier.PUBLIC)) {
97
                            continue;
98
                        }
99
                        if (exec.getParameters().size() != 1) {
100
                            continue;
101
                        }
102
                        if (exec.getParameters().get(0).asType().equals(antHelper)) {
103
                            found = true;
104
                            break;
105
                        }
106
                    }
107
                    if (!found) {
108
                        throw new LayerGenerationException("There needs to be public constructor taking AntProjectHelper parameter"); // NOI18N
109
                    }
110
111
                    break;
112
                case METHOD:
113
                    classname = processingEnv.getElementUtils().getBinaryName((TypeElement)e.getEnclosingElement()).toString();
114
                    methodname = ((ExecutableElement) e).getSimpleName().toString();
115
                    name = (classname + "." + methodname).replace('.', '-');
116
                    
117
                    if (!e.getEnclosingElement().getModifiers().contains(Modifier.PUBLIC)) {
118
                        throw new LayerGenerationException("Class needs to be public"); // NOI18N
119
                    }
120
121
                    ExecutableElement exec = (ExecutableElement)e;
122
                    if (
123
                        !exec.getModifiers().contains(Modifier.PUBLIC) ||
124
                        !exec.getModifiers().contains(Modifier.STATIC) ||
125
                        exec.getParameters().size() != 1 ||
126
                        !exec.getParameters().get(0).asType().equals(antHelper)
127
                    ) {
128
                        throw new LayerGenerationException("The method needs to be public, static and take AntProjectHelper argument"); // NOI18N
129
                    }
130
131
                    break;
132
                default:
133
                    throw new IllegalArgumentException(e.toString());
134
            }
135
136
            File f = layer(e).
137
                file("Services/AntBasedProjectTypes/" + name + ".instance").
138
                stringvalue("type", reg.type()).
139
                stringvalue("iconResource", reg.iconResource()).
140
                stringvalue("sharedName", reg.sharedConfiguration().name()).
141
                stringvalue("sharedNamespace", reg.sharedConfiguration().namespace()).
142
                stringvalue("privateName", reg.privateConfiguration().name()).
143
                stringvalue("privateNamespace", reg.privateConfiguration().namespace()).
144
                stringvalue("className", classname).
145
                stringvalue("instanceClass", AntBasedProjectType.class.getName()).
146
                methodvalue("instanceCreate", AntBasedProjectFactorySingleton.class.getName(), "create");
147
148
            if (methodname != null) {
149
                f = f.stringvalue("methodName", methodname);
150
            }
151
            f.write();
152
        }
153
        return true;
154
    }
155
156
}
(-)project.ant/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingleton.java (-4 / +8 lines)
 Lines 69-75    Link Here 
69
import org.netbeans.spi.project.ProjectFactory2;
69
import org.netbeans.spi.project.ProjectFactory2;
70
import org.netbeans.spi.project.ProjectState;
70
import org.netbeans.spi.project.ProjectState;
71
import org.netbeans.spi.project.support.ant.AntBasedProjectType;
71
import org.netbeans.spi.project.support.ant.AntBasedProjectType;
72
import org.netbeans.spi.project.support.ant.AntBasedProjectType2;
73
import org.netbeans.spi.project.support.ant.AntProjectHelper;
72
import org.netbeans.spi.project.support.ant.AntProjectHelper;
74
import org.openide.filesystems.FileObject;
73
import org.openide.filesystems.FileObject;
75
import org.openide.filesystems.FileUtil;
74
import org.openide.filesystems.FileUtil;
 Lines 187-194    Link Here 
187
                    if (type != null) {
186
                    if (type != null) {
188
                        AntBasedProjectType provider = findAntBasedProjectType(type);
187
                        AntBasedProjectType provider = findAntBasedProjectType(type);
189
                        if (provider != null) {
188
                        if (provider != null) {
190
                            if (provider instanceof AntBasedProjectType2) {
189
                            if (provider instanceof AntBasedGenericType) {
191
                                return new ProjectManager.Result(((AntBasedProjectType2)provider).getIcon());
190
                                return new ProjectManager.Result(((AntBasedGenericType)provider).getIcon());
192
                            } else {
191
                            } else {
193
                                //put special icon?
192
                                //put special icon?
194
                                return new ProjectManager.Result(null);
193
                                return new ProjectManager.Result(null);
 Lines 385-389    Link Here 
385
        }
384
        }
386
        assert HELPER_CALLBACK != null;
385
        assert HELPER_CALLBACK != null;
387
    }
386
    }
388
    
387
388
    public static AntBasedProjectType create(Map map) {
389
        return new AntBasedGenericType(map);
390
    }
391
392
389
}
393
}
(-)project.ant/src/org/netbeans/spi/project/support/ant/AntBasedProjectRegistration.java (+114 lines)
Added Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.spi.project.support.ant;
43
44
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
47
import java.lang.annotation.Target;
48
import org.netbeans.api.project.Project;
49
50
/** Registers a {@link Project} implementation as an
51
 * {@link org.netbeans.spi.project.support.ant.AntBasedProjectType} extension.
52
 * Just write a project with constructor that takes one
53
 * {@link AntProjectHelper} argument and annotate the class with this annotation.
54
 * As an alternative you can annotate a factory method with the same parameter.
55
 *
56
 * @author Jaroslav Tulach
57
 * @since 1.30
58
 */
59
@Retention(RetentionPolicy.SOURCE)
60
@Target({ ElementType.TYPE, ElementType.METHOD })
61
public @interface AntBasedProjectRegistration {
62
    /**
63
     * icon of the project type represented by the given implementation of the interface.
64
     * @return the {@link ClassLoader#getResource(java.lang.String)} path to the icon
65
     */
66
    public String iconResource();
67
68
69
    /**
70
     * Get a unique type identifier for this kind of project.
71
     * No two registered {@link AntBasedProjectType} instances may share the same type.
72
     * The type is stored in <code>nbproject/project.xml</code> in the <code>type</code> element.
73
     * It is forbidden for the result of this method to change from call to call.
74
     * @return the project type
75
     */
76
    String type();
77
78
    /** Returns setup for configuration of shared data section inside <code>project.xml</code>
79
     * @return the configuration data element
80
     */
81
    PrimaryConfigurationDataElement sharedConfiguration();
82
83
    /** Returns setup for configuration of private data section inside <code>private.xml</code>
84
     * @return the configuration data element
85
     */
86
    PrimaryConfigurationDataElement privateConfiguration();
87
88
89
    public @interface PrimaryConfigurationDataElement {
90
        /**
91
         * Get the simple name of the XML element that should be used to store
92
         * the project's specific configuration data in <code>nbproject/project.xml</code>
93
         * (inside <code>&lt;configuration&gt;</code>) or <code>nbproject/private/private.xml</code>
94
         * (inside <code>&lt;project-private&gt;</code>).
95
         * It is forbidden for the result of this method to change from call to call.
96
         * @param shared if true, refers to <code>project.xml</code>, else refers to
97
         *               <code>private.xml</code>
98
         * @return a simple name; <samp>data</samp> is recommended but not required
99
         */
100
        String name();
101
        /**
102
         * Get the namespace of the XML element that should be used to store
103
         * the project's specific configuration data in <code>nbproject/project.xml</code>
104
         * (inside <code>&lt;configuration&gt;</code>) or <code>nbproject/private/private.xml</code>
105
         * (inside <code>&lt;project-private&gt;</code>).
106
         * It is forbidden for the result of this method to change from call to call.
107
         * @param shared if true, refers to <code>project.xml</code>, else refers to
108
         *               <code>private.xml</code>
109
         * @return an XML namespace, e.g. <samp>http://www.netbeans.org/ns/j2se-project</samp>
110
         *         or <samp>http://www.netbeans.org/ns/j2se-project-private</samp>
111
         */
112
        String namespace();
113
    }
114
}
(-)project.ant/src/org/netbeans/spi/project/support/ant/AntBasedProjectType2.java (-60 lines)
Removed Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.spi.project.support.ant;
43
44
import javax.swing.Icon;
45
46
/**
47
 * extension of {@link org.netbeans.spi.project.support.ant.AntBasedProjectType}
48
 * that provides an icon for the project without actually creating an project instance for it.
49
 * @author mkleint
50
 * @since org.netbeans.modules.project.ant 1.28
51
 */
52
public interface AntBasedProjectType2 extends AntBasedProjectType {
53
54
    /**
55
     * icon of the project type represented by the given implementation of the interface.
56
     * @return
57
     */
58
    public Icon getIcon();
59
60
}
(-)project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedProjectRegistrationTest.java (+148 lines)
Added Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.spi.project.support.ant;
43
44
import java.io.IOException;
45
import java.util.Collection;
46
import java.util.Iterator;
47
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.ProjectManager;
49
import org.netbeans.api.project.TestUtil;
50
import org.netbeans.junit.NbTestCase;
51
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileUtil;
53
import org.openide.util.Lookup;
54
import org.openide.util.lookup.Lookups;
55
import org.openide.util.test.MockLookup;
56
57
/**
58
 * That that a project registered by annotation is really found.
59
 * @author Jaroslav Tulach
60
 */
61
public class AntBasedProjectRegistrationTest extends NbTestCase {
62
    
63
    public AntBasedProjectRegistrationTest(String name) {
64
        super(name);
65
    }
66
    
67
    private FileObject scratch;
68
    private FileObject projdir;
69
    private ProjectManager pm;
70
    
71
    protected @Override void setUp() throws Exception {
72
        super.setUp();
73
        MockLookup.init();
74
        assertEquals("No factory has been used yet", 0, AnnotatedProject.factoryCalls);
75
        Collection<? extends Object> all = Lookups.forPath("Services/AntBasedProjectTypes").lookupAll(AntBasedProjectType.class);
76
        assertEquals("Two found", 2, all.size());
77
        Iterator<? extends Object> it = all.iterator();
78
        if ("testFactory".equals(getName())) {
79
            it.next();
80
        }
81
        MockLookup.setInstances(it.next());
82
        scratch = TestUtil.makeScratchDir(this);
83
        projdir = scratch.createFolder("proj");
84
        ProjectGenerator.createProject(projdir, "test");
85
        pm = ProjectManager.getDefault();
86
    }
87
88
    protected @Override void tearDown() throws Exception {
89
        scratch = null;
90
        projdir = null;
91
        pm = null;
92
        super.tearDown();
93
    }
94
    
95
    public void testFindProject() throws Exception {
96
        Project p = pm.findProject(projdir);
97
        assertNotNull("Annotation project found", p.getLookup().lookup(AnnotatedProject.class));
98
    }
99
100
    public void testFactory() throws Exception {
101
        Project p = pm.findProject(projdir);
102
        assertNotNull("Annotation project found", p.getLookup().lookup(AnnotatedProject.class));
103
        assertEquals(1, AnnotatedProject.factoryCalls);
104
    }
105
106
    @AntBasedProjectRegistration(
107
        iconResource="noicon",
108
        type="test",
109
        privateConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
110
            name="data",
111
            namespace="urn:test:private"
112
        ),
113
        sharedConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
114
            name="data",
115
            namespace="urn:test:shared"
116
        )
117
    )
118
    public static final class AnnotatedProject extends AntBasedTestUtil.TestAntBasedProject {
119
        static int factoryCalls;
120
        
121
        public AnnotatedProject(AntProjectHelper h) throws IOException {
122
            super(h, null);
123
        }
124
125
        @Override
126
        public Lookup getLookup() {
127
            return Lookups.singleton(this);
128
        }
129
130
        @AntBasedProjectRegistration(
131
            iconResource = "noicon",
132
            type = "test",
133
            privateConfiguration = @AntBasedProjectRegistration.PrimaryConfigurationDataElement(
134
                name = "data",
135
                namespace = "urn:test:private"
136
            ),
137
            sharedConfiguration = @AntBasedProjectRegistration.PrimaryConfigurationDataElement(
138
                name = "data",
139
                namespace = "urn:test:shared"
140
            )
141
        )
142
        public static Project factoryMethod(AntProjectHelper h) throws IOException {
143
            factoryCalls++;
144
            return new AnnotatedProject(h);
145
        }
146
    }
147
    
148
}
(-)project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java (-2 / +2 lines)
 Lines 157-170    Link Here 
157
        
157
        
158
    }
158
    }
159
    
159
    
160
    private static final class TestAntBasedProject implements Project {
160
    public static class TestAntBasedProject implements Project {
161
        
161
        
162
        private final AntProjectHelper helper;
162
        private final AntProjectHelper helper;
163
        private final ReferenceHelper refHelper;
163
        private final ReferenceHelper refHelper;
164
        private final GeneratedFilesHelper genFilesHelper;
164
        private final GeneratedFilesHelper genFilesHelper;
165
        private final Lookup l;
165
        private final Lookup l;
166
        
166
        
167
        TestAntBasedProject(AntProjectHelper helper, AntBuildExtenderImplementation ext) throws IOException {
167
        protected TestAntBasedProject(AntProjectHelper helper, AntBuildExtenderImplementation ext) throws IOException {
168
            if (helper.getProjectDirectory().getFileObject("nbproject/broken") != null) {
168
            if (helper.getProjectDirectory().getFileObject("nbproject/broken") != null) {
169
                throw new IOException("broken");
169
                throw new IOException("broken");
170
            }
170
            }
(-)web.project/src/org/netbeans/modules/web/project/WebProjectType.java (-21 / +17 lines)
 Lines 43-58    Link Here 
43
43
44
import java.io.IOException;
44
import java.io.IOException;
45
import java.util.Collection;
45
import java.util.Collection;
46
import javax.swing.Icon;
47
import org.netbeans.api.project.Project;
46
import org.netbeans.api.project.Project;
48
import org.netbeans.modules.web.project.spi.WebProjectImplementationFactory;
47
import org.netbeans.modules.web.project.spi.WebProjectImplementationFactory;
49
import org.netbeans.spi.project.support.ant.AntBasedProjectType2;
48
import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration;
50
import org.netbeans.spi.project.support.ant.AntProjectHelper;
49
import org.netbeans.spi.project.support.ant.AntProjectHelper;
51
import org.openide.util.ImageUtilities;
52
import org.openide.util.Lookup;
50
import org.openide.util.Lookup;
53
51
54
@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.project.support.ant.AntBasedProjectType.class)
52
public final class WebProjectType {
55
public final class WebProjectType implements AntBasedProjectType2 {
56
53
57
    public static final String TYPE = "org.netbeans.modules.web.project";
54
    public static final String TYPE = "org.netbeans.modules.web.project";
58
    private static final String PROJECT_CONFIGURATION_NAME = "data";
55
    private static final String PROJECT_CONFIGURATION_NAME = "data";
 Lines 66-78    Link Here 
66
            "http://www.netbeans.org/ns/web-project/3"};
63
            "http://www.netbeans.org/ns/web-project/3"};
67
64
68
    /** Do nothing, just a service. */
65
    /** Do nothing, just a service. */
69
    public WebProjectType() {}
66
    private WebProjectType() {}
70
    
67
    
71
    public String getType() {
68
    public String getType() {
72
        return TYPE;
69
        return TYPE;
73
    }
70
    }
74
    
71
    @AntBasedProjectRegistration(
75
    public Project createProject(AntProjectHelper helper) throws IOException {
72
        iconResource="org/netbeans/modules/web/project/ui/resources/webProjectIcon.gif", // NOI18N
73
        type=TYPE,
74
        sharedConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
75
            name=PROJECT_CONFIGURATION_NAME,
76
            namespace=PROJECT_CONFIGURATION_NAMESPACE
77
        ),
78
        privateConfiguration=@AntBasedProjectRegistration.PrimaryConfigurationDataElement(
79
            name=PRIVATE_CONFIGURATION_NAME,
80
            namespace=PRIVATE_CONFIGURATION_NAMESPACE
81
        )
82
    )
83
    public static Project createProject(AntProjectHelper helper) throws IOException {
76
        for(WebProjectImplementationFactory factory : getProjectFactories()) {
84
        for(WebProjectImplementationFactory factory : getProjectFactories()) {
77
            if (factory.acceptProject(helper)) {
85
            if (factory.acceptProject(helper)) {
78
                //delegate project completely to another implementation
86
                //delegate project completely to another implementation
 Lines 82-100    Link Here 
82
        return new WebProject(helper);
90
        return new WebProject(helper);
83
    }
91
    }
84
92
85
    public String getPrimaryConfigurationDataElementName(boolean shared) {
93
    private static Collection<? extends WebProjectImplementationFactory> getProjectFactories() {
86
        return shared ? PROJECT_CONFIGURATION_NAME : PRIVATE_CONFIGURATION_NAME;
87
    }
88
    
89
    public String getPrimaryConfigurationDataElementNamespace(boolean shared) {
90
        return shared ? PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
91
    }
92
93
    private Collection<? extends WebProjectImplementationFactory> getProjectFactories() {
94
        return Lookup.getDefault().lookupAll(WebProjectImplementationFactory.class);
94
        return Lookup.getDefault().lookupAll(WebProjectImplementationFactory.class);
95
    }
95
    }
96
97
    public Icon getIcon() {
98
        return ImageUtilities.image2Icon(ImageUtilities.loadImage("org/netbeans/modules/web/project/ui/resources/webProjectIcon.gif", true));
99
    }
100
}
96
}

Return to bug 153655
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo