diff -r c114f5342f08 form/src/org/netbeans/modules/form/Bundle.properties --- a/form/src/org/netbeans/modules/form/Bundle.properties Fri Apr 24 13:49:07 2009 +0200 +++ b/form/src/org/netbeans/modules/form/Bundle.properties Sat Apr 25 05:30:35 2009 +1000 @@ -98,6 +98,7 @@ HINT_ASSISTANT_SHOWN=If selected, the assistant is shown in the designer. PROP_GENERATE_FQN=Generate Full Classnames HINT_GENERATE_FQN=If selected then fully qualified names of classes are generated. +HINT_SHOW_READ_ONLY=When selected properties that are read-only will be visible in the property inspector. # form toolbar CTL_SelectionButtonHint=Selection Mode @@ -753,6 +754,7 @@ Selection_Border_Color=Selection &Border Color: Guiding_Line_Color=Guiding Line &Color: Generate_FQN=Generate Fully &Qualified Names of Classes +Show_Read_Only=Show Read Only Properties MSG_Paiting_Exception=The following exception has been thrown during painting of the form. \ Use the Inspector window to fix or remove the problematic component. diff -r c114f5342f08 form/src/org/netbeans/modules/form/FormEditorCustomizer.java --- a/form/src/org/netbeans/modules/form/FormEditorCustomizer.java Fri Apr 24 13:49:07 2009 +0200 +++ b/form/src/org/netbeans/modules/form/FormEditorCustomizer.java Sat Apr 25 05:30:35 2009 +1000 @@ -74,6 +74,7 @@ private JCheckBox cbFold = new JCheckBox (); private JCheckBox cbAssistant = new JCheckBox(); private JCheckBox cbFQN = new JCheckBox(); + private JCheckBox cbShowReadOnly = new JCheckBox(); private JComboBox cbModifier = new JComboBox (); private JRadioButton rbGenerateLocals = new JRadioButton (); private JRadioButton rbGenerateFields = new JRadioButton (); @@ -92,6 +93,7 @@ loc(cbFold, "Fold"); // NOI18N loc(cbAssistant, "Assistant"); // NOI18N loc(cbFQN, "Generate_FQN"); // NOI18N + loc(cbShowReadOnly, "Show_Read_Only"); // NOI18N loc(rbGenerateLocals, "Generate_Locals"); // NOI18N group.add (rbGenerateLocals); loc(rbGenerateFields, "Generate_Fields"); // NOI18N @@ -140,6 +142,7 @@ cbFold.setToolTipText(loc("HINT_FOLD_GENERATED_CODE")); // NOI18N cbAssistant.setToolTipText(loc("HINT_ASSISTANT_SHOWN")); // NOI18N cbFQN.setToolTipText(loc("HINT_GENERATE_FQN")); // NOI18N + cbShowReadOnly.setToolTipText(loc("HINT_SHOW_READ_ONLY")); // NOI18N rbGenerateLocals.getAccessibleContext().setAccessibleDescription(loc("Generate_Locals_ACSD")); // NOI18N rbGenerateFields.getAccessibleContext().setAccessibleDescription(loc("Generate_Fields_ACSD")); // NOI18N @@ -172,6 +175,7 @@ .add(cbFold) .add(cbAssistant) .add(cbFQN) + .add(cbShowReadOnly) .add(cbModifier, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(cbLayoutStyle, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(cbComponentNames, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -213,6 +217,7 @@ .add(cbFold) .add(cbAssistant) .add(cbFQN) + .add(cbShowReadOnly) .addPreferredGap(LayoutStyle.RELATED) .add(layout.createParallelGroup(GroupLayout.LEADING) .add(GroupLayout.CENTER, guideLineColLabel) @@ -229,6 +234,7 @@ cbFold.addActionListener (this); cbAssistant.addActionListener(this); cbFQN.addActionListener(this); + cbShowReadOnly.addActionListener(this); cbLayoutStyle.addActionListener (this); cbComponentNames.addActionListener (this); cbListenerStyle.addActionListener (this); @@ -278,6 +284,7 @@ cbFold.setSelected(options.getFoldGeneratedCode()); cbAssistant.setSelected(options.getAssistantShown()); cbFQN.setSelected(options.getGenerateFQN()); + cbShowReadOnly.setSelected(options.getShowReadOnlyProperties()); rbGenerateLocals.setSelected(options.getVariablesLocal()); rbGenerateFields.setSelected(!options.getVariablesLocal()); if ((options.getVariablesModifier() & Modifier.PUBLIC) > 0) { @@ -303,6 +310,7 @@ options.setFoldGeneratedCode (cbFold.isSelected ()); options.setAssistantShown(cbAssistant.isSelected()); options.setGenerateFQN(cbFQN.isSelected()); + options.setShowReadOnlyProperties(cbShowReadOnly.isSelected()); options.setListenerGenerationStyle (cbListenerStyle.getSelectedIndex ()); options.setLayoutCodeTarget(cbLayoutStyle.getSelectedIndex ()); options.setAutoSetComponentName(cbComponentNames.getSelectedIndex()); diff -r c114f5342f08 form/src/org/netbeans/modules/form/FormLoaderSettings.java --- a/form/src/org/netbeans/modules/form/FormLoaderSettings.java Fri Apr 24 13:49:07 2009 +0200 +++ b/form/src/org/netbeans/modules/form/FormLoaderSettings.java Sat Apr 25 05:30:35 2009 +1000 @@ -110,6 +110,8 @@ public static final String PROP_LAYOUT_CODE_TARGET = "layoutCodeTarget"; // NOI18N /** Property name of the generate FQN property. */ public static final String PROP_GENERATE_FQN = "generateFQN"; // NOI18N + /** Property name of the showReadOnlyProperties property. */ + public static final String PROP_SHOW_READ_ONLY_PROPERTIES = "showReadOnlyProperties"; // NOI18N /** Name of the property for automatic resources/i18n management. * The name refers only to i18n for compatibility reasons. */ @@ -413,6 +415,14 @@ getPreferences().putInt(PROP_AUTO_SET_COMPONENT_NAME, value); } + public boolean getShowReadOnlyProperties() { + return getPreferences().getBoolean(PROP_SHOW_READ_ONLY_PROPERTIES, true); + } + + public void setShowReadOnlyProperties(boolean value) { + getPreferences().putBoolean(PROP_SHOW_READ_ONLY_PROPERTIES, value); + } + /** * Getter for the generateMnemonicsCode option. * diff -r c114f5342f08 form/src/org/netbeans/modules/form/FormSettings.java --- a/form/src/org/netbeans/modules/form/FormSettings.java Fri Apr 24 13:49:07 2009 +0200 +++ b/form/src/org/netbeans/modules/form/FormSettings.java Sat Apr 25 05:30:35 2009 +1000 @@ -129,6 +129,15 @@ return autoName; } + public boolean getShowReadOnlyProperties() { + Boolean val = (Boolean) settings.get(FormLoaderSettings.PROP_SHOW_READ_ONLY_PROPERTIES); + return val == null ? true : val.booleanValue(); + } + + public void setShowReadOnlyProperties(boolean value) { + settings.put(FormLoaderSettings.PROP_SHOW_READ_ONLY_PROPERTIES, Boolean.valueOf(value)); + } + public boolean getGenerateMnemonicsCode() { Boolean generateMnemonicsCode = (Boolean)settings.get(FormLoaderSettings.PROP_GENERATE_MNEMONICS); return generateMnemonicsCode.booleanValue(); diff -r c114f5342f08 form/src/org/netbeans/modules/form/RADComponent.java --- a/form/src/org/netbeans/modules/form/RADComponent.java Fri Apr 24 13:49:07 2009 +0200 +++ b/form/src/org/netbeans/modules/form/RADComponent.java Sat Apr 25 05:30:35 2009 +1000 @@ -46,7 +46,9 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.*; +import java.util.prefs.PreferenceChangeEvent; import java.lang.reflect.Method; +import java.util.prefs.PreferenceChangeListener; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.swing.AbstractButton; @@ -124,6 +126,10 @@ private String storedName; // component name preserved e.g. for remove undo private boolean valid = true; + + private PreferenceChangeListener settingsListener; + + // ----------------------------------------------------------------------------- // Constructors & Initialization @@ -142,6 +148,21 @@ // properties and events will be created on first request clearProperties(); +// TODO: Find out the correct place to register/deregister this event. +// if (settingsListener != null) { +// FormLoaderSettings.getPreferences().removePreferenceChangeListener(settingsListener); +// } + + settingsListener = new PreferenceChangeListener() { + public void preferenceChange(PreferenceChangeEvent evt) { + if (FormLoaderSettings.PROP_SHOW_READ_ONLY_PROPERTIES.equals(evt.getKey())) { + clearProperties(); + createBeanProperties(); + } + } + }; + FormLoaderSettings.getPreferences().addPreferenceChangeListener(settingsListener); + // if (beanClass != null) // createCodeExpression(); @@ -840,6 +861,10 @@ propAccessClsf = FormUtils.getPropertiesAccessClsf(beanClass); propParentChildDepClsf = FormUtils.getPropertiesParentChildDepsClsf(beanClass); } + + descriptors[i].setDisplayName( + RADProperty.getFormedName( + descriptors[i].getDisplayName())); prop = createBeanProperty(descriptors[j], propAccessClsf, propParentChildDepClsf); @@ -1213,7 +1238,15 @@ boolean action = (pd.getValue("action") != null); // NOI18N Object category = pd.getValue("category"); // NOI18N List listToAdd; - + + if (!FormLoaderSettings.getInstance().getShowReadOnlyProperties() && + (pd.isHidden() || + pd.getPropertyType() == null || + pd.getWriteMethod() == null) + ) { + continue; + } + if ((category == null) || (!(category instanceof String))) { Object propCat = FormUtils.getPropertyCategory(pd, propsCats); if (propCat == FormUtils.PROP_PREFERRED) diff -r c114f5342f08 form/src/org/netbeans/modules/form/RADProperty.java --- a/form/src/org/netbeans/modules/form/RADProperty.java Fri Apr 24 13:49:07 2009 +0200 +++ b/form/src/org/netbeans/modules/form/RADProperty.java Sat Apr 25 05:30:35 2009 +1000 @@ -70,11 +70,33 @@ private PropertyDescriptor desc; private Object defaultValue; + public static String getFormedName(String v) { + char[] chars = v.toCharArray(); + StringBuilder res = new StringBuilder((int) (v.length() * 1.2)); + boolean lup = false; + for (int i = 0; i < chars.length; i++) { + if (i == 0) { + res.append(Character.toUpperCase(chars[i])); + lup = true; + } else if (Character.isUpperCase(chars[i])) { + if (!lup) { + res.append(' '); + } + res.append(chars[i]); + lup = true; + } else { + res.append(chars[i]); + lup = false; + } + } + return res.toString(); + } + public RADProperty(RADComponent metacomp, PropertyDescriptor propdesc) { super(new FormPropertyContext.Component(metacomp), propdesc.getName(), propdesc.getPropertyType(), - propdesc.getDisplayName(), + getFormedName(propdesc.getDisplayName()), propdesc.getShortDescription()); component = metacomp;