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);
}
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);
}
}
});
}
Aggregations