This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 179749
Collapse All | Expand All

(-)a/api.java/apichanges.xml (+14 lines)
Lines 73-78 Link Here
73
<!-- ACTUAL CHANGES BEGIN HERE: -->
73
<!-- ACTUAL CHANGES BEGIN HERE: -->
74
74
75
<changes>
75
<changes>
76
        <change id="apt-query">
77
            <api name="classpath"/>
78
            <summary>Introducing AptQuery</summary>
79
            <version major="1" minor="25"/>
80
            <date day="27" month="1" year="2010"/>
81
            <author login="jlahoda"/>
82
            <compatibility addition="yes" modification="no" semantic="compatible" source="compatible" binary="compatible"/>
83
            <description>
84
                <p>
85
                </p>
86
            </description>
87
            <class package="org.netbeans.api.java.queries" name="AptQuery" />
88
            <issue number="179749"/>
89
        </change>
76
        <change id="java-classpath-processorpath">
90
        <change id="java-classpath-processorpath">
77
            <api name="classpath"/>
91
            <api name="classpath"/>
78
            <summary>Introducing JavaClassPathConstants.PROCESSOR_PATH</summary>
92
            <summary>Introducing JavaClassPathConstants.PROCESSOR_PATH</summary>
(-)a/api.java/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.java/1
2
OpenIDE-Module: org.netbeans.api.java/1
3
OpenIDE-Module-Specification-Version: 1.24
3
OpenIDE-Module-Specification-Version: 1.25
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/java/queries/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/java/queries/Bundle.properties
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
6
6
(-)a/api.java/nbproject/project.xml (+9 lines)
Lines 47-52 Link Here
47
            <code-name-base>org.netbeans.api.java</code-name-base>
47
            <code-name-base>org.netbeans.api.java</code-name-base>
48
            <module-dependencies>
48
            <module-dependencies>
49
                <dependency>
49
                <dependency>
50
                    <code-name-base>org.netbeans.api.annotations.common</code-name-base>
51
                    <build-prerequisite/>
52
                    <compile-dependency/>
53
                    <run-dependency>
54
                        <release-version>1</release-version>
55
                        <specification-version>1.4</specification-version>
56
                    </run-dependency>
57
                </dependency>
58
                <dependency>
50
                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
59
                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
51
                    <build-prerequisite/>
60
                    <build-prerequisite/>
52
                    <compile-dependency/>
61
                    <compile-dependency/>
(-)a/api.java/src/org/netbeans/api/java/queries/AptQuery.java (+126 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.api.java.queries;
41
42
import javax.swing.event.ChangeListener;
43
import org.netbeans.api.annotations.common.CheckForNull;
44
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.api.java.classpath.ClassPath;
46
import org.netbeans.api.java.classpath.JavaClassPathConstants;
47
import org.netbeans.spi.java.queries.AptQueryImplementation;
48
import org.openide.filesystems.FileObject;
49
import org.openide.util.Lookup;
50
import org.openide.util.Parameters;
51
52
/**Return annotation processing configuration for given Java file, package or source folder.
53
 *
54
 * @author Jan Lahoda
55
 * @since org.netbeans.api.java/1 1.25
56
 */
57
public class AptQuery {
58
59
    /**
60
     * Returns annotation processing configuration for Java file, Java package or source folder.
61
     * @param file Java source file, Java package or source folder in question
62
     * @return annotation processing configuration. Never null.
63
     */
64
    public static @NonNull Result getAptOptions(@NonNull FileObject file) {
65
        Parameters.notNull("file", file);
66
        
67
        for (AptQueryImplementation i : Lookup.getDefault().lookupAll(AptQueryImplementation.class)) {
68
            Result r = i.getAptOptions(file);
69
70
            if (r != null) {
71
                return r;
72
            }
73
        }
74
75
        return EMPTY;
76
    }
77
78
    /**Annotation processing configuration. The processor path is returned from
79
     * {@link ClassPath#getClassPath(org.openide.filesystems.FileObject, java.lang.String)}
80
     * for {@link JavaClassPathConstants#PROCESSOR_PATH}.
81
     *
82
     */
83
    public static interface Result {
84
85
        /**Whether the annotation processors should be run inside Java editor.
86
         *
87
         * @return true if and only if the annotation processors should be run inside the Java editor
88
         */
89
        public boolean annotationProcessingEnabled();
90
91
        /**Which annotation processors should be run.
92
         *
93
         * @return if null, run all annotation processors found on the ClassPath will be run,
94
         *         otherwise only the selected processors will be run.
95
         */
96
        public @CheckForNull Iterable<? extends String> annotationProcessorsToRun();
97
98
        /**Add a {@link ChangeListener}.
99
         *
100
         * @param l the listener
101
         */
102
        public void addChangeListener(@NonNull ChangeListener l);
103
104
        /**Remove a {@link ChangeListener}.
105
         *
106
         * @param l the listener
107
         */
108
        public void removeChangeListener(@NonNull ChangeListener l);
109
    }
110
111
    private static final Result EMPTY = new Result() {
112
        public boolean annotationProcessingEnabled() {
113
            return true;
114
        }
115
116
        public Iterable<? extends String> annotationProcessorsToRun() {
117
            return null;
118
        }
119
120
        public void addChangeListener(ChangeListener l) {}
121
        public void removeChangeListener(ChangeListener l) {}
122
123
    };
124
125
    private AptQuery() {}
126
}
(-)a/api.java/src/org/netbeans/spi/java/queries/AptQueryImplementation.java (+61 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.spi.java.queries;
41
42
import org.netbeans.api.java.queries.AptQuery;
43
import org.netbeans.api.java.queries.AptQuery.Result;
44
import org.openide.filesystems.FileObject;
45
46
/**SPI for the {@link AptQuery}.
47
 *
48
 * @author Jan Lahoda
49
 * @since org.netbeans.api.java/1 1.25
50
 */
51
public interface AptQueryImplementation {
52
53
    /**Return the annotation processing configuration, or null if the current
54
     * provider cannot provide configuration for the given file/folder.
55
     *
56
     * @param file Java source file, Java package or source folder in question
57
     * @return non-null Result if this provider can provide annotation processing configuration for the given file/folder.
58
     */
59
    public Result getAptOptions(FileObject file);
60
61
}
(-)a/java.api.common/apichanges.xml (+19 lines)
Lines 103-108 Link Here
103
    <!-- ACTUAL CHANGES BEGIN HERE: -->
103
    <!-- ACTUAL CHANGES BEGIN HERE: -->
104
    <changes>
104
    <changes>
105
    
105
    
106
        <change id="apt-query">
107
            <api name="java-api-common"/>
108
            <summary>Support for AptQuery</summary>
109
            <version major="1" minor="14"/>
110
            <date day="26" month="1" year="2010"/>
111
            <author login="jlahoda"/>
112
            <compatibility addition="yes"/>
113
            <description>
114
                <p>
115
                    Adding support for AptQuery, and related API changes.
116
                </p>
117
            </description>
118
            <class package="org.netbeans.modules.java.api.common.classpath" name="ClassPathProviderImpl"/>
119
            <class package="org.netbeans.modules.java.api.common.project" name="ProjectProperties"/>
120
            <class package="org.netbeans.modules.java.api.common.project.ui.customizer" name="EditMediator"/>
121
            <class package="org.netbeans.modules.java.api.common.queries" name="QuerySupport"/>
122
            <issue number="179749"/>
123
        </change>
124
106
        <change id="endorsed-classpath">
125
        <change id="endorsed-classpath">
107
            <api name="java-api-common"/>
126
            <api name="java-api-common"/>
108
            <summary>Add support for endorsed libraries</summary>
127
            <summary>Add support for endorsed libraries</summary>
(-)a/java.api.common/manifest.mf (-1 / +1 lines)
Lines 1-4 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.java.api.common/0
2
OpenIDE-Module: org.netbeans.modules.java.api.common/0
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.13
4
OpenIDE-Module-Specification-Version: 1.14
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ClassPathProviderImpl.java (-2 / +75 lines)
Lines 46-51 Link Here
46
import java.util.Map;
46
import java.util.Map;
47
import java.util.HashMap;
47
import java.util.HashMap;
48
import org.netbeans.api.java.classpath.ClassPath;
48
import org.netbeans.api.java.classpath.ClassPath;
49
import org.netbeans.api.java.classpath.JavaClassPathConstants;
49
import org.netbeans.api.project.ProjectManager;
50
import org.netbeans.api.project.ProjectManager;
50
import org.netbeans.api.project.SourceGroup;
51
import org.netbeans.api.project.SourceGroup;
51
import org.netbeans.modules.java.api.common.SourceRoots;
52
import org.netbeans.modules.java.api.common.SourceRoots;
Lines 71-76 Link Here
71
    private String distJar = "dist.jar"; // NOI18N
72
    private String distJar = "dist.jar"; // NOI18N
72
    private String buildTestClassesDir = "build.test.classes.dir"; // NOI18N
73
    private String buildTestClassesDir = "build.test.classes.dir"; // NOI18N
73
    private String[] javacClasspath = new String[]{"javac.classpath"};    //NOI18N
74
    private String[] javacClasspath = new String[]{"javac.classpath"};    //NOI18N
75
    private String[] processorClasspath = new String[]{ProjectProperties.JAVAC_PROCESSORPATH};    //NOI18N
74
    private String[] javacTestClasspath = new String[]{"javac.test.classpath"};  //NOI18N
76
    private String[] javacTestClasspath = new String[]{"javac.test.classpath"};  //NOI18N
75
    private String[] runClasspath = new String[]{"run.classpath"};    //NOI18N
77
    private String[] runClasspath = new String[]{"run.classpath"};    //NOI18N
76
    private String[] runTestClasspath = new String[]{"run.test.classpath"};  //NOI18N
78
    private String[] runTestClasspath = new String[]{"run.test.classpath"};  //NOI18N
Lines 93-100 Link Here
93
     * 6  -  execute class path for dist.jar
95
     * 6  -  execute class path for dist.jar
94
     * 7  -  boot class path
96
     * 7  -  boot class path
95
     * 8  -  endorsed class path
97
     * 8  -  endorsed class path
98
     * 9  -  processor path
99
     * 10  -  test processor path
96
     */
100
     */
97
    private final ClassPath[] cache = new ClassPath[9];
101
    private final ClassPath[] cache = new ClassPath[11];
98
102
99
    private final Map<String,FileObject> dirCache = new HashMap<String,FileObject>();
103
    private final Map<String,FileObject> dirCache = new HashMap<String,FileObject>();
100
104
Lines 143-153 Link Here
143
            String buildClassesDir, String distJar, String buildTestClassesDir,
147
            String buildClassesDir, String distJar, String buildTestClassesDir,
144
            String[] javacClasspath, String[] javacTestClasspath, String[] runClasspath,
148
            String[] javacClasspath, String[] javacTestClasspath, String[] runClasspath,
145
            String[] runTestClasspath, String[] endorsedClasspath) {
149
            String[] runTestClasspath, String[] endorsedClasspath) {
150
        this(helper,
151
            evaluator,
152
            sourceRoots,
153
            testSourceRoots,
154
            buildClassesDir,
155
            distJar,
156
            buildTestClassesDir,
157
            javacClasspath,
158
            javacClasspath,
159
            javacTestClasspath,
160
            runClasspath,
161
            runTestClasspath,
162
            new String[]{ProjectProperties.ENDORSED_CLASSPATH});
163
    }
164
165
    /**
166
     * Constructor allowing customization of processorPath.
167
     * @since org.netbeans.modules.java.api.common/0 1.14
168
     */
169
    public ClassPathProviderImpl(AntProjectHelper helper, PropertyEvaluator evaluator,
170
            SourceRoots sourceRoots, SourceRoots testSourceRoots,
171
            String buildClassesDir, String distJar, String buildTestClassesDir,
172
            String[] javacClasspath, String[] processorPath, String[] javacTestClasspath, String[] runClasspath,
173
            String[] runTestClasspath, String[] endorsedClasspath) {
146
        this(helper, evaluator, sourceRoots, testSourceRoots);
174
        this(helper, evaluator, sourceRoots, testSourceRoots);
147
        this.buildClassesDir = buildClassesDir;
175
        this.buildClassesDir = buildClassesDir;
148
        this.distJar = distJar;
176
        this.distJar = distJar;
149
        this.buildTestClassesDir = buildTestClassesDir;
177
        this.buildTestClassesDir = buildTestClassesDir;
150
        this.javacClasspath = javacClasspath;
178
        this.javacClasspath = javacClasspath;
179
        this.processorClasspath = processorPath;
151
        this.javacTestClasspath = javacTestClasspath;
180
        this.javacTestClasspath = javacTestClasspath;
152
        this.runClasspath = runClasspath;
181
        this.runClasspath = runClasspath;
153
        this.runTestClasspath = runTestClasspath;
182
        this.runTestClasspath = runTestClasspath;
Lines 270-275 Link Here
270
        return cp;
299
        return cp;
271
    }
300
    }
272
    
301
    
302
    private ClassPath getProcessorClasspath(FileObject file) {
303
        int type = getType(file);
304
        return this.getProcessorClasspath(type);
305
    }
306
307
    private synchronized ClassPath getProcessorClasspath(int type) {
308
        if (type < 0 || type > 1) {
309
            // Not a source file.
310
            return null;
311
        }
312
        ClassPath cp = cache[9+type];
313
        if ( cp == null) {
314
            if (type == 0) {
315
                cp = ClassPathFactory.createClassPath(
316
                    ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
317
                    projectDirectory, evaluator, processorClasspath)); // NOI18N
318
            }
319
            else {
320
                cp = ClassPathFactory.createClassPath(
321
                    ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
322
                    projectDirectory, evaluator, /*XXX*/processorClasspath)); // NOI18N
323
            }
324
            cache[9+type] = cp;
325
        }
326
        return cp;
327
    }
328
273
    private ClassPath getRunTimeClasspath(FileObject file) {
329
    private ClassPath getRunTimeClasspath(FileObject file) {
274
        int type = getType(file);
330
        int type = getType(file);
275
        if (type < 0 || type > 4) {
331
        if (type < 0 || type > 4) {
Lines 366-371 Link Here
366
    public ClassPath findClassPath(FileObject file, String type) {
422
    public ClassPath findClassPath(FileObject file, String type) {
367
        if (type.equals(ClassPath.COMPILE)) {
423
        if (type.equals(ClassPath.COMPILE)) {
368
            return getCompileTimeClasspath(file);
424
            return getCompileTimeClasspath(file);
425
        } else if (type.equals(JavaClassPathConstants.PROCESSOR_PATH)) {
426
            return getProcessorClasspath(file);
369
        } else if (type.equals(ClassPath.EXECUTE)) {
427
        } else if (type.equals(ClassPath.EXECUTE)) {
370
            return getRunTimeClasspath(file);
428
            return getRunTimeClasspath(file);
371
        } else if (type.equals(ClassPath.SOURCE)) {
429
        } else if (type.equals(ClassPath.SOURCE)) {
Lines 395-400 Link Here
395
                    l[1] = getCompileTimeClasspath(1);
453
                    l[1] = getCompileTimeClasspath(1);
396
                    return l;
454
                    return l;
397
                }
455
                }
456
                if (JavaClassPathConstants.PROCESSOR_PATH.equals(type)) {
457
                    ClassPath[] l = new ClassPath[2];
458
                    l[0] = getProcessorClasspath(0);
459
                    l[1] = getProcessorClasspath(1);
460
                    return l;
461
                }
398
                if (ClassPath.SOURCE.equals(type)) {
462
                if (ClassPath.SOURCE.equals(type)) {
399
                    ClassPath[] l = new ClassPath[2];
463
                    ClassPath[] l = new ClassPath[2];
400
                    l[0] = getSourcepath(0);
464
                    l[0] = getSourcepath(0);
Lines 417-422 Link Here
417
        if (ClassPath.COMPILE.equals(type)) {
481
        if (ClassPath.COMPILE.equals(type)) {
418
            return getCompileTimeClasspath(0);
482
            return getCompileTimeClasspath(0);
419
        }
483
        }
484
        if (JavaClassPathConstants.PROCESSOR_PATH.equals(type)) {
485
            return getProcessorClasspath(0);
486
        }
420
        if (ClassPath.SOURCE.equals(type)) {
487
        if (ClassPath.SOURCE.equals(type)) {
421
            return getSourcepath(0);
488
            return getSourcepath(0);
422
        }
489
        }
Lines 437-443 Link Here
437
            }
504
            }
438
            else if (ClassPath.EXECUTE.equals(type)) {
505
            else if (ClassPath.EXECUTE.equals(type)) {
439
                return runTestClasspath;
506
                return runTestClasspath;
440
            }
507
            }//XXX: processor path
441
            else {
508
            else {
442
                return null;
509
                return null;
443
            }
510
            }
Lines 449-454 Link Here
449
            else if (ClassPath.EXECUTE.equals(type)) {
516
            else if (ClassPath.EXECUTE.equals(type)) {
450
                return runClasspath;
517
                return runClasspath;
451
            }
518
            }
519
            else if (JavaClassPathConstants.PROCESSOR_PATH.equals(type)) {
520
                return processorClasspath;
521
            }
452
            else {
522
            else {
453
                return null;
523
                return null;
454
            }
524
            }
Lines 469-474 Link Here
469
                else if (ClassPath.EXECUTE.equals(type)) {
539
                else if (ClassPath.EXECUTE.equals(type)) {
470
                    return runClasspath;
540
                    return runClasspath;
471
                }
541
                }
542
                else if (JavaClassPathConstants.PROCESSOR_PATH.equals(type)) {
543
                    return processorClasspath;
544
                }
472
                else {
545
                else {
473
                    return null;
546
                    return null;
474
                }
547
                }
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/project/ProjectProperties.java (+21 lines)
Lines 53-59 Link Here
53
 */
53
 */
54
public final class ProjectProperties {
54
public final class ProjectProperties {
55
55
56
    /**
57
     * @since org.netbeans.modules.java.api.common/0 1.14
58
     */
59
    public static final String APT_ENABLED = "apt.enabled"; //NOI18N
60
    /**
61
     * @since org.netbeans.modules.java.api.common/0 1.14
62
     */
63
    public static final String APT_ENABLED_IN_EDITOR = "apt.enabled.in.editor"; //NOI18N
64
    /**
65
     * @since org.netbeans.modules.java.api.common/0 1.14
66
     */
67
    public static final String APT_RUN_ALL_PROCESSORS = "apt.run.all.processors"; //NOI18N
68
    /**
69
     * @since org.netbeans.modules.java.api.common/0 1.14
70
     */
71
    public static final String APT_PROCESSORS_LIST = "apt.processors.list"; //NOI18N
56
    public static final String JAVAC_CLASSPATH = "javac.classpath"; //NOI18N
72
    public static final String JAVAC_CLASSPATH = "javac.classpath"; //NOI18N
73
    /**
74
     * @since org.netbeans.modules.java.api.common/0 1.14
75
     */
76
    public static final String JAVAC_PROCESSORPATH = "javac.processorpath"; //NOI18N
57
    public static final String JAVAC_TEST_CLASSPATH = "javac.test.classpath"; // NOI18N
77
    public static final String JAVAC_TEST_CLASSPATH = "javac.test.classpath"; // NOI18N
58
    public static final String RUN_CLASSPATH = "run.classpath"; // NOI18N
78
    public static final String RUN_CLASSPATH = "run.classpath"; // NOI18N
59
    public static final String RUN_TEST_CLASSPATH = "run.test.classpath"; // NOI18N
79
    public static final String RUN_TEST_CLASSPATH = "run.test.classpath"; // NOI18N
Lines 63-68 Link Here
63
83
64
    public static final String[] WELL_KNOWN_PATHS = new String[] {
84
    public static final String[] WELL_KNOWN_PATHS = new String[] {
65
        "${" + JAVAC_CLASSPATH + "}", // NOI18N
85
        "${" + JAVAC_CLASSPATH + "}", // NOI18N
86
        "${" + JAVAC_PROCESSORPATH + "}", // NOI18N
66
        "${" + JAVAC_TEST_CLASSPATH + "}", // NOI18N
87
        "${" + JAVAC_TEST_CLASSPATH + "}", // NOI18N
67
        "${" + RUN_CLASSPATH + "}", // NOI18N
88
        "${" + RUN_CLASSPATH + "}", // NOI18N
68
        "${" + RUN_TEST_CLASSPATH + "}", // NOI18N
89
        "${" + RUN_TEST_CLASSPATH + "}", // NOI18N
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/customizer/EditMediator.java (-4 / +51 lines)
Lines 111-116 Link Here
111
    private final ButtonModel moveUp;
111
    private final ButtonModel moveUp;
112
    private final ButtonModel moveDown;
112
    private final ButtonModel moveDown;
113
    private final ButtonModel edit;
113
    private final ButtonModel edit;
114
    private final boolean allowRemoveClassPath;
114
    private Document libraryPath;
115
    private Document libraryPath;
115
    private ClassPathUiSupport.Callback callback;
116
    private ClassPathUiSupport.Callback callback;
116
    private AntProjectHelper helper;
117
    private AntProjectHelper helper;
Lines 131-136 Link Here
131
                         ButtonModel moveUp,
132
                         ButtonModel moveUp,
132
                         ButtonModel moveDown, 
133
                         ButtonModel moveDown, 
133
                         ButtonModel edit,
134
                         ButtonModel edit,
135
                         boolean allowRemoveClassPath,
134
                         Document libPath,
136
                         Document libPath,
135
                         ClassPathUiSupport.Callback callback,
137
                         ClassPathUiSupport.Callback callback,
136
                         String[] antArtifactTypes,
138
                         String[] antArtifactTypes,
Lines 157-162 Link Here
157
        this.filter = filter;
159
        this.filter = filter;
158
        this.fileSelectionMode = fileSelectionMode;
160
        this.fileSelectionMode = fileSelectionMode;
159
        this.antArtifactTypes = antArtifactTypes;
161
        this.antArtifactTypes = antArtifactTypes;
162
        this.allowRemoveClassPath = allowRemoveClassPath;
160
    }
163
    }
161
164
162
    public static void register(Project project,
165
    public static void register(Project project,
Lines 173-183 Link Here
173
                                Document libPath,
176
                                Document libPath,
174
                                ClassPathUiSupport.Callback callback) {    
177
                                ClassPathUiSupport.Callback callback) {    
175
        register(project, helper, refHelper, list, addJar, addLibrary, 
178
        register(project, helper, refHelper, list, addJar, addLibrary, 
176
                addAntArtifact, remove, moveUp, moveDown, edit, libPath, 
179
                addAntArtifact, remove, moveUp, moveDown, edit, false, libPath,
177
                callback, DEFAULT_ANT_ARTIFACT_TYPES, JAR_ZIP_FILTER, 
180
                callback);
181
    }
182
    
183
    public static void register(Project project,
184
                                AntProjectHelper helper,
185
                                ReferenceHelper refHelper,
186
                                ListComponent list,
187
                                ButtonModel addJar,
188
                                ButtonModel addLibrary,
189
                                ButtonModel addAntArtifact,
190
                                ButtonModel remove,
191
                                ButtonModel moveUp,
192
                                ButtonModel moveDown,
193
                                ButtonModel edit,
194
                                boolean allowRemoveClassPath,
195
                                Document libPath,
196
                                ClassPathUiSupport.Callback callback) {
197
        register(project, helper, refHelper, list, addJar, addLibrary,
198
                addAntArtifact, remove, moveUp, moveDown, edit, allowRemoveClassPath, libPath,
199
                callback, DEFAULT_ANT_ARTIFACT_TYPES, JAR_ZIP_FILTER,
178
                JFileChooser.FILES_AND_DIRECTORIES);
200
                JFileChooser.FILES_AND_DIRECTORIES);
179
    }
201
    }
180
    
202
203
    public static void register(Project project,
204
                                AntProjectHelper helper,
205
                                ReferenceHelper refHelper,
206
                                ListComponent list,
207
                                ButtonModel addJar,
208
                                ButtonModel addLibrary,
209
                                ButtonModel addAntArtifact,
210
                                ButtonModel remove,
211
                                ButtonModel moveUp,
212
                                ButtonModel moveDown,
213
                                ButtonModel edit,
214
                                Document libPath,
215
                                ClassPathUiSupport.Callback callback,
216
                                String[] antArtifactTypes,
217
                                FileFilter filter,
218
                                int fileSelectionMode) {
219
        register(project, helper, refHelper, list, addJar, addLibrary, addAntArtifact, remove, moveUp, moveDown, edit, false, libPath, callback, antArtifactTypes, filter, fileSelectionMode);
220
    }
221
222
    /**Added {@code allowRemoveClassPath} option that will allow the user to delete {@code ${javac.classpath}}.
223
     *
224
     * @since org.netbeans.modules.java.api.common/0 1.14
225
     */
181
    public static void register(Project project,
226
    public static void register(Project project,
182
                                AntProjectHelper helper,
227
                                AntProjectHelper helper,
183
                                ReferenceHelper refHelper,
228
                                ReferenceHelper refHelper,
Lines 189-194 Link Here
189
                                ButtonModel moveUp,
234
                                ButtonModel moveUp,
190
                                ButtonModel moveDown, 
235
                                ButtonModel moveDown, 
191
                                ButtonModel edit,
236
                                ButtonModel edit,
237
                                boolean allowRemoveClassPath,
192
                                Document libPath,
238
                                Document libPath,
193
                                ClassPathUiSupport.Callback callback,
239
                                ClassPathUiSupport.Callback callback,
194
                                String[] antArtifactTypes,
240
                                String[] antArtifactTypes,
Lines 206-211 Link Here
206
                                            moveUp,
252
                                            moveUp,
207
                                            moveDown,
253
                                            moveDown,
208
                                            edit,
254
                                            edit,
255
                                            allowRemoveClassPath,
209
                                            libPath,
256
                                            libPath,
210
                                            callback,
257
                                            callback,
211
                                            antArtifactTypes,
258
                                            antArtifactTypes,
Lines 409-415 Link Here
409
                if ( selectionModel.isSelectedIndex( i ) ) {
456
                if ( selectionModel.isSelectedIndex( i ) ) {
410
                    ClassPathSupport.Item item = (ClassPathSupport.Item)listModel.get( i );
457
                    ClassPathSupport.Item item = (ClassPathSupport.Item)listModel.get( i );
411
                    if ( item.getType() == ClassPathSupport.Item.TYPE_CLASSPATH ) {
458
                    if ( item.getType() == ClassPathSupport.Item.TYPE_CLASSPATH ) {
412
                        canRemove = false;
459
                        canRemove = allowRemoveClassPath;
413
                        break;
460
                        break;
414
                    }
461
                    }
415
                }
462
                }
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/queries/AptQueryImpl.java (+133 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.java.api.common.queries;
41
42
import java.beans.PropertyChangeEvent;
43
import java.beans.PropertyChangeListener;
44
import java.lang.ref.Reference;
45
import java.lang.ref.WeakReference;
46
import java.util.Arrays;
47
import java.util.HashSet;
48
import java.util.Set;
49
import javax.swing.event.ChangeListener;
50
import org.netbeans.api.java.queries.AptQuery.Result;
51
import org.netbeans.spi.java.queries.AptQueryImplementation;
52
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
53
import org.openide.filesystems.FileObject;
54
import org.openide.util.ChangeSupport;
55
import org.openide.util.WeakListeners;
56
57
/**
58
 *
59
 * @author lahvac
60
 */
61
final class AptQueryImpl implements AptQueryImplementation {
62
    
63
    private final PropertyEvaluator evaluator;
64
    private final String annotationProcessingEnabledProperty;
65
    private final String runAllAnnotationProcessorsProperty;
66
    private final String annotationProcessorsProperty;
67
    private final Set<String> properties;
68
69
    public AptQueryImpl(PropertyEvaluator evaluator, String annotationProcessingEnabledProperty, String runAllAnnotationProcessorsProperty, String annotationProcessorsProperty) {
70
        this.evaluator = evaluator;
71
        this.annotationProcessingEnabledProperty = annotationProcessingEnabledProperty;
72
        this.runAllAnnotationProcessorsProperty = runAllAnnotationProcessorsProperty;
73
        this.annotationProcessorsProperty = annotationProcessorsProperty;
74
        this.properties = new HashSet<String>(Arrays.asList(annotationProcessingEnabledProperty, runAllAnnotationProcessorsProperty, annotationProcessorsProperty));
75
    }
76
77
    private Reference<Result> cache;
78
79
    public synchronized Result getAptOptions(FileObject file) {
80
        Result current = cache != null ? cache.get() : null;
81
82
        if (current == null) {
83
            cache = new WeakReference<Result>(current = new ResultImpl());
84
        }
85
86
        return current;
87
    }
88
89
    private static final Set<String> TRUE = new HashSet<String>(Arrays.asList("true", "on", "1"));
90
    
91
    private final class ResultImpl implements Result, PropertyChangeListener {
92
93
        private final ChangeSupport cs = new ChangeSupport(this);
94
95
        public ResultImpl() {
96
            evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator));
97
        }
98
99
        public boolean annotationProcessingEnabled() {
100
            return TRUE.contains(evaluator.getProperty(annotationProcessingEnabledProperty));
101
        }
102
103
        public Iterable<? extends String> annotationProcessorsToRun() {
104
            if (TRUE.contains(evaluator.getProperty(runAllAnnotationProcessorsProperty))) {
105
                return null;
106
            }
107
108
            String processors = evaluator.getProperty(annotationProcessorsProperty);
109
110
            if (processors == null) {
111
                //TODO: what to do in this case?
112
                processors = "";
113
            }
114
115
            return Arrays.asList(processors.split(","));
116
        }
117
118
        public void addChangeListener(ChangeListener l) {
119
            cs.addChangeListener(l);
120
        }
121
122
        public void removeChangeListener(ChangeListener l) {
123
            cs.removeChangeListener(l);
124
        }
125
126
        public void propertyChange(PropertyChangeEvent evt) {
127
            if (evt.getPropertyName() == null || properties.contains(evt.getPropertyName())) {
128
                cs.fireChange();
129
            }
130
        }
131
132
    }
133
}
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java (-3 / +18 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
4
 * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved.
5
 *
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
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
7
 * General Public License Version 2 only ("GPL") or the Common
Lines 34-45 Link Here
34
 *
34
 *
35
 * Contributor(s):
35
 * Contributor(s):
36
 *
36
 *
37
 * Portions Copyrighted 2007 Sun Microsystems, Inc.
37
 * Portions Copyrighted 2007-2010 Sun Microsystems, Inc.
38
 */
38
 */
39
39
40
package org.netbeans.modules.java.api.common.queries;
40
package org.netbeans.modules.java.api.common.queries;
41
41
42
import org.netbeans.api.java.queries.AptQuery.Result;
42
import org.netbeans.modules.java.api.common.SourceRoots;
43
import org.netbeans.modules.java.api.common.SourceRoots;
44
import org.netbeans.spi.java.queries.AptQueryImplementation;
43
import org.netbeans.spi.java.queries.BinaryForSourceQueryImplementation;
45
import org.netbeans.spi.java.queries.BinaryForSourceQueryImplementation;
44
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
46
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
45
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
47
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
Lines 281-285 Link Here
281
                "build.classes.dir", "build.test.classes.dir"); // NOI18N
283
                "build.classes.dir", "build.test.classes.dir"); // NOI18N
282
    }
284
    }
283
    
285
    
284
    
286
    /**Create a new query to provide apt configuration data.
287
     * 
288
     * @param helper project's AntProjectHelper
289
     * @param evaluator project's evaluator
290
     * @param annotationProcessingEnabledProperty property whose value will be returned from {@link Result#annotationProcessingEnabled()}
291
     * @param runAllAnnotationProcessorsProperty when true, {@link Result#annotationProcessorsToRun()} will return null
292
     * @param annotationProcessorsProperty should contain comma separated list of annotation processors to run (will be returned from  {@link Result#annotationProcessorsToRun()})
293
     * @return a {@link AptQueryImplementation} to provide apt configuration data for this project.
294
     * @since org.netbeans.modules.java.api.common/0 1.14
295
     */
296
    public static AptQueryImplementation createAptQuery(AntProjectHelper helper, PropertyEvaluator evaluator,
297
            String annotationProcessingEnabledProperty, String runAllAnnotationProcessorsProperty, String annotationProcessorsProperty) {
298
        return new AptQueryImpl(evaluator, annotationProcessingEnabledProperty, runAllAnnotationProcessorsProperty, annotationProcessorsProperty);
299
    }
285
}
300
}
(-)a/java.project/src/org/netbeans/modules/java/project/ProjectAptQueryImpl.java (+67 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.java.project;
41
42
import org.netbeans.api.java.queries.AptQuery.Result;
43
import org.netbeans.api.project.FileOwnerQuery;
44
import org.netbeans.api.project.Project;
45
import org.netbeans.spi.java.queries.AptQueryImplementation;
46
import org.openide.filesystems.FileObject;
47
import org.openide.util.lookup.ServiceProvider;
48
49
/**
50
 *
51
 * @author lahvac
52
 */
53
@ServiceProvider(service=AptQueryImplementation.class,position=100)
54
public class ProjectAptQueryImpl implements AptQueryImplementation {
55
56
    public Result getAptOptions(FileObject file) {
57
        Project project = FileOwnerQuery.getOwner(file);
58
        if (project != null) {
59
            AptQueryImplementation slq = project.getLookup().lookup(AptQueryImplementation.class);
60
            if (slq != null) {
61
                return slq.getAptOptions(file);
62
            }
63
        }
64
        return null;
65
    }
66
67
}

Return to bug 179749