This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 216316 - Outline Table headers fail to render on restart when we persisted a HIDDEN column through restart.
Summary: Outline Table headers fail to render on restart when we persisted a HIDDEN co...
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Outline&TreeTable (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P3 normal with 5 votes (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-02 10:30 UTC by dirving
Modified: 2013-06-04 01:47 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dirving 2012-08-02 10:30:59 UTC
ERROR rendering Outline after hiding columns, and persisting through an application shutdown.
i.e.
THE IMPORTANT ITEM TO LOOK AT IS THE ModelIndex.

The first time we start the program we create an Outline table with 4 columns.
The table columns might be set in alphabetical order, so the modelindex references for the columns get swapped around.

We are using the 
@ConvertAsProperties(dtd = "-//com.crispin.icost.gui//CVSMapper//EN",
autostore = false)
annotation type for persistance methodology.

We close the program, and call Outline.writeSettings(p,"partsviewe2");
as part of the window persistance work.

Initially the property set looks like the following.

<properties>

    <property name="partsview2ColumnsNumber" value="4"/>
    <property name="partsview2HiddenColumnsNumber" value="0"/>

    <property name="partsview2ETableColumn-0-HeaderValue" value="Parts/Sizes"/>
    <property name="partsview2ETableColumn-0-ModelIndex" value="0"/>

    <property name="partsview2ETableColumn-1-HeaderValue" value="# (pp)"/>
    <property name="partsview2ETableColumn-1-ModelIndex" value="1"/>

    <property name="partsview2ETableColumn-2-HeaderValue" value="MtNm"/>
    <property name="partsview2ETableColumn-2-ModelIndex" value="2"/>

    <property name="partsview2ETableColumn-3-HeaderValue" value="MnRt"/>
    <property name="partsview2ETableColumn-3-ModelIndex" value="3"/>

</properties>

On restarting the program the table is now defined from the readSettings(p,prefix) 

Our ETable model contained 4 items, hence ModelIndex up to 3.

This time we hide one column.
We close the program once again using 
Outline.writeSettings(Properties p, String prefix) to persist the settings.

The property set now looks like...

<properties>

    <property name="partsview2ColumnsNumber" value="3"/> <!-- 3 only, not 4 -->
    <property name="partsview2HiddenColumnsNumber" value="1"/>


    <property name="partsview2ETableColumn-0-HeaderValue" value="Parts/Sizes"/>
    <property name="partsview2ETableColumn-0-ModelIndex" value="0"/>

    <property name="partsview2ETableColumn-1-HeaderValue" value="# (pp)"/>
    <property name="partsview2ETableColumn-1-ModelIndex" value="1"/>

    <property name="partsview2ETableColumn-2-HeaderValue" value="MtNm"/>
    <property name="partsview2ETableColumn-2-ModelIndex" value="2"/>

    <property name="partsview2HiddenETableColumn-0-HeaderValue" value="MnRt"/>
    <property name="partsview2HiddenETableColumn-0-ModelIndex" value="3"/>
    <property name="partsview2HiddenPositionETableColumn-0" value="3"/>

</properties>

NOTE THAT THE last PROPERTY STILL HAS A MODEL_INDEX of 3.

When we now restart the program, the ETableModel appears to be created from the count of visible columns,
and the hidden columns are added to a list of hidden columns.

so the ETableModel now only has 3 columns, (i.e. max index of 2. 
It does not now have an index of '3').

When we come to render the get the RawColumnName we get an exception from one of the columns. it gets passed a column index of '3' and fails.
(I am guessing that if the model indexes that get persisted in the visible list of columns refers to a 
column number that is not rebuild on restart, that is what created the problem.
i.e. we re-created the table with only 3 columns, but one of our visible columns refers to a column
no longer visible.

The rendering fails and the Outline window is messed up on restart if a column is hidden.


java.lang.ArrayIndexOutOfBoundsException: 1
	at org.openide.explorer.view.PropertiesRowModel.getRawColumnName(PropertiesRowModel.java:282)
	at org.openide.explorer.view.OutlineView$OutlineViewOutline$OutlineViewOutlineColumn.getRawColumnName(OutlineView.java:2067)
	at org.openide.explorer.view.OutlineView$OutlineViewOutline.transformValue(OutlineView.java:1772)
	at org.netbeans.swing.etable.ColumnSelectionPanel.layoutPanel(ColumnSelectionPanel.java:153)
	at org.netbeans.swing.etable.ColumnSelectionPanel.<init>(ColumnSelectionPanel.java:112)
	at org.netbeans.swing.etable.ColumnSelectionPanel.showColumnSelectionDialog(ColumnSelectionPanel.java:397)
	at org.netbeans.swing.etable.ColumnSelectionPanel.showColumnSelectionPopupOrDialog(ColumnSelectionPanel.java:261)
	at org.netbeans.swing.etable.ETable$1.actionPerformed(ETable.java:1079)
	---

This does not happen if all columns are left visible.
Comment 1 dirving 2012-08-02 10:32:26 UTC
during the restart we use outline.readSettings(p,prefix) and nothing else to reget the column data.
Comment 2 nfiedler 2013-02-25 14:51:19 UTC
Regarding the Platform setting on this bug report, I'm seeing this on Mac as well. This is not a Windows-specific bug, in case anyone took it to be the case.
Comment 3 Martin Entlicher 2013-06-03 06:34:41 UTC
Fixed by changeset:   255373:4f32a481bc07 including a test.
http://hg.netbeans.org/core-main/rev/4f32a481bc07
Comment 4 Quality Engineering 2013-06-04 01:47:23 UTC
Integrated into 'main-golden', will be available in build *201306032301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4f32a481bc07
User: mentlicher@netbeans.org
Log: #216316: Create properties for all columns, including hidden ones. Covered by tests.