use of org.phoebus.logbook.ui.write.LogEntryEditorStage in project phoebus by ControlSystemStudio.
the class SendLogbookAction method submitLogEntry.
private void submitLogEntry(final Node parent, final String title, final String body, final File image_file) {
LogEntryBuilder logEntryBuilder = new LogEntryBuilder();
if (title != null)
logEntryBuilder.title(title);
if (body != null)
logEntryBuilder.appendDescription(body);
if (image_file != null) {
try {
final Attachment attachment = AttachmentImpl.of(image_file, "image", false);
logEntryBuilder.attach(attachment);
} catch (FileNotFoundException ex) {
logger.log(Level.WARNING, "Cannot attach " + image_file, ex);
}
}
final LogEntryModel model = new LogEntryModel(logEntryBuilder.createdDate(Instant.now()).build());
new LogEntryEditorStage(parent, model, null).show();
}
use of org.phoebus.logbook.ui.write.LogEntryEditorStage in project phoebus by ControlSystemStudio.
the class PACEInstance method doSaveChanges.
private void doSaveChanges(final JobMonitor monitor) {
final String text = createElogText();
final LogEntryBuilder builder = new LogEntryBuilder();
builder.title(MessageFormat.format(Messages.ELogTitleFmt, model.getTitle()));
builder.appendDescription(text);
final LogEntry entry = builder.createdDate(Instant.now()).build();
LogEntryModel logEntryModel = new LogEntryModel(entry);
new LogEntryEditorStage(gui, logEntryModel, logEntry -> {
if (logEntry != null) {
final String user = logEntryModel.getUsername();
try {
// Change PVs
model.saveUserValues(user);
// On success, clear user values
model.clearUserValues();
} catch (Exception ex) {
logger.log(Level.WARNING, "Save failed", ex);
// At least some saves failed, to revert
try {
model.revertOriginalValues();
} catch (Exception ex2) {
// Since saving didn't work, restoral will also fail.
// Hopefully those initial PVs that did get updated will
// also be restored...
logger.log(Level.WARNING, "Restore failed", ex2);
}
ExceptionDetailsErrorDialog.openError(gui, Messages.SaveError, Messages.PVWriteError, ex);
}
}
}).show();
}
Aggregations