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 29294
Collapse All | Expand All

(-)openide/api/doc/org/openide/explorer/doc-files/api.html (+44 lines)
Lines 742-747 Link Here
742
            <TD> org.openide.util.Lookup </TD>
742
            <TD> org.openide.util.Lookup </TD>
743
            <TD> A lookup to use to query for results.</TD>
743
            <TD> A lookup to use to query for results.</TD>
744
        </TR>
744
        </TR>
745
	<TR> 
746
	    <TD rowspan='3'>java.lang.String </TD>
747
	    <TD>instructions</TD>
748
	    <TD>String</TD>
749
	    <TD>Should contain localized instructions to the user, to be displayed in the
750
                String custom editor</TD>
751
        </TR>
752
        <TR>
753
            <TD>oneline</TD>
754
            <TD>Boolean</TD>
755
            <TD>Instructs the property editor that the custom editor should present
756
                a one-line text control (JTextField or equivalent) rather than
757
                a multi-line text control (JTextArea or equivalent).
758
            </TD>
759
        </TR>
760
        <TR>
761
	    <TD>suppressCustomEditor</TD>
762
            <TD>Boolean</TD>
763
            <TD>Instructs the property editor to suppress the custom editor 
764
                button on the property sheet.</TD>
765
        </TR>
766
	<TR>
767
	    <TD rowspan='2'> java.lang.Integer </TD>
768
            <TD>stringKeys</TD>
769
            <TD>String[]</TD>
770
            <TD> Should contain internationalized strings that should be used as tags in
771
                 a combo box.  Number of elements must be >= 1.  If this hint is 
772
                 supplied, the hint <code>intKeyValues</code> must also be supplied
773
            </TD>
774
        </TR>
775
        <TR>
776
            <TD>intKeyValues</TD>
777
            <TD> int[] </TD>
778
            <TD> The values the string keys correspond to. Must have the same number
779
                 of elements as the string array </TD>
780
        </TR>	
781
        <TR>
782
           <TD> java.lang.Boolean </TD>
783
           <TD> stringvalues </TD>
784
           <TD> String[] </TD>
785
           <TD> Should contain an array of two strings to be used for user
786
                displayable text for the boolean values, in the order
787
                false, true - for example, <code>new String[] {"off","on"}</code>.</TD
788
        </TR>
745
    </TABLE>
789
    </TABLE>
746
790
747
<H4> Custom parameters that are not tied with particular editor </H4>
791
<H4> Custom parameters that are not tied with particular editor </H4>
(-)core/src/org/netbeans/beaninfo/editors/StringEditor.java (-2 / +9 lines)
Lines 50-56 Link Here
50
    }
50
    }
51
51
52
    public boolean supportsCustomEditor () {
52
    public boolean supportsCustomEditor () {
53
        return true;
53
        return customEd;
54
    }
54
    }
55
55
56
    public java.awt.Component getCustomEditor () {
56
    public java.awt.Component getCustomEditor () {
Lines 59-65 Link Here
59
        if (val != null) {
59
        if (val != null) {
60
            s = val.toString();
60
            s = val.toString();
61
        }
61
        }
62
        return new StringCustomEditor (s, isEditable()); // NOI18N
62
        return new StringCustomEditor (s, isEditable(), oneline, instructions); // NOI18N
63
    }
63
    }
64
64
65
    private static String toAscii(String str) {
65
    private static String toAscii(String str) {
Lines 91-102 Link Here
91
        return buf.toString();
91
        return buf.toString();
92
    }
92
    }
93
    
93
    
94
    private String instructions=null;
95
    private boolean oneline=false;
96
    private boolean customEd=true;
94
    // bugfix# 9219 added attachEnv() method checking if the user canWrite in text box 
97
    // bugfix# 9219 added attachEnv() method checking if the user canWrite in text box 
95
    public void attachEnv(PropertyEnv env) {        
98
    public void attachEnv(PropertyEnv env) {        
96
        FeatureDescriptor desc = env.getFeatureDescriptor();
99
        FeatureDescriptor desc = env.getFeatureDescriptor();
97
        if (desc instanceof Node.Property){
100
        if (desc instanceof Node.Property){
98
            Node.Property prop = (Node.Property)desc;
101
            Node.Property prop = (Node.Property)desc;
99
            editable = prop.canWrite();
102
            editable = prop.canWrite();
103
            //issue 29294
104
            instructions = (String) prop.getValue ("instructions"); //NOI18N
105
            oneline = Boolean.TRUE.equals (prop.getValue ("oneline")); //NOI18N
106
            customEd = !Boolean.TRUE.equals (prop.getValue ("suppressCustomEditor"));
100
        }
107
        }
101
    }
108
    }
102
}
109
}
(-)core/src/org/netbeans/beaninfo/editors/StringCustomEditor.java (-38 / +82 lines)
Lines 17-52 Link Here
17
import org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor;
17
import org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor;
18
import javax.swing.*;
18
import javax.swing.*;
19
import javax.swing.border.*;
19
import javax.swing.border.*;
20
20
import javax.swing.text.JTextComponent;
21
import java.awt.BorderLayout;
21
/** A custom editor for Strings.
22
/** A custom editor for Strings.
22
*
23
*
23
* @author  Ian Formanek
24
* @author  Ian Formanek, Tim Boudreau
24
* @version 1.00, Sep 21, 1998
25
* @version 1.01, Mar 3, 2003
25
*/
26
*/
26
public class StringCustomEditor extends javax.swing.JPanel implements EnhancedCustomPropertyEditor {
27
public class StringCustomEditor extends javax.swing.JPanel implements EnhancedCustomPropertyEditor {
27
28
    
28
    static final long serialVersionUID =7348579663907322425L;
29
    static final long serialVersionUID =7348579663907322425L;
29
    
30
    
31
    boolean oneline=false;
32
    String instructions = null;
33
    //enh 29294, provide one line editor on request
34
    StringCustomEditor (String value, boolean editable, boolean oneline, String instructions) {
35
        this.oneline = oneline;
36
        this.instructions = instructions;
37
        initComponents();
38
        init (value, editable);
39
   }
40
    
30
    /** Initializes the Form */
41
    /** Initializes the Form */
42
    //constructor retained for backward compat (not that anyone should be
43
    //using it)
31
    public StringCustomEditor(String s, boolean editable) {
44
    public StringCustomEditor(String s, boolean editable) {
32
        initComponents ();
45
        initComponents ();
33
        
46
        init (s, editable);
47
    }
48
    
49
    private void init (String s, boolean editable) {
50
        //original constructor code
34
        textArea.setEditable(editable);
51
        textArea.setEditable(editable);
35
        textArea.setText (s);
52
        textArea.setText (s);
36
        textArea.setWrapStyleWord( true );
53
        if (textArea instanceof JTextArea) {
37
        textArea.setLineWrap( true );
54
            ((JTextArea) textArea).setWrapStyleWord( true );
38
        setBorder (new javax.swing.border.EmptyBorder (new java.awt.Insets(12, 12, 0, 11)));
55
            ((JTextArea)textArea).setLineWrap( true );
39
        setPreferredSize (new java.awt.Dimension(500, 300));
56
            setPreferredSize (new java.awt.Dimension(500, 300));
57
            if ( !editable ) {
58
                // hack to fix #9219
59
                JTextField hack = new JTextField();
60
                hack.setEditable( false );
61
                textArea.setBackground( hack.getBackground() );
62
                textArea.setForeground( hack.getForeground() );
63
            }
64
        } else {
65
            textArea.setMinimumSize (new java.awt.Dimension (100, 20));
66
        }
67
        setBorder (BorderFactory.createEmptyBorder(12,12,0,11));
40
        
68
        
41
        textArea.getAccessibleContext().setAccessibleName(NbBundle.getBundle(StringCustomEditor.class).getString("ACS_TextArea"));
69
        textArea.getAccessibleContext().setAccessibleName(NbBundle.getBundle(StringCustomEditor.class).getString("ACS_TextArea")); //NOI18N
42
        textArea.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(StringCustomEditor.class).getString("ACSD_TextArea"));
70
        if (instructions == null) {
43
        getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(StringCustomEditor.class).getString("ACSD_CustomStringEditor"));
71
            textArea.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(StringCustomEditor.class).getString("ACSD_TextArea")); //NOI18N
44
        if ( !editable ) {
72
        } else {
45
            // hack to fix #9219
73
            textArea.getAccessibleContext().setAccessibleDescription(instructions);
46
            JTextField hack = new JTextField();
74
        }
47
            hack.setEditable( false );
75
        getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(StringCustomEditor.class).getString("ACSD_CustomStringEditor")); //NOI18N
48
            textArea.setBackground( hack.getBackground() );
76
        int prefHeight = textArea.getPreferredSize().height + 8;
49
            textArea.setForeground( hack.getForeground() );
77
        
78
        if (instructions != null) {
79
            JTextArea jta = new JTextArea(instructions);
80
            jta.setEditable (false);
81
            java.awt.Color c = UIManager.getColor("control");  //NOI18N
82
            if (c != null) {
83
                jta.setBackground (c);
84
            } else {
85
                jta.setBackground (getBackground());
86
            }
87
            jta.setLineWrap(true);
88
            jta.setWrapStyleWord(true);
89
            jta.setFont (getFont());
90
            add (jta, BorderLayout.NORTH);
91
            jta.getAccessibleContext().setAccessibleName(
92
                NbBundle.getMessage(StringCustomEditor.class, 
93
                "ACS_Instructions")); //NOI18N
94
            jta.getAccessibleContext().setAccessibleDescription(
95
                NbBundle.getMessage(StringCustomEditor.class, 
96
                "ACSD_Instructions")); //NOI18N
97
            prefHeight += jta.getPreferredSize().height;
98
        }
99
        if (textArea instanceof JTextField) {
100
            setPreferredSize (new java.awt.Dimension (300, 
101
                prefHeight));
50
        }
102
        }
51
    }
103
    }
52
104
Lines 61-88 Link Here
61
113
62
    /** This method is called from within the constructor to
114
    /** This method is called from within the constructor to
63
     * initialize the form.
115
     * initialize the form.
64
     * WARNING: Do NOT modify this code. The content of this method is
65
     * always regenerated by the FormEditor.
66
     */
116
     */
67
    private void initComponents () {//GEN-BEGIN:initComponents
117
    private void initComponents () {
68
        setLayout (new java.awt.BorderLayout ());
118
        setLayout (new java.awt.BorderLayout ());
119
        if (oneline) {
120
            textArea = new javax.swing.JTextField();
121
            add (textArea, BorderLayout.CENTER);
122
        } else {
123
            textAreaScroll = new javax.swing.JScrollPane ();
124
            textArea = new javax.swing.JTextArea ();
125
            textAreaScroll.setViewportView (textArea);
126
            add (textAreaScroll, BorderLayout.CENTER);
127
        }
128
    }
69
129
70
        textAreaScroll = new javax.swing.JScrollPane ();
71
72
        textArea = new javax.swing.JTextArea ();
73
74
        textAreaScroll.setViewportView (textArea);
75
76
77
        add (textAreaScroll, "Center"); // NOI18N
78
79
    }//GEN-END:initComponents
80
81
82
83
    // Variables declaration - do not modify//GEN-BEGIN:variables
84
    private javax.swing.JScrollPane textAreaScroll;
130
    private javax.swing.JScrollPane textAreaScroll;
85
    private javax.swing.JTextArea textArea;
131
    private JTextComponent textArea;
86
    // End of variables declaration//GEN-END:variables
87
88
}
132
}

Return to bug 29294