}
private StaticTextItem buildBaseUnitsItem(final SelectItem metricDropDownMenu, FormItemIfFunction ifFunc,
boolean editMode) {
String baseUnits = MSG.view_alert_definition_condition_editor_common_baseUnits();
final StaticTextItem baseUnitsItem = new StaticTextItem("baseUnits", baseUnits);
baseUnitsItem.setHoverWidth(200);
baseUnitsItem.setShowIfCondition(ifFunc);
metricDropDownMenu.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
MeasurementDefinition measDef = getMeasurementDefinition(metricDropDownMenu.getValueAsString());
baseUnitsItem.setValue(measDef.getUnits() == MeasurementUnits.NONE ? MSG
.view_alert_definition_condition_editor_common_baseUnits_none() : measDef.getUnits().toString());
List<MeasurementUnits> availableUnits = measDef.getUnits().getFamilyUnits();
baseUnitsItem.setTooltip(MSG.view_alert_definition_condition_editor_common_baseUnits_availableUnits()
+ (availableUnits.isEmpty() || availableUnits.get(0) == MeasurementUnits.NONE ? MSG
.view_alert_definition_condition_editor_common_baseUnits_none() : availableUnits));
}
});
// initialize the field, the default will be the first entry in the value map
MeasurementDefinition defaultMeasDef = getMeasurementDefinition((String) metricDropDownMenu
.getAttributeAsMap("valueMap").keySet().iterator().next());
MeasurementUnits units = defaultMeasDef.getUnits();
baseUnitsItem.setValue(units == MeasurementUnits.NONE ? MSG
.view_alert_definition_condition_editor_common_baseUnits_none() : units.toString());
List<MeasurementUnits> availableUnits = units.getFamilyUnits();
baseUnitsItem.setTooltip(MSG.view_alert_definition_condition_editor_common_baseUnits_availableUnits()
+ (availableUnits.isEmpty() || availableUnits.get(0) == MeasurementUnits.NONE ? MSG
.view_alert_definition_condition_editor_common_baseUnits_none() : availableUnits));
return baseUnitsItem;
}