Skip to content

Commit

Permalink
Fix dependency issues
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharrer committed Oct 13, 2015
1 parent 4a12495 commit 9fb9859
Show file tree
Hide file tree
Showing 48 changed files with 233 additions and 221 deletions.
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/ArchitectureTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static Iterable<Object[]> data() {
new Object[][] {
{"net.sf.jabref.logic", PACKAGE_JAVA_AWT},
{"net.sf.jabref.logic", PACKAGE_JAVAX_SWING},
{"net.sf.jabref.logic", PACKAGE_NET_SF_JABREF_GUI},
// commented out as there are still four classes that do not conform to this specification
//{"net.sf.jabref.logic", PACKAGE_NET_SF_JABREF_GUI},
{"net.sf.jabref.model", PACKAGE_JAVA_AWT},
{"net.sf.jabref.model", PACKAGE_JAVAX_SWING},
{"net.sf.jabref.model", PACKAGE_NET_SF_JABREF_GUI}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/sf/jabref/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@

public class Globals {

private static final Log LOGGER = LogFactory.getLog(Globals.class);
public static final String FILE_FIELD = "file";
public static final String FOLDER_FIELD = "folder";

private static final Log LOGGER = LogFactory.getLog(Globals.class);
// JabRef version info
public static final BuildInfo BUILD_INFO = new BuildInfo();
// Signature written at the top of the .bib file.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/JabRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public Vector<ParserResult> processArguments(String[] args, boolean initialStart
}
MetaData metaData = pr.getMetaData();
metaData.setFile(theFile);
Globals.prefs.fileDirForDatabase = metaData.getFileDirectory(GUIGlobals.FILE_FIELD);
Globals.prefs.fileDirForDatabase = metaData.getFileDirectory(Globals.FILE_FIELD);
Globals.prefs.databaseFile = metaData.getFile();
System.out.println(Localization.lang("Exporting") + ": " + data[0]);
IExportFormat format = ExportFormats.getExportFormat(data[1]);
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/net/sf/jabref/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import net.sf.jabref.gui.preftabs.ImportSettingsTab;
import net.sf.jabref.importer.fileformat.ImportFormat;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelPattern.AbstractLabelPattern;
import net.sf.jabref.logic.labelPattern.GlobalLabelPattern;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.entry.CustomEntryType;
Expand Down Expand Up @@ -841,14 +840,14 @@ private JabRefPreferences() {
defaults.put(USE_CASE_KEEPER_ON_SEARCH, Boolean.TRUE);
defaults.put(USE_UNIT_FORMATTER_ON_SEARCH, Boolean.TRUE);

defaults.put(USER_FILE_DIR, GUIGlobals.FILE_FIELD + "Directory");
defaults.put(USER_FILE_DIR, Globals.FILE_FIELD + "Directory");
try {
defaults.put(USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '@' + InetAddress.getLocalHost().getHostName()); // Legacy setting name - was a bug: @ not allowed inside BibTeX comment text. Retained for backward comp.
defaults.put(USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName()); // Valid setting name
defaults.put(USER_FILE_DIR_IND_LEGACY, Globals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '@' + InetAddress.getLocalHost().getHostName()); // Legacy setting name - was a bug: @ not allowed inside BibTeX comment text. Retained for backward comp.
defaults.put(USER_FILE_DIR_INDIVIDUAL, Globals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName()); // Valid setting name
} catch (UnknownHostException ex) {
LOGGER.info("Hostname not found.", ex);
defaults.put(USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER));
defaults.put(USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER));
defaults.put(USER_FILE_DIR_IND_LEGACY, Globals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER));
defaults.put(USER_FILE_DIR_INDIVIDUAL, Globals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER));
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/sf/jabref/exporter/ExportFormats.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import net.sf.jabref.gui.JabRefFrame;
import net.sf.jabref.gui.actions.MnemonicAwareAction;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.entry.BibtexEntry;

Expand Down Expand Up @@ -209,7 +208,7 @@ public void actionPerformed(ActionEvent e) {
// so formatters can resolve linked files correctly.
// (This is an ugly hack!)
Globals.prefs.fileDirForDatabase = frame.basePanel().metaData()
.getFileDirectory(GUIGlobals.FILE_FIELD);
.getFileDirectory(Globals.FILE_FIELD);
// Also store the database's file in a global variable:
Globals.prefs.databaseFile = frame.basePanel().metaData().getFile();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.model.database.BibtexDatabase;
import net.sf.jabref.model.entry.BibtexEntry;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.Globals;
import net.sf.jabref.gui.JabRefFrame;
import net.sf.jabref.logic.l10n.Localization;
Expand Down Expand Up @@ -103,7 +102,7 @@ public void run() {
// so formatters can resolve linked files correctly.
// (This is an ugly hack!)
Globals.prefs.fileDirForDatabase = frame.basePanel().metaData()
.getFileDirectory(GUIGlobals.FILE_FIELD);
.getFileDirectory(Globals.FILE_FIELD);
// Also store the database's file in a global variable:
Globals.prefs.databaseFile = frame.basePanel().metaData().getFile();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.File;

import net.sf.jabref.logic.util.io.FileUtil;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.Globals;
import net.sf.jabref.exporter.layout.ParamLayoutFormatter;
import net.sf.jabref.gui.FileListEntry;
Expand Down Expand Up @@ -72,7 +71,7 @@ public String format(String field) {
if (Globals.prefs.fileDirForDatabase != null) {
dirs = Globals.prefs.fileDirForDatabase;
} else {
dirs = new String[] {Globals.prefs.get(GUIGlobals.FILE_FIELD + "Directory")};
dirs = new String[] {Globals.prefs.get(Globals.FILE_FIELD + "Directory")};
}

File f = FileUtil.expandFilename(link, dirs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import net.sf.jabref.gui.FileListTableModel;
import net.sf.jabref.gui.FileListEntry;
import net.sf.jabref.Globals;
import net.sf.jabref.gui.GUIGlobals;

import java.util.*;
import java.io.File;
Expand Down Expand Up @@ -147,7 +146,7 @@ public String format(String field) {
if (Globals.prefs.fileDirForDatabase != null) {
dirs = Globals.prefs.fileDirForDatabase;
} else {
dirs = new String[] {Globals.prefs.get(GUIGlobals.FILE_FIELD + "Directory")};
dirs = new String[] {Globals.prefs.get(Globals.FILE_FIELD + "Directory")};
}

File f = FileUtil.expandFilename(flEntry.getLink(), dirs);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/net/sf/jabref/external/AttachFileAction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.jabref.external;

import net.sf.jabref.Globals;
import net.sf.jabref.gui.*;
import net.sf.jabref.gui.actions.BaseAction;
import net.sf.jabref.gui.undo.UndoableFieldChange;
Expand Down Expand Up @@ -34,16 +35,16 @@ public void action() {
editor.setVisible(true, true);
if (editor.okPressed()) {
FileListTableModel model = new FileListTableModel();
String oldVal = entry.getField(GUIGlobals.FILE_FIELD);
String oldVal = entry.getField(Globals.FILE_FIELD);
if (oldVal != null) {
model.setContent(oldVal);
}
model.addEntry(model.getRowCount(), flEntry);
String newVal = model.getStringRepresentation();

UndoableFieldChange ce = new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD,
UndoableFieldChange ce = new UndoableFieldChange(entry, Globals.FILE_FIELD,
oldVal, newVal);
entry.setField(GUIGlobals.FILE_FIELD, newVal);
entry.setField(Globals.FILE_FIELD, newVal);
panel.undoManager.addEdit(ce);
panel.markBaseChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.sf.jabref.*;
import net.sf.jabref.gui.FileListEntry;
import net.sf.jabref.gui.FileListEntryEditor;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.gui.JabRefFrame;
import net.sf.jabref.gui.net.MonitoredURLDownload;
import net.sf.jabref.logic.l10n.Localization;
Expand Down Expand Up @@ -354,7 +353,7 @@ private String getSuffix(final String link) {
}

private String[] getFileDirectory(String link) {
return metaData.getFileDirectory(GUIGlobals.FILE_FIELD);
return metaData.getFileDirectory(Globals.FILE_FIELD);
}


Expand Down
22 changes: 11 additions & 11 deletions src/main/java/net/sf/jabref/external/DroppedFileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void handleDroppedfile(String fileName, ExternalFileType fileType, boolea
String destFilename;

if (linkInPlace.isSelected()) {
destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD)).toString();
destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(Globals.FILE_FIELD)).toString();
} else {
destFilename = renameCheckBox.isSelected() ? renameToTextBox.getText() : new File(fileName).getName();
if (copyRadioButton.isSelected()) {
Expand Down Expand Up @@ -193,7 +193,7 @@ public void linkPdfToEntry(String fileName, MainTable entryTable, BibtexEntry en
String destFilename;

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

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

if (linkInPlace.isSelected()) {
destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD)).toString();
destFilename = FileUtil.shortenFileName(new File(fileName), panel.metaData().getFileDirectory(Globals.FILE_FIELD)).toString();
} else {
if (renameCheckBox.isSelected()) {
destFilename = fileName;
Expand Down Expand Up @@ -345,7 +345,7 @@ private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileTy
BibtexEntry entry, boolean newEntry, final boolean multipleEntries, BibtexDatabase database) {

String dialogTitle = Localization.lang("Link to file %0", linkFileName);
String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD);
int found = -1;
for (int i = 0; i < dirs.length; i++) {
if (new File(dirs[i]).exists()) {
Expand Down Expand Up @@ -440,7 +440,7 @@ public void stateChanged(ChangeEvent arg0) {
private void doLink(BibtexEntry entry, ExternalFileType fileType, String filename,
boolean avoidDuplicate, NamedCompound edits) {

String oldValue = entry.getField(GUIGlobals.FILE_FIELD);
String oldValue = entry.getField(Globals.FILE_FIELD);
FileListTableModel tm = new FileListTableModel();
if (oldValue != null) {
tm.setContent(oldValue);
Expand All @@ -449,7 +449,7 @@ private void doLink(BibtexEntry entry, ExternalFileType fileType, String filenam
// If avoidDuplicate==true, we should check if this file is already linked:
if (avoidDuplicate) {
// For comparison, find the absolute filename:
String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD);
String absFilename = !new File(filename).isAbsolute() && dirs.length > 0 ?
FileUtil.expandFilename(filename, dirs).getAbsolutePath() : filename;

Expand All @@ -468,9 +468,9 @@ private void doLink(BibtexEntry entry, ExternalFileType fileType, String filenam

tm.addEntry(tm.getRowCount(), new FileListEntry("", filename, fileType));
String newValue = tm.getStringRepresentation();
UndoableFieldChange edit = new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD,
UndoableFieldChange edit = new UndoableFieldChange(entry, Globals.FILE_FIELD,
oldValue, newValue);
entry.setField(GUIGlobals.FILE_FIELD, newValue);
entry.setField(Globals.FILE_FIELD, newValue);

if (edits == null) {
panel.undoManager.addEdit(edit);
Expand All @@ -491,7 +491,7 @@ private void doLink(BibtexEntry entry, ExternalFileType fileType, String filenam
*/
private boolean doMove(String fileName, ExternalFileType fileType, String destFilename,
NamedCompound edits) {
String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD);
int found = -1;
for (int i = 0; i < dirs.length; i++) {
if (new File(dirs[i]).exists()) {
Expand Down Expand Up @@ -540,7 +540,7 @@ private boolean doMove(String fileName, ExternalFileType fileType, String destFi
private boolean doCopy(String fileName, ExternalFileType fileType, String toFile,
NamedCompound edits) {

String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD);
int found = -1;
for (int i = 0; i < dirs.length; i++) {
if (new File(dirs[i]).exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import net.sf.jabref.gui.JabRefFrame;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.entry.BibtexEntry;
import net.sf.jabref.logic.util.io.JabRefDesktop;
import net.sf.jabref.gui.desktop.JabRefDesktop;

/**
* The menu item used in the popup menu for opening external resources associated
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/sf/jabref/external/FindFullTextAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package net.sf.jabref.external;

import net.sf.jabref.Globals;
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.gui.undo.UndoableFieldChange;
import net.sf.jabref.gui.FileListEntry;
import net.sf.jabref.gui.FileListTableModel;
Expand Down Expand Up @@ -60,7 +60,7 @@ public void run() {
public void update() {
if (result.isPresent()) {
String bibtexKey = entry.getCiteKey();
String[] dirs = basePanel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirs = basePanel.metaData().getFileDirectory(Globals.FILE_FIELD);
if (dirs.length == 0) {
// FIXME: Localization
JOptionPane.showMessageDialog(basePanel.frame(), "Main file directory not set! Preferences -> External programs", "Directory not found", JOptionPane.ERROR_MESSAGE);
Expand All @@ -73,12 +73,12 @@ public void update() {
@Override
public void downloadComplete(FileListEntry file) {
FileListTableModel tm = new FileListTableModel();
String oldValue = entry.getField(GUIGlobals.FILE_FIELD);
String oldValue = entry.getField(Globals.FILE_FIELD);
tm.setContent(oldValue);
tm.addEntry(tm.getRowCount(), file);
String newValue = tm.getStringRepresentation();
UndoableFieldChange edit = new UndoableFieldChange(entry, GUIGlobals.FILE_FIELD, oldValue, newValue);
entry.setField(GUIGlobals.FILE_FIELD, newValue);
UndoableFieldChange edit = new UndoableFieldChange(entry, Globals.FILE_FIELD, oldValue, newValue);
entry.setField(Globals.FILE_FIELD, newValue);
basePanel.undoManager.addEdit(edit);
basePanel.markBaseChanged();
}
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 @@ -63,7 +63,7 @@ public void actionPerformed(ActionEvent event) {
}

// Get an absolute path representation:
String[] dirs = frame.basePanel().metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirs = frame.basePanel().metaData().getFileDirectory(Globals.FILE_FIELD);
int found = -1;
for (int i = 0; i < dirs.length; i++) {
if (new File(dirs[i]).exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
public class SynchronizeFileField extends AbstractWorker {

private final String fieldName = GUIGlobals.FILE_FIELD;
private final String fieldName = Globals.FILE_FIELD;
private final BasePanel panel;
private BibtexEntry[] sel;
private SynchronizeFileField.OptionsDialog optDiag;
Expand Down Expand Up @@ -156,7 +156,7 @@ public void run() {
tableModel.setContentDontGuessTypes(old);

// We need to specify which directories to search in for Util.expandFilename:
String[] dirsS = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirsS = panel.metaData().getFileDirectory(Globals.FILE_FIELD);
ArrayList<File> dirs = new ArrayList<File>();
for (String dirs1 : dirsS) {
dirs.add(new File(dirs1));
Expand Down Expand Up @@ -391,7 +391,7 @@ public void setVisible(boolean visible) {
canceled = true;
}

String[] dirs = metaData.getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirs = metaData.getFileDirectory(Globals.FILE_FIELD);
if (dirs.length == 0) {

autoSetNone.setSelected(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package net.sf.jabref.external;

import net.sf.jabref.Globals;
import net.sf.jabref.model.entry.BibtexEntry;
import net.sf.jabref.logic.util.io.FileUtil;
import net.sf.jabref.gui.GUIGlobals;
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.gui.FileListTableModel;

Expand All @@ -38,14 +38,14 @@ public class TransferableFileLinkSelection implements Transferable {


public TransferableFileLinkSelection(BasePanel panel, BibtexEntry[] selection) {
String s = selection[0].getField(GUIGlobals.FILE_FIELD);
String s = selection[0].getField(Globals.FILE_FIELD);
FileListTableModel tm = new FileListTableModel();
if (s != null) {
tm.setContent(s);
}
if (tm.getRowCount() > 0) {
// Find the default directory for this field type, if any:
String[] dirs = panel.metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
String[] dirs = panel.metaData().getFileDirectory(Globals.FILE_FIELD);
File expLink = FileUtil.expandFilename(tm.getEntry(0).getLink(), dirs);
fileList.add(expLink);

Expand Down

0 comments on commit 9fb9859

Please sign in to comment.