Search in sources :

Example 6 with Tag

use of org.phoebus.logbook.Tag in project phoebus by ControlSystemStudio.

the class LogEntryTableDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    ResourceBundle resourceBundle = NLS.getMessages(Messages.class);
    FXMLLoader loader = new FXMLLoader();
    loader.setResources(resourceBundle);
    loader.setLocation(this.getClass().getResource("LogEntryTableView.fxml"));
    loader.setControllerFactory(clazz -> {
        try {
            if (clazz.isAssignableFrom(LogEntryTableViewController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(AdvancedSearchViewController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(SingleLogEntryDisplayController.class)) {
                return clazz.getConstructor(String.class).newInstance(getLogClient().getServiceUrl());
            } else if (clazz.isAssignableFrom(LogPropertiesController.class)) {
                return clazz.getConstructor().newInstance();
            } else if (clazz.isAssignableFrom(AttachmentsPreviewController.class)) {
                return clazz.getConstructor().newInstance();
            } else if (clazz.isAssignableFrom(LogEntryCellController.class)) {
                return clazz.getConstructor().newInstance();
            } else if (clazz.isAssignableFrom(LogEntryDisplayController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(MergedLogEntryDisplayController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(SingleLogEntryDisplayController.class)) {
                return clazz.getConstructor(String.class).newInstance(getLogClient().getServiceUrl());
            } else {
                throw new RuntimeException("No controller for class " + clazz.getName());
            }
        } catch (Exception e) {
            Logger.getLogger(LogEntryEditorStage.class.getName()).log(Level.SEVERE, "Failed to construct controller for log calendar view", e);
        }
        return null;
    });
    loader.load();
    LogEntryTableViewController controller = loader.getController();
    Parent root = loader.getRoot();
    primaryStage.setScene(new Scene(root, 400, 400));
    primaryStage.show();
    List<LogEntry> logs = new ArrayList<LogEntry>();
    Set<Tag> tags = new HashSet<Tag>();
    tags.add(TagImpl.of("tag1", "active"));
    tags.add(TagImpl.of("tag2", "active"));
    Set<Logbook> logbooks = new HashSet<Logbook>();
    logbooks.add(LogbookImpl.of("logbook1", "active"));
    logbooks.add(LogbookImpl.of("logbook2", "active"));
    File imageFile = new File(this.getClass().getClassLoader().getResource("image_1.png").toURI());
    File textFile = new File(this.getClass().getClassLoader().getResource("file_phoebus.txt").toURI());
    List<File> listOfFiles = Arrays.asList(imageFile, textFile);
    Map<String, String> tracAttributes = new HashMap<>();
    tracAttributes.put("id", "1234");
    tracAttributes.put("URL", "https://trac.epics.org/tickets/1234");
    Property track = PropertyImpl.of("Track", tracAttributes);
    Map<String, String> experimentAttributes = new HashMap<>();
    experimentAttributes.put("id", "1234");
    experimentAttributes.put("type", "XPD xray diffraction");
    experimentAttributes.put("scan-id", "6789");
    Property experimentProperty = PropertyImpl.of("Experiment", experimentAttributes);
    for (int i = 0; i < 10; i++) {
        Thread.sleep(500);
        LogEntryBuilder lb = LogEntryBuilder.log().owner("Owner").title("log " + i).description("First line for log " + i).createdDate(Instant.now()).inLogbooks(logbooks).id(Long.valueOf(i)).withTags(tags);
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < i; j++) {
            sb.append("Some additional log text");
        }
        lb.appendDescription(sb.toString());
        if (i % 2 != 0) {
            listOfFiles.forEach(file -> {
                try {
                    lb.attach(AttachmentImpl.of(file));
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            });
            lb.appendProperty(experimentProperty);
            lb.appendProperty(track);
        }
        logs.add(lb.build());
    }
    controller.setLogs(logs);
}
Also used : LogClient(org.phoebus.logbook.LogClient) Parent(javafx.scene.Parent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) FXMLLoader(javafx.fxml.FXMLLoader) Logbook(org.phoebus.logbook.Logbook) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) Property(org.phoebus.logbook.Property) LogEntry(org.phoebus.logbook.LogEntry) HashSet(java.util.HashSet) LogEntryEditorStage(org.phoebus.logbook.olog.ui.write.LogEntryEditorStage) Scene(javafx.scene.Scene) LogbookException(org.phoebus.logbook.LogbookException) FileNotFoundException(java.io.FileNotFoundException) ResourceBundle(java.util.ResourceBundle) Tag(org.phoebus.logbook.Tag) File(java.io.File)

Example 7 with Tag

use of org.phoebus.logbook.Tag in project phoebus by ControlSystemStudio.

the class LogEntrySearchDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    ResourceBundle resourceBundle = NLS.getMessages(Messages.class);
    FXMLLoader loader = new FXMLLoader();
    loader.setResources(resourceBundle);
    loader.setLocation(this.getClass().getResource("LogEntryTableView.fxml"));
    loader.setControllerFactory(clazz -> {
        try {
            if (clazz.isAssignableFrom(LogEntryTableViewController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(AdvancedSearchViewController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(LogPropertiesController.class)) {
                return clazz.getConstructor().newInstance();
            } else if (clazz.isAssignableFrom(AttachmentsPreviewController.class)) {
                return clazz.getConstructor().newInstance();
            } else if (clazz.isAssignableFrom(LogEntryCellController.class)) {
                return clazz.getConstructor().newInstance();
            } else if (clazz.isAssignableFrom(LogEntryDisplayController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(MergedLogEntryDisplayController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(SingleLogEntryDisplayController.class)) {
                return clazz.getConstructor(String.class).newInstance(getLogClient().getServiceUrl());
            } else {
                throw new RuntimeException("No controller for class " + clazz.getName());
            }
        } catch (Exception e) {
            Logger.getLogger(LogEntryEditorStage.class.getName()).log(Level.SEVERE, "Failed to construct controller for log calendar view", e);
        }
        return null;
    });
    loader.load();
    LogEntryTableViewController controller = loader.getController();
    Parent root = loader.getRoot();
    primaryStage.setScene(new Scene(root, 400, 400));
    primaryStage.show();
    List<LogEntry> logs = new ArrayList<LogEntry>();
    Set<Tag> tags = new HashSet<Tag>();
    tags.add(TagImpl.of("tag1", "active"));
    tags.add(TagImpl.of("tag2", "active"));
    Set<Logbook> logbooks = new HashSet<Logbook>();
    logbooks.add(LogbookImpl.of("logbook1", "active"));
    logbooks.add(LogbookImpl.of("logbook2", "active"));
    File imageFile = new File(this.getClass().getClassLoader().getResource("image_1.png").toURI());
    File textFile = new File(this.getClass().getClassLoader().getResource("file_phoebus.txt").toURI());
    List<File> listOfFiles = Arrays.asList(imageFile, textFile);
    for (int i = 0; i < 10; i++) {
        LogEntryBuilder lb = LogEntryBuilder.log().owner("Owner").title("log " + i).description("First line for log " + i).createdDate(Instant.now()).inLogbooks(logbooks).id(Long.valueOf(i)).withTags(tags);
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < i; j++) {
            sb.append("Some additional log text");
        }
        lb.appendDescription(sb.toString());
        listOfFiles.forEach(file -> {
            try {
                lb.attach(AttachmentImpl.of(file));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        });
        logs.add(lb.build());
    }
    controller.setLogs(logs);
}
Also used : LogClient(org.phoebus.logbook.LogClient) Parent(javafx.scene.Parent) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) FXMLLoader(javafx.fxml.FXMLLoader) Logbook(org.phoebus.logbook.Logbook) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) LogEntry(org.phoebus.logbook.LogEntry) HashSet(java.util.HashSet) LogEntryEditorStage(org.phoebus.logbook.olog.ui.write.LogEntryEditorStage) Scene(javafx.scene.Scene) LogbookException(org.phoebus.logbook.LogbookException) FileNotFoundException(java.io.FileNotFoundException) ResourceBundle(java.util.ResourceBundle) Tag(org.phoebus.logbook.Tag) File(java.io.File)

Example 8 with Tag

use of org.phoebus.logbook.Tag in project phoebus by ControlSystemStudio.

the class LogEntryTableViewController method initialize.

@FXML
public void initialize() {
    resize.setText("<");
    searchParameters = FXCollections.observableHashMap();
    searchParameters.put(Keys.SEARCH, "*");
    searchParameters.put(Keys.STARTTIME, TimeParser.format(java.time.Duration.ofHours(8)));
    searchParameters.put(Keys.ENDTIME, TimeParser.format(java.time.Duration.ZERO));
    advancedSearchViewController.setSearchParameters(searchParameters);
    query.setText(searchParameters.entrySet().stream().sorted(Map.Entry.comparingByKey()).map((e) -> e.getKey().getName().trim() + "=" + e.getValue().trim()).collect(Collectors.joining("&")));
    searchParameters.addListener((MapChangeListener<Keys, String>) change -> query.setText(searchParameters.entrySet().stream().sorted(Entry.comparingByKey()).map((e) -> e.getKey().getName().trim() + "=" + e.getValue().trim()).collect(Collectors.joining("&"))));
    // The display table.
    tableView.getColumns().clear();
    tableView.setEditable(false);
    timeOwnerCol = new TableColumn<>("Time");
    descriptionCol = new TableColumn<>("Log");
    metaCol = new TableColumn<>("Logbook/Tags");
    timeOwnerCol.setMaxWidth(1f * Integer.MAX_VALUE * 25);
    timeOwnerCol.setCellValueFactory(col -> new SimpleObjectProperty(col.getValue()));
    timeOwnerCol.setCellFactory(col -> {
        final GridPane pane = new GridPane();
        final Label timeText = new Label();
        timeText.setStyle("-fx-font-weight: bold");
        final Label ownerText = new Label();
        pane.addColumn(0, timeText, ownerText);
        return new TableCell<>() {

            @Override
            public void updateItem(LogEntry logEntry, boolean empty) {
                super.updateItem(logEntry, empty);
                if (empty) {
                    setGraphic(null);
                } else {
                    if (logEntry.getCreatedDate() != null) {
                        timeText.setText(SECONDS_FORMAT.format(logEntry.getCreatedDate()));
                    }
                    ownerText.setText(logEntry.getOwner());
                    setGraphic(pane);
                }
            }
        };
    });
    descriptionCol.setMaxWidth(1f * Integer.MAX_VALUE * 50);
    descriptionCol.setCellValueFactory(col -> new SimpleObjectProperty(col.getValue()));
    descriptionCol.setCellFactory(col -> {
        final GridPane pane = new GridPane();
        final Label titleText = new Label();
        titleText.setStyle("-fx-font-weight: bold");
        final Text descriptionText = new Text();
        descriptionText.wrappingWidthProperty().bind(descriptionCol.widthProperty());
        Node parent = topLevelNode.getScene().getRoot();
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("write/AttachmentsView.fxml"));
        fxmlLoader.setControllerFactory(clazz -> {
            try {
                if (clazz.isAssignableFrom(AttachmentsViewController.class)) {
                    AttachmentsViewController attachmentsViewController = (AttachmentsViewController) clazz.getConstructor(Node.class, Boolean.class).newInstance(parent, false);
                    return attachmentsViewController;
                }
            } catch (Exception e) {
                Logger.getLogger(LogEntryTableViewController.class.getName()).log(Level.SEVERE, "Failed to construct controller for attachments view", e);
            }
            return null;
        });
        try {
            Node node = fxmlLoader.load();
            pane.addColumn(0, titleText, descriptionText, node);
        } catch (IOException e) {
            Logger.getLogger(LogEntryTableViewController.class.getName()).log(Level.WARNING, "Unable to load fxml for attachments view", e);
        }
        ColumnConstraints cc = new ColumnConstraints();
        cc.setHgrow(Priority.ALWAYS);
        pane.getColumnConstraints().add(cc);
        return new TableCell<>() {

            @Override
            public void updateItem(LogEntry logEntry, boolean empty) {
                super.updateItem(logEntry, empty);
                if (empty) {
                    setGraphic(null);
                } else {
                    if (logEntry.getTitle() == null || logEntry.getTitle().isEmpty()) {
                        titleText.setVisible(false);
                    } else {
                        titleText.setVisible(true);
                        titleText.setText(logEntry.getTitle());
                    }
                    descriptionText.setText(logEntry.getDescription());
                    AttachmentsViewController controller = fxmlLoader.getController();
                    LogEntryModel model = new LogEntryModel(logEntry);
                    controller.setImages(model.getImages());
                    controller.setFiles(model.getFiles());
                    setGraphic(pane);
                }
            }
        };
    });
    metaCol.setMaxWidth(1f * Integer.MAX_VALUE * 25);
    metaCol.setCellValueFactory(col -> new SimpleObjectProperty(col.getValue()));
    metaCol.setCellFactory(col -> {
        final GridPane pane = new GridPane();
        final Label logbooks = new Label();
        final Separator seperator = new Separator();
        final Label tags = new Label();
        pane.addColumn(0, logbooks, seperator, tags);
        return new TableCell<>() {

            @Override
            public void updateItem(LogEntry logEntry, boolean empty) {
                super.updateItem(logEntry, empty);
                if (empty) {
                    setGraphic(null);
                } else {
                    logbooks.setText(logEntry.getLogbooks().stream().map(Logbook::getName).collect(Collectors.joining(System.lineSeparator())));
                    logbooks.setGraphic(new ImageView(logbook));
                    tags.setText(logEntry.getTags().stream().map(Tag::getName).collect(Collectors.joining(System.lineSeparator())));
                    tags.setGraphic(new ImageView(tag));
                    setGraphic(pane);
                }
            }
        };
    });
    tableView.getColumns().add(timeOwnerCol);
    tableView.getColumns().add(descriptionCol);
    tableView.getColumns().add(metaCol);
    // Bind ENTER key press to search
    query.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
        if (event.getCode() == KeyCode.ENTER) {
            search();
        }
    });
}
Also used : Button(javafx.scene.control.Button) LogEntry(org.phoebus.logbook.LogEntry) Arrays(java.util.Arrays) ColumnConstraints(javafx.scene.layout.ColumnConstraints) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FXCollections(javafx.collections.FXCollections) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) AttachmentsViewController(org.phoebus.logbook.ui.write.AttachmentsViewController) TimeParser(org.phoebus.util.time.TimeParser) FXMLLoader(javafx.fxml.FXMLLoader) Map(java.util.Map) KeyValue(javafx.animation.KeyValue) TableView(javafx.scene.control.TableView) GridPane(javafx.scene.layout.GridPane) SECONDS_FORMAT(org.phoebus.util.time.TimestampFormats.SECONDS_FORMAT) KeyCode(javafx.scene.input.KeyCode) Logbook(org.phoebus.logbook.Logbook) ImageCache(org.phoebus.ui.javafx.ImageCache) KeyFrame(javafx.animation.KeyFrame) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) Node(javafx.scene.Node) MapChangeListener(javafx.collections.MapChangeListener) Tag(org.phoebus.logbook.Tag) Timeline(javafx.animation.Timeline) IOException(java.io.IOException) KeyEvent(javafx.scene.input.KeyEvent) LogEntryModel(org.phoebus.logbook.ui.write.LogEntryModel) ObservableMap(javafx.collections.ObservableMap) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) Separator(javafx.scene.control.Separator) Text(javafx.scene.text.Text) Priority(javafx.scene.layout.Priority) List(java.util.List) Duration(javafx.util.Duration) Keys(org.phoebus.logbook.ui.LogbookQueryUtil.Keys) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ImageView(javafx.scene.image.ImageView) Entry(java.util.Map.Entry) ObservableList(javafx.collections.ObservableList) LogClient(org.phoebus.logbook.LogClient) Image(javafx.scene.image.Image) GridPane(javafx.scene.layout.GridPane) ColumnConstraints(javafx.scene.layout.ColumnConstraints) LogEntryModel(org.phoebus.logbook.ui.write.LogEntryModel) Node(javafx.scene.Node) Label(javafx.scene.control.Label) AttachmentsViewController(org.phoebus.logbook.ui.write.AttachmentsViewController) Text(javafx.scene.text.Text) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) IOException(java.io.IOException) Logbook(org.phoebus.logbook.Logbook) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) TableCell(javafx.scene.control.TableCell) Keys(org.phoebus.logbook.ui.LogbookQueryUtil.Keys) ImageView(javafx.scene.image.ImageView) Tag(org.phoebus.logbook.Tag) LogEntry(org.phoebus.logbook.LogEntry) Separator(javafx.scene.control.Separator) FXML(javafx.fxml.FXML)

Example 9 with Tag

use of org.phoebus.logbook.Tag in project phoebus by ControlSystemStudio.

the class SingleLogEntryDisplayController method setLogEntry.

public void setLogEntry(LogEntry logEntry) {
    this.logEntry = logEntry;
    // Always expand properties pane.
    attachmentsPane.setExpanded(true);
    // Get the attachments from service
    fetchAttachments();
    // attachmentsPreviewController
    // .setAttachments(FXCollections.observableArrayList(logEntry.getAttachments()));
    List<String> hiddenPropertiesNames = Arrays.asList(LogbookUIPreferences.hidden_properties);
    // Remove the hidden properties
    List<Property> propertiesToShow = logEntry.getProperties().stream().filter(property -> !hiddenPropertiesNames.contains(property.getName())).collect(Collectors.toList());
    propertiesController.setProperties(propertiesToShow);
    logTime.setText(SECONDS_FORMAT.format(logEntry.getCreatedDate()));
    logOwner.setText(logEntry.getOwner());
    logTitle.setWrapText(true);
    logTitle.setText(logEntry.getTitle());
    // Content is defined by the source (default) or description field. If both are null
    // or empty, do no load any content to the WebView.
    WebEngine webEngine = logDescription.getEngine();
    webEngine.setUserStyleSheetLocation(getClass().getResource("/detail_log_webview.css").toExternalForm());
    if (logEntry.getSource() != null) {
        webEngine.loadContent(getFullHtml(logEntry.getSource()));
    } else if (logEntry.getDescription() != null) {
        webEngine.loadContent(getFullHtml(logEntry.getDescription()));
    }
    ObservableList<String> logbookList = FXCollections.observableArrayList();
    logbookList.addAll(logEntry.getLogbooks().stream().map(Logbook::getName).collect(Collectors.toList()));
    ObservableList<String> tagList = FXCollections.observableArrayList();
    tagList.addAll(logEntry.getTags().stream().map(Tag::getName).collect(Collectors.toList()));
    if (!logEntry.getLogbooks().isEmpty()) {
        logbooks.setWrapText(false);
        logbooks.setText(logEntry.getLogbooks().stream().map(Logbook::getName).collect(Collectors.joining(",")));
    }
    if (!logEntry.getTags().isEmpty()) {
        tags.setText(logEntry.getTags().stream().map(Tag::getName).collect(Collectors.joining(",")));
    } else {
        tags.setText(null);
    }
    logEntryId.setText(Long.toString(logEntry.getId()));
    level.setText(logEntry.getLevel());
}
Also used : Button(javafx.scene.control.Button) LogEntry(org.phoebus.logbook.LogEntry) OlogAttachment(org.phoebus.olog.es.api.model.OlogAttachment) WebEngine(javafx.scene.web.WebEngine) JobManager(org.phoebus.framework.jobs.JobManager) Arrays(java.util.Arrays) FXCollections(javafx.collections.FXCollections) VBox(javafx.scene.layout.VBox) StandardCopyOption(java.nio.file.StandardCopyOption) Level(java.util.logging.Level) Property(org.phoebus.logbook.Property) Attachment(org.phoebus.logbook.Attachment) Path(java.nio.file.Path) LogbookException(org.phoebus.logbook.LogbookException) SECONDS_FORMAT(org.phoebus.util.time.TimestampFormats.SECONDS_FORMAT) WebView(javafx.scene.web.WebView) Logbook(org.phoebus.logbook.Logbook) ImageCache(org.phoebus.ui.javafx.ImageCache) Label(javafx.scene.control.Label) TitledPane(javafx.scene.control.TitledPane) Files(java.nio.file.Files) Collection(java.util.Collection) Tag(org.phoebus.logbook.Tag) IOException(java.io.IOException) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) List(java.util.List) Clipboard(javafx.scene.input.Clipboard) ImageView(javafx.scene.image.ImageView) ObservableList(javafx.collections.ObservableList) ClipboardContent(javafx.scene.input.ClipboardContent) OlogLog(org.phoebus.olog.es.api.model.OlogLog) Image(javafx.scene.image.Image) LogClient(org.phoebus.logbook.LogClient) Logbook(org.phoebus.logbook.Logbook) Tag(org.phoebus.logbook.Tag) Property(org.phoebus.logbook.Property) WebEngine(javafx.scene.web.WebEngine)

Example 10 with Tag

use of org.phoebus.logbook.Tag in project phoebus by ControlSystemStudio.

the class LogEntryDisplayDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("LogEntry Display demo");
    VBox root = new VBox();
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(this.getClass().getResource("LogEntryDisplay.fxml"));
    loader.setRoot(root);
    loader.setController(new LogEntryController());
    loader.load();
    LogEntryController controller = loader.getController();
    root = loader.getRoot();
    primaryStage.setScene(new Scene(root, 400, 400));
    primaryStage.show();
    // Every few seconds add a new log entry
    ex.schedule(() -> {
        LogEntry log = LogEntryBuilder.log().description("Fast correctors for the vertical orbit have glitched to near saturation. Archiver shows there have been several episodes the past 24 hrs. Appears that FOFB in vertical plane might have momentary bad BPM reading.").createdDate(Instant.now()).build();
        runLater(() -> {
            controller.setLogEntry(log);
        });
    }, 2, TimeUnit.SECONDS);
    ex.schedule(() -> {
        Set<Tag> tags = new HashSet<Tag>();
        tags.add(TagImpl.of("tag1", "active"));
        tags.add(TagImpl.of("tag2", "active"));
        Set<Logbook> logbooks = new HashSet<Logbook>();
        logbooks.add(LogbookImpl.of("logbook1", "active"));
        logbooks.add(LogbookImpl.of("logbook2", "active"));
        runLater(() -> {
            controller.setLogEntry(LogEntryBuilder.log(controller.getLogEntry()).inLogbooks(logbooks).withTags(tags).build());
        });
    }, 2, TimeUnit.SECONDS);
    ex.schedule(() -> {
        Set<Tag> tags = new HashSet<Tag>();
        tags.add(TagImpl.of("tag1", "active"));
        tags.add(TagImpl.of("tag2", "active"));
        Set<Logbook> logbooks = new HashSet<Logbook>();
        logbooks.add(LogbookImpl.of("logbook1", "active"));
        logbooks.add(LogbookImpl.of("logbook2", "active"));
        String path = "C:\\Users\\Kunal Shroff\\Pictures\\screenshot-git\\log-att";
        File folder = new File(path);
        List<File> listOfFiles = Arrays.asList(folder.listFiles());
        runLater(() -> {
            LogEntryBuilder lb = LogEntryBuilder.log().createdDate(Instant.now()).description("Fast correctors for the vertical orbit have glitched to near saturation. Archiver shows there have been several episodes the past 24 hrs. Appears that FOFB in vertical plane might have momentary bad BPM reading.").withTags(new HashSet<Tag>(Arrays.asList(TagImpl.of("Orbit", "active"), TagImpl.of("Studies", "active")))).inLogbooks(new HashSet<Logbook>(Arrays.asList(LogbookImpl.of("Operations", "active"))));
            listOfFiles.forEach(file -> {
                try {
                    lb.attach(AttachmentImpl.of(file));
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            });
            controller.setLogEntry(lb.build());
        });
    }, 2, TimeUnit.SECONDS);
}
Also used : FileNotFoundException(java.io.FileNotFoundException) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) Logbook(org.phoebus.logbook.Logbook) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) Tag(org.phoebus.logbook.Tag) VBox(javafx.scene.layout.VBox) File(java.io.File) LogEntry(org.phoebus.logbook.LogEntry) HashSet(java.util.HashSet)

Aggregations

Logbook (org.phoebus.logbook.Logbook)13 Tag (org.phoebus.logbook.Tag)13 LogEntry (org.phoebus.logbook.LogEntry)12 FXMLLoader (javafx.fxml.FXMLLoader)10 LogClient (org.phoebus.logbook.LogClient)10 HashSet (java.util.HashSet)9 Scene (javafx.scene.Scene)9 File (java.io.File)8 FileNotFoundException (java.io.FileNotFoundException)8 ArrayList (java.util.ArrayList)8 LogEntryBuilder (org.phoebus.logbook.LogEntryImpl.LogEntryBuilder)8 LogbookException (org.phoebus.logbook.LogbookException)8 Parent (javafx.scene.Parent)6 ResourceBundle (java.util.ResourceBundle)4 ImageView (javafx.scene.image.ImageView)4 LogEntryEditorStage (org.phoebus.logbook.olog.ui.write.LogEntryEditorStage)4 Arrays (java.util.Arrays)3 List (java.util.List)3 Level (java.util.logging.Level)3 Collectors (java.util.stream.Collectors)3