-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into ooPanel
* 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
Showing
36 changed files
with
742 additions
and
642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 2 additions & 10 deletions
12
src/main/java/org/jabref/gui/actions/ManageCustomExportsAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialog.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
67 changes: 67 additions & 0 deletions
67
src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
Oops, something went wrong.