-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export pdf/linked files #3147
Merged
Export pdf/linked files #3147
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
9d38d12
First approach for implementing PDF Exporter
Siedlerchr 00eccc7
First approach for implementing PDF Exporter
Siedlerchr 50e9716
Add to File menu and context menu
Siedlerchr 26a7e1f
Remove separator from tools menu
Siedlerchr ec7c44b
fix fileUtil and localzation from rebase
Siedlerchr 68e1562
Remove empty line
Siedlerchr d1b53eb
Move service to new class
Siedlerchr 7021371
Fix translation
Siedlerchr 6b02e9c
Add idea for list view dialog
Siedlerchr edec73d
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr 95474ea
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr bed0a54
Add TableView to show log message
Siedlerchr e347bc9
Add class for table view data
Siedlerchr 090a4cd
Add Green/Red icons for status
Siedlerchr 93f72b2
fix checkstyle and make cancel button close button
Siedlerchr 353e9ad
fix codacy
Siedlerchr f29066c
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr aa10731
Renamings
Siedlerchr 9e6cffc
Remove setter
Siedlerchr b61082c
Add fxml and move to package
Siedlerchr 713ecec
fix controller
Siedlerchr cfa74e5
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr 4c01181
add button data
Siedlerchr cc30b98
Add new wrapper class for injection
Siedlerchr a67cd4e
Add todos hinting at empty
Siedlerchr 5d96526
Fix injection of data
Siedlerchr 8011e6e
rebame and fix checkstyle
Siedlerchr bb1a304
Make variables private
Siedlerchr 5e1117a
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr 8dabe6d
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr fc7a2a1
fix merge error in lang files
Siedlerchr ba35360
Fix some coday warnings
Siedlerchr 88faa7c
Rename l10n
Siedlerchr 658d97e
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr 8f14cc7
fix showing of progress bar
Siedlerchr 07ee6ea
Merge branch 'exportPdf' of https://github.com/JabRef/jabref into exp…
Siedlerchr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
70 changes: 70 additions & 0 deletions
70
src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.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,70 @@ | ||
package org.jabref.gui.copyfiles; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import javax.swing.AbstractAction; | ||
|
||
import javafx.concurrent.Task; | ||
|
||
import org.jabref.Globals; | ||
import org.jabref.JabRefExecutorService; | ||
import org.jabref.JabRefGUI; | ||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.FXDialogService; | ||
import org.jabref.gui.util.DefaultTaskExecutor; | ||
import org.jabref.gui.util.DirectoryDialogConfiguration; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.preferences.JabRefPreferences; | ||
|
||
public class CopyFilesAction extends AbstractAction { | ||
|
||
private final DialogService dialogService = new FXDialogService(); | ||
private BibDatabaseContext databaseContext; | ||
private List<BibEntry> entries; | ||
|
||
public CopyFilesAction() { | ||
super(Localization.lang("Copy linked files to folder...")); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
|
||
DirectoryDialogConfiguration dirDialogConfiguration = new DirectoryDialogConfiguration.Builder() | ||
.withInitialDirectory(Paths.get(Globals.prefs.get(JabRefPreferences.EXPORT_WORKING_DIRECTORY))) | ||
.build(); | ||
entries = JabRefGUI.getMainFrame().getCurrentBasePanel().getSelectedEntries(); | ||
|
||
Optional<Path> exportPath = DefaultTaskExecutor | ||
.runInJavaFXThread(() -> dialogService.showDirectorySelectionDialog(dirDialogConfiguration)); | ||
|
||
exportPath.ifPresent(path -> { | ||
databaseContext = JabRefGUI.getMainFrame().getCurrentBasePanel().getDatabaseContext(); | ||
|
||
Task<List<CopyFilesResultItemViewModel>> exportTask = new CopyFilesTask(databaseContext, entries, path); | ||
startServiceAndshowProgessDialog(exportTask); | ||
}); | ||
} | ||
|
||
private void startServiceAndshowProgessDialog(Task<List<CopyFilesResultItemViewModel>> exportService) { | ||
DefaultTaskExecutor.runInJavaFXThread(() -> { | ||
exportService.setOnSucceeded(value -> { | ||
DefaultTaskExecutor.runInJavaFXThread(() -> showDialog(exportService.getValue())); | ||
|
||
}); | ||
JabRefExecutorService.INSTANCE.executeInterruptableTask(exportService); | ||
dialogService.showCanceableProgressDialogAndWait(exportService); | ||
|
||
}); | ||
} | ||
|
||
private void showDialog(List<CopyFilesResultItemViewModel> data) { | ||
CopyFilesDialogView dlg = new CopyFilesDialogView(databaseContext, new CopyFilesResultListDependency(data)); | ||
dlg.show(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/org/jabref/gui/copyfiles/CopyFilesDialogController.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,59 @@ | ||
package org.jabref.gui.copyfiles; | ||
|
||
import javax.inject.Inject; | ||
|
||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.text.Text; | ||
|
||
import org.jabref.gui.AbstractController; | ||
import org.jabref.gui.util.ValueTableCellFactory; | ||
|
||
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; | ||
import de.jensd.fx.glyphs.materialdesignicons.utils.MaterialDesignIconFactory; | ||
|
||
public class CopyFilesDialogController extends AbstractController<CopyFilesDialogViewModel> { | ||
|
||
@FXML private TableView<CopyFilesResultItemViewModel> tvResult; | ||
@FXML private TableColumn<CopyFilesResultItemViewModel, MaterialDesignIcon> colStatus; | ||
@FXML private TableColumn<CopyFilesResultItemViewModel, String> colMessage; | ||
@FXML private TableColumn<CopyFilesResultItemViewModel, String> colFile; | ||
|
||
@Inject private CopyFilesResultListDependency copyfilesresultlistDependency; //This var must have the same name as the key in the View | ||
|
||
@FXML | ||
private void close(@SuppressWarnings("unused") ActionEvent event) { | ||
getStage().close(); | ||
} | ||
|
||
@FXML | ||
private void initialize() { | ||
viewModel = new CopyFilesDialogViewModel(copyfilesresultlistDependency); | ||
setupTable(); | ||
} | ||
|
||
private void setupTable() { | ||
colFile.setCellValueFactory(cellData -> cellData.getValue().getFile()); | ||
colMessage.setCellValueFactory(cellData -> cellData.getValue().getMessage()); | ||
colStatus.setCellValueFactory(cellData -> cellData.getValue().getIcon()); | ||
|
||
colFile.setCellFactory(new ValueTableCellFactory<CopyFilesResultItemViewModel, String>().withText(item -> item).withTooltip(item -> item)); | ||
colStatus.setCellFactory(new ValueTableCellFactory<CopyFilesResultItemViewModel, MaterialDesignIcon>().withGraphic(item -> { | ||
|
||
Text icon = MaterialDesignIconFactory.get().createIcon(item); | ||
if (item == MaterialDesignIcon.CHECK) { | ||
icon.setFill(Color.GREEN); | ||
} | ||
if (item == MaterialDesignIcon.ALERT) { | ||
icon.setFill(Color.RED); | ||
} | ||
return icon; | ||
})); | ||
|
||
tvResult.setItems(viewModel.copyFilesResultListProperty()); | ||
tvResult.setColumnResizePolicy((param) -> true); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/org/jabref/gui/copyfiles/CopyFilesDialogView.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,36 @@ | ||
package org.jabref.gui.copyfiles; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
import javafx.scene.control.Alert.AlertType; | ||
import javafx.scene.control.DialogPane; | ||
|
||
import org.jabref.gui.AbstractDialogView; | ||
import org.jabref.gui.FXDialog; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
|
||
public class CopyFilesDialogView extends AbstractDialogView { | ||
|
||
public CopyFilesDialogView(BibDatabaseContext bibDatabaseContext, CopyFilesResultListDependency results) { | ||
super(createContext(bibDatabaseContext, results)); | ||
} | ||
|
||
@Override | ||
public void show() { | ||
FXDialog copyFilesResultDlg = new FXDialog(AlertType.INFORMATION, Localization.lang("Result")); | ||
copyFilesResultDlg.setResizable(true); | ||
copyFilesResultDlg.setDialogPane((DialogPane) this.getView()); | ||
copyFilesResultDlg.show(); | ||
} | ||
|
||
private static Function<String, Object> createContext(BibDatabaseContext bibDatabaseContext, CopyFilesResultListDependency copyfilesresultlistDependency) { | ||
Map<String, Object> context = new HashMap<>(); | ||
//The "keys" of the HashMap must have the same name as the with @inject annotated field in the controller | ||
context.put("bibdatabasecontext", bibDatabaseContext); | ||
context.put("copyfilesresultlistDependency", copyfilesresultlistDependency); | ||
return context::get; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/org/jabref/gui/copyfiles/CopyFilesDialogViewModel.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,21 @@ | ||
package org.jabref.gui.copyfiles; | ||
|
||
import javafx.beans.property.SimpleListProperty; | ||
import javafx.collections.FXCollections; | ||
|
||
import org.jabref.gui.AbstractViewModel; | ||
|
||
public class CopyFilesDialogViewModel extends AbstractViewModel { | ||
|
||
private final SimpleListProperty<CopyFilesResultItemViewModel> copyFilesResultItems = new SimpleListProperty<>( | ||
FXCollections.observableArrayList()); | ||
|
||
public CopyFilesDialogViewModel(CopyFilesResultListDependency results) { | ||
copyFilesResultItems.addAll(results.getResults()); | ||
} | ||
|
||
public SimpleListProperty<CopyFilesResultItemViewModel> copyFilesResultListProperty() { | ||
return this.copyFilesResultItems; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/org/jabref/gui/copyfiles/CopyFilesResultItemViewModel.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,42 @@ | ||
package org.jabref.gui.copyfiles; | ||
|
||
import java.nio.file.Path; | ||
|
||
import javafx.beans.property.ObjectProperty; | ||
import javafx.beans.property.SimpleObjectProperty; | ||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
|
||
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; | ||
|
||
public class CopyFilesResultItemViewModel { | ||
|
||
private final StringProperty file = new SimpleStringProperty(""); | ||
private final ObjectProperty<MaterialDesignIcon> icon = new SimpleObjectProperty<>(MaterialDesignIcon.ALERT); | ||
private final StringProperty message = new SimpleStringProperty(""); | ||
|
||
public CopyFilesResultItemViewModel(Path file, boolean success, String message) { | ||
this.file.setValue(file.toString()); | ||
this.message.setValue(message); | ||
if (success) { | ||
this.icon.setValue(MaterialDesignIcon.CHECK); | ||
} | ||
} | ||
|
||
public StringProperty getFile() { | ||
return file; | ||
} | ||
|
||
public StringProperty getMessage() { | ||
return message; | ||
} | ||
|
||
public ObjectProperty<MaterialDesignIcon> getIcon() { | ||
return icon; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CopyFilesResultItemViewModel [file=" + file.get() + ", message=" + message.get() + "]"; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/org/jabref/gui/copyfiles/CopyFilesResultListDependency.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,31 @@ | ||
package org.jabref.gui.copyfiles; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* This class is a wrapper class for the containing list as it is currently not possible to inject complex object types into FXML controller | ||
* | ||
*/ | ||
public class CopyFilesResultListDependency { | ||
|
||
private List<CopyFilesResultItemViewModel> results = new ArrayList<>(); | ||
|
||
public CopyFilesResultListDependency() { | ||
//empty, workaround for injection into FXML controller | ||
} | ||
|
||
public CopyFilesResultListDependency(List<CopyFilesResultItemViewModel> results) { | ||
this.results = results; | ||
} | ||
|
||
public List<CopyFilesResultItemViewModel> getResults() { | ||
return results; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CopyFilesResultListDependency [results=" + results + "]"; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way to prevent that fourth column appearing #3147 (comment) ?