Skip to content

Commit 60d0b7a

Browse files
committed
Moved createLogERntryFromSelectipn from Context Menu to New Log Entry Button
1 parent 210f3b8 commit 60d0b7a

3 files changed

Lines changed: 25 additions & 15 deletions

File tree

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@
3838
import org.phoebus.logbook.LogEntry;
3939
import org.phoebus.logbook.olog.ui.write.EditMode;
4040
import org.phoebus.logbook.olog.ui.write.LogEntryEditorStage;
41+
import org.phoebus.logbook.olog.ui.write.LogEntryUtils;
4142
import org.phoebus.olog.es.api.model.LogGroupProperty;
4243
import org.phoebus.olog.es.api.model.OlogLog;
4344
import org.phoebus.ui.javafx.ImageCache;
4445

46+
import java.util.List;
4547
import java.util.logging.Level;
4648
import java.util.logging.Logger;
4749

@@ -184,12 +186,6 @@ public void reply() {
184186
new LogEntryEditorStage(new OlogLog(), logEntryProperty.get(), EditMode.NEW_LOG_ENTRY).show();
185187
}
186188

187-
@FXML
188-
public void newLogEntry(){
189-
// Show a new editor dialog.
190-
new LogEntryEditorStage(new OlogLog(), null, EditMode.NEW_LOG_ENTRY).show();
191-
}
192-
193189
@FXML
194190
public void goBack() {
195191
if (logEntryTableViewController.goBackAndGoForwardActions.isPresent()) {
@@ -204,6 +200,22 @@ public void goForward() {
204200
}
205201
}
206202

203+
/**
204+
* Creates a new Log Entry.
205+
* If 2 or more existing Log Entries in the list are selected,
206+
* they get linked into the description of the new Log Entry.
207+
* */
208+
@FXML
209+
public void createNewLogEntry(){
210+
List<LogEntry> selectedLogEntries = logEntryTableViewController.getSelectedLogEntries();
211+
if (selectedLogEntries.size() > 1){
212+
LogEntry logEntry = LogEntryUtils.createLogEntryFromList(LogbookUIPreferences.web_client_root_URL, selectedLogEntries);
213+
new LogEntryEditorStage(logEntry,null, EditMode.NEW_LOG_ENTRY_FROM_SELECTION).show();
214+
} else {
215+
new LogEntryEditorStage(new OlogLog(), null, EditMode.NEW_LOG_ENTRY).show();
216+
}
217+
}
218+
207219
/**
208220
* Sets/renders the {@link LogEntry} in the view unless already rendered or unedited.
209221
* @param logEntry A non-null {@link LogEntry}

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,7 @@ public void initialize() {
215215
menuItemUpdateLogEntry.acceleratorProperty().setValue(new KeyCodeCombination(KeyCode.U, KeyCombination.CONTROL_DOWN));
216216
menuItemUpdateLogEntry.setOnAction(ae -> new LogEntryEditorStage(selectedLogEntries.get(0), null, EditMode.UPDATE_LOG_ENTRY).show());
217217

218-
//Milena
219-
MenuItem menuItemCreateLogEntryFromSelection = new MenuItem(Messages.CreateLogEntryFromSelection);
220-
menuItemCreateLogEntryFromSelection.setOnAction(pl -> {
221-
LogEntry logEntry = LogEntryUtils.createLogEntryFromList(LogbookUIPreferences.web_client_root_URL, selectedLogEntries);
222-
new LogEntryEditorStage(logEntry, null, EditMode.NEW_LOG_ENTRY_FROM_SELECTION).show();
223-
});
224-
225-
contextMenu.getItems().addAll(groupSelectedEntries, menuItemShowHideAll, menuItemNewLogEntry, menuItemCreateLogEntryFromSelection);
218+
contextMenu.getItems().addAll(groupSelectedEntries, menuItemShowHideAll, menuItemNewLogEntry);
226219
if (LogbookUIPreferences.log_entry_update_support) {
227220
contextMenu.getItems().add(menuItemUpdateLogEntry);
228221
}
@@ -599,6 +592,11 @@ public OlogQuery fromString(String s) {
599592

600593
}
601594

595+
596+
public List<LogEntry> getSelectedLogEntries(){
597+
return selectedLogEntries;
598+
}
599+
602600
/**
603601
* Wrapper class for a {@link LogEntry} and a flag indicating whether details of the
604602
* log entry meta-data should be rendered in the list view.

app/logbook/olog/ui/src/main/resources/org/phoebus/logbook/olog/ui/LogEntryDisplay.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<top>
2929
<ToolBar fx:id="toolBar">
3030
<items>
31-
<Button fx:id="newLogEntryButton" mnemonicParsing="false" onAction="#newLogEntry" text="%NewLogEntry"/>
31+
<Button fx:id="newLogEntryButton" mnemonicParsing="false" onAction="#createNewLogEntry" text="%NewLogEntry"/>
3232
<Button fx:id="replyButton" mnemonicParsing="false" onAction="#reply" text="%Reply" disable="true"/>
3333
<ToggleButton fx:id="showHideLogEntryGroupButton" contentDisplay="RIGHT" mnemonicParsing="false"
3434
text="%ShowHideLogEntryGroup" disable="true" onAction="#showHideLogEntryGroup"/>

0 commit comments

Comments
 (0)