Skip to content

Commit

Permalink
Merge branch 'master' into fileChooserRefactor
Browse files Browse the repository at this point in the history
* master:
  define xjc input/ouput dir (subsequent builds will be faster) (JabRef#1628)
  Consistent file name casing (and other localization improvements) (JabRef#1629)
  Builds are now stored via build-upload.jabref.org
  Some enhancements and cleanups related to dates (JabRef#1575)
  changes should be tested manually
  Cleanup FindFile and asssociated tests (JabRef#1596)
  More field names and a method (JabRef#1627)
  Moved, removed, and used String constants (JabRef#1618)
  Updated preview entries (JabRef#1606)
  Improved LaTeX to Unicode/HTML formatters to output more sensible values for unknown commands (JabRef#1622)
  Fixed JabRef#636 by using DOICheck and DOIStrip in export filters (JabRef#1624)
  Converted a few getField to getFieldOptional (JabRef#1625)
  • Loading branch information
Siedlerchr committed Jul 26, 2016
2 parents d1dc7bf + 653c8a9 commit d83ec67
Show file tree
Hide file tree
Showing 194 changed files with 1,801 additions and 1,789 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- [ ] Change in CHANGELOG.md described
- [ ] Tests created for changes
- [ ] Screenshots added (for bigger UI changes)
- [ ] Manually tested changed features in running JabRef
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
### Fixed
- Fixed [#1264](https://github.com/JabRef/jabref/issues/1264): S with caron does not render correctly
- LaTeX to Unicode converter now handles combining accents
- Fixed [#636](https://github.com/JabRef/jabref/issues/636): DOI in export filters
- Fixed [#1527](https://github.com/JabRef/jabref/issues/1527): 'Get BibTeX data from DOI' Removes Marking
- Fixed [#1592](https://github.com/JabRef/jabref/issues/1592): LibreOffice: wrong numbers in citation labels
- Fixed [#1321](https://github.com/JabRef/jabref/issues/1321): LaTeX commands in fields not displayed in the list of references
- Date fields in the BibLatex standard are now always formatted in the correct way, independent of the preferences

### Removed
- It is not longer possible to choose to convert HTML sub- and superscripts to equations
Expand Down
26 changes: 15 additions & 11 deletions medline.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@

configurations {
xjc
}
xjc
}

dependencies {
xjc group: 'com.sun.xml.bind', name: 'jaxb-xjc', version: '2.2.4-1'
xjc 'com.sun.xml.bind:jaxb-xjc:2.2.4-1'
}

task xjc () << {
ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.xjc.asPath)

ant.xjc(destdir: 'src/main/gen/', package: 'net.sf.jabref.importer.fileformat.medline'){
schema(dir: 'src/main/resources/xjc/medline', includes: 'medline.xsd')
}
task xjc {
inputs.dir "src/main/resources/xjc/medline/"
outputs.dir "src/main/gen/net/sf/jabref/importer/fileformat/medline"

ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.xjc.asPath)

doLast {
ant.xjc(destdir: 'src/main/gen/', package: 'net.sf.jabref.importer.fileformat.medline') {
schema(dir: 'src/main/resources/xjc/medline', includes: 'medline.xsd')
}
}
}

tasks. compileJava.dependsOn xjc
tasks.compileJava.dependsOn xjc
2 changes: 1 addition & 1 deletion scripts/upload-to-builds.jabref.org.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ command="${command}exit\n"

# now $command is complete

echo -e "$command" | sftp -P 9922 builds_jabref_org@builds.jabref.org
echo -e "$command" | sftp -P 9922 builds_jabref_org@build-upload.jabref.org
11 changes: 6 additions & 5 deletions src/main/java/net/sf/jabref/BibDatabaseContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
import java.util.Objects;
import java.util.Optional;

import net.sf.jabref.logic.layout.format.FileLinkPreferences;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.database.BibDatabaseMode;
import net.sf.jabref.model.database.BibDatabaseModeDetection;
import net.sf.jabref.model.entry.FieldName;
import net.sf.jabref.preferences.JabRefPreferences;

/**
* Represents everything related to a .bib file.
* Represents everything related to a BIB file.
* <p>
* The entries are stored in BibDatabase, the other data in MetaData and the options relevant for this file in Defaults.
*/
Expand Down Expand Up @@ -116,7 +117,7 @@ public boolean isBiblatexMode() {
* 1. metadata user-specific directory
* 2. metadata general directory
* 3. preferences directory
* 4. bib file directory
* 4. BIB file directory
*
* @param fieldName The field type
* @return The default directory for this field type.
Expand All @@ -137,12 +138,12 @@ public List<String> getFileDirectory(String fieldName) {
}

// 3. preferences directory
String dir = Globals.prefs.get(fieldName + Globals.DIR_SUFFIX); // FILE_DIR
String dir = Globals.prefs.get(fieldName + FileLinkPreferences.DIR_SUFFIX); // FILE_DIR
if (dir != null) {
fileDirs.add(dir);
}

// 4. bib file directory
// 4. BIB file directory
if (getDatabaseFile() != null) {
String parentDir = getDatabaseFile().getParent();
// Check if we should add it as primary file dir (first in the list) or not:
Expand All @@ -159,7 +160,7 @@ public List<String> getFileDirectory(String fieldName) {
private String getFileDirectoryPath(String directoryName) {
String dir = directoryName;
// If this directory is relative, we try to interpret it as relative to
// the file path of this bib file:
// the file path of this BIB file:
if (!new File(dir).isAbsolute() && (getDatabaseFile() != null)) {
String relDir;
if (".".equals(dir)) {
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/net/sf/jabref/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,14 @@

public class Globals {

public static final String DIR_SUFFIX = "Directory";

// JabRef version info
public static final BuildInfo BUILD_INFO = new BuildInfo();
// Signature written at the top of the .bib file.
public static final String SIGNATURE = "This file was created with JabRef";
public static final String ENCODING_PREFIX = "Encoding: ";
// Character separating field names that are to be used in sequence as
// fallbacks for a single column (e.g. "author/editor" to use editor where
// author is not set):
public static final String COL_DEFINITION_FIELD_SEPARATOR = "/";
// Newlines
// will be overridden in initialization due to feature #857 @ JabRef.java
public static String NEWLINE = System.lineSeparator();

// Remote listener
public static final RemoteListenerServerLifecycle REMOTE_LISTENER = new RemoteListenerServerLifecycle();

public static final ImportFormatReader IMPORT_FORMAT_READER = new ImportFormatReader();


// Non-letters which are used to denote accents in LaTeX-commands, e.g., in {\"{a}}
public static final String SPECIAL_COMMAND_CHARS = "\"`^~'=.|";

// In the main program, this field is initialized in JabRef.java
// Each test case initializes this field if required
public static JabRefPreferences prefs;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.sf.jabref.logic.net.ProxyRegisterer;
import net.sf.jabref.logic.remote.RemotePreferences;
import net.sf.jabref.logic.remote.client.RemoteListenerClient;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.entry.InternalBibtexFields;
import net.sf.jabref.preferences.JabRefPreferences;

Expand Down Expand Up @@ -92,7 +93,7 @@ private static void start(String[] args) {

// override used newline character with the one stored in the preferences
// The preferences return the system newline character sequence as default
Globals.NEWLINE = Globals.prefs.get(JabRefPreferences.NEWLINE);
OS.NEWLINE = Globals.prefs.get(JabRefPreferences.NEWLINE);

// Process arguments
ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/net/sf/jabref/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.AbstractLabelPattern;
import net.sf.jabref.logic.labelpattern.DatabaseLabelPattern;
import net.sf.jabref.logic.layout.format.FileLinkPreferences;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.logic.util.strings.StringUtil;
import net.sf.jabref.model.database.BibDatabaseMode;
import net.sf.jabref.model.entry.FieldName;
Expand All @@ -58,7 +60,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 + Globals.DIR_SUFFIX;
private static final String FILE_DIRECTORY = FieldName.FILE + FileLinkPreferences.DIR_SUFFIX;
public static final String SELECTOR_META_PREFIX = "selector_";
private static final String PROTECTED_FLAG_META = "protectedFlag";

Expand Down Expand Up @@ -364,7 +366,7 @@ public Map<String, String> getAsStringMap() {

//in case of save actions, add an additional newline after the enabled flag
if (metaItem.getKey().equals(SAVE_ACTIONS) && ("enabled".equals(dataItem) || "disabled".equals(dataItem))) {
stringBuilder.append(Globals.NEWLINE);
stringBuilder.append(OS.NEWLINE);
}
}

Expand All @@ -379,12 +381,12 @@ public Map<String, String> getAsStringMap() {
// (which is always the AllEntriesGroup).
if ((groupsRoot != null) && (groupsRoot.getNumberOfChildren() > 0)) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(Globals.NEWLINE);
stringBuilder.append(OS.NEWLINE);

for (String groupNode : groupsRoot.getTreeAsString()) {
stringBuilder.append(StringUtil.quote(groupNode, ";", '\\'));
stringBuilder.append(";");
stringBuilder.append(Globals.NEWLINE);
stringBuilder.append(OS.NEWLINE);
}
serializedMetaData.put(GROUPSTREE, stringBuilder.toString());
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/sf/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private List<ParserResult> importAndOpenFiles() {
if (!cli.isBlank() && (cli.getLeftOver().length > 0)) {
for (String aLeftOver : cli.getLeftOver()) {
// Leftover arguments that have a "bib" extension are interpreted as
// bib files to open. Other files, and files that could not be opened
// BIB files to open. Other files, and files that could not be opened
// as bib, we try to import instead.
boolean bibExtension = aLeftOver.toLowerCase(Locale.ENGLISH).endsWith("bib");
ParserResult pr = null;
Expand Down Expand Up @@ -294,7 +294,7 @@ private boolean generateAux(List<ParserResult> loaded, String[] data) {
SaveSession session = databaseWriter.saveDatabase(new BibDatabaseContext(newBase, defaults),
prefs);

// Show just a warning message if encoding didn't work for all characters:
// Show just a warning message if encoding did not work for all characters:
if (!session.getWriter().couldEncodeAll()) {
System.err.println(Localization.lang("Warning") + ": "
+ Localization.lang(
Expand Down Expand Up @@ -336,7 +336,7 @@ private void exportFile(List<ParserResult> loaded, String[] data) {
SaveSession session = databaseWriter.saveDatabase(
new BibDatabaseContext(pr.getDatabase(), pr.getMetaData(), defaults), prefs);

// Show just a warning message if encoding didn't work for all characters:
// Show just a warning message if encoding did not work for all characters:
if (!session.getWriter().couldEncodeAll()) {
System.err.println(Localization.lang("Warning") + ": "
+ Localization.lang(
Expand Down Expand Up @@ -438,7 +438,7 @@ private void regenerateBibtexKeys(List<ParserResult> loaded) {
LabelPatternUtil.makeLabel(metaData, database, entry, Globals.prefs);
}
} else {
LOGGER.info(Localization.lang("No meta data present in bibfile. Cannot regenerate BibTeX keys"));
LOGGER.info(Localization.lang("No meta data present in BIB_file. Cannot regenerate BibTeX keys"));
}
}
}
Expand Down Expand Up @@ -483,7 +483,7 @@ private Optional<ParserResult> fetch(String fetchCommand) {
}

String query = split[1];
System.out.println(Localization.lang("Running Query '%0' with fetcher '%1'.", query, engine) + " "
System.out.println(Localization.lang("Running query '%0' with fetcher '%1'.", query, engine) + " "
+ Localization.lang("Please wait..."));
Collection<BibEntry> result = new ImportInspectionCommandLine().query(query, fetcher);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/cli/JabRefCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private Options getOptions() {

options.addOption(Option.builder("a").
longOpt("aux").
desc(String.format("%s: %s[.aux],%s[.bib]", Localization.lang("Subdatabase from aux"),
desc(String.format("%s: %s[.aux],%s[.bib]", Localization.lang("Subdatabase from AUX"),
Localization.lang("file"),
Localization.lang("new"))).
hasArg().
Expand All @@ -214,7 +214,7 @@ private Options getOptions() {

options.addOption(Option.builder("f").
longOpt("fetch").
desc(Localization.lang("Run Fetcher, e.g. \"--fetch=Medline:cancer\"")).
desc(Localization.lang("Run fetcher, e.g. \"--fetch=Medline:cancer\"")).
hasArg().
argName("FILE").
build());
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/net/sf/jabref/external/AutoSetLinks.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class AutoSetLinks {
* @param entries the entries for which links should be set
* @param databaseContext the database for which links are set
*/
public static void autoSetLinks(Collection<BibEntry> entries, BibDatabaseContext databaseContext) {
public static void autoSetLinks(List<BibEntry> entries, BibDatabaseContext databaseContext) {
autoSetLinks(entries, null, null, null, databaseContext, null, null);
}

Expand Down Expand Up @@ -69,7 +69,9 @@ public static void autoSetLinks(Collection<BibEntry> entries, BibDatabaseContext
* parameter can be null, which means that no progress update will be shown.
* @return the thread performing the automatically setting
*/
public static Runnable autoSetLinks(final Collection<BibEntry> entries, final NamedCompound ce, final Set<BibEntry> changedEntries, final FileListTableModel singleTableModel, final BibDatabaseContext databaseContext, final ActionListener callback, final JDialog diag) {
public static Runnable autoSetLinks(final List<BibEntry> entries, final NamedCompound ce,
final Set<BibEntry> changedEntries, final FileListTableModel singleTableModel,
final BibDatabaseContext databaseContext, final ActionListener callback, final JDialog diag) {
final Collection<ExternalFileType> types = ExternalFileTypes.getInstance().getExternalFileTypeSelection();
if (diag != null) {
final JProgressBar prog = new JProgressBar(JProgressBar.HORIZONTAL, 0, types.size() - 1);
Expand All @@ -94,7 +96,7 @@ public void run() {
dirs.addAll(dirsS.stream().map(File::new).collect(Collectors.toList()));

// determine extensions
Collection<String> extensions = new ArrayList<>();
List<String> extensions = new ArrayList<>();
for (final ExternalFileType type : types) {
extensions.add(type.getExtension());
}
Expand All @@ -105,7 +107,8 @@ public void run() {
String regExp = Globals.prefs.get(JabRefPreferences.REG_EXP_SEARCH_EXPRESSION_KEY);
result = RegExpFileSearch.findFilesForSet(entries, extensions, dirs, regExp);
} else {
result = FileUtil.findAssociatedFiles(entries, extensions, dirs, Globals.prefs);
boolean autoLinkExactKeyOnly = Globals.prefs.getBoolean(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY);
result = FileUtil.findAssociatedFiles(entries, extensions, dirs, autoLinkExactKeyOnly);
}

boolean foundAny = false;
Expand Down Expand Up @@ -210,7 +213,8 @@ public void run() {
* parameter can be null, which means that no progress update will be shown.
* @return the runnable able to perform the automatically setting
*/
public static Runnable autoSetLinks(final BibEntry entry, final FileListTableModel singleTableModel, final BibDatabaseContext databaseContext, final ActionListener callback, final JDialog diag) {
public static Runnable autoSetLinks(final BibEntry entry, final FileListTableModel singleTableModel,
final BibDatabaseContext databaseContext, final ActionListener callback, final JDialog diag) {
return autoSetLinks(Collections.singletonList(entry), null, null, singleTableModel, databaseContext, callback,
diag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void download(URL url, final DownloadCallback callback) throws IOExceptio
if (suggestedType.isPresent()) {
suffix = suggestedType.get().getExtension();
} else {
// If we didn't find a file type from the MIME type, try based on extension:
// If we did not find a file type from the MIME type, try based on extension:
suffix = getSuffix(res);
if (suffix == null) {
suffix = "";
Expand Down Expand Up @@ -200,10 +200,10 @@ public void download(URL url, final DownloadCallback callback) throws IOExceptio
if (directory == null) {
dirPrefix = null;
} else {
if (directory.endsWith(System.getProperty("file.separator"))) {
if (directory.endsWith(OS.FILE_SEPARATOR)) {
dirPrefix = directory;
} else {
dirPrefix = directory + System.getProperty("file.separator");
dirPrefix = directory + OS.FILE_SEPARATOR;
}
}

Expand Down Expand Up @@ -249,7 +249,7 @@ public void download(URL url, final DownloadCallback callback) throws IOExceptio
private File expandFilename(String directory, String link) {
File toFile = new File(link);
// If this is a relative link, we should perhaps append the directory:
String dirPrefix = directory + System.getProperty("file.separator");
String dirPrefix = directory + OS.FILE_SEPARATOR;
if (!toFile.isAbsolute()) {
toFile = new File(dirPrefix + link);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/sf/jabref/external/DroppedFileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import net.sf.jabref.gui.undo.UndoableFieldChange;
import net.sf.jabref.gui.undo.UndoableInsertEntry;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.logic.util.io.FileUtil;
import net.sf.jabref.logic.xmp.XMPUtil;
import net.sf.jabref.model.database.BibDatabase;
Expand Down Expand Up @@ -478,7 +479,7 @@ private boolean doMove(String fileName, String destFilename,
LOGGER.warn("Cannot determine destination directory or destination directory does not exist");
return false;
}
File toFile = new File(dirs.get(found) + System.getProperty("file.separator") + destFilename);
File toFile = new File(dirs.get(found) + OS.FILE_SEPARATOR + destFilename);
if (toFile.exists()) {
int answer = JOptionPane.showConfirmDialog(frame,
Localization.lang("'%0' exists. Overwrite file?", toFile.getAbsolutePath()),
Expand Down Expand Up @@ -530,7 +531,7 @@ private boolean doCopy(String fileName, String toFile, NamedCompound edits) {
}
String destinationFileName = new File(toFile).getName();

File destFile = new File(dirs.get(found) + System.getProperty("file.separator") + destinationFileName);
File destFile = new File(dirs.get(found) + OS.FILE_SEPARATOR + destinationFileName);
if (destFile.equals(new File(fileName))) {
// File is already in the correct position. Don't override!
return true;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/sf/jabref/external/ExternalFileTypes.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.sf.jabref.external;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -104,7 +103,7 @@ public static List<ExternalFileType> getDefaultExternalFileTypes() {
return list;
}

public Collection<ExternalFileType> getExternalFileTypeSelection() {
public Set<ExternalFileType> getExternalFileTypeSelection() {
return externalFileTypes;
}

Expand Down
Loading

0 comments on commit d83ec67

Please sign in to comment.