Skip to content

Commit

Permalink
Merge pull request #332 from JabRef/uisearchhistory
Browse files Browse the repository at this point in the history
Better search
  • Loading branch information
matthiasgeiger committed Nov 27, 2015
2 parents a9790d8 + f453017 commit 446a593
Show file tree
Hide file tree
Showing 62 changed files with 1,829 additions and 1,666 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Feature: Merge information from both entries on duplication detection
- Always use import inspection dialog on import from file
- All duplicate whitespaces / tabs / newlines are now removed from non-multiline fields
- Improvements to search:
- Search bar is now at the top
- A summary of the search result is shown in textual form in the search bar
- The search text field changes its color based on the search result (red if nothing is found, green if at least one entry is found)
- Autocompletion suggestions are shown in a popup
- Search options are available via a drop-down list, this implements Feature Request #853
- "Clear search" button also clears search field, this implements Feature Request #601
- Every search is done automatically (live) as soon as the search text is changed
- Search is local by default. To do a global search, one has to do a local search and then this search can be done globally as well, opening a new window.
- The local search results can be shown in a new window.
- Feature: Merge information from a DOI generated BibTex entry to an entry
- Added more characters to HTML/Unicode converter
- Feature: Push citations to Texmaker ([bug 318](https://sourceforge.net/p/jabref/bugs/318/), [bug 582](https://sourceforge.net/p/jabref/bugs/582/))
Expand Down Expand Up @@ -101,6 +111,10 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Remove support for key bindings per external application by allowing only the key binding "push to application" for the currently selected external application.
- Remove "edit preamble" from toolbar
- Remove support to the move-to-SysTray action
- Remove incremental search
- Remove option to disable autocompleters for search and make this always one
- Remove option to highlight matches and make this always one when not using regex or grammar-based search

- Remove option Tools -> Open PDF or PS which is replaced by Tools -> Open File

## 2.80 - never released
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/JabRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void start(String[] args) {
return;
}

openWindow(loaded);
SwingUtilities.invokeLater(() -> openWindow(loaded));
}

private void setupLogHandlerForErrorConsole() {
Expand Down
44 changes: 14 additions & 30 deletions src/main/java/net/sf/jabref/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,8 @@ public class JabRefPreferences {
public static final String SIDE_PANE_COMPONENT_NAMES = "sidePaneComponentNames";
public static final String XMP_PRIVACY_FILTERS = "xmpPrivacyFilters";
public static final String USE_XMP_PRIVACY_FILTER = "useXmpPrivacyFilter";
public static final String SEARCH_AUTO_COMPLETE = "searchAutoComplete";
public static final String INCREMENT_S = "incrementS";
public static final String SEARCH_ALL = "searchAll";
public static final String SEARCH_GEN = "searchGen";
public static final String SEARCH_OPT = "searchOpt";
public static final String SEARCH_REQ = "searchReq";
public static final String CASE_SENSITIVE_SEARCH = "caseSensitiveSearch";
public static final String SEARCH_MODE_FILTER = "searchModeFilter";
public static final String SEARCH_CASE_SENSITIVE = "caseSensitiveSearch";
public static final String DEFAULT_AUTO_SORT = "defaultAutoSort";
public static final String DEFAULT_SHOW_SOURCE = "defaultShowSource";
public static final String STRINGS_SIZE_Y = "stringsSizeY";
Expand Down Expand Up @@ -169,9 +164,9 @@ public class JabRefPreferences {
public static final String AUTO_COMP_FIRST_LAST = "autoCompFF";
public static final String AUTO_COMPLETE_FIELDS = "autoCompleteFields";
public static final String AUTO_COMPLETE = "autoComplete";
public static final String HIGH_LIGHT_WORDS = "highLightWords";
public static final String REG_EXP_SEARCH = "regExpSearch";
public static final String SELECT_S = "selectS";
public static final String SEARCH_PANE_POS_Y = "searchPanePosY";
public static final String SEARCH_PANE_POS_X = "searchPanePosX";
public static final String SEARCH_REG_EXP = "regExpSearch";
public static final String EDITOR_EMACS_KEYBINDINGS = "editorEMACSkeyBindings";
public static final String EDITOR_EMACS_KEYBINDINGS_REBIND_CA = "editorEMACSkeyBindingsRebindCA";
public static final String EDITOR_EMACS_KEYBINDINGS_REBIND_CF = "editorEMACSkeyBindingsRebindCF";
Expand Down Expand Up @@ -233,7 +228,6 @@ public class JabRefPreferences {
public static final String DEFAULT_OWNER = "defaultOwner";
public static final String GROUPS_VISIBLE_ROWS = "groupsVisibleRows";
public static final String DEFAULT_ENCODING = "defaultEncoding";
public static final String SEARCH_PANEL_VISIBLE = "searchPanelVisible";
public static final String TOOLBAR_VISIBLE = "toolbarVisible";
public static final String HIGHLIGHT_GROUPS_MATCHING_ALL = "highlightGroupsMatchingAll";
public static final String HIGHLIGHT_GROUPS_MATCHING_ANY = "highlightGroupsMatchingAny";
Expand Down Expand Up @@ -262,9 +256,7 @@ public class JabRefPreferences {
// When this should be made possible, the code to inspect is net.sf.jabref.gui.preftabs.LabelPatternPrefTab.storeSettings() -> LabelPattern keypatterns = getLabelPattern(); etc
public static final String DEFAULT_LABEL_PATTERN = "defaultLabelPattern";

public static final String SEARCH_ALL_BASES = "searchAllBases";
public static final String SHOW_SEARCH_IN_DIALOG = "showSearchInDialog";
public static final String FLOAT_SEARCH = "floatSearch";
public static final String SEARCH_MODE_FLOAT = "floatSearch";
public static final String GRAY_OUT_NON_HITS = "grayOutNonHits";
public static final String CONFIRM_DELETE = "confirmDelete";
public static final String WARN_BEFORE_OVERWRITING_KEY = "warnBeforeOverwritingKey";
Expand Down Expand Up @@ -553,25 +545,20 @@ private JabRefPreferences() {
defaults.put(MERGEENTRIES_SIZE_Y, 600);
defaults.put(DEFAULT_SHOW_SOURCE, Boolean.FALSE);
defaults.put(DEFAULT_AUTO_SORT, Boolean.FALSE);
defaults.put(CASE_SENSITIVE_SEARCH, Boolean.FALSE);
defaults.put(SEARCH_REQ, Boolean.TRUE);
defaults.put(SEARCH_OPT, Boolean.TRUE);
defaults.put(SEARCH_GEN, Boolean.TRUE);
defaults.put(SEARCH_ALL, Boolean.FALSE);
defaults.put(INCREMENT_S, Boolean.FALSE);
defaults.put(SEARCH_AUTO_COMPLETE, Boolean.TRUE);

defaults.put(SELECT_S, Boolean.FALSE);
defaults.put(REG_EXP_SEARCH, Boolean.TRUE);
defaults.put(HIGH_LIGHT_WORDS, Boolean.TRUE);
defaults.put(SEARCH_CASE_SENSITIVE, Boolean.FALSE);
defaults.put(SEARCH_MODE_FILTER, Boolean.TRUE);

defaults.put(SEARCH_REG_EXP, Boolean.FALSE);
defaults.put(SEARCH_PANE_POS_X, 0);
defaults.put(SEARCH_PANE_POS_Y, 0);
defaults.put(EDITOR_EMACS_KEYBINDINGS, Boolean.FALSE);
defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CA, Boolean.TRUE);
defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CF, Boolean.TRUE);
defaults.put(AUTO_COMPLETE, Boolean.TRUE);
defaults.put(AUTO_COMPLETE_FIELDS, "author;editor;title;journal;publisher;keywords;crossref");
defaults.put(AUTO_COMP_FIRST_LAST, Boolean.FALSE); // "Autocomplete names in 'Firstname Lastname' format only"
defaults.put(AUTO_COMP_LAST_FIRST, Boolean.FALSE); // "Autocomplete names in 'Lastname, Firstname' format only"
defaults.put(SHORTEST_TO_COMPLETE, 2);
defaults.put(SHORTEST_TO_COMPLETE, 1);
defaults.put(AUTOCOMPLETE_FIRSTNAME_MODE, JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE_BOTH);
defaults.put(GROUP_FLOAT_SELECTIONS, Boolean.TRUE);
defaults.put(GROUP_INTERSECT_SELECTIONS, Boolean.TRUE);
Expand All @@ -591,7 +578,6 @@ private JabRefPreferences() {
defaults.put(HIGHLIGHT_GROUPS_MATCHING_ANY, Boolean.FALSE);
defaults.put(HIGHLIGHT_GROUPS_MATCHING_ALL, Boolean.FALSE);
defaults.put(TOOLBAR_VISIBLE, Boolean.TRUE);
defaults.put(SEARCH_PANEL_VISIBLE, Boolean.FALSE);
defaults.put(DEFAULT_ENCODING, "UTF-8");
defaults.put(GROUPS_VISIBLE_ROWS, 8);
defaults.put(DEFAULT_OWNER, System.getProperty("user.name"));
Expand Down Expand Up @@ -665,9 +651,7 @@ private JabRefPreferences() {
defaults.put(WARN_BEFORE_OVERWRITING_KEY, Boolean.TRUE);
defaults.put(CONFIRM_DELETE, Boolean.TRUE);
defaults.put(GRAY_OUT_NON_HITS, Boolean.TRUE);
defaults.put(FLOAT_SEARCH, Boolean.TRUE);
defaults.put(SHOW_SEARCH_IN_DIALOG, Boolean.FALSE);
defaults.put(SEARCH_ALL_BASES, Boolean.FALSE);
defaults.put(SEARCH_MODE_FLOAT, Boolean.FALSE);
defaults.put(DEFAULT_LABEL_PATTERN, "[authors3][year]");
defaults.put(PREVIEW_ENABLED, Boolean.TRUE);
defaults.put(ACTIVE_PREVIEW, 0);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/sf/jabref/SearchManagerNoGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Collection;
import java.util.Vector;

import net.sf.jabref.logic.search.SearchQuery;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -49,19 +50,18 @@ public BibtexDatabase getDBfromMatches() {
searchTerm = fieldYear();
}

SearchRule searchRule = SearchRules.getSearchRuleByQuery(searchTerm,
Globals.prefs.getBoolean(JabRefPreferences.CASE_SENSITIVE_SEARCH),
Globals.prefs.getBoolean(JabRefPreferences.REG_EXP_SEARCH));
SearchQuery searchQuery = new SearchQuery(searchTerm, Globals.prefs.getBoolean(JabRefPreferences.SEARCH_CASE_SENSITIVE),
Globals.prefs.getBoolean(JabRefPreferences.SEARCH_REG_EXP));

if (!searchRule.validateSearchStrings(searchTerm)) {
if (!searchQuery.isValidQuery()) {
LOGGER.warn("Search failed: illegal search expression");
return base;
}

Collection<BibtexEntry> entries = database.getEntries();
Vector<BibtexEntry> matchEntries = new Vector<>();
for (BibtexEntry entry : entries) {
boolean hit = searchRule.applyRule(searchTerm, entry);
boolean hit = searchQuery.isMatch(entry);
entry.setSearchHit(hit);
if (hit) {
matchEntries.add(entry);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/exporter/layout/Layout.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.logging.LogFactory;

import java.util.ArrayList;
import java.util.List;

import net.sf.jabref.model.database.BibtexDatabase;
import net.sf.jabref.model.entry.BibtexEntry;
Expand All @@ -36,7 +37,7 @@ public class Layout {

private static final Log LOGGER = LogFactory.getLog(Layout.class);

public Layout(Vector<StringInt> parsedEntries, String classPrefix) throws Exception {
public Layout(Vector<StringInt> parsedEntries, String classPrefix) {
StringInt si;
Vector<LayoutEntry> tmpEntries = new Vector<>(parsedEntries.size());

Expand Down Expand Up @@ -121,8 +122,7 @@ public String doLayout(BibtexEntry bibtex, BibtexDatabase database) {
* string references will be replaced by the strings' contents. Even
* recursive string references are resolved.
*/
public String doLayout(BibtexEntry bibtex, BibtexDatabase database, ArrayList<String> wordsToHighlight)
{
public String doLayout(BibtexEntry bibtex, BibtexDatabase database, List<String> wordsToHighlight) {
StringBuilder sb = new StringBuilder(100);

for (LayoutEntry layoutEntry : layoutEntries) {
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/net/sf/jabref/exporter/layout/LayoutEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -58,7 +60,7 @@ class LayoutEntry {
private static final Log LOGGER = LogFactory.getLog(LayoutEntry.class);


public LayoutEntry(StringInt si, String classPrefix_) throws Exception {
public LayoutEntry(StringInt si, String classPrefix_) {
type = si.i;
classPrefix = classPrefix_;

Expand Down Expand Up @@ -94,7 +96,7 @@ public LayoutEntry(StringInt si, String classPrefix_) throws Exception {
}
}

public LayoutEntry(Vector<StringInt> parsedEntries, String classPrefix_, int layoutType) throws Exception {
public LayoutEntry(Vector<StringInt> parsedEntries, String classPrefix_, int layoutType) {
classPrefix = classPrefix_;
String blockStart;
String blockEnd;
Expand Down Expand Up @@ -177,7 +179,7 @@ private String doLayout(BibtexEntry bibtex, BibtexDatabase database) {
return doLayout(bibtex, database, null);
}

public String doLayout(BibtexEntry bibtex, BibtexDatabase database, ArrayList<String> wordsToHighlight) {
public String doLayout(BibtexEntry bibtex, BibtexDatabase database, List<String> wordsToHighlight) {
switch (type) {
case LayoutHelper.IS_LAYOUT_TEXT:
return text;
Expand Down Expand Up @@ -479,16 +481,16 @@ public ArrayList<String> getInvalidFormatters() {
* This check is a quick hack to avoid highlighting of HTML tags It does not always work, but it does its job mostly
*
* @param text This is a String in which we search for different words
* @param toHighlight List of all words which must be highlighted
*
* @param wordsToHighlight List of all words which must be highlighted
*
* @return String that was called by the method, with HTML Tags if a word was found
*/
private String highlightWords(String text, ArrayList<String> toHighlight) {
if (toHighlight == null) {
private String highlightWords(String text, List<String> wordsToHighlight) {
if (wordsToHighlight == null) {
return text;
}

Matcher matcher = Util.getPatternForWords(toHighlight).matcher(text);
Matcher matcher = Util.getPatternForWords(wordsToHighlight).matcher(text);

if (Character.isLetterOrDigit(text.charAt(0))) {
String hlColor = HIGHLIGHT_COLOR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public LayoutHelper(Reader in) {
_in = new PushbackReader(in);
}

public Layout getLayoutFromText(String classPrefix) throws Exception {
public Layout getLayoutFromText(String classPrefix) throws IOException {
parse();

StringInt si;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/sf/jabref/groups/GroupSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ public void valueChanged(TreeSelectionEvent e) {
final TreePath[] selection = groupsTree.getSelectionPaths();
if ((selection == null) || (selection.length == 0) || ((selection.length == 1)
&& (((GroupTreeNode) selection[0].getLastPathComponent()).getGroup() instanceof AllEntriesGroup))) {
panel.stopShowingGroup();
panel.getFilterGroupToggle().stop();
panel.mainTable.stopShowingFloatGrouping();
if (showOverlappingGroups.isSelected()) {
groupsTree.setHighlight2Cells(null);
Expand Down Expand Up @@ -784,11 +784,11 @@ public void update() {
// Show the result in the chosen way:
if (hideNonHits.isSelected()) {
panel.mainTable.stopShowingFloatGrouping(); // Turn off shading, if active.
panel.setGroupMatcher(GroupMatcher.INSTANCE); // Turn on filtering.
panel.getFilterGroupToggle().start(); // Turn on filtering.

} else if (grayOut.isSelected()) {
panel.stopShowingGroup(); // Turn off filtering, if active.
panel.mainTable.showFloatGrouping(GroupMatcher.INSTANCE); // Turn on shading.
panel.getFilterGroupToggle().stop(); // Turn off filtering, if active.
panel.mainTable.showFloatGrouping(); // Turn on shading.
}

if (showOverlappingGroupsP) {
Expand Down Expand Up @@ -889,7 +889,7 @@ public void componentOpening() {
@Override
public void componentClosing() {
if (panel != null) {// panel may be null if no file is open any more
panel.stopShowingGroup();
panel.getFilterGroupToggle().stop();
panel.mainTable.stopShowingFloatGrouping();
}
frame.groupToggle.setSelected(false);
Expand Down
Loading

0 comments on commit 446a593

Please sign in to comment.