diff --git a/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java b/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java index 870013fa67b..27379646260 100644 --- a/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java +++ b/src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java @@ -63,9 +63,8 @@ import net.sf.jabref.logic.openoffice.OOBibStyle; import net.sf.jabref.logic.openoffice.OpenOfficePreferences; import net.sf.jabref.logic.openoffice.StyleLoader; +import net.sf.jabref.logic.util.TestEntry; import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.model.entry.FieldName; -import net.sf.jabref.model.entry.IdGenerator; import net.sf.jabref.preferences.JabRefPreferences; import ca.odell.glazedlists.BasicEventList; @@ -109,7 +108,7 @@ class StyleSelectDialog { private final Rectangle toRect = new Rectangle(0, 0, 1, 1); private final JButton ok = new JButton(Localization.lang("OK")); private final JButton cancel = new JButton(Localization.lang("Cancel")); - private final BibEntry prevEntry = new BibEntry(IdGenerator.next()); + private final BibEntry prevEntry; private boolean okPressed; private final StyleLoader loader; @@ -121,7 +120,7 @@ public StyleSelectDialog(JabRefFrame frame, OpenOfficePreferences preferences, S this.frame = Objects.requireNonNull(frame); this.preferences = Objects.requireNonNull(preferences); this.loader = Objects.requireNonNull(loader); - setupPrevEntry(); + prevEntry = TestEntry.getTestEntry(); init(); } @@ -372,19 +371,6 @@ private Optional getSelectedStyle() { return Optional.empty(); } - private void setupPrevEntry() { - prevEntry.setField(FieldName.AUTHOR, "Smith, Bill and Jones, Bob and Williams, Jeff"); - prevEntry.setField(FieldName.EDITOR, "Taylor, Phil"); - prevEntry.setField(FieldName.TITLE, "Title of the test entry for reference styles"); - prevEntry.setField(FieldName.VOLUME, "34"); - prevEntry.setField(FieldName.YEAR, "2008"); - prevEntry.setField(FieldName.JOURNAL, "BibTeX journal"); - prevEntry.setField(FieldName.PUBLISHER, "JabRef publishing"); - prevEntry.setField(FieldName.ADDRESS, "Trondheim"); - prevEntry.setField("www", "https://github.com/JabRef"); - } - - static class StyleTableFormat implements TableFormat { @Override diff --git a/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java b/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java index 0cb3e3eeb83..8f9ca1df657 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java @@ -31,9 +31,7 @@ import net.sf.jabref.gui.PreviewPanel; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.model.entry.FieldName; -import net.sf.jabref.model.entry.IdGenerator; +import net.sf.jabref.logic.util.TestEntry; import net.sf.jabref.preferences.JabRefPreferences; import org.apache.commons.logging.Log; @@ -59,8 +57,6 @@ class PreviewPrefsTab extends JPanel implements PrefsTab { private final JPanel secondPanel = new JPanel(); private final JScrollPane secondScrollPane = new JScrollPane(layout2); - private static BibEntry entry; - public PreviewPrefsTab(JabRefPreferences prefs) { this.prefs = prefs; @@ -154,9 +150,8 @@ public PreviewPrefsTab(JabRefPreferences prefs) { }); testButton.addActionListener(e -> { - PreviewPrefsTab.getTestEntry(); try { - PreviewPanel testPanel = new PreviewPanel(null, PreviewPrefsTab.entry, null, layout1.getText()); + PreviewPanel testPanel = new PreviewPanel(null, TestEntry.getTestEntry(), null, layout1.getText()); testPanel.setPreferredSize(new Dimension(800, 350)); JOptionPane.showMessageDialog(null, testPanel, Localization.lang("Preview"), JOptionPane.PLAIN_MESSAGE); } catch (StringIndexOutOfBoundsException ex) { @@ -169,9 +164,9 @@ public PreviewPrefsTab(JabRefPreferences prefs) { }); testButton2.addActionListener(e -> { - PreviewPrefsTab.getTestEntry(); try { - PreviewPanel testPanel = new PreviewPanel(null, PreviewPrefsTab.entry, null, layout2.getText()); + PreviewPanel testPanel = new PreviewPanel(null, TestEntry.getTestEntry(), null, + layout2.getText()); testPanel.setPreferredSize(new Dimension(800, 350)); JOptionPane.showMessageDialog(null, new JScrollPane(testPanel), Localization.lang("Preview"), JOptionPane.PLAIN_MESSAGE); @@ -185,48 +180,6 @@ public PreviewPrefsTab(JabRefPreferences prefs) { }); } - private static BibEntry getTestEntry() { - if (PreviewPrefsTab.entry != null) { - return PreviewPrefsTab.entry; - } - PreviewPrefsTab.entry = new BibEntry(IdGenerator.next(), "article"); - PreviewPrefsTab.entry.setCiteKey("conceicao1997"); - PreviewPrefsTab.entry.setField(FieldName.AUTHOR, - "Luis E. C. Conceic{\\~a}o and Terje van der Meeren and Johan A. J. Verreth and M S. Evjen and D. F. Houlihan and H. J. Fyhn"); - PreviewPrefsTab.entry.setField(FieldName.TITLE, - "Amino acid metabolism and protein turnover in larval turbot (Scophthalmus maximus) fed natural zooplankton or Artemia"); - PreviewPrefsTab.entry.setField(FieldName.YEAR, "1997"); - PreviewPrefsTab.entry.setField(FieldName.JOURNAL, "Marine Biology"); - PreviewPrefsTab.entry.setField(FieldName.MONTH, "January"); - PreviewPrefsTab.entry.setField(FieldName.NUMBER, "2"); - PreviewPrefsTab.entry.setField(FieldName.VOLUME, "123"); - PreviewPrefsTab.entry.setField("pdf", "conceicao1997.pdf"); - PreviewPrefsTab.entry.setField(FieldName.PAGES, "255--265"); - PreviewPrefsTab.entry.setField(FieldName.KEYWORDS, "energetics, artemia, metabolism, amino acid, turbot"); - PreviewPrefsTab.entry.setField(FieldName.URL, "http://ejournals.ebsco.com/direct.asp?ArticleID=TYY4NT82XA9H7R8PFPPV"); - PreviewPrefsTab.entry.setField(FieldName.ABSTRACT, - "Abstract The present paper studied the influence of different food regimes " - + "on the free amino acid (FAA) pool, the rate of protein turnover, the flux of amino acids, and " - + "their relation to growth of larval turbot (Scophthalmus maximus L.) from first feeding until " - + "metamorphosis. The amino acid profile of protein was stable during the larval period although " - + "some small, but significant, differences were found. Turbot larvae had proteins which were rich " - + "in leucine and aspartate, and poor in glutamate, suggesting a high leucine requirement. The " - + "profile of the FAA pool was highly variable and quite different from the amino acid profile in " - + "protein. The proportion of essential FAA decreased with development. High contents of free tyrosine " - + "and phenylalanine were found on Day 3, while free taurine was present at high levels throughout " - + "the experimental period. Larval growth rates were positively correlated with taurine levels, " - + "suggesting a dietary dependency for taurine and/or sulphur amino acids.\n\nReduced growth rates in " - + "Artemia-fed larvae were associated with lower levels of free methionine, indicating that this diet " - + "is deficient in methionine for turbot larvae. Leucine might also be limiting turbot growth as the " - + "different diet organisms had lower levels of this amino acid in the free pool than was found in the " - + "larval protein. A previously presented model was used to describe the flux of amino acids in growing " - + "turbot larvae. The FAA pool was found to be small and variable. It was estimated that the daily dietary " - + "amino acid intake might be up to ten times the larval FAA pool. In addition, protein synthesis and " - + "protein degradation might daily remove and return, respectively, the equivalent of up to 20 and 10 " - + "times the size of the FAA pool. In an early phase (Day 11) high growth rates were associated with a " - + "relatively low protein turnover, while at a later stage (Day 17), a much higher turnover was observed."); - return PreviewPrefsTab.entry; - } @Override public void setValues() { diff --git a/src/main/java/net/sf/jabref/logic/util/TestEntry.java b/src/main/java/net/sf/jabref/logic/util/TestEntry.java new file mode 100644 index 00000000000..3bf8e0cc679 --- /dev/null +++ b/src/main/java/net/sf/jabref/logic/util/TestEntry.java @@ -0,0 +1,30 @@ +package net.sf.jabref.logic.util; + +import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.FieldName; +import net.sf.jabref.model.entry.IdGenerator; + +public class TestEntry { + + public static BibEntry getTestEntry() { + + BibEntry entry = new BibEntry(IdGenerator.next(), "article"); + entry.setCiteKey("Smith2016"); + entry.setField(FieldName.AUTHOR, "Smith, Bill and Jones, Bob and Williams, Jeff"); + entry.setField(FieldName.EDITOR, "Taylor, Phil"); + entry.setField(FieldName.TITLE, "Title of the test entry"); + entry.setField(FieldName.NUMBER, "3"); + entry.setField(FieldName.VOLUME, "34"); + entry.setField(FieldName.YEAR, "2016"); + entry.setField(FieldName.PAGES, "45--67"); + entry.setField(FieldName.MONTH, "July"); + entry.setField(FieldName.FILE, ":testentry.pdf:PDF"); + entry.setField(FieldName.JOURNAL, "BibTeX Journal"); + entry.setField(FieldName.PUBLISHER, "JabRef Publishing"); + entry.setField(FieldName.ADDRESS, "Trondheim"); + entry.setField(FieldName.URL, "https://github.com/JabRef"); + entry.setField(FieldName.ABSTRACT, + "This entry describes a test scenario which may be useful in JabRef. By providing a test entry it is possible to see how certain things will look in this graphical bib-file mananger."); + return entry; + } +}