Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE in search bar #3497

Merged
merged 2 commits into from
Dec 8, 2017
Merged
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
16 changes: 4 additions & 12 deletions src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jabref.gui.search;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
Expand Down Expand Up @@ -59,11 +58,6 @@

public class GlobalSearchBar extends JPanel {

private static final Color NEUTRAL_COLOR = Color.WHITE;
private static final Color NO_RESULTS_COLOR = new Color(232, 202, 202);
private static final Color RESULTS_FOUND_COLOR = new Color(217, 232, 202);
private static final Color ADVANCED_SEARCH_COLOR = new Color(102, 255, 255);

private static final PseudoClass CLASS_NO_RESULTS = PseudoClass.getPseudoClass("emptyResult");
private static final PseudoClass CLASS_RESULTS_FOUND = PseudoClass.getPseudoClass("emptyResult");

Expand Down Expand Up @@ -192,10 +186,10 @@ public void actionPerformed(ActionEvent e) {

container = OS.LINUX ? new CustomJFXPanel() : new JFXPanel();
DefaultTaskExecutor.runInJavaFXThread(() -> {
container.setScene(new Scene(searchField));
container.getScene().getStylesheets().add(GlobalSearchBar.class.getResource("../Main.css").toExternalForm());
Scene scene = new Scene(searchField);
scene.getStylesheets().add(GlobalSearchBar.class.getResource("../Main.css").toExternalForm());
container.setScene(scene);
container.addKeyListener(new SearchKeyAdapter());

});

setLayout(new FlowLayout(FlowLayout.RIGHT));
Expand Down Expand Up @@ -247,7 +241,7 @@ private void openLocalFindingsInExternalPanel() {

SearchResultFrame searchDialog = new SearchResultFrame(currentBasePanel.frame(),
Localization.lang("Search results in library %0 for %1", currentBasePanel.getBibDatabaseContext()
.getDatabaseFile().map(File::getName).orElse(GUIGlobals.UNTITLED_TITLE),
.getDatabaseFile().map(File::getName).orElse(GUIGlobals.UNTITLED_TITLE),
this.getSearchQuery().localize()),
getSearchQuery(), false);
List<BibEntry> entries = currentBasePanel.getDatabase().getEntries().stream()
Expand Down Expand Up @@ -369,7 +363,6 @@ public void setAutoCompleter(AutoCompleteSuggestionProvider<Author> searchComple
searchCompleter,
new PersonNameStringConverter(false, false, AutoCompleteFirstNameMode.BOTH),
new AppendPersonNamesStrategy());

}

public SearchQueryHighlightObservable getSearchQueryHighlightObservable() {
Expand Down Expand Up @@ -415,7 +408,6 @@ public void setSearchTerm(String searchTerm) {

setDontSelectSearchBar();
DefaultTaskExecutor.runInJavaFXThread(() -> searchField.setText(searchTerm));

}

public void setDontSelectSearchBar() {
Expand Down