From 982876f2b5da563a91fc0335908c2e9c41c93ffa Mon Sep 17 00:00:00 2001 From: Milena Schedle Date: Wed, 17 Jun 2026 15:29:27 +0200 Subject: [PATCH 1/3] Work in Progress --- .../olog/ui/LogEntryTableViewController.java | 10 +++++- .../org/phoebus/logbook/olog/ui/Messages.java | 1 + .../logbook/olog/ui/write/LogEntryUtils.java | 28 ++++++++++++++++ .../logbook/olog/ui/messages.properties | 2 ++ .../olog/ui/write/LogEntryUtilsTest.java | 33 +++++++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java create mode 100644 app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/write/LogEntryUtilsTest.java diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java index 3e5bb795be..cc41df5d51 100644 --- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java @@ -56,6 +56,7 @@ import org.phoebus.logbook.olog.ui.spi.Decoration; import org.phoebus.logbook.olog.ui.write.EditMode; import org.phoebus.logbook.olog.ui.write.LogEntryEditorStage; +import org.phoebus.logbook.olog.ui.write.LogEntryUtils; import org.phoebus.olog.es.api.model.LogGroupProperty; import org.phoebus.olog.es.api.model.OlogLog; import org.phoebus.security.store.SecureStore; @@ -214,7 +215,14 @@ public void initialize() { menuItemUpdateLogEntry.acceleratorProperty().setValue(new KeyCodeCombination(KeyCode.U, KeyCombination.CONTROL_DOWN)); menuItemUpdateLogEntry.setOnAction(ae -> new LogEntryEditorStage(selectedLogEntries.get(0), null, EditMode.UPDATE_LOG_ENTRY).show()); - contextMenu.getItems().addAll(groupSelectedEntries, menuItemShowHideAll, menuItemNewLogEntry); + //Milena + MenuItem menuItemCreateLogEntryFromSelection = new MenuItem(Messages.CreateLogEntryFromSelection); + menuItemCreateLogEntryFromSelection.setOnAction(pl -> { + LogEntry logEntry = LogEntryUtils.createLogEntryFromList(LogbookUIPreferences.web_client_root_URL, selectedLogEntries); + new LogEntryEditorStage(logEntry, null, EditMode.NEW_LOG_ENTRY).show(); + }); + + contextMenu.getItems().addAll(groupSelectedEntries, menuItemShowHideAll, menuItemNewLogEntry, menuItemCreateLogEntryFromSelection); if (LogbookUIPreferences.log_entry_update_support) { contextMenu.getItems().add(menuItemUpdateLogEntry); } diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/Messages.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/Messages.java index b6a741f161..ba732b94c2 100644 --- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/Messages.java +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/Messages.java @@ -28,6 +28,7 @@ public class Messages CloseRequestHeader, CloseRequestButtonContinue, CloseRequestButtonDiscard, + CreateLogEntryFromSelection, DownloadSelected, DownloadingAttachments, EditLogEntry, diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java new file mode 100644 index 0000000000..5f64f25876 --- /dev/null +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java @@ -0,0 +1,28 @@ +package org.phoebus.logbook.olog.ui.write; + +import org.phoebus.logbook.LogEntry; +import org.phoebus.olog.es.api.model.OlogLog; + +import java.util.List; + +public class LogEntryUtils { + + public static LogEntry createLogEntryFromList(String baseURL, List logEntries){ + // number of log entries + // they links should be based on the + // instantiate new Log Entry implementatin Olog + // interface: type of class that defines a behavior/functionality/data + // you cannot instantiate an interface + // so we instantiate an OlogLog + // public class OlogLog implements LogEntry + OlogLog log = new OlogLog(); + StringBuilder stringBuilder = new StringBuilder(); + logEntries.forEach(l -> { + stringBuilder.append("\n"); + stringBuilder.append("[").append(l.getTitle()).append("](").append(baseURL).append(l.getId()).append(")\n\n"); + }); + + log.setSource(stringBuilder.toString()); + return log; + } +} diff --git a/app/logbook/olog/ui/src/main/resources/org/phoebus/logbook/olog/ui/messages.properties b/app/logbook/olog/ui/src/main/resources/org/phoebus/logbook/olog/ui/messages.properties index bed80ccac5..273c426ba5 100644 --- a/app/logbook/olog/ui/src/main/resources/org/phoebus/logbook/olog/ui/messages.properties +++ b/app/logbook/olog/ui/src/main/resources/org/phoebus/logbook/olog/ui/messages.properties @@ -30,6 +30,8 @@ CloseRequestHeader=Log entry not saved. Do you wish to close? CloseRequestButtonContinue=Continue Editing CloseRequestButtonDiscard=Close CreateLogbookEntry=Create Log Book Entry +#milena +CreateLogEntryFromSelection=Create Log Entry From Selection CopyMarkdown=Copy Markdown CopyURL=Copy URL CSSWindow=CSS Window diff --git a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/write/LogEntryUtilsTest.java b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/write/LogEntryUtilsTest.java new file mode 100644 index 0000000000..854c3f3422 --- /dev/null +++ b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/write/LogEntryUtilsTest.java @@ -0,0 +1,33 @@ +package org.phoebus.logbook.olog.ui.write; + +import org.junit.jupiter.api.Test; +import org.phoebus.logbook.*; +import org.phoebus.olog.es.api.model.OlogLog; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +public class LogEntryUtilsTest { + + @Test + public void testCreateLogEntryFromList(){ + + OlogLog ologEntry01 = new OlogLog(); + ologEntry01.setTitle("Title01"); + ologEntry01.setId(1L); + + OlogLog ologEntry02 = new OlogLog(); + ologEntry02.setTitle("Title02"); + ologEntry02.setId(2L); + + + OlogLog ologEntry03 = new OlogLog(); + ologEntry03.setTitle("Title03"); + ologEntry03.setId(3L); + + LogEntry testListLog = LogEntryUtils.createLogEntryFromList("someURL", List.of(ologEntry01, ologEntry02, ologEntry03)); + + assertEquals("\n[Title01](someURL1)\n\n\n[Title02](someURL2)\n\n\n[Title03](someURL3)\n\n", testListLog.getSource()); + } +} + From b3e7090492ed6d7a35c0487bc6669fa34bf96271 Mon Sep 17 00:00:00 2001 From: milenaschedle Date: Thu, 18 Jun 2026 12:45:10 +0100 Subject: [PATCH 2/3] Create new Log Entry from Selection of log entries --- .../olog/ui/write/LogEntryEditorController.java | 4 ++-- .../phoebus/logbook/olog/ui/write/LogEntryUtils.java | 10 +--------- .../logbook/olog/ui/write/LogEntryUtilsTest.java | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java index f5b0008876..0c82ad87c9 100644 --- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java @@ -389,8 +389,8 @@ public void initialize() { textArea.textProperty().bindBidirectional(descriptionProperty); // When editing an existing entry, set the description to the source of the entry. - descriptionProperty.set(editMode.equals(EditMode.UPDATE_LOG_ENTRY) ? logEntry.getSource() : - (logEntry.getDescription() != null ? logEntry.getDescription() : "")); + descriptionProperty.set(logEntry.getSource()); +// (logEntry.getDescription() != null ? logEntry.getDescription() : "")); descriptionProperty.addListener((observable, oldValue, newValue) -> isDirty = true); Image tagIcon = ImageCache.getImage(LogEntryEditorController.class, "/icons/add_tag.png"); diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java index 5f64f25876..291061af66 100644 --- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java @@ -2,24 +2,16 @@ import org.phoebus.logbook.LogEntry; import org.phoebus.olog.es.api.model.OlogLog; - import java.util.List; public class LogEntryUtils { public static LogEntry createLogEntryFromList(String baseURL, List logEntries){ - // number of log entries - // they links should be based on the - // instantiate new Log Entry implementatin Olog - // interface: type of class that defines a behavior/functionality/data - // you cannot instantiate an interface - // so we instantiate an OlogLog - // public class OlogLog implements LogEntry OlogLog log = new OlogLog(); StringBuilder stringBuilder = new StringBuilder(); logEntries.forEach(l -> { stringBuilder.append("\n"); - stringBuilder.append("[").append(l.getTitle()).append("](").append(baseURL).append(l.getId()).append(")\n\n"); + stringBuilder.append("- [").append(l.getTitle()).append("](").append(baseURL).append("/").append(l.getId()).append(")"); }); log.setSource(stringBuilder.toString()); diff --git a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/write/LogEntryUtilsTest.java b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/write/LogEntryUtilsTest.java index 854c3f3422..84e5387e23 100644 --- a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/write/LogEntryUtilsTest.java +++ b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/write/LogEntryUtilsTest.java @@ -27,7 +27,7 @@ public void testCreateLogEntryFromList(){ LogEntry testListLog = LogEntryUtils.createLogEntryFromList("someURL", List.of(ologEntry01, ologEntry02, ologEntry03)); - assertEquals("\n[Title01](someURL1)\n\n\n[Title02](someURL2)\n\n\n[Title03](someURL3)\n\n", testListLog.getSource()); + assertEquals("\n- [Title01](someURL/1)\n- [Title02](someURL/2)\n- [Title03](someURL/3)", testListLog.getSource()); } } From a2bed9f2292eb01ef497c3011e68a45995c37f42 Mon Sep 17 00:00:00 2001 From: milenaschedle Date: Thu, 18 Jun 2026 13:17:54 +0100 Subject: [PATCH 3/3] Removed comments --- .../phoebus/logbook/olog/ui/write/LogEntryEditorController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java index 0c82ad87c9..0c51be9e29 100644 --- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java @@ -388,9 +388,7 @@ public void initialize() { titleProperty.set(logEntry.getTitle()); textArea.textProperty().bindBidirectional(descriptionProperty); - // When editing an existing entry, set the description to the source of the entry. descriptionProperty.set(logEntry.getSource()); -// (logEntry.getDescription() != null ? logEntry.getDescription() : "")); descriptionProperty.addListener((observable, oldValue, newValue) -> isDirty = true); Image tagIcon = ImageCache.getImage(LogEntryEditorController.class, "/icons/add_tag.png");