diff --git a/build.gradle b/build.gradle index 180808e1ffe5..956b4989233a 100644 --- a/build.gradle +++ b/build.gradle @@ -120,11 +120,6 @@ dependencies { compile 'org.xmlunit:xmlunit-core:2.3.0' compile 'org.xmlunit:xmlunit-matchers:2.3.0' - // need to use snapshots as the stable version is from 2013 and doesn't support v1.0.1 CitationStyles - compile 'org.citationstyles:styles:1.0.1-SNAPSHOT' - compile 'org.citationstyles:locales:1.0.1-SNAPSHOT' - compile 'de.undercouch:citeproc-java:1.0.1' - compile 'com.github.lgooddatepicker:LGoodDatePicker:8.2.2' testCompile 'junit:junit:4.12' diff --git a/external-libraries.txt b/external-libraries.txt index 4d969fa02dac..c13f110ecc6e 100644 --- a/external-libraries.txt +++ b/external-libraries.txt @@ -156,19 +156,4 @@ Project: Spin URL: http://spin.sourceforge.net/ License: LGPL-2.1+ -Id: org.citationstyles.styles -Project: CSL Styles -URL: https://github.com/citation-style-language/styles -Licence: Creative Commons Attribution-ShareAlike 3.0 Unported license - -Id: org.citationstyles.locales -Project: CSL Locales -URL: https://github.com/citation-style-language/locales -Licence: CC-BY-SA-3.0 - -Id: de.undercouch.citeproc-java -Project: Citeproc-Java -URL: http://michel-kraemer.github.io/citeproc-java/ -Licence: Apache-2.0 - The last entry has to end with an empty line. Otherwise the entry is not present in About.html. diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index d600fb0f212b..eba7d757de1a 100644 --- a/src/main/java/net/sf/jabref/gui/BasePanel.java +++ b/src/main/java/net/sf/jabref/gui/BasePanel.java @@ -98,7 +98,6 @@ import net.sf.jabref.logic.autocompleter.AutoCompleterFactory; import net.sf.jabref.logic.autocompleter.ContentAutoCompleters; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; -import net.sf.jabref.logic.citationstyle.CitationStyleCache; import net.sf.jabref.logic.exporter.BibtexDatabaseWriter; import net.sf.jabref.logic.exporter.FileSaveSession; import net.sf.jabref.logic.exporter.SaveException; @@ -151,8 +150,6 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe private final BibDatabaseContext bibDatabaseContext; private final MainTableDataModel tableModel; - private final CitationStyleCache citationStyleCache; - // To contain instantiated entry editors. This is to save time // As most enums, this must not be null private BasePanelMode mode = BasePanelMode.SHOWING_NOTHING; @@ -219,8 +216,6 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) { this.frame = frame; this.tableModel = new MainTableDataModel(getBibDatabaseContext()); - citationStyleCache = new CitationStyleCache(bibDatabaseContext); - setupMainPanel(); setupActions(); @@ -2382,10 +2377,6 @@ public void setCurrentSearchQuery(SearchQuery currentSearchQuery) { this.currentSearchQuery = currentSearchQuery; } - public CitationStyleCache getCitationStyleCache() { - return citationStyleCache; - } - public PreviewPanel getPreviewPanel() { if (selectionListener == null) { // only occurs if this is called while instantiating this BasePanel diff --git a/src/main/java/net/sf/jabref/gui/PreviewPanel.java b/src/main/java/net/sf/jabref/gui/PreviewPanel.java index 0238f1861b72..97501e09be42 100644 --- a/src/main/java/net/sf/jabref/gui/PreviewPanel.java +++ b/src/main/java/net/sf/jabref/gui/PreviewPanel.java @@ -31,8 +31,6 @@ import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.gui.fieldeditors.PreviewPanelTransferHandler; import net.sf.jabref.gui.keyboard.KeyBinding; -import net.sf.jabref.gui.worker.CitationStyleWorker; -import net.sf.jabref.logic.citationstyle.CitationStyle; import net.sf.jabref.logic.exporter.ExportFormats; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.layout.Layout; @@ -79,7 +77,6 @@ public class PreviewPanel extends JPanel implements SearchQueryHighlightListener private final CopyPreviewAction copyPreviewAction = new CopyPreviewAction(); private Optional highlightPattern = Optional.empty(); - private Optional citationStyleWorker = Optional.empty(); /** * @param databaseContext @@ -202,21 +199,10 @@ public void updateLayout() { PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences(); String style = previewPreferences.getPreviewCycle().get(previewPreferences.getPreviewCyclePosition()); - if (CitationStyle.isCitationStyleFile(style)) { - if (basePanel.isPresent()) { - layout = Optional.empty(); - CitationStyle citationStyle = CitationStyle.createCitationStyleFromFile(style); - if (citationStyle != null) { - basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle); - basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle())); - } - } - } else { updatePreviewLayout(previewPreferences.getPreviewStyle()); if (basePanel.isPresent()) { basePanel.get().output(Localization.lang("Preview style changed to: %0", Localization.lang("Preview"))); } - } update(); } @@ -264,11 +250,6 @@ public BibEntry getEntry() { public void update() { ExportFormats.entryNumber = 1; // Set entry number in case that is included in the preview layout. - if (citationStyleWorker.isPresent()){ - citationStyleWorker.get().cancel(true); - citationStyleWorker = Optional.empty(); - } - if (layout.isPresent()){ StringBuilder sb = new StringBuilder(); bibEntry.ifPresent(entry -> sb.append(layout.get() @@ -276,10 +257,6 @@ public void update() { setPreviewLabel(sb.toString()); markHighlights(); } - else if (basePanel.isPresent()){ - citationStyleWorker = Optional.of(new CitationStyleWorker(this, previewPane)); - citationStyleWorker.get().execute(); - } } @@ -316,18 +293,12 @@ public Optional getHighlightPattern() { /** * this fixes the Layout, the user cannot change it anymore. Useful for testing the styles in the settings - * @param parameter should be either a {@link String} (for the old PreviewStyle) or a {@link CitationStyle}. */ - public PreviewPanel setFixedLayout(Object parameter) { + public PreviewPanel setFixedLayout(String parameter) { this.fixedLayout = true; if (parameter instanceof String) { updatePreviewLayout((String) parameter); - } else if (parameter instanceof CitationStyle) { - layout = Optional.empty(); - if (basePanel.isPresent()){ - basePanel.get().getCitationStyleCache().setCitationStyle((CitationStyle) parameter); - } } else { LOGGER.error("unknown style type"); } 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 38bdaf180582..3cbfc9978e4d 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java @@ -22,7 +22,6 @@ import net.sf.jabref.JabRefGUI; import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.PreviewPanel; -import net.sf.jabref.logic.citationstyle.CitationStyle; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.TestEntry; import net.sf.jabref.preferences.PreviewPreferences; @@ -38,8 +37,6 @@ public class PreviewPrefsTab extends JPanel implements PrefsTab { private static final Log LOGGER = LogFactory.getLog(PreviewPrefsTab.class); - private SwingWorker, Void> discoverCitationStyleWorker; - private final DefaultListModel availableModel = new DefaultListModel<>(); private final DefaultListModel chosenModel = new DefaultListModel<>(); @@ -171,16 +168,12 @@ public void setValues() { chosenModel.clear(); boolean isPreviewChosen = false; for (String style : previewPreferences.getPreviewCycle()) { - if (CitationStyle.isCitationStyleFile(style)) { - chosenModel.addElement(CitationStyle.createCitationStyleFromFile(style)); - } else { if (isPreviewChosen) { LOGGER.error("Preview is already in the list, something went wrong"); continue; } isPreviewChosen = true; chosenModel.addElement(Localization.lang("Preview")); - } } availableModel.clear(); @@ -193,35 +186,6 @@ public void setValues() { btnUp.setEnabled(!chosen.isSelectionEmpty()); btnDown.setEnabled(!chosen.isSelectionEmpty()); - if (discoverCitationStyleWorker != null){ - discoverCitationStyleWorker.cancel(true); - } - - discoverCitationStyleWorker = new SwingWorker, Void>() { - @Override - protected List doInBackground() throws Exception { - return CitationStyle.discoverCitationStyles(); - } - - @Override - public void done(){ - if (this.isCancelled()) { - return; - } - try { - get().stream() - .filter(style -> !previewPreferences.getPreviewCycle().contains(style.getFilepath())) - .sorted((style0, style1) -> style0.getTitle().compareTo(style1.getTitle())) - .forEach(availableModel::addElement); - - btnRight.setEnabled(!availableModel.isEmpty()); - } catch (InterruptedException | ExecutionException e) { - LOGGER.error("something went wrong while adding the discovered CitationStyles to the list "); - } - } - }; - discoverCitationStyleWorker.execute(); - layout.setText(Globals.prefs.getPreviewPreferences().getPreviewStyle().replace("__NEWLINE__", "\n")); } @@ -231,11 +195,7 @@ public void storeSettings() { Enumeration elements = chosenModel.elements(); while (elements.hasMoreElements()) { Object obj = elements.nextElement(); - if (obj instanceof CitationStyle) { - styles.add(((CitationStyle) obj).getFilepath()); - } else if (obj instanceof String) { - styles.add("Preview"); - } + styles.add("Preview"); } PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences() .getBuilder() diff --git a/src/main/java/net/sf/jabref/gui/worker/CitationStyleWorker.java b/src/main/java/net/sf/jabref/gui/worker/CitationStyleWorker.java deleted file mode 100644 index 1cd1489d7972..000000000000 --- a/src/main/java/net/sf/jabref/gui/worker/CitationStyleWorker.java +++ /dev/null @@ -1,77 +0,0 @@ -package net.sf.jabref.gui.worker; - -import java.util.Objects; -import java.util.Optional; -import java.util.concurrent.ExecutionException; - -import javax.swing.JEditorPane; -import javax.swing.SwingWorker; - -import net.sf.jabref.gui.BasePanel; -import net.sf.jabref.gui.PreviewPanel; -import net.sf.jabref.logic.citationstyle.CitationStyle; -import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.model.entry.BibEntry; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -/** - * Generates a citation and updates the linked preview panel - */ -public class CitationStyleWorker extends SwingWorker { - - private static final Log LOGGER = LogFactory.getLog(CitationStyleWorker.class); - - private final PreviewPanel previewPanel; - - - public CitationStyleWorker(PreviewPanel previewPanel, JEditorPane previewPane) { - this.previewPanel = Objects.requireNonNull(previewPanel); - Objects.requireNonNull(previewPane); - - Optional basePanel = previewPanel.getBasePanel(); - if (basePanel.isPresent()){ - CitationStyle citationStyle = basePanel.get().getCitationStyleCache().getCitationStyle(); - previewPane.setText("" + Localization.lang("Processing %0", Localization.lang("Citation Style")) + - ": " + citationStyle.getTitle() + " ..." + ""); - } - previewPane.revalidate(); - } - - @Override - protected String doInBackground() throws Exception { - Optional basePanel = previewPanel.getBasePanel(); - BibEntry entry = previewPanel.getEntry(); - - String fieldText = ""; - if ((entry != null) && basePanel.isPresent()) { - fieldText = basePanel.get().getCitationStyleCache().getCitationFor(entry); - } - return fieldText; - } - - @Override - public void done() { - if (this.isCancelled()) { - return; - } - String text; - Boolean success = true; - try { - text = this.get(); - } catch (InterruptedException | ExecutionException e) { - LOGGER.error("Error while generating citation style", e); - text = Localization.lang("Error while generating citation style"); - success = false; - } - - previewPanel.setPreviewLabel(text); - - if (success) { - previewPanel.markHighlights(); - } - } - -} diff --git a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyle.java b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyle.java deleted file mode 100644 index f4988b46d803..000000000000 --- a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyle.java +++ /dev/null @@ -1,178 +0,0 @@ -package net.sf.jabref.logic.citationstyle; - -import java.io.IOException; -import java.io.StringReader; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import java.util.Objects; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import net.sf.jabref.logic.util.FileExtensions; - -import de.undercouch.citeproc.helper.CSLUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.CharacterData; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - - -/** - * Representation of a CitationStyle - * Stores its name, the filepath and the style itself - */ -public class CitationStyle { - - public static final String DEFAULT = "/ieee.csl"; - private static final Log LOGGER = LogFactory.getLog(CitationStyle.class); - - private final String filepath; - private final String title; - private final String source; - - - private CitationStyle(final String filename, final String title, final String source) { - this.filepath = Objects.requireNonNull(filename); - this.title = Objects.requireNonNull(title); - this.source = Objects.requireNonNull(source); - } - - /** - * Creates an CitationStyle instance out of the style string - */ - private static CitationStyle createCitationStyleFromSource(final String source, final String filename) { - try { - DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - InputSource is = new InputSource(); - is.setCharacterStream(new StringReader(source)); - - Document doc = db.parse(is); - NodeList nodes = doc.getElementsByTagName("info"); - - NodeList titleNode = ((Element) nodes.item(0)).getElementsByTagName("title"); - String title = ((CharacterData) titleNode.item(0).getFirstChild()).getData(); - - return new CitationStyle(filename, title, source); - } catch (ParserConfigurationException | SAXException | IOException e) { - LOGGER.error("Error while parsing source", e); - } - return null; - } - - /** - * Loads the CitationStyle from the given file - */ - public static CitationStyle createCitationStyleFromFile(final String styleFile) { - if (!isCitationStyleFile(styleFile)) { - LOGGER.error("Can only load style files: "+ styleFile); - return null; - } - - try { - String text; - String internalFile = (styleFile.startsWith("/") ? "" : "/") + styleFile; - URL url = CitationStyle.class.getResource(internalFile); - if (url != null) { - text = CSLUtils.readURLToString(url, StandardCharsets.UTF_8.toString()); - } else { - // if the url is null then the style is located outside the classpath - text = new String(Files.readAllBytes(Paths.get(styleFile)), StandardCharsets.UTF_8); - } - return createCitationStyleFromSource(text, styleFile); - } catch (NoSuchFileException e){ - LOGGER.error("Could not find file: "+ styleFile, e); - } catch (IOException e) { - LOGGER.error("Error reading source file", e); - } - return null; - } - - public static CitationStyle getDefault(){ - return createCitationStyleFromFile(DEFAULT); - } - - /** - * THIS ONLY WORKS WHEN JabRef IS STARTED AS AN APPLICATION (JAR) - * - * Reads all available CitationStyle in the Jar - */ - public static List discoverCitationStyles() { - try { - final List citationStyles = new ArrayList<>(); - String path = CitationStyle.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); - - try (JarFile file = new JarFile(path)) { - Enumeration entries = file.entries(); - while (entries.hasMoreElements()) { - String filename = entries.nextElement().getName(); - if (!filename.startsWith("dependent") && filename.endsWith("csl")) { - CitationStyle citationStyle = CitationStyle.createCitationStyleFromFile(filename); - if (citationStyle != null) { - citationStyles.add(citationStyle); - } - } - } - } - return citationStyles; - } catch (IOException | URISyntaxException ex) { - LOGGER.error("something went wrong while searching available CitationStyles. " + - "Are you running directly from source code?", ex); - } - return Collections.emptyList(); - } - - /** - * Checks if the given style file is a CitationStyle - */ - public static boolean isCitationStyleFile(String styleFile){ - return Arrays.stream(FileExtensions.CITATION_STYLE.getExtensions()).anyMatch(styleFile::endsWith); - } - - public String getTitle() { - return title; - } - - public String getSource() { - return source; - } - - public String getFilepath() { - return filepath; - } - - @Override - public String toString() { - return title; - } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - if (other == null || getClass() != other.getClass()) { - return false; - } - - CitationStyle that = (CitationStyle) other; - return source != null ? source.equals(that.source) : that.source == null; - } - -} diff --git a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleCache.java b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleCache.java deleted file mode 100644 index aef0b05e98a8..000000000000 --- a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleCache.java +++ /dev/null @@ -1,77 +0,0 @@ -package net.sf.jabref.logic.citationstyle; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import net.sf.jabref.model.database.BibDatabaseContext; -import net.sf.jabref.model.database.event.EntryRemovedEvent; -import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.model.entry.event.EntryChangedEvent; - -import com.google.common.eventbus.Subscribe; - - -/** - * Caches the generated Citations for quicker access - * {@link CitationStyleGenerator} generates the citaiton with JavaScript which may take some time - */ -public class CitationStyleCache { - - private CitationStyle citationStyle = CitationStyle.getDefault(); - private Map citationStylesCache = new HashMap<>(); - - - public CitationStyleCache(BibDatabaseContext bibDatabaseContext) { - this(bibDatabaseContext, CitationStyle.getDefault()); - } - - public CitationStyleCache(BibDatabaseContext bibDatabaseContext, CitationStyle citationStyle) { - this.setCitationStyle(citationStyle); - bibDatabaseContext.getDatabase().registerListener(new BibDatabaseEntryListener()); - } - - /** - * returns the citation for the given BibEntry and the set CitationStyle - */ - public String getCitationFor(BibEntry entry) { - String citation = citationStylesCache.get(entry); - if (citation == null) { - citation = CitationStyleGenerator.generateCitation(entry, this.citationStyle); - citationStylesCache.put(entry, citation); - } - return citation; - } - - public void setCitationStyle(CitationStyle citationStyle) { - Objects.requireNonNull(citationStyle); - if (!this.citationStyle.equals(citationStyle)){ - this.citationStyle = citationStyle; - this.citationStylesCache.clear(); - } - } - - public CitationStyle getCitationStyle() { - return citationStyle; - } - - - private class BibDatabaseEntryListener { - /** - * removes the outdated citation of the changed entry - */ - @Subscribe - public void listen(EntryChangedEvent entryChangedEvent) { - citationStylesCache.remove(entryChangedEvent.getBibEntry()); - } - - /** - * removes the citation of the removed entry as it's not needed anymore - */ - @Subscribe - public void listen(EntryRemovedEvent entryRemovedEvent) { - citationStylesCache.remove(entryRemovedEvent.getBibEntry()); - } - } - -} diff --git a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleGenerator.java b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleGenerator.java deleted file mode 100644 index fed37f29cea8..000000000000 --- a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleGenerator.java +++ /dev/null @@ -1,80 +0,0 @@ -package net.sf.jabref.logic.citationstyle; - -import java.io.IOException; -import java.util.Map; - -import net.sf.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter; -import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.model.entry.BibEntry; - -import de.undercouch.citeproc.CSL; -import de.undercouch.citeproc.bibtex.BibTeXConverter; -import de.undercouch.citeproc.csl.CSLItemData; -import de.undercouch.citeproc.output.Bibliography; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jbibtex.BibTeXEntry; -import org.jbibtex.DigitStringValue; -import org.jbibtex.Key; -import org.jbibtex.TokenMgrException; - - -/** - * WARNING: the citation is generated with JavaScript which may take some time, better call it in outside the main Thread - */ -public class CitationStyleGenerator { - - private static final Log LOGGER = LogFactory.getLog(CitationStyleGenerator.class); - private static final UnicodeToLatexFormatter UNICODE_TO_LATEX_FORMATTER = new UnicodeToLatexFormatter(); - private static final BibTeXConverter BIBTEX_CONVERTER = new BibTeXConverter(); - - /** - * Generates a Citation based on the given entry and style - * WARNING: the citation is generated with JavaScript which may take some time, better call it in outside the main Thread - */ - protected static String generateCitation(BibEntry entry, CitationStyle style) { - return generateCitation(entry, style.getSource(), CitationStyleOutputFormat.HTML); - } - - /** - * Generates a Citation based on the given entry and style - * WARNING: the citation is generated with JavaScript which may take some time, better call it in outside the main Thread - */ - protected static String generateCitation(BibEntry entry, String style) { - return generateCitation(entry, style, CitationStyleOutputFormat.HTML); - } - - /** - * Generates a Citation based on the given entry, style, and output format - * WARNING: the citation is generated with JavaScript which may take some time, better call it in outside the main Thread - */ - protected static String generateCitation(BibEntry entry, String style, CitationStyleOutputFormat outputFormat) { - try { - String citeKey = entry.getCiteKeyOptional().orElse(""); - BibTeXEntry bibTeXEntry = new BibTeXEntry(new Key(entry.getType()), new Key(citeKey)); - for (Map.Entry field : entry.getFieldMap().entrySet()) { - String value = UNICODE_TO_LATEX_FORMATTER.format(field.getValue()); - bibTeXEntry.addField(new Key(field.getKey()), new DigitStringValue(value)); - } - - CSLItemData cslItemData = BIBTEX_CONVERTER.toItemData(bibTeXEntry); - Bibliography bibliography = CSL.makeAdhocBibliography(style, outputFormat.getFormat(), cslItemData); - return bibliography.getEntries()[0]; - - } catch (IOException | ArrayIndexOutOfBoundsException e) { - LOGGER.error("Could not generate BibEntry citation", e); - return Localization.lang("Cannot generate preview based on selected citation style."); - } catch (TokenMgrException e) { - LOGGER.error("Bad character inside BibEntry", e); - // sadly one cannot easily retrieve the bad char from the TokenMgrError - return new StringBuilder() - .append(Localization.lang("Cannot generate preview based on selected citation style.")) - .append(outputFormat == CitationStyleOutputFormat.HTML ? "
" : "\n") - .append(Localization.lang("Bad character inside entry")) - .append(outputFormat == CitationStyleOutputFormat.HTML ? "
" : "\n") - .append(e.getLocalizedMessage()) - .toString(); - } - } - -} diff --git a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleOutputFormat.java b/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleOutputFormat.java deleted file mode 100644 index dc6bf3119f02..000000000000 --- a/src/main/java/net/sf/jabref/logic/citationstyle/CitationStyleOutputFormat.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.sf.jabref.logic.citationstyle; - - -public enum CitationStyleOutputFormat { - - HTML("html"), - TEXT("text"), - ASCII_DOC("asciidoc"), - FO("fo"), - RTF("rtf"); - - private final String format; - - CitationStyleOutputFormat(String format) { - this.format = format; - } - - public String getFormat() { - return format; - } - - @Override - public String toString() { - return format; - } - -} diff --git a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java index 6ac6633b13f7..91c8ccbef5fd 100644 --- a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java @@ -42,7 +42,6 @@ import net.sf.jabref.logic.bibtex.FieldContentParserPreferences; import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; -import net.sf.jabref.logic.citationstyle.CitationStyle; import net.sf.jabref.logic.cleanup.CleanupPreferences; import net.sf.jabref.logic.cleanup.CleanupPreset; import net.sf.jabref.logic.cleanup.Cleanups; @@ -799,7 +798,7 @@ private JabRefPreferences() { defaults.put(VERSION_IGNORED_UPDATE, ""); // preview - defaults.put(CYCLE_PREVIEW, "Preview;" + CitationStyle.DEFAULT); + defaults.put(CYCLE_PREVIEW, "Preview"); defaults.put(CYCLE_PREVIEW_POS, 0); defaults.put(PREVIEW_PANEL_HEIGHT, 200); defaults.put(PREVIEW_ENABLED, Boolean.TRUE); diff --git a/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleGeneratorTest.java b/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleGeneratorTest.java deleted file mode 100644 index 03f580009a72..000000000000 --- a/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleGeneratorTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package net.sf.jabref.logic.citationstyle; - -import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.model.entry.FieldName; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class CitationStyleGeneratorTest { - - @Test - public void testIgnoreNewLine() { - BibEntry entry = new BibEntry(); - entry.setField(FieldName.AUTHOR, "Last, First and\nDoe, Jane"); - - // if the default citation style changes this has to be modified - String expected = "
\n" + - "
[1]
F. Last and J. Doe, .
\n" + - "
\n"; - String citation = CitationStyleGenerator.generateCitation(entry, CitationStyle.getDefault()); - assertEquals(expected, citation); - } - - @Test - public void testIgnoreCarriageReturnNewLine() { - BibEntry entry = new BibEntry(); - entry.setField(FieldName.AUTHOR, "Last, First and\r\nDoe, Jane"); - - // if the default citation style changes this has to be modified - String expected = "
\n" + - "
[1]
F. Last and J. Doe, .
\n" + - "
\n"; - String citation = CitationStyleGenerator.generateCitation(entry, CitationStyle.getDefault()); - assertEquals(expected, citation); - } - - @Test - public void testMissingCitationStyle() { - String expected = Localization.lang("Cannot generate preview based on selected citation style."); - String citation = CitationStyleGenerator.generateCitation(new BibEntry(), "faulty citation style"); - assertEquals(expected, citation); - } - -} diff --git a/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleTest.java b/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleTest.java deleted file mode 100644 index 1e673494a1ab..000000000000 --- a/src/test/java/net/sf/jabref/logic/citationstyle/CitationStyleTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.sf.jabref.logic.citationstyle; - -import net.sf.jabref.logic.util.TestEntry; - -import org.junit.Assert; -import org.junit.Test; - - -public class CitationStyleTest { - - @Test - public void getDefault() throws Exception { - Assert.assertNotNull(CitationStyle.getDefault()); - } - - @Test - public void testDefaultCitation() { - String citation = CitationStyleGenerator.generateCitation(TestEntry.getTestEntry(), CitationStyle.getDefault()); - - // if the default citation style changes this has to be modified - String expected = "
\n" + - "
[1]
" + - "B. Smith, B. Jones, and J. Williams, “Title of the test entry,” " + - "BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016.
\n" + - "
\n"; - - Assert.assertEquals(citation, expected); - } - -}