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

#2772 issue fixed #3552

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 7 additions & 6 deletions src/main/java/org/jabref/logic/exporter/ExportFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jabref.logic.layout.Layout;
import org.jabref.logic.layout.LayoutFormatterPreferences;
import org.jabref.logic.layout.LayoutHelper;
import org.jabref.logic.util.FileExtensions;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;

Expand All @@ -38,7 +39,7 @@ public class ExportFormat implements IExportFormat {
private String consoleName;
private String lfFileName;
private String directory;
private String extension;
private FileExtensions extension;
private Charset encoding; // If this value is set, it will be used to override
// the default encoding for the getCurrentBasePanel.
private LayoutFormatterPreferences layoutPreferences;
Expand All @@ -56,7 +57,7 @@ public class ExportFormat implements IExportFormat {
* @param directory Directory in which to find the layout file.
* @param extension Should contain the . (for instance .txt).
*/
public ExportFormat(String displayName, String consoleName, String lfFileName, String directory, String extension) {
public ExportFormat(String displayName, String consoleName, String lfFileName, String directory, FileExtensions extension) {
this.displayName = displayName;
this.consoleName = consoleName;
this.lfFileName = lfFileName;
Expand All @@ -76,8 +77,8 @@ public ExportFormat(String displayName, String consoleName, String lfFileName, S
* @param layoutPreferences Preferences for layout
* @param savePreferences Preferences for saving
*/
public ExportFormat(String displayName, String consoleName, String lfFileName, String directory, String extension,
LayoutFormatterPreferences layoutPreferences, SavePreferences savePreferences) {
public ExportFormat(String displayName, String consoleName, String lfFileName, String directory,
FileExtensions extension, LayoutFormatterPreferences layoutPreferences, SavePreferences savePreferences) {
this(displayName, consoleName, lfFileName, directory, extension);
this.layoutPreferences = layoutPreferences;
this.savePreferences = savePreferences;
Expand Down Expand Up @@ -131,7 +132,7 @@ public void setEncoding(Charset encoding) {
* @see IExportFormat#getExtension()
*/
@Override
public String getExtension() {
public FileExtensions getExtension() {
return extension;
}

Expand Down Expand Up @@ -239,7 +240,7 @@ public void performExport(final BibDatabaseContext databaseContext, final String
Layout defLayout;
LayoutHelper layoutHelper;
try (Reader reader = getReader(lfFileName + ".layout")) {
layoutHelper = new LayoutHelper(reader,layoutPreferences);
layoutHelper = new LayoutHelper(reader, layoutPreferences);
defLayout = layoutHelper.getLayoutFromText();
}
if (defLayout != null) {
Expand Down
47 changes: 16 additions & 31 deletions src/main/java/org/jabref/logic/exporter/ExportFormats.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.jabref.logic.l10n.Localization;
import org.jabref.logic.layout.LayoutFormatterPreferences;
import org.jabref.logic.util.FileExtensions;

public class ExportFormats {

Expand All @@ -24,38 +25,23 @@ public static void initAllExports(Map<String, ExportFormat> customFormats,
ExportFormats.EXPORT_FORMATS.clear();

// Initialize Build-In Export Formats
ExportFormats
.putFormat(new ExportFormat("HTML", "html", "html", null, ".html", layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat(Localization.lang("Simple HTML"), "simplehtml", "simplehtml", null,
".html", layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat("DocBook 4.4", "docbook", "docbook", null, ".xml", layoutPreferences,
savePreferences));
ExportFormats.putFormat(new ExportFormat("DIN 1505", "din1505", "din1505winword", "din1505", ".rtf",
layoutPreferences, savePreferences));
ExportFormats.putFormat(
new ExportFormat("BibO RDF", "bibordf", "bibordf", null, ".rdf", layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat(Localization.lang("HTML table"), "tablerefs", "tablerefs", "tablerefs",
".html", layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat(Localization.lang("HTML list"), "listrefs", "listrefs", "listrefs",
".html", layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat(Localization.lang("HTML table (with Abstract & BibTeX)"),
"tablerefsabsbib", "tablerefsabsbib", "tablerefsabsbib", ".html", layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat("Harvard RTF", "harvard", "harvard", "harvard", ".rtf",
layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat("ISO 690 RTF", "iso690rtf", "iso690RTF", "iso690rtf", ".rtf",
layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat("ISO 690", "iso690txt", "iso690", "iso690txt", ".txt",
layoutPreferences, savePreferences));
ExportFormats.putFormat(new ExportFormat("Endnote", "endnote", "EndNote", "endnote", ".txt", layoutPreferences,
savePreferences));
ExportFormats.putFormat(new ExportFormat("OpenOffice/LibreOffice CSV", "oocsv", "openoffice-csv", "openoffice",
".csv", layoutPreferences, savePreferences));
ExportFormat ef = new ExportFormat("RIS", "ris", "ris", "ris", ".ris", layoutPreferences, savePreferences);
putFormat(new ExportFormat("HTML", "html", "html", null, FileExtensions.HTML, layoutPreferences, savePreferences));
putFormat(new ExportFormat(Localization.lang("Simple HTML"), "simplehtml", "simplehtml", null, FileExtensions.HTML, layoutPreferences, savePreferences));
putFormat(new ExportFormat("DocBook 4.4", "docbook", "docbook", "", FileExtensions.XML, layoutPreferences, savePreferences));
putFormat(new ExportFormat("DIN 1505", "din1505", "din1505winword", "din1505", FileExtensions.RTF, layoutPreferences, savePreferences));
putFormat(new ExportFormat("BibO RDF", "bibordf", "bibordf", null, FileExtensions.RDF, layoutPreferences, savePreferences));
putFormat(new ExportFormat(Localization.lang("HTML table"), "tablerefs", "tablerefs", "tablerefs", FileExtensions.HTML, layoutPreferences, savePreferences));
putFormat(new ExportFormat(Localization.lang("HTML list"), "listrefs", "listrefs", "listrefs", FileExtensions.HTML, layoutPreferences, savePreferences));
putFormat(new ExportFormat(Localization.lang("HTML table (with Abstract & BibTeX)"), "tablerefsabsbib", "tablerefsabsbib", "tablerefsabsbib", FileExtensions.HTML, layoutPreferences, savePreferences));
putFormat(new ExportFormat("Harvard RTF", "harvard", "harvard", "harvard", FileExtensions.RTF, layoutPreferences, savePreferences));
putFormat(new ExportFormat("ISO 690 RTF", "iso690rtf", "iso690RTF", "iso690rtf", FileExtensions.RTF, layoutPreferences, savePreferences));
putFormat(new ExportFormat("ISO 690", "iso690txt", "iso690", "iso690txt", FileExtensions.TXT, layoutPreferences, savePreferences));
putFormat(new ExportFormat("Endnote", "endnote", "EndNote", "endnote", FileExtensions.TXT, layoutPreferences, savePreferences));
putFormat(new ExportFormat("OpenOffice/LibreOffice CSV", "oocsv", "openoffice-csv", "openoffice", FileExtensions.CSV, layoutPreferences, savePreferences));
ExportFormat ef = new ExportFormat("RIS", "ris", "ris", "ris", FileExtensions.RIS, layoutPreferences, savePreferences);
ef.setEncoding(StandardCharsets.UTF_8);
ExportFormats.putFormat(ef);
ExportFormats.putFormat(
new ExportFormat("MIS Quarterly", "misq", "misq", "misq", ".rtf", layoutPreferences, savePreferences));

putFormat(new ExportFormat("MIS Quarterly", "misq", "misq", "misq", FileExtensions.RTF, layoutPreferences, savePreferences));
ExportFormats.putFormat(new BibTeXMLExportFormat());
ExportFormats.putFormat(new OpenOfficeDocumentCreator());
ExportFormats.putFormat(new OpenDocumentSpreadsheetCreator());
Expand Down Expand Up @@ -120,5 +106,4 @@ public static IExportFormat getExportFormat(String consoleName) {
private static void putFormat(IExportFormat format) {
ExportFormats.EXPORT_FORMATS.put(format.getConsoleName(), format);
}

}
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/logic/exporter/IExportFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.nio.charset.Charset;
import java.util.List;

import org.jabref.logic.util.FileExtensions;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;

Expand All @@ -19,7 +20,7 @@ public interface IExportFormat {
*/
String getDisplayName();

String getExtension();
FileExtensions getExtension();

/**
* Perform the export.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.jabref.logic.util.FileExtensions;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
Expand All @@ -43,7 +44,7 @@ public class OpenOfficeDocumentCreator extends ExportFormat {
* Creates a new instance of OpenOfficeDocumentCreator
*/
public OpenOfficeDocumentCreator() {
super("OpenOffice/LibreOffice Calc", "oocalc", null, null, ".sxc");
super("OpenOffice/LibreOffice Calc", "oocalc", null, null, FileExtensions.CSV);
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/logic/util/FileExtensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public enum FileExtensions {
CLASS(Localization.lang("%0 file", "CLASS"), "class"),
JAR(Localization.lang("%0 file", "JAR"), "jar"),
XML(Localization.lang("%0 file", "XML"), "xml"),
ZIP(Localization.lang("%0 file", "ZIP"), "zip");
ZIP(Localization.lang("%0 file", "ZIP"), "zip"),
HTML(Localization.lang("%0 file", "HTML"), "html"),
RTF(Localization.lang("%0 file", "RTF"), "rtf"),
CSV(Localization.lang("%0 file", "CSV"), "csv"),
RDF(Localization.lang("%0 file", "RDF"), "rdf");

private final String[] extension;
private final String description;
Expand Down