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.

Bug 58639 - Load freeform subprojects lazily
Summary: Load freeform subprojects lazily
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant Freeform (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2005-05-06 00:17 UTC by Jesse Glick
Modified: 2005-09-05 09:50 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2005-05-06 00:17:40 UTC
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).
Comment 1 Jesse Glick 2005-05-06 18:24:55 UTC
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.
Comment 2 Jan Lahoda 2005-05-10 16:37:51 UTC
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
Comment 3 Jan Lahoda 2005-05-10 16:56:35 UTC
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