abbreviations.put("i", CrmXml.INFINITY_VALUE.getValueForConfig());
abbreviations.put("+", CrmXml.PLUS_INFINITY_VALUE.getValueForConfig());
abbreviations.put("I", CrmXml.INFINITY_VALUE.getValueForConfig());
abbreviations.put("a", "ALWAYS");
abbreviations.put("n", "NEVER");
final Widget wi = widgetFactory.createInstance(
Widget.Type.COMBOBOX,
NOTHING_SELECTED_VALUE,
new Value[]{NOTHING_SELECTED_VALUE,
new StringValue("0"),
new StringValue("2"),
new StringValue("ALWAYS"),
new StringValue("NEVER"),
CrmXml.INFINITY_VALUE,
CrmXml.MINUS_INFINITY_VALUE,
CrmXml.INFINITY_VALUE},
"^((-?\\d*|(-|\\+)?"
+ CrmXml.INFINITY_VALUE
+ "))|ALWAYS|NEVER|@NOTHING_SELECTED@$",
rightWidth,
abbreviations,
new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
Widget.NO_BUTTON);
wi.setEditable(true);
final Widget prevWi = scoreComboBoxHash.get(hi);
scoreComboBoxHash.put(hi, wi);
/* set selected host scores in the combo box from
* savedHostLocations */
if (prevWi == null) {
final HostLocation hl = savedHostLocations.get(hi);
String hsSaved = null;
if (hl != null) {
hsSaved = hl.getScore();
}
wi.setValue(new StringValue(hsSaved));
} else {
wi.setValue(prevWi.getValue());
}
}
/* host score combo boxes */
int rows = 0;
for (final Host host : getBrowser().getClusterHosts()) {
final HostInfo hi = host.getBrowser().getHostInfo();
final Widget wi = scoreComboBoxHash.get(hi);
String op = null;
final HostLocation hl = savedHostLocations.get(hi);
if (hl != null) {
op = hl.getOperation();
}
final String text = getHostLocationLabel(hi.getName(), op);
final JLabel label = new JLabel(text);
final String onText = getHostLocationLabel(hi.getName(), "eq");
final String notOnText = getHostLocationLabel(hi.getName(), "ne");
label.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(final MouseEvent e) {
/* do nothing */
}
@Override
public void mouseEntered(final MouseEvent e) {
/* do nothing */
}
@Override
public void mouseExited(final MouseEvent e) {
/* do nothing */
}
@Override
public void mousePressed(final MouseEvent e) {
final String currentText = label.getText();
application.invokeLater(new Runnable() {
@Override
public void run() {
if (currentText.equals(onText)) {
label.setText(notOnText);
} else {
label.setText(onText);
}
final String[] params = getParametersFromXML();
setApplyButtons(CACHED_FIELD, params);
}
});
}
@Override
public void mouseReleased(final MouseEvent e) {
/* do nothing */
}
});
wi.setLabel(label, text);
addField(panel, label, wi.getComponent(), leftWidth, rightWidth, 0);
rows++;
}
rows += addPingField(panel, leftWidth, rightWidth);
SpringUtilities.makeCompactGrid(panel, rows, 2, /* rows, cols */