use of org.yamcs.protobuf.Yamcs.Event.EventSeverity in project yamcs-studio by yamcs.
the class AddManualEventDialog method okPressed.
@Override
protected void okPressed() {
String source = "Manual";
if (userText != null && !userText.getText().isEmpty()) {
source += " :: " + userText.getText();
} else if (userLbl != null) {
source += " :: " + userLbl.getText();
}
String message = messageText.getText();
long generationTime = TimeEncoding.fromCalendar(RCPUtils.toCalendar(generationDatePicker, generationTimePicker));
long receptionTime = TimeCatalogue.getInstance().getMissionTime();
EventSeverity severity = EventSeverity.internalGetValueMap().findValueByNumber(severityCombo.getSelectionIndex() > 3 ? severityCombo.getSelectionIndex() + 1 : severityCombo.getSelectionIndex());
EventCatalogue catalogue = EventCatalogue.getInstance();
try {
catalogue.createEvent(source, sequenceNumber++, message, generationTime, receptionTime, severity).whenComplete((data, exc) -> {
if (exc == null) {
Display.getDefault().asyncExec(() -> {
// MessageBox m = new MessageBox(getShell(),
// SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
// m.setText("Ok");
// m.setMessage("Added the manual event successfully.\n" + new String(data));
// m.open();
close();
});
} else {
Display.getDefault().asyncExec(() -> {
MessageBox m = new MessageBox(getShell(), SWT.OK | SWT.ICON_ERROR | SWT.APPLICATION_MODAL);
m.setText("Error");
m.setMessage(exc.getMessage());
m.open();
});
}
});
} catch (Exception e) {
Display.getDefault().asyncExec(() -> {
MessageBox m = new MessageBox(getShell(), SWT.OK | SWT.ICON_ERROR | SWT.APPLICATION_MODAL);
m.setText("Error");
m.setMessage("Error: " + e.getMessage());
m.open();
});
}
}
Aggregations