Search in sources :

Example 6 with ArchiveTag

use of org.yamcs.protobuf.Yamcs.ArchiveTag in project yamcs-studio by yamcs.

the class TagBox method buildPopup.

protected void buildPopup() {
    editTagPopup = new JPopupMenu();
    tagLabelItem = new JLabel();
    tagLabelItem.setEnabled(false);
    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createHorizontalGlue());
    hbox.add(tagLabelItem);
    hbox.add(Box.createHorizontalGlue());
    editTagPopup.insert(hbox, 0);
    editTagPopup.addSeparator();
    editTagMenuItem = new JMenuItem("Edit Annotation");
    editTagMenuItem.addActionListener(evt -> {
        ArchiveTag selectedTag = tags.get(selectedRow).get(selectedIndex);
        Display.getDefault().asyncExec(() -> {
            CreateAnnotationDialog dialog = new CreateAnnotationDialog(Display.getCurrent().getActiveShell());
            dialog.fillFrom(selectedTag);
            if (dialog.open() == Window.OK) {
                SwingUtilities.invokeLater(() -> {
                    System.out.println("signal update to " + dialog.buildArchiveTag());
                    dataView.emitActionEvent(new TagEvent(this, "update-tag", selectedTag, dialog.buildArchiveTag()));
                });
            }
        });
    });
    editTagPopup.add(editTagMenuItem);
    removeTagMenuItem = new JMenuItem("Remove Annotation");
    removeTagMenuItem.addActionListener(evt -> {
        ArchiveTag selectedTag = tags.get(selectedRow).get(selectedIndex);
        int answer = JOptionPane.showConfirmDialog(null, "Remove " + selectedTag.getName() + " ?", "Are you sure?", JOptionPane.YES_NO_OPTION);
        if (answer == JOptionPane.YES_OPTION) {
            dataView.emitActionEvent(new TagEvent(this, "delete-tag", selectedTag, null));
        }
    });
    editTagPopup.add(removeTagMenuItem);
}
Also used : JLabel(javax.swing.JLabel) Box(javax.swing.Box) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu) ArchiveTag(org.yamcs.protobuf.Yamcs.ArchiveTag)

Example 7 with ArchiveTag

use of org.yamcs.protobuf.Yamcs.ArchiveTag 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

ArchiveTag (org.yamcs.protobuf.Yamcs.ArchiveTag)7 ArrayList (java.util.ArrayList)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 Insets (java.awt.Insets)1 LineMetrics (java.awt.font.LineMetrics)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 List (java.util.List)1 Box (javax.swing.Box)1 JLabel (javax.swing.JLabel)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 RGB (org.eclipse.swt.graphics.RGB)1 CreateTagRequest (org.yamcs.protobuf.Rest.CreateTagRequest)1 ArchiveCatalogue (org.yamcs.studio.core.model.ArchiveCatalogue)1