Search in sources :

Example 1 with EventSeverity

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();
        });
    }
}
Also used : EventSeverity(org.yamcs.protobuf.Yamcs.Event.EventSeverity) EventCatalogue(org.yamcs.studio.core.model.EventCatalogue) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

MessageBox (org.eclipse.swt.widgets.MessageBox)1 EventSeverity (org.yamcs.protobuf.Yamcs.Event.EventSeverity)1 EventCatalogue (org.yamcs.studio.core.model.EventCatalogue)1