Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6e18e87
Remove unused import in BibtexDatabaseTest
lenhard Jul 16, 2015
b7812d1
Fix Findbugs warning and remove unused variable in OOBibStyle
lenhard Jul 16, 2015
d5c7c72
Add hashCode implementation that matches equals
lenhard Jul 16, 2015
476625b
Add hashCode implementation for AuthorList.Author
lenhard Jul 16, 2015
dda0762
Remove unused items and add serialVersionUIDs in BasePanel
lenhard Jul 16, 2015
5649e94
Fix potential misplaced parantheses bug in BasePanel
lenhard Jul 16, 2015
d168b01
Remove unused code and add serialVersionUIDs to get rid of warnings
lenhard Jul 16, 2015
028e1ea
Add default serialVersionUIDs to silence warnings
lenhard Jul 16, 2015
4af08be
Remove unnecessary if: The size of a Vector cannot be negative
lenhard Jul 16, 2015
ae47c42
Turn EasyDateFormat non-static
lenhard Jul 16, 2015
f481398
Improve method naming in EasyDateFormat
lenhard Jul 16, 2015
221d898
Remove unused method with FindBugs warning
lenhard Jul 16, 2015
e0cd34a
Remove unused inner class with reference to hard-coded reference to l…
lenhard Jul 16, 2015
03b26a4
Delete class, since it is unused
lenhard Jul 16, 2015
6d4d842
Remove unused variables/assignments and add default serialVersionUID
lenhard Jul 16, 2015
d6c4445
Turn unused main-method into unit test
lenhard Jul 16, 2015
bee8a52
Improve name (Findbugs warning)
lenhard Jul 16, 2015
967a781
Remove duplicate condition
lenhard Jul 16, 2015
b57991a
Make unnecessarily static variables non-static
lenhard Jul 16, 2015
2570a64
Fix typo
lenhard Jul 16, 2015
aca2cc0
Add pull request to change log
lenhard Jul 16, 2015
b93e9aa
Fix indentation
lenhard Jul 16, 2015
60c2f28
Remove unused variable
lenhard Jul 16, 2015
e8fec29
Log broken links instead of ignoring them
lenhard Jul 17, 2015
463f633
Add call to Globals.lang and reformat with JabRef formatter
lenhard Jul 17, 2015
767de83
Build support for internationalization in log message
lenhard Jul 17, 2015
b5ef0c7
Add comment for DateFormat changes
lenhard Jul 17, 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
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[master]
- Fix several FindBugs warnings
- Fix for bug #1276: OO styles do not consider editor fields anymore for sorting
- Antialiasing is now enabled and set to LCD
2.11 beta 3
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Open `About.html` and add yourself below `Contributions from:`.

The headers of each `.java` file state the authors.
These entries should match the modifications done.
If you do not want to add your real name, add yourself as `JabRef contriubtors`.
If you do not want to add your real name, add yourself as `JabRef contributors`.

For instance,

Expand Down
27 changes: 27 additions & 0 deletions src/main/java/net/sf/jabref/AuthorList.java
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ public String getAuthorsFirstFirst(boolean abbr, boolean oxfordComma) {
return authorsFirstFirst[abbrInt];
}


/**
* Compare this object with the given one.
*
Expand All @@ -924,6 +925,15 @@ public boolean equals(Object o) {

return this.authors.equals(a.authors);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((authors == null) ? 0 : authors.hashCode());
return result;
}


/**
* Returns the list of authors separated by "and"s with first names before
Expand Down Expand Up @@ -1011,6 +1021,23 @@ public static class Author {
private final String jr_part;


@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((first_abbr == null) ? 0 : first_abbr.hashCode());
result = prime * result
+ ((first_part == null) ? 0 : first_part.hashCode());
result = prime * result
+ ((jr_part == null) ? 0 : jr_part.hashCode());
result = prime * result
+ ((last_part == null) ? 0 : last_part.hashCode());
result = prime * result
+ ((von_part == null) ? 0 : von_part.hashCode());
return result;
}

/**
* Compare this object with the given one.
*
Expand Down
32 changes: 11 additions & 21 deletions src/main/java/net/sf/jabref/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@

public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListener {

private static final long serialVersionUID = 1L;

private static final Logger logger = Logger.getLogger(BasePanel.class.getName());

public final static int SHOWING_NOTHING = 0;
Expand Down Expand Up @@ -213,7 +215,7 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe
//GroupSelector groupSelector;

private boolean showingSearch = false;
private boolean showingGroup = false;

public boolean sortingBySearchResults = false;
public boolean coloringBySearchResults = false;
public boolean hidingNonHits = false;
Expand All @@ -236,22 +238,6 @@ public ContentAutoCompleters getAutoCompleters() {

private ContentAutoCompleters autoCompleters;


/**
* Create a new BasePanel with an empty database.
* @param frame The application window.
*/
private BasePanel(JabRefFrame frame) {
this.sidePaneManager = Globals.sidePaneManager;
database = new BibtexDatabase();
metaData = new MetaData();
metaData.initializeNewDatabase();
this.frame = frame;
setupActions();
setupMainPanel();
encoding = Globals.prefs.get("defaultEncoding");
}

public BasePanel(JabRefFrame frame, BibtexDatabase db, File file,
MetaData metaData, String encoding) {
assert (frame != null);
Expand Down Expand Up @@ -2062,6 +2048,8 @@ public void listChanged(ListEvent<BibtexEntry> listEvent) {

mainTable.getActionMap().put("cut", new AbstractAction() {

private static final long serialVersionUID = 1L;

@Override
public void actionPerformed(ActionEvent e) {
try {
Expand All @@ -2073,6 +2061,8 @@ public void actionPerformed(ActionEvent e) {
});
mainTable.getActionMap().put("copy", new AbstractAction() {

private static final long serialVersionUID = 1L;

@Override
public void actionPerformed(ActionEvent e) {
try {
Expand All @@ -2084,6 +2074,8 @@ public void actionPerformed(ActionEvent e) {
});
mainTable.getActionMap().put("paste", new AbstractAction() {

private static final long serialVersionUID = 1L;

@Override
public void actionPerformed(ActionEvent e) {
try {
Expand Down Expand Up @@ -2435,7 +2427,6 @@ public EntryEditor getCurrentEditor() {
* @param editor The entry editor to add.
*/
public void showEntryEditor(EntryEditor editor) {
int oldSplitterLocation = -1;
if (mode == BasePanel.SHOWING_EDITOR) {
Globals.prefs.putInt("entryEditorHeight", splitPane.getHeight() - splitPane.getDividerLocation());
} else if (mode == BasePanel.SHOWING_PREVIEW) {
Expand Down Expand Up @@ -2599,8 +2590,9 @@ public void markBaseChanged() {
// remove this message, since it is no longer relevant. If a
// different message is shown, we leave it.
if (frame.statusLine.getText().startsWith(Globals.lang("Saved database"))) {
frame.output(" ");
}
frame.output(" ");

}

public void markNonUndoableBaseChanged() {
Expand Down Expand Up @@ -2679,7 +2671,6 @@ public void setSearchMatcher(SearchMatcher matcher) {

public void setGroupMatcher(Matcher<BibtexEntry> matcher) {
groupFilterList.setMatcher(matcher);
showingGroup = true;
}

public void stopShowingSearchResults() {
Expand All @@ -2689,7 +2680,6 @@ public void stopShowingSearchResults() {

public void stopShowingGroup() {
groupFilterList.setMatcher(NoSearchMatcher.INSTANCE);
showingGroup = false;
}

/**
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/net/sf/jabref/EasyDateFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
public class EasyDateFormat {

/**
* A static Object for date formatting. Please do not create the object
* here, because there are some references from the Globals class.....
* The formatter objects
*/
private static SimpleDateFormat dateFormatter = null;
private SimpleDateFormat dateFormatter = null;

/**
* Creates a String containing the current date (and possibly time),
Expand All @@ -18,8 +17,8 @@ public class EasyDateFormat {
*
* @return The date string.
*/
public static String easyDateFormat() {
return easyDateFormat(new Date());
public String getCurrentDate() {
return getDateAt(new Date());
}

/**
Expand All @@ -28,7 +27,7 @@ public static String easyDateFormat() {
*
* @return The formatted date string.
*/
public static String easyDateFormat(Date date) {
public String getDateAt(Date date) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! :) no strange static class anymore. 👍

// first use, create an instance
if (dateFormatter == null) {
String format = Globals.prefs.get("timeStampFormat");
Expand Down
37 changes: 35 additions & 2 deletions src/main/java/net/sf/jabref/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
*/
public class EntryEditor extends JPanel implements VetoableChangeListener, EntryContainer {

private static final long serialVersionUID = 1L;

// A reference to the entry this object works on.
private BibtexEntry entry;

Expand Down Expand Up @@ -189,7 +191,6 @@ public EntryEditor(JabRefFrame frame_, BasePanel panel_, BibtexEntry entry_) {

helpAction = new HelpAction(frame.helpDiag, GUIGlobals.entryEditorHelp, "Help");
closeAction = new CloseAction();
CopyKeyAction copyKeyAction = new CopyKeyAction();
generateKeyAction = new GenerateKeyAction(frame);
storeFieldAction = new StoreFieldAction();
writeXmp = new WriteXMPEntryEditorAction(panel_, this);
Expand Down Expand Up @@ -449,7 +450,7 @@ public JComponent getExtra(String string, final FieldEditor ed) {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) // double click
{
String date = EasyDateFormat.easyDateFormat();
String date = new EasyDateFormat().getCurrentDate();
ed.setText(date);
}
}
Expand Down Expand Up @@ -1057,6 +1058,8 @@ public void setMovingToDifferentEntry() {

private class TypeButton extends JButton {

private static final long serialVersionUID = 1L;

public TypeButton(String type) {
super(GUIGlobals.getImage("edit"));
setToolTipText(Globals.lang("Change entry type"));
Expand All @@ -1078,6 +1081,8 @@ public void actionPerformed(ActionEvent e) {

private class TypeLabel extends JLabel {

private static final long serialVersionUID = 1L;

public TypeLabel(String type) {
super(type);
setUI(new VerticalLabelUI(false));
Expand Down Expand Up @@ -1179,6 +1184,8 @@ public void run() {

class DeleteAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public DeleteAction() {
super(Globals.lang("Delete"), GUIGlobals.getImage("delete"));
putValue(Action.SHORT_DESCRIPTION, Globals.lang("Delete entry"));
Expand All @@ -1203,6 +1210,8 @@ public void actionPerformed(ActionEvent e) {

class CloseAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public CloseAction() {
super(Globals.lang("Close window"), GUIGlobals.getImage("close"));
putValue(Action.SHORT_DESCRIPTION, Globals.lang("Close window"));
Expand All @@ -1223,6 +1232,8 @@ public void actionPerformed(ActionEvent e) {

class CopyKeyAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public CopyKeyAction() {
super("Copy BibTeX key to clipboard");
putValue(Action.SHORT_DESCRIPTION, "Copy BibTeX key to clipboard (Ctrl-K)");
Expand All @@ -1242,6 +1253,8 @@ public void actionPerformed(ActionEvent e) {

public class StoreFieldAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public StoreFieldAction() {
super("Store field value");
putValue(Action.SHORT_DESCRIPTION, "Store field value");
Expand Down Expand Up @@ -1409,6 +1422,8 @@ public void run() {

class SwitchLeftAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public SwitchLeftAction() {
super("Switch to the panel to the left");
}
Expand All @@ -1425,6 +1440,8 @@ public void actionPerformed(ActionEvent e) {

class SwitchRightAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public SwitchRightAction() {
super("Switch to the panel to the right");
}
Expand All @@ -1441,6 +1458,8 @@ public void actionPerformed(ActionEvent e) {

class NextEntryAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public NextEntryAction() {
super(Globals.lang("Next entry"), GUIGlobals.getImage("down"));

Expand Down Expand Up @@ -1471,6 +1490,8 @@ public void actionPerformed(ActionEvent e) {

class PrevEntryAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public PrevEntryAction() {
super(Globals.lang("Previous entry"), GUIGlobals.getImage("up"));

Expand Down Expand Up @@ -1502,6 +1523,8 @@ public void actionPerformed(ActionEvent e) {

class GenerateKeyAction extends AbstractAction {

private static final long serialVersionUID = 1L;

final JabRefFrame parent;

BibtexEntry selectedEntry;
Expand Down Expand Up @@ -1572,6 +1595,8 @@ else if (Globals.prefs.getBoolean("warnBeforeOverwritingKey")) {

class UndoAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public UndoAction() {
super("Undo", GUIGlobals.getImage("undo"));
putValue(Action.SHORT_DESCRIPTION, "Undo");
Expand All @@ -1588,6 +1613,8 @@ public void actionPerformed(ActionEvent e) {

class RedoAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public RedoAction() {
super("Undo", GUIGlobals.getImage("redo"));
putValue(Action.SHORT_DESCRIPTION, "Redo");
Expand All @@ -1604,6 +1631,8 @@ public void actionPerformed(ActionEvent e) {

class SaveDatabaseAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public SaveDatabaseAction() {
super("Save database");
}
Expand Down Expand Up @@ -1656,6 +1685,8 @@ public void mouseClicked(MouseEvent evt) {

class ChangeTypeAction extends AbstractAction {

private static final long serialVersionUID = 1L;

final BibtexEntryType type;

final BasePanel panel;
Expand Down Expand Up @@ -1710,6 +1741,8 @@ private void warnEmptyBibtexkey() {

private class AutoLinkAction extends AbstractAction {

private static final long serialVersionUID = 1L;

public AutoLinkAction() {
putValue(Action.SMALL_ICON, GUIGlobals.getImage("autoGroup"));
putValue(Action.SHORT_DESCRIPTION, Globals.lang("Automatically set file links for this entry") + " (Alt-F)");
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/net/sf/jabref/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,11 @@ public void writeMetaData(Writer out) throws IOException {
for (String key : metaData.keySet()) {
StringBuffer sb = new StringBuffer();
Vector<String> orderedData = metaData.get(key);
if (orderedData.size() >= 0) {
sb.append("@comment{").append(GUIGlobals.META_FLAG).append(key).append(":");
for (int j = 0; j < orderedData.size(); j++) {
sb.append(StringUtil.quote(orderedData.elementAt(j), ";", '\\')).append(";");
}
sb.append("}");
sb.append("@comment{").append(GUIGlobals.META_FLAG).append(key).append(":");
for (int j = 0; j < orderedData.size(); j++) {
sb.append(StringUtil.quote(orderedData.elementAt(j), ";", '\\')).append(";");
}
sb.append("}");
wrapStringBuffer(sb, Globals.METADATA_LINE_LENGTH);
sb.append(Globals.NEWLINE);
sb.append(Globals.NEWLINE);
Expand Down
Loading