Lookup Viewer

The Maven integrated view that I showed yesterday I was able to create because I happened to know that an implementation of SubprojectProvider and LogicalViewProvider are in the Lookup of Maven projects. With that knowledge, I was able to use and even delegate to those implementations. But what if you don't know that those implementations are in the Lookup of the Project object? In the case of the Maven Project implementation, you could look in the source code of the Maven Project implementation, at the "getLookup" method. However, any other module could be putting its own objects into that Lookup, dynamically, i.e., at runtime. So there's no way of knowing what's in the Lookup of any Project object or any other object with a Lookup.

But now imagine that you have a Lookup Viewer, as a tool during development, which you would exclude when distributing the application. Whenever new objects are found in the Lookup, the viewer displays them. You could install the Lookup Viewer into NetBeans IDE, or any other NetBeans Platform application, and then get a quick impression of what's actually in the Lookup when you select a different item in the application during development.

Here it is (though I vaguely remember someone else writing something similar):

Above, a Maven Project is selected. The Lookup Window shows that, among many other classes, an implementation of SubprojectProvider and LogicalViewProvider are found in the Lookup when the Maven Project is selected. If an item in the Lookup Window has its own Lookup, the content of that Lookup is displayed as child nodes of the Lookup, etc, i.e., you can explore all the way down the Lookup of each item found within objects found within the current selection. (What's especially fun is seeing the SaveCookieImpl being added and removed from the Lookup Window when you make/save a change in a document.)

Another example is below, showing the Lookup Window installed in a custom application created during a course at MIT in Boston:

A small trick I had to apply is that, when a Node in the Lookup Window is selected, I always show the previous Lookup, since the current Lookup, when you select one of the Nodes in the Lookup Window, would be the Lookup of the Lookup Window itself! If anyone is interested in this, I can publish the NetBeans module providing the above window to the NetBeans update center. 

Comments:

I used the Bean Browser plugin in the past. Unfortunately I don't know where to download the binary. The source code is at http://hg.netbeans.org/main/contrib/file/7ceebbb201a7/apisupport.beanbrowser

A short web search also revealed this plugin:
http://plugins.netbeans.org/plugin/44971/netbeans-lookupinspector

Posted by holger.stenger@gmx.de on November 04, 2012 at 08:41 AM PST #

> Here it is (though I vaguely remember someone else writing something similar):
Yes Geertjan, that was my plugin.
http://plugins.netbeans.org/plugin/44971/netbeans-lookupinspector

> If anyone is interested in this, I can publish the NetBeans module providing the above window to the NetBeans update center.
Yes, please publish it there! Please create it as signed plugin so it be downloaded from the IDE.

Greetings

Posted by guest on November 05, 2012 at 04:24 AM PST #

Sources are here:

java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.2/misc/LookupViewer

Posted by Geertjan on November 06, 2012 at 03:43 AM PST #

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
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today