Index: view/NodeTableModel.java =================================================================== RCS file: /cvs/openide/src/org/openide/explorer/view/NodeTableModel.java,v retrieving revision 1.20 diff -u -r1.20 NodeTableModel.java --- view/NodeTableModel.java 18 Nov 2003 16:26:46 -0000 1.20 +++ view/NodeTableModel.java 9 Nov 2004 14:04:21 -0000 @@ -247,35 +247,61 @@ return -1; } - /* If true, column property should be comparable - allows sorting + /** + * If true, column property should be comparable - allows sorting + * @param column Index of a visible column */ boolean isComparableColumn(int column) { - Property p = allPropertyColumns[propertyColumns[column]].getProperty(); + return isComparableColumnEx( propertyColumns[column] ); + } + + /** + * If true, column property should be comparable - allows sorting + * @param column Index to the array of all properties + */ + boolean isComparableColumnEx(int column) { + Property p = allPropertyColumns[column].getProperty(); Object o = p.getValue( ATTR_COMPARABLE_COLUMN ); if ( o != null && o instanceof Boolean ) return ((Boolean)o).booleanValue(); return false; } + /** + * @param column Index to the array of all properties + * @return True if the property at the given index is visible + */ + boolean isVisibleColumnEx( int column ) { + for( int i=0; i= 0 ) + column = propertyColumns[column]; + return propertyForColumnEx( column ); + } + + /** + * Helper method to ask for a property representant of column. + * @param Index to the array of all properties. + */ + Property propertyForColumnEx(int column) { if ( column == -1 ) return treeColumnProperty; else - return allPropertyColumns[propertyColumns[column]].getProperty(); + return allPropertyColumns[column].getProperty(); } - int getArrayColumnCount() { + /** + * @return The count of all properties (includes invisible columns) + */ + int getColumnCountEx() { return allPropertyColumns.length; } @@ -451,7 +516,15 @@ * @return display name of property which represents column */ public String getColumnName(int column) { - return allPropertyColumns[propertyColumns[column]].getProperty().getDisplayName(); + return getColumnNameEx( propertyColumns[column] ); + } + + /** Getter for column name + * @param column table column index + * @return display name of property which represents column + */ + String getColumnNameEx(int column) { + return allPropertyColumns[column].getProperty().getDisplayName(); } /* display panel to set/unset set of visible columns Index: view/TreeTableView.java =================================================================== RCS file: /cvs/openide/src/org/openide/explorer/view/TreeTableView.java,v retrieving revision 1.67 diff -u -r1.67 TreeTableView.java --- view/TreeTableView.java 5 Nov 2004 15:32:28 -0000 1.67 +++ view/TreeTableView.java 9 Nov 2004 14:04:22 -0000 @@ -206,11 +206,12 @@ } } else { + int realIndex = tableModel.translateVisibleColumnIndex( index ); setSortingColumn( index ); setSortingOrder( true ); } } else if ( tableModel.isComparableColumn( index ) ) { - if ( tableModel.isSortingColumn( index ) ) { + if ( tableModel.isSortingColumnEx( tableModel.translateVisibleColumnIndex( index ) ) ) { if (!tableModel.isSortOrderDescending()) setSortingOrder(false); else { @@ -218,7 +219,8 @@ } } else { - setSortingColumn( index ); + int realIndex = tableModel.translateVisibleColumnIndex( index ); + setSortingColumn( realIndex ); setSortingOrder( true ); } } @@ -231,7 +233,7 @@ viewName = getParent().getName(); if ( tableModel.selectVisibleColumns( viewName, treeTable.getColumnName(0), getSortedNodeTreeModel ().getRootDescription() ) ) { - if ( tableModel.getVisibleSortingColumn() == -1 ) + if ( tableModel.getSortingColumn() == -1 ) getSortedNodeTreeModel ().setSortedByProperty( null ); setTreePreferredWidth( treeColumnWidth ); for (int i=0; i < tableModel.getColumnCount(); i++) { @@ -450,9 +452,9 @@ !treeColumnProperty.isSortOrderDescending() ); } else { - int index = tableModel.getVisibleSortingColumn(); + int index = tableModel.getSortingColumn(); if ( index != -1 ) { - getSortedNodeTreeModel ().setSortedByProperty( tableModel.propertyForColumn( index ), + getSortedNodeTreeModel ().setSortedByProperty( tableModel.propertyForColumnEx( index ), !tableModel.isSortOrderDescending() ); } } @@ -670,7 +672,24 @@ visibleComparable++; colItem = new JRadioButtonMenuItem( tableModel.getColumnName( i ), - tableModel.isSortingColumn( i ) ); + tableModel.isSortingColumnEx( tableModel.translateVisibleColumnIndex( i ) ) ); + colItem.setHorizontalTextPosition( SwingConstants.LEFT ); + final int index = tableModel.translateVisibleColumnIndex( i ); + colItem.addActionListener( new ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent actionEvent) { + setSortingColumn( index ); + } + }); + sortItem.add( colItem ); + } + } + //add invisible columns + for (int i=0; i < tableModel.getColumnCountEx(); i++) { + if ( tableModel.isComparableColumnEx( i ) && !tableModel.isVisibleColumnEx( i ) ) { + visibleComparable++; + colItem = new JRadioButtonMenuItem( + tableModel.getColumnNameEx( i ), + tableModel.isSortingColumnEx( i ) ); colItem.setHorizontalTextPosition( SwingConstants.LEFT ); final int index = i; colItem.addActionListener( new ActionListener() { @@ -736,9 +755,9 @@ /* Sets column to be currently used for sorting */ private void setSortingColumn(int index) { - tableModel.setSortingColumn( index ); + tableModel.setSortingColumnEx( index ); if ( index != -1 ) { - getSortedNodeTreeModel ().setSortedByProperty( tableModel.propertyForColumn( index ), + getSortedNodeTreeModel ().setSortedByProperty( tableModel.propertyForColumnEx( index ), !tableModel.isSortOrderDescending()); treeColumnProperty.setSortingColumn( false ); } @@ -751,7 +770,7 @@ } private void noSorting() { - tableModel.setSortingColumn( -1 ); + tableModel.setSortingColumnEx( -1 ); getSortedNodeTreeModel ().setNoSorting(); treeColumnProperty.setSortingColumn( false ); // to change sort icon