-
-
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
Export pdf/linked files #3147
Changes from 32 commits
9d38d12
00eccc7
50e9716
26a7e1f
ec7c44b
68e1562
d1b53eb
7021371
6b02e9c
edec73d
95474ea
bed0a54
e347bc9
090a4cd
93f72b2
353e9ad
f29066c
aa10731
9e6cffc
b61082c
713ecec
cfa74e5
4c01181
cc30b98
a67cd4e
5d96526
8011e6e
bb1a304
5e1117a
8dabe6d
fc7a2a1
ba35360
88faa7c
658d97e
8f14cc7
07ee6ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
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()); | ||
} | ||
} |
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; | ||
} | ||
} |
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; | ||
} | ||
|
||
} |
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() + "]"; | ||
} | ||
} |
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tobiasdiez I have created this wrapper class to inject it There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have a look at it later. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With #3334 you should be able to use |
||
|
||
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 + "]"; | ||
} | ||
|
||
} |
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) ?