Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated preview entries #1606

Merged
merged 3 commits into from
Jul 25, 2016
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
20 changes: 3 additions & 17 deletions src/main/java/net/sf/jabref/gui/openoffice/StyleSelectDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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();

}
Expand Down Expand Up @@ -372,19 +371,6 @@ private Optional<OOBibStyle> 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<OOBibStyle> {

@Override
Expand Down
55 changes: 4 additions & 51 deletions src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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() {
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/net/sf/jabref/logic/util/TestEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.sf.jabref.logic.util;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure that it should life in logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I merged it. We can discuss moving the class somewhere else somewhere else. ;)


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;
}
}