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

(-)projects/projectapi/src/org/netbeans/api/project/ProjectManager.java (-1 / +1 lines)
Lines 308-314 Link Here
308
     * @return a project made from it, or null if it is not recognized
308
     * @return a project made from it, or null if it is not recognized
309
     * @throws IOException if there was a problem loading the project
309
     * @throws IOException if there was a problem loading the project
310
     */
310
     */
311
    private Project createProject(FileObject dir) throws IOException {
311
    public Project createProject(FileObject dir) throws IOException {
312
        assert dir != null;
312
        assert dir != null;
313
        assert dir.isFolder();
313
        assert dir.isFolder();
314
        assert mutex().isReadAccess();
314
        assert mutex().isReadAccess();
(-)projects/projectui/src/org/netbeans/modules/project/ui/ProjectsRootNode.java (-2 / +53 lines)
Lines 16-21 Link Here
16
import java.beans.PropertyChangeEvent;
16
import java.beans.PropertyChangeEvent;
17
import java.beans.PropertyChangeListener;
17
import java.beans.PropertyChangeListener;
18
import java.io.CharConversionException;
18
import java.io.CharConversionException;
19
import java.io.IOException;
19
import java.lang.ref.WeakReference;
20
import java.lang.ref.WeakReference;
20
import java.text.MessageFormat;
21
import java.text.MessageFormat;
21
import java.util.ArrayList;
22
import java.util.ArrayList;
Lines 33-38 Link Here
33
import javax.swing.event.ChangeListener;
34
import javax.swing.event.ChangeListener;
34
import org.netbeans.api.project.FileOwnerQuery;
35
import org.netbeans.api.project.FileOwnerQuery;
35
import org.netbeans.api.project.Project;
36
import org.netbeans.api.project.Project;
37
import org.netbeans.api.project.ProjectManager;
36
import org.netbeans.api.project.ProjectUtils;
38
import org.netbeans.api.project.ProjectUtils;
37
import org.netbeans.api.project.Sources;
39
import org.netbeans.api.project.Sources;
38
import org.netbeans.spi.project.ui.LogicalViewProvider;
40
import org.netbeans.spi.project.ui.LogicalViewProvider;
Lines 40-46 Link Here
40
import org.openide.filesystems.FileObject;
42
import org.openide.filesystems.FileObject;
41
import org.openide.filesystems.Repository;
43
import org.openide.filesystems.Repository;
42
import org.openide.loaders.DataFolder;
44
import org.openide.loaders.DataFolder;
43
import org.openide.loaders.DataObject;
44
import org.openide.loaders.FolderLookup;
45
import org.openide.loaders.FolderLookup;
45
import org.openide.nodes.AbstractNode;
46
import org.openide.nodes.AbstractNode;
46
import org.openide.nodes.Children;
47
import org.openide.nodes.Children;
Lines 239-245 Link Here
239
                }
240
                }
240
            }
241
            }
241
            else {
242
            else {
242
                nodes = new Node[] { lvp.createLogicalView() };
243
                Node logical = lvp.createLogicalView();
244
                nodes = new Node[] { new FilterNode ( logical,
245
                        new SubprojectFilterChildren( logical, project )) };
243
                if (nodes[0].getLookup().lookup(Project.class) != project) {
246
                if (nodes[0].getLookup().lookup(Project.class) != project) {
244
                    // Various actions, badging, etc. are not going to work.
247
                    // Various actions, badging, etc. are not going to work.
245
                    ErrorManager.getDefault().log(ErrorManager.WARNING, "Warning - project " + ProjectUtils.getInformation(project).getName() + " failed to supply itself in the lookup of the root node of its own logical view"); // NOI18N
248
                    ErrorManager.getDefault().log(ErrorManager.WARNING, "Warning - project " + ProjectUtils.getInformation(project).getName() + " failed to supply itself in the lookup of the root node of its own logical view"); // NOI18N
Lines 376-381 Link Here
376
            return delegate.objectsToSearch();
379
            return delegate.objectsToSearch();
377
        }
380
        }
378
        
381
        
382
    }
383
    
384
    private static final class SubprojectFilterChildren extends Children.Keys {
385
        private final Node orig;
386
        private final Project proj;
387
        SubprojectFilterChildren (Node orig, Project p) {
388
            this.orig = orig;
389
            this.proj = p;
390
        }
391
392
        protected Node[] createNodes(Object key) {
393
            Node n = (Node) key;
394
            return new Node[] { new FilterNode (n) };
395
        }
396
397
        protected void addNotify() {
398
            final List keys = new ArrayList (
399
                    Arrays.asList(orig.getChildren().getNodes()));
400
401
            final FileObject[] kids = proj.getProjectDirectory().getChildren();
402
            final ProjectManager mgr = ProjectManager.getDefault();
403
            Runnable findProjects = new Runnable() {
404
                public void run() {
405
                    for (int i=0; i < kids.length; i++) {
406
                        if (kids[i].isFolder() && mgr.isProject (kids[i])) {
407
                            try {
408
                                Project p = mgr.createProject(kids[i]);
409
410
                                LogicalViewProvider lvp = (LogicalViewProvider)
411
                                    p.getLookup().lookup (
412
                                    LogicalViewProvider.class );
413
414
                                if (lvp != null) {
415
                                    Node n = lvp.createLogicalView();
416
                                    keys.add ( new FilterNode ( n,
417
                                            new SubprojectFilterChildren( n, p )) );
418
                                }
419
                            } catch ( IOException ioe ) {
420
                                ErrorManager.getDefault().notify (
421
                                        ErrorManager.INFORMATIONAL, ioe);
422
                            }
423
                        }
424
                    }
425
                }
426
            };
427
            mgr.mutex().readAccess(findProjects);
428
            setKeys (keys);
429
        }
379
    }
430
    }
380
    
431
    
381
}
432
}

Return to bug 77766