Skip to content

Commit

Permalink
Remove support of CSL styles
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Dec 8, 2016
1 parent 69b18f9 commit 5edc49b
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 617 deletions.
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 0 additions & 15 deletions external-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
9 changes: 0 additions & 9 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -219,8 +216,6 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) {
this.frame = frame;
this.tableModel = new MainTableDataModel(getBibDatabaseContext());

citationStyleCache = new CitationStyleCache(bibDatabaseContext);

setupMainPanel();

setupActions();
Expand Down Expand Up @@ -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
Expand Down
31 changes: 1 addition & 30 deletions src/main/java/net/sf/jabref/gui/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,7 +77,6 @@ public class PreviewPanel extends JPanel implements SearchQueryHighlightListener
private final CopyPreviewAction copyPreviewAction = new CopyPreviewAction();

private Optional<Pattern> highlightPattern = Optional.empty();
private Optional<CitationStyleWorker> citationStyleWorker = Optional.empty();

/**
* @param databaseContext
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -264,22 +250,13 @@ 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()
.doLayout(entry, databaseContext.map(BibDatabaseContext::getDatabase).orElse(null))));
setPreviewLabel(sb.toString());
markHighlights();
}
else if (basePanel.isPresent()){
citationStyleWorker = Optional.of(new CitationStyleWorker(this, previewPane));
citationStyleWorker.get().execute();
}

}

Expand Down Expand Up @@ -316,18 +293,12 @@ public Optional<Pattern> 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");
}
Expand Down
42 changes: 1 addition & 41 deletions src/main/java/net/sf/jabref/gui/preftabs/PreviewPrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,8 +37,6 @@ public class PreviewPrefsTab extends JPanel implements PrefsTab {

private static final Log LOGGER = LogFactory.getLog(PreviewPrefsTab.class);

private SwingWorker<List<CitationStyle>, Void> discoverCitationStyleWorker;

private final DefaultListModel<Object> availableModel = new DefaultListModel<>();
private final DefaultListModel<Object> chosenModel = new DefaultListModel<>();

Expand Down Expand Up @@ -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();
Expand All @@ -193,35 +186,6 @@ public void setValues() {
btnUp.setEnabled(!chosen.isSelectionEmpty());
btnDown.setEnabled(!chosen.isSelectionEmpty());

if (discoverCitationStyleWorker != null){
discoverCitationStyleWorker.cancel(true);
}

discoverCitationStyleWorker = new SwingWorker<List<CitationStyle>, Void>() {
@Override
protected List<CitationStyle> 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"));
}

Expand All @@ -231,11 +195,7 @@ public void storeSettings() {
Enumeration<Object> 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()
Expand Down
77 changes: 0 additions & 77 deletions src/main/java/net/sf/jabref/gui/worker/CitationStyleWorker.java

This file was deleted.

Loading

0 comments on commit 5edc49b

Please sign in to comment.