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.32
diff -u -r1.32 api.html
--- openide/api/doc/org/openide/explorer/doc-files/api.html 26 Feb 2003 06:09:40 -0000 1.32
+++ openide/api/doc/org/openide/explorer/doc-files/api.html 3 Mar 2003 16:05:54 -0000
@@ -742,6 +742,50 @@
org.openide.util.Lookup |
A lookup to use to query for results. |
+
+ java.lang.String |
+ instructions |
+ String |
+ Should contain localized instructions to the user, to be displayed in the
+ String custom editor |
+
+
+ oneline |
+ Boolean |
+ Instructs the property editor that the custom editor should present
+ a one-line text control (JTextField or equivalent) rather than
+ a multi-line text control (JTextArea or equivalent).
+ |
+
+
+ suppressCustomEditor |
+ Boolean |
+ Instructs the property editor to suppress the custom editor
+ button on the property sheet. |
+
+
+ java.lang.Integer |
+ stringKeys |
+ String[] |
+ Should contain internationalized strings that should be used as tags in
+ a combo box. Number of elements must be >= 1. If this hint is
+ supplied, the hint intKeyValues must also be supplied
+ |
+
+
+ intKeyValues |
+ int[] |
+ The values the string keys correspond to. Must have the same number
+ of elements as the string array |
+
+
+ java.lang.Boolean |
+ stringvalues |
+ String[] |
+ Should contain an array of two strings to be used for user
+ displayable text for the boolean values, in the order
+ false, true - for example, new String[] {"off","on"} . |
Custom parameters that are not tied with particular editor
Index: core/src/org/netbeans/beaninfo/editors/StringEditor.java
===================================================================
RCS file: /cvs/core/src/org/netbeans/beaninfo/editors/StringEditor.java,v
retrieving revision 1.17
diff -u -r1.17 StringEditor.java
--- core/src/org/netbeans/beaninfo/editors/StringEditor.java 3 Dec 2002 14:09:58 -0000 1.17
+++ core/src/org/netbeans/beaninfo/editors/StringEditor.java 3 Mar 2003 16:05:54 -0000
@@ -50,7 +50,7 @@
}
public boolean supportsCustomEditor () {
- return true;
+ return customEd;
}
public java.awt.Component getCustomEditor () {
@@ -59,7 +59,7 @@
if (val != null) {
s = val.toString();
}
- return new StringCustomEditor (s, isEditable()); // NOI18N
+ return new StringCustomEditor (s, isEditable(), oneline, instructions); // NOI18N
}
private static String toAscii(String str) {
@@ -91,12 +91,19 @@
return buf.toString();
}
+ private String instructions=null;
+ private boolean oneline=false;
+ private boolean customEd=true;
// bugfix# 9219 added attachEnv() method checking if the user canWrite in text box
public void attachEnv(PropertyEnv env) {
FeatureDescriptor desc = env.getFeatureDescriptor();
if (desc instanceof Node.Property){
Node.Property prop = (Node.Property)desc;
editable = prop.canWrite();
+ //issue 29294
+ instructions = (String) prop.getValue ("instructions"); //NOI18N
+ oneline = Boolean.TRUE.equals (prop.getValue ("oneline")); //NOI18N
+ customEd = !Boolean.TRUE.equals (prop.getValue ("suppressCustomEditor"));
}
}
}
Index: core/src/org/netbeans/beaninfo/editors/StringCustomEditor.java
===================================================================
RCS file: /cvs/core/src/org/netbeans/beaninfo/editors/StringCustomEditor.java,v
retrieving revision 1.23
diff -u -r1.23 StringCustomEditor.java
--- core/src/org/netbeans/beaninfo/editors/StringCustomEditor.java 3 Dec 2002 14:09:58 -0000 1.23
+++ core/src/org/netbeans/beaninfo/editors/StringCustomEditor.java 3 Mar 2003 16:05:54 -0000
@@ -17,36 +17,88 @@
import org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor;
import javax.swing.*;
import javax.swing.border.*;
-
+import javax.swing.text.JTextComponent;
+import java.awt.BorderLayout;
/** A custom editor for Strings.
*
-* @author Ian Formanek
-* @version 1.00, Sep 21, 1998
+* @author Ian Formanek, Tim Boudreau
+* @version 1.01, Mar 3, 2003
*/
public class StringCustomEditor extends javax.swing.JPanel implements EnhancedCustomPropertyEditor {
-
+
static final long serialVersionUID =7348579663907322425L;
+ boolean oneline=false;
+ String instructions = null;
+ //enh 29294, provide one line editor on request
+ StringCustomEditor (String value, boolean editable, boolean oneline, String instructions) {
+ this.oneline = oneline;
+ this.instructions = instructions;
+ initComponents();
+ init (value, editable);
+ }
+
/** Initializes the Form */
+ //constructor retained for backward compat (not that anyone should be
+ //using it)
public StringCustomEditor(String s, boolean editable) {
initComponents ();
-
+ init (s, editable);
+ }
+
+ private void init (String s, boolean editable) {
+ //original constructor code
textArea.setEditable(editable);
textArea.setText (s);
- textArea.setWrapStyleWord( true );
- textArea.setLineWrap( true );
- setBorder (new javax.swing.border.EmptyBorder (new java.awt.Insets(12, 12, 0, 11)));
- setPreferredSize (new java.awt.Dimension(500, 300));
+ if (textArea instanceof JTextArea) {
+ ((JTextArea) textArea).setWrapStyleWord( true );
+ ((JTextArea)textArea).setLineWrap( true );
+ setPreferredSize (new java.awt.Dimension(500, 300));
+ if ( !editable ) {
+ // hack to fix #9219
+ JTextField hack = new JTextField();
+ hack.setEditable( false );
+ textArea.setBackground( hack.getBackground() );
+ textArea.setForeground( hack.getForeground() );
+ }
+ } else {
+ textArea.setMinimumSize (new java.awt.Dimension (100, 20));
+ }
+ setBorder (BorderFactory.createEmptyBorder(12,12,0,11));
- textArea.getAccessibleContext().setAccessibleName(NbBundle.getBundle(StringCustomEditor.class).getString("ACS_TextArea"));
- textArea.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(StringCustomEditor.class).getString("ACSD_TextArea"));
- getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(StringCustomEditor.class).getString("ACSD_CustomStringEditor"));
- if ( !editable ) {
- // hack to fix #9219
- JTextField hack = new JTextField();
- hack.setEditable( false );
- textArea.setBackground( hack.getBackground() );
- textArea.setForeground( hack.getForeground() );
+ textArea.getAccessibleContext().setAccessibleName(NbBundle.getBundle(StringCustomEditor.class).getString("ACS_TextArea")); //NOI18N
+ if (instructions == null) {
+ textArea.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(StringCustomEditor.class).getString("ACSD_TextArea")); //NOI18N
+ } else {
+ textArea.getAccessibleContext().setAccessibleDescription(instructions);
+ }
+ getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(StringCustomEditor.class).getString("ACSD_CustomStringEditor")); //NOI18N
+ int prefHeight = textArea.getPreferredSize().height + 8;
+
+ if (instructions != null) {
+ JTextArea jta = new JTextArea(instructions);
+ jta.setEditable (false);
+ java.awt.Color c = UIManager.getColor("control"); //NOI18N
+ if (c != null) {
+ jta.setBackground (c);
+ } else {
+ jta.setBackground (getBackground());
+ }
+ jta.setLineWrap(true);
+ jta.setWrapStyleWord(true);
+ jta.setFont (getFont());
+ add (jta, BorderLayout.NORTH);
+ jta.getAccessibleContext().setAccessibleName(
+ NbBundle.getMessage(StringCustomEditor.class,
+ "ACS_Instructions")); //NOI18N
+ jta.getAccessibleContext().setAccessibleDescription(
+ NbBundle.getMessage(StringCustomEditor.class,
+ "ACSD_Instructions")); //NOI18N
+ prefHeight += jta.getPreferredSize().height;
+ }
+ if (textArea instanceof JTextField) {
+ setPreferredSize (new java.awt.Dimension (300,
+ prefHeight));
}
}
@@ -61,28 +113,20 @@
/** This method is called from within the constructor to
* initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the FormEditor.
*/
- private void initComponents () {//GEN-BEGIN:initComponents
+ private void initComponents () {
setLayout (new java.awt.BorderLayout ());
+ if (oneline) {
+ textArea = new javax.swing.JTextField();
+ add (textArea, BorderLayout.CENTER);
+ } else {
+ textAreaScroll = new javax.swing.JScrollPane ();
+ textArea = new javax.swing.JTextArea ();
+ textAreaScroll.setViewportView (textArea);
+ add (textAreaScroll, BorderLayout.CENTER);
+ }
+ }
- textAreaScroll = new javax.swing.JScrollPane ();
-
- textArea = new javax.swing.JTextArea ();
-
- textAreaScroll.setViewportView (textArea);
-
-
- add (textAreaScroll, "Center"); // NOI18N
-
- }//GEN-END:initComponents
-
-
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane textAreaScroll;
- private javax.swing.JTextArea textArea;
- // End of variables declaration//GEN-END:variables
-
+ private JTextComponent textArea;
}