Restoring OutlineView Changes

Spent the last afternoons working with Ruben Hinojo, who I met recently at the Tinkerforge/NetBeans integration course in Germany. He's Spanish, lives in Scotland, and joined the course by flying from Edinburgh to Amsterdam and then driving from there to the course in Germany. Since then he spent some days in Amsterdam and we've been working a bit in a cafe in Amsterdam.

He's working freelance on a freight management system on the NetBeans Platform and here's a pic of him and his application:

I showed him a few things to improve the initial appearance of the application, such as removing the unneeded tab in the editor position and displaying data at startup so that the main window isn't empty initially.

He, in turn, told me about something I didn't know about, where "freightViewer" below is an OutlineView:

void writeProperties(java.util.Properties p) {
    // better to version settings since initial version as advocated at
    p.setProperty("version", "1.0");
    freightViewer.writeSettings(p, "FreightViewer");

void readProperties(java.util.Properties p) {
    String version = p.getProperty("version");
    freightViewer.readSettings(p, "FreightViewer");

The "" enables you to save/restore changes to an OutlineView, e.g., column width, column position, and which columns are displayed/hidden.

In the user dir, within the .settings file of the TopComponent (in config/Windows2Local/Components), you'll then find content like this, where the "FreightViewer" argument above is now the prefix of the name of each property element:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE properties PUBLIC "-//org.ruben.viewer//RubenViewer//EN" "">
    <property name="FreightViewerOutlineViewOutlineColumn-1-shortDescription" value="Type"/>
    <property name="FreightViewerETableColumn-1-HeaderValue" value="Type"/>
    <property name="FreightViewerColumnsNumber" value="3"/>
    <property name="FreightViewerETableColumn-0-PreferredWidth" value="75"/>
    <property name="FreightViewerETableColumn-2-HeaderValue" value="Description"/>
    <property name="version" value="1.0"/>
    <property name="FreightViewerETableColumn-2-SortRank" value="0"/>
    <property name="FreightViewerETableColumn-2-Width" value="122"/>
    <property name="FreightViewerETableColumn-0-ModelIndex" value="0"/>
    <property name="FreightViewerETableColumn-1-Width" value="123"/>
    <property name="FreightViewerHiddenColumnsNumber" value="0"/>
    <property name="FreightViewerETableColumn-0-SortRank" value="0"/>
    <property name="FreightViewerETableColumn-1-ModelIndex" value="1"/>
    <property name="FreightViewerETableColumn-1-PreferredWidth" value="75"/>
    <property name="FreightViewerETableColumn-0-Ascending" value="true"/>
    <property name="FreightViewerETableColumn-2-ModelIndex" value="2"/>
    <property name="FreightViewerETableColumn-1-Ascending" value="true"/>
    <property name="FreightViewerETableColumn-2-PreferredWidth" value="75"/>
    <property name="FreightViewerETableColumn-1-SortRank" value="0"/>
    <property name="FreightViewerETableColumn-0-HeaderValue" value="Nodes"/>
    <property name="FreightViewerETableColumn-2-Ascending" value="true"/>
    <property name="FreightViewerETableColumn-0-Width" value="122"/>
    <property name="FreightViewerOutlineViewOutlineColumn-2-shortDescription" value="Description"/>

NB: However, note as described in this issue, i.e., since 7.2, hiding a column isn't persisted and in fact causes problems. I replaced the org-openide-explorer.jar with a previous one, from 7.1.1, and then the problem was solved. But now the enhancements in the OutlineView since 7.2 are no longer present, of course. So, looking forward to seeing this problem fixed.



A good trick.

I am trying to do it with an outlineview conected to a root node displying data in database. But the OutlineView does not restore the content of the columns. The treeView in the left side is restored with all data in the database table, but the columns have no content. Data are displayed only in the tree

Comments will be very appreciate


Posted by Sabin on September 26, 2012 at 12:47 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.


« July 2016