Skip to content

Commit

Permalink
Searchbar across all bib files instead each having its own (JabRef#1549)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriba authored and zesaro committed Oct 27, 2016
1 parent 9a902fb commit b17be55
Show file tree
Hide file tree
Showing 58 changed files with 912 additions and 618 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit b17be55

Please sign in to comment.