Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ooPanel
Browse files Browse the repository at this point in the history
* upstream/master:
  Bump applicationinsights-logging-log4j2 from 2.2.1 to 2.3.0 (#4540)
  Bump antlr4-runtime from 4.7.1 to 4.7.2 (#4542)
  Bump applicationinsights-core from 2.2.1 to 2.3.0 (#4541)
  Bump antlr4 from 4.7.1 to 4.7.2 (#4543)
  Fix journal name "Astronomy Journal" to "Astronomical Journal"
  fix-for-issue-4489 (#4538)
  Sorting of read-status isn't working as expected #4521 (#4536)
  Add preselect last used export format in export to clipboard dialog (#4533)
  fixed 4365 put html in clipboard (#4519)
  [WIP] Convert Exporter Customization Dialog to javafx (#4394)
  Fixes #4437 (#4531)
  Bump checkstyle from 8.14 to 8.15 (#4528)

# Conflicts:
#	src/main/java/org/jabref/preferences/PreferencesService.java
  • Loading branch information
Siedlerchr committed Dec 23, 2018
2 parents 8be8bdc + 949d204 commit 3e4d135
Show file tree
Hide file tree
Showing 36 changed files with 742 additions and 642 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We added an option in the preference dialog box, that allows user to pick the dark or light theme option. [#4130] (https://github.com/JabRef/jabref/issues/4130)
- We updated updated the Related Articles tab to accept JSON from the new version of the Mr. DLib service
- We added an option in the preference dialog box that allows user to choose behavior after dragging and dropping files in Entry Editor. [#4356](https://github.com/JabRef/jabref/issues/4356)
- We added the ability to have an export preference where previously "File"-->"Export"/"Export selected entries" would not save the user's preference[#4495](https://github.com/JabRef/jabref/issues/4495)



Expand Down Expand Up @@ -88,7 +89,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where the ArXiv Fetcher did not support HTTP URLs [koppor#328](https://github.com/koppor/jabref/issues/328)
- We fixed an issue where only one PDF file could be imported [#4422](https://github.com/JabRef/jabref/issues/4422)
- We fixed an issue where "Move to group" would always move the first entry in the library and not the selected [#4414](https://github.com/JabRef/jabref/issues/4414)

- We fixed an issue where an older dialog appears when downloading full texts from the quality menu. [#4489](https://github.com/JabRef/jabref/issues/4489)



Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ dependencies {
antlr3 'org.antlr:antlr:3.5.2'
compile 'org.antlr:antlr-runtime:3.5.2'

antlr4 'org.antlr:antlr4:4.7.1'
compile 'org.antlr:antlr4-runtime:4.7.1'
antlr4 'org.antlr:antlr4:4.7.2'
compile 'org.antlr:antlr4-runtime:4.7.2'

compile 'mysql:mysql-connector-java:8.0.13'

Expand Down Expand Up @@ -157,8 +157,8 @@ dependencies {

errorproneJavac 'com.google.errorprone:javac:1.8.0-u20'

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

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.2'
Expand All @@ -180,7 +180,7 @@ dependencies {
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit5:4.0.+"

checkstyle 'com.puppycrawl.tools:checkstyle:8.14'
checkstyle 'com.puppycrawl.tools:checkstyle:8.15'
}

jacoco {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.prefs.BackingStoreException;

Expand Down Expand Up @@ -459,8 +458,7 @@ private void importPreferences() {
Globals.prefs.importPreferences(cli.getPreferencesImport());
EntryTypes.loadCustomEntryTypes(Globals.prefs.loadCustomEntryTypes(BibDatabaseMode.BIBTEX),
Globals.prefs.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX));
Map<String, TemplateExporter> customExporters = Globals.prefs.customExports.getCustomExportFormats(Globals.prefs,
Globals.journalAbbreviationLoader);
List<TemplateExporter> customExporters = Globals.prefs.getCustomExportFormats(Globals.journalAbbreviationLoader);
LayoutFormatterPreferences layoutPreferences = Globals.prefs
.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader);
SavePreferences savePreferences = Globals.prefs.loadForExportFromPreferences();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ private void setupActions() {
actions.put(Actions.REMOVE_FROM_GROUP, new GroupAddRemoveDialog(this, false, false));
actions.put(Actions.MOVE_TO_GROUP, new GroupAddRemoveDialog(this, true, true));

actions.put(Actions.DOWNLOAD_FULL_TEXT, new FindFullTextAction(frame.getDialogService(), this));
actions.put(Actions.DOWNLOAD_FULL_TEXT, new FindFullTextAction(this)::execute);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,6 @@ private void tearDownJabRef(List<String> filenames) {
}

fileHistory.storeHistory();
prefs.customExports.store(Globals.prefs);
prefs.customImports.store();

prefs.flush();

// dispose all windows, even if they are not displayed anymore
Expand Down Expand Up @@ -928,7 +925,7 @@ private MenuBar createMenu() {

factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction()),
factory.createMenuItem(StandardActions.MANAGE_CUSTOM_IMPORTS, new ManageCustomImportsAction(this)),
factory.createMenuItem(StandardActions.MANAGE_CUSTOM_EXPORTS, new ManageCustomExportsAction(this)),
factory.createMenuItem(StandardActions.MANAGE_CUSTOM_EXPORTS, new ManageCustomExportsAction()),
factory.createMenuItem(StandardActions.MANAGE_EXTERNAL_FILETYPES, new EditExternalFileTypesAction()),
factory.createMenuItem(StandardActions.MANAGE_JOURNALS, new ManageJournalsAction()),
factory.createMenuItem(StandardActions.CUSTOMIZE_KEYBINDING, new CustomizeKeyBindingAction()),
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/org/jabref/gui/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

/**
* Displays an BibEntry using the given layout format.
Expand Down Expand Up @@ -351,7 +354,19 @@ public void close() {
}

private void copyPreviewToClipBoard() {
String previewContent = (String) previewView.getEngine().executeScript("document.documentElement.outerHTML");
clipBoardManager.setContent(previewContent);
StringBuilder previewStringContent = new StringBuilder();
Document document = previewView.getEngine().getDocument();
NodeList nodeList = document.getElementsByTagName("*");

for (int i = 0; i < nodeList.getLength(); i++) {
Element element = (Element) nodeList.item(i);
previewStringContent.append(element.getNodeValue()).append("\n");
}

ClipboardContent content = new ClipboardContent();
content.putString(previewStringContent.toString());
content.putHtml((String) previewView.getEngine().executeScript("document.documentElement.outerHTML"));

clipBoardManager.setContent(content);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
package org.jabref.gui.actions;

import org.jabref.gui.JabRefFrame;
import org.jabref.gui.exporter.ExportCustomizationDialog;
import org.jabref.gui.exporter.ExportCustomizationDialogView;

public class ManageCustomExportsAction extends SimpleCommand {

private final JabRefFrame jabRefFrame;

public ManageCustomExportsAction(JabRefFrame jabRefFrame) {
this.jabRefFrame = jabRefFrame;
}

@Override
public void execute() {
ExportCustomizationDialog ecd = new ExportCustomizationDialog(jabRefFrame);
ecd.setVisible(true);
new ExportCustomizationDialogView().show();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonType?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<DialogPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="480.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.exporter.CreateModifyExporterDialogView">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="320.0">
<children>
<GridPane prefWidth="480.0" scaleShape="false">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="name" GridPane.rowIndex="1" />
<Label text="%Main layout file:" GridPane.rowIndex="2" />
<TextField fx:id="fileName" GridPane.rowIndex="3" />
<TextField fx:id="extension" GridPane.rowIndex="6" />
<Label alignment="TOP_LEFT" text="%Export format name:">
<GridPane.margin>
<Insets />
</GridPane.margin>
</Label>
<Label text="%File extension:" GridPane.rowIndex="5" />
<Button fx:id="browseButton" text="%Browse" onAction="#browse" GridPane.rowIndex="4" />
</children>
<padding>
<Insets bottom="30.0" left="30.0" right="30.0" top="30.0" />
</padding>
</GridPane>
</children></AnchorPane>
</content>
<ButtonType fx:id="saveExporter" text="%Save exporter" />
<ButtonType fx:constant="CANCEL" />
</DialogPane>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.jabref.gui.exporter;

import javax.inject.Inject;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextField;

import org.jabref.gui.DialogService;
import org.jabref.gui.util.BaseDialog;
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.PreferencesService;

import com.airhacks.afterburner.views.ViewLoader;

public class CreateModifyExporterDialogView extends BaseDialog<ExporterViewModel> {

@FXML private Button browseButton;
@FXML private TextField name;
@FXML private TextField fileName;
@FXML private TextField extension;
@FXML private ButtonType saveExporter;

@Inject private DialogService dialogService;
@Inject private PreferencesService preferences;
@Inject private final JournalAbbreviationLoader loader;
private CreateModifyExporterDialogViewModel viewModel;

private final ExporterViewModel exporter;

public CreateModifyExporterDialogView(ExporterViewModel exporter, DialogService dialogService,
PreferencesService preferences, JournalAbbreviationLoader loader) {
this.setTitle(Localization.lang("Customize Export Formats"));
this.exporter = exporter;
this.loader = loader;
this.dialogService = dialogService;
this.preferences = preferences;

ViewLoader.view(this)
.load()
.setAsDialogPane(this);

this.setResultConverter(button -> {
if (button == saveExporter) {
return viewModel.saveExporter();
} else {
return null;
}
});
}

@FXML
private void initialize() {
viewModel = new CreateModifyExporterDialogViewModel(exporter, dialogService, preferences, loader);
name.textProperty().bindBidirectional(viewModel.getName());
fileName.textProperty().bindBidirectional(viewModel.getLayoutFileName());
extension.textProperty().bindBidirectional(viewModel.getExtension());
}

@FXML
private void browse(ActionEvent event) {
viewModel.browse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package org.jabref.gui.exporter;

import java.nio.file.Path;
import java.nio.file.Paths;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.DialogService;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.exporter.SavePreferences;
import org.jabref.logic.exporter.TemplateExporter;
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.layout.LayoutFormatterPreferences;
import org.jabref.logic.util.StandardFileType;
import org.jabref.preferences.PreferencesService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
* This view model can be used both for "add exporter" and "modify exporter" functionalities.
* It takes an optional exporter which is empty for "add exporter," and takes the selected exporter
* for "modify exporter." It returns an optional exporter which empty if an invalid or no exporter is
* created, and otherwise contains the exporter to be added or that is modified.
*
*/

public class CreateModifyExporterDialogViewModel extends AbstractViewModel {

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

private final DialogService dialogService;
private final PreferencesService preferences;

private final StringProperty name = new SimpleStringProperty("");
private final StringProperty layoutFile = new SimpleStringProperty("");
private final StringProperty extension = new SimpleStringProperty("");

private final JournalAbbreviationLoader loader;

public CreateModifyExporterDialogViewModel(ExporterViewModel exporter, DialogService dialogService, PreferencesService preferences,
JournalAbbreviationLoader loader) {
this.dialogService = dialogService;
this.preferences = preferences;
this.loader = loader;

//Set text of each of the boxes
if (exporter != null) {
name.setValue(exporter.name().get());
layoutFile.setValue(exporter.layoutFileName().get());
extension.setValue(exporter.extension().get());
}
}

public ExporterViewModel saveExporter() {
Path layoutFileDir = Paths.get(layoutFile.get()).getParent();
if (layoutFileDir != null) {
String layoutFileDirString = layoutFileDir.toString();
preferences.setExportWorkingDirectory(layoutFileDirString);
}

// Check that there are no empty strings.
if (layoutFile.get().isEmpty() || name.get().isEmpty() || extension.get().isEmpty()
|| !layoutFile.get().endsWith(".layout")) {

LOGGER.info("One of the fields is empty or invalid!");
return null;
}

// Create a new exporter to be returned to ExportCustomizationDialogViewModel, which requested it
LayoutFormatterPreferences layoutPreferences = preferences.getLayoutFormatterPreferences(loader);
SavePreferences savePreferences = preferences.loadForExportFromPreferences();
TemplateExporter format = new TemplateExporter(name.get(), layoutFile.get(), extension.get(),
layoutPreferences, savePreferences);
format.setCustomExport(true);
return new ExporterViewModel(format);
}

public String getExportWorkingDirectory() {
return preferences.getExportWorkingDirectory();
}

public void browse() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(Localization.lang("Custom layout file"), StandardFileType.LAYOUT)
.withDefaultExtension(Localization.lang("Custom layout file"), StandardFileType.LAYOUT)
.withInitialDirectory(getExportWorkingDirectory()).build();
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(f -> layoutFile.set(f.toAbsolutePath().toString()));
}

public StringProperty getName() {
return name;
}

public StringProperty getLayoutFileName() {
return layoutFile;
}

public StringProperty getExtension() {
return extension;
}

}
Loading

0 comments on commit 3e4d135

Please sign in to comment.