public CustomizeAlertPanel( TenantIdentifier tenant, JobIdentifier job, AlertDefinition alert, JobMetrics result) { super(); _alert = alert; metricAnchor = new MetricAnchor(tenant); metricAnchor.setJobMetrics(result); metricAnchor.setMetric(_alert.getMetricIdentifier()); initWidget(uiBinder.createAndBindUi(this)); _severityIntelligenceRadio = createRadioButton("alert_severity", "Intelligence", AlertSeverity.INTELLIGENCE); _severitySurveillanceRadio = createRadioButton("alert_severity", "Surveillance", AlertSeverity.SURVEILLANCE); _severityWarningRadio = createRadioButton("alert_severity", "Warning", AlertSeverity.WARNING); _severityFatalRadio = createRadioButton("alert_severity", "Fatal", AlertSeverity.FATAL); if (getSelectedSeverity() == null) { // set default severity _severityIntelligenceRadio.setValue(true); } descriptionTextBox.setText(_alert.getDescription()); minimumValueTextBox.setNumberValue(_alert.getMinimumValue()); maximumValueTextBox.setNumberValue(_alert.getMaximumValue()); }
public AlertDefinition updateAlert() { final Integer max = maximumValueTextBox.getNumberValue(); final Integer min = minimumValueTextBox.getNumberValue(); if (max == null && min == null) { throw new DCUserInputException( "Please enter a maximum or a minimum value for the selected metric."); } _alert.setMetricIdentifier(metricAnchor.getMetric()); _alert.setDescription(descriptionTextBox.getText()); _alert.setMaximumValue(max); _alert.setMinimumValue(min); _alert.setSeverity(getSelectedSeverity()); return _alert; }