Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/AdvancedTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public void storeSettings() {

preferences.putBoolean(JabRefPreferences.BIBLATEX_MODE, biblatexMode.isSelected());

if ((useDefault.isSelected() == oldUseDef) ||
if (useDefault.isSelected() == oldUseDef ||
!oldLnf.equals(className.getSelectedItem().toString())) {
JOptionPane.showMessageDialog(null,
Globals.lang("You have changed the look and feel setting.")
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/net/sf/jabref/AppearancePrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ public AppearancePrefsTab(JabRefPreferences prefs) {
//p2.add(browseBut);
//builder.append(p2);

JPanel upper = new JPanel(), sort = new JPanel(), namesp = new JPanel(), iconCol = new JPanel();
JPanel upper = new JPanel();
JPanel sort = new JPanel();
JPanel namesp = new JPanel();
JPanel iconCol = new JPanel();
GridBagLayout gbl = new GridBagLayout();
upper.setLayout(gbl);
sort.setLayout(gbl);
Expand Down Expand Up @@ -189,8 +192,8 @@ public void storeSettings() {
_prefs.putBoolean(JabRefPreferences.TABLE_SHOW_GRID, showGrid.isSelected());
try {
int size = Integer.parseInt(fontSize.getText());
if ((overrideFonts.isSelected() != oldOverrideFontSize) ||
(size != oldMenuFontSize)) {
if (overrideFonts.isSelected() != oldOverrideFontSize ||
size != oldMenuFontSize) {
_prefs.putInt(JabRefPreferences.MENU_FONT_SIZE, size);
JOptionPane.showMessageDialog(null,
Globals.lang("You have changed the menu and label font size.")
Expand Down
103 changes: 55 additions & 48 deletions src/main/java/net/sf/jabref/AuthorList.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ public class AuthorList {

// Variables for storing computed strings, so they only need be created
// once:
private String authorsNatbib = null, authorsFirstFirstAnds = null,
authorsAlph = null;
private String authorsNatbib = null;
private String authorsFirstFirstAnds = null;
private String authorsAlph = null;

private final String[] authorsFirstFirst = new String[4];
private final String[] authorsLastOnly = new String[2];
Expand Down Expand Up @@ -379,12 +380,12 @@ private Author getAuthor() {
von_start = tokens.size() - AuthorList.TOKEN_GROUP_LENGTH;
break;
}
} else if ((last_start < 0) && token_case) {
} else if (last_start < 0 && token_case) {
last_start = tokens.size() - AuthorList.TOKEN_GROUP_LENGTH;
break;
}
}
}// end token_loop
}

// Second step: split name into parts (here: calculate indices
// of parts in 'tokens' Vector)
Expand All @@ -394,14 +395,20 @@ private Author getAuthor() {
}

// the following negatives indicate absence of the corresponding part
int first_part_start = -1, von_part_start = -1, last_part_start = -1, jr_part_start = -1;
int first_part_end, von_part_end = 0, last_part_end = 0, jr_part_end = 0;
int first_part_start = -1;
int von_part_start = -1;
int last_part_start = -1;
int jr_part_start = -1;
int first_part_end;
int von_part_end = 0;
int last_part_end = 0;
int jr_part_end = 0;
boolean jrAsFirstname = false;
if (comma_first < 0) { // no commas
if (von_start < 0) { // no 'von part'
last_part_end = tokens.size();
last_part_start = tokens.size() - AuthorList.TOKEN_GROUP_LENGTH;
int index = (tokens.size() - (2 * AuthorList.TOKEN_GROUP_LENGTH)) + AuthorList.OFFSET_TOKEN_TERM;
int index = tokens.size() - 2 * AuthorList.TOKEN_GROUP_LENGTH + AuthorList.OFFSET_TOKEN_TERM;
if (index > 0) {
Character ch = (Character) tokens.elementAt(index);
if (ch == '-') {
Expand Down Expand Up @@ -461,7 +468,7 @@ private Author getAuthor() {
}
}

if ((first_part_start == -1) && (last_part_start == -1) && (von_part_start != -1)) {
if (first_part_start == -1 && last_part_start == -1 && von_part_start != -1) {
// There is no first or last name, but we have a von part. This is likely
// to indicate a single-entry name without an initial capital letter, such
// as "unknown".
Expand All @@ -478,13 +485,13 @@ private Author getAuthor() {
}

// Third step: do actual splitting, construct Author object
return new Author((first_part_start < 0 ? null : concatTokens(first_part_start,
first_part_end, AuthorList.OFFSET_TOKEN, false)), (first_part_start < 0 ? null : concatTokens(
first_part_start, first_part_end, AuthorList.OFFSET_TOKEN_ABBR, true)), (von_part_start < 0 ? null
: concatTokens(von_part_start, von_part_end, AuthorList.OFFSET_TOKEN, false)),
(last_part_start < 0 ? null : concatTokens(last_part_start, last_part_end,
AuthorList.OFFSET_TOKEN, false)), (jr_part_start < 0 ? null : concatTokens(jr_part_start,
jr_part_end, AuthorList.OFFSET_TOKEN, false)));
return new Author(first_part_start < 0 ? null : concatTokens(first_part_start,
first_part_end, AuthorList.OFFSET_TOKEN, false), first_part_start < 0 ? null : concatTokens(
first_part_start, first_part_end, AuthorList.OFFSET_TOKEN_ABBR, true), von_part_start < 0 ? null
: concatTokens(von_part_start, von_part_end, AuthorList.OFFSET_TOKEN, false),
last_part_start < 0 ? null : concatTokens(last_part_start, last_part_end,
AuthorList.OFFSET_TOKEN, false), jr_part_start < 0 ? null : concatTokens(jr_part_start,
jr_part_end, AuthorList.OFFSET_TOKEN, false));
}

/**
Expand Down Expand Up @@ -516,7 +523,7 @@ private String concatTokens(int start, int end, int offset, boolean dot_after) {
}
start += AuthorList.TOKEN_GROUP_LENGTH;
while (start < end) {
res.append(tokens.get((start - AuthorList.TOKEN_GROUP_LENGTH) + AuthorList.OFFSET_TOKEN_TERM));
res.append(tokens.get(start - AuthorList.TOKEN_GROUP_LENGTH + AuthorList.OFFSET_TOKEN_TERM));
res.append((String) tokens.get(start + offset));
if (dot_after) {
res.append('.');
Expand Down Expand Up @@ -557,7 +564,7 @@ private int getToken() {
token_start = token_end;
while (token_start < orig.length()) {
char c = orig.charAt(token_start);
if (!((c == '~') || (c == '-') || Character.isWhitespace(c))) {
if (!(c == '~' || c == '-' || Character.isWhitespace(c))) {
break;
}
token_start++;
Expand Down Expand Up @@ -586,10 +593,10 @@ private int getToken() {
braces_level--;
}
}
if (first_letter_is_found && (token_abbr < 0) && (braces_level == 0)) {
if (first_letter_is_found && token_abbr < 0 && braces_level == 0) {
token_abbr = token_end;
}
if (!first_letter_is_found && (current_backslash < 0) && Character.isLetter(c)) {
if (!first_letter_is_found && current_backslash < 0 && Character.isLetter(c)) {
if (braces_level == 0) {
token_case = Character.isUpperCase(c);
} else {
Expand All @@ -600,7 +607,7 @@ private int getToken() {
}
first_letter_is_found = true;
}
if ((current_backslash >= 0) && !Character.isLetter(c)) {
if (current_backslash >= 0 && !Character.isLetter(c)) {
if (!first_letter_is_found) {
String tex_cmd_name = orig.substring(current_backslash + 1, token_end);
if (AuthorList.tex_names.contains(tex_cmd_name)) {
Expand All @@ -614,7 +621,7 @@ private int getToken() {
current_backslash = token_end;
}
if (braces_level == 0) {
if ((c == ',') || (c == '~') || (c == '-') || Character.isWhitespace(c)) {
if (c == ',' || c == '~' || c == '-' || Character.isWhitespace(c)) {
break;
}
}
Expand All @@ -628,7 +635,7 @@ private int getToken() {
if (token_abbr < 0) {
token_abbr = token_end;
}
if ((token_end < orig.length()) && (orig.charAt(token_end) == '-')) {
if (token_end < orig.length() && orig.charAt(token_end) == '-') {
token_term = '-';
}
if (orig.substring(token_start, token_end).equalsIgnoreCase("and")) {
Expand Down Expand Up @@ -711,7 +718,7 @@ public String getAuthorsNatbib() {
* @return formatted list of authors.
*/
public String getAuthorsLastOnly(boolean oxfordComma) {
int abbrInt = (oxfordComma ? 0 : 1);
int abbrInt = oxfordComma ? 0 : 1;

// Check if we've computed this before:
if (authorsLastOnly[abbrInt] != null) {
Expand All @@ -722,12 +729,12 @@ public String getAuthorsLastOnly(boolean oxfordComma) {
if (size() > 0) {
res.append(getAuthor(0).getLastOnly());
int i = 1;
while (i < (size() - 1)) {
while (i < size() - 1) {
res.append(", ");
res.append(getAuthor(i).getLastOnly());
i++;
}
if ((size() > 2) && oxfordComma) {
if (size() > 2 && oxfordComma) {
res.append(',');
}
if (size() > 1) {
Expand Down Expand Up @@ -766,8 +773,8 @@ public String getAuthorsLastOnly(boolean oxfordComma) {
* @return formatted list of authors.
*/
public String getAuthorsLastFirst(boolean abbreviate, boolean oxfordComma) {
int abbrInt = (abbreviate ? 0 : 1);
abbrInt += (oxfordComma ? 0 : 2);
int abbrInt = abbreviate ? 0 : 1;
abbrInt += oxfordComma ? 0 : 2;

// Check if we've computed this before:
if (authorsLastFirst[abbrInt] != null) {
Expand All @@ -778,12 +785,12 @@ public String getAuthorsLastFirst(boolean abbreviate, boolean oxfordComma) {
if (size() > 0) {
res.append(getAuthor(0).getLastFirst(abbreviate));
int i = 1;
while (i < (size() - 1)) {
while (i < size() - 1) {
res.append(", ");
res.append(getAuthor(i).getLastFirst(abbreviate));
i++;
}
if ((size() > 2) && oxfordComma) {
if (size() > 2 && oxfordComma) {
res.append(',');
}
if (size() > 1) {
Expand Down Expand Up @@ -815,7 +822,7 @@ public String toString() {
* @return formatted list of authors.
*/
public String getAuthorsLastFirstAnds(boolean abbreviate) {
int abbrInt = (abbreviate ? 0 : 1);
int abbrInt = abbreviate ? 0 : 1;
// Check if we've computed this before:
if (authorLastFirstAnds[abbrInt] != null) {
return authorLastFirstAnds[abbrInt];
Expand All @@ -835,7 +842,7 @@ public String getAuthorsLastFirstAnds(boolean abbreviate) {
}

public String getAuthorsLastFirstFirstLastAnds(boolean abbreviate) {
int abbrInt = (abbreviate ? 0 : 1);
int abbrInt = abbreviate ? 0 : 1;
// Check if we've computed this before:
if (authorsLastFirstFirstLast[abbrInt] != null) {
return authorsLastFirstFirstLast[abbrInt];
Expand Down Expand Up @@ -881,8 +888,8 @@ public String getAuthorsLastFirstFirstLastAnds(boolean abbreviate) {
*/
public String getAuthorsFirstFirst(boolean abbr, boolean oxfordComma) {

int abbrInt = (abbr ? 0 : 1);
abbrInt += (oxfordComma ? 0 : 2);
int abbrInt = abbr ? 0 : 1;
abbrInt += oxfordComma ? 0 : 2;

// Check if we've computed this before:
if (authorsFirstFirst[abbrInt] != null) {
Expand All @@ -893,12 +900,12 @@ public String getAuthorsFirstFirst(boolean abbr, boolean oxfordComma) {
if (size() > 0) {
res.append(getAuthor(0).getFirstLast(abbr));
int i = 1;
while (i < (size() - 1)) {
while (i < size() - 1) {
res.append(", ");
res.append(getAuthor(i).getFirstLast(abbr));
i++;
}
if ((size() > 2) && oxfordComma) {
if (size() > 2 && oxfordComma) {
res.append(',');
}
if (size() > 1) {
Expand Down Expand Up @@ -930,7 +937,7 @@ public boolean equals(Object o) {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((authors == null) ? 0 : authors.hashCode());
result = prime * result + (authors == null ? 0 : authors.hashCode());
return result;
}

Expand Down Expand Up @@ -1026,15 +1033,15 @@ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((first_abbr == null) ? 0 : first_abbr.hashCode());
+ (first_abbr == null ? 0 : first_abbr.hashCode());
result = prime * result
+ ((first_part == null) ? 0 : first_part.hashCode());
+ (first_part == null ? 0 : first_part.hashCode());
result = prime * result
+ ((jr_part == null) ? 0 : jr_part.hashCode());
+ (jr_part == null ? 0 : jr_part.hashCode());
result = prime * result
+ ((last_part == null) ? 0 : last_part.hashCode());
+ (last_part == null ? 0 : last_part.hashCode());
result = prime * result
+ ((von_part == null) ? 0 : von_part.hashCode());
+ (von_part == null ? 0 : von_part.hashCode());
return result;
}

Expand Down Expand Up @@ -1114,7 +1121,7 @@ private boolean properBrackets(String s) {
}
i++;
}
return (level == 0);
return level == 0;
}

/**
Expand Down Expand Up @@ -1239,9 +1246,9 @@ public String getJr() {
*/
public String getLastOnly() {
if (von_part == null) {
return (last_part == null ? "" : last_part);
return last_part == null ? "" : last_part;
} else {
return (last_part == null ? von_part : von_part + ' ' + last_part);
return last_part == null ? von_part : von_part + ' ' + last_part;
}
}

Expand Down Expand Up @@ -1315,12 +1322,12 @@ public String getNameForAlphabetization() {
res.append(", ");
res.append(first_abbr);
}
while ((res.length() > 0) && (res.charAt(0) == '{')) {
while (res.length() > 0 && res.charAt(0) == '{') {
res.deleteCharAt(0);
}
return res.toString();
}
}// end Author
}


public static void main(String[] args) {
Expand All @@ -1335,6 +1342,6 @@ public static void main(String[] args) {
System.out.println((i + 1) + ": von = '" + a.getVon() + '\'');
}

System.out.println((new CreateDocBookAuthors()).format(s));
System.out.println(new CreateDocBookAuthors().format(s));
}
}// end AuthorList
}
Loading