Search in sources :

Example 1 with EventCatalogue

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

Example 2 with EventCatalogue

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());
}
Also used : ManagementCatalogue(org.yamcs.studio.core.model.ManagementCatalogue) YamcsClient(org.yamcs.studio.core.client.YamcsClient) TimeCatalogue(org.yamcs.studio.core.model.TimeCatalogue) ParameterCatalogue(org.yamcs.studio.core.model.ParameterCatalogue) AlarmCatalogue(org.yamcs.studio.core.model.AlarmCatalogue) EventCatalogue(org.yamcs.studio.core.model.EventCatalogue) CommandingCatalogue(org.yamcs.studio.core.model.CommandingCatalogue) LinkCatalogue(org.yamcs.studio.core.model.LinkCatalogue) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue)

Example 3 with EventCatalogue

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);
            });
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) TimeCatalogue(org.yamcs.studio.core.model.TimeCatalogue) TimeInterval(org.yamcs.studio.core.TimeInterval) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) Display(org.eclipse.swt.widgets.Display) EventCatalogue(org.yamcs.studio.core.model.EventCatalogue) List(java.util.List) RowLayout(org.eclipse.swt.layout.RowLayout) Calendar(java.util.Calendar) TitleAreaDialog(org.eclipse.jface.dialogs.TitleAreaDialog) Composite(org.eclipse.swt.widgets.Composite) TimeEncoding(org.yamcs.utils.TimeEncoding) SWT(org.eclipse.swt.SWT) RCPUtils(org.yamcs.studio.core.ui.utils.RCPUtils) GridData(org.eclipse.swt.layout.GridData) DateTime(org.eclipse.swt.widgets.DateTime) Label(org.eclipse.swt.widgets.Label) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) EventCatalogue(org.yamcs.studio.core.model.EventCatalogue)

Aggregations

EventCatalogue (org.yamcs.studio.core.model.EventCatalogue)3 TimeCatalogue (org.yamcs.studio.core.model.TimeCatalogue)2 Calendar (java.util.Calendar)1 List (java.util.List)1 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 TitleAreaDialog (org.eclipse.jface.dialogs.TitleAreaDialog)1 SWT (org.eclipse.swt.SWT)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 DateTime (org.eclipse.swt.widgets.DateTime)1 Display (org.eclipse.swt.widgets.Display)1 Label (org.eclipse.swt.widgets.Label)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 Shell (org.eclipse.swt.widgets.Shell)1 EventSeverity (org.yamcs.protobuf.Yamcs.Event.EventSeverity)1 TimeInterval (org.yamcs.studio.core.TimeInterval)1 YamcsClient (org.yamcs.studio.core.client.YamcsClient)1