X

Geertjan's Blog

  • August 15, 2008

Migrating from TreeTableView to OutlineView

Geertjan Wielenga
Product Manager
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:
    treeTableView1.setProperties(props);
    treeTableView1.setRootVisible(false);

    To these lines:

    outlineView1.setProperties(props);
    //treeTableView1.setRootVisible(false);

  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.

Join the discussion

Comments ( 12 )
  • Vincent Cantin Friday, August 15, 2008

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


  • Geertjan Friday, August 15, 2008

    Same as the TreeTableView.


  • kevin Jaques Sunday, November 23, 2008

    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.


  • kevin Jaques Sunday, November 23, 2008

    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.


  • Kevin Jaques Sunday, November 23, 2008

    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'.


  • Kevin Jaques Sunday, November 23, 2008

    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.


  • kevin Jaques Sunday, November 23, 2008

    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)


  • Geertjan Monday, November 24, 2008

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


  • Achim Sunday, January 11, 2009

    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?


  • Kevin Jaques Wednesday, December 9, 2009

    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.


  • Binu K Idicula Thursday, June 2, 2011
    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
  • guest Monday, July 30, 2012

    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.


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