Feature Viewer (Part 1)

Run through the New Module wizard, run through the New Window Component wizard, drop a JEditorPane on the TopComponent, set its content type to text/html, add a dependency on Auto Update Services, and then stick this snippet to the end of your TopComponent constructor:

List featureUpdateUnit = UpdateManager.getDefault().getUpdateUnits(UpdateManager.TYPE.FEATURE);
StringBuilder sb = new StringBuilder();
sb.append("<table border=\\"1\\">");
sb.append("<tr><th>Feature</th><th>Details</th></tr>");
for (int i = 0; i < featureUpdateUnit.size(); i++) {
    UpdateUnit uu = (UpdateUnit) featureUpdateUnit.get(i);
    List<UpdateElement> el = uu.getAvailableUpdates();
    for (int j = 0; j < el.size(); j++) {
        String displayName = el.get(j).getDisplayName();
        String desc = el.get(j).getDescription();
        sb.append("" +
                "<tr>" +
                "<td>" + displayName + "</td>" +
                "<td>" + desc + "</td>" +
                "<tr>"
                );
    }
}
sb.append("</table>");

jEditorPane1.setText(sb.toString());

Install the module and then you have a feature viewer, especially useful for seeing which modules are currently available but not (yet) installed:

Next, work with the PrintCookie, as described here and here. And then... you will be able to create reports from the data retrieved from the Plugin Manager, which is something the Plugin Manager itself can't do. For example, here's a print preview:

Continue here for part 2.

Comments:

sb.append("" +
"<tr>" +
"<td>" + displayName + "</td>" +
"<td>" + desc + "</td>" +
"<tr>"
);

I think that you should not concatenate string in the StringBuilder's append method especially in the loop because of it will generate a lot of redundant StringBuilder for concatenating strings implicitly. So I think the following code snippet is better than the above :).

sb.append("<tr>");
sb.apppend("<td>").append(displayName).append("</td>");
sb.append("<td>").append(desc).append("</td>");
sb.append("</tr>");

Posted by Pan Feng on August 08, 2007 at 12:00 PM PDT #

Thanks!!

Posted by Geertjan on August 08, 2007 at 10:34 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today