Search in sources :

Example 1 with GUI

use of org.csstudio.display.pace.gui.GUI 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)

Example 2 with GUI

use of org.csstudio.display.pace.gui.GUI in project phoebus by ControlSystemStudio.

the class GUIDemo method start.

@Override
public void start(final Stage stage) throws Exception {
    final GUI gui = new GUI(dirty -> System.out.println("Table is dirty: " + dirty));
    stage.setScene(new Scene(gui, 800, 600));
    stage.show();
    JobManager.schedule("Load...", monitor -> {
        Thread.sleep(2000);
        final Model model = new Model(Model.class.getResourceAsStream("/pace_examples/localtest.pace"));
        gui.setModel(model);
        model.start();
    });
}
Also used : Model(org.csstudio.display.pace.model.Model) GUI(org.csstudio.display.pace.gui.GUI) Scene(javafx.scene.Scene)

Aggregations

GUI (org.csstudio.display.pace.gui.GUI)2 Model (org.csstudio.display.pace.model.Model)2 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 Scene (javafx.scene.Scene)1 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)1 PACEApp.logger (org.csstudio.display.pace.PACEApp.logger)1 Cell (org.csstudio.display.pace.model.Cell)1 Instance (org.csstudio.display.pace.model.Instance)1 JobManager (org.phoebus.framework.jobs.JobManager)1 JobMonitor (org.phoebus.framework.jobs.JobMonitor)1 AppDescriptor (org.phoebus.framework.spi.AppDescriptor)1 AppInstance (org.phoebus.framework.spi.AppInstance)1 LogEntry (org.phoebus.logbook.LogEntry)1 LogEntryBuilder (org.phoebus.logbook.LogEntryImpl.LogEntryBuilder)1