Skip to content

Commit d2b0bbd

Browse files
moved uniqueIdSearch() from SearchAndFilterViewController.java to SearchResultTableViewController.java
1 parent ffde6af commit d2b0bbd

File tree

2 files changed

+47
-60
lines changed

2 files changed

+47
-60
lines changed

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/search/SearchAndFilterViewController.java

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,13 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
228228
uniqueIdTextField.textProperty().bindBidirectional(uniqueIdProperty);
229229
uniqueIdTextField.setOnKeyPressed(e -> {
230230
if (e.getCode() == KeyCode.ENTER) {
231-
// updateParametersAndSearch();
232-
LOGGER.log(Level.INFO, "Hello uniqueIdTextField");
233-
LOGGER.log(Level.INFO, "uniqueIdTextField: " + uniqueIdTextField.textProperty().getValue());
231+
LOGGER.log(Level.INFO, "ENTER has been pressed in uniqueIdTextField");
234232
LOGGER.log(Level.INFO, "uniqueIdProperty: " + uniqueIdProperty.getValueSafe());
235-
236-
uniqueIdSearch();
233+
if (uniqueIdProperty.isEmpty().get()) {
234+
LOGGER.log(Level.INFO, "uniqueIdString: is empty");
235+
} else {
236+
searchResultTableViewController.uniqueIdSearch(uniqueIdProperty.getValueSafe());
237+
}
237238
}
238239
});
239240
nodeNameTextField.textProperty().bindBidirectional(nodeNameProperty);
@@ -366,8 +367,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
366367
filterNameTextField.textProperty().bindBidirectional(filterNameProperty);
367368
filterNameTextField.disableProperty().bind(saveAndRestoreController.getUserIdentity().isNull());
368369
saveFilterButton.disableProperty().bind(Bindings.createBooleanBinding(() ->
369-
filterNameProperty.get() == null ||
370-
filterNameProperty.get().isEmpty() ||
370+
filterNameProperty.isEmpty().get() ||
371371
saveAndRestoreController.getUserIdentity().isNull().get() ||
372372
uniqueIdProperty.isNotEmpty().get(),
373373
filterNameProperty, saveAndRestoreController.getUserIdentity(), uniqueIdProperty));
@@ -479,59 +479,6 @@ public void showTagsSelectionPopover() {
479479
}
480480
}
481481

482-
/**
483-
* Search with a unique ID
484-
* Results will be 0 or 1 entries
485-
* Fill results table
486-
*/
487-
private void uniqueIdSearch() {
488-
LOGGER.log(Level.INFO, "Hello uniqueIdSearch");
489-
LOGGER.log(Level.INFO, "uniqueIdProperty: " + uniqueIdProperty);
490-
LOGGER.log(Level.INFO, "uniqueIdProperty.getValueSafe(): " + uniqueIdProperty.getValueSafe());
491-
492-
if (uniqueIdProperty.get() == null) {
493-
LOGGER.log(Level.INFO, "uniqueIdProperty: is null");
494-
} else {
495-
LOGGER.log(Level.INFO, "uniqueIdProperty: is not null");
496-
}
497-
if (uniqueIdProperty.isEmpty().get()) {
498-
LOGGER.log(Level.INFO, "uniqueIdProperty: is empty");
499-
} else {
500-
LOGGER.log(Level.INFO, "uniqueIdProperty: is not empty");
501-
}
502-
503-
try {
504-
/* Search with the uniqueID */
505-
Node uniqueIdNode = SaveAndRestoreService.getInstance().getNode(uniqueIdProperty.getValueSafe());
506-
LOGGER.log(Level.INFO, "uniqueIDNode: " + uniqueIdNode);
507-
508-
/* Check that there are results, fill table - should be at most one result */
509-
if (uniqueIdNode != null) {
510-
LOGGER.log(Level.INFO, "uniqueID: " + uniqueIdNode.getUniqueId());
511-
LOGGER.log(Level.INFO, "name: " + uniqueIdNode.getName());
512-
513-
Platform.runLater(() -> {
514-
tableEntries.setAll(List.of(uniqueIdNode));
515-
hitCountProperty.set(1);
516-
});
517-
/* Clear the results table if no record returned */
518-
} else {
519-
Platform.runLater(tableEntries::clear);
520-
hitCountProperty.set(0);
521-
}
522-
} catch (Exception e) {
523-
ExceptionDetailsErrorDialog.openError(
524-
resultTableView,
525-
Messages.errorGeneric,
526-
Messages.searchErrorBody,
527-
e
528-
);
529-
/* Clear the results table if there's an error*/
530-
tableEntries.clear();
531-
hitCountProperty.set(0);
532-
}
533-
}
534-
535482
private void updateParametersAndSearch() {
536483
if (searchDisabled) {
537484
return;

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/search/SearchResultTableViewController.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
import java.util.Map;
7070
import java.util.Optional;
7171
import java.util.ResourceBundle;
72+
import java.util.logging.Level;
73+
import java.util.logging.Logger;
7274
import java.util.regex.Pattern;
7375
import java.util.stream.Collectors;
7476

@@ -133,6 +135,7 @@ public class SearchResultTableViewController extends SaveAndRestoreBaseControlle
133135
private final SimpleIntegerProperty pageSizeProperty =
134136
new SimpleIntegerProperty(Preferences.search_result_page_size);
135137
private String queryString;
138+
private static final Logger LOGGER = Logger.getLogger(SearchResultTableViewController.class.getName());
136139

137140
private SaveAndRestoreService saveAndRestoreService;
138141

@@ -355,6 +358,43 @@ public void search(final String query) {
355358
});
356359
}
357360

361+
/**
362+
* Search with a unique ID
363+
* Results will be 0 or 1 entry
364+
* Fill results table
365+
*/
366+
void uniqueIdSearch(final String uniqueIdString) {
367+
LOGGER.log(Level.INFO, "uniqueIdSearch() called with: uniqueIdString = " + uniqueIdString);
368+
try {
369+
/* Search with the uniqueID */
370+
Node uniqueIdNode = SaveAndRestoreService.getInstance().getNode(uniqueIdString);
371+
LOGGER.log(Level.INFO, "uniqueIDNode: " + uniqueIdNode);
372+
373+
/* Check that there are results, then fill table - should be at most one result */
374+
if (uniqueIdNode != null) {
375+
LOGGER.log(Level.INFO, "uniqueIdNode.getName(): " + uniqueIdNode.getName());
376+
Platform.runLater(() -> {
377+
tableEntries.setAll(List.of(uniqueIdNode));
378+
hitCountProperty.set(1);
379+
});
380+
/* Clear the results table if no record returned */
381+
} else {
382+
Platform.runLater(tableEntries::clear);
383+
hitCountProperty.set(0);
384+
}
385+
} catch (Exception e) {
386+
ExceptionDetailsErrorDialog.openError(
387+
resultTableView,
388+
Messages.errorGeneric,
389+
Messages.searchErrorBody,
390+
e
391+
);
392+
/* Clear the results table if there's an error */
393+
tableEntries.clear();
394+
hitCountProperty.set(0);
395+
}
396+
}
397+
358398
/**
359399
* Retrieves a filter from the service and loads then performs a search for matching {@link Node}s. If
360400
* the filter does not exist, or if retrieval fails, an error dialog is shown.

0 commit comments

Comments
 (0)