Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into maintable-beta
Browse files Browse the repository at this point in the history
* upstream/master:
  Pdf exporter - delete xmp actions in the menu bar and the cli option (#3947)
  Improve search performance (#3950)
  New Crowdin translations (#3949)
  Update dependencies for junit, mockito and checkstyle (#3951)
  Add XMP Exporter (#3895)
  Switch colors of search icon for the two search modes (#3871)

# Conflicts:
#	src/main/java/org/jabref/gui/search/GlobalSearchBar.java
  • Loading branch information
Siedlerchr committed Apr 13, 2018
2 parents 8dff922 + 1d9ce25 commit fa9f59d
Show file tree
Hide file tree
Showing 22 changed files with 402 additions and 212 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The new default removes the linked file from the entry instead of deleting the f
- We changed the metadata reading and writing. DublinCore is now the only metadata format, JabRef supports. (https://github.com/JabRef/jabref/pull/3710)
- We added another CLI functionality for reading and writing metadata to pdfs. (see https://github.com/JabRef/jabref/pull/3756 and see http://help.jabref.org/en/CommandLine)
- We no longer print errors in field values during autosave into the log [#3811](https://github.com/JabRef/jabref/issues/3811)
- We improved the search performance by adding a short delay before starting to display search results [Bug report in the forum](http://discourse.jabref.org/t/poor-performance-of-jabref-4/1110/2)

### Fixed
- We fixed several performance problems with the management of journal abbreviations [#3323](https://github.com/JabRef/jabref/issues/3323)
Expand All @@ -56,6 +57,7 @@ The new default removes the linked file from the entry instead of deleting the f
- We fixed the name of the group editing window to "Add group" instead of "Edit Group" when adding a new group. [koppor#277](https://github.com/koppor/jabref/issues/277)
- We fixed the `pureauth` [BibTeX key generator pattern](https://help.jabref.org/en/BibtexKeyPatterns) to just return the author if no author, but an editor is present.
- We fixed an issue where the "Copy linked files" dialog produced an error when the entry had no file [#3818](https://github.com/JabRef/jabref/issues/3818)
- We fixed the coloring of the search box icon in case a user switches to advanced search mode [#3870](https://github.com/JabRef/jabref/issues/3870)
- We fixed an issue where pressing <kbd>del</kbd> in the `file` field would trigger the delete dialog a second file, if the first file is deleted [#3926](https://github.com/JabRef/jabref/issues/3926)

### Removed
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ dependencies {
compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.0.2'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.0.2'

testCompile 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.1.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
testRuntime 'org.junit.vintage:junit-vintage-engine:5.1.0'
testCompile 'org.junit.platform:junit-platform-launcher:1.1.0'
testCompile 'org.junit.jupiter:junit-jupiter-api:5.1.1'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.1.1'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.1.1'
testRuntime 'org.junit.vintage:junit-vintage-engine:5.1.1'
testCompile 'org.junit.platform:junit-platform-launcher:1.1.1'
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.0'
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.0'
testCompile 'org.mockito:mockito-core:2.17.0'
testCompile 'org.mockito:mockito-core:2.18.0'
testCompile 'com.github.tomakehurst:wiremock:2.16.0'
testCompile 'org.assertj:assertj-swing-junit:3.8.0'
testCompile 'org.reflections:reflections:0.9.11'
Expand All @@ -175,7 +175,7 @@ dependencies {
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit5:4.0.+"

checkstyle 'com.puppycrawl.tools:checkstyle:8.8'
checkstyle 'com.puppycrawl.tools:checkstyle:8.9'
}

jacoco {
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.jabref.logic.search.SearchQuery;
import org.jabref.logic.shared.prefs.SharedDatabasePreferences;
import org.jabref.logic.util.OS;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.model.Defaults;
import org.jabref.model.EntryTypes;
import org.jabref.model.database.BibDatabase;
Expand Down Expand Up @@ -223,11 +224,6 @@ private List<ParserResult> processArguments() {
doAuxImport(loaded);
}

if (cli.isXmpFacilities()) {
XmpUtilMain.executeXmpConsoleApplicaton();
System.exit(0);
}

return loaded;
}

Expand Down Expand Up @@ -471,7 +467,8 @@ private void importPreferences() {
LayoutFormatterPreferences layoutPreferences = Globals.prefs
.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader);
SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs);
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences);
XmpPreferences xmpPreferences = Globals.prefs.getXMPPreferences();
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences);
} catch (JabRefException ex) {
LOGGER.error("Cannot import preferences", ex);
}
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/org/jabref/cli/JabRefCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ public String getExportMatches() {
return cl.getOptionValue("exportMatches");
}

public boolean isXmpFacilities() {
return cl.hasOption("readAndWriteXmpMetadata");
}

public boolean isGenerateBibtexKeys() { return cl.hasOption("generateBibtexKeys"); }

public boolean isAutomaticallySetFileLinks() { return cl.hasOption("automaticallySetFileLinks"); }
Expand Down Expand Up @@ -236,11 +232,6 @@ private Options getOptions() {
desc(Localization.lang("Automatically set file links")).
build());

options.addOption(Option.builder("xmp").
longOpt("readAndWriteXmpMetadata").
desc("Read and write xmp metadata from/to pdf files").
build());

return options;
}

Expand Down
129 changes: 0 additions & 129 deletions src/main/java/org/jabref/cli/XmpUtilMain.java

This file was deleted.

24 changes: 18 additions & 6 deletions src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.SearchPreferences;

import impl.org.controlsfx.skin.AutoCompletePopup;
import org.controlsfx.control.textfield.AutoCompletionBinding;
import org.fxmisc.easybind.EasyBind;
import org.reactfx.util.FxTimer;
import org.reactfx.util.Timer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GlobalSearchBar extends HBox {
private static final Logger LOGGER = LoggerFactory.getLogger(GlobalSearchBar.class);

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

private static final int SEARCH_DELAY = 400;
private static final PseudoClass CLASS_NO_RESULTS = PseudoClass.getPseudoClass("emptyResult");
private static final PseudoClass CLASS_RESULTS_FOUND = PseudoClass.getPseudoClass("emptyResult");

Expand All @@ -86,6 +86,13 @@ public class GlobalSearchBar extends HBox {

private SearchDisplayMode searchDisplayMode;

private final JLabel searchIcon = new JLabel(IconTheme.JabRefIcon.SEARCH.getIcon());

/**
* if this flag is set the searchbar won't be selected after the next search
*/
private boolean dontSelectSearchBar;

public GlobalSearchBar(JabRefFrame frame) {
super();
this.frame = Objects.requireNonNull(frame);
Expand Down Expand Up @@ -244,10 +251,15 @@ private void openLocalFindingsInExternalPanel() {

SearchResultFrame searchDialog = new SearchResultFrame(currentBasePanel.frame(),
Localization.lang("Search results in library %0 for %1", currentBasePanel.getBibDatabaseContext()
.getDatabaseFile().map(File::getName).orElse(GUIGlobals.UNTITLED_TITLE),
.getDatabasePath()
.map(Path::getFileName)
.map(Path::toString)
.orElse(GUIGlobals.UNTITLED_TITLE),
this.getSearchQuery().localize()),
getSearchQuery(), false);
List<BibEntry> entries = currentBasePanel.getDatabase().getEntries().stream()
List<BibEntry> entries = currentBasePanel.getDatabase()
.getEntries()
.stream()
.filter(BibEntry::isSearchHit)
.collect(Collectors.toList());
searchDialog.addEntries(entries, currentBasePanel);
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/jabref/logic/exporter/ExporterFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.layout.LayoutFormatterPreferences;
import org.jabref.logic.util.FileType;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.preferences.JabRefPreferences;

public class ExporterFactory {
Expand All @@ -29,7 +30,7 @@ private ExporterFactory(List<Exporter> exporters) {
}

public static ExporterFactory create(Map<String, TemplateExporter> customFormats,
LayoutFormatterPreferences layoutPreferences, SavePreferences savePreferences) {
LayoutFormatterPreferences layoutPreferences, SavePreferences savePreferences, XmpPreferences xmpPreferences) {

List<Exporter> exporters = new ArrayList<>();

Expand All @@ -54,6 +55,8 @@ public static ExporterFactory create(Map<String, TemplateExporter> customFormats
exporters.add(new OpenDocumentSpreadsheetCreator());
exporters.add(new MSBibExporter());
exporters.add(new ModsExporter());
exporters.add(new XmpExporter(xmpPreferences));
exporters.add(new XmpPdfExporter(xmpPreferences));

// Now add custom export formats
exporters.addAll(customFormats.values());
Expand All @@ -65,7 +68,8 @@ public static ExporterFactory create(JabRefPreferences preferences, JournalAbbre
Map<String, TemplateExporter> customFormats = preferences.customExports.getCustomExportFormats(preferences, abbreviationLoader);
LayoutFormatterPreferences layoutPreferences = preferences.getLayoutFormatterPreferences(abbreviationLoader);
SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(preferences);
return create(customFormats, layoutPreferences, savePreferences);
XmpPreferences xmpPreferences = preferences.getXMPPreferences();
return create(customFormats, layoutPreferences, savePreferences, xmpPreferences);
}

/**
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/org/jabref/logic/exporter/XmpExporter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.jabref.logic.exporter;

import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import org.jabref.logic.util.FileType;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.logic.xmp.XmpUtilWriter;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;

/**
* A custom exporter to write bib entries to a .xmp file for further processing
* in other scenarios and applications. The xmp metadata are written in dublin
* core format.
*/
public class XmpExporter extends Exporter {

private static final String XMP_SPLIT_PATTERN = "split";

private final XmpPreferences xmpPreferences;

public XmpExporter(XmpPreferences xmpPreferences) {
super("xmp", FileType.PLAIN_XMP.getDescription(), FileType.PLAIN_XMP);
this.xmpPreferences = xmpPreferences;
}

@Override
public void export(BibDatabaseContext databaseContext, Path file, Charset encoding, List<BibEntry> entries) throws Exception {
Objects.requireNonNull(databaseContext);
Objects.requireNonNull(file);
Objects.requireNonNull(entries);

if (entries.isEmpty()) {
return;
}

// This is a distinction between writing all entries from the supplied list to a single .xmp file,
// or write every entry to a separate file.
if (file.getFileName().toString().trim().equals(XMP_SPLIT_PATTERN)) {

for (BibEntry entry : entries) {
// Avoid situations, where two cite keys are null
Path entryFile;
String suffix = entry.getId() + "_" + entry.getCiteKey() + ".xmp";
if (file.getParent() == null) {
entryFile = Paths.get(suffix);
} else {
entryFile = Paths.get(file.getParent().toString() + "/" + suffix);
}

this.writeBibToXmp(entryFile, Arrays.asList(entry), encoding);
}
} else {
this.writeBibToXmp(file, entries, encoding);
}
}

private void writeBibToXmp(Path file, List<BibEntry> entries, Charset encoding) throws IOException {
try (BufferedWriter writer = Files.newBufferedWriter(file, encoding)) {
writer.write(XmpUtilWriter.generateXmpString(entries, this.xmpPreferences));
writer.flush();
}
}
}
Loading

0 comments on commit fa9f59d

Please sign in to comment.