Skip to content

Commit

Permalink
Merge branch 'master' into mrdlib_removal
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Jul 28, 2015
2 parents 92a734a + a2afe39 commit b780f85
Show file tree
Hide file tree
Showing 42 changed files with 429 additions and 562 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[mrdlib_removal]
- Remove Mr.DLib support as MR.DLib will be shut down in 2015
[master]
- "ISBN to BibTeX" fetcher now uses eBook.de's API (fixes bug #1241)
- Update dependencies: jersey, commons.logging, pdfbox, jgoodies, lazedlists, JDBC connectors
- Refactored preferences
- Remove local jgoodies dependency: replace SimpleInteralFrame with swingx JXTitledPanel and UIFSplitPane by JSplitPane
Expand All @@ -14,6 +15,7 @@
- Switch vom antlr2 grammar to antlr4 for capturing the search expressions. Should be backwards compatible.
- Changed html description of search expressions, expressing the conditional logic more explicitly with brackets.
- Fixed INSPIRE searches compatibility problem (by Stefano Gariazzo).
- BREAKING: Search groups now use same search logic as UI --> avoids confusion when converting a UI search into a search group. Behaviour before: contains/regex check of whole search string; behaviour after: contains/regex check of every word of the search string. The new search is more powerful and con simulate the old behaviour: enclose everything in double quotes, e.g., process language --> "process language".
2.11 beta 3
- New MacOSX integration
- Two releases for MacOSX: OSX-Java6 for Apple Java 1.6 and OSX for Oracle Java 1.7+
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/sf/jabref/SearchManager2.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
import net.sf.jabref.search.SearchRule;
import net.sf.jabref.search.SearchRules;
import net.sf.jabref.search.matchers.SearchMatcher;
import net.sf.jabref.search.rules.BasicRegexSearchRule;
import net.sf.jabref.search.rules.BasicSearchRule;
import net.sf.jabref.search.rules.SearchExpression;
import net.sf.jabref.search.rules.GrammarBasedSearchRule;

import javax.swing.*;
import javax.swing.event.CaretEvent;
Expand Down Expand Up @@ -802,7 +800,7 @@ private void updateSearchButtonText() {
}

private boolean isSpecificSearch() {
return !increment.isSelected() && SearchExpression.isValid(caseSensitive.isSelected(), regExpSearch.isSelected(), searchField.getText());
return !increment.isSelected() && GrammarBasedSearchRule.isValid(caseSensitive.isSelected(), regExpSearch.isSelected(), searchField.getText());
}

@Override
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/net/sf/jabref/SearchManagerNoGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

import net.sf.jabref.imports.*;
import net.sf.jabref.search.SearchRules;
import net.sf.jabref.search.rules.BasicRegexSearchRule;
import net.sf.jabref.search.rules.BasicSearchRule;
import net.sf.jabref.search.rules.SearchExpression;
import net.sf.jabref.search.SearchRule;

/**
Expand Down
73 changes: 30 additions & 43 deletions src/main/java/net/sf/jabref/groups/GroupDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@
*/
package net.sf.jabref.groups;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.Borders;
import com.jgoodies.forms.layout.FormLayout;
import net.sf.jabref.*;
import net.sf.jabref.groups.structure.*;
import net.sf.jabref.search.SearchRules;
import net.sf.jabref.search.describer.SearchDescribers;
import net.sf.jabref.util.StringUtil;
import net.sf.jabref.util.Util;

import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.undo.AbstractUndoableEdit;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
Expand All @@ -28,24 +39,6 @@
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.undo.AbstractUndoableEdit;

import com.jgoodies.forms.factories.Borders;
import net.sf.jabref.*;
import net.sf.jabref.groups.structure.*;
import net.sf.jabref.search.describer.BasicSearchDescriber;
import net.sf.jabref.search.describer.SearchExpressionDescriber;
import net.sf.jabref.search.rules.SearchExpression;
import net.sf.jabref.util.StringUtil;
import net.sf.jabref.util.Util;

import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.FormLayout;

/**
* Dialog for creating or modifying groups. Operates directly on the Vector
* containing group information.
Expand All @@ -65,11 +58,11 @@ class GroupDialog extends JDialog {
private final JRadioButton m_searchRadioButton = new JRadioButton(
Globals.lang("Dynamically group entries by a free-form search expression"));
private final JRadioButton m_independentButton = new JRadioButton( // JZTODO lyrics
Globals.lang("Independent group: When selected, view only this group's entries"));
Globals.lang("Independent group: When selected, view only this group's entries"));
private final JRadioButton m_intersectionButton = new JRadioButton( // JZTODO lyrics
Globals.lang("Refine supergroup: When selected, view entries contained in both this group and its supergroup"));
Globals.lang("Refine supergroup: When selected, view entries contained in both this group and its supergroup"));
private final JRadioButton m_unionButton = new JRadioButton( // JZTODO lyrics
Globals.lang("Include subgroups: When selected, view entries contained in this group or its subgroups"));
Globals.lang("Include subgroups: When selected, view entries contained in this group or its subgroups"));
// for KeywordGroup
private final JTextField m_kgSearchField = new JTextField(GroupDialog.TEXTFIELD_LENGTH);
private final FieldTextField m_kgSearchTerm = new FieldTextField("keywords", "",
Expand Down Expand Up @@ -111,17 +104,13 @@ public Dimension getPreferredSize() {

private final CardLayout m_optionsLayout = new CardLayout();


/**
* Shows a group add/edit dialog.
*
* @param jabrefFrame
* The parent frame.
* @param basePanel
* The default grouping field.
* @param editedGroup
* The group being edited, or null if a new group is to be
* created.
* @param jabrefFrame The parent frame.
* @param basePanel The default grouping field.
* @param editedGroup The group being edited, or null if a new group is to be
* created.
*/
public GroupDialog(JabRefFrame jabrefFrame, BasePanel basePanel,
AbstractGroup editedGroup) {
Expand Down Expand Up @@ -308,9 +297,9 @@ public void actionPerformed(ActionEvent e) {
// therefore I don't catch anything here
m_resultingGroup = new KeywordGroup(
m_name.getText().trim(), m_kgSearchField.getText()
.trim(), m_kgSearchTerm.getText().trim(),
.trim(), m_kgSearchTerm.getText().trim(),
m_kgCaseSensitive.isSelected(), m_kgRegExp
.isSelected(), getContext());
.isSelected(), getContext());
if (((m_editedGroup instanceof ExplicitGroup) || (m_editedGroup instanceof SearchGroup))
&& m_resultingGroup.supportsAdd()) {
addPreviousEntries();
Expand Down Expand Up @@ -448,12 +437,8 @@ private void updateComponents() {
+ "To search the field <b>Author</b> for <b>Smith</b> and the field <b>Title</b> for <b>electrical</b>, enter%c<p>"
+ "<tt>author%esmith and title%eelectrical</tt>"));
} else {
SearchExpression expression = new SearchExpression(isCaseSensitive(), isRegex());
if(expression.validateSearchStrings(s1)) {
setDescription(new SearchExpressionDescriber(isCaseSensitive(), isRegex(), expression.getTree()).getDescription());
} else {
setDescription(new BasicSearchDescriber(isCaseSensitive(), isRegex(), s1).getDescription());
}
setDescription(SearchDescribers.getSearchDescriberFor(SearchRules.getSearchRuleByQuery(s1, isCaseSensitive(), isRegex()), s1).getDescription());

if (isRegex()) {
try {
Pattern.compile(s1);
Expand Down Expand Up @@ -553,7 +538,9 @@ public AbstractUndoableEdit getUndoForAddPreviousEntries() {
return m_undoAddPreviousEntires;
}

/** Sets the font of the name entry field. */
/**
* Sets the font of the name entry field.
*/
private void setNameFontItalic(boolean italic) {
Font f = m_name.getFont();
if (f.isItalic() != italic) {
Expand Down
111 changes: 46 additions & 65 deletions src/main/java/net/sf/jabref/groups/structure/SearchGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/
package net.sf.jabref.groups.structure;

import javax.swing.undo.AbstractUndoableEdit;

import net.sf.jabref.*;
import net.sf.jabref.search.describer.BasicSearchDescriber;
import net.sf.jabref.search.describer.SearchExpressionDescriber;
import net.sf.jabref.search.rules.RegExpSearchRule;
import net.sf.jabref.BibtexDatabase;
import net.sf.jabref.BibtexEntry;
import net.sf.jabref.Globals;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.search.SearchRule;
import net.sf.jabref.search.rules.SearchExpression;
import net.sf.jabref.search.rules.SimpleSearchRule;
import net.sf.jabref.search.SearchRules;
import net.sf.jabref.search.describer.SearchDescribers;
import net.sf.jabref.util.QuotedStringTokenizer;
import net.sf.jabref.util.StringUtil;

import javax.swing.undo.AbstractUndoableEdit;

/**
* Internally, it consists of a search pattern.
*
Expand All @@ -40,14 +40,7 @@ public class SearchGroup extends AbstractGroup {
private final boolean caseSensitive;
private final boolean regExp;

/**
* If searchExpression is in valid syntax for advanced search, <b>this
* </b> will do the search; otherwise, either <b>RegExpSearchRule </b> or
* <b>SimpleSearchRule </b> will be used.
*/
private final SearchRule searchRule;
private final SearchExpression expressionSearchRule;


/**
* Creates a SearchGroup with the specified properties.
Expand All @@ -58,15 +51,7 @@ public SearchGroup(String name, String searchExpression, boolean caseSensitive,
this.caseSensitive = caseSensitive;
this.regExp = regExp;

// TODO why use other search rules instead of "normal" search in JabRef. This WILL cause confusion!
expressionSearchRule = new SearchExpression(caseSensitive, regExp);
if (expressionSearchRule.validateSearchStrings(this.searchExpression)) {
searchRule = expressionSearchRule; // do advanced search
} else if (this.regExp) {
searchRule = new RegExpSearchRule(this.caseSensitive);
} else {
searchRule = new SimpleSearchRule(this.caseSensitive);
}
this.searchRule = SearchRules.getSearchRuleByQuery(searchExpression, caseSensitive, regExp);
}

/**
Expand All @@ -76,7 +61,7 @@ public SearchGroup(String name, String searchExpression, boolean caseSensitive,
* SearchGroup.toString(), or null if incompatible
*/
public static AbstractGroup fromString(String s, BibtexDatabase db,
int version) throws Exception {
int version) throws Exception {
if (!s.startsWith(SearchGroup.ID)) {
throw new Exception(
"Internal error: SearchGroup cannot be created from \"" + s
Expand All @@ -86,33 +71,33 @@ public static AbstractGroup fromString(String s, BibtexDatabase db,
QuotedStringTokenizer tok = new QuotedStringTokenizer(s.substring(SearchGroup.ID
.length()), AbstractGroup.SEPARATOR, AbstractGroup.QUOTE_CHAR);
switch (version) {
case 0:
case 1:
case 2: {
String name = tok.nextToken();
String expression = tok.nextToken();
boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
// version 0 contained 4 additional booleans to specify search
// fields; these are ignored now, all fields are always searched
return new SearchGroup(StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR), StringUtil
.unquote(expression, AbstractGroup.QUOTE_CHAR), caseSensitive, regExp,
GroupHierarchyType.INDEPENDENT);
}
case 3: {
String name = tok.nextToken();
int context = Integer.parseInt(tok.nextToken());
String expression = tok.nextToken();
boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
// version 0 contained 4 additional booleans to specify search
// fields; these are ignored now, all fields are always searched
return new SearchGroup(StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR), StringUtil
.unquote(expression, AbstractGroup.QUOTE_CHAR), caseSensitive, regExp,
GroupHierarchyType.getByNumber(context));
}
default:
throw new UnsupportedVersionException("SearchGroup", version);
case 0:
case 1:
case 2: {
String name = tok.nextToken();
String expression = tok.nextToken();
boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
// version 0 contained 4 additional booleans to specify search
// fields; these are ignored now, all fields are always searched
return new SearchGroup(StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR), StringUtil
.unquote(expression, AbstractGroup.QUOTE_CHAR), caseSensitive, regExp,
GroupHierarchyType.INDEPENDENT);
}
case 3: {
String name = tok.nextToken();
int context = Integer.parseInt(tok.nextToken());
String expression = tok.nextToken();
boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
// version 0 contained 4 additional booleans to specify search
// fields; these are ignored now, all fields are always searched
return new SearchGroup(StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR), StringUtil
.unquote(expression, AbstractGroup.QUOTE_CHAR), caseSensitive, regExp,
GroupHierarchyType.getByNumber(context));
}
default:
throw new UnsupportedVersionException("SearchGroup", version);
}
}

Expand Down Expand Up @@ -227,11 +212,7 @@ public boolean isDynamic() {

@Override
public String getDescription() {
if(expressionSearchRule.getTree() != null) {
return new SearchExpressionDescriber(caseSensitive, regExp, expressionSearchRule.getTree()).getDescription();
} else {
return new BasicSearchDescriber(caseSensitive, regExp, searchExpression).getDescription();
}
return SearchDescribers.getSearchDescriberFor(searchRule, searchExpression).getDescription();
}

@Override
Expand All @@ -250,14 +231,14 @@ public String getShortDescription() {
sb.append(" <b>").
append(StringUtil.quoteForHTML(searchExpression)).append("</b>)");
switch (getHierarchicalContext()) {
case INCLUDING:
sb.append(", ").append(Globals.lang("includes subgroups"));
break;
case REFINING:
sb.append(", ").append(Globals.lang("refines supergroup"));
break;
default:
break;
case INCLUDING:
sb.append(", ").append(Globals.lang("includes subgroups"));
break;
case REFINING:
sb.append(", ").append(Globals.lang("refines supergroup"));
break;
default:
break;
}
return sb.toString();
}
Expand Down
Loading

0 comments on commit b780f85

Please sign in to comment.