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.

View | Details | Raw Unified | Return to bug 56257
Collapse All | Expand All

(-)openide/openide-spec-vers.properties (-1 / +1 lines)
Lines 4-7 Link Here
4
# Must always be numeric (numbers separated by '.', e.g. 4.11).
4
# Must always be numeric (numbers separated by '.', e.g. 4.11).
5
# See http://openide.netbeans.org/versioning-policy.html for more.
5
# See http://openide.netbeans.org/versioning-policy.html for more.
6
6
7
openide.specification.version=5.5
7
openide.specification.version=5.6
(-)openide/api/doc/changes/apichanges.xml (+22 lines)
Lines 114-119 Link Here
114
114
115
<!-- ACTUAL CHANGES BEGIN HERE: -->
115
<!-- ACTUAL CHANGES BEGIN HERE: -->
116
<changes>
116
<changes>
117
    <change id="new-attribute-for-StringArrayPropertyEditor">
118
      <api name="explorer"/>
119
      <summary>One can specify separator for property editor for <code>String[]</code> </summary>
120
      <version major="5" minor="6"/>
121
      <date day="18" month="2" year="2005"/>
122
      <author login="jtulach"/>
123
      <compatibility addition="yes" binary="compatible" semantic="compatible" source="compatible" />
124
      <description>
125
        One can specify an item separator for properties using string array editor. For example
126
        following code:
127
        <pre>
128
          Node.Property np = new Node.Property (String[].class, ...);
129
          np.setValue ("item.separator", "-");        
130
        </pre>
131
        separates items returned from <code>getAsText</code> and parsed by <code>setAsText</code>
132
        by <q>-</q>. List of supported parameters can be found 
133
        <a href="@TOP@org/openide/explorer/doc-files/api.html#core_editors_custom_parameters">here</a>.
134
      </description>
135
      <class package="org.openide.explorer.propertysheet" name="PropertyPanel"/>
136
      <issue number="56257" />
137
    </change>
138
    
117
    <change id="add-leaf-attribute-to-DialogDescriptor">
139
    <change id="add-leaf-attribute-to-DialogDescriptor">
118
      <api name="dialogs"/>
140
      <api name="dialogs"/>
119
      <summary>Added paramater <code>leaf</code> to <code>DialogDescriptor</code></summary>
141
      <summary>Added paramater <code>leaf</code> to <code>DialogDescriptor</code></summary>
(-)openide/api/doc/org/openide/explorer/doc-files/api.html (+9 lines)
Lines 764-769 Link Here
764
            <TD>Instructs the property editor to suppress the custom editor 
764
            <TD>Instructs the property editor to suppress the custom editor 
765
                button on the property sheet.</TD>
765
                button on the property sheet.</TD>
766
        </TR>
766
        </TR>
767
	<TR> 
768
	    <TD rowspan='1'>java.lang.String[]</TD>
769
	    <TD>item.separator</TD>
770
	    <TD>String</TD>
771
	    <TD>Contains the separator that is used when composing individual
772
                items into <code>getAsText</code> value and parse the text
773
                when doing <code>setAsText</code>. Since version 5.6.
774
            </TD>
775
        </TR>
767
	<TR>
776
	<TR>
768
	    <TD rowspan='3'> java.lang.Integer and primitive integer </TD>
777
	    <TD rowspan='3'> java.lang.Integer and primitive integer </TD>
769
            <TD>stringKeys</TD>
778
            <TD>stringKeys</TD>
(-)openide/arch/arch-openide-propertysheet.xml (-3 / +12 lines)
Lines 317-325 Link Here
317
        </question>
317
        </question>
318
-->
318
-->
319
<answer id="exec-component">
319
<answer id="exec-component">
320
Yes.  A variety of hints can be supplied to property editors to influence their
320
<api name="PropertyEditorsProperties" category="devel" group="property" type="export" 
321
behavior.  These are documented in full 
321
  url="@TOP@org/openide/explorer/doc-files/api.html#custom_property_editors" 
322
<a href="http://www.netbeans.org/download/dev/javadoc/OpenAPIs/org/openide/explorer/doc-files/api.html#custom_property_editors">here</a>.
322
>
323
A variety of hints that can be supplied to property editors to influence their
324
behavior. The usual usage is to create a feature descriptor and set parameters 
325
on it:
326
<pre>
327
Node.Property prop = new Node.Property (Boolean.TYPE, ...);
328
prop.setValue ("stringValue", new String[] { "yes", "no" });
329
</pre>
330
</api>
323
331
324
332
325
<p>The property sheet's display can be customized to a degree by a look and feel
333
<p>The property sheet's display can be customized to a degree by a look and feel
Lines 436-441 Link Here
436
            <code>stringValues</code>, <code>valueIcon</code>, <code>nodeDescription</code>,
444
            <code>stringValues</code>, <code>valueIcon</code>, <code>nodeDescription</code>,
437
            <code>propertiesHelpID</code>, <code>nameIcon</code>
445
            <code>propertiesHelpID</code>, <code>nameIcon</code>
438
        </p>
446
        </p>
447
        
439
448
440
</answer>
449
</answer>
441
450
(-)core/src/org/netbeans/beaninfo/editors/StringArrayEditor.java (-3 / +15 lines)
Lines 39-44 Link Here
39
    private String[] strings;
39
    private String[] strings;
40
    private PropertyChangeSupport support;
40
    private PropertyChangeSupport support;
41
    private boolean editable = true;
41
    private boolean editable = true;
42
    private String separator = ",";
42
43
43
    public StringArrayEditor() {
44
    public StringArrayEditor() {
44
        support = new PropertyChangeSupport (this);
45
        support = new PropertyChangeSupport (this);
Lines 79-86 Link Here
79
        for (int i = 0; i < strings.length; i++) {
80
        for (int i = 0; i < strings.length; i++) {
80
            // XXX handles in-string escapes if quoted
81
            // XXX handles in-string escapes if quoted
81
            buf.append(quoted ? "\""+strings[i]+"\"" : strings[i]); // NOI18N
82
            buf.append(quoted ? "\""+strings[i]+"\"" : strings[i]); // NOI18N
82
            if (i != strings.length - 1)
83
            if (i != strings.length - 1) {
83
                buf.append (", "); // NOI18N
84
                buf.append (separator); 
85
                buf.append (' '); // NOI18N
86
            }
84
        }
87
        }
85
88
86
        return buf.toString ();
89
        return buf.toString ();
Lines 95-101 Link Here
95
            setValue(null);
98
            setValue(null);
96
            return;
99
            return;
97
        }
100
        }
98
        StringTokenizer tok = new StringTokenizer(text, ","); // NOI18N
101
        StringTokenizer tok = new StringTokenizer(text, separator);
99
        java.util.List list = new LinkedList();
102
        java.util.List list = new LinkedList();
100
        while (tok.hasMoreTokens()) {
103
        while (tok.hasMoreTokens()) {
101
            String s = tok.nextToken();
104
            String s = tok.nextToken();
Lines 221-232 Link Here
221
    
224
    
222
    public void attachEnv(PropertyEnv env) {
225
    public void attachEnv(PropertyEnv env) {
223
        FeatureDescriptor d = env.getFeatureDescriptor();
226
        FeatureDescriptor d = env.getFeatureDescriptor();
227
        readEnv (env.getFeatureDescriptor ());
228
    }
229
    
230
    final void readEnv (FeatureDescriptor d) {
224
        if (d instanceof Node.Property) {
231
        if (d instanceof Node.Property) {
225
            editable = ((Node.Property)d).canWrite();
232
            editable = ((Node.Property)d).canWrite();
226
        } else if (d instanceof PropertyDescriptor) {
233
        } else if (d instanceof PropertyDescriptor) {
227
            editable = ((PropertyDescriptor)d).getWriteMethod() != null;
234
            editable = ((PropertyDescriptor)d).getWriteMethod() != null;
228
        } else {
235
        } else {
229
            editable = true;
236
            editable = true;
237
        }
238
        
239
        Object v = d.getValue ("item.separator"); // NOI18N
240
        if (v instanceof String) {
241
            separator = (String)v;
230
        }
242
        }
231
    }
243
    }
232
}
244
}
(-)core/test/unit/src/org/netbeans/beaninfo/editors/StringArrayEditorTest.java (+103 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.beaninfo.editors;
15
16
import junit.framework.*;
17
import java.awt.*;
18
import java.beans.*;
19
import java.util.*;
20
import javax.swing.JList;
21
import javax.swing.JScrollPane;
22
import org.openide.explorer.propertysheet.ExPropertyEditor;
23
import org.openide.explorer.propertysheet.PropertyEnv;
24
import org.openide.explorer.propertysheet.editors.XMLPropertyEditor;
25
import org.openide.nodes.Node;
26
27
/**
28
 *
29
 * @author jarda
30
 */
31
public class StringArrayEditorTest extends TestCase {
32
    static {
33
        PropertyEditorManager.registerEditor (String[].class, StringArrayEditor.class);
34
    }
35
    
36
    public StringArrayEditorTest (String testName) {
37
        super (testName);
38
    }
39
    
40
    protected void setUp () throws Exception {
41
    }
42
43
    protected void tearDown () throws Exception {
44
    }
45
46
    public static Test suite () {
47
        TestSuite suite = new TestSuite(StringArrayEditorTest.class);
48
        
49
        return suite;
50
    }
51
52
 
53
    public void testTheEditorHonoursSeparatorAttribute () throws Exception {
54
        NP np = new NP ();
55
        np.setValue ("item.separator", "-");
56
        
57
        PropertyEditor p = np.getPropertyEditor ();
58
        assertNotNull ("There is some editor", p);
59
        assertEquals ("It is StringArrayEditor", StringArrayEditor.class, p.getClass ());
60
        ((StringArrayEditor)p).readEnv (np);
61
        
62
        p.setAsText ("A-B");
63
        
64
        String[] value = (String[])p.getValue ();
65
        
66
        assertNotNull ("Values is there", value);
67
        if (value.length != 2 || !"A".equals (value[0]) || !"B".equals(value[1])) {
68
            fail ("Unexpected arrays: " + Arrays.asList (value));
69
        }
70
        
71
        p.setValue (new String[] { "X", "Y" });
72
        String t = np.getPropertyEditor ().getAsText ();
73
        if (!"X- Y".equals (t)) {
74
            fail ("Wrong text: " + t);
75
        }
76
    }
77
    
78
    class NP extends Node.Property {
79
        public String[] value;
80
        
81
        public NP () {
82
            super (String[].class);
83
        }
84
85
        public void setValue (Object val) throws IllegalAccessException, IllegalArgumentException, java.lang.reflect.InvocationTargetException {
86
            value = (String[])val;
87
        }
88
89
        public Object getValue () throws IllegalAccessException, java.lang.reflect.InvocationTargetException {
90
            return value;
91
        }
92
93
        public boolean canWrite () {
94
            return true;
95
        }
96
97
        public boolean canRead () {
98
            return true;
99
        }
100
        
101
        
102
    }
103
}

Return to bug 56257