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 146852
Collapse All | Expand All

(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java (-1 / +1 lines)
Lines 274-280 Link Here
274
            UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()),
274
            UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()),
275
            QuerySupport.createUnitTestForSourceQuery(getSourceRoots(), getTestSourceRoots()),
275
            QuerySupport.createUnitTestForSourceQuery(getSourceRoots(), getTestSourceRoots()),
276
            QuerySupport.createSourceLevelQuery(evaluator()),
276
            QuerySupport.createSourceLevelQuery(evaluator()),
277
            new J2SESources (this.helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
277
            new J2SESources(this, helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
278
            QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
278
            QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
279
            QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
279
            QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
280
            new RecommendedTemplatesImpl (this.updateHelper),
280
            new RecommendedTemplatesImpl (this.updateHelper),
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SESources.java (-15 / +6 lines)
Lines 53-58 Link Here
53
import org.netbeans.api.project.ProjectManager;
53
import org.netbeans.api.project.ProjectManager;
54
import org.netbeans.api.project.FileOwnerQuery;
54
import org.netbeans.api.project.FileOwnerQuery;
55
import org.netbeans.api.java.project.JavaProjectConstants;
55
import org.netbeans.api.java.project.JavaProjectConstants;
56
import org.netbeans.api.project.Project;
56
import org.netbeans.modules.java.api.common.SourceRoots;
57
import org.netbeans.modules.java.api.common.SourceRoots;
57
import org.netbeans.spi.project.support.GenericSources;
58
import org.netbeans.spi.project.support.GenericSources;
58
import org.netbeans.spi.project.support.ant.SourcesHelper;
59
import org.netbeans.spi.project.support.ant.SourcesHelper;
Lines 71-90 Link Here
71
    private static final String BUILD_DIR_PROP = "${" + J2SEProjectProperties.BUILD_DIR + "}";    //NOI18N
72
    private static final String BUILD_DIR_PROP = "${" + J2SEProjectProperties.BUILD_DIR + "}";    //NOI18N
72
    private static final String DIST_DIR_PROP = "${" + J2SEProjectProperties.DIST_DIR + "}";    //NOI18N
73
    private static final String DIST_DIR_PROP = "${" + J2SEProjectProperties.DIST_DIR + "}";    //NOI18N
73
74
75
    private final Project project;
74
    private final AntProjectHelper helper;
76
    private final AntProjectHelper helper;
75
    private final PropertyEvaluator evaluator;
77
    private final PropertyEvaluator evaluator;
76
    private final SourceRoots sourceRoots;
78
    private final SourceRoots sourceRoots;
77
    private final SourceRoots testRoots;
79
    private final SourceRoots testRoots;
78
    private SourcesHelper sourcesHelper;
80
    private SourcesHelper sourcesHelper;
79
    private Sources delegate;
81
    private Sources delegate;
80
    /**
81
     * Flag to forbid multiple invocation of {@link SourcesHelper#registerExternalRoots} 
82
     **/
83
    private boolean externalRootsRegistered;    
84
    private final ChangeSupport changeSupport = new ChangeSupport(this);
82
    private final ChangeSupport changeSupport = new ChangeSupport(this);
85
83
86
    J2SESources(AntProjectHelper helper, PropertyEvaluator evaluator,
84
    J2SESources(Project project, AntProjectHelper helper, PropertyEvaluator evaluator,
87
                SourceRoots sourceRoots, SourceRoots testRoots) {
85
                SourceRoots sourceRoots, SourceRoots testRoots) {
86
        this.project = project;
88
        this.helper = helper;
87
        this.helper = helper;
89
        this.evaluator = evaluator;
88
        this.evaluator = evaluator;
90
        this.sourceRoots = sourceRoots;
89
        this.sourceRoots = sourceRoots;
Lines 151-170 Link Here
151
    }
150
    }
152
    
151
    
153
    private Sources initSources() {
152
    private Sources initSources() {
154
        this.sourcesHelper = new SourcesHelper(helper, evaluator);   //Safe to pass APH        
153
        this.sourcesHelper = new SourcesHelper(project, helper, evaluator);   //Safe to pass APH
155
        register(sourceRoots);
154
        register(sourceRoots);
156
        register(testRoots);
155
        register(testRoots);
157
        this.sourcesHelper.addNonSourceRoot(BUILD_DIR_PROP);
156
        this.sourcesHelper.addNonSourceRoot(BUILD_DIR_PROP);
158
        this.sourcesHelper.addNonSourceRoot(DIST_DIR_PROP);
157
        this.sourcesHelper.addNonSourceRoot(DIST_DIR_PROP);
159
        externalRootsRegistered = false;
158
        sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
160
        ProjectManager.mutex().postWriteRequest(new Runnable() {
161
            public void run() {                
162
                if (!externalRootsRegistered) {
163
                    sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
164
                    externalRootsRegistered = true;
165
                }
166
            }
167
        });
168
        return this.sourcesHelper.createSources();
159
        return this.sourcesHelper.createSources();
169
    }
160
    }
170
161
(-)a/project.ant/src/org/netbeans/spi/project/support/ant/SourcesHelper.java (-9 / +32 lines)
Lines 74-79 Link Here
74
import org.openide.filesystems.FileStateInvalidException;
74
import org.openide.filesystems.FileStateInvalidException;
75
import org.openide.filesystems.FileUtil;
75
import org.openide.filesystems.FileUtil;
76
import org.openide.util.ChangeSupport;
76
import org.openide.util.ChangeSupport;
77
import org.openide.util.Parameters;
77
import org.openide.util.WeakListeners;
78
import org.openide.util.WeakListeners;
78
79
79
// XXX should perhaps be legal to call add* methods at any time (should update things)
80
// XXX should perhaps be legal to call add* methods at any time (should update things)
Lines 98-104 Link Here
98
            if (val == null) {
99
            if (val == null) {
99
                return null;
100
                return null;
100
            }
101
            }
101
            return project.resolveFile(val);
102
            return aph.resolveFile(val);
102
        }
103
        }
103
        public Collection<FileObject> getIncludeRoots() {
104
        public Collection<FileObject> getIncludeRoots() {
104
            File loc = getActualLocation();
105
            File loc = getActualLocation();
Lines 285-291 Link Here
285
        }
286
        }
286
    }
287
    }
287
    
288
    
288
    private final AntProjectHelper project;
289
    private final AntProjectHelper aph;
290
    private final Project project;
289
    private final PropertyEvaluator evaluator;
291
    private final PropertyEvaluator evaluator;
290
    private final List<SourceRoot> principalSourceRoots = new ArrayList<SourceRoot>();
292
    private final List<SourceRoot> principalSourceRoots = new ArrayList<SourceRoot>();
291
    private final List<Root> nonSourceRoots = new ArrayList<Root>();
293
    private final List<Root> nonSourceRoots = new ArrayList<Root>();
Lines 304-314 Link Here
304
    /**
306
    /**
305
     * Create the helper object, initially configured to recognize only sources
307
     * Create the helper object, initially configured to recognize only sources
306
     * contained inside the project directory.
308
     * contained inside the project directory.
307
     * @param project an Ant project helper
309
     * @param aph an Ant project helper
308
     * @param evaluator a way to evaluate Ant properties used to define source locations
310
     * @param evaluator a way to evaluate Ant properties used to define source locations
311
     * @deprecated Rather use {@link #SourcesHelper(Project, AntProjectHelper, PropertyEvaluator)}.
309
     */
312
     */
310
    public SourcesHelper(AntProjectHelper project, PropertyEvaluator evaluator) {
313
    @Deprecated
314
    public SourcesHelper(AntProjectHelper aph, PropertyEvaluator evaluator) {
315
        this.project = null;
316
        this.aph = aph;
317
        this.evaluator = evaluator;
318
    }
319
    
320
    /**
321
     * Create the helper object, initially configured to recognize only sources
322
     * contained inside the project directory.
323
     * @param project the project object (need not yet be registered in {@link ProjectManager})
324
     * @param aph an Ant project helper
325
     * @param evaluator a way to evaluate Ant properties used to define source locations
326
     * @since XXX
327
     */
328
    public SourcesHelper(Project project, AntProjectHelper aph, PropertyEvaluator evaluator) {
329
        Parameters.notNull("project", project);
311
        this.project = project;
330
        this.project = project;
331
        this.aph = aph;
312
        this.evaluator = evaluator;
332
        this.evaluator = evaluator;
313
    }
333
    }
314
    
334
    
Lines 462-468 Link Here
462
    }
482
    }
463
    
483
    
464
    private Project getProject() {
484
    private Project getProject() {
465
        return AntBasedProjectFactorySingleton.getProjectFor(project);
485
        return project != null ? project : AntBasedProjectFactorySingleton.getProjectFor(aph);
466
    }
486
    }
467
    
487
    
468
    /**
488
    /**
Lines 496-506 Link Here
496
     * {@link FileOwnerQuery#EXTERNAL_ALGORITHM_TRANSIENT}.
516
     * {@link FileOwnerQuery#EXTERNAL_ALGORITHM_TRANSIENT}.
497
     * </p>
517
     * </p>
498
     * <p>
518
     * <p>
499
     * You may <em>not</em> call this method inside the project's constructor, as
519
     * If you used the old constructor form
500
     * it requires the actual project to exist and be registered in {@link ProjectManager}.
520
     * {@link #SourcesHelper(AntProjectHelper, PropertyEvaluator)}
501
     * Typically you would use {@link org.openide.util.Mutex#postWriteRequest} to run it
521
     * then you may <em>not</em> call this method inside the project's constructor, as
522
     * it requires the actual project to exist and be registered in {@link ProjectManager};
523
     * in this case you could still use {@link org.openide.util.Mutex#postWriteRequest} to run it
502
     * later, if you were creating the helper in your constructor, since the project construction
524
     * later, if you were creating the helper in your constructor, since the project construction
503
     * normally occurs in read access.
525
     * normally occurs in read access.
526
     * Better to use {@link #SourcesHelper(Project, AntProjectHelper, PropertyEvaluator)}.
504
     * </p>
527
     * </p>
505
     * @param algorithm an external root registration algorithm as per
528
     * @param algorithm an external root registration algorithm as per
506
     *                  {@link FileOwnerQuery#markExternalOwner}
529
     *                  {@link FileOwnerQuery#markExternalOwner}
Lines 521-527 Link Here
521
        allRoots.addAll(nonSourceRoots);
544
        allRoots.addAll(nonSourceRoots);
522
        allRoots.addAll(ownedFiles);
545
        allRoots.addAll(ownedFiles);
523
        Project p = getProject();
546
        Project p = getProject();
524
        FileObject pdir = project.getProjectDirectory();
547
        FileObject pdir = aph.getProjectDirectory();
525
        // First time: register roots and add to lastRegisteredRoots.
548
        // First time: register roots and add to lastRegisteredRoots.
526
        // Subsequent times: add to newRootsToRegister and maybe add them later.
549
        // Subsequent times: add to newRootsToRegister and maybe add them later.
527
        if (lastRegisteredRoots == null) {
550
        if (lastRegisteredRoots == null) {

Return to bug 146852