Skip to content

Commit

Permalink
Use getter instead of field
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharrer committed Jan 26, 2016
1 parent 38aa3c0 commit 8fa19de
Show file tree
Hide file tree
Showing 45 changed files with 101 additions and 99 deletions.
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 @@ -82,7 +82,7 @@ public ChangeScanner(JabRefFrame frame, BasePanel bp, File file) { //, BibDataba
this.panel = bp;
this.frame = frame;
this.inMem = bp.database();
this.mdInMem = bp.loadedDatabase.getMetaData();
this.mdInMem = bp.getLoadedDatabase().getMetaData();
this.f = file;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/collab/GroupChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public GroupChange(GroupTreeNode changedGroups, GroupTreeNode tmpGroupRoot) {

@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {
final GroupTreeNode root = panel.loadedDatabase.getMetaData().getGroups();
final GroupTreeNode root = panel.getLoadedDatabase().getMetaData().getGroups();
final UndoableModifySubtree undo = new UndoableModifySubtree(
panel.getGroupSelector(), panel.loadedDatabase.getMetaData().getGroups(),
panel.getGroupSelector(), panel.getLoadedDatabase().getMetaData().getGroups(),
root, Localization.lang("Modified groups"));
root.removeAllChildren();
if (changedGroups == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/exporter/AutoSaveManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static boolean autoSave(BasePanel panel) {
File databaseFile = panel.getLoadedDatabase().getDatabaseFile();
File backupFile = AutoSaveManager.getAutoSaveFile(databaseFile);
try {
SaveSession ss = FileActions.saveDatabase(new LoadedDatabase(panel.database(), panel.loadedDatabase.getMetaData()),
SaveSession ss = FileActions.saveDatabase(new LoadedDatabase(panel.database(), panel.getLoadedDatabase().getMetaData()),
backupFile, Globals.prefs, false, false, panel.getEncoding(), true);
ss.commit();
} catch (SaveException e) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/exporter/ExportFormats.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ public void actionPerformed(ActionEvent e) {
// Set the global variable for this database's file directory before exporting,
// so formatters can resolve linked files correctly.
// (This is an ugly hack!)
Globals.prefs.fileDirForDatabase = frame.getCurrentBasePanel().loadedDatabase.getMetaData()
Globals.prefs.fileDirForDatabase = frame.getCurrentBasePanel().getLoadedDatabase().getMetaData()
.getFileDirectory(Globals.FILE_FIELD).toArray(new String[0]);
// Also store the database's file in a global variable:
Globals.prefs.databaseFile = frame.getCurrentBasePanel().loadedDatabase.getDatabaseFile();
Globals.prefs.databaseFile = frame.getCurrentBasePanel().getLoadedDatabase().getDatabaseFile();

// Make sure we remember which filter was used, to set
// the default for next time:
Expand All @@ -228,7 +228,7 @@ public void actionPerformed(ActionEvent e) {
public void run() {
try {
format.performExport(frame.getCurrentBasePanel().database(),
frame.getCurrentBasePanel().loadedDatabase.getMetaData(),
frame.getCurrentBasePanel().getLoadedDatabase().getMetaData(),
finFile.getPath(), frame
.getCurrentBasePanel().getEncoding(), finEntryIDs);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ public void run() {
// Set the global variable for this database's file directory before exporting,
// so formatters can resolve linked files correctly.
// (This is an ugly hack!)
Globals.prefs.fileDirForDatabase = frame.getCurrentBasePanel().loadedDatabase.getMetaData()
Globals.prefs.fileDirForDatabase = frame.getCurrentBasePanel().getLoadedDatabase().getMetaData()
.getFileDirectory(Globals.FILE_FIELD).toArray(new String[0]);
// Also store the database's file in a global variable:
Globals.prefs.databaseFile = frame.getCurrentBasePanel().loadedDatabase.getDatabaseFile();
Globals.prefs.databaseFile = frame.getCurrentBasePanel().getLoadedDatabase().getDatabaseFile();

File tmp = null;
Reader reader = null;
Expand All @@ -115,7 +115,7 @@ public void run() {
}

// Write to file:
format.performExport(database, panel.loadedDatabase.getMetaData(),
format.performExport(database, panel.getLoadedDatabase().getMetaData(),
tmp.getPath(), panel.getEncoding(), entries);
// Read the file and put the contents on the clipboard:
StringBuilder sb = new StringBuilder();
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/net/sf/jabref/exporter/SaveDatabaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void run() {
}
else { // User indicated to store anyway.
// See if the database has the protected flag set:
List<String> pd = panel.loadedDatabase.getMetaData().getData(Globals.PROTECTED_FLAG_META);
List<String> pd = panel.getLoadedDatabase().getMetaData().getData(Globals.PROTECTED_FLAG_META);
boolean databaseProtectionFlag = (pd != null) && Boolean.parseBoolean(pd.get(0));
if (databaseProtectionFlag) {
JOptionPane.showMessageDialog(frame, Localization.lang("Database is protected. Cannot save until external changes have been reviewed."),
Expand Down Expand Up @@ -226,11 +226,11 @@ private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding)
frame.block();
try {
if (selectedOnly) {
session = FileActions.savePartOfDatabase(new LoadedDatabase(panel.database(), panel.loadedDatabase.getMetaData()),
session = FileActions.savePartOfDatabase(new LoadedDatabase(panel.database(), panel.getLoadedDatabase().getMetaData()),
file, Globals.prefs,
panel.getSelectedEntries(), encoding, FileActions.DatabaseSaveType.DEFAULT);
} else {
session = FileActions.saveDatabase(new LoadedDatabase(panel.database(), panel.loadedDatabase.getMetaData()),
session = FileActions.saveDatabase(new LoadedDatabase(panel.database(), panel.getLoadedDatabase().getMetaData()),
file, Globals.prefs, false, false, encoding, false);
}

Expand Down Expand Up @@ -376,13 +376,13 @@ public void saveAs() throws Throwable {
}

if (chosenFile != null) {
File oldFile = panel.loadedDatabase.getDatabaseFile();
panel.loadedDatabase.getMetaData().setFile(f);
File oldFile = panel.getLoadedDatabase().getDatabaseFile();
panel.getLoadedDatabase().getMetaData().setFile(f);
Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, f.getParent());
runCommand();
// If the operation failed, revert the file field and return:
if (!success) {
panel.loadedDatabase.getMetaData().setFile(oldFile);
panel.getLoadedDatabase().getMetaData().setFile(oldFile);
return;
}
// Register so we get notifications about outside changes to the file.
Expand All @@ -391,7 +391,7 @@ public void saveAs() throws Throwable {
} catch (IOException ex) {
LOGGER.error("Problem registering file change notifications", ex);
}
frame.getFileHistory().newFile(panel.loadedDatabase.getDatabaseFile().getPath());
frame.getFileHistory().newFile(panel.getLoadedDatabase().getDatabaseFile().getPath());
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/external/AttachFileAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void action() {
BibEntry entry = panel.getSelectedEntries()[0];
FileListEntry flEntry = new FileListEntry("", "", null);
FileListEntryEditor editor = new FileListEntryEditor(panel.frame(), flEntry, false, true,
panel.loadedDatabase.getMetaData());
panel.getLoadedDatabase().getMetaData());
editor.setVisible(true, true);
if (editor.okPressed()) {
FileListTableModel model = new FileListTableModel();
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/sf/jabref/external/DroppedFileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void handleDroppedfile(String fileName, ExternalFileType fileType, boolea
String destFilename;

if (linkInPlace.isSelected()) {
destFilename = FileUtil.shortenFileName(new File(fileName), panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD)).toString();
destFilename = FileUtil.shortenFileName(new File(fileName), panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD)).toString();
} else {
destFilename = renameCheckBox.isSelected() ? renameToTextBox.getText() : new File(fileName).getName();
if (copyRadioButton.isSelected()) {
Expand Down Expand Up @@ -195,7 +195,7 @@ public void linkPdfToEntry(String fileName, MainTable entryTable, BibEntry entry
String destFilename;

if (linkInPlace.isSelected()) {
destFilename = FileUtil.shortenFileName(new File(fileName), panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD)).toString();
destFilename = FileUtil.shortenFileName(new File(fileName), panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD)).toString();
} else {
destFilename = renameCheckBox.isSelected() ? renameToTextBox.getText() : new File(fileName).getName();
if (copyRadioButton.isSelected()) {
Expand Down Expand Up @@ -225,7 +225,7 @@ public void importXmp(List<BibEntry> xmpEntriesInFile, String fileName) {
String destFilename;

if (linkInPlace.isSelected()) {
destFilename = FileUtil.shortenFileName(new File(fileName), panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD)).toString();
destFilename = FileUtil.shortenFileName(new File(fileName), panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD)).toString();
} else {
if (renameCheckBox.isSelected()) {
destFilename = fileName;
Expand Down Expand Up @@ -312,7 +312,7 @@ private boolean tryXmpImport(String fileName, ExternalFileType fileType, boolean
String destFilename;

if (linkInPlace.isSelected()) {
destFilename = FileUtil.shortenFileName(new File(fileName), panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD)).toString();
destFilename = FileUtil.shortenFileName(new File(fileName), panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD)).toString();
} else {
if (renameCheckBox.isSelected()) {
destFilename = fileName;
Expand Down Expand Up @@ -349,7 +349,7 @@ private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileTy
BibEntry entry, boolean newEntry, final boolean multipleEntries, BibDatabase database) {

String dialogTitle = Localization.lang("Link to file %0", linkFileName);
List<String> dirs = panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
List<String> dirs = panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
int found = -1;
for (int i = 0; i < dirs.size(); i++) {
if (new File(dirs.get(i)).exists()) {
Expand Down Expand Up @@ -451,7 +451,7 @@ private void doLink(BibEntry entry, ExternalFileType fileType, String filename,
// If avoidDuplicate==true, we should check if this file is already linked:
if (avoidDuplicate) {
// For comparison, find the absolute filename:
List<String> dirs = panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
List<String> dirs = panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
String absFilename = !new File(filename).isAbsolute() && (dirs.size() > 0) ?
FileUtil.expandFilename(filename, dirs).getAbsolutePath() : filename;

Expand Down Expand Up @@ -492,7 +492,7 @@ private void doLink(BibEntry entry, ExternalFileType fileType, String filename,
*/
private boolean doMove(String fileName, ExternalFileType fileType, String destFilename,
NamedCompound edits) {
List<String> dirs = panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
List<String> dirs = panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
int found = -1;
for (int i = 0; i < dirs.size(); i++) {
if (new File(dirs.get(i)).exists()) {
Expand Down Expand Up @@ -543,7 +543,7 @@ private boolean doMove(String fileName, ExternalFileType fileType, String destFi
private boolean doCopy(String fileName, ExternalFileType fileType, String toFile,
NamedCompound edits) {

List<String> dirs = panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
List<String> dirs = panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
int found = -1;
for (int i = 0; i < dirs.size(); i++) {
if (new File(dirs.get(i)).exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public boolean openLink() {
ExternalFileType type = fileType;
if (this.fileType == null) {
if (this.fieldName != null) {
JabRefDesktop.openExternalViewer(frame.getCurrentBasePanel().loadedDatabase.getMetaData(), link, fieldName);
JabRefDesktop.openExternalViewer(frame.getCurrentBasePanel().getLoadedDatabase().getMetaData(), link, fieldName);
return true;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/external/FindFullTextAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public void run() {
@Override
public void update() {
if (result.isPresent()) {
List<String> dirs = basePanel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
List<String> dirs = basePanel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
if (dirs.size() == 0) {
// FIXME: Localization
JOptionPane.showMessageDialog(basePanel.frame(), "Main file directory not set! Preferences -> External programs", "Directory not found", JOptionPane.ERROR_MESSAGE);
return;
}
String bibtexKey = entry.getCiteKey();
// TODO: this needs its own thread as it blocks the UI!
DownloadExternalFile def = new DownloadExternalFile(basePanel.frame(), basePanel.loadedDatabase.getMetaData(), bibtexKey);
DownloadExternalFile def = new DownloadExternalFile(basePanel.frame(), basePanel.getLoadedDatabase().getMetaData(), bibtexKey);
try {
def.download(result.get(), new DownloadExternalFile.DownloadCallback() {
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/external/MoveFileAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void actionPerformed(ActionEvent event) {
}

// Get an absolute path representation:
List<String> dirs = frame.getCurrentBasePanel().loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
List<String> dirs = frame.getCurrentBasePanel().getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
int found = -1;
for (int i = 0; i < dirs.size(); i++) {
if (new File(dirs.get(i)).exists()) {
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 @@ -74,7 +74,7 @@ public void init() {

// Ask about rules for the operation:
if (optDiag == null) {
optDiag = new SynchronizeFileField.OptionsDialog(panel.frame(), panel.loadedDatabase.getMetaData());
optDiag = new SynchronizeFileField.OptionsDialog(panel.frame(), panel.getLoadedDatabase().getMetaData());
}
PositionWindow.placeDialog(optDiag, panel.frame());
optDiag.setVisible(true);
Expand Down Expand Up @@ -111,7 +111,7 @@ public void run() {
Collections.addAll(entries, sel);

// Start the autosetting process:
Runnable r = Util.autoSetLinks(entries, ce, changedEntries, null, panel.loadedDatabase.getMetaData(), null, null);
Runnable r = Util.autoSetLinks(entries, ce, changedEntries, null, panel.getLoadedDatabase().getMetaData(), null, null);
JabRefExecutorService.INSTANCE.executeAndWait(r);
}
progress += sel.length * weightAutoSet;
Expand All @@ -128,7 +128,7 @@ public void run() {
tableModel.setContentDontGuessTypes(old);

// We need to specify which directories to search in for Util.expandFilename:
List<String> dirsS = panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
List<String> dirsS = panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
ArrayList<File> dirs = new ArrayList<>();
for (String dirs1 : dirsS) {
dirs.add(new File(dirs1));
Expand Down Expand Up @@ -166,7 +166,7 @@ public void run() {
case 1:
// Assign new file.
FileListEntryEditor flEditor = new FileListEntryEditor
(panel.frame(), flEntry, false, true, panel.loadedDatabase.getMetaData());
(panel.frame(), flEntry, false, true, panel.getLoadedDatabase().getMetaData());
flEditor.setVisible(true, true);
break;
case 2:
Expand Down Expand Up @@ -222,7 +222,7 @@ public void run() {
// User wants to change the type of this link.
// First get a model of all file links for this entry:
FileListEntryEditor editor = new FileListEntryEditor
(panel.frame(), flEntry, false, true, panel.loadedDatabase.getMetaData());
(panel.frame(), flEntry, false, true, panel.getLoadedDatabase().getMetaData());
editor.setVisible(true, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public TransferableFileLinkSelection(BasePanel panel, BibEntry[] selection) {
selection[0].getFieldOptional(Globals.FILE_FIELD).ifPresent(file -> tm.setContent(file));
if (tm.getRowCount() > 0) {
// Find the default directory for this field type, if any:
List<String> dirs = panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
List<String> dirs = panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
File expLink = FileUtil.expandFilename(tm.getEntry(0).link, dirs);
fileList.add(expLink);

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 @@ -123,14 +123,14 @@ public void run() {

// First check the (legacy) "pdf" field:
String pdf = entry.getField("pdf");
List<String> dirs = panel.loadedDatabase.getMetaData().getFileDirectory("pdf");
List<String> dirs = panel.getLoadedDatabase().getMetaData().getFileDirectory("pdf");
File f = FileUtil.expandFilename(pdf, dirs);
if (f != null) {
files.add(f);
}

// Then check the "file" field:
dirs = panel.loadedDatabase.getMetaData().getFileDirectory(Globals.FILE_FIELD);
dirs = panel.getLoadedDatabase().getMetaData().getFileDirectory(Globals.FILE_FIELD);
if (entry.hasField(Globals.FILE_FIELD)) {
FileListTableModel tm = new FileListTableModel();
tm.setContent(entry.getField(Globals.FILE_FIELD));
Expand Down
Loading

0 comments on commit 8fa19de

Please sign in to comment.