Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/JabRef/jabref into docboo…
Browse files Browse the repository at this point in the history
…k-exporter
  • Loading branch information
johannes-manner committed Jun 6, 2018
2 parents 318ee5e + 828b417 commit 152cf52
Show file tree
Hide file tree
Showing 68 changed files with 524 additions and 238 deletions.
17 changes: 11 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]

### Changed
- We added a validity check for dates in the `date` and `urldate` fields.
- We added a text file export for 'Find Unlinked Files'. [#3341](https://github.com/JabRef/jabref/issues/3341)
- We added a fetcher based on RFC-IDs. [#3971](https://github.com/JabRef/jabref/issues/3971)
- We changed the implementation of the `[shorttitle]` key pattern. It now removes small words like `a`, `an`, `on`, `the` etc. Refer to the help page for a complete overview. [Feature request in the forum](http://discourse.jabref.org/t/jabref-differences-in-shorttitle-between-versions-3-8-1-and-4-not-discounting-the-a-an-of-in-titles/1147)
- We added a formatter for adding braces around the `title` field. E.g., `title = {ExamPle}` becomes `title = {{ExamPle}}`, which prevents BibTeX to convert it to lower case. You can use it at the [cleanup entries](http://help.jabref.org/en/CleanupEntries) functionality.
- We added a formatter to ensure correct en dashes in the `title` field. E.g., `title = {Example - illustrative}` becomes `title = {Example -- illustrative}`.
- We streamlined the defaults for a [cleanup of entries](http://help.jabref.org/en/CleanupEntries) in the case of BibTeX.
- The import inspection window now uses the same font size setting as the maintable [Feature request in the forum](http://discourse.jabref.org/t/inspection-window-and-others-line-height-of-table-too-small-for-fonts/1168)

### Fixed
We fixed an issue where the export to clipboard functionality could not be invoked. [#3994](https://github.com/JabRef/jabref/issues/3994)
We fixed an issue with the migration of invalid Look and Feels. [#3995, comment](https://github.com/JabRef/jabref/issues/3995#issuecomment-385649448)
We fixed an issue where JabRef would no longer start, when the option "Override default font settings" was activated. [#3986](https://github.com/JabRef/jabref/issues/3986)
We fixed an issue where JabRef removed whitespace from the Title-fetcher which resulting in no entries being found. [#4014](https://github.com/JabRef/jabref/issues/4014)
We fixed an issue where fetched entries from the ACM fetcher could not be imported. [#4018](https://github.com/JabRef/jabref/issues/4018)
- We fixed an issue where the export to clipboard functionality could not be invoked. [#3994](https://github.com/JabRef/jabref/issues/3994)
- We fixed an issue with the migration of invalid Look and Feels. [#3995, comment](https://github.com/JabRef/jabref/issues/3995#issuecomment-385649448)
- We fixed an issue where JabRef would no longer start, when the option "Override default font settings" was activated. [#3986](https://github.com/JabRef/jabref/issues/3986)
- We fixed an issue where JabRef removed whitespace from the Title-fetcher which resulting in no entries being found. [#4014](https://github.com/JabRef/jabref/issues/4014)
- We fixed an issue where fetched entries from the ACM fetcher could not be imported. [#4018](https://github.com/JabRef/jabref/issues/4018)
- We fixed an issue to enable push to application on macOs again [#4041](https://github.com/JabRef/jabref/issues/4041)

### Removed
We removed the GTK Look and Feel from the Options, as it leads to freezes in JabRef on MacOSX and Linux [#3995](https://github.com/JabRef/jabref/issues/3995)
- We removed the GTK Look and Feel from the Options, as it leads to freezes in JabRef on MacOSX and Linux [#3995](https://github.com/JabRef/jabref/issues/3995).
The GTK Look and Feel is now replaced with the "Nimbus" style as default.


Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ dependencies {

compile 'com.github.tomtung:latex2unicode_2.12:0.2.2'

compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.1.0'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.1.0'
compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.1.1'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.1.1'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.2.0'
Expand All @@ -163,7 +163,7 @@ dependencies {
testCompile 'org.reflections:reflections:0.9.11'
testCompile 'org.xmlunit:xmlunit-core:2.6.0'
testCompile 'org.xmlunit:xmlunit-matchers:2.6.0'
testCompile 'com.tngtech.archunit:archunit-junit:0.5.0'
testCompile 'com.tngtech.archunit:archunit-junit:0.8.0'
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit:4.0.+"

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
128 changes: 63 additions & 65 deletions src/main/java/org/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,21 @@
* JabRef MainClass
*/
public class JabRefMain extends Application {

private static final Logger LOGGER = LoggerFactory.getLogger(JabRefMain.class);

private static String[] arguments;

public static void main(String[] args) {
arguments = args;

launch(arguments);
}

@Override
public void start(Stage mainStage) throws Exception {
Platform.setImplicitExit(false);
SwingUtilities.invokeLater(() -> start(arguments));
}

/**
* Tests if we are running an acceptable Java and terminates JabRef when we are sure the version is not supported.
* This test uses the requirements for the Java version as specified in <code>gradle.build</code>. It is possible to
Expand Down Expand Up @@ -93,58 +98,37 @@ private static void ensureCorrectJavaVersion() {
}

private static void start(String[] args) {
// Init preferences
JabRefPreferences preferences = JabRefPreferences.getInstance();
Globals.prefs = preferences;
// Perform Migrations
// Perform checks and changes for users with a preference set from an older JabRef version.
PreferencesMigrations.upgradePrefsToOrgJabRef();
PreferencesMigrations.upgradeSortOrder();
PreferencesMigrations.upgradeFaultyEncodingStrings();
PreferencesMigrations.upgradeLabelPatternToBibtexKeyPattern();
PreferencesMigrations.upgradeImportFileAndDirePatterns();
PreferencesMigrations.upgradeStoredCustomEntryTypes();
PreferencesMigrations.upgradeKeyBindingsToJavaFX();
PreferencesMigrations.addCrossRefRelatedFieldsForAutoComplete();
PreferencesMigrations.upgradeObsoleteLookAndFeels();

// Fail on unsupported Java versions
ensureCorrectJavaVersion();
FallbackExceptionHandler.installExceptionHandler();

ensureCorrectJavaVersion();
// Init preferences
final JabRefPreferences preferences = JabRefPreferences.getInstance();
Globals.prefs = preferences;
// Perform migrations
PreferencesMigrations.runMigrations();

ProxyPreferences proxyPreferences = preferences.getProxyPreferences();
ProxyRegisterer.register(proxyPreferences);
if (proxyPreferences.isUseProxy() && proxyPreferences.isUseAuthentication()) {
Authenticator.setDefault(new ProxyAuthenticator());
}
configureProxy(preferences.getProxyPreferences());

Globals.startBackgroundTasks();

// Update handling of special fields based on preferences
InternalBibtexFields
.updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS));
// Update name of the time stamp field based on preferences
InternalBibtexFields.updateTimeStampField(Globals.prefs.getTimestampPreferences().getTimestampField());
// Update which fields should be treated as numeric, based on preferences:
InternalBibtexFields.setNumericFields(Globals.prefs.getStringList(JabRefPreferences.NUMERIC_FIELDS));

// Read list(s) of journal names and abbreviations
Globals.journalAbbreviationLoader = new JournalAbbreviationLoader();

/* Build list of Import and Export formats */
Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(),
Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor());
EntryTypes.loadCustomEntryTypes(preferences.loadCustomEntryTypes(BibDatabaseMode.BIBTEX),
preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX));
Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader);
applyPreferences(preferences);

// Process arguments
ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START);

// Initialize protected terms loader
Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences());

// Check for running JabRef
if (!handleMultipleAppInstances(args) || argumentProcessor.shouldShutDown()) {
shutdownCurrentInstance();
return;
}

// If not, start GUI
SwingUtilities
.invokeLater(() -> new JabRefGUI(argumentProcessor.getParserResults(), argumentProcessor.isBlank()));
}

private static boolean handleMultipleAppInstances(String[] args) {
RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences();
if (remotePreferences.useRemoteServer()) {
Globals.REMOTE_LISTENER.open(new JabRefMessageHandler(), remotePreferences.getPort());
Expand All @@ -155,37 +139,51 @@ private static void start(String[] args) {
// We have successfully sent our command line options through the socket to another JabRef instance.
// So we assume it's all taken care of, and quit.
LOGGER.info(Localization.lang("Arguments passed on to running JabRef instance. Shutting down."));
Globals.shutdownThreadPools();
// needed to tell JavaFx to stop
Platform.exit();
return;
return false;
}
}
// we are alone, we start the server
Globals.REMOTE_LISTENER.start();
}
return true;
}

private static void shutdownCurrentInstance() {
Globals.shutdownThreadPools();
// needed to tell JavaFx to stop
Platform.exit();
}

private static void applyPreferences(JabRefPreferences preferences) {
// Update handling of special fields based on preferences
InternalBibtexFields.updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS));
// Update name of the time stamp field based on preferences
InternalBibtexFields.updateTimeStampField(Globals.prefs.getTimestampPreferences().getTimestampField());
// Update which fields should be treated as numeric, based on preferences:
InternalBibtexFields.setNumericFields(Globals.prefs.getStringList(JabRefPreferences.NUMERIC_FIELDS));

// Read list(s) of journal names and abbreviations
Globals.journalAbbreviationLoader = new JournalAbbreviationLoader();

/* Build list of Import and Export formats */
Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(),
Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor());
EntryTypes.loadCustomEntryTypes(preferences.loadCustomEntryTypes(BibDatabaseMode.BIBTEX),
preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX));
Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader);

// Initialize protected terms loader
Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences());

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

// See if we should shut down now
if (argumentProcessor.shouldShutDown()) {
Globals.shutdownThreadPools();
Platform.exit();
return;
}

// If not, start GUI
SwingUtilities
.invokeLater(() -> new JabRefGUI(argumentProcessor.getParserResults(),
argumentProcessor.isBlank()));
}

@Override
public void start(Stage mainStage) throws Exception {
Platform.setImplicitExit(false);
SwingUtilities.invokeLater(() -> start(arguments)
);
private static void configureProxy(ProxyPreferences proxyPreferences) {
ProxyRegisterer.register(proxyPreferences);
if (proxyPreferences.isUseProxy() && proxyPreferences.isUseAuthentication()) {
Authenticator.setDefault(new ProxyAuthenticator());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,12 @@ class EntryTable extends JTable {
public EntryTable(TableModel model) {
super(model);
getTableHeader().setReorderingAllowed(false);

setFont(GUIGlobals.currentFont);
int maxOfIconsAndFontSize = Math.max(GUIGlobals.currentFont.getSize(), Globals.prefs.getInt(JabRefPreferences.ICON_SIZE_SMALL));
setRowHeight(Globals.prefs.getInt(JabRefPreferences.TABLE_ROW_PADDING) + maxOfIconsAndFontSize);
// Update Table header with new settings
this.getTableHeader().resizeAndRepaint();
}

@Override
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/jabref/gui/push/AbstractPushToApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,19 @@ public void pushEntries(BibDatabase database, List<BibEntry> entries, String key
try {
if (OS.OS_X) {
String[] commands = getCommandLine(keyString);
ProcessBuilder processBuilder = new ProcessBuilder("open -a " + commands[0] + " -n --args " + commands[1] + " " + commands[2]);
if (commands.length < 3) {
LOGGER.error("Commandline does not contain enough parameters to \"push to application\"");
return;
}
ProcessBuilder processBuilder = new ProcessBuilder(
"open",
"-a",
commands[0],
"-n",
"--args",
commands[1],
commands[2]
);
processBuilder.start();
} else {
ProcessBuilder processBuilder = new ProcessBuilder(getCommandLine(keyString));
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/logic/formatter/Formatters.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import java.util.Objects;
import java.util.Optional;

import org.jabref.logic.formatter.bibtexfields.AddBracesFormatter;
import org.jabref.logic.formatter.bibtexfields.ClearFormatter;
import org.jabref.logic.formatter.bibtexfields.EscapeUnderscoresFormatter;
import org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter;
import org.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter;
import org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter;
import org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter;
import org.jabref.logic.formatter.bibtexfields.NormalizeEnDashesFormatter;
import org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter;
import org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter;
import org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter;
Expand Down Expand Up @@ -47,10 +49,12 @@ public class Formatters {
);

private static final List<Formatter> OTHERS = Arrays.asList(
new AddBracesFormatter(),
new ClearFormatter(),
new LatexCleanupFormatter(),
new MinifyNameListFormatter(),
new NormalizeDateFormatter(),
new NormalizeEnDashesFormatter(),
new NormalizeMonthFormatter(),
new NormalizeNamesFormatter(),
new NormalizePagesFormatter(),
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/jabref/logic/formatter/IdentityFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* It may seem useless, but is needed as a fallback option
*/
public class IdentityFormatter implements Formatter {
public class IdentityFormatter extends Formatter {

@Override
public String getName() {
Expand All @@ -35,15 +35,4 @@ public String getDescription() {
public String getExampleInput() {
return "JabRef";
}

@Override
public int hashCode() {
return defaultHashCode();
}

@Override
public boolean equals(Object obj) {
return defaultEquals(obj);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.jabref.logic.formatter.bibtexfields;

import java.util.Objects;

import org.jabref.logic.l10n.Localization;
import org.jabref.model.cleanup.Formatter;

public class AddBracesFormatter extends Formatter {

@Override
public String getName() {
return Localization.lang("Add enclosing braces");
}

@Override
public String getKey() {
return "add_braces";
}

@Override
public String format(String value) {
Objects.requireNonNull(value);

if ((value.length() >= 2) && (value.charAt(0) != '{') && (value.charAt(value.length() - 1) != '}')) {
// Title does not start with { and does not end with }, then this formatter can be applied
return "{" + value + "}";
} else {
return value;
}
}

@Override
public String getDescription() {
return Localization.lang("Add braces encapsulating the complete field content.");
}

@Override
public String getExampleInput() {
return "In CDMA";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.cleanup.Formatter;

public class ClearFormatter implements Formatter {
public class ClearFormatter extends Formatter {

@Override
public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.cleanup.Formatter;

public class EscapeUnderscoresFormatter implements Formatter {
public class EscapeUnderscoresFormatter extends Formatter {

private static final Pattern UNDERSCORES = Pattern.compile("_");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HtmlToLatexFormatter implements LayoutFormatter, Formatter {
public class HtmlToLatexFormatter extends Formatter implements LayoutFormatter {

private static final Logger LOGGER = LoggerFactory.getLogger(HtmlToLatexFormatter.class);

Expand Down
Loading

0 comments on commit 152cf52

Please sign in to comment.