From 144c03c8140737e5c8cac86b6f9156c71ac2bda7 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Wed, 23 Mar 2016 00:13:19 +0100 Subject: [PATCH] Minor code inspection --- .../jabref/gui/entryeditor/EntryEditor.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java index 8544f24e140..dd55624997d 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java @@ -32,6 +32,7 @@ import java.beans.PropertyChangeEvent; import java.beans.VetoableChangeListener; import java.io.IOException; +import java.io.StringReader; import java.io.StringWriter; import java.util.*; import java.util.stream.Collectors; @@ -729,8 +730,7 @@ public synchronized void switchTo(BibEntry switchEntry) { } private boolean storeSource() { - // Store edited bibtex code. - BibtexParser bibtexParser = new BibtexParser(new java.io.StringReader(source.getText())); + BibtexParser bibtexParser = new BibtexParser(new StringReader(source.getText())); try { ParserResult parserResult = bibtexParser.parse(); @@ -750,7 +750,7 @@ private boolean storeSource() { } NamedCompound compound = new NamedCompound(Localization.lang("source edit")); - BibEntry newEntry = database.getEntries().iterator().next(); + BibEntry newEntry = database.getEntries().get(0); String newKey = newEntry.getCiteKey(); boolean anyChanged = false; boolean changedType = false; @@ -787,8 +787,7 @@ private boolean storeSource() { // See if the user has changed the entry type: if (newEntry.getType() != entry.getType()) { - compound.addEdit(new UndoableChangeType(entry, - entry.getType(), newEntry.getType())); + compound.addEdit(new UndoableChangeType(entry, entry.getType(), newEntry.getType())); entry.setType(newEntry.getType()); anyChanged = true; changedType = true; @@ -810,13 +809,11 @@ private boolean storeSource() { } lastSourceStringAccepted = source.getText(); - if (changedType) { - panel.updateEntryEditorIfShowing(); - } else { - updateAllFields(); - lastSourceAccepted = true; - updateSource = true; - } + // Update UI + // TODO: we need to repaint if fields that are not displayed have been added + panel.updateEntryEditorIfShowing(); + lastSourceAccepted = true; + updateSource = true; // TODO: does updating work properly after source stored? panel.markBaseChanged();