Search in sources :

Example 6 with ArchiveCatalogue

use of org.yamcs.studio.core.model.ArchiveCatalogue in project yamcs-studio by yamcs.

the class ArchiveIndexReceiver method updateTag.

public void updateTag(ArchiveTag oldTag, ArchiveTag newTag) {
    EditTagRequest.Builder requestb = EditTagRequest.newBuilder();
    if (newTag.hasName())
        requestb.setName(newTag.getName());
    if (newTag.hasColor())
        requestb.setColor(newTag.getColor());
    if (newTag.hasDescription())
        requestb.setDescription(newTag.getDescription());
    if (newTag.hasStart())
        requestb.setStart(TimeEncoding.toString(newTag.getStart()));
    if (newTag.hasStop())
        requestb.setStop(TimeEncoding.toString(newTag.getStop()));
    long tagTime = oldTag.hasStart() ? oldTag.getStart() : 0;
    int tagId = oldTag.getId();
    ArchiveCatalogue catalogue = ArchiveCatalogue.getInstance();
    catalogue.editTag(tagTime, tagId, requestb.build()).thenRun(() -> {
        archiveView.tagChanged(oldTag, newTag);
    });
}
Also used : EditTagRequest(org.yamcs.protobuf.Rest.EditTagRequest) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue)

Example 7 with ArchiveCatalogue

use of org.yamcs.studio.core.model.ArchiveCatalogue in project yamcs-studio by yamcs.

the class ArchiveIndexReceiver method createTag.

public void createTag(ArchiveTag tag) {
    CreateTagRequest.Builder requestb = CreateTagRequest.newBuilder();
    if (tag.hasName())
        requestb.setName(tag.getName());
    if (tag.hasColor())
        requestb.setColor(tag.getColor());
    if (tag.hasDescription())
        requestb.setDescription(tag.getDescription());
    if (tag.hasStart())
        requestb.setStart(TimeEncoding.toString(tag.getStart()));
    if (tag.hasStop())
        requestb.setStop(TimeEncoding.toString(tag.getStop()));
    ArchiveCatalogue catalogue = ArchiveCatalogue.getInstance();
    catalogue.createTag(requestb.build()).whenComplete((data, exc) -> {
        if (exc != null) {
            ArchiveTag response;
            try {
                response = ArchiveTag.parseFrom(data);
                archiveView.tagAdded(response);
            } catch (InvalidProtocolBufferException e) {
                log.log(Level.SEVERE, "Failed to decode server message", e);
            }
        }
    });
}
Also used : CreateTagRequest(org.yamcs.protobuf.Rest.CreateTagRequest) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue) ArchiveTag(org.yamcs.protobuf.Yamcs.ArchiveTag)

Aggregations

ArchiveCatalogue (org.yamcs.studio.core.model.ArchiveCatalogue)7 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 YamcsApiException (org.yamcs.api.YamcsApiException)2 CreateTagRequest (org.yamcs.protobuf.Rest.CreateTagRequest)2 EditTagRequest (org.yamcs.protobuf.Rest.EditTagRequest)2 ListTagsResponse (org.yamcs.protobuf.Rest.ListTagsResponse)2 ArchiveTag (org.yamcs.protobuf.Yamcs.ArchiveTag)2 TimeInterval (org.yamcs.studio.core.TimeInterval)2 YamcsClient (org.yamcs.studio.core.client.YamcsClient)2 TimeCatalogue (org.yamcs.studio.core.model.TimeCatalogue)2 TimeEncoding (org.yamcs.utils.TimeEncoding)2 Calendar (java.util.Calendar)1 List (java.util.List)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 TitleAreaDialog (org.eclipse.jface.dialogs.TitleAreaDialog)1 SWT (org.eclipse.swt.SWT)1 GridData (org.eclipse.swt.layout.GridData)1