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

Searchbar across all bib files instead each having its own #1549

Merged
merged 24 commits into from Sep 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,13 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]

### Changed
- Implemented [#825](https://github.com/JabRef/jabref/issues/825): Search Bar across all bib files instead each having its own
- Implemented [#573](https://github.com/JabRef/jabref/issues/573): Add key shortcut for global search (`ctrl+shift+f`, if the searchfield is empty it will be focused instead)
- The search result Window will now show which entry belongs to which bib file
- The search result Window will now remember its location
- The search result Window won't stay on top anymore if the main Window is focused and will be present in the taskbar
- The user can jump from the searchbar to the maintable with `ctrl+enter`
- Implemented [#573 (comment)](https://github.com/JabRef/jabref/issues/573#issuecomment-232284156): Added shortcut: closing the search result window with `ctrl+w`
- Added integrity check for fields with BibTeX keys, e.g., `crossref` and `related`, to check that the key exists
- [#1496](https://github.com/JabRef/jabref/issues/1496) Keep track of which entry a downloaded file belongs to
- Made it possible to download multiple entries in one action
Expand All @@ -26,6 +33,13 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#

### Fixed
- Fixed selecting an entry out of multiple duplicates
- Fixed [#617](https://github.com/JabRef/jabref/issues/617): `Enter` in global search opens the selected entry & `Enter` in search dialog window opens the selected entry
- Entries in the SearchResultPanel will be shown correctly (Latex to Unicode)
- Suggestions in the autocomplete will be shown correctly (Latex to Unicode)
- Fixed: When searching the first match will be selected if the current selection is no match
- Selecting an entry in the search result Window will now select the correct entry in the bib file
- Entries in the SearchResultDialog are now converted to Unicode
- Suggestions in the autocomplete (search) are now in Unicode
- Fixed NullPointerException when opening search result window for an untitled database
- Fixed entry table traversal with Tab (no column traversal thus no double jump)
- Fixed [#1757](https://github.com/JabRef/jabref/issues/1757): Crash after saving illegal argument in entry editor
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/sf/jabref/cli/ArgumentProcessor.java
Expand Up @@ -47,6 +47,7 @@
import net.sf.jabref.model.database.BibDatabaseMode;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.preferences.JabRefPreferences;
import net.sf.jabref.preferences.SearchPreferences;
import net.sf.jabref.shared.prefs.SharedDatabasePreferences;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -166,9 +167,10 @@ private boolean exportMatches(List<ParserResult> loaded) {
BibDatabaseContext databaseContext = pr.getDatabaseContext();
BibDatabase dataBase = pr.getDatabase();

SearchPreferences searchPreferences = new SearchPreferences(Globals.prefs);
SearchQuery query = new SearchQuery(searchTerm,
Globals.prefs.getBoolean(JabRefPreferences.SEARCH_CASE_SENSITIVE),
Globals.prefs.getBoolean(JabRefPreferences.SEARCH_REG_EXP));
searchPreferences.isCaseSensitive(),
searchPreferences.isRegularExpression());
List<BibEntry> matches = new DatabaseSearcher(query, dataBase).getMatches();

//export matches
Expand Down
44 changes: 31 additions & 13 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Expand Up @@ -78,7 +78,6 @@
import net.sf.jabref.gui.mergeentries.FetchAndMergeEntry;
import net.sf.jabref.gui.mergeentries.MergeEntriesDialog;
import net.sf.jabref.gui.plaintextimport.TextInputDialog;
import net.sf.jabref.gui.search.SearchBar;
import net.sf.jabref.gui.undo.CountingUndoManager;
import net.sf.jabref.gui.undo.NamedCompound;
import net.sf.jabref.gui.undo.UndoableChangeType;
Expand Down Expand Up @@ -107,6 +106,7 @@
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.layout.Layout;
import net.sf.jabref.logic.layout.LayoutHelper;
import net.sf.jabref.logic.search.SearchQuery;
import net.sf.jabref.logic.util.FileExtensions;
import net.sf.jabref.logic.util.UpdateField;
import net.sf.jabref.logic.util.io.FileBasedLock;
Expand Down Expand Up @@ -205,9 +205,10 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe

private final SidePaneManager sidePaneManager;

private final SearchBar searchBar;
private ContentAutoCompleters autoCompleters;

private SearchQuery currentSearchQuery;


public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) {
Objects.requireNonNull(frame);
Expand All @@ -219,17 +220,16 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) {
this.frame = frame;
this.tableModel = new MainTableDataModel(getBibDatabaseContext());

searchBar = new SearchBar(this);

setupMainPanel();

setupActions();

Optional<File> file = bibDatabaseContext.getDatabaseFile();
this.getDatabase().registerListener(new SearchListener());

// ensure that at each addition of a new entry, the entry is added to the groups interface
this.bibDatabaseContext.getDatabase().registerListener(new GroupTreeListener());

Optional<File> file = bibDatabaseContext.getDatabaseFile();
if (file.isPresent()) {
// Register so we get notifications about outside changes to the file.
try {
Expand Down Expand Up @@ -519,7 +519,8 @@ public void update() {

actions.put(Actions.MERGE_ENTRIES, (BaseAction) () -> new MergeEntriesDialog(BasePanel.this));

actions.put(Actions.SEARCH, (BaseAction) searchBar::focus);
actions.put(Actions.SEARCH, (BaseAction) frame.getGlobalSearchBar()::focus);
actions.put(Actions.GLOBAL_SEARCH, (BaseAction) frame.getGlobalSearchBar()::performGlobalSearch);

// The action for copying the selected entry's key.
actions.put(Actions.COPY_KEY, (BaseAction) () -> copyKey());
Expand Down Expand Up @@ -1166,11 +1167,6 @@ public BibEntry newEntry(EntryType type) {
return null;
}

public SearchBar getSearchBar() {
return searchBar;
}


private class GroupTreeListener {

private final Runnable task = new Runnable() {
Expand Down Expand Up @@ -1273,6 +1269,21 @@ public void listen(EntryChangedEvent entryChangedEvent) {
}
}

/**
* Ensures that the results of the current search are updated when a new entry is inserted into the database
*/
private class SearchListener {
@Subscribe
public void listen(EntryAddedEvent addedEntryEvent) {
frame.getGlobalSearchBar().performSearch();
}

@Subscribe
public void listen(EntryChangedEvent entryChangedEvent) {
frame.getGlobalSearchBar().performSearch();
}
}


/**
* This method is called from JabRefFrame when the user wants to create a new entry.
Expand Down Expand Up @@ -1477,7 +1488,6 @@ public void setupMainPanel() {

setLayout(new BorderLayout());
removeAll();
add(searchBar, BorderLayout.NORTH);
add(splitPane, BorderLayout.CENTER);

// Set up name autocompleter for search:
Expand Down Expand Up @@ -1511,7 +1521,7 @@ public void setupMainPanel() {
}

public void updateSearchManager() {
searchBar.setAutoCompleter(searchAutoCompleter);
frame.getGlobalSearchBar().setAutoCompleter(searchAutoCompleter);
}

private void instantiateSearchAutoCompleter() {
Expand Down Expand Up @@ -2414,4 +2424,12 @@ public Map<String, EntryEditor> getEntryEditors() {
public BibDatabaseContext getDatabaseContext() {
return bibDatabaseContext;
}

public SearchQuery getCurrentSearchQuery() {
return currentSearchQuery;
}

public void setCurrentSearchQuery(SearchQuery currentSearchQuery) {
this.currentSearchQuery = currentSearchQuery;
}
}
2 changes: 2 additions & 0 deletions src/main/java/net/sf/jabref/gui/IconTheme.java
Expand Up @@ -157,6 +157,8 @@ public enum JabRefIcon {
FORUM("\uf28c"), /* css: forum */
FACEBOOK("\uf20c"), /* css: facebook */
BLOG("\uf46b"), /* css: rss */
GLOBAL_SEARCH_ON("\uF1E7"), /* css: earth */
GLOBAL_SEARCH_OFF("\uF1E8"), /* css: earth-off */
// STILL MISSING:
GROUP_REGULAR("\uF4E6", Color.RED);

Expand Down