Restoring OutlineView Changes

Posted by Geertjan on Oracle Blogs See other posts from Oracle Blogs or by Geertjan
Published on Tue, 25 Sep 2012 19:59:07 +0000 Indexed on 2012/09/25 21:44 UTC
Read the original article Hit count: 186

Filed under:
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
    // http://wiki.apidesign.org/wiki/PropertyFiles
    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 "OutlineView.read/writeSettings" 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" "http://www.netbeans.org/dtds/properties-1_0.dtd">
<properties>
    <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"/>
</properties>

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.

© Oracle Blogs or respective owner

Related posts about /NetBeans IDE