Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
CloseRequestHeader,
CloseRequestButtonContinue,
CloseRequestButtonDiscard,
CreateLogEntryFromSelection,

Check warning on line 31 in app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make CreateLogEntryFromSelection a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7azf6xbMcWAlw33vmb&open=AZ7azf6xbMcWAlw33vmb&pullRequest=3841

Check warning on line 31 in app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static CreateLogEntryFromSelection" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7azf6xbMcWAlw33vmc&open=AZ7azf6xbMcWAlw33vmc&pullRequest=3841

Check warning on line 31 in app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "CreateLogEntryFromSelection" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7azf6xbMcWAlw33vmd&open=AZ7azf6xbMcWAlw33vmd&pullRequest=3841
DownloadSelected,
DownloadingAttachments,
EditLogEntry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(editMode.equals(EditMode.UPDATE_LOG_ENTRY) ? logEntry.getSource() :
(logEntry.getDescription() != null ? logEntry.getDescription() : ""));
descriptionProperty.set(logEntry.getSource());
descriptionProperty.addListener((observable, oldValue, newValue) -> isDirty = true);

Image tagIcon = ImageCache.getImage(LogEntryEditorController.class, "/icons/add_tag.png");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 {

Check warning on line 7 in app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryUtils.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a private constructor to hide the implicit public one.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7azf5wbMcWAlw33vma&open=AZ7azf5wbMcWAlw33vma&pullRequest=3841

public static LogEntry createLogEntryFromList(String baseURL, List<LogEntry> logEntries){
OlogLog log = new OlogLog();
StringBuilder stringBuilder = new StringBuilder();
logEntries.forEach(l -> {
stringBuilder.append("\n");
stringBuilder.append("- [").append(l.getTitle()).append("](").append(baseURL).append("/").append(l.getId()).append(")");
});

log.setSource(stringBuilder.toString());
return log;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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](someURL/1)\n- [Title02](someURL/2)\n- [Title03](someURL/3)", testListLog.getSource());
}
}

Loading