Index: openide/openide-spec-vers.properties =================================================================== RCS file: /cvs/openide/openide-spec-vers.properties,v retrieving revision 1.166 diff -u -r1.166 openide-spec-vers.properties --- openide/openide-spec-vers.properties 9 Feb 2005 12:33:24 -0000 1.166 +++ openide/openide-spec-vers.properties 11 Mar 2005 11:50:35 -0000 @@ -4,4 +4,4 @@ # Must always be numeric (numbers separated by '.', e.g. 4.11). # See http://openide.netbeans.org/versioning-policy.html for more. -openide.specification.version=5.5 +openide.specification.version=5.6 Index: openide/api/doc/changes/apichanges.xml =================================================================== RCS file: /cvs/openide/api/doc/changes/apichanges.xml,v retrieving revision 1.234 diff -u -r1.234 apichanges.xml --- openide/api/doc/changes/apichanges.xml 9 Feb 2005 12:33:24 -0000 1.234 +++ openide/api/doc/changes/apichanges.xml 11 Mar 2005 11:50:36 -0000 @@ -114,6 +114,28 @@ + + + One can specify separator for property editor for String[] + + + + + + One can specify an item separator for properties using string array editor. For example + following code: +
+          Node.Property np = new Node.Property (String[].class, ...);
+          np.setValue ("item.separator", "-");        
+        
+ separates items returned from getAsText and parsed by setAsText + by -. List of supported parameters can be found + here. +
+ + +
+ Added paramater leaf to DialogDescriptor Index: openide/api/doc/org/openide/explorer/doc-files/api.html =================================================================== RCS file: /cvs/openide/api/doc/org/openide/explorer/doc-files/api.html,v retrieving revision 1.49 diff -u -r1.49 api.html --- openide/api/doc/org/openide/explorer/doc-files/api.html 18 Feb 2005 18:04:52 -0000 1.49 +++ openide/api/doc/org/openide/explorer/doc-files/api.html 11 Mar 2005 11:50:36 -0000 @@ -764,6 +764,15 @@ Instructs the property editor to suppress the custom editor button on the property sheet. + + java.lang.String[] + item.separator + String + Contains the separator that is used when composing individual + items into getAsText value and parse the text + when doing setAsText. Since version 5.6. + + java.lang.Integer and primitive integer stringKeys Index: openide/arch/arch-openide-propertysheet.xml =================================================================== RCS file: /cvs/openide/arch/arch-openide-propertysheet.xml,v retrieving revision 1.22 diff -u -r1.22 arch-openide-propertysheet.xml --- openide/arch/arch-openide-propertysheet.xml 20 Dec 2004 21:48:27 -0000 1.22 +++ openide/arch/arch-openide-propertysheet.xml 11 Mar 2005 11:50:36 -0000 @@ -317,9 +317,17 @@ --> -Yes. A variety of hints can be supplied to property editors to influence their -behavior. These are documented in full -here. + +A variety of hints that can be supplied to property editors to influence their +behavior. The usual usage is to create a feature descriptor and set parameters +on it: +
+Node.Property prop = new Node.Property (Boolean.TYPE, ...);
+prop.setValue ("stringValue", new String[] { "yes", "no" });
+
+

The property sheet's display can be customized to a degree by a look and feel @@ -436,6 +444,7 @@ stringValues, valueIcon, nodeDescription, propertiesHelpID, nameIcon

+
Index: core/src/org/netbeans/beaninfo/editors/StringArrayEditor.java =================================================================== RCS file: /cvs/core/src/org/netbeans/beaninfo/editors/StringArrayEditor.java,v retrieving revision 1.6 diff -u -r1.6 StringArrayEditor.java --- core/src/org/netbeans/beaninfo/editors/StringArrayEditor.java 1 Sep 2004 12:05:35 -0000 1.6 +++ core/src/org/netbeans/beaninfo/editors/StringArrayEditor.java 11 Mar 2005 11:50:38 -0000 @@ -39,6 +39,7 @@ private String[] strings; private PropertyChangeSupport support; private boolean editable = true; + private String separator = ","; public StringArrayEditor() { support = new PropertyChangeSupport (this); @@ -79,8 +80,10 @@ for (int i = 0; i < strings.length; i++) { // XXX handles in-string escapes if quoted buf.append(quoted ? "\""+strings[i]+"\"" : strings[i]); // NOI18N - if (i != strings.length - 1) - buf.append (", "); // NOI18N + if (i != strings.length - 1) { + buf.append (separator); + buf.append (' '); // NOI18N + } } return buf.toString (); @@ -95,7 +98,7 @@ setValue(null); return; } - StringTokenizer tok = new StringTokenizer(text, ","); // NOI18N + StringTokenizer tok = new StringTokenizer(text, separator); java.util.List list = new LinkedList(); while (tok.hasMoreTokens()) { String s = tok.nextToken(); @@ -221,12 +224,21 @@ public void attachEnv(PropertyEnv env) { FeatureDescriptor d = env.getFeatureDescriptor(); + readEnv (env.getFeatureDescriptor ()); + } + + final void readEnv (FeatureDescriptor d) { if (d instanceof Node.Property) { editable = ((Node.Property)d).canWrite(); } else if (d instanceof PropertyDescriptor) { editable = ((PropertyDescriptor)d).getWriteMethod() != null; } else { editable = true; + } + + Object v = d.getValue ("item.separator"); // NOI18N + if (v instanceof String) { + separator = (String)v; } } } Index: core/test/unit/src/org/netbeans/beaninfo/editors/StringArrayEditorTest.java =================================================================== RCS file: core/test/unit/src/org/netbeans/beaninfo/editors/StringArrayEditorTest.java diff -N core/test/unit/src/org/netbeans/beaninfo/editors/StringArrayEditorTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ core/test/unit/src/org/netbeans/beaninfo/editors/StringArrayEditorTest.java 11 Mar 2005 11:50:38 -0000 @@ -0,0 +1,103 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.beaninfo.editors; + +import junit.framework.*; +import java.awt.*; +import java.beans.*; +import java.util.*; +import javax.swing.JList; +import javax.swing.JScrollPane; +import org.openide.explorer.propertysheet.ExPropertyEditor; +import org.openide.explorer.propertysheet.PropertyEnv; +import org.openide.explorer.propertysheet.editors.XMLPropertyEditor; +import org.openide.nodes.Node; + +/** + * + * @author jarda + */ +public class StringArrayEditorTest extends TestCase { + static { + PropertyEditorManager.registerEditor (String[].class, StringArrayEditor.class); + } + + public StringArrayEditorTest (String testName) { + super (testName); + } + + protected void setUp () throws Exception { + } + + protected void tearDown () throws Exception { + } + + public static Test suite () { + TestSuite suite = new TestSuite(StringArrayEditorTest.class); + + return suite; + } + + + public void testTheEditorHonoursSeparatorAttribute () throws Exception { + NP np = new NP (); + np.setValue ("item.separator", "-"); + + PropertyEditor p = np.getPropertyEditor (); + assertNotNull ("There is some editor", p); + assertEquals ("It is StringArrayEditor", StringArrayEditor.class, p.getClass ()); + ((StringArrayEditor)p).readEnv (np); + + p.setAsText ("A-B"); + + String[] value = (String[])p.getValue (); + + assertNotNull ("Values is there", value); + if (value.length != 2 || !"A".equals (value[0]) || !"B".equals(value[1])) { + fail ("Unexpected arrays: " + Arrays.asList (value)); + } + + p.setValue (new String[] { "X", "Y" }); + String t = np.getPropertyEditor ().getAsText (); + if (!"X- Y".equals (t)) { + fail ("Wrong text: " + t); + } + } + + class NP extends Node.Property { + public String[] value; + + public NP () { + super (String[].class); + } + + public void setValue (Object val) throws IllegalAccessException, IllegalArgumentException, java.lang.reflect.InvocationTargetException { + value = (String[])val; + } + + public Object getValue () throws IllegalAccessException, java.lang.reflect.InvocationTargetException { + return value; + } + + public boolean canWrite () { + return true; + } + + public boolean canRead () { + return true; + } + + + } +}