-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search now per tab, plus global search only per popup from an existin…
…g search window. TODO: settings menu, some TODOs in the code in which other classes want to listen to search changes.
- Loading branch information
1 parent
30e8851
commit a2b0588
Showing
17 changed files
with
163 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/net/sf/jabref/gui/search/GlobalSearchWorker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package net.sf.jabref.gui.search; | ||
|
||
import net.sf.jabref.gui.BasePanel; | ||
import net.sf.jabref.gui.JabRefFrame; | ||
import net.sf.jabref.gui.worker.AbstractWorker; | ||
import net.sf.jabref.logic.l10n.Localization; | ||
import net.sf.jabref.model.entry.BibtexEntry; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
class GlobalSearchWorker extends AbstractWorker { | ||
|
||
private final JabRefFrame frame; | ||
private final SearchQuery searchQuery; | ||
private final SearchResultsDialog dialog; | ||
|
||
public GlobalSearchWorker(JabRefFrame frame, SearchQuery query) { | ||
this.frame = Objects.requireNonNull(frame); | ||
this.searchQuery = Objects.requireNonNull(query); | ||
|
||
dialog = new SearchResultsDialog(frame, | ||
Localization.lang("Search results in all databases for %0", | ||
this.searchQuery.toString())); | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see net.sf.jabref.Worker#run() | ||
*/ | ||
@Override | ||
public void run() { | ||
// Search all databases | ||
for (int i = 0; i < frame.getTabbedPane().getTabCount(); i++) { | ||
BasePanel basePanel = frame.baseAt(i); | ||
for (BibtexEntry entry : basePanel.getDatabase().getEntries()) { | ||
boolean hit = searchQuery.rule.applyRule(searchQuery.query, entry); | ||
if (hit) { | ||
dialog.addEntry(entry, basePanel); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see net.sf.jabref.AbstractWorker#update() | ||
*/ | ||
@Override | ||
public void update() { | ||
dialog.selectFirstEntry(); | ||
dialog.setVisible(true); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.