Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fixSetFiles
Browse files Browse the repository at this point in the history
* upstream/master: (31 commits)
  Source tab entry duplication (#3360)
  Use CITE_COMMENT not only for external latex editors but also for cop… (#3351)
  Updating with new translations (#3348)
  Upgrade error-prone (#3350)
  Jabref_pt_BR partially updated (#3349)
  Used late initialization for context menus (#3340)
  Fix NPE when calling with bib file as cmd argument (#3343)
  update mockito-core from 2.10.0 -> 2.11.0 (#3338)
  Remove underscore in Localized messages (#3336)
  Localisation: French: new entries translated (#3337)
  Refactoring: Lazy init of all editor tabs (#3333)
  Initializing EntryEditor Tabs on focus (#3331)
  Fix #3292: annotations are now automatically refreshed (#3325)
  Change integrity message for names depending on database mode (#3330)
  Fix location bundle with fast access (#3327)
  Small code cleanup
  Fix "path not found" exception
  Small fix in drag and drop handler of linked files (#3328)
  Fix NPE in MainTable (#3318)
  Increase relative size of abstract field in editor (#3320)
  ...
  • Loading branch information
Siedlerchr committed Oct 27, 2017
2 parents d1cf1b6 + 6bb21d4 commit 1c12a4d
Show file tree
Hide file tree
Showing 87 changed files with 1,270 additions and 1,369 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Updated French translation
- We improved the handling of abstracts in the "Astrophysics Data System" fetcher. [#2471](https://github.com/JabRef/jabref/issues/2471)
- We added support for pasting entries in different formats [#3143](https://github.com/JabRef/jabref/issues/3143)
- In the annotation tab, PDF files are now monitored for new or changed annotation. A manual reload is no longer necessary. [#3292](https://github.com/JabRef/jabref/issues/3292)
- We increased the relative size of the "abstract" field in the entry editor. [Feature request in the forum](http://discourse.jabref.org/t/entry-preview-in-version-4/827)
- Crossreferenced entries are now used when a BibTex key is generated for an entry with empty fields. [#2811](https://github.com/JabRef/jabref/issues/2811)
- We now set the WM_CLASS of the UI to org-jabref-JabRefMain to allow certain Un*x window managers to properly identify its windows
- We changed the default paths for the OpenOffice/LibreOffice binaries to the default path for LibreOffice
- We no longer create a new entry editor when selecting a new entry to increase performance. [#3187](https://github.com/JabRef/jabref/pull/3187)
- We increased performance and decreased the memory footprint of the entry editor drastically. [#3331](https://github.com/JabRef/jabref/pull/3331)
- Late initialization of the context menus in the entry editor. This improves performance and memory footprint further [#3340](https://github.com/JabRef/jabref/pull/3340)


### Fixed
- We fixed the translation of \textendash in the entry preview [#3307](https://github.com/JabRef/jabref/issues/3307)
- We fixed an issue where JabRef would not terminated after asking to collect anonymous statistics [#2955 comment](https://github.com/JabRef/jabref/issues/2955#issuecomment-334591123)
- We fixed an issue where JabRef would not shut down when started with the '-n' (No GUI) option.
- We fixed an issue where JabRef would not shut down when started with the '-n' (No GUI) option. [#3247](https://github.com/JabRef/jabref/issues/3247)
- We improved the way metadata is updated in remote databases. [#3235](https://github.com/JabRef/jabref/issues/3235)

- We improved font rendering of the Entry Editor for Linux based systems [#3295](https://github.com/JabRef/jabref/issues/3295)
- We fixed an issue where JabRef would freeze when trying to replace the original entry after a merge with new information from identifiers like DOI/ISBN etc. [3294](https://github.com/JabRef/jabref/issues/3294)
- We fixed an issue where JabRef would not show the translated content at some points, although there existed a translation
- We fixed an issue where editing in the source tab would override content of other entries [#3352](https://github.com/JabRef/jabref/issues/3352#issue-268580818)
### Removed


Expand Down
16 changes: 9 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id "de.sebastianboegl.shadow.transformer.log4j" version "2.1.1"
id "com.simonharrer.modernizer" version '1.5.0-1'
id 'me.champeau.gradle.jmh' version '0.4.3'
id 'net.ltgt.errorprone' version '0.0.11'
id 'net.ltgt.errorprone' version '0.0.13'
}

// use the gradle build scan feature: https://scans.gradle.com/get-started
Expand Down Expand Up @@ -104,11 +104,13 @@ dependencies {
compile 'de.codecentric.centerdevice:javafxsvg:1.2.1'
compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4'
compile 'de.saxsys:mvvmfx-validation:1.7.0'
compile 'org.controlsfx:controlsfx:8.40.14'
compile 'org.fxmisc.easybind:easybind:1.0.3'
compile 'org.fxmisc.flowless:flowless:0.5.2'
compile 'org.fxmisc.richtext:richtextfx:0.7-M5'

// Cannot be updated to 9.*.* until Jabref works with Java 9
compile 'org.controlsfx:controlsfx:8.40.14'

compile 'org.jsoup:jsoup:1.10.3'
compile 'com.mashape.unirest:unirest-java:1.4.9'

Expand All @@ -122,13 +124,13 @@ dependencies {
compile 'org.citationstyles:locales:1.0.1-SNAPSHOT'
compile 'de.undercouch:citeproc-java:1.0.1'

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

compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '1.0.+'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '1.0.+'
compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '1.0.9'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '1.0.9'

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.10.0'
testCompile 'org.mockito:mockito-core:2.11.0'
testCompile 'com.github.tomakehurst:wiremock:2.8.0'
testCompile 'org.assertj:assertj-swing-junit:3.8.0'
testCompile 'org.reflections:reflections:0.9.11'
Expand Down Expand Up @@ -353,7 +355,7 @@ task media(type: com.install4j.gradle.Install4jTask, dependsOn: "releaseJar") {
checkstyle {
// do not use other packages for checkstyle, excluding gen(erated) sources
checkstyleMain.source = "src/main/java"
toolVersion = '8.0'
toolVersion = '8.3'
}

checkstyleMain.shouldRunAfter test
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
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-bin.zip
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.util.Optional;
import java.util.UUID;

import org.jabref.collab.FileUpdateMonitor;
import org.jabref.gui.GlobalFocusListener;
import org.jabref.gui.StateManager;
import org.jabref.gui.keyboard.KeyBindingRepository;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.FileUpdateMonitor;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.importer.ImportFormatReader;
import org.jabref.logic.journals.JournalAbbreviationLoader;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/jabref/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ private void setLookAndFeel() {
LOGGER.warn("Unable to find requested look and feel", e);
}
}

// On Linux, Java FX fonts look blurry per default. This can be improved by using a non-default rendering
// setting. See https://github.com/woky/javafx-hates-linux
if (Globals.prefs.getBoolean(JabRefPreferences.FX_FONT_RENDERING_TWEAK)) {
System.setProperty("prism.text", "t2k");
System.setProperty("prism.lcdtext", "true");
}
} catch (Exception e) {
LOGGER.warn("Look and feel could not be set", e);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ private static void start(String[] args) {

Globals.prefs = preferences;
Globals.startBackgroundTasks();
Localization.setLanguage(preferences.get(JabRefPreferences.LANGUAGE));

// Note that the language was already set during the initialization of the preferences and it is safe to
// call the next function.
Globals.prefs.setLanguageDependentDefaultValues();

// Perform Migrations
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ private void regenerateBibtexKeys(List<ParserResult> loaded) {
database, entry, Globals.prefs.getBibtexKeyPatternPreferences());
}
} else {
LOGGER.info(Localization.lang("No meta data present in BIB_file. Cannot regenerate BibTeX keys"));
LOGGER.info(Localization.lang("No meta data present in BIB file. Cannot regenerate BibTeX keys"));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/collab/ChangeDisplayDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ChangeDisplayDialog(JFrame owner, final BasePanel panel,
if (anyDisabled) {
panel.markBaseChanged();
}
panel.setUpdatedExternally(false);
panel.markExternalChangesAsResolved();
dispose();
okPressed = true;
});
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/jabref/collab/ChangeScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class ChangeScanner implements Runnable {

private static final double MATCH_THRESHOLD = 0.4;
private final File file;
private final Path tempFile;
private final BibDatabase databaseInMemory;
private final MetaData metadataInMemory;

Expand All @@ -67,20 +68,20 @@ public class ChangeScanner implements Runnable {

// NamedCompound edit = new NamedCompound("Merged external changes")

public ChangeScanner(JabRefFrame frame, BasePanel bp, File file) {
public ChangeScanner(JabRefFrame frame, BasePanel bp, File file, Path tempFile) {
this.panel = bp;
this.frame = frame;
this.databaseInMemory = bp.getDatabase();
this.metadataInMemory = bp.getBibDatabaseContext().getMetaData();
this.file = file;
this.tempFile = tempFile;
}

@Override
public void run() {
try {

// Parse the temporary file.
Path tempFile = Globals.getFileUpdateMonitor().getTempFile(panel.fileMonitorHandle());
ImportFormatPreferences importFormatPreferences = Globals.prefs.getImportFormatPreferences();
ParserResult result = OpenDatabase.loadDatabase(tempFile.toFile(), importFormatPreferences);
databaseInTemp = result.getDatabase();
Expand Down Expand Up @@ -153,7 +154,7 @@ private void storeTempDatabase() {
Defaults defaults = new Defaults(Globals.prefs.getDefaultBibDatabaseMode());
BibDatabaseWriter<SaveSession> databaseWriter = new BibtexDatabaseWriter<>(FileSaveSession::new);
SaveSession ss = databaseWriter.saveDatabase(new BibDatabaseContext(databaseInTemp, metadataInTemp, defaults), prefs);
ss.commit(Globals.getFileUpdateMonitor().getTempFile(panel.fileMonitorHandle()));
ss.commit(tempFile);
} catch (SaveException ex) {
LOGGER.warn("Problem updating tmp file after accepting external changes", ex);
}
Expand Down
161 changes: 161 additions & 0 deletions src/main/java/org/jabref/collab/DatabaseChangeMonitor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
package org.jabref.collab;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;

import javax.swing.SwingUtilities;

import org.jabref.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.SidePaneManager;
import org.jabref.gui.util.FileUpdateListener;
import org.jabref.gui.util.FileUpdateMonitor;
import org.jabref.logic.util.io.FileBasedLock;
import org.jabref.logic.util.io.FileUtil;
import org.jabref.model.database.BibDatabaseContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DatabaseChangeMonitor implements FileUpdateListener {
private static final Log LOGGER = LogFactory.getLog(DatabaseChangeMonitor.class);

private final BibDatabaseContext database;
private final FileUpdateMonitor fileMonitor;
private final BasePanel panel;
private boolean updatedExternally;
private Path tmpFile;
private long timeStamp;
private long fileSize;

public DatabaseChangeMonitor(BibDatabaseContext database, FileUpdateMonitor fileMonitor, BasePanel panel) {
this.database = database;
this.fileMonitor = fileMonitor;
this.panel = panel;

this.database.getDatabasePath().ifPresent(path -> {
try {
fileMonitor.addListenerForFile(path, this);
timeStamp = Files.getLastModifiedTime(path).toMillis();
fileSize = Files.size(path);
tmpFile = Files.createTempFile("jabref", ".bib");
tmpFile.toFile().deleteOnExit();
copyToTemp(path);
} catch (IOException e) {
LOGGER.error("Error while trying to monitor " + path, e);
}
});
}

@Override
public void fileUpdated() {
if (panel.isSaving()) {
// We are just saving the file, so this message is most likely due to bad timing.
// If not, we'll handle it on the next polling.
return;
}

updatedExternally = true;

final ChangeScanner scanner = new ChangeScanner(panel.frame(), panel, database.getDatabaseFile().orElse(null), tmpFile);

// Test: running scan automatically in background
if (database.getDatabasePath().isPresent() && !FileBasedLock.waitForFileLock(database.getDatabasePath().get())) {
// The file is locked even after the maximum wait. Do nothing.
LOGGER.error("File updated externally, but change scan failed because the file is locked.");

// Wait a bit and then try again
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// Nothing to do
}
fileUpdated();
return;
}

JabRefExecutorService.INSTANCE.executeInterruptableTaskAndWait(scanner);

// Adding the sidepane component is Swing work, so we must do this in the Swing
// thread:
Runnable t = () -> {

// Check if there is already a notification about external
// changes:
SidePaneManager sidePaneManager = panel.getSidePaneManager();
boolean hasAlready = sidePaneManager.hasComponent(FileUpdatePanel.class);
if (hasAlready) {
sidePaneManager.hideComponent(FileUpdatePanel.class);
sidePaneManager.unregisterComponent(FileUpdatePanel.class);
}
FileUpdatePanel pan = new FileUpdatePanel(panel, sidePaneManager,
database.getDatabaseFile().orElse(null), scanner);
sidePaneManager.register(pan);
sidePaneManager.show(FileUpdatePanel.class);
};

if (scanner.changesFound()) {
SwingUtilities.invokeLater(t);
} else {
updatedExternally = false;
}
}

/**
* Forces a check on the file, and returns the result. Check if time stamp or the file size has changed.
*
* @return boolean true if the file has changed.
*/
private boolean hasBeenModified() {
Optional<Path> file = database.getDatabasePath();
if (file.isPresent()) {
try {
long modified = Files.getLastModifiedTime(file.get()).toMillis();
if (modified == 0L) {
// File deleted
return false;
}
long fileSizeNow = Files.size(file.get());
return (timeStamp != modified) || (fileSize != fileSizeNow);
} catch (IOException ex) {
return false;
}
}
return false;
}

public void unregister() {
database.getDatabasePath().ifPresent(file -> fileMonitor.removeListener(file, this));
}

public boolean hasBeenModifiedExternally() {
return updatedExternally || hasBeenModified();
}

public void markExternalChangesAsResolved() {
updatedExternally = false;
}

public void markAsSaved() {
database.getDatabasePath().ifPresent(file -> {
try {
timeStamp = Files.getLastModifiedTime(file).toMillis();
fileSize = Files.size(file);

copyToTemp(file);
} catch (IOException ex) {
LOGGER.error("Error while getting file information", ex);
}
});
}

private void copyToTemp(Path file) {
FileUtil.copyFile(file, tmpFile, true);
}

public Path getTempFile() {
return tmpFile;
}
}
Loading

0 comments on commit 1c12a4d

Please sign in to comment.