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 27895 - Redesign ContentDescriptor and ContainersList
Summary: Redesign ContentDescriptor and ContainersList
Status: CLOSED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P3 blocker (vote)
Assignee: Vitezslav Stejskal
URL:
Keywords: API
Depends on:
Blocks:
 
Reported: 2002-10-09 19:29 UTC by Vitezslav Stejskal
Modified: 2003-12-11 14:14 UTC (History)
0 users

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 Vitezslav Stejskal 2002-10-09 19:29:58 UTC
According to the feedback on dev@projects it seems
that design of ContentDescriptor and
ContainersList has serious flaws. In particular
the problems are:

1. ContentDescriptor.getContents() returns
Collection which is used as a kind of union type
structure

2. ContentDescriptor can support more MIME types
which makes anybody using it to write code like
the one below:

ContainersList l =
project.getContainersList().search("mimetype");
ContentDescriptor[] descs = l.getContents();
for (int i = 0; i < descs.length; i++) {
  Collection c = descs.getContents("mimetype");
}

3. it's hard to access ContentDescriptors provided
by single ProjectObject, one has to write:

Lookup.Result res =
container.getEnvironment().lookup(new 
Lookup.Template(ContentDescriptor.class));
for (Iterator it = res.allInstances().iterator();
it.hasNext(); ) {
   ContentDescriptor cd =
(ContentDescriptor)it.next();
   Collection c = cd.getContents(mimetype);
   for (Iterator it2 = c.iterator();
it2.hasNext(); ) {
     Object item = it2.next();
     // do some stuff with the item
   }
}

See the discussion on
http://projects.netbeans.org/servlets/ReadMsg?msgId=388662&listName=dev
Comment 1 Vitezslav Stejskal 2002-10-15 01:13:38 UTC
Done. 

ad 1. getContent() returns Object, the type of returned instance is
part of MIME type definition contract. For basic mime types defined by
infrastructure the instance of FileSet must be returned.

ad 2. ContentDescriptor can be registered for exactly one MIME type,
thus there is no need to pass the MIME type to methods of
ContentDescriptor anymore.

ad 3. Two ContainersList.findFor methods has been introduced, they
take Project and ProjectMember respectively. The code mentioned in
this point can be rewritten to:

ContentDescriptor cd [] =
ContainersList.findFor(container).search(mimeType);
Object item = cd[0].getContent();

ad 4. (mentioned on dev@projects) - the getVisualObject method still
exists, it helps implementors of ContentDescriptor contract to return
different visualObjects from different instances of single
implementation of ContentDescriptor, otherwise they would have to
create several classes extending CD.

CDs can be provided by either ProjectEnvironmentProviders or directly
by DataObjects on PFS (e.g. build targets). In latter case you can
either provide single instance of CD as a cookie or you can provide
instance of Lookup.Provider as a cookie and put several CDs in the lookup.
Comment 2 Vitezslav Stejskal 2003-07-10 13:08:05 UTC
verified
Comment 3 Jan Becicka 2003-11-25 14:22:18 UTC
As described in
http://www.netbeans.org/servlets/ReadMsg?msgId=619519&listName=nbdiscuss the
current work on projects prototype has been stopped.

Marking issue as CLOSED.