//---------------------------------/
//- notifyPropertyChangeListeners -/
//---------------------------------/
JMethod jMethod = new JMethod("notifyPropertyChangeListeners");
jMethod.getModifiers().makeProtected();
JDocComment jdc = jMethod.getJDocComment();
JDocDescriptor jdDesc = null;
String desc = null;
desc = "Notifies all registered PropertyChangeListeners "
+ "when a bound property's value changes.";
jdc.appendComment(desc);
jMethod.addParameter(new JParameter(SGTypes.STRING, "fieldName"));
jdDesc = jdc.getParamDescriptor("fieldName");
jdDesc.setDescription("the name of the property that has changed.");
jMethod.addParameter(new JParameter(SGTypes.OBJECT, "oldValue"));
jdDesc = jdc.getParamDescriptor("oldValue");
jdDesc.setDescription("the old value of the property.");
jMethod.addParameter(new JParameter(SGTypes.OBJECT, "newValue"));
jdDesc = jdc.getParamDescriptor("newValue");
jdDesc.setDescription("the new value of the property.");
parent.addMethod(jMethod);
JSourceCode jsc = jMethod.getSourceCode();
//--fix for bug 1026
jsc.add("if (");
jsc.append(vName);
jsc.append(" == null) return;");
jsc.add(vName);
jsc.append(".firePropertyChange(fieldName,oldValue,newValue);");
//-----------------------------/
//- addPropertyChangeListener -/
//-----------------------------/
JType jType = new JClass("java.beans.PropertyChangeListener");
jMethod = new JMethod("addPropertyChangeListener");
desc = "Registers a PropertyChangeListener with this class.";
jdc = jMethod.getJDocComment();
jdc.appendComment(desc);
jMethod.addParameter(new JParameter(jType, "pcl"));
desc = "The PropertyChangeListener to register.";
jdDesc = jdc.getParamDescriptor("pcl");
jdDesc.setDescription(desc);
parent.addMethod(jMethod);
jsc = jMethod.getSourceCode();
jsc.add("if (");
jsc.append(vName);
jsc.append(" == null) {");
jsc.addIndented(vName + " = new java.beans.PropertyChangeSupport(this);");
jsc.add("}");
jsc.add(vName);
jsc.append(".addPropertyChangeListener(pcl);");
//--------------------------------/
//- removePropertyChangeListener -/
//--------------------------------/
jMethod = new JMethod("removePropertyChangeListener", JType.BOOLEAN,
"always returns true if pcl != null");
desc = "Removes the given PropertyChangeListener "
+ "from this classes list of ProperyChangeListeners.";
jdc = jMethod.getJDocComment();
jdc.appendComment(desc);
jMethod.addParameter(new JParameter(jType, "pcl"));
desc = "The PropertyChangeListener to remove.";
jdDesc = jdc.getParamDescriptor("pcl");
jdDesc.setDescription(desc);
parent.addMethod(jMethod);
jsc = jMethod.getSourceCode();
jsc.add("if (");
jsc.append(vName);
jsc.append(" == null) return false;");
jsc.add(vName);