-
-
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.
- Loading branch information
1 parent
690def5
commit 3156930
Showing
10 changed files
with
271 additions
and
223 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
25 changes: 0 additions & 25 deletions
25
src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.ComboBox?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.ListView?> | ||
<?import javafx.scene.control.ScrollPane?> | ||
<?import javafx.scene.layout.BorderPane?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import org.controlsfx.control.MasterDetailPane?> | ||
<ScrollPane xmlns:fx="http://javafx.com/fxml/1" fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" | ||
styleClass="fileAnnotationTab" xmlns="http://javafx.com/javafx/8.0.112" | ||
fx:controller="org.jabref.gui.entryeditor.FileAnnotationTabController"> | ||
<MasterDetailPane prefHeight="581.0" prefWidth="488.0"> | ||
<masterNode> | ||
<BorderPane> | ||
<top> | ||
<HBox> | ||
<Label text="%Filename"/> | ||
<ComboBox fx:id="files" maxWidth="Infinity" HBox.hgrow="ALWAYS"/> | ||
</HBox> | ||
</top> | ||
<center> | ||
<ListView fx:id="annotationList"/> | ||
</center> | ||
</BorderPane> | ||
</masterNode> | ||
<detailNode> | ||
|
||
</detailNode> | ||
</MasterDetailPane> | ||
</ScrollPane> |
67 changes: 67 additions & 0 deletions
67
src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.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.entryeditor; | ||
|
||
import javax.inject.Inject; | ||
|
||
import javafx.beans.binding.Bindings; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.ComboBox; | ||
import javafx.scene.control.Control; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.ListView; | ||
import javafx.scene.control.SelectionMode; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.VBox; | ||
import javafx.scene.text.Text; | ||
|
||
import org.jabref.gui.AbstractController; | ||
import org.jabref.gui.util.ViewModelListCellFactory; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.pdf.FileAnnotationCache; | ||
import org.jabref.model.entry.BibEntry; | ||
|
||
public class FileAnnotationTabController extends AbstractController<FileAnnotationTabViewModel> { | ||
|
||
@FXML ComboBox<String> files; | ||
@FXML ListView<FileAnnotationViewModel> annotationList; | ||
|
||
@Inject private FileAnnotationCache fileAnnotationCache; | ||
@Inject private BibEntry entry; | ||
|
||
@FXML | ||
public void initialize() { | ||
viewModel = new FileAnnotationTabViewModel(fileAnnotationCache, entry); | ||
|
||
// Set-up files list | ||
files.getItems().setAll(viewModel.filesProperty().get()); | ||
files.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> viewModel.notifyNewSelectedFile(newValue)); | ||
files.getSelectionModel().selectFirst(); | ||
|
||
// Set-up annotation list | ||
annotationList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); | ||
annotationList.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> viewModel.notifyNewSelectedAnnotation(newValue)); | ||
ViewModelListCellFactory<FileAnnotationViewModel> cellFactory = new ViewModelListCellFactory<FileAnnotationViewModel>() | ||
.withTooltip(FileAnnotationViewModel::getDescription) | ||
.withGraphic(annotation -> { | ||
VBox node = new VBox(); | ||
|
||
Text text = new Text(); | ||
text.setText(annotation.getContent()); | ||
text.getStyleClass().setAll("text"); | ||
|
||
HBox details = new HBox(); | ||
details.getStyleClass().setAll("details"); | ||
Text page = new Text(); | ||
page.setText(Localization.lang("Page: ") + Integer.toString(annotation.getPage())); | ||
Text author = new Text(); | ||
author.setText(Localization.lang("Author: ") + annotation.getAuthor()); | ||
details.getChildren().addAll(page, author); | ||
|
||
node.getChildren().addAll(text, details); | ||
node.setMaxWidth(Control.USE_PREF_SIZE); | ||
return node; | ||
}); | ||
annotationList.setCellFactory(cellFactory); | ||
annotationList.setPlaceholder(new Label(Localization.lang("File has no attached annotations"))); | ||
Bindings.bindContent(annotationList.itemsProperty().get(), viewModel.annotationsProperty()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabView.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,23 @@ | ||
package org.jabref.gui.entryeditor; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
import org.jabref.gui.AbstractView; | ||
import org.jabref.logic.pdf.FileAnnotationCache; | ||
import org.jabref.model.entry.BibEntry; | ||
|
||
public class FileAnnotationTabView extends AbstractView { | ||
|
||
public FileAnnotationTabView(BibEntry entry, FileAnnotationCache fileAnnotationCache) { | ||
super(createContext(entry, fileAnnotationCache)); | ||
} | ||
|
||
private static Function<String, Object> createContext(BibEntry entry, FileAnnotationCache fileAnnotationCache) { | ||
Map<String, Object> context = new HashMap<>(); | ||
context.put("entry", entry); | ||
context.put("fileAnnotationCache", fileAnnotationCache); | ||
return context::get; | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.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,108 @@ | ||
package org.jabref.gui.entryeditor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import javafx.beans.property.ListProperty; | ||
import javafx.beans.property.SimpleListProperty; | ||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
import javafx.collections.FXCollections; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextArea; | ||
import javafx.scene.layout.GridPane; | ||
import javafx.scene.text.Text; | ||
|
||
import org.jabref.gui.AbstractViewModel; | ||
import org.jabref.logic.pdf.FileAnnotationCache; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.pdf.FileAnnotation; | ||
|
||
public class FileAnnotationTabViewModel extends AbstractViewModel { | ||
|
||
private final ListProperty<FileAnnotationViewModel> annotations = new SimpleListProperty<>(FXCollections.observableArrayList()); | ||
private final ListProperty<String> files = new SimpleListProperty<>(FXCollections.observableArrayList()); | ||
private Map<String, List<FileAnnotation>> fileAnnotations; | ||
private StringProperty currentAuthor = new SimpleStringProperty(); | ||
private StringProperty currentPage = new SimpleStringProperty(); | ||
private StringProperty currentDate = new SimpleStringProperty(); | ||
private StringProperty currentContent = new SimpleStringProperty(); | ||
private StringProperty currentMarking = new SimpleStringProperty(); | ||
|
||
public FileAnnotationTabViewModel(FileAnnotationCache cache, BibEntry entry) { | ||
fileAnnotations = cache.getFromCache(entry); | ||
files.addAll(fileAnnotations.keySet()); | ||
} | ||
|
||
public ListProperty<FileAnnotationViewModel> annotationsProperty() { | ||
return annotations; | ||
} | ||
|
||
public ListProperty<String> filesProperty() { | ||
return files; | ||
} | ||
|
||
public void notifyNewSelectedAnnotation(FileAnnotationViewModel newAnnotation) { | ||
/* | ||
currentAuthor.setValue(newValue.getAuthor()); | ||
currentPage.setValue(newValue.getPage()); | ||
currentDate.setValue(newValue.getTimeModified().toString()); | ||
currentContent.setValue(getContentOrNA(newValue.getContent())); | ||
currentMarking.setValue(getMarking(newValue)); | ||
*/ | ||
} | ||
|
||
private GridPane setupRightSide() { | ||
GridPane rightSide = new GridPane(); | ||
|
||
|
||
rightSide.addRow(0, new Label("Author")); | ||
|
||
Text annotationAuthor = new Text(); | ||
annotationAuthor.textProperty().bind(currentAuthor); | ||
rightSide.addColumn(1, annotationAuthor); | ||
|
||
rightSide.addRow(1, new Label("Page")); | ||
Text annotationPage = new Text(); | ||
annotationPage.textProperty().bind(currentPage); | ||
|
||
rightSide.addColumn(1, annotationPage); | ||
|
||
rightSide.addRow(2, new Label("Date")); | ||
Text annotationDate = new Text(); | ||
annotationDate.textProperty().bind(currentDate); | ||
|
||
rightSide.addColumn(1, annotationDate); | ||
|
||
rightSide.addRow(3, new Label("Content")); | ||
TextArea annotationContent = new TextArea(); | ||
|
||
annotationContent.textProperty().bind(currentContent); | ||
annotationContent.setEditable(false); | ||
annotationContent.setWrapText(true); | ||
rightSide.addColumn(1, annotationContent); | ||
|
||
rightSide.addRow(4, new Label("Marking")); | ||
TextArea markingArea = new TextArea(); | ||
markingArea.textProperty().bind(currentMarking); | ||
markingArea.setEditable(false); | ||
markingArea.setWrapText(true); | ||
rightSide.addColumn(1, markingArea); | ||
return rightSide; | ||
} | ||
|
||
public void notifyNewSelectedFile(String newFile) { | ||
Comparator<FileAnnotation> byPage = Comparator.comparingInt(FileAnnotation::getPage); | ||
|
||
List<FileAnnotationViewModel> newAnnotations = fileAnnotations.getOrDefault(newFile, new ArrayList<>()) | ||
.stream() | ||
.filter(annotation -> (null != annotation.getContent())) | ||
.sorted(byPage) | ||
.map(FileAnnotationViewModel::new) | ||
.collect(Collectors.toList()); | ||
annotations.setAll(newAnnotations); | ||
} | ||
} |
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
Oops, something went wrong.