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.
If you have a freeform project with a lot of dependencies (e.g. nbbuild/misc), it can take a while to compute its list of subprojects. However OpenSubprojects (projects/projectui) uses this code to check its enablement: SubprojectProvider spp = (SubprojectProvider)p.getLookup().lookup( SubprojectProvider.class ); if ( spp != null && spp.getSubprojects().iterator().hasNext() ) { someSubprojects = true; } Now if you merely show the context menu, currently all the subprojects actually get loaded, whereas the action only cares whether the set is empty or not. So the freeform SPP could be optimized to compute its list lazily, to avoid loading subprojects until it really needs to. Note: probably the action should be modified to say SubprojectProvider spp = (SubprojectProvider)p.getLookup().lookup( SubprojectProvider.class ); someSubprojects = spp != null && !spp.getSubprojects().isEmpty(); which would make the impl even a bit simpler since you would just need to override isEmpty(). Careful - a <project> can be listed in <subprojects> which does not correspond to a real dir, or whose dir does not hold a loadable project; SPP should obey the Set contract here (e.g. call to size() must try to load them all).
See also issue #58654, which seems similar. Possible alternative approaches: 1. Change the "Open Required Projects" action to always be enabled. If invoked and there are no required projects, simply display an informational dialog saying so. Simple and probably sufficient. 2. Add an extension interface SubprojectProvider2 which has a method boolean hasSubprojects(); which should be semantically equivalent to !getSubprojects().isEmpty() if possible but is permitted to give false positives (not false negatives), and use this new interface (when available) from OpenSubprojects. Petre/Jano your opinion please.
The freeform's subprojects are load lazily. The open subprojects action should be changed to use isEmpty() instead of iterator(): Checking in src/org/netbeans/modules/ant/freeform/Subprojects.java; /cvs/ant/freeform/src/org/netbeans/modules/ant/freeform/Subprojects.java,v <-- Subprojects.java new revision: 1.3; previous revision: 1.2 done Checking in test/unit/data/example-projects/extsrcroot/proj/nbproject/project.xml; /cvs/ant/freeform/test/unit/data/example-projects/extsrcroot/proj/nbproject/project.xml,v <-- project.xml new revision: 1.2; previous revision: 1.1 done Checking in test/unit/src/org/netbeans/modules/ant/freeform/SubprojectsTest.java; /cvs/ant/freeform/test/unit/src/org/netbeans/modules/ant/freeform/SubprojectsTest.java,v <-- SubprojectsTest.java new revision: 1.2; previous revision: 1.1 done
I have changed the OpenSubprojectsAction to use isEmpty(): Checking in OpenSubprojects.java; /cvs/projects/projectui/src/org/netbeans/modules/project/ui/actions/OpenSubprojects.java,v <-- OpenSubprojects.java new revision: 1.3; previous revision: 1.2 done