use of org.yamcs.studio.core.model.EventCatalogue 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();
});
}
}
use of org.yamcs.studio.core.model.EventCatalogue in project yamcs-studio by yamcs.
the class YamcsPlugin method start.
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
TimeEncoding.setUp();
yamcsClient = new YamcsClient(getProductString(), true);
yamcsClient.addConnectionListener(new UIConnectionListener());
ManagementCatalogue managementCatalogue = new ManagementCatalogue();
catalogues.put(ManagementCatalogue.class, managementCatalogue);
addYamcsConnectionListener(managementCatalogue);
registerCatalogue(new TimeCatalogue());
registerCatalogue(new ParameterCatalogue());
registerCatalogue(new CommandingCatalogue());
registerCatalogue(new AlarmCatalogue());
registerCatalogue(new EventCatalogue());
registerCatalogue(new LinkCatalogue());
registerCatalogue(new ArchiveCatalogue());
}
use of org.yamcs.studio.core.model.EventCatalogue in project yamcs-studio by yamcs.
the class ImportPastEventsDialog method okPressed.
@Override
protected void okPressed() {
getButton(IDialogConstants.OK_ID).setEnabled(false);
long start = TimeEncoding.fromCalendar(RCPUtils.toCalendar(startDate, startTime));
long stop = TimeEncoding.fromCalendar(RCPUtils.toCalendar(stopDate, stopTime));
EventCatalogue catalogue = EventCatalogue.getInstance();
catalogue.downloadEvents(start, stop, batch -> {
Display.getDefault().asyncExec(() -> eventLog.addEvents(batch));
}).whenComplete((data, exc) -> {
if (exc == null) {
Display.getDefault().asyncExec(() -> {
eventLog.addedAllEvents();
ImportPastEventsDialog.super.okPressed();
});
} else {
Display.getDefault().asyncExec(() -> {
getButton(IDialogConstants.OK_ID).setEnabled(true);
});
}
});
}
Aggregations