diff --git a/openide.explorer/apichanges.xml b/openide.explorer/apichanges.xml
--- a/openide.explorer/apichanges.xml
+++ b/openide.explorer/apichanges.xml
@@ -47,6 +47,29 @@
Explorer API
+
+
+ OutlineView.setPropertyColumns,
+ OutlineView.addPropertyColumn and
+ OutlineView.removePropertyColumn added.
+
+
+
+
+
+
+ Added methods to manipulate the displayed columns of an OutlineView
+ without needing to create prototype property objects, both making
+ it simpler to use, and avoiding the common problem of properties
+ not appearing because the prototype property does not use the
+ exact type required.
+
+ Deprecated OutlineView.setProperties(), as this was
+ only needed for ease of replacement of TreeTableView.
+
+
+
+ OutlineView.setTreeSortable added.
diff --git a/openide.explorer/nbproject/project.properties b/openide.explorer/nbproject/project.properties
--- a/openide.explorer/nbproject/project.properties
+++ b/openide.explorer/nbproject/project.properties
@@ -44,4 +44,4 @@
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
-spec.version.base=6.24.0
+spec.version.base=6.25.0
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
@@ -54,11 +54,14 @@
import java.beans.PropertyEditor;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.EventObject;
+import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Logger;
@@ -95,9 +98,11 @@
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.propertysheet.PropertyPanel;
import org.openide.nodes.Node;
-import org.openide.util.Exceptions;
+import org.openide.nodes.Node.Property;
+import org.openide.nodes.PropertySupport;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
+import org.openide.util.Parameters;
import org.openide.util.WeakListeners;
/**
@@ -260,10 +265,97 @@
return popupListener != null;
}
+ /**
+ * Set the properties which are shown in the non-tree columns of this
+ * Outline view.
+ *
+ * The passed set of properties are typically
+ * prototypes - for a given Node's
+ * property to be shown in a given column, that Node must have a Property
+ * which equals() one of the prototype properties. By default,
+ * this means that the return values of the prototype property's getName()
+ * and getValueType() must exactly match.
+ *
+ * It is also possible to use the actual Property objects from one Node
+ * being shown, if they are available.
+ *
+ * @deprecated This method is here to enable easy replacement
+ * of TreeTableView with OutlineView.
+ * Use setPropertyColumns, addPropertyColumn and
+ * removePropertyColumn instead.
+ * @param newProperties An array of prototype properties
+ */
+ @Deprecated
public void setProperties(Node.Property[] newProperties) {
rowModel.setProperties(newProperties);
outline.tableChanged(null);
}
+
+ /**
+ * Adds a property column which will match any property with the passed
+ * name.
+ *
+ * @param name The programmatic name of the property
+ * @param displayName A localized display name for the property which can
+ * be shown in the table header
+ * @since 6.25
+ */
+ public void addPropertyColumn(String name, String displayName) {
+ Parameters.notNull("name", name); //NOI18N
+ Parameters.notNull("displayName", displayName); //NOI18N
+ Property[] p = rowModel.getProperties();
+ Property[] nue = new Property[p.length + 1];
+ System.arraycopy(p, 0, nue, 0, p.length);
+ nue[p.length] = new PrototypeProperty(name, displayName);
+ setProperties (nue);
+ }
+
+ /**
+ * Remove the first property column for properties named name
+ * @param name The programmatic name of the Property, i.e. the
+ * return value of Property.getName()
+ *
+ * @return true if a column was removed
+ * @since 6.25
+ */
+ public boolean removePropertyColumn(String name) {
+ Parameters.notNull("name", name); //NOI18N
+ Property[] props = rowModel.getProperties();
+ List nue = new LinkedList(Arrays.asList(props));
+ boolean found = false;
+ for (Iterator i=nue.iterator(); i.hasNext();) {
+ Property p = i.next();
+ if (name.equals(p.getName())) {
+ found = true;
+ i.remove();
+ break;
+ }
+ }
+ if (found) {
+ props = nue.toArray(new Property[props.length - 1]);
+ setProperties (props);
+ }
+ return found;
+ }
+
+ /**
+ * Set all of the non-tree columns property names and display names.
+ *
+ * @param namesAndDisplayNames An array, divisible by 2, of
+ * programmatic name, display name, programmatic name, display name...
+ * @since 6.25
+ */
+ public void setPropertyColumns(String... namesAndDisplayNames) {
+ if (namesAndDisplayNames.length % 2 != 0) {
+ throw new IllegalArgumentException("Odd number of names and " + //NOI18N
+ "display names: " + Arrays.asList(namesAndDisplayNames)); //NOI18N
+ }
+ Property[] props = new Property[namesAndDisplayNames.length / 2];
+ for (int i = 0; i < namesAndDisplayNames.length; i+=2) {
+ props[i / 2] = new PrototypeProperty (namesAndDisplayNames[i], namesAndDisplayNames[i+1]);
+ }
+ setProperties (props);
+ }
/** Enable/disable displaying popup menus on tree view items.
* Default is enabled.
@@ -1158,4 +1250,29 @@
}
}
+ static final class PrototypeProperty extends PropertySupport.ReadWrite