MVCUtilspublic class MVCUtils extends Object
Fields Summary |
---|
private static final String | TRUE | private static final String | EMPTY |
Constructors Summary |
---|
private MVCUtils()Creates new MVCUtils
|
Methods Summary |
---|
private static java.lang.String | getStringElementValue(java.lang.Object model, java.lang.String propName)
String retVal = EMPTY;
Method reader = null;
try {
PropertyDescriptor destPd = new PropertyDescriptor(propName, model.getClass());
reader = destPd.getReadMethod();
Object tmp = reader.invoke(model,null);
if (null != tmp)
retVal =tmp.toString();
}
catch (Throwable t) {
Reporter.critical(new StackTrace(t)); //NOI18N
}
return retVal;
| public static void | linkBooleanStringElement(java.lang.Object model, javax.swing.AbstractButton view, java.lang.String propName) //NOI18N
view.addItemListener(new BooleanStringItemListener(model, propName));
view.setSelected(getStringElementValue(model, propName).equals(TRUE));
| public static void | linkBooleanStringElement(java.lang.Object model, javax.swing.AbstractButton view)
String propName = view.getName();
if (null != propName) {
linkBooleanStringElement(model,view,propName);
}
else
Reporter.critical("the name of the " + model + " is null"); //NOI18N
| public static void | linkIntStringElement(java.lang.Object model, javax.swing.text.JTextComponent view, java.lang.String propName)
view.addKeyListener(new IntStringItemListener(model,propName));
view.setText(getStringElementValue(model,propName));
| public static void | linkIntStringElement(java.lang.Object model, javax.swing.text.JTextComponent view, java.lang.String propName, int defaultValue)
view.addKeyListener(new IntStringItemListener(model,propName));
String tval = getStringElementValue(model,propName);
view.setText(getStringElementValue(model,propName));
if (null == tval || tval.equals(EMPTY))
view.setText(EMPTY + defaultValue);
| public static void | linkIntStringElement(java.lang.Object model, javax.swing.text.JTextComponent view, java.lang.String propName, int min, int max)
view.addKeyListener(new IntStringItemListener(model,propName, min, max));
// String tval = getStringElementValue(model,propName);
view.setText(getStringElementValue(model,propName));
// if (null == tval || tval.equals(""))
// view.setText("" + defaultValue);
| public static void | linkIntStringElement(java.lang.Object model, javax.swing.text.JTextComponent view, java.lang.String propName, int defaultValue, int min, int max)
view.addKeyListener(new IntStringItemListener(model,propName, min, max));
String tval = getStringElementValue(model,propName);
view.setText(getStringElementValue(model,propName));
if (null == tval || tval.equals(EMPTY))
view.setText(EMPTY + defaultValue);
| public static void | linkStringElement(java.lang.Object model, javax.swing.text.JTextComponent view, java.lang.String propName)
view.addKeyListener(new StringItemListener(model,propName));
view.setText(getStringElementValue(model,propName));
| public static void | linkStringElement(java.lang.Object model, javax.swing.text.JTextComponent view)
String propName = view.getName();
if (null != propName) {
linkStringElement(model,view,propName);
}
else
Reporter.critical("the name of the " + model + " is null"); //NOI18N
| public static void | selectionSensitive(java.lang.Object hasListSelectionModel, java.awt.Component sensitiveItem)
try {
Method getter = hasListSelectionModel.getClass().getMethod("getSelectionModel",null); //NOI18N
javax.swing.ListSelectionModel lsm[] = new javax.swing.ListSelectionModel[1];
Class lsmArgs[] = { javax.swing.ListSelectionModel.class };
if (null != getter) {
lsm[0] = (javax.swing.ListSelectionModel) getter.invoke(hasListSelectionModel,null);
if (null == lsm[0]) {
lsm[0] = new javax.swing.DefaultListSelectionModel();
Method putter = hasListSelectionModel.getClass().getMethod("setSelectionModel", lsmArgs); //NOI18N
putter.invoke(hasListSelectionModel,lsm);
}
lsm[0].addListSelectionListener(new SelectionActivator(sensitiveItem, hasListSelectionModel));
}
}
catch (Throwable t) {
Reporter.critical(new StackTrace(t)); //NOI18N
}
| public static void | validationSensitive(javax.swing.text.JTextComponent f, java.awt.Component sensitive, com.sun.enterprise.tools.common.Validator v)
StringValidationListener svl =
new StringValidationListener(sensitive,v);
f.addKeyListener(svl);
|
|