Skip to content

Commit

Permalink
Renamed and added more constants
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed Jul 20, 2016
1 parent d997457 commit bf50d38
Show file tree
Hide file tree
Showing 115 changed files with 752 additions and 747 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/BibDatabaseContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,6 @@ private String getFileDirectoryPath(String directoryName) {
}

public List<String> getFileDirectory() {
return getFileDirectory(FieldName.FILE_FIELD);
return getFileDirectory(FieldName.FILE);
}
}
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class MetaData implements Iterable<String> {
private static final String DATABASE_TYPE = "databaseType";

private static final String GROUPSTREE = "groupstree";
private static final String FILE_DIRECTORY = FieldName.FILE_FIELD + Globals.DIR_SUFFIX;
private static final String FILE_DIRECTORY = FieldName.FILE + Globals.DIR_SUFFIX;
public static final String SELECTOR_META_PREFIX = "selector_";
private static final String PROTECTED_FLAG_META = "protectedFlag";

Expand Down Expand Up @@ -128,10 +128,10 @@ public Optional<SaveOrderConfig> getSaveOrderConfig() {
*/
public void initializeNewDatabase() {
metaData.put(SELECTOR_META_PREFIX + "keywords", new Vector<>());
metaData.put(SELECTOR_META_PREFIX + FieldName.AUTHOR_FIELD, new Vector<>());
metaData.put(SELECTOR_META_PREFIX + FieldName.AUTHOR, new Vector<>());
metaData.put(SELECTOR_META_PREFIX + "journal", new Vector<>());
metaData.put(SELECTOR_META_PREFIX + "publisher", new Vector<>());
metaData.put(SELECTOR_META_PREFIX + FieldName.REVIEW_FIELD, new Vector<>());
metaData.put(SELECTOR_META_PREFIX + FieldName.REVIEW, new Vector<>());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/collab/ChangeScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

public class ChangeScanner implements Runnable {

private static final String[] SORT_BY = new String[] {FieldName.YEAR_FIELD, FieldName.AUTHOR_FIELD, "title"};
private static final String[] SORT_BY = new String[] {FieldName.YEAR, FieldName.AUTHOR, FieldName.TITLE};

private final File f;

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/external/AttachFileAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public void action() {
editor.setVisible(true, true);
if (editor.okPressed()) {
FileListTableModel model = new FileListTableModel();
entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(model::setContent);
entry.getFieldOptional(FieldName.FILE).ifPresent(model::setContent);
model.addEntry(model.getRowCount(), flEntry);
String newVal = model.getStringRepresentation();

UndoableFieldChange ce = new UndoableFieldChange(entry, FieldName.FILE_FIELD,
entry.getFieldOptional(FieldName.FILE_FIELD).orElse(null), newVal);
entry.setField(FieldName.FILE_FIELD, newVal);
UndoableFieldChange ce = new UndoableFieldChange(entry, FieldName.FILE,
entry.getFieldOptional(FieldName.FILE).orElse(null), newVal);
entry.setField(FieldName.FILE, newVal);
panel.getUndoManager().addEdit(ce);
panel.markBaseChanged();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/external/AutoSetLinks.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void run() {
// Iterate over the entries:
for (Entry<BibEntry, List<File>> entryFilePair : result.entrySet()) {
FileListTableModel tableModel;
Optional<String> oldVal = entryFilePair.getKey().getFieldOptional(FieldName.FILE_FIELD);
Optional<String> oldVal = entryFilePair.getKey().getFieldOptional(FieldName.FILE);
if (singleTableModel == null) {
tableModel = new FileListTableModel();
oldVal.ifPresent(tableModel::setContent);
Expand Down Expand Up @@ -153,12 +153,12 @@ public void run() {
if (ce != null) {
// store undo information
UndoableFieldChange change = new UndoableFieldChange(entryFilePair.getKey(),
FieldName.FILE_FIELD, oldVal.orElse(null), newVal);
FieldName.FILE, oldVal.orElse(null), newVal);
ce.addEdit(change);
}
// hack: if table model is given, do NOT modify entry
if (singleTableModel == null) {
entryFilePair.getKey().setField(FieldName.FILE_FIELD, newVal);
entryFilePair.getKey().setField(FieldName.FILE, newVal);
}
if (changedEntries != null) {
changedEntries.add(entryFilePair.getKey());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/external/DroppedFileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileTy
private void doLink(BibEntry entry, ExternalFileType fileType, String filename,
boolean avoidDuplicate, NamedCompound edits) {

Optional<String> oldValue = entry.getFieldOptional(FieldName.FILE_FIELD);
Optional<String> oldValue = entry.getFieldOptional(FieldName.FILE);
FileListTableModel tm = new FileListTableModel();
oldValue.ifPresent(tm::setContent);

Expand Down Expand Up @@ -442,8 +442,8 @@ private void doLink(BibEntry entry, ExternalFileType fileType, String filename,

tm.addEntry(tm.getRowCount(), new FileListEntry("", filename, fileType));
String newValue = tm.getStringRepresentation();
UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE_FIELD, oldValue.orElse(null), newValue);
entry.setField(FieldName.FILE_FIELD, newValue);
UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE, oldValue.orElse(null), newValue);
entry.setField(FieldName.FILE, newValue);

if (edits == null) {
panel.getUndoManager().addEdit(edit);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/external/FindFullTextAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public void update() {
try {
def.download(result.get(), file -> {
FileListTableModel tm = new FileListTableModel();
entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent);
entry.getFieldOptional(FieldName.FILE).ifPresent(tm::setContent);
tm.addEntry(tm.getRowCount(), file);
String newValue = tm.getStringRepresentation();
UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE_FIELD,
entry.getFieldOptional(FieldName.FILE_FIELD).orElse(null), newValue);
entry.setField(FieldName.FILE_FIELD, newValue);
UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE,
entry.getFieldOptional(FieldName.FILE).orElse(null), newValue);
entry.setField(FieldName.FILE, newValue);
basePanel.getUndoManager().addEdit(edit);
basePanel.markBaseChanged();
});
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/sf/jabref/external/SynchronizeFileField.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void run() {
boolean removeAllBroken = false;
mainLoop: for (BibEntry aSel : sel) {
panel.frame().setProgressBarValue(progress++);
final Optional<String> old = aSel.getFieldOptional(FieldName.FILE_FIELD);
final Optional<String> old = aSel.getFieldOptional(FieldName.FILE);
// Check if a extension is set:
if (old.isPresent() && !(old.get().isEmpty())) {
FileListTableModel tableModel = new FileListTableModel();
Expand Down Expand Up @@ -255,11 +255,11 @@ public void run() {
// The table has been modified. Store the change:
String toSet = tableModel.getStringRepresentation();
if (toSet.isEmpty()) {
ce.addEdit(new UndoableFieldChange(aSel, FieldName.FILE_FIELD, old.orElse(null), null));
aSel.clearField(FieldName.FILE_FIELD);
ce.addEdit(new UndoableFieldChange(aSel, FieldName.FILE, old.orElse(null), null));
aSel.clearField(FieldName.FILE);
} else {
ce.addEdit(new UndoableFieldChange(aSel, FieldName.FILE_FIELD, old.orElse(null), toSet));
aSel.setField(FieldName.FILE_FIELD, toSet);
ce.addEdit(new UndoableFieldChange(aSel, FieldName.FILE, old.orElse(null), toSet));
aSel.setField(FieldName.FILE, toSet);
}
changedEntries.add(aSel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class TransferableFileLinkSelection implements Transferable {

public TransferableFileLinkSelection(BasePanel panel, List<BibEntry> selection) {
FileListTableModel tm = new FileListTableModel();
selection.get(0).getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent);
selection.get(0).getFieldOptional(FieldName.FILE).ifPresent(tm::setContent);
if (tm.getRowCount() > 0) {
// Find the default directory for this field type, if any:
List<String> dirs = panel.getBibDatabaseContext().getFileDirectory();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/external/WriteXMPAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ public void run() {
.ifPresent(files::add));
// Then check the "file" field:
List<String> dirs = panel.getBibDatabaseContext().getFileDirectory();
if (entry.hasField(FieldName.FILE_FIELD)) {
if (entry.hasField(FieldName.FILE)) {
FileListTableModel tm = new FileListTableModel();
entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent);
entry.getFieldOptional(FieldName.FILE).ifPresent(tm::setContent);
for (int j = 0; j < tm.getRowCount(); j++) {
FileListEntry flEntry = tm.getEntry(j);
if ((flEntry.type.isPresent()) && "pdf".equalsIgnoreCase(flEntry.type.get().getName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public void actionPerformed(ActionEvent actionEvent) {

// Then check the "file" field:
List<String> dirs = panel.getBibDatabaseContext().getFileDirectory();
if (entry.hasField(FieldName.FILE_FIELD)) {
if (entry.hasField(FieldName.FILE)) {
FileListTableModel tm = new FileListTableModel();
entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent);
entry.getFieldOptional(FieldName.FILE).ifPresent(tm::setContent);
for (int j = 0; j < tm.getRowCount(); j++) {
FileListEntry flEntry = tm.getEntry(j);
if ((flEntry.type.isPresent()) && "pdf".equalsIgnoreCase(flEntry.type.get().getName())) {
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1035,13 +1035,13 @@ private void openExternalFile() {
}

final BibEntry entry = bes.get(0);
if (!entry.hasField(FieldName.FILE_FIELD)) {
if (!entry.hasField(FieldName.FILE)) {
// no bibtex field
new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen();
return;
}
FileListTableModel tableModel = new FileListTableModel();
entry.getFieldOptional(FieldName.FILE_FIELD).ifPresent(tableModel::setContent);
entry.getFieldOptional(FieldName.FILE).ifPresent(tableModel::setContent);
if (tableModel.getRowCount() == 0) {
// content in bibtex field is not readable
new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen();
Expand Down Expand Up @@ -2064,11 +2064,11 @@ private class OpenURLAction implements BaseAction {
public void action() {
final List<BibEntry> bes = mainTable.getSelectedEntries();
if (bes.size() == 1) {
String field = FieldName.DOI_FIELD;
Optional<String> link = bes.get(0).getFieldOptional(FieldName.DOI_FIELD);
if (bes.get(0).hasField(FieldName.URL_FIELD)) {
link = bes.get(0).getFieldOptional(FieldName.URL_FIELD);
field = FieldName.URL_FIELD;
String field = FieldName.DOI;
Optional<String> link = bes.get(0).getFieldOptional(FieldName.DOI);
if (bes.get(0).hasField(FieldName.URL)) {
link = bes.get(0).getFieldOptional(FieldName.URL);
field = FieldName.URL;
}
if (link.isPresent()) {
try {
Expand All @@ -2082,10 +2082,10 @@ public void action() {
// Look for web links in the "file" field as a fallback:
FileListEntry entry = null;
FileListTableModel tm = new FileListTableModel();
bes.get(0).getFieldOptional(FieldName.FILE_FIELD).ifPresent(tm::setContent);
bes.get(0).getFieldOptional(FieldName.FILE).ifPresent(tm::setContent);
for (int i = 0; i < tm.getRowCount(); i++) {
FileListEntry flEntry = tm.getEntry(i);
if (FieldName.URL_FIELD.equalsIgnoreCase(flEntry.type.get().getName())
if (FieldName.URL.equalsIgnoreCase(flEntry.type.get().getName())
|| PS_FIELD.equalsIgnoreCase(flEntry.type.get().getName())
|| PDF_FIELD.equalsIgnoreCase(flEntry.type.get().getName())) {
entry = flEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ private void setupFieldSelector() {
}
if (contents.isEmpty()) {
// if nothing was added, put the default fields (as described in the help)
fieldListModel.addElement(FieldName.AUTHOR_FIELD);
fieldListModel.addElement(FieldName.AUTHOR);
fieldListModel.addElement("journal");
fieldListModel.addElement("keywords");
fieldListModel.addElement("publisher");
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/gui/GUIGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static void init() {

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

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

label = new JLabel(IconTheme.JabRefIcon.DOI.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " DOI " + Localization.lang("web link"));
GUIGlobals.TABLE_ICONS.put(FieldName.DOI_FIELD, label);
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);

label = new JLabel(IconTheme.JabRefIcon.FOLDER.getSmallIcon());
label.setToolTipText(Localization.lang("Open folder"));
GUIGlobals.TABLE_ICONS.put(FieldName.FOLDER_FIELD, label);
GUIGlobals.TABLE_ICONS.put(FieldName.FOLDER, label);

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

for (ExternalFileType fileType : ExternalFileTypes.getInstance().getExternalFileTypeSelection()) {
label = new JLabel(fileType.getIcon());
Expand Down
Loading

0 comments on commit bf50d38

Please sign in to comment.