Search in sources :

Example 21 with LogEntry

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

the class LogEntryDisplayController method reply.

@FXML
public void reply() {
    LogEntry logEntry = logEntryProperty.get();
    OlogLog ologLog = new OlogLog();
    ologLog.setTitle(logEntry.getTitle());
    ologLog.setTags(logEntry.getTags());
    ologLog.setLogbooks(logEntry.getLogbooks());
    ologLog.setProperties(logEntry.getProperties());
    ologLog.setLevel(logEntry.getLevel());
    // Show a new editor dialog. When user selects to save the reply entry, update the original log entry
    // to ensure that it contains the log group property.
    new LogEntryEditorStage(DockPane.getActiveDockPane(), ologLog, logEntry, null).show();
}
Also used : LogEntryEditorStage(org.phoebus.logbook.olog.ui.write.LogEntryEditorStage) OlogLog(org.phoebus.olog.es.api.model.OlogLog) LogEntry(org.phoebus.logbook.LogEntry) FXML(javafx.fxml.FXML)

Example 22 with LogEntry

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

the class LogEntryTableViewController method initialize.

@FXML
public void initialize() {
    configureComboBox();
    ologQueries.setAll(ologQueryManager.getQueries());
    searchParameters.addListener((observable, oldValue, newValue) -> {
        query.getEditor().setText(newValue);
    });
    tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    MenuItem groupSelectedEntries = new MenuItem(Messages.GroupSelectedEntries);
    groupSelectedEntries.setOnAction(e -> {
        createLogEntryGroup();
    });
    groupSelectedEntries.disableProperty().bind(Bindings.createBooleanBinding(() -> selectedLogEntries.size() < 2, selectedLogEntries));
    ContextMenu contextMenu = new ContextMenu();
    MenuItem menuItemShowHideAll = new MenuItem(Messages.ShowHideDetails);
    menuItemShowHideAll.acceleratorProperty().setValue(new KeyCodeCombination(KeyCode.D, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
    menuItemShowHideAll.setOnAction(ae -> {
        showDetails.set(!showDetails.get());
        tableView.getItems().forEach(item -> item.setShowDetails(!item.isShowDetails().get()));
    });
    contextMenu.getItems().addAll(groupSelectedEntries, menuItemShowHideAll);
    tableView.setContextMenu(contextMenu);
    // The display table.
    tableView.getColumns().clear();
    tableView.setEditable(false);
    tableView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null && tableView.getSelectionModel().getSelectedItems().size() == 1) {
            selectedLogEntry = newValue.getLogEntry();
            logEntryDisplayController.setLogEntry(newValue.getLogEntry());
        }
        List<LogEntry> logEntries = tableView.getSelectionModel().getSelectedItems().stream().map(TableViewListItem::getLogEntry).collect(Collectors.toList());
        selectedLogEntries.setAll(logEntries);
    });
    tableView.getStylesheets().add(this.getClass().getResource("/search_result_view.css").toExternalForm());
    pagination.getStylesheets().add(this.getClass().getResource("/pagination.css").toExternalForm());
    descriptionCol = new TableColumn<>();
    descriptionCol.setMaxWidth(1f * Integer.MAX_VALUE * 100);
    descriptionCol.setCellValueFactory(col -> new SimpleObjectProperty(col.getValue()));
    descriptionCol.setCellFactory(col -> {
        return new TableCell<>() {

            private final Node graphic;

            private final PseudoClass childlessTopLevel = PseudoClass.getPseudoClass("grouped");

            private final LogEntryCellController controller;

            {
                try {
                    FXMLLoader loader = new FXMLLoader(getClass().getResource("LogEntryCell.fxml"));
                    graphic = loader.load();
                    controller = loader.getController();
                } catch (IOException exc) {
                    throw new RuntimeException(exc);
                }
            }

            @Override
            public void updateItem(TableViewListItem logEntry, boolean empty) {
                super.updateItem(logEntry, empty);
                if (empty) {
                    setGraphic(null);
                    pseudoClassStateChanged(childlessTopLevel, false);
                } else {
                    controller.setLogEntry(logEntry);
                    setGraphic(graphic);
                    boolean b = LogGroupProperty.getLogGroupProperty(logEntry.getLogEntry()).isPresent();
                    pseudoClassStateChanged(childlessTopLevel, b);
                }
            }
        };
    });
    tableView.getColumns().add(descriptionCol);
    tableView.setPlaceholder(new Label(Messages.NoSearchResults));
    progressIndicator.visibleProperty().bind(searchInProgress);
    searchDescendingImageView.setImage(ImageCache.getImage(LogEntryTableViewController.class, "/icons/arrow_down.png"));
    searchAscendingImageView.setImage(ImageCache.getImage(LogEntryTableViewController.class, "/icons/arrow_up.png"));
    searchResultView.disableProperty().bind(searchInProgress);
    pagination.currentPageIndexProperty().addListener((a, b, c) -> {
        search();
    });
    pageSizeTextField.setText(Integer.toString(pageSizeProperty.get()));
    Pattern DIGIT_PATTERN = Pattern.compile("\\d*");
    // This is to accept numerical input only, and at most 3 digits (maximizing search to 999 hits).
    pageSizeTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (DIGIT_PATTERN.matcher(newValue).matches()) {
            if ("".equals(newValue)) {
                pageSizeProperty.set(LogbookUIPreferences.search_result_page_size);
            } else if (newValue.length() > 3) {
                pageSizeTextField.setText(oldValue);
            } else {
                pageSizeProperty.set(Integer.parseInt(newValue));
            }
        } else {
            pageSizeTextField.setText(oldValue);
        }
    });
    // Hide the pagination widget if hit count == 0 or page count < 2
    pagination.visibleProperty().bind(Bindings.createBooleanBinding(() -> hitCountProperty.get() > 0 && pagination.pageCountProperty().get() > 1, hitCountProperty, pagination.pageCountProperty()));
    pagination.pageCountProperty().bind(pageCountProperty);
    pagination.maxPageIndicatorCountProperty().bind(pageCountProperty);
    query.itemsProperty().bind(new SimpleObjectProperty<>(ologQueries));
    query.setOnKeyPressed(e -> {
        if (e.getCode() == KeyCode.ENTER) {
            search();
        }
    });
    query.getEditor().setText(ologQueries.get(0).getQuery());
    query.getSelectionModel().select(ologQueries.get(0));
    searchParameters.setQuery(ologQueries.get(0).getQuery());
    searchAscendingButton.disableProperty().bind(searchInProgress);
    searchDescendingButton.disableProperty().bind(searchInProgress);
    search();
}
Also used : PseudoClass(javafx.css.PseudoClass) Pattern(java.util.regex.Pattern) Node(javafx.scene.Node) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) ContextMenu(javafx.scene.control.ContextMenu) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) TableCell(javafx.scene.control.TableCell) LogEntry(org.phoebus.logbook.LogEntry) FXML(javafx.fxml.FXML)

Example 23 with LogEntry

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

the class LogEntryCellDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("LogEntry Cell Demo");
    // VBox root = new VBox();
    GridPane root;
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(this.getClass().getResource("LogEntryCell.fxml"));
    // loader.setController(new LogEntryCellDemo());
    loader.load();
    LogEntryCellController 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().id(1L).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()).owner("nsls2-user").build();
        runLater(() -> {
            controller.setLogEntry(new TableViewListItem(log, true));
        });
    }, 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 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()).inLogbooks(logbooks).id(2L).withTags(tags).owner("nsls2-user").build();
        runLater(() -> {
            controller.setLogEntry(new TableViewListItem(log, true));
        });
    }, 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"));
        File imageFile = null;
        File textFile = null;
        try {
            imageFile = new File(this.getClass().getClassLoader().getResource("image_1.png").toURI());
            textFile = new File(this.getClass().getClassLoader().getResource("file_phoebus.txt").toURI());
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        List<File> listOfFiles = Arrays.asList(imageFile, textFile);
        runLater(() -> {
            LogEntryBuilder lb = LogEntryBuilder.log().createdDate(Instant.now()).title("A simple log Entry with some tags and logbooks").id(3L).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"), LogbookImpl.of("Electrical", "active")))).owner("nsls2-user");
            listOfFiles.forEach(file -> {
                try {
                    lb.attach(AttachmentImpl.of(file));
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            });
            controller.setLogEntry(new TableViewListItem(lb.build(), true));
        });
    }, 2, TimeUnit.SECONDS);
}
Also used : GridPane(javafx.scene.layout.GridPane) FileNotFoundException(java.io.FileNotFoundException) URISyntaxException(java.net.URISyntaxException) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) Logbook(org.phoebus.logbook.Logbook) TableViewListItem(org.phoebus.logbook.olog.ui.LogEntryTableViewController.TableViewListItem) LogEntryBuilder(org.phoebus.logbook.LogEntryImpl.LogEntryBuilder) Tag(org.phoebus.logbook.Tag) File(java.io.File) LogEntry(org.phoebus.logbook.LogEntry) HashSet(java.util.HashSet)

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