Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1656cec
CSSTUDIO-2167 Add HBox "decorations" to LogEntryCell.fxml.
abrahamwolk Aug 30, 2024
485344c
CSSTUDIO-2167 Add field "HBox decorations" to LogEntryCellController.
abrahamwolk Aug 30, 2024
aea98e1
CSSTUDIO-2167 Remove unused import.
abrahamwolk Aug 30, 2024
a8f2e21
CSSTUDIO-2167 Initial version of Enum-PV decoration in the Logbook ap…
abrahamwolk Oct 18, 2024
2e46b90
Fix typo.
abrahamwolk Oct 18, 2024
87765f8
CSSTUDIO-2167 Factor out the decorations-feature into its own FXML fi…
abrahamwolk Oct 23, 2024
15a111e
CSSTUDIO-2167 Add support for decorating with 3 PVs.
abrahamwolk Oct 24, 2024
b35f1fc
CSSTUDIO-2167 Add tooltip with enum-values to decorations.
abrahamwolk Oct 28, 2024
1985b78
CSSTUDIO-2167 Add PV Name to the tooltip.
abrahamwolk Oct 28, 2024
1c98d51
CSSTUDIO-2167 Add progress indicator when loading decorations.
abrahamwolk Oct 30, 2024
6f6cbdd
CSSTUDIO-2167 Rename "union" -> "vBox".
abrahamwolk Oct 30, 2024
39f8fd1
CSSTUDIO-2167 Add margins next to decorations, improvements, and fix …
abrahamwolk Oct 30, 2024
e6baddb
CSSTUDIO-2167 Fix: align the date to the right.
abrahamwolk Oct 31, 2024
5b617e8
CSSTUDIO-2167 If PV is not of enum type, don't display the PV.
abrahamwolk Oct 31, 2024
1202a7d
CSSTUDIO-2167 Factor out function createRectangleWithText().
abrahamwolk Nov 1, 2024
f54558f
CSSTUDIO-2167 Fix the logic to determine when a channel was not found.
abrahamwolk Nov 1, 2024
229e414
CSSTUDIO-2167 Handle the case where the archiver doesn't return the l…
abrahamwolk Nov 1, 2024
0f8d88e
CSSTUDIO-2167 When vEnumFromPreviousLogEntryToThisLogEntry.size() > 2…
abrahamwolk Nov 1, 2024
74bf9df
CSSTUDIO-2167 Replace ProgressIndicator with a Rectangle with text.
abrahamwolk Nov 1, 2024
046ac9a
CSSTUDIO-2167 Add the interface org.phoebus.logbook.olog.ui.spi.Decor…
abrahamwolk Nov 5, 2024
0d36f93
CSSTUDIO-2167 Move "Decorations.fxml" into separate module (outside o…
abrahamwolk Nov 5, 2024
a1bd311
CSSTUDIO-2167 Move implementation of the decorations out into a separ…
abrahamwolk Nov 6, 2024
8a169ab
CSSTUDIO-2167 Set refresh function for LogEntryTableView.
abrahamwolk Nov 6, 2024
fc5d996
CSSTUDIO-2167 Remove dependency on 'app-databrowser'.
abrahamwolk Nov 8, 2024
ab5629c
CSSTUDIO-2167 Add back spaces.
abrahamwolk Nov 8, 2024
c59e103
CSSTUDIO-2167 Remove unused imports and replace wildcard imports with…
abrahamwolk Nov 8, 2024
ae0b08f
CSSTUDIO-2167 Remove the ability to input PVs for decorations under "…
abrahamwolk Nov 20, 2024
2a2116f
CSSTUDIO-2167 Remove "@FXML".
abrahamwolk Nov 20, 2024
cbdc098
CSSTUDIO-2167 Improve code style: remove the modifiers 'public' from …
abrahamwolk Nov 20, 2024
a906512
CSSTUDIO-2167 Adjust padding.
abrahamwolk Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
Expand Down Expand Up @@ -113,10 +114,11 @@ public class AdvancedSearchViewController {
private final SimpleBooleanProperty requireAttachments = new SimpleBooleanProperty(false);

private Runnable searchCallback = () -> {
throw new IllegalStateException("Search callback is not set on AdvancedSearchViewConroller!");
throw new IllegalStateException("Search callback is not set on AdvancedSearchViewController!");
};

public AdvancedSearchViewController(LogClient logClient, SearchParameters searchParameters) {
public AdvancedSearchViewController(LogClient logClient,
SearchParameters searchParameters) {
this.logClient = logClient;
this.searchParameters = searchParameters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import org.commonmark.Extension;
Expand All @@ -16,9 +17,11 @@
import org.phoebus.logbook.Logbook;
import org.phoebus.logbook.Tag;
import org.phoebus.logbook.olog.ui.LogEntryTableViewController.TableViewListItem;
import org.phoebus.logbook.olog.ui.spi.Decoration;
import org.phoebus.ui.javafx.ImageCache;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -40,11 +43,16 @@ public class LogEntryCellController {
@FXML
VBox root;

@FXML
VBox logEntryCell;

@FXML
Label time;
@FXML
Label owner;
@FXML
HBox decorationNodes;
@FXML
Label title;
@FXML
Label logbooks;
Expand Down Expand Up @@ -74,7 +82,6 @@ public class LogEntryCellController {

private SimpleBooleanProperty expanded = new SimpleBooleanProperty(true);


public LogEntryCellController() {

List<Extension> extensions = Arrays.asList(TablesExtension.create(), ImageAttributesExtension.create());
Expand All @@ -92,8 +99,20 @@ public void initialize() {
conversationIcon.setImage(conversation);
}

@FXML
private List<Decoration> decorations = new LinkedList<>();

public void setDecorations(List<Decoration> decorations) {
this.decorations = decorations;
}

public void refresh() {

decorationNodes.getChildren().clear();
for (Decoration decoration : decorations) {
Node decorationNode = decoration.createDecorationForLogEntryCell(logEntry.getLogEntry());
decorationNodes.getChildren().add(decorationNode);
}

if (logEntry != null) {

time.setText(SECONDS_FORMAT.format(logEntry.getLogEntry().getCreatedDate()));
Expand Down Expand Up @@ -126,8 +145,8 @@ public void refresh() {

logEntryId.setText(logEntry.getLogEntry().getId() != null ? logEntry.getLogEntry().getId().toString() : "");
level.setText(logEntry.getLogEntry().getLevel());

}

}

public void setLogEntry(TableViewListItem logEntry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
import org.phoebus.logbook.LogClient;
import org.phoebus.logbook.LogEntry;
import org.phoebus.logbook.olog.ui.query.OlogQueryManager;
import org.phoebus.logbook.olog.ui.spi.Decoration;
import org.phoebus.logbook.olog.ui.write.AttachmentsEditorController;
import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog;
import org.phoebus.ui.docking.DockItem;
import org.phoebus.ui.docking.DockPane;

import java.io.IOException;
import java.net.URI;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -32,10 +36,18 @@ public class LogEntryTable implements AppInstance {
private LogEntryTableViewController controller;

public GoBackAndGoForwardActions goBackAndGoForwardActions;

public LogEntryTable(final LogEntryTableApp app) {
this.app = app;
goBackAndGoForwardActions = new GoBackAndGoForwardActions();

List<Decoration> decorations = new LinkedList<>();
{
ServiceLoader<Decoration> decorationClasses = ServiceLoader.load(Decoration.class);
for (Decoration decoration : decorationClasses) {
decorations.add(decoration);
}
}

try {
OlogQueryManager ologQueryManager = OlogQueryManager.getInstance();
SearchParameters searchParameters = new SearchParameters();
Expand All @@ -51,10 +63,10 @@ public LogEntryTable(final LogEntryTableApp app) {
if (clazz.isAssignableFrom(LogEntryTableViewController.class)) {
LogEntryTableViewController logEntryTableViewController = (LogEntryTableViewController) clazz.getConstructor(LogClient.class, OlogQueryManager.class, SearchParameters.class).newInstance(app.getClient(), ologQueryManager, searchParameters);
logEntryTableViewController.setGoBackAndGoForwardActions(goBackAndGoForwardActions);
logEntryTableViewController.setDecorations(decorations);
return logEntryTableViewController;
} else if (clazz.isAssignableFrom(AdvancedSearchViewController.class)) {
return clazz.getConstructor(LogClient.class, SearchParameters.class)
.newInstance(app.getClient(), searchParameters);
return clazz.getConstructor(LogClient.class, SearchParameters.class).newInstance(app.getClient(), searchParameters);
} else if (clazz.isAssignableFrom(SingleLogEntryDisplayController.class)) {
SingleLogEntryDisplayController singleLogEntryDisplayController = (SingleLogEntryDisplayController) clazz.getConstructor(LogClient.class).newInstance(app.getClient());
singleLogEntryDisplayController.setSelectLogEntryInUI(id -> goBackAndGoForwardActions.loadLogEntryWithID(id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,22 @@
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Pagination;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
Expand All @@ -26,9 +40,15 @@
import javafx.util.Duration;
import javafx.util.StringConverter;
import org.phoebus.framework.jobs.JobManager;
import org.phoebus.logbook.*;
import org.phoebus.logbook.LogClient;
import org.phoebus.logbook.LogEntry;
import org.phoebus.logbook.LogService;
import org.phoebus.logbook.LogbookException;
import org.phoebus.logbook.LogbookPreferences;
import org.phoebus.logbook.SearchResult;
import org.phoebus.logbook.olog.ui.query.OlogQuery;
import org.phoebus.logbook.olog.ui.query.OlogQueryManager;
import org.phoebus.logbook.olog.ui.spi.Decoration;
import org.phoebus.logbook.olog.ui.write.LogEntryEditorStage;
import org.phoebus.logbook.olog.ui.write.LogEntryUpdateStage;
import org.phoebus.olog.es.api.model.LogGroupProperty;
Expand Down Expand Up @@ -207,6 +227,10 @@ public void initialize() {
descriptionCol.setMaxWidth(1f * Integer.MAX_VALUE * 100);
descriptionCol.setCellValueFactory(col -> new SimpleObjectProperty<>(col.getValue()));
descriptionCol.setCellFactory(col -> new TableCell<>() {
{
setStyle("-fx-padding: -1px");
}

private final Node graphic;
private final PseudoClass childlessTopLevel =
PseudoClass.getPseudoClass("grouped");
Expand All @@ -217,6 +241,7 @@ public void initialize() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("LogEntryCell.fxml"));
graphic = loader.load();
controller = loader.getController();
controller.setDecorations(decorations);
} catch (IOException exc) {
throw new RuntimeException(exc);
}
Expand Down Expand Up @@ -374,8 +399,20 @@ public void setLogs(List<LogEntry> logs) {
throw new RuntimeException(new UnsupportedOperationException());
}

private List<Decoration> decorations;
protected void setDecorations(List<Decoration> decorations) {
this.decorations = decorations;
for (Decoration decoration : decorations) {
decoration.setRefreshLogEntryTableView(() -> refresh());
}
}

private void setSearchResult(SearchResult searchResult) {
this.searchResult = searchResult;

List<LogEntry> logEntries = searchResult.getLogs();
decorations.forEach(decoration -> decoration.setLogEntries(logEntries));

Platform.runLater(() -> {
hitCountProperty.set(searchResult.getHitCount());
pageCountProperty.set(1 + (hitCountProperty.get() / pageSizeProperty.get()));
Expand All @@ -392,12 +429,19 @@ public String getQuery() {
return query.getValue().getQuery();
}

private void refresh() {
private synchronized void refresh() {
if (this.searchResult != null) {
List<TableViewListItem> selectedLogEntries = new ArrayList<>(tableView.getSelectionModel().getSelectedItems());
ObservableList<TableViewListItem> logsList = FXCollections.observableArrayList();
logsList.addAll(searchResult.getLogs().stream().map(le -> new TableViewListItem(le, showDetails.get())).toList());

List<LogEntry> logEntries = searchResult.getLogs();
logEntries.sort((o1, o2) -> -(o1.getCreatedDate().compareTo(o2.getCreatedDate())));

boolean showDetailsBoolean = showDetails.get();
var logs = logEntries.stream().map(le -> new TableViewListItem(le, showDetailsBoolean)).toList();

ObservableList<TableViewListItem> logsList = FXCollections.observableArrayList(logs);
tableView.setItems(logsList);

// This will ensure that selected entries stay selected after the list has been
// updated from the search result.
for (TableViewListItem selectedItem : selectedLogEntries) {
Expand All @@ -408,8 +452,7 @@ private void refresh() {
goBackAndGoForwardActions.get().setIsRecordingHistoryDisabled(true); // Do not create a "Back" action for the automatic reload.
tableView.getSelectionModel().select(item);
goBackAndGoForwardActions.get().setIsRecordingHistoryDisabled(false);
}
else {
} else {
tableView.getSelectionModel().select(item);
}
});
Expand Down Expand Up @@ -562,14 +605,15 @@ protected void setLogEntry(LogEntry logEntry) {
* Selects a log entry as a result of an action outside the {@link TreeView}, but selection happens on the
* {@link TreeView} item, if it exists (match on log entry id). If it does not exist, selection is cleared
* anyway to indicate that user selected log entry is not visible in {@link TreeView}.
*
* @param logEntry User selected log entry.
* @return <code>true</code> if user selected log entry is present in {@link TreeView}, otherwise
* <code>false</code>.
*/
public boolean selectLogEntry(LogEntry logEntry){
public boolean selectLogEntry(LogEntry logEntry) {
tableView.getSelectionModel().clearSelection();
Optional<TableViewListItem> optional = tableView.getItems().stream().filter(i -> i.getLogEntry().getId().equals(logEntry.getId())).findFirst();
if(optional.isPresent()){
if (optional.isPresent()) {
tableView.getSelectionModel().select(optional.get());
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.phoebus.logbook.olog.ui.spi;

import javafx.scene.Node;
import org.phoebus.logbook.LogEntry;

import java.util.List;

public interface Decoration {
void setLogEntries(List<LogEntry> logEntries);

void setRefreshLogEntryTableView(Runnable refreshLogEntryTableView);

Node createDecorationForLogEntryCell(LogEntry logEntry);
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
</GridPane.margin>
</Label>
<TextField fx:id="attachmentTypes" GridPane.columnSpan="2" GridPane.rowIndex="18" />

</children>
</GridPane>
</children>
Expand Down
Loading
Loading