diff --git a/openide.explorer/apichanges.xml b/openide.explorer/apichanges.xml --- a/openide.explorer/apichanges.xml +++ b/openide.explorer/apichanges.xml @@ -50,6 +50,24 @@ Explorer API + + + setPropertyColumnAttribute() method added to OutlineView + + + + + + In order to conveniently set attributes to column properties, + setPropertyColumnAttribute() method is added to OutlineView. + After OutlineView.setProperties() method was deprecated, the preferred + way how to add columns is via addPropertyColumn()/setPropertyColumns(). + But then there's no Node.Property to set additional attributes on. + This is why setPropertyColumnAttribute() method is introduced. + + + + QuickSearch attached to OutlineView diff --git a/openide.explorer/manifest.mf b/openide.explorer/manifest.mf --- a/openide.explorer/manifest.mf +++ b/openide.explorer/manifest.mf @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.explorer OpenIDE-Module-Localizing-Bundle: org/openide/explorer/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 6.43 +OpenIDE-Module-Specification-Version: 6.44 diff --git a/openide.explorer/src/org/openide/explorer/view/OutlineView.java b/openide.explorer/src/org/openide/explorer/view/OutlineView.java --- a/openide.explorer/src/org/openide/explorer/view/OutlineView.java +++ b/openide.explorer/src/org/openide/explorer/view/OutlineView.java @@ -635,6 +635,33 @@ setProperties (props, true); } + /** + * Set an attribute value for the property column + * representing properties that have the passed programmatic (not display) + * name. + * + * @param columnName The programmatic name (Property.getName()) of the + * column + * @param attributeName The name of the attribute that is to be set + * @param value The value of the attribute + * @throws IllegalArgumentException if the column name is not found. + * @since 6.44 + */ + public final void setPropertyColumnAttribute(String columnName, String attributeName, Object value) + throws IllegalArgumentException { + Property[] props = rowModel.getProperties(); + boolean found = false; + for (Property p : props) { + if (columnName.equals(p.getName())) { + p.setValue(attributeName, value); + found = true; + } + } + if (!found) { + throw new IllegalArgumentException("Unknown column "+columnName); + } + } + /** Enable/disable displaying popup menus on tree view items. * Default is enabled. * @param value true to enable diff --git a/openide.explorer/test/unit/src/org/openide/explorer/view/OutlineViewTest.java b/openide.explorer/test/unit/src/org/openide/explorer/view/OutlineViewTest.java --- a/openide.explorer/test/unit/src/org/openide/explorer/view/OutlineViewTest.java +++ b/openide.explorer/test/unit/src/org/openide/explorer/view/OutlineViewTest.java @@ -234,6 +234,19 @@ assertEquals ("[2]", view.getOutline ().getValueAt (3, 0).toString ()); assertEquals ("[2-index from 200 to 299]", view.getOutline ().getValueAt (101, 0).toString ()); } + + public void testColumnSortability() throws Exception { + ETableColumnModel etcm = (ETableColumnModel) view.getOutline().getColumnModel(); + ETableColumn etc = (ETableColumn) etcm.getColumn(1); + boolean sortable = etc.isSortingAllowed(); + assertEquals("Has to be sortable, initially.", true, sortable); + view.setPropertyColumnAttribute("unitTestPropName", "SortableColumn", Boolean.FALSE); + sortable = etc.isSortingAllowed(); + assertEquals("Should not be sortable after attribute change.", false, sortable); + view.setPropertyColumnAttribute("unitTestPropName", "SortableColumn", Boolean.TRUE); + sortable = etc.isSortingAllowed(); + assertEquals("Sortable, again.", true, sortable); + } private class OutlineViewComponent extends JPanel implements ExplorerManager.Provider {