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

Added more fields and fixed some issues #1617

Merged
merged 1 commit into from
Jul 23, 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
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/external/WriteXMPAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void run() {
List<File> files = new ArrayList<>();

// First check the (legacy) "pdf" field:
entry.getFieldOptional("pdf").ifPresent(pdf ->
entry.getFieldOptional(FieldName.PDF).ifPresent(pdf ->
FileUtil.expandFilename(pdf, panel.getBibDatabaseContext().getFileDirectory("pdf"))
.ifPresent(files::add));
// Then check the "file" field:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void actionPerformed(ActionEvent actionEvent) {
List<File> files = new ArrayList<>();

// First check the (legacy) "pdf" field:
entry.getFieldOptional("pdf").ifPresent(pdf -> FileUtil
entry.getFieldOptional(FieldName.PDF).ifPresent(pdf -> FileUtil
.expandFilename(pdf, panel.getBibDatabaseContext().getFileDirectory("pdf")).ifPresent(files::add));

// Then check the "file" field:
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2056,10 +2056,6 @@ public void action() {

private class OpenURLAction implements BaseAction {

private static final String PS_FIELD = "ps";
private static final String PDF_FIELD = "pdf";


@Override
public void action() {
final List<BibEntry> bes = mainTable.getSelectedEntries();
Expand All @@ -2086,8 +2082,8 @@ public void action() {
for (int i = 0; i < tm.getRowCount(); i++) {
FileListEntry flEntry = tm.getEntry(i);
if (FieldName.URL.equalsIgnoreCase(flEntry.type.get().getName())
|| PS_FIELD.equalsIgnoreCase(flEntry.type.get().getName())
|| PDF_FIELD.equalsIgnoreCase(flEntry.type.get().getName())) {
|| FieldName.PS.equalsIgnoreCase(flEntry.type.get().getName())
|| FieldName.PDF.equalsIgnoreCase(flEntry.type.get().getName())) {
entry = flEntry;
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import net.sf.jabref.model.EntryTypes;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.entry.EntryType;
import net.sf.jabref.model.entry.FieldName;
import net.sf.jabref.preferences.JabRefPreferences;

import com.jgoodies.forms.builder.ButtonBarBuilder;
Expand Down Expand Up @@ -997,7 +998,7 @@ public void mousePressed(MouseEvent e) {
try {
JabRefDesktop.openExternalViewer(
JabRefGUI.getMainFrame().getCurrentBasePanel().getBibDatabaseContext(),
fnw.file.getAbsolutePath(), "pdf");
fnw.file.getAbsolutePath(), FieldName.PDF);
} catch (IOException e1) {
LOGGER.info("Error opening file", e1);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/gui/GUIGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static void init() {
JLabel label;
label = new JLabel(IconTheme.JabRefIcon.PDF_FILE.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " PDF");
GUIGlobals.TABLE_ICONS.put("pdf", label);
GUIGlobals.TABLE_ICONS.put(FieldName.PDF, label);

label = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " URL");
Expand All @@ -109,15 +109,15 @@ public static void init() {

label = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " ArXiv URL");
GUIGlobals.TABLE_ICONS.put("eprint", label);
GUIGlobals.TABLE_ICONS.put(FieldName.EPRINT, label);

label = new JLabel(IconTheme.JabRefIcon.DOI.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " DOI " + Localization.lang("web link"));
GUIGlobals.TABLE_ICONS.put(FieldName.DOI, label);

label = new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " PS");
GUIGlobals.TABLE_ICONS.put("ps", label);
GUIGlobals.TABLE_ICONS.put(FieldName.PS, label);

label = new JLabel(IconTheme.JabRefIcon.FOLDER.getSmallIcon());
label.setToolTipText(Localization.lang("Open folder"));
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/sf/jabref/gui/desktop/JabRefDesktop.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void openExternalViewer(BibDatabaseContext databaseContext, String
String initialFieldName) throws IOException {
String link = initialLink;
String fieldName = initialFieldName;
if ("ps".equals(fieldName) || "pdf".equals(fieldName)) {
if (FieldName.PS.equals(fieldName) || FieldName.PDF.equals(fieldName)) {
// Find the default directory for this field type:
List<String> dir = databaseContext.getFileDirectory(fieldName);

Expand All @@ -90,10 +90,10 @@ public static void openExternalViewer(BibDatabaseContext databaseContext, String
String[] split = file.get().getName().split("\\.");
if (split.length >= 2) {
if ("pdf".equalsIgnoreCase(split[split.length - 1])) {
fieldName = "pdf";
fieldName = FieldName.PDF;
} else if ("ps".equalsIgnoreCase(split[split.length - 1])
|| ((split.length >= 3) && "ps".equalsIgnoreCase(split[split.length - 2]))) {
fieldName = "ps";
fieldName = FieldName.PS;
}
}
} else if (FieldName.DOI.equals(fieldName)) {
Expand All @@ -103,7 +103,7 @@ public static void openExternalViewer(BibDatabaseContext databaseContext, String
}
// should be opened in browser
fieldName = FieldName.URL;
} else if ("eprint".equals(fieldName)) {
} else if (FieldName.EPRINT.equals(fieldName)) {
fieldName = FieldName.URL;

// Check to see if link field already contains a well formated URL
Expand All @@ -121,15 +121,15 @@ public static void openExternalViewer(BibDatabaseContext databaseContext, String
// In BasePanel.java, the exception is catched and a text output to the frame
// throw e;
}
} else if ("ps".equals(fieldName)) {
} else if (FieldName.PS.equals(fieldName)) {
try {
NATIVE_DESKTOP.openFile(link, "ps");
NATIVE_DESKTOP.openFile(link, FieldName.PS);
} catch (IOException e) {
LOGGER.error("An error occured on the command: " + link, e);
}
} else if ("pdf".equals(fieldName)) {
} else if (FieldName.PDF.equals(fieldName)) {
try {
NATIVE_DESKTOP.openFile(link, "pdf");
NATIVE_DESKTOP.openFile(link, FieldName.PDF);
} catch (IOException e) {
LOGGER.error("An error occured on the command: " + link, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MainTableFormat implements TableFormat<BibEntry> {
// These values are also used to put a heading into the table; see getColumnName(int)
private static final List<String> URL_FIRST = Arrays.asList(FieldName.URL, FieldName.DOI);
private static final List<String> DOI_FIRST = Arrays.asList(FieldName.DOI, FieldName.URL);
private static final List<String> ARXIV = Collections.singletonList("eprint");
private static final List<String> ARXIV = Collections.singletonList(FieldName.EPRINT);

private final BibDatabase database;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/importer/OAI2Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void endElement(String uri, String localName, String qualifiedName) throw
if ("error".equals(qualifiedName)) {
throw new RuntimeException(content);
} else if ("id".equals(qualifiedName)) {
entry.setField("eprint", content);
entry.setField(FieldName.EPRINT, content);
} else if ("keyname".equals(qualifiedName)) {
keyname = content;
} else if ("forenames".equals(qualifiedName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
} else if ("UR".equals(entry.getKey()) || "AT".equals(entry.getKey())) {
String s = entry.getValue().toString().trim();
hm.put(s.startsWith("http://") || s.startsWith("ftp://") ? FieldName.URL
: "pdf", entry.getValue().toString());
: FieldName.PDF, entry.getValue().toString());
} else if ("C1".equals(entry.getKey())) {
comments.add("Custom1: "
+ entry.getValue());
Expand All @@ -180,7 +180,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
comments.add("Custom6: "
+ entry.getValue());
} else if ("DE".equals(entry.getKey())) {
hm.put("annote", entry
hm.put(FieldName.ANNOTE, entry
.getValue().toString());
} else if ("CA".equals(entry.getKey())) {
comments.add("Categories: "
Expand All @@ -190,7 +190,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
+ entry.getValue());
} else if ("SE".equals(entry.getKey()))
{
hm.put("chapter", entry
hm.put(FieldName.CHAPTER, entry
.getValue().toString());
//else if (entry.getKey().equals("AC"))
// hm.put("",entry.getValue().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public ParserResult importEntries(String text) {
e.setField(FieldName.NUMBER, parser.getElementText());
} else if (FieldName.DOI.equals(ln)
|| FieldName.INSTITUTION.equals(ln)
|| "location".equals(ln)
|| FieldName.LOCATION.equals(ln)
|| FieldName.NUMBER.equals(ln)
|| FieldName.NOTE.equals(ln)
|| FieldName.TITLE.equals(ln)
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/logic/cleanup/CleanupWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.sf.jabref.logic.journals.JournalAbbreviationLoader;
import net.sf.jabref.model.FieldChange;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.FieldName;
import net.sf.jabref.preferences.JabRefPreferences;

public class CleanupWorker {
Expand Down Expand Up @@ -62,7 +63,7 @@ private List<CleanupJob> determineCleanupActions(CleanupPreset preset) {
List<CleanupJob> jobs = new ArrayList<>();

if (preset.isCleanUpUpgradeExternalLinks()) {
jobs.add(new UpgradePdfPsToFileCleanup(Arrays.asList("pdf", "ps")));
jobs.add(new UpgradePdfPsToFileCleanup(Arrays.asList(FieldName.PDF, FieldName.PS)));
}
if (preset.isCleanUpDOI()) {
jobs.add(new DoiCleanup());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public Document getDOMrepresentation() {
addTableCell(result, row, getField(e, FieldName.NOTE));
addTableCell(result, row, getField(e, FieldName.URL));
addTableCell(result, row, getField(e, FieldName.BOOKTITLE));
addTableCell(result, row, getField(e, "chapter"));
addTableCell(result, row, getField(e, FieldName.CHAPTER));
addTableCell(result, row, getField(e, FieldName.EDITION));
addTableCell(result, row, getField(e, FieldName.SERIES));
addTableCell(result, row, getField(e, FieldName.EDITOR));//new AuthorLastFirst().format(getField(e, FieldName.EDITOR_FIELD)));
Expand All @@ -180,7 +180,7 @@ public Document getDOMrepresentation() {
addTableCell(result, row, getField(e, FieldName.INSTITUTION));
addTableCell(result, row, getField(e, FieldName.ORGANIZATION));
addTableCell(result, row, getField(e, FieldName.SCHOOL));
addTableCell(result, row, getField(e, "annote"));
addTableCell(result, row, getField(e, FieldName.ANNOTE));
addTableCell(result, row, getField(e, "assignee"));
addTableCell(result, row, getField(e, "day"));
addTableCell(result, row, getField(e, "dayfiled"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ public Document getDOMrepresentation() {
addTableCell(result, row, new GetOpenOfficeType().format(e.getType()));
addTableCell(result, row, getField(e, FieldName.ADDRESS));
addTableCell(result, row, getField(e, "assignee"));
addTableCell(result, row, getField(e, "annote"));
addTableCell(result, row, getField(e, FieldName.ANNOTE));
addTableCell(result, row, getField(e, FieldName.AUTHOR));//new AuthorLastFirst().format(getField(e, FieldName.AUTHOR_FIELD)));
addTableCell(result, row, getField(e, FieldName.BOOKTITLE));
addTableCell(result, row, getField(e, "chapter"));
addTableCell(result, row, getField(e, FieldName.CHAPTER));
addTableCell(result, row, getField(e, "day"));
addTableCell(result, row, getField(e, "dayfiled"));
addTableCell(result, row, getField(e, FieldName.EDITION));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MSBibMapping {
bibtexToMSBib.put(FieldName.BOOKTITLE, "BookTitle");
//bibtexToMSBib.put(FieldName.BOOKTITLE, "ConferenceName");
//bibtexToMSBib.put(FieldName.PAGES, "Pages");
bibtexToMSBib.put("chapter", "ChapterNumber");
bibtexToMSBib.put(FieldName.CHAPTER, "ChapterNumber");
bibtexToMSBib.put(FieldName.JOURNAL, "JournalName");
bibtexToMSBib.put(FieldName.NUMBER, "Issue");
bibtexToMSBib.put(FieldName.SCHOOL, "Department");
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/logic/xmp/XMPUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public static Optional<BibEntry> getBibtexEntryFromDublinCore(XMPSchemaDublinCor
*/
List<String> publishers = dcSchema.getPublishers();
if ((publishers != null) && !publishers.isEmpty()) {
entry.setField("publishers", String.join(" and ", publishers));
entry.setField(FieldName.PUBLISHER, String.join(" and ", publishers));
}

/**
Expand Down Expand Up @@ -667,7 +667,7 @@ private static void writeToDCSchema(XMPSchemaDublinCore dcSchema,
*
* Bibtex-Fields used: author
*/
if ("author".equals(field)) {
if (FieldName.AUTHOR.equals(field)) {
String authors = resolvedEntry.getField(field);
AuthorList list = AuthorList.parse(authors);

Expand Down Expand Up @@ -1009,7 +1009,7 @@ private static void writeDocumentInformation(PDDocument document,

if (useXmpPrivacyFilter && filters.contains(field)) {
// erase field instead of adding it
if ("author".equals(field)) {
if (FieldName.AUTHOR.equals(field)) {
di.setAuthor(null);
} else if (FieldName.TITLE.equals(field)) {
di.setTitle(null);
Expand All @@ -1023,7 +1023,7 @@ private static void writeDocumentInformation(PDDocument document,
continue;
}

if ("author".equals(field)) {
if (FieldName.AUTHOR.equals(field)) {
di.setAuthor(resolvedEntry.getField(FieldName.AUTHOR));
} else if (FieldName.TITLE.equals(field)) {
di.setTitle(resolvedEntry.getField(FieldName.TITLE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*/
public class FileLinksUpgradeWarning implements PostOpenAction {

private static final String[] FIELDS_TO_LOOK_FOR = new String[] {"pdf", "ps", "evastar_pdf"};
private static final String[] FIELDS_TO_LOOK_FOR = new String[] {FieldName.PDF, FieldName.PS, "evastar_pdf"};

private boolean offerChangeSettings;

Expand Down
Loading