Migrating from TreeTableView to OutlineView

Here, based on an existing example, is how to migrate from "TreeTableView" to the new NetBeans Platform 6.5 "OutlineView":
  1. Install the Marilyn TreeTableView Sample.

  2. Create the sample, i.e., choose "Samples | Java | Marilyn" in the New Project wizard and complete the steps in the wizard.

  3. Add the following JARs from "platform9" folder in the NetBeans installation directory to the app's classpath: org-openide-actions.jar, org-openide-awt.jar, org-openide-dialogs.jar, org-openide-explorer.jar, org-openide-nodes.jar, org-openide-util.jar.

  4. Run the application to check everything is working and that you're set for migration.

  5. Open demo.MyFirstFrame.java in the Design view. Delete the Swing component you find there, which is the TreeTableView.

  6. Right-click in the Palette to the right of the Design view and choose Palette Manager. Click "Add from JAR" and browse to "org-openide-explorer.jar". From the list of available components, choose "OutlineView" and click Next. Add it to any palette category and then click Finish.

  7. From the "platform9" folder, add the org-netbeans-swing-outline.jar onto the app's classpath.

  8. From the category where you added the "OutlineView" component, drag it onto the JFrame. Then switch to the Source view.

  9. Change these lines:

    To these lines:


  10. Run the application again and now you have the same result as before, except that you're using "OutlineView" instead of "TreeTableView".

In other words, you're using the same concepts as before, i.e., the Nodes API, the ExplorerManager, and the NodeTableModel. However, the explorer view is changed to one that is not buggy (which was the original reason for replacing TreeTableView) and has a few extra features, based on the "Outline" component. These additional features will be discussed here soon.


It could be useful to have a screenshot of what the outline view looks like.

Posted by Vincent Cantin on August 15, 2008 at 11:36 AM PDT #

Same as the TreeTableView.

Posted by Geertjan on August 15, 2008 at 11:38 AM PDT #

You should mention for mac users how to find the jar files and add them to the classPath, due to a rather puzzling decision on how to distribute NetBeans.
On MacOS X, Netbeans is delivered as a 'package'. This is a folder which is presented to the user as if it were a single file. Therefore, I had a hell of a time finding the jar files you mentioned. Neither the system's indexed search feature (Spotlight) nor the unix 'locate' commands could find it, although the very slow unix 'find' command did get it.
The next problem is that when you try to add the classpath, the java file browser won't penetrate into the contents of the package. Adding the package seems to work, but the IDE still thinks the imported packages don't exist.
I haven't figured that out. I would appreciate help.

Posted by kevin Jaques on November 23, 2008 at 01:47 AM PST #

Here is a work around to the inability of NetBeans to penetrate its own Mac package structure to permit you to add JARs it contains to the ClassPath.
1. In Finder, control Click NetBeans application and choose, 'show package contents'.
2. in Finder, select the folder containing the NetBeans Application. Oddly, it comes locked down against any changes by administrators. So, 'get info', click the padlock, enter your administrator password, and then select 'read and write' access for administrators.
3. In Finder, option drag the 'contents' folder from the package contents to the Netbeans folder, making an alias.
4. Now, you can use the alias to permit Netbeans to access the contents of the Netbeans application package.
5. Remember to do this for every update. Prepare for frustration and confusion since you obviously won't remember that. Try renaming the alias to provide a hint.

Posted by kevin Jaques on November 23, 2008 at 02:26 AM PST #

NetBeans 6.5 did not contain org-openide-util.jar. It did contain org-openide-util-enumerations.jar. That didn't work. You can download this library from http://www.java2s.com/Code/Jar/netbeans-5.5/Downloadorgopenideutiljar.htm.
Note that it appears to be from a much prior version. Oh oh.
Anyway, on the Mac, Apple recommends that java Class Libraries get installed into either "/Library/Java/Extensions" or "~/Library/Java/Extensions". However, NetBeans doesn't see them there.
Adding the jar file as a new Library to Netbeans or adding the path to it under global library doesn't solve the problem. You must right click 'Libraries' under the project in the projects window, and choose 'add jar'.

Posted by Kevin Jaques on November 23, 2008 at 03:11 AM PST #

By the way, the math question must time out or something. It only works for me when I hit it very quickly after the page loads.

Posted by Kevin Jaques on November 23, 2008 at 03:12 AM PST #

The demo, prior to conversion, doesn't run. It complains of "no such method" regarding the 'mutex' method from the obsolete openIDE library I just posted about.
It says:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.openide.util.Mutex.<init>(Lorg/openide/util/Mutex$Privileged;Ljava/util/concurrent/Executor;)V
at org.openide.nodes.Children.<clinit>(Children.java:99)
at org.openide.nodes.Node.<clinit>(Node.java:111)
at org.openide.explorer.ExplorerManager.init(ExplorerManager.java:159)
at org.openide.explorer.ExplorerManager.<init>(ExplorerManager.java:153)
at demo.MyFirstFrame.<init>(MyFirstFrame.java:30)
at demo.MyFirstFrame$1.run(MyFirstFrame.java:96)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Posted by kevin Jaques on November 23, 2008 at 03:25 AM PST #

It would be completely impossible to run NetBeans IDE if it didn't contain org-openide-util.jar.

Posted by Geertjan on November 24, 2008 at 01:58 AM PST #

You removed the "treeTableView1.setRootVisible(false);" line in the ported version. Is it possible to hide the root node in the OutlineView? If this isn't possible directly, is there another way to achieve this, without using a custom tree model and Outline?

Posted by Achim on January 11, 2009 at 03:32 AM PST #

I found your 'completely impossible to run NetBeans IDE if it didn't contain org-openide-util.jar' remark very convincing.

So, I tried another way of looking. For the assistance of Mac Users, don't rely on Spotlight to find this, as it doesn't search inside packages. I used the free 'Notlight' and told it to search within the NetBeans package, and you were right.

I now have Netbeans 6.7.1, and it also has the file, at /Applications/NetBeans/NetBeans 6.7.1.app/Contents/Resources/NetBeans/platform10/lib/org-openide-util.jar.

Sorry about the delay, but I have been away from java for a time, and don't recall receiving notice of your reply.

Posted by Kevin Jaques on December 09, 2009 at 10:46 AM PST #

Hi Geertjan, Is there any restriction that an Outline view does not give Lookup of Nodes when a row in outline view is selected? I have a Bean Tree View in Explorer and an Outline View in Editor. Both display the same Node hierarchy. But Bean Tree View selection gives look up correctly, where as Outline View does not. regards Binu K Idiculka

Posted by Binu K Idicula on June 01, 2011 at 08:08 PM PDT #

Have tried this, and it works well when all columns are visible.
However, once one hides a column, and uses writeProperties and readProperties(after setting up the columns) the header renderer gives errors, and screws up the interface.
Only happens if 1 or more columns is marked as hidden, and we close and restart the program.

Posted by guest on July 30, 2012 at 08:10 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

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.


« June 2016