# HG changeset patch # Parent e714bfe933e464b7a37c07b834fa7aa98b127d8f # User Jesse Glick Prefer to look up FileObject, not DataObject, in selections. diff --git a/projectui/src/org/netbeans/modules/project/ui/Hacks.java b/projectui/src/org/netbeans/modules/project/ui/Hacks.java --- a/projectui/src/org/netbeans/modules/project/ui/Hacks.java +++ b/projectui/src/org/netbeans/modules/project/ui/Hacks.java @@ -115,9 +115,8 @@ LOG.log(/*XXX for now*/Level.FINE, "Activated node selection {0} contains nonopen project {1} though none are open; leak? activated TC: {2} current nodes: {3} (report in issue #102805)", new Object[] {Arrays.toString(sel), p, r.getActivated(), Arrays.toString(r.getCurrentNodes())}); } } else { - DataObject d = l.lookup(DataObject.class); - if (d != null) { - FileObject f = d.getPrimaryFile(); + FileObject f = l.lookup(FileObject.class); + if (f != null) { p = FileOwnerQuery.getOwner(f); if (p != null) { projects.add(p); diff --git a/projectui/src/org/netbeans/modules/project/ui/actions/ActionsUtil.java b/projectui/src/org/netbeans/modules/project/ui/actions/ActionsUtil.java --- a/projectui/src/org/netbeans/modules/project/ui/actions/ActionsUtil.java +++ b/projectui/src/org/netbeans/modules/project/ui/actions/ActionsUtil.java @@ -81,22 +77,13 @@ * is one project with the command disabled it will return empty array. */ public static Project[] getProjectsFromLookup( Lookup lookup, String command ) { - /* - if ( lookupResultsCache == null ) { - lookupResultsCache = new LookupResultsCache( new Class[] { Project.class, DataObject.class } ); - } - - Project[] projectsArray = lookupResultsCache.getProjects( lookup ); - */ - // #74161: do not cache // First find out whether there is a project directly in the Lookup Set result = new HashSet(); for (Project p : lookup.lookupAll(Project.class)) { result.add(p); } - // Now try to guess the project from dataobjects - for (DataObject dObj : lookup.lookupAll(DataObject.class)) { - FileObject fObj = dObj.getPrimaryFile(); + // Now try to guess the project from files + for (FileObject fObj : lookup.lookupAll(FileObject.class)) { Project p = FileOwnerQuery.getOwner(fObj); if ( p != null ) { result.add( p ); @@ -121,8 +108,7 @@ */ public static FileObject[] getFilesFromLookup( Lookup lookup, Project project ) { HashSet result = new HashSet(); - for (DataObject dObj : lookup.lookupAll(DataObject.class)) { - FileObject fObj = dObj.getPrimaryFile(); + for (FileObject fObj : lookup.lookupAll(FileObject.class)) { Project p = FileOwnerQuery.getOwner(fObj); if ( p != null && p.equals( project ) ) { result.add( fObj );