Skip to content
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
merged 36 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9d38d12
First approach for implementing PDF Exporter
Siedlerchr Apr 2, 2017
00eccc7
First approach for implementing PDF Exporter
Siedlerchr Oct 7, 2017
50e9716
Add to File menu and context menu
Siedlerchr Oct 7, 2017
26a7e1f
Remove separator from tools menu
Siedlerchr Oct 7, 2017
ec7c44b
fix fileUtil and localzation from rebase
Siedlerchr Oct 7, 2017
68e1562
Remove empty line
Siedlerchr Oct 7, 2017
d1b53eb
Move service to new class
Siedlerchr Oct 8, 2017
7021371
Fix translation
Siedlerchr Oct 8, 2017
6b02e9c
Add idea for list view dialog
Siedlerchr Oct 8, 2017
edec73d
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr Oct 11, 2017
95474ea
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr Oct 19, 2017
bed0a54
Add TableView to show log message
Siedlerchr Oct 19, 2017
e347bc9
Add class for table view data
Siedlerchr Oct 19, 2017
090a4cd
Add Green/Red icons for status
Siedlerchr Oct 19, 2017
93f72b2
fix checkstyle and make cancel button close button
Siedlerchr Oct 19, 2017
353e9ad
fix codacy
Siedlerchr Oct 20, 2017
f29066c
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr Oct 20, 2017
aa10731
Renamings
Siedlerchr Oct 20, 2017
9e6cffc
Remove setter
Siedlerchr Oct 20, 2017
b61082c
Add fxml and move to package
Siedlerchr Oct 20, 2017
713ecec
fix controller
Siedlerchr Oct 20, 2017
cfa74e5
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr Oct 21, 2017
4c01181
add button data
Siedlerchr Oct 21, 2017
cc30b98
Add new wrapper class for injection
Siedlerchr Oct 21, 2017
a67cd4e
Add todos hinting at empty
Siedlerchr Oct 21, 2017
5d96526
Fix injection of data
Siedlerchr Oct 21, 2017
8011e6e
rebame and fix checkstyle
Siedlerchr Oct 21, 2017
bb1a304
Make variables private
Siedlerchr Oct 21, 2017
5e1117a
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr Oct 22, 2017
8dabe6d
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr Oct 25, 2017
fc7a2a1
fix merge error in lang files
Siedlerchr Oct 25, 2017
ba35360
Fix some coday warnings
Siedlerchr Oct 25, 2017
88faa7c
Rename l10n
Siedlerchr Oct 26, 2017
658d97e
Merge remote-tracking branch 'upstream/master' into exportPdf
Siedlerchr Oct 31, 2017
8f14cc7
fix showing of progress bar
Siedlerchr Oct 31, 2017
07ee6ea
Merge branch 'exportPdf' of https://github.com/JabRef/jabref into exp…
Siedlerchr Oct 31, 2017
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
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/AbstractDialogView.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package org.jabref.gui;

import java.util.function.Function;

public abstract class AbstractDialogView extends AbstractView {

public AbstractDialogView() {
super();
}

public AbstractDialogView(Function<String, Object> injectionContext) {
super(injectionContext);
}

public abstract void show();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/DefaultInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private static Object createDependency(Class<?> clazz) {
return Globals.journalAbbreviationLoader;
} else if (clazz == StateManager.class) {
return Globals.stateManager;

} else {
try {
return clazz.newInstance();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
package org.jabref.gui.copyfiles;

import java.util.List;

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 org.jabref.model.database.BibDatabaseContext;

import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.utils.MaterialDesignIconFactory;

public class CopyFilesDialogController extends AbstractController<CopyFilesDialogViewModel> {

Expand All @@ -15,13 +25,35 @@ public class CopyFilesDialogController extends AbstractController<CopyFilesDialo
@FXML private TableColumn<CopyFilesResultItemViewModel, String> colMessage;
@FXML private TableColumn<CopyFilesResultItemViewModel, String> colFile;

@Inject private CopyFilesResultListDependency results;
@Inject private BibDatabaseContext bibdatabasecontext;

@FXML
void close(ActionEvent event) {
getStage().close();
}

@FXML
private void initialize() {
viewModel = new CopyFilesDialogViewModel();
viewModel = new CopyFilesDialogViewModel(results, bibdatabasecontext);
setupTable();
}

private void setupTable() {
colFile.setCellValueFactory(cellData -> cellData.getValue().getFile());
colMessage.setCellValueFactory(cellData -> cellData.getValue().getMessage());
colStatus.setCellValueFactory(cellData -> cellData.getValue().getIcon());

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;
}));
}
}
15 changes: 15 additions & 0 deletions src/main/java/org/jabref/gui/copyfiles/CopyFilesDialogView.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
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"));
Expand All @@ -17,4 +26,10 @@ public void show() {
copyFilesResultDlg.show();
}

private static Function<String, Object> createContext(BibDatabaseContext bibDatabaseContext, CopyFilesResultListDependency results) {
Map<String, Object> context = new HashMap<>();
context.put("bibdatabasecontext", bibDatabaseContext);
context.put("copyfilesresultltlistdependency", results);
return context::get;
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package org.jabref.gui.copyfiles;

import java.util.List;

import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;

import org.jabref.gui.AbstractViewModel;
import org.jabref.model.database.BibDatabaseContext;

public class CopyFilesDialogViewModel extends AbstractViewModel {

private final SimpleListProperty<CopyFilesResultItemViewModel> copyFilesResultItems = new SimpleListProperty<>(
FXCollections.observableArrayList());

//TODO: How do I add the data here?
public CopyFilesDialogViewModel(List<CopyFilesResultItemViewModel> items) {

this.copyFilesResultItems.addAll(items);
}
public CopyFilesDialogViewModel(CopyFilesResultListDependency results, BibDatabaseContext bibdatabasecontext) {

public CopyFilesDialogViewModel() {
// TODO Auto-generated constructor stub
copyFilesResultItems.addAll(results.getResults());
}

public SimpleListProperty<CopyFilesResultItemViewModel> abbreviationsProperty() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.jabref.gui.copyfiles;

import java.util.ArrayList;
import java.util.List;

public class CopyFilesResultListDependency {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobiasdiez I have created this wrapper class to inject it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I dont' intilaize the ArrayList with Empty, it will give an NPE in my View Model which leads to the conclusion that this are somehow different objects. I remember having similair problems wit the Sharelatex Integration and ended up making it static. But maybe there is another solution?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh damn...thats ugly. It is not possible to directly inject the list of results?
You also hit this bug here: AdamBien/afterburner.fx#71 this is why you need the no-arg constructor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look at it later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list can not be directly injected, because List is an interface which of course can not be instantiated...that's where our default injector throws an error
I tried to add handling for list but then generics are a problem...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobiasdiez I found the issue. The "key" of the Hashmap and the name of the with inject annotated variable differed! That's why the data was not passed correct

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #3334 you should be able to use @Inject List<whatever> toBeInjected or other complex types (they do not need to have a no-args constructor anymore). Of course the names of the "key" and the "field" have to coincide to make this work.


private List<CopyFilesResultItemViewModel> results = new ArrayList<>();

public CopyFilesResultListDependency() {
//empty
}

public CopyFilesResultListDependency(List<CopyFilesResultItemViewModel> results) {
this.results = results;
}

public List<CopyFilesResultItemViewModel> getResults() {
return results;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

import javax.swing.AbstractAction;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.paint.Color;
Expand Down Expand Up @@ -76,7 +71,11 @@ private void startServiceAndshowProgessDialog(Task<List<CopyFilesResultItemViewM
}

private void showDialog(List<CopyFilesResultItemViewModel> data) {
Dialog<ButtonType> dlg = new Dialog<>();

CopyFilesDialogView dlg = new CopyFilesDialogView(databaseContext, new CopyFilesResultListDependency(data));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobiasdiez Here I am passing the instance of the object, but it doesn't display any data.

dlg.show();

/*Dialog<ButtonType> dlg = new Dialog<>();
dlg.setTitle(Localization.lang("Result"));
ObservableList<CopyFilesResultItemViewModel> tableData = FXCollections.observableArrayList(data);

Expand All @@ -93,6 +92,7 @@ private void showDialog(List<CopyFilesResultItemViewModel> data) {
dlg.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
dlg.setResizable(true);
dlg.showAndWait();
*/
}

private static TableView<CopyFilesResultItemViewModel> createTable() {
Expand Down