Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fixCustomExportFi…
Browse files Browse the repository at this point in the history
…leType

* upstream/master: (33 commits)
  Import inspection uses now same font size setttings as maintable (#4062)
  Add date checker (#4007)
  Enable tests
  macOs push to application fix
  Fix #4041 to make Push to Application work again on OSX. (#4057)
  Add NormalizeEnDashesFormatter (#4045)
  Package private for tests
  Shutdown duplicate code
  Move migrations to PreferencesMigrations
  Structure startup
  Extract migrations
  A first solution for the cli problem #4038 (#4047)
  New translations JabRef_en.properties (French) (#4052)
  Update CHANGELOG.md
  Fix checkstyle
  Make test more informative in the failing case
  New translations JabRef_en.properties (French) (#4051)
  New translations JabRef_en.properties (Vietnamese) (#4050)
  Make Formatter an abstract class (and remove AbstractFormatter)
  New Crowdin translations (#4048)
  ...

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
Siedlerchr committed May 27, 2018
2 parents 1a0cde3 + d2ddf93 commit d0df7ca
Show file tree
Hide file tree
Showing 79 changed files with 599 additions and 275 deletions.
20 changes: 15 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,26 @@ 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 custom exports could not be selected in the 'Export (selected) entries' dialog [#4013](https://github.com/JabRef/jabref/issues/4013)
- 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)
- We fixed an issue where custom exports could not be selected in the 'Export (selected) entries' dialog [#4013](https://github.com/JabRef/jabref/issues/4013)

### 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
120 changes: 59 additions & 61 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,39 +98,65 @@ private static void ensureCorrectJavaVersion() {
}

private static void start(String[] args) {
// Fail on unsupported Java versions
ensureCorrectJavaVersion();
FallbackExceptionHandler.installExceptionHandler();

// Init preferences
JabRefPreferences preferences = JabRefPreferences.getInstance();
final 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();
// Perform migrations
PreferencesMigrations.runMigrations();

configureProxy(preferences.getProxyPreferences());

Globals.startBackgroundTasks();

applyPreferences(preferences);

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

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

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

ProxyPreferences proxyPreferences = preferences.getProxyPreferences();
ProxyRegisterer.register(proxyPreferences);
if (proxyPreferences.isUseProxy() && proxyPreferences.isUseAuthentication()) {
Authenticator.setDefault(new ProxyAuthenticator());
private static boolean handleMultipleAppInstances(String[] args) {
RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences();
if (remotePreferences.useRemoteServer()) {
Globals.REMOTE_LISTENER.open(new JabRefMessageHandler(), remotePreferences.getPort());

if (!Globals.REMOTE_LISTENER.isOpen()) {
// we are not alone, there is already a server out there, try to contact already running JabRef:
if (new RemoteClient(remotePreferences.getPort()).sendCommandLineArguments(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."));
return false;
}
}
// we are alone, we start the server
Globals.REMOTE_LISTENER.start();
}
return true;
}

Globals.startBackgroundTasks();
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));
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:
Expand All @@ -144,48 +175,15 @@ private static void start(String[] args) {
// Initialize protected terms loader
Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences());

// Check for running JabRef
RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences();
if (remotePreferences.useRemoteServer()) {
Globals.REMOTE_LISTENER.open(new JabRefMessageHandler(), remotePreferences.getPort());

if (!Globals.REMOTE_LISTENER.isOpen()) {
// we are not alone, there is already a server out there, try to contact already running JabRef:
if (new RemoteClient(remotePreferences.getPort()).sendCommandLineArguments(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;
}
}
// we are alone, we start the server
Globals.REMOTE_LISTENER.start();
}

// 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());
}
}
}
13 changes: 7 additions & 6 deletions src/main/java/org/jabref/gui/EntryTypeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public EntryTypeDialog(JabRefFrame frame) {
setTitle(Localization.lang("Select entry type"));

addWindowListener(new WindowAdapter() {

@Override
public void windowClosing(WindowEvent e) {
cancelAction.actionPerformed(null);
Expand Down Expand Up @@ -246,7 +247,6 @@ static class TypeButton extends JButton implements Comparable<TypeButton> {

private final EntryType type;


TypeButton(String label, EntryType type) {
super(label);
this.type = type;
Expand All @@ -263,6 +263,7 @@ public EntryType getType() {
}

class CancelAction extends AbstractAction {

public CancelAction() {
super("Cancel");
}
Expand All @@ -275,6 +276,7 @@ public void actionPerformed(ActionEvent e) {
}

private class FetcherWorker extends SwingWorker<Optional<BibEntry>, Void> {

private boolean fetcherException = false;
private String fetcherExceptionMessage = "";
private IdBasedFetcher fetcher = null;
Expand All @@ -288,10 +290,9 @@ protected Optional<BibEntry> doInBackground() throws Exception {
generateButton.setText(Localization.lang("Searching..."));
});

Globals.prefs.put(JabRefPreferences.ID_ENTRY_GENERATOR,String.valueOf(comboBox.getSelectedItem()));
searchID = idTextField.getText().trim();
searchID = searchID.replaceAll(" ", "");
Globals.prefs.put(JabRefPreferences.ID_ENTRY_GENERATOR, String.valueOf(comboBox.getSelectedItem()));
fetcher = WebFetchers.getIdBasedFetchers(Globals.prefs.getImportFormatPreferences()).get(comboBox.getSelectedIndex());
searchID = idTextField.getText();
if (!searchID.isEmpty()) {
try {
bibEntry = fetcher.performSearchById(searchID);
Expand All @@ -311,7 +312,7 @@ protected void done() {
if (result.isPresent()) {
final BibEntry bibEntry = result.get();
if ((DuplicateCheck.containsDuplicate(frame.getCurrentBasePanel().getDatabase(), bibEntry, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).isPresent())) {
//If there are duplicates starts ImportInspectionDialog
//If there are duplicates starts ImportInspectionDialog
final BasePanel panel = (BasePanel) frame.getTabbedPane().getSelectedComponent();

ImportInspectionDialog diag = new ImportInspectionDialog(frame, panel, Localization.lang("Import"), false);
Expand All @@ -321,7 +322,7 @@ protected void done() {
diag.setVisible(true);
diag.toFront();
} else {
// Regenerate CiteKey of imported BibEntry
// Regenerate CiteKey of imported BibEntry
new BibtexKeyGenerator(frame.getCurrentBasePanel().getBibDatabaseContext(), Globals.prefs.getBibtexKeyPatternPreferences()).generateAndSetKey(bibEntry);
// Update Timestamps
if (Globals.prefs.getTimestampPreferences().includeCreatedTimestamp()) {
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class ACMPortalFetcher implements PreviewEntryFetcher {

private static final Pattern FULL_CITATION_PATTERN = Pattern.compile("<a href=\"(citation.cfm.*)\" target.*");

private static final Pattern ID_PATTERN = Pattern.compile("citation.cfm\\?id=(\\d+)&.*");
private static final Pattern ID_PATTERN = Pattern.compile("citation.cfm\\?id=(\\d+).*");

// Patterns used to extract information for the preview:
private static final Pattern TITLE_PATTERN = Pattern.compile("<a href=.*?\">([^<]*)</a>");
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
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ else if (val.matches("edtr\\d+")) {
} else if ("fulltitle".equals(val)) {
return entry.getResolvedFieldOrAlias(FieldName.TITLE, database).orElse("");
} else if ("shorttitle".equals(val)) {
return getTitleWords(3, entry.getResolvedFieldOrAlias(FieldName.TITLE, database).orElse(""));
return getTitleWords(3,
removeSmallWords(entry.getResolvedFieldOrAlias(FieldName.TITLE, database).orElse("")));
} else if ("shorttitleINI".equals(val)) {
return keepLettersAndDigitsOnly(
applyModifiers(getTitleWordsWithSpaces(3, entry.getResolvedFieldOrAlias(FieldName.TITLE, database).orElse("")),
Expand Down
Loading

0 comments on commit d0df7ca

Please sign in to comment.