Search in sources :

Example 1 with OlogQuery

use of org.phoebus.logbook.olog.ui.query.OlogQuery in project phoebus by ControlSystemStudio.

the class LogEntryCalenderViewController method configureComboBox.

private void configureComboBox() {
    Font defaultQueryFont = Font.font("Liberation Sans", FontWeight.BOLD, 12);
    Font defaultQueryFontRegular = Font.font("Liberation Sans", FontWeight.NORMAL, 12);
    query.setVisibleRowCount(OlogQueryManager.getInstance().getQueryListSize());
    // Needed to customize item rendering, e.g. default query rendered in bold.
    query.setCellFactory(new Callback<>() {

        @Override
        public ListCell<OlogQuery> call(ListView<OlogQuery> param) {
            final ListCell<OlogQuery> cell = new ListCell<>() {

                @Override
                public void updateItem(OlogQuery item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        setText(item.getQuery().isEmpty() ? "<empty>" : item.getQuery());
                        if (item.isDefaultQuery()) {
                            setFont(defaultQueryFont);
                        } else {
                            setFont(defaultQueryFontRegular);
                        }
                    } else {
                        setText(null);
                    }
                }
            };
            return cell;
        }
    });
    // This is needed for the "editor" part of the ComboBox
    query.setConverter(new StringConverter<>() {

        @Override
        public String toString(OlogQuery query) {
            if (query == null) {
                return "";
            } else {
                return query.getQuery();
            }
        }

        @Override
        public OlogQuery fromString(String s) {
            return new OlogQuery(s);
        }
    });
}
Also used : OlogQuery(org.phoebus.logbook.olog.ui.query.OlogQuery) ListCell(javafx.scene.control.ListCell) Font(javafx.scene.text.Font)

Example 2 with OlogQuery

use of org.phoebus.logbook.olog.ui.query.OlogQuery in project phoebus by ControlSystemStudio.

the class LogEntryCalenderViewController method initialize.

@FXML
public void initialize() {
    configureComboBox();
    // Set the search parameters in the advanced search controller so that it operates on the same object.
    ologQueries.setAll(ologQueryManager.getQueries());
    searchParameters.addListener((observable, oldValue, newValue) -> {
        query.getEditor().setText(newValue);
    });
    agenda = new Agenda();
    agenda.setEditAppointmentCallback(new Callback<Agenda.Appointment, Void>() {

        @Override
        public Void call(Appointment appointment) {
            return null;
        }
    });
    agenda.setActionCallback((appointment) -> {
        // show detailed view
        try {
            if (map != null) {
                final Stage dialog = new Stage();
                dialog.initModality(Modality.NONE);
                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(SingleLogEntryDisplayController.class)) {
                            return clazz.getConstructor(LogClient.class).newInstance(client);
                        } else if (clazz.isAssignableFrom(AttachmentsPreviewController.class)) {
                            return clazz.getConstructor().newInstance();
                        } else if (clazz.isAssignableFrom(LogEntryDisplayController.class)) {
                            return clazz.getConstructor(LogClient.class).newInstance(client);
                        } else if (clazz.isAssignableFrom(LogPropertiesController.class)) {
                            return clazz.getConstructor().newInstance();
                        }
                    } catch (Exception e) {
                        logger.log(Level.SEVERE, "Failed to construct controller for log entry display", e);
                    }
                    return null;
                });
                loader.load();
                LogEntryDisplayController controller = loader.getController();
                controller.setLogEntry(map.get(appointment));
                Scene dialogScene = new Scene(loader.getRoot(), 800, 600);
                dialog.setScene(dialogScene);
                dialog.show();
            }
        } catch (Exception e) {
            logger.log(Level.WARNING, "Failed to show details for : " + appointment.getSummary(), e);
        }
        return null;
    });
    agenda.allowDraggingProperty().set(false);
    agenda.allowResizeProperty().set(false);
    appointmentGroupMap = agenda.appointmentGroups().stream().collect(Collectors.toMap(AppointmentGroup::getDescription, Function.identity()));
    try {
        String styleSheetResource = LogbookUIPreferences.calendar_view_item_stylesheet;
        URL url = this.getClass().getResource(styleSheetResource);
        // url may be null...
        if (url != null) {
            agenda.getStylesheets().add(this.getClass().getResource(styleSheetResource).toString());
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, "Failed to set css style", e);
    }
    AnchorPane.setTopAnchor(agenda, 6.0);
    AnchorPane.setBottomAnchor(agenda, 6.0);
    AnchorPane.setLeftAnchor(agenda, 6.0);
    AnchorPane.setRightAnchor(agenda, 6.0);
    agendaPane.getChildren().add(agenda);
    query.itemsProperty().bind(new SimpleObjectProperty<>(ologQueries));
    query.setOnKeyPressed(e -> {
        if (e.getCode() == KeyCode.ENTER) {
            // Query set -> search is triggered!
            query.setValue(new OlogQuery(query.getEditor().getText()));
        }
    });
    query.getEditor().setText(ologQueries.get(0).getQuery());
    // Query set -> search is triggered!
    query.getSelectionModel().select(ologQueries.get(0));
    resize.setText(">");
    search.disableProperty().bind(searchInProgress);
    search();
}
Also used : Appointment(jfxtras.scene.control.agenda.Agenda.Appointment) AppointmentGroup(jfxtras.scene.control.agenda.Agenda.AppointmentGroup) LogClient(org.phoebus.logbook.LogClient) Agenda(jfxtras.scene.control.agenda.Agenda) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) URL(java.net.URL) OlogQuery(org.phoebus.logbook.olog.ui.query.OlogQuery) Stage(javafx.stage.Stage) ResourceBundle(java.util.ResourceBundle) FXML(javafx.fxml.FXML)

Example 3 with OlogQuery

use of org.phoebus.logbook.olog.ui.query.OlogQuery in project phoebus by ControlSystemStudio.

the class LogEntryTableViewController method configureComboBox.

private void configureComboBox() {
    Font defaultQueryFont = Font.font("Liberation Sans", FontWeight.BOLD, 12);
    Font defaultQueryFontRegular = Font.font("Liberation Sans", FontWeight.NORMAL, 12);
    query.setVisibleRowCount(OlogQueryManager.getInstance().getQueryListSize());
    // Needed to customize item rendering, e.g. default query rendered in bold.
    query.setCellFactory(new Callback<>() {

        @Override
        public ListCell<OlogQuery> call(ListView<OlogQuery> param) {
            final ListCell<OlogQuery> cell = new ListCell<>() {

                @Override
                public void updateItem(OlogQuery item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        setText(item.getQuery().isEmpty() ? "<empty>" : item.getQuery());
                        if (item.isDefaultQuery()) {
                            setFont(defaultQueryFont);
                        } else {
                            setFont(defaultQueryFontRegular);
                        }
                    } else {
                        setText(null);
                    }
                }
            };
            return cell;
        }
    });
    // This is needed for the "editor" part of the ComboBox
    query.setConverter(new StringConverter<>() {

        @Override
        public String toString(OlogQuery query) {
            if (query == null) {
                return "";
            } else {
                return query.getQuery();
            }
        }

        @Override
        public OlogQuery fromString(String s) {
            return new OlogQuery(s);
        }
    });
}
Also used : OlogQuery(org.phoebus.logbook.olog.ui.query.OlogQuery) ListCell(javafx.scene.control.ListCell) Font(javafx.scene.text.Font)

Aggregations

OlogQuery (org.phoebus.logbook.olog.ui.query.OlogQuery)3 ListCell (javafx.scene.control.ListCell)2 Font (javafx.scene.text.Font)2 URL (java.net.URL)1 ResourceBundle (java.util.ResourceBundle)1 FXML (javafx.fxml.FXML)1 FXMLLoader (javafx.fxml.FXMLLoader)1 Scene (javafx.scene.Scene)1 Stage (javafx.stage.Stage)1 Agenda (jfxtras.scene.control.agenda.Agenda)1 Appointment (jfxtras.scene.control.agenda.Agenda.Appointment)1 AppointmentGroup (jfxtras.scene.control.agenda.Agenda.AppointmentGroup)1 LogClient (org.phoebus.logbook.LogClient)1