Search in sources :

Example 1 with LogEntryEditorStage

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();
}
Also used : LogEntryModel(org.phoebus.logbook.ui.write.LogEntryModel) FileNotFoundException(java.io.FileNotFoundException) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) Attachment(org.phoebus.logbook.Attachment) LogEntryEditorStage(org.phoebus.logbook.ui.write.LogEntryEditorStage)

Example 2 with LogEntryEditorStage

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();
}
Also used : LogEntry(org.phoebus.logbook.LogEntry) JobManager(org.phoebus.framework.jobs.JobManager) Cell(org.csstudio.display.pace.model.Cell) AppInstance(org.phoebus.framework.spi.AppInstance) LogEntryEditorStage(org.phoebus.logbook.ui.write.LogEntryEditorStage) JobMonitor(org.phoebus.framework.jobs.JobMonitor) HashMap(java.util.HashMap) Instance(org.csstudio.display.pace.model.Instance) AppDescriptor(org.phoebus.framework.spi.AppDescriptor) LogEntryModel(org.phoebus.logbook.ui.write.LogEntryModel) Instant(java.time.Instant) MessageFormat(java.text.MessageFormat) Level(java.util.logging.Level) PACEApp.logger(org.csstudio.display.pace.PACEApp.logger) Platform(javafx.application.Platform) Model(org.csstudio.display.pace.model.Model) Map(java.util.Map) URI(java.net.URI) DockPane(org.phoebus.ui.docking.DockPane) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) ExceptionDetailsErrorDialog(org.phoebus.ui.dialog.ExceptionDetailsErrorDialog) DockItemWithInput(org.phoebus.ui.docking.DockItemWithInput) GUI(org.csstudio.display.pace.gui.GUI) LogEntryModel(org.phoebus.logbook.ui.write.LogEntryModel) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) LogEntryEditorStage(org.phoebus.logbook.ui.write.LogEntryEditorStage) LogEntry(org.phoebus.logbook.LogEntry)

Aggregations

LogEntryBuilder (org.phoebus.logbook.LogEntryImpl.LogEntryBuilder)2 LogEntryEditorStage (org.phoebus.logbook.ui.write.LogEntryEditorStage)2 LogEntryModel (org.phoebus.logbook.ui.write.LogEntryModel)2 FileNotFoundException (java.io.FileNotFoundException)1 URI (java.net.URI)1 MessageFormat (java.text.MessageFormat)1 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Level (java.util.logging.Level)1 Platform (javafx.application.Platform)1 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)1 PACEApp.logger (org.csstudio.display.pace.PACEApp.logger)1 GUI (org.csstudio.display.pace.gui.GUI)1 Cell (org.csstudio.display.pace.model.Cell)1 Instance (org.csstudio.display.pace.model.Instance)1 Model (org.csstudio.display.pace.model.Model)1 JobManager (org.phoebus.framework.jobs.JobManager)1 JobMonitor (org.phoebus.framework.jobs.JobMonitor)1 AppDescriptor (org.phoebus.framework.spi.AppDescriptor)1