Search in sources :

Example 6 with LogEntry

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

the class LogEntryCalenderDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(this.getClass().getResource("LogEntryCalenderView.fxml"));
    loader.setControllerFactory(clazz -> {
        try {
            if (clazz.isAssignableFrom(LogEntryCalenderViewController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            } else if (clazz.isAssignableFrom(AdvancedSearchViewController.class)) {
                return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
            }
        } catch (Exception e) {
            Logger.getLogger(LogEntryEditorStage.class.getName()).log(Level.SEVERE, "Failed to construct controller for log calendar view", e);
        }
        return null;
    });
    loader.load();
    LogEntryCalenderViewController 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().minusSeconds(i * 60 * 60)).inLogbooks(logbooks).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) LogEntryEditorStage(org.phoebus.logbook.olog.ui.write.LogEntryEditorStage) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) LogbookException(org.phoebus.logbook.LogbookException) FileNotFoundException(java.io.FileNotFoundException) Logbook(org.phoebus.logbook.Logbook) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) Tag(org.phoebus.logbook.Tag) File(java.io.File) LogEntry(org.phoebus.logbook.LogEntry) HashSet(java.util.HashSet)

Example 7 with LogEntry

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

the class LogEntryDisplayDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("LogEntry Display demo");
    BorderPane root;
    ResourceBundle resourceBundle = NLS.getMessages(Messages.class);
    FXMLLoader loader = new FXMLLoader();
    loader.setResources(resourceBundle);
    loader.setLocation(this.getClass().getResource("LogEntryDisplay.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(LogClient.class).newInstance(getLogClient());
            } 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();
    LogEntryDisplayController 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(() -> {
        OlogLog ologLog = new OlogLog(1L);
        ologLog.setDescription("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.");
        ologLog.setCreatedDate(Instant.now());
        runLater(() -> {
            controller.setLogEntry(ologLog);
        });
    }, 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"));
        LogEntry logEntry = controller.getLogEntry();
        runLater(() -> {
            OlogLog anotherLog = new OlogLog(2L);
            anotherLog.setDescription(controller.getLogEntry().getDescription());
            anotherLog.setCreatedDate(controller.getLogEntry().getCreatedDate());
            anotherLog.setTags(tags);
            anotherLog.setLogbooks(logbooks);
            controller.setLogEntry(anotherLog);
        });
    }, 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"));
        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);
        runLater(() -> {
            OlogLog ologLog = new OlogLog(3L);
            ologLog.setCreatedDate(Instant.now());
            ologLog.setTitle("A report on the orbit studies");
            ologLog.setDescription("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.");
            ologLog.setTags(new HashSet(Arrays.asList(TagImpl.of("Orbit", "active"), TagImpl.of("Studies", "active"))));
            ologLog.setLogbooks(new HashSet(Arrays.asList(LogbookImpl.of("Operations", "active"))));
            ologLog.setProperties(Arrays.asList(track, experimentProperty));
            List<Attachment> attachments = new ArrayList<>();
            OlogAttachment attachment1 = new OlogAttachment("image_1.png");
            attachment1.setFileName("image_1.png");
            attachment1.setContentType("image");
            OlogAttachment attachment2 = new OlogAttachment("file_phoebus.txt");
            attachment2.setFileName("file_phoebus.txt");
            attachment2.setContentType("text");
            attachments.add(attachment1);
            attachments.add(attachment2);
            ologLog.setAttachments(attachments);
            controller.setLogEntry(ologLog);
        });
    }, 2, TimeUnit.SECONDS);
}
Also used : BorderPane(javafx.scene.layout.BorderPane) LogClient(org.phoebus.logbook.LogClient) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) OlogAttachment(org.phoebus.olog.es.api.model.OlogAttachment) Attachment(org.phoebus.logbook.Attachment) OlogLog(org.phoebus.olog.es.api.model.OlogLog) FXMLLoader(javafx.fxml.FXMLLoader) Logbook(org.phoebus.logbook.Logbook) OlogAttachment(org.phoebus.olog.es.api.model.OlogAttachment) 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) ResourceBundle(java.util.ResourceBundle) Tag(org.phoebus.logbook.Tag)

Example 8 with LogEntry

use of org.phoebus.logbook.LogEntry 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 9 with LogEntry

use of org.phoebus.logbook.LogEntry 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 10 with LogEntry

use of org.phoebus.logbook.LogEntry 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)

Aggregations

LogEntry (org.phoebus.logbook.LogEntry)23 LogClient (org.phoebus.logbook.LogClient)12 Logbook (org.phoebus.logbook.Logbook)12 Tag (org.phoebus.logbook.Tag)12 FXMLLoader (javafx.fxml.FXMLLoader)11 LogEntryBuilder (org.phoebus.logbook.LogEntryImpl.LogEntryBuilder)10 File (java.io.File)9 FileNotFoundException (java.io.FileNotFoundException)9 ArrayList (java.util.ArrayList)9 HashSet (java.util.HashSet)9 Scene (javafx.scene.Scene)9 LogbookException (org.phoebus.logbook.LogbookException)9 FXML (javafx.fxml.FXML)7 Parent (javafx.scene.Parent)6 Property (org.phoebus.logbook.Property)6 IOException (java.io.IOException)5 List (java.util.List)5 HashMap (java.util.HashMap)4 Level (java.util.logging.Level)4 ObservableList (javafx.collections.ObservableList)4