X

Geertjan's Blog

  • January 16, 2008

Source File Visualizers

Geertjan Wielenga
Product Manager
The history of source file visualizers on the NetBeans Platform consists, in addition to the UML, Visual Web, and Mobility support, of three significant moments—Vadiraj Deshpande's Part 3 - XML Multiview + Visual Library, Toni Epple's A Visual Datbase Explorer for NetBeans, and Damir Tesanovic's
DDL Visualizer - Visualize sql script with NetBeans
.

Of them all, I've looked most closely at the latter of the three, recently. The basic framework of a visualizer can be extracted from that blog entry. Then one needs to incorporate some way of parsing the source in question. For HTML, you'd need some kind of HTML parser, etc. (By the way, the NetBeans APIs provide an HTML parser too, did you know that? See the HTML Lexer API, and the isHyperlinkPoint class in the NetBeans Hyperlink Navigation Tutorial.) If you want to parse XML files, see the NetBeans XML Editor Extension Module Tutorial, because that tutorial includes complete code for an XML parser. For parsing Java source files, the NetBeans Java Language Infrastructure Tutorial is incredibly useful. By combining the code from that tutorial with the information from Damir Tesanovic's blog entry, I made a visualizer for Java source files:

The visual scene shows information about the constructor, methods, and fields of a class. The scene is created when you right-click inside a Java source file and choose "Visualize". Then a new TopComponent opens, with a Visual Library API scene created within it, and then the nodes are added to the scene, with the pins added to the nodes.

If you are creating a visualizer, I recommend working backwards through the three blog entries listed above. Start with the one by Damir Tesanovic, then the one by Toni Epple, and then look through the one by Vadiraj Deshpande.

Join the discussion

Comments ( 9 )
  • guest Wednesday, January 16, 2008

    Will you be releasing this as a netbeans module?


  • Geertjan Wednesday, January 16, 2008

    Maybe I'm mistaken, but I think the Reverse Engineer menu item on Java files (i.e., this is UML) does the job already. Or do you need this for something specific, 160.91.44.54?


  • dabar Thursday, January 17, 2008

    Hi Geertjan, am sorry this comment is off the topic but i saw the DJ Native swing project and was hoping for a netbeans plugin that can allow one to preview HTML files within Netbeans so that as I edit in Netbeans, I can click on a button and then a tab showing the preview of my HTML opens that uses the DJ component internally. Any such thing in perspective soon? Will it be trivial to build


  • dabar Thursday, January 17, 2008

    Hi I have put something together but I dont know how to continue from thier. Please provide me links on how I can trigger editor action, write clean-up code when an editor is closed.

    I have a screenshot at http://blog.dabarobjects.com/?p=27

    Thanks


  • Geertjan Thursday, January 17, 2008

    Can you send me all your sources in a ZIP? I've created the other half...


  • Geertjan Thursday, January 17, 2008

    Actually, why don't you read the blog entries I referred to above? The one by Damir Tesanovic should give you everything you need.


  • dabar Thursday, January 17, 2008

    I have uploaded the zip of what I have here http://www.dabarobjects.com/downloads/DJHTMLViewer.zip. Actually my headache has being how to plug in the NativeCode Initialization routine which is supposed to be called at the init of the GUI application. I used ModuleInstall but it is not yet stable, it loads up, works a bit and the test platform stops responding after a while. I think you may also need to get the DJ libraries to resolve the project dependencies


  • Geertjan Thursday, January 17, 2008

    Thanks. Looking at your code now. See my today's blog entry for my progress, but using a different 3rd party library.


  • Geertjan Thursday, January 17, 2008

    It's going to take me some time to set up the DJ native browser and then to learn how to use it. Hoping to do it by the end of the weekend. Hope that's acceptable. In general though, my guess is you shouldn't be using a module installer at all. But that's just a guess.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.