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

Better search #332

Merged
merged 51 commits into from
Nov 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0265b6c
First version of search bar at top
tobiasdiez Sep 2, 2015
4cfeb6d
Merge remote-tracking branch 'upstream/dev_2.11' into uisearch
tobiasdiez Sep 2, 2015
f93a350
Code cleanup
tobiasdiez Sep 2, 2015
ae50ac4
Remove unnecessary libs
tobiasdiez Sep 2, 2015
77d9875
Revert "Remove unnecessary libs"
tobiasdiez Sep 2, 2015
f897fe7
Revert "Revert "Remove unnecessary libs""
tobiasdiez Sep 2, 2015
570cac4
Add description in changelog
tobiasdiez Sep 2, 2015
2c9601c
Revert "Add description in changelog"
tobiasdiez Sep 2, 2015
9891b6a
Add description in changelog
tobiasdiez Sep 2, 2015
87c180b
Fix of gradle build and code cleanup
tobiasdiez Sep 3, 2015
ae8c35e
Code cleanup, refactor
tobiasdiez Sep 11, 2015
822168a
Merge remote-tracking branch 'JabRef/master' into uisearch
tobiasdiez Sep 11, 2015
bb68a5d
Fix NullException
tobiasdiez Sep 11, 2015
709056d
Add jsplitbutton to libraries
tobiasdiez Sep 11, 2015
fe17cae
Merge remote-tracking branch 'JabRef/master' into uisearch
tobiasdiez Sep 11, 2015
52ef6e8
Integrate last changes
tobiasdiez Sep 11, 2015
87fdc31
Code cleanup and format
tobiasdiez Sep 12, 2015
ba8d1cc
Move files
tobiasdiez Sep 12, 2015
2150300
Revert code formatting
tobiasdiez Nov 7, 2015
d736b42
Merge remote-tracking branch 'refs/remotes/JabRef/master' into uisearch
tobiasdiez Nov 7, 2015
a1b231e
Towards a easier to use search by removing incremental search, adding…
simonharrer Nov 16, 2015
30e8851
Improve code and better search description while hovering over the qu…
simonharrer Nov 16, 2015
a2b0588
Search now per tab, plus global search only per popup from an existin…
simonharrer Nov 16, 2015
e24a5a4
Fixes settings menu, search text field is colored depending whether e…
simonharrer Nov 17, 2015
96a4e7c
Use checkboxes intead of toggle buttons.
simonharrer Nov 17, 2015
251f81c
Moved SearchTextListener and its corresponding logic into the logic p…
simonharrer Nov 17, 2015
c9e5b1f
Merge branch 'master' into search-improvements
simonharrer Nov 20, 2015
364139d
Remove split button.
simonharrer Nov 20, 2015
31918b1
User cannot disable auto-complete or highlight words - they are alway…
simonharrer Nov 20, 2015
adf000f
User cannot disable auto-complete or highlight words - they are alway…
simonharrer Nov 20, 2015
e6938ae
Shorter name for global search.
simonharrer Nov 20, 2015
5abe7cb
Remove unused code.
simonharrer Nov 20, 2015
1cfee69
Merge branch 'master' into search-improvements
simonharrer Nov 23, 2015
3e64e40
Add lighter colors
simonharrer Nov 23, 2015
f3f0042
Merge branch 'master' into search-improvements
simonharrer Nov 24, 2015
b3f4440
Search is only triggered once and not two times in special circumstan…
simonharrer Nov 24, 2015
d341f97
By default, regex search is deactivated.
simonharrer Nov 24, 2015
0f3c4de
SearchQueryLocalizer localizes a SearchQuery for display to the user.
simonharrer Nov 24, 2015
a11f2aa
ESC moves focus to main table again when pressed when having focus in…
simonharrer Nov 24, 2015
4ac9216
Minor code improvements.
simonharrer Nov 24, 2015
22ab748
Merge branch 'master' into uisearchhistory
simonharrer Nov 25, 2015
1d5ddbf
JabRef has had serious issues as a lot of code was NOT executed on th…
simonharrer Nov 25, 2015
b0a124e
Fixes issue that opening a new window resulted in a NPE within the Pr…
simonharrer Nov 25, 2015
4f84f54
Floating is shown in the right order again.
simonharrer Nov 25, 2015
26e53f9
Button allows switching the Float/Filter mode.
simonharrer Nov 25, 2015
8660d0b
Simpler l10n texts.
simonharrer Nov 25, 2015
de4ea1f
Merge branch 'master' into uisearchhistory
simonharrer Nov 26, 2015
a72bb0c
Search icon indicates whether advanced search is active with tooltip …
simonharrer Nov 26, 2015
db76624
Remove unused code.
simonharrer Nov 26, 2015
d77c746
Fixes an issue caused by cycling through issues and searching: focus …
simonharrer Nov 26, 2015
f453017
Use green instead of red.
simonharrer Nov 26, 2015
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 @@ -99,6 +109,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