Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/org/jabref/gui/DialogService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jabref.gui;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -247,4 +248,12 @@ Optional<ButtonType> showCustomButtonDialogAndWait(Alert.AlertType type, String
*/
boolean showPrintDialog(PrinterJob job);

/**
* Shows a new dialog that list all files contained in the given archive and which lets the user select one of these
* files. The method doesn't return until the displayed open dialog is dismissed. The return value specifies the
* file chosen by the user or an empty {@link Optional} if no selection has been made.
*
* @return the selected file or an empty {@link Optional} if no file has been selected
*/
Optional<Path> showFileOpenFromArchiveDialog(Path archivePath) throws IOException;
}
13 changes: 13 additions & 0 deletions src/main/java/org/jabref/gui/FXDialogService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.jabref.gui;

import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -31,6 +34,7 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.gui.util.ZipFileChooser;
import org.jabref.logic.l10n.Localization;

import org.controlsfx.dialog.ExceptionDialog;
Expand Down Expand Up @@ -300,4 +304,13 @@ private FileChooser getConfiguredFileChooser(FileDialogConfiguration fileDialogC
public boolean showPrintDialog(PrinterJob job) {
return job.showPrintDialog(mainWindow);
}

@Override
public Optional<Path> showFileOpenFromArchiveDialog(Path archivePath) throws IOException {
try (FileSystem zipFile = FileSystems.newFileSystem(archivePath, null)) {
return new ZipFileChooser(zipFile).showAndWait();
} catch (NoClassDefFoundError exc) {
throw new IOException("Could not instantiate ZIP-archive reader.", exc);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ private MenuBar createMenu() {
new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction()),
factory.createMenuItem(StandardActions.MANAGE_CUSTOM_IMPORTS, new ManageCustomImportsAction(this)),
factory.createMenuItem(StandardActions.MANAGE_CUSTOM_IMPORTS, new ManageCustomImportsAction()),
factory.createMenuItem(StandardActions.MANAGE_CUSTOM_EXPORTS, new ManageCustomExportsAction()),
factory.createMenuItem(StandardActions.MANAGE_EXTERNAL_FILETYPES, new EditExternalFileTypesAction()),
factory.createMenuItem(StandardActions.MANAGE_JOURNALS, new ManageJournalsAction()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package org.jabref.gui.actions;

import org.jabref.gui.JabRefFrame;
import org.jabref.gui.importer.ImportCustomizationDialog;

public class ManageCustomImportsAction extends SimpleCommand {

private final JabRefFrame jabRefFrame;

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

@Override
public void execute() {
ImportCustomizationDialog ecd = new ImportCustomizationDialog(jabRefFrame);
ecd.setVisible(true);

new ImportCustomizationDialog().showAndWait();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,13 @@ public ExportCustomizationDialogView() {
.load()
.setAsDialogPane(this);

ControlHelper.setAction(addButton, getDialogPane(), event -> addExporter());
ControlHelper.setAction(modifyButton, getDialogPane(), event -> modifyExporter());
ControlHelper.setAction(removeButton, getDialogPane(), event -> removeExporter());
ControlHelper.setAction(closeButton, getDialogPane(), event -> saveAndClose());
}

private void addExporter() {
viewModel.addExporter();
}

private void modifyExporter() {
viewModel.modifyExporter();
}

private void removeExporter() {
viewModel.removeExporters();
ControlHelper.setAction(addButton, getDialogPane(), event -> viewModel.addExporter());
ControlHelper.setAction(modifyButton, getDialogPane(), event -> viewModel.modifyExporter());
ControlHelper.setAction(removeButton, getDialogPane(), event -> viewModel.removeExporters());
ControlHelper.setAction(closeButton, getDialogPane(), event -> {
viewModel.saveToPrefs();
close();
});
}

@FXML
Expand All @@ -69,9 +60,4 @@ private void initialize() {
layoutColumn.setCellValueFactory(cellData -> cellData.getValue().layoutFileName());
extensionColumn.setCellValueFactory(cellData -> cellData.getValue().extension());
}

private void saveAndClose() {
viewModel.saveToPrefs();
close();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ButtonType?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<DialogPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.171"
fx:controller="org.jabref.gui.importer.ImportCustomizationDialog">
<content>
<TableView fx:id="importerTable">
<columns>
<TableColumn fx:id="nameColumn" prefWidth="150.0" text="%Import name"/>
<TableColumn fx:id="classColumn" prefWidth="100.0" text="%Importer class"/>
<TableColumn fx:id="basePathColumn" prefWidth="100.0" text="%Contained in"/>
</columns>
</TableView>
</content>
<ButtonType fx:id="addButton" text="%Add"/>
<ButtonType fx:id="removeButton" text="%Remove"/>
<ButtonType fx:id="closeButton" fx:constant="OK"/>
<ButtonType fx:constant="CANCEL"/>
</DialogPane>
Loading