Skip to content

Commit 1640839

Browse files
authored
Merge branch 'ControlSystemStudio:master' into pv-tango
2 parents 3533057 + 8854527 commit 1640839

File tree

16 files changed

+244
-25
lines changed

16 files changed

+244
-25
lines changed

app/display/representation-javafx/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
<version>1.3</version>
2121
<scope>test</scope>
2222
</dependency>
23-
<dependency>
24-
<groupId>org.apache.commons</groupId>
25-
<artifactId>commons-lang3</artifactId>
26-
<version>3.5</version>
27-
</dependency>
2823
<dependency>
2924
<groupId>org.controlsfx</groupId>
3025
<artifactId>controlsfx</artifactId>

app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogHttpClient.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,14 @@ private SearchResult findLogs(MultivaluedMap<String, String> searchParams) throw
260260
.build();
261261
try {
262262
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
263-
OlogSearchResult searchResult = OlogObjectMappers.logEntryDeserializer.readValue(response.body(), OlogSearchResult.class);
264-
return SearchResult.of(new ArrayList<>(searchResult.getLogs()),
265-
searchResult.getHitCount());
263+
if(response.statusCode() == 200) {
264+
OlogSearchResult searchResult = OlogObjectMappers.logEntryDeserializer.readValue(response.body(), OlogSearchResult.class);
265+
return SearchResult.of(new ArrayList<>(searchResult.getLogs()),
266+
searchResult.getHitCount());
267+
}
268+
else{
269+
throw new RuntimeException(response.body());
270+
}
266271
} catch (Exception e) {
267272
LOGGER.log(Level.WARNING, "failed to retrieve log entries", e);
268273
throw new RuntimeException(e);

app/logbook/olog/ui/doc/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ Features
2121

2222
- Log entry viewers offer search capabilities based on meta data and content.
2323

24+
Missing features
25+
----------------
26+
In contrast to other markup implementations, HTML tags are **not** supported. Any such tags entered by user will
27+
be rendered as plain text.
28+
29+
2430
Launching the log entry editor
2531
------------------------------
2632
The log entry editor is launched as a non-modal window using one of the following methods:

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/HtmlAwareController.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,38 @@
2929

3030
public class HtmlAwareController {
3131

32-
private Parser parser;
33-
private HtmlRenderer htmlRenderer;
32+
private final Parser parser;
33+
private final HtmlRenderer htmlRenderer;
3434

35+
/**
36+
* Constructor to generate html code for HTML preview feature in LogEntryEditor or detailed log entry view.
37+
* @param serviceUrl Olog service url
38+
*/
3539
public HtmlAwareController(String serviceUrl){
36-
List<Extension> extensions =
37-
Arrays.asList(TablesExtension.create(), ImageAttributesExtension.create());
38-
this.parser = Parser.builder().extensions(extensions).build();
39-
htmlRenderer = HtmlRenderer.builder()
40-
.attributeProviderFactory(context -> new OlogAttributeProvider(serviceUrl))
41-
.extensions(extensions).build();
40+
this(new OlogAttributeProvider(serviceUrl));
4241
}
4342

4443
/**
45-
* To create HtmlAwareController object to generate html code for HTML preview feature in LogEntryEditor.
44+
* Constructor to generate html code for HTML preview feature in LogEntryEditor or detailed log entry view.
4645
* @param serviceUrl Olog service url.
4746
* @param preview Set true when preview button is clicked.
4847
* @param attachments The current attachments list from AttachmentsEditorController.
4948
*/
5049
public HtmlAwareController(String serviceUrl, boolean preview, List<Attachment> attachments){
50+
this(new OlogAttributeProvider(serviceUrl, preview, attachments));
51+
}
52+
53+
/**
54+
* Private constructor to avoid code duplication.
55+
* @param ologAttributeProvider The {@link OlogAttributeProvider} particular to the use case.
56+
*/
57+
private HtmlAwareController(OlogAttributeProvider ologAttributeProvider){
5158
List<Extension> extensions =
5259
Arrays.asList(TablesExtension.create(), ImageAttributesExtension.create());
5360
this.parser = Parser.builder().extensions(extensions).build();
5461
htmlRenderer = HtmlRenderer.builder()
55-
.attributeProviderFactory(context -> new OlogAttributeProvider(serviceUrl, preview, attachments))
62+
.escapeHtml(true)
63+
.attributeProviderFactory(context -> ologAttributeProvider)
5664
.extensions(extensions).build();
5765
}
5866

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryCalenderViewController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.phoebus.logbook.SearchResult;
3535
import org.phoebus.logbook.olog.ui.query.OlogQuery;
3636
import org.phoebus.logbook.olog.ui.query.OlogQueryManager;
37+
import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog;
3738

3839
import java.net.URL;
3940
import java.time.LocalDateTime;
@@ -262,7 +263,8 @@ public void search() {
262263
},
263264
(msg, ex) -> {
264265
searchInProgress.set(false);
265-
});
266+
ExceptionDetailsErrorDialog.openError(agenda, Messages.SearchFailed, "", ex);
267+
});
266268
}
267269

268270
public String getQuery() {

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import javafx.scene.control.Pagination;
2626
import javafx.scene.control.ProgressIndicator;
2727
import javafx.scene.control.SelectionMode;
28+
import javafx.scene.control.SplitPane;
2829
import javafx.scene.control.TableCell;
2930
import javafx.scene.control.TableColumn;
3031
import javafx.scene.control.TableView;
@@ -60,6 +61,7 @@
6061
import org.phoebus.security.store.SecureStore;
6162
import org.phoebus.security.tokens.ScopedAuthenticationToken;
6263
import org.phoebus.ui.dialog.DialogHelper;
64+
import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog;
6365

6466
import java.io.IOException;
6567
import java.util.ArrayList;
@@ -88,6 +90,10 @@ public class LogEntryTableViewController extends LogbookSearchController impleme
8890
@SuppressWarnings("unused")
8991
private GridPane viewSearchPane;
9092

93+
@SuppressWarnings("unused")
94+
@FXML
95+
private SplitPane splitPane;
96+
9197
// elements related to the table view of the log entries
9298
@FXML
9399
@SuppressWarnings("unused")
@@ -420,6 +426,7 @@ public void search() {
420426
},
421427
(msg, ex) -> {
422428
searchInProgress.set(false);
429+
ExceptionDetailsErrorDialog.openError(splitPane, Messages.SearchFailed, "", ex);
423430
});
424431
}
425432

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/Messages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class Messages
5555
PreviewOpenErrorTitle,
5656
ReplyToLogEntry,
5757
RequestTooLarge,
58+
SearchFailed,
5859
SelectFile,
5960
SelectFolder,
6061
ShowHideDetails,

app/logbook/olog/ui/src/main/resources/org/phoebus/logbook/olog/ui/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ ScalingFactor=Scaling Factor
9494
SearchButtonText=Search:
9595
Search=Search available:
9696
SearchAvailableItems=Search the list of available items.
97+
SearchFailed=Search Failed
9798
SearchToolTip=Edit and press Enter to search
9899
Selected=Selected
99100
SelectFolder=Select Folder
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (C) 2025 European Spallation Source ERIC.
3+
*/
4+
5+
package org.phoebus.logbook.olog.ui;
6+
7+
import org.junit.jupiter.api.Test;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
10+
public class HtmlAwareControllerTest {
11+
12+
@Test
13+
public void testEscapeHtml(){
14+
HtmlAwareController htmlAwareController = new HtmlAwareController("");
15+
String escapedHtml = htmlAwareController.toHtml("<br><p>Paragraph</p>");
16+
assertEquals("<p>&lt;br&gt;&lt;p&gt;Paragraph&lt;/p&gt;</p>\n", escapedHtml);
17+
}
18+
}

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotController.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ public void initializeViewForNewSnapshot(Node configurationNode) {
724724
SnapshotData snapshotData = new SnapshotData();
725725
snapshotData.setSnapshotItems(configurationToSnapshotItems(configPvs));
726726
this.snapshot = new Snapshot();
727+
this.snapshot.setSnapshotNode(Node.builder().nodeType(NodeType.SNAPSHOT).build());
727728
this.snapshot.setSnapshotData(snapshotData);
728729
updateUi();
729730
Platform.runLater(() -> actionResultReadbackColumn.visibleProperty().setValue(false));
@@ -757,13 +758,18 @@ public void takeSnapshot() {
757758
*/
758759
private void resetMetaData() {
759760
tabTitleProperty.setValue(Messages.unnamedSnapshot);
760-
snapshotNameProperty.setValue(null);
761-
snapshotCommentProperty.setValue(null);
762761
createdDateTextProperty.setValue(null);
763762
lastModifiedDateTextProperty.setValue(null);
764763
createdByTextProperty.setValue(null);
765764
}
766765

766+
public static Throwable getRootCause(Throwable throwable) {
767+
if (throwable.getCause() != null)
768+
return getRootCause(throwable.getCause());
769+
770+
return throwable;
771+
}
772+
767773
@SuppressWarnings("unused")
768774
public void saveSnapshot(ActionEvent actionEvent) {
769775
disabledUi.set(true);
@@ -795,7 +801,8 @@ public void saveSnapshot(ActionEvent actionEvent) {
795801
Platform.runLater(() -> {
796802
Alert alert = new Alert(Alert.AlertType.ERROR);
797803
alert.setTitle(Messages.errorActionFailed);
798-
alert.setContentText(e.getMessage());
804+
// get root cause of exception because the nested exception names are not very friendly
805+
alert.setContentText(getRootCause(e).getMessage());
799806
alert.setHeaderText(Messages.saveSnapshotErrorContent);
800807
DialogHelper.positionDialog(alert, borderPane, -150, -150);
801808
alert.showAndWait();
@@ -1101,7 +1108,14 @@ private void takeSnapshotReadPVs(Consumer<Optional<Snapshot>> consumer) {
11011108
});
11021109
showTakeSnapshotResult(snapshotItems);
11031110
Snapshot snapshot = new Snapshot();
1104-
snapshot.setSnapshotNode(Node.builder().nodeType(NodeType.SNAPSHOT).build());
1111+
snapshot.setSnapshotNode(
1112+
Node.builder()
1113+
.nodeType(NodeType.SNAPSHOT)
1114+
// set name and description to preserve the name / comment fields
1115+
.name(snapshotNameProperty.getValue())
1116+
.description(snapshotCommentProperty.getValue())
1117+
.build()
1118+
);
11051119
SnapshotData snapshotData = new SnapshotData();
11061120
snapshotData.setSnapshotItems(snapshotItems);
11071121
snapshot.setSnapshotData(snapshotData);

0 commit comments

Comments
 (0)