From 86e584d4cdf518b0dd1999a0cbdcc916e19790e6 Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Wed, 12 Jul 2017 22:56:05 +0200 Subject: [PATCH 01/21] Initial class creation --- .../jabref/gui/entryeditor/EntryEditor.java | 1 + .../gui/entryeditor/FxFileAnnotationTab.java | 78 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 282d3099d01..efbe159c34d 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -274,6 +274,7 @@ private void addTabs() { // Special tabs tabs.add(new MathSciNetTab(entry)); tabs.add(new FileAnnotationTab(entry, this, panel.getAnnotationCache())); + tabs.add(new FxFileAnnotationTab(frame, panel, this, panel.getAnnotationCache())); tabs.add(new RelatedArticlesTab(entry)); // Source tab diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java new file mode 100644 index 00000000000..358d2966977 --- /dev/null +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -0,0 +1,78 @@ +package org.jabref.gui.entryeditor; + +import javafx.scene.control.ScrollPane; +import javafx.scene.control.Tooltip; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.Region; + +import org.jabref.gui.BasePanel; +import org.jabref.gui.IconTheme; +import org.jabref.gui.JabRefFrame; +import org.jabref.gui.fieldeditors.FieldEditorFX; +import org.jabref.logic.l10n.Localization; +import org.jabref.logic.pdf.FileAnnotationCache; +import org.jabref.model.entry.FieldName; + +public class FxFileAnnotationTab extends EntryEditorTab { + private final Region panel; + + private final EntryEditor parent; + private final JabRefFrame frame; + private final BasePanel basePanel; + private final FileAnnotationCache cache; + private FieldEditorFX activeField; + + public FxFileAnnotationTab(JabRefFrame frame, BasePanel basePanel, EntryEditor parent, FileAnnotationCache cache) { + this.parent = parent; + this.frame = frame; + this.basePanel = basePanel; + + this.panel = setupPanel(frame, basePanel); + this.cache = cache; + setText(Localization.lang("File annotations NEW")); // TODO: rename in "File annotations" + setTooltip(new Tooltip(Localization.lang("Show file annotations"))); + setGraphic(IconTheme.JabRefIcon.REQUIRED.getGraphicNode()); + } + + private Region setupPanel(JabRefFrame frame, BasePanel basePanel) { + GridPane gridPane = new GridPane(); + gridPane.getStyleClass().add("editorPane"); + + ColumnConstraints columnExpand = new ColumnConstraints(); + columnExpand.setHgrow(Priority.ALWAYS); + + ColumnConstraints columnDoNotContract = new ColumnConstraints(); + columnDoNotContract.setMinWidth(Region.USE_PREF_SIZE); + + // TODO: actual content + + // Warp everything in a scroll-pane + ScrollPane scrollPane = new ScrollPane(); + scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); + scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); + scrollPane.setContent(gridPane); + scrollPane.setFitToWidth(true); + scrollPane.setFitToHeight(true); + return scrollPane; + } + + @Override + public boolean shouldShow() { + return parent.getEntry().getField(FieldName.FILE).isPresent(); + } + + + @Override + public void requestFocus() { + if (activeField != null) { + activeField.requestFocus(); + } + } + + @Override + protected void initialize() { + setContent(panel); + } +} From 7ee22de7053ec4663f29cb985a583f14aa37a291 Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Fri, 14 Jul 2017 00:53:32 +0200 Subject: [PATCH 02/21] Add content placeholders --- .../gui/entryeditor/FxFileAnnotationTab.java | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java index 358d2966977..e328db272ae 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -1,10 +1,10 @@ package org.jabref.gui.entryeditor; +import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; import javafx.scene.control.Tooltip; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; -import javafx.scene.layout.Priority; import javafx.scene.layout.Region; import org.jabref.gui.BasePanel; @@ -31,7 +31,7 @@ public FxFileAnnotationTab(JabRefFrame frame, BasePanel basePanel, EntryEditor p this.panel = setupPanel(frame, basePanel); this.cache = cache; - setText(Localization.lang("File annotations NEW")); // TODO: rename in "File annotations" + setText(Localization.lang("File annotations")); // TODO: rename in "File annotations" setTooltip(new Tooltip(Localization.lang("Show file annotations"))); setGraphic(IconTheme.JabRefIcon.REQUIRED.getGraphicNode()); } @@ -39,14 +39,12 @@ public FxFileAnnotationTab(JabRefFrame frame, BasePanel basePanel, EntryEditor p private Region setupPanel(JabRefFrame frame, BasePanel basePanel) { GridPane gridPane = new GridPane(); gridPane.getStyleClass().add("editorPane"); + ColumnConstraints leftSideConstraint = new ColumnConstraints(); + leftSideConstraint.setPercentWidth(50); + gridPane.getColumnConstraints().addAll(leftSideConstraint); - ColumnConstraints columnExpand = new ColumnConstraints(); - columnExpand.setHgrow(Priority.ALWAYS); - - ColumnConstraints columnDoNotContract = new ColumnConstraints(); - columnDoNotContract.setMinWidth(Region.USE_PREF_SIZE); - - // TODO: actual content + gridPane.addColumn(0, setupLeftSide()); + gridPane.addColumn(1, setupRightSide()); // Warp everything in a scroll-pane ScrollPane scrollPane = new ScrollPane(); @@ -58,12 +56,31 @@ private Region setupPanel(JabRefFrame frame, BasePanel basePanel) { return scrollPane; } + private GridPane setupRightSide() { + GridPane rightSide = new GridPane(); + + rightSide.addRow(0, new Label("Author")); + rightSide.addRow(1, new Label("date")); + + rightSide.addRow(2, new Label("page")); + rightSide.addRow(3, new Label("content")); + + rightSide.addRow(4, new Label("highlight")); + return rightSide; + } + + private GridPane setupLeftSide() { + GridPane leftSide = new GridPane(); + leftSide.addRow(0, new Label("filename")); + leftSide.addRow(1, new Label("AnnotationsList")); + return leftSide; + } + @Override public boolean shouldShow() { return parent.getEntry().getField(FieldName.FILE).isPresent(); } - @Override public void requestFocus() { if (activeField != null) { From 11e0e629dd92de2ad37ac9380e92088a6317549e Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Thu, 3 Aug 2017 09:14:51 +0200 Subject: [PATCH 03/21] Add FileCombobox --- .../jabref/gui/entryeditor/EntryEditor.java | 6 ++++-- .../gui/entryeditor/FxFileAnnotationTab.java | 21 +++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index d6031875a0c..cfcb0ec675d 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -69,6 +69,7 @@ import org.jabref.logic.importer.EntryBasedFetcher; import org.jabref.logic.importer.WebFetchers; import org.jabref.logic.l10n.Localization; +import org.jabref.logic.pdf.FileAnnotationCache; import org.jabref.logic.search.SearchQueryHighlightListener; import org.jabref.logic.util.UpdateField; import org.jabref.model.EntryTypes; @@ -276,8 +277,9 @@ private void addTabs(String lastTabName) { // Special tabs tabs.add(new MathSciNetTab(entry)); - tabs.add(new FileAnnotationTab(entry, this, panel.getAnnotationCache())); - tabs.add(new FxFileAnnotationTab(frame, panel, this, panel.getAnnotationCache())); + FileAnnotationCache annotationCache = panel.getAnnotationCache(); + tabs.add(new FileAnnotationTab(entry, this, annotationCache)); + tabs.add(new FxFileAnnotationTab(frame, panel, this, annotationCache)); tabs.add(new RelatedArticlesTab(entry)); // Source tab diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java index e328db272ae..a9fda0de667 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -1,5 +1,10 @@ package org.jabref.gui.entryeditor; +import java.util.List; +import java.util.Map; + +import javafx.collections.FXCollections; +import javafx.scene.control.ComboBox; import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; import javafx.scene.control.Tooltip; @@ -14,6 +19,7 @@ import org.jabref.logic.l10n.Localization; import org.jabref.logic.pdf.FileAnnotationCache; import org.jabref.model.entry.FieldName; +import org.jabref.model.pdf.FileAnnotation; public class FxFileAnnotationTab extends EntryEditorTab { private final Region panel; @@ -28,9 +34,9 @@ public FxFileAnnotationTab(JabRefFrame frame, BasePanel basePanel, EntryEditor p this.parent = parent; this.frame = frame; this.basePanel = basePanel; + this.cache = cache; this.panel = setupPanel(frame, basePanel); - this.cache = cache; setText(Localization.lang("File annotations")); // TODO: rename in "File annotations" setTooltip(new Tooltip(Localization.lang("Show file annotations"))); setGraphic(IconTheme.JabRefIcon.REQUIRED.getGraphicNode()); @@ -71,11 +77,22 @@ private GridPane setupRightSide() { private GridPane setupLeftSide() { GridPane leftSide = new GridPane(); - leftSide.addRow(0, new Label("filename")); + + leftSide.addColumn(0, new Label("Filename")); + leftSide.addRow(0, createFileNameComboBox()); + leftSide.addRow(1, new Label("AnnotationsList")); return leftSide; } + private ComboBox createFileNameComboBox() { + final Map> fileAnnotations = cache.getFromCache(parent.getEntry()); + + ComboBox comboBox = new ComboBox<>(FXCollections.observableArrayList(fileAnnotations.keySet())); + comboBox.getSelectionModel().selectFirst(); + return comboBox; + } + @Override public boolean shouldShow() { return parent.getEntry().getField(FieldName.FILE).isPresent(); From ac9d4c9ad353e01fd2e6e641d9cb63b0b7f45de6 Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Thu, 3 Aug 2017 14:52:47 +0200 Subject: [PATCH 04/21] Add Annotation List --- .../FileAnnotationListCellRenderer.java | 25 +++++++++++ .../gui/entryeditor/FxFileAnnotationTab.java | 44 +++++++++++++++++-- 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java new file mode 100644 index 00000000000..2d0a62fce68 --- /dev/null +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java @@ -0,0 +1,25 @@ +package org.jabref.gui.entryeditor; + +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.util.Callback; + +import org.jabref.model.pdf.FileAnnotation; + +public class FileAnnotationListCellRenderer implements Callback, ListCell> { + + + @Override + public ListCell call(ListView param) { + + return new ListCell() { + @Override + protected void updateItem(FileAnnotation t, boolean bln) { + super.updateItem(t, bln); + if (t != null) { + setText(t.getContent()); + } + } + }; + } +} diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java index a9fda0de667..3c1bac25767 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -1,11 +1,16 @@ package org.jabref.gui.entryeditor; +import java.time.LocalDateTime; +import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Optional; import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; +import javafx.scene.control.ListView; import javafx.scene.control.ScrollPane; import javafx.scene.control.Tooltip; import javafx.scene.layout.ColumnConstraints; @@ -21,6 +26,8 @@ import org.jabref.model.entry.FieldName; import org.jabref.model.pdf.FileAnnotation; +import static org.jabref.model.pdf.FileAnnotationType.NONE; + public class FxFileAnnotationTab extends EntryEditorTab { private final Region panel; @@ -29,12 +36,15 @@ public class FxFileAnnotationTab extends EntryEditorTab { private final BasePanel basePanel; private final FileAnnotationCache cache; private FieldEditorFX activeField; + private Map> fileAnnotations; + private ObservableList fileAnnotationsList = FXCollections.observableArrayList(); public FxFileAnnotationTab(JabRefFrame frame, BasePanel basePanel, EntryEditor parent, FileAnnotationCache cache) { this.parent = parent; this.frame = frame; this.basePanel = basePanel; this.cache = cache; + fileAnnotations = cache.getFromCache(parent.getEntry()); this.panel = setupPanel(frame, basePanel); setText(Localization.lang("File annotations")); // TODO: rename in "File annotations" @@ -79,14 +89,42 @@ private GridPane setupLeftSide() { GridPane leftSide = new GridPane(); leftSide.addColumn(0, new Label("Filename")); - leftSide.addRow(0, createFileNameComboBox()); + ComboBox fileNameComboBox = createFileNameComboBox(); + leftSide.addRow(0, fileNameComboBox); + + leftSide.addRow(1, createFileAnnotationsList()); + updateShownAnnotations(fileAnnotations.get(fileNameComboBox.getSelectionModel().getSelectedItem())); - leftSide.addRow(1, new Label("AnnotationsList")); return leftSide; } + private ListView createFileAnnotationsList() { + ListView listView = new ListView<>(); + listView.setItems(fileAnnotationsList); + + listView.setCellFactory(new FileAnnotationListCellRenderer()); + return listView; + } + + /** + * Updates the list model to show the given notes without those with no content + * + * @param annotations value is the annotation name and the value is a pdfAnnotation object to add to the list model + */ + private void updateShownAnnotations(List annotations) { + fileAnnotationsList.clear(); + if (annotations == null || annotations.isEmpty()) { + fileAnnotationsList.add(new FileAnnotation("", LocalDateTime.now(), 0, Localization.lang("File has no attached annotations"), NONE, Optional.empty())); + } else { + Comparator byPage = Comparator.comparingInt(FileAnnotation::getPage); + annotations.stream() + .filter(annotation -> (null != annotation.getContent())) + .sorted(byPage) + .forEach(annotation -> fileAnnotationsList.add(new FileAnnotationViewModel(annotation))); + } + } + private ComboBox createFileNameComboBox() { - final Map> fileAnnotations = cache.getFromCache(parent.getEntry()); ComboBox comboBox = new ComboBox<>(FXCollections.observableArrayList(fileAnnotations.keySet())); comboBox.getSelectionModel().selectFirst(); From abe76f9802eff0cdbd033ee56b1e63f1462aee3f Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Mon, 7 Aug 2017 17:03:50 +0200 Subject: [PATCH 05/21] Listview expands --- .../org/jabref/gui/entryeditor/FxFileAnnotationTab.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java index 3c1bac25767..8cec0a1a1a0 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -15,6 +15,7 @@ import javafx.scene.control.Tooltip; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; import javafx.scene.layout.Region; import org.jabref.gui.BasePanel; @@ -76,6 +77,8 @@ private GridPane setupRightSide() { GridPane rightSide = new GridPane(); rightSide.addRow(0, new Label("Author")); + + rightSide.addRow(1, new Label("date")); rightSide.addRow(2, new Label("page")); @@ -90,9 +93,11 @@ private GridPane setupLeftSide() { leftSide.addColumn(0, new Label("Filename")); ComboBox fileNameComboBox = createFileNameComboBox(); + GridPane.setHgrow(fileNameComboBox, Priority.ALWAYS); + leftSide.addRow(0, fileNameComboBox); - leftSide.addRow(1, createFileAnnotationsList()); + leftSide.add(createFileAnnotationsList(), 0, 1, 2, 1); updateShownAnnotations(fileAnnotations.get(fileNameComboBox.getSelectionModel().getSelectedItem())); return leftSide; @@ -101,6 +106,7 @@ private GridPane setupLeftSide() { private ListView createFileAnnotationsList() { ListView listView = new ListView<>(); listView.setItems(fileAnnotationsList); + GridPane.setHgrow(listView, Priority.ALWAYS); listView.setCellFactory(new FileAnnotationListCellRenderer()); return listView; From 690def58b2f73e40a23c3ddfdc68b88c5b3c9675 Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Mon, 7 Aug 2017 19:26:37 +0200 Subject: [PATCH 06/21] Minimal viable product of the fxfileannotationtab --- .../gui/entryeditor/FxFileAnnotationTab.java | 81 +++++++++++++++++-- 1 file changed, 74 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java index 8cec0a1a1a0..ea6546f0394 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -6,17 +6,24 @@ import java.util.Map; import java.util.Optional; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.ScrollPane; +import javafx.scene.control.SelectionMode; +import javafx.scene.control.TextArea; import javafx.scene.control.Tooltip; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; import javafx.scene.layout.Priority; import javafx.scene.layout.Region; +import javafx.scene.text.Text; import org.jabref.gui.BasePanel; import org.jabref.gui.IconTheme; @@ -40,6 +47,13 @@ public class FxFileAnnotationTab extends EntryEditorTab { private Map> fileAnnotations; private ObservableList fileAnnotationsList = FXCollections.observableArrayList(); + + 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 FxFileAnnotationTab(JabRefFrame frame, BasePanel basePanel, EntryEditor parent, FileAnnotationCache cache) { this.parent = parent; this.frame = frame; @@ -76,18 +90,49 @@ private Region setupPanel(JabRefFrame frame, BasePanel basePanel) { 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.addRow(1, new Label("date")); + rightSide.addColumn(1, annotationPage); - rightSide.addRow(2, new Label("page")); - rightSide.addRow(3, new Label("content")); + rightSide.addRow(2, new Label("Date")); + Text annotationDate = new Text(); + annotationDate.textProperty().bind(currentDate); - rightSide.addRow(4, new Label("highlight")); + 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; } + private String getMarking(FileAnnotation annotation) { + if (annotation.hasLinkedAnnotation()) { + return getContentOrNA(annotation.getLinkedFileAnnotation().getContent()); + } + return "N/A"; + } + private GridPane setupLeftSide() { GridPane leftSide = new GridPane(); @@ -97,21 +142,43 @@ private GridPane setupLeftSide() { leftSide.addRow(0, fileNameComboBox); - leftSide.add(createFileAnnotationsList(), 0, 1, 2, 1); - updateShownAnnotations(fileAnnotations.get(fileNameComboBox.getSelectionModel().getSelectedItem())); + ListView listView = createFileAnnotationsList(fileNameComboBox); + leftSide.add(listView, 0, 1, 2, 1); return leftSide; } - private ListView createFileAnnotationsList() { + private ListView createFileAnnotationsList(ComboBox fileNameComboBox) { ListView listView = new ListView<>(); listView.setItems(fileAnnotationsList); + listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + listView.getSelectionModel().selectedItemProperty().addListener( + new ChangeListener() { + @Override + public void changed(ObservableValue ov, FileAnnotation t, FileAnnotation newFA) { + currentAuthor.setValue(listView.getSelectionModel().getSelectedItem().getAuthor()); + currentPage.setValue(Integer.toString(listView.getSelectionModel().getSelectedItem().getPage())); + currentDate.setValue(listView.getSelectionModel().getSelectedItem().getTimeModified().toString()); + currentContent.setValue(getContentOrNA(listView.getSelectionModel().getSelectedItem().getContent())); + currentMarking.setValue(getMarking(listView.getSelectionModel().getSelectedItem())); + } + } + ); GridPane.setHgrow(listView, Priority.ALWAYS); listView.setCellFactory(new FileAnnotationListCellRenderer()); + updateShownAnnotations(fileAnnotations.get(fileNameComboBox.getSelectionModel().getSelectedItem())); return listView; } + private String getContentOrNA(String content) { + if (content.isEmpty()) { + return "N/A"; + } + return content; + } + + /** * Updates the list model to show the given notes without those with no content * From c8944e344e552778fba0a9cd33211f7dfb790e8e Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Mon, 7 Aug 2017 20:50:47 +0200 Subject: [PATCH 07/21] Fix Checkstyle --- .../gui/entryeditor/FileAnnotationListCellRenderer.java | 2 -- .../org/jabref/gui/entryeditor/FxFileAnnotationTab.java | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java index 2d0a62fce68..849c08cb875 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java @@ -8,10 +8,8 @@ public class FileAnnotationListCellRenderer implements Callback, ListCell> { - @Override public ListCell call(ListView param) { - return new ListCell() { @Override protected void updateItem(FileAnnotation t, boolean bln) { diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java index ea6546f0394..6ceb09170ac 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -47,7 +47,6 @@ public class FxFileAnnotationTab extends EntryEditorTab { private Map> fileAnnotations; private ObservableList fileAnnotationsList = FXCollections.observableArrayList(); - private StringProperty currentAuthor = new SimpleStringProperty(); private StringProperty currentPage = new SimpleStringProperty(); private StringProperty currentDate = new SimpleStringProperty(); @@ -61,13 +60,13 @@ public FxFileAnnotationTab(JabRefFrame frame, BasePanel basePanel, EntryEditor p this.cache = cache; fileAnnotations = cache.getFromCache(parent.getEntry()); - this.panel = setupPanel(frame, basePanel); - setText(Localization.lang("File annotations")); // TODO: rename in "File annotations" + this.panel = setupPanel(); + setText(Localization.lang("File annotations")); setTooltip(new Tooltip(Localization.lang("Show file annotations"))); setGraphic(IconTheme.JabRefIcon.REQUIRED.getGraphicNode()); } - private Region setupPanel(JabRefFrame frame, BasePanel basePanel) { + private Region setupPanel() { GridPane gridPane = new GridPane(); gridPane.getStyleClass().add("editorPane"); ColumnConstraints leftSideConstraint = new ColumnConstraints(); @@ -90,7 +89,6 @@ private Region setupPanel(JabRefFrame frame, BasePanel basePanel) { private GridPane setupRightSide() { GridPane rightSide = new GridPane(); - rightSide.addRow(0, new Label("Author")); Text annotationAuthor = new Text(); From 8c35f03f8272157a4428decd66e5f969154cf028 Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Tue, 8 Aug 2017 00:32:50 +0200 Subject: [PATCH 08/21] Add TODOs --- .../gui/entryeditor/FxFileAnnotationTab.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java index 6ceb09170ac..95160ece45c 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -1,30 +1,17 @@ package org.jabref.gui.entryeditor; -import java.time.LocalDateTime; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Optional; - import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import javafx.scene.control.ComboBox; -import javafx.scene.control.Label; -import javafx.scene.control.ListView; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.SelectionMode; -import javafx.scene.control.TextArea; -import javafx.scene.control.Tooltip; +import javafx.scene.control.*; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; import javafx.scene.layout.Priority; import javafx.scene.layout.Region; import javafx.scene.text.Text; - import org.jabref.gui.BasePanel; import org.jabref.gui.IconTheme; import org.jabref.gui.JabRefFrame; @@ -34,6 +21,12 @@ import org.jabref.model.entry.FieldName; import org.jabref.model.pdf.FileAnnotation; +import java.time.LocalDateTime; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Optional; + import static org.jabref.model.pdf.FileAnnotationType.NONE; public class FxFileAnnotationTab extends EntryEditorTab { @@ -76,7 +69,6 @@ private Region setupPanel() { gridPane.addColumn(0, setupLeftSide()); gridPane.addColumn(1, setupRightSide()); - // Warp everything in a scroll-pane ScrollPane scrollPane = new ScrollPane(); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); @@ -88,7 +80,7 @@ private Region setupPanel() { private GridPane setupRightSide() { GridPane rightSide = new GridPane(); - + // TODO: add localization rightSide.addRow(0, new Label("Author")); Text annotationAuthor = new Text(); @@ -121,6 +113,9 @@ private GridPane setupRightSide() { markingArea.setEditable(false); markingArea.setWrapText(true); rightSide.addColumn(1, markingArea); + + rightSide.addRow(5, new Button("Reload Annotations")); // Todo: add functionality + rightSide.addColumn(1, new Button("Copy to Clipboard")); // Todo: add functionality return rightSide; } From 3156930b101bcfd1b2559395801d112625ab2d48 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 8 Aug 2017 10:46:32 +0200 Subject: [PATCH 09/21] Rework --- .../java/org/jabref/gui/AbstractView.java | 7 +- .../jabref/gui/entryeditor/EntryEditor.java | 2 +- .../FileAnnotationListCellRenderer.java | 25 --- .../gui/entryeditor/FileAnnotationTab.fxml | 31 +++ .../FileAnnotationTabController.java | 67 ++++++ .../entryeditor/FileAnnotationTabView.java | 23 ++ .../FileAnnotationTabViewModel.java | 108 +++++++++ .../entryeditor/FileAnnotationViewModel.java | 18 ++ .../gui/entryeditor/FxFileAnnotationTab.java | 205 +----------------- .../jabref/logic/pdf/FileAnnotationCache.java | 8 + 10 files changed, 271 insertions(+), 223 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java create mode 100644 src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml create mode 100644 src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java create mode 100644 src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabView.java create mode 100644 src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java diff --git a/src/main/java/org/jabref/gui/AbstractView.java b/src/main/java/org/jabref/gui/AbstractView.java index 79df1bbcf66..085b1557c71 100644 --- a/src/main/java/org/jabref/gui/AbstractView.java +++ b/src/main/java/org/jabref/gui/AbstractView.java @@ -1,6 +1,7 @@ package org.jabref.gui; import java.util.Optional; +import java.util.function.Function; import javafx.scene.Parent; import javafx.stage.Stage; @@ -11,7 +12,11 @@ public class AbstractView extends FXMLView { public AbstractView() { - super(); + this(f -> null); + } + + public AbstractView(Function injectionContext) { + super(injectionContext); // Set resource bundle to internal localizations bundle = Localization.getMessages(); diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index cfcb0ec675d..2c24cc516df 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -279,7 +279,7 @@ private void addTabs(String lastTabName) { tabs.add(new MathSciNetTab(entry)); FileAnnotationCache annotationCache = panel.getAnnotationCache(); tabs.add(new FileAnnotationTab(entry, this, annotationCache)); - tabs.add(new FxFileAnnotationTab(frame, panel, this, annotationCache)); + tabs.add(new FxFileAnnotationTab(this, annotationCache)); tabs.add(new RelatedArticlesTab(entry)); // Source tab diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java deleted file mode 100644 index 2d0a62fce68..00000000000 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationListCellRenderer.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.jabref.gui.entryeditor; - -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.util.Callback; - -import org.jabref.model.pdf.FileAnnotation; - -public class FileAnnotationListCellRenderer implements Callback, ListCell> { - - - @Override - public ListCell call(ListView param) { - - return new ListCell() { - @Override - protected void updateItem(FileAnnotation t, boolean bln) { - super.updateItem(t, bln); - if (t != null) { - setText(t.getContent()); - } - } - }; - } -} diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml new file mode 100644 index 00000000000..2d69a8e8cc4 --- /dev/null +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + +
+ +
+
+
+ + + +
+
diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java new file mode 100644 index 00000000000..11ba8d110f1 --- /dev/null +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java @@ -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 { + + @FXML ComboBox files; + @FXML ListView 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 cellFactory = new ViewModelListCellFactory() + .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()); + } +} diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabView.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabView.java new file mode 100644 index 00000000000..d7c0022e9dc --- /dev/null +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabView.java @@ -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 createContext(BibEntry entry, FileAnnotationCache fileAnnotationCache) { + Map context = new HashMap<>(); + context.put("entry", entry); + context.put("fileAnnotationCache", fileAnnotationCache); + return context::get; + } +} diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java new file mode 100644 index 00000000000..9d8cd13b098 --- /dev/null +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java @@ -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 annotations = new SimpleListProperty<>(FXCollections.observableArrayList()); + private final ListProperty files = new SimpleListProperty<>(FXCollections.observableArrayList()); + private Map> 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 annotationsProperty() { + return annotations; + } + + public ListProperty 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 byPage = Comparator.comparingInt(FileAnnotation::getPage); + + List newAnnotations = fileAnnotations.getOrDefault(newFile, new ArrayList<>()) + .stream() + .filter(annotation -> (null != annotation.getContent())) + .sorted(byPage) + .map(FileAnnotationViewModel::new) + .collect(Collectors.toList()); + annotations.setAll(newAnnotations); + } +} diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java index ea2a9ac7fa9..90497bad320 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java @@ -34,4 +34,22 @@ public String toString() { return super.toString(); } + + public String getDescription() { + return null; + } + + private String getMarking(FileAnnotation annotation) { + if (annotation.hasLinkedAnnotation()) { + return getContentOrNA(annotation.getLinkedFileAnnotation().getContent()); + } + return "N/A"; + } + + private String getContentOrNA(String content) { + if (content.isEmpty()) { + return "N/A"; + } + return content; + } } diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java index ea6546f0394..8a74647e20f 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java @@ -1,223 +1,36 @@ package org.jabref.gui.entryeditor; -import java.time.LocalDateTime; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.scene.control.ComboBox; -import javafx.scene.control.Label; -import javafx.scene.control.ListView; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.SelectionMode; -import javafx.scene.control.TextArea; import javafx.scene.control.Tooltip; -import javafx.scene.layout.ColumnConstraints; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.Priority; -import javafx.scene.layout.Region; -import javafx.scene.text.Text; -import org.jabref.gui.BasePanel; -import org.jabref.gui.IconTheme; -import org.jabref.gui.JabRefFrame; -import org.jabref.gui.fieldeditors.FieldEditorFX; import org.jabref.logic.l10n.Localization; import org.jabref.logic.pdf.FileAnnotationCache; +import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; -import org.jabref.model.pdf.FileAnnotation; - -import static org.jabref.model.pdf.FileAnnotationType.NONE; public class FxFileAnnotationTab extends EntryEditorTab { - private final Region panel; - - private final EntryEditor parent; - private final JabRefFrame frame; - private final BasePanel basePanel; - private final FileAnnotationCache cache; - private FieldEditorFX activeField; - private Map> fileAnnotations; - private ObservableList fileAnnotationsList = FXCollections.observableArrayList(); + private final FileAnnotationCache fileAnnotationCache; + private final BibEntry entry; - 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 FxFileAnnotationTab(EntryEditor parent, FileAnnotationCache cache) { + this.fileAnnotationCache = cache; + this.entry = parent.getEntry(); - public FxFileAnnotationTab(JabRefFrame frame, BasePanel basePanel, EntryEditor parent, FileAnnotationCache cache) { - this.parent = parent; - this.frame = frame; - this.basePanel = basePanel; - this.cache = cache; - fileAnnotations = cache.getFromCache(parent.getEntry()); - - this.panel = setupPanel(frame, basePanel); - setText(Localization.lang("File annotations")); // TODO: rename in "File annotations" + setText(Localization.lang("File annotations")); setTooltip(new Tooltip(Localization.lang("Show file annotations"))); - setGraphic(IconTheme.JabRefIcon.REQUIRED.getGraphicNode()); - } - - private Region setupPanel(JabRefFrame frame, BasePanel basePanel) { - GridPane gridPane = new GridPane(); - gridPane.getStyleClass().add("editorPane"); - ColumnConstraints leftSideConstraint = new ColumnConstraints(); - leftSideConstraint.setPercentWidth(50); - gridPane.getColumnConstraints().addAll(leftSideConstraint); - - gridPane.addColumn(0, setupLeftSide()); - gridPane.addColumn(1, setupRightSide()); - - // Warp everything in a scroll-pane - ScrollPane scrollPane = new ScrollPane(); - scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); - scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); - scrollPane.setContent(gridPane); - scrollPane.setFitToWidth(true); - scrollPane.setFitToHeight(true); - return scrollPane; - } - - 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; - } - - private String getMarking(FileAnnotation annotation) { - if (annotation.hasLinkedAnnotation()) { - return getContentOrNA(annotation.getLinkedFileAnnotation().getContent()); - } - return "N/A"; - } - - private GridPane setupLeftSide() { - GridPane leftSide = new GridPane(); - - leftSide.addColumn(0, new Label("Filename")); - ComboBox fileNameComboBox = createFileNameComboBox(); - GridPane.setHgrow(fileNameComboBox, Priority.ALWAYS); - - leftSide.addRow(0, fileNameComboBox); - - ListView listView = createFileAnnotationsList(fileNameComboBox); - leftSide.add(listView, 0, 1, 2, 1); - - return leftSide; - } - - private ListView createFileAnnotationsList(ComboBox fileNameComboBox) { - ListView listView = new ListView<>(); - listView.setItems(fileAnnotationsList); - listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); - listView.getSelectionModel().selectedItemProperty().addListener( - new ChangeListener() { - @Override - public void changed(ObservableValue ov, FileAnnotation t, FileAnnotation newFA) { - currentAuthor.setValue(listView.getSelectionModel().getSelectedItem().getAuthor()); - currentPage.setValue(Integer.toString(listView.getSelectionModel().getSelectedItem().getPage())); - currentDate.setValue(listView.getSelectionModel().getSelectedItem().getTimeModified().toString()); - currentContent.setValue(getContentOrNA(listView.getSelectionModel().getSelectedItem().getContent())); - currentMarking.setValue(getMarking(listView.getSelectionModel().getSelectedItem())); - } - } - ); - GridPane.setHgrow(listView, Priority.ALWAYS); - - listView.setCellFactory(new FileAnnotationListCellRenderer()); - updateShownAnnotations(fileAnnotations.get(fileNameComboBox.getSelectionModel().getSelectedItem())); - return listView; - } - - private String getContentOrNA(String content) { - if (content.isEmpty()) { - return "N/A"; - } - return content; - } - - - /** - * Updates the list model to show the given notes without those with no content - * - * @param annotations value is the annotation name and the value is a pdfAnnotation object to add to the list model - */ - private void updateShownAnnotations(List annotations) { - fileAnnotationsList.clear(); - if (annotations == null || annotations.isEmpty()) { - fileAnnotationsList.add(new FileAnnotation("", LocalDateTime.now(), 0, Localization.lang("File has no attached annotations"), NONE, Optional.empty())); - } else { - Comparator byPage = Comparator.comparingInt(FileAnnotation::getPage); - annotations.stream() - .filter(annotation -> (null != annotation.getContent())) - .sorted(byPage) - .forEach(annotation -> fileAnnotationsList.add(new FileAnnotationViewModel(annotation))); - } - } - - private ComboBox createFileNameComboBox() { - - ComboBox comboBox = new ComboBox<>(FXCollections.observableArrayList(fileAnnotations.keySet())); - comboBox.getSelectionModel().selectFirst(); - return comboBox; } @Override public boolean shouldShow() { - return parent.getEntry().getField(FieldName.FILE).isPresent(); + return entry.getField(FieldName.FILE).isPresent(); } @Override public void requestFocus() { - if (activeField != null) { - activeField.requestFocus(); - } } @Override protected void initialize() { - setContent(panel); + setContent(new FileAnnotationTabView(entry, fileAnnotationCache).getView()); } } diff --git a/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java b/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java index 33baadedd6b..fece6fb1a10 100644 --- a/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java +++ b/src/main/java/org/jabref/logic/pdf/FileAnnotationCache.java @@ -22,6 +22,14 @@ public class FileAnnotationCache { //the inner list holds the annotations per file, the outer collection maps this to a BibEntry. private LoadingCache>> annotationCache; + /** + * Creates an empty fil annotation cache. Required to allow the annotation cache to be injected into views without + * hitting the bug https://github.com/AdamBien/afterburner.fx/issues/71. + */ + public FileAnnotationCache() { + + } + public FileAnnotationCache(BibDatabaseContext context) { annotationCache = CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).build(new CacheLoader>>() { @Override From 7fb7c4e732469bd48ca1551e4c935cb1bc9beb59 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 8 Aug 2017 11:15:49 +0200 Subject: [PATCH 10/21] Initial shot at details pane --- .../org/jabref/gui/entryeditor/FileAnnotationTab.fxml | 6 +++++- .../gui/entryeditor/FileAnnotationTabController.java | 7 +++++++ .../gui/entryeditor/FileAnnotationTabViewModel.java | 9 ++++++++- .../gui/entryeditor/FileAnnotationViewModel.java | 10 ++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml index 2d69a8e8cc4..b31b124df48 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml @@ -6,6 +6,7 @@ + - + + diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java index 11ba8d110f1..e0f15652607 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java @@ -19,10 +19,13 @@ import org.jabref.logic.pdf.FileAnnotationCache; import org.jabref.model.entry.BibEntry; +import org.fxmisc.easybind.EasyBind; + public class FileAnnotationTabController extends AbstractController { @FXML ComboBox files; @FXML ListView annotationList; + @FXML Label author; @Inject private FileAnnotationCache fileAnnotationCache; @Inject private BibEntry entry; @@ -63,5 +66,9 @@ public void initialize() { annotationList.setCellFactory(cellFactory); annotationList.setPlaceholder(new Label(Localization.lang("File has no attached annotations"))); Bindings.bindContent(annotationList.itemsProperty().get(), viewModel.annotationsProperty()); + + // Set-up details pane + author.textProperty().bind( + EasyBind.select(viewModel.currentAnnotationProperty()).selectObject(FileAnnotationViewModel::authorProperty)); } } diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java index 9d8cd13b098..55c337b82fa 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java @@ -7,7 +7,9 @@ import java.util.stream.Collectors; import javafx.beans.property.ListProperty; +import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleListProperty; +import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.collections.FXCollections; @@ -25,18 +27,22 @@ public class FileAnnotationTabViewModel extends AbstractViewModel { private final ListProperty annotations = new SimpleListProperty<>(FXCollections.observableArrayList()); private final ListProperty files = new SimpleListProperty<>(FXCollections.observableArrayList()); + private final ObjectProperty currentAnnotation = new SimpleObjectProperty<>(); private Map> 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 ObjectProperty currentAnnotationProperty() { + return currentAnnotation; + } + public ListProperty annotationsProperty() { return annotations; } @@ -46,6 +52,7 @@ public ListProperty filesProperty() { } public void notifyNewSelectedAnnotation(FileAnnotationViewModel newAnnotation) { + currentAnnotation.set(newAnnotation); /* currentAuthor.setValue(newValue.getAuthor()); currentPage.setValue(newValue.getPage()); diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java index 90497bad320..7e86529f545 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java +++ b/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java @@ -2,15 +2,25 @@ import java.util.Optional; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + import org.jabref.logic.l10n.Localization; import org.jabref.model.pdf.FileAnnotation; import org.jabref.model.pdf.FileAnnotationType; public class FileAnnotationViewModel extends FileAnnotation { + private StringProperty author = new SimpleStringProperty(); + public FileAnnotationViewModel(FileAnnotation annotation) { super(annotation.getAuthor(), annotation.getTimeModified(), annotation.getPage(), annotation.getContent(), annotation.getAnnotationType(), annotation.hasLinkedAnnotation() ? Optional.of(annotation.getLinkedFileAnnotation()) : Optional.empty()); + author.set(annotation.getContent()); // Use content just for test, since some annotations don't have an author + } + + public StringProperty authorProperty() { + return author; } @Override From 9936acc359c7a8815f9b7f93221c9d491108d3c5 Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Tue, 8 Aug 2017 15:57:36 +0200 Subject: [PATCH 11/21] Move FileAnnotationTab to own package, fix localization --- .../jabref/gui/entryeditor/EntryEditor.java | 2 ++ .../FileAnnotationTab.fxml | 2 +- .../FileAnnotationTab.java | 10 +++++---- .../FileAnnotationTabController.java | 21 ++++++++++++------- .../FileAnnotationTabView.java | 2 +- .../FileAnnotationTabViewModel.java | 17 +++++++-------- .../FileAnnotationViewModel.java | 2 +- .../FxFileAnnotationTab.java | 4 +++- 8 files changed, 35 insertions(+), 25 deletions(-) rename src/main/java/org/jabref/gui/entryeditor/{ => fileannotationtab}/FileAnnotationTab.fxml (92%) rename src/main/java/org/jabref/gui/entryeditor/{ => fileannotationtab}/FileAnnotationTab.java (98%) rename src/main/java/org/jabref/gui/entryeditor/{ => fileannotationtab}/FileAnnotationTabController.java (84%) rename src/main/java/org/jabref/gui/entryeditor/{ => fileannotationtab}/FileAnnotationTabView.java (93%) rename src/main/java/org/jabref/gui/entryeditor/{ => fileannotationtab}/FileAnnotationTabViewModel.java (90%) rename src/main/java/org/jabref/gui/entryeditor/{ => fileannotationtab}/FileAnnotationViewModel.java (97%) rename src/main/java/org/jabref/gui/entryeditor/{ => fileannotationtab}/FxFileAnnotationTab.java (86%) diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 25e57e540f8..f20dba02bb9 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -47,6 +47,8 @@ import org.jabref.gui.JabRefFrame; import org.jabref.gui.OSXCompatibleToolbar; import org.jabref.gui.actions.Actions; +import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab; +import org.jabref.gui.entryeditor.fileannotationtab.FxFileAnnotationTab; import org.jabref.gui.externalfiles.WriteXMPEntryEditorAction; import org.jabref.gui.fieldeditors.FieldEditor; import org.jabref.gui.fieldeditors.TextField; diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.fxml similarity index 92% rename from src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml rename to src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.fxml index b31b124df48..73f855dce87 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.fxml +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.fxml @@ -10,7 +10,7 @@ + fx:controller="org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTabController"> diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.java similarity index 98% rename from src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java rename to src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.java index 77ed0558732..fe592a052bf 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.java @@ -1,4 +1,4 @@ -package org.jabref.gui.entryeditor; +package org.jabref.gui.entryeditor.fileannotationtab; import java.awt.Component; import java.awt.GridBagConstraints; @@ -32,6 +32,8 @@ import org.jabref.gui.ClipBoardManager; import org.jabref.gui.GUIGlobals; import org.jabref.gui.IconTheme; +import org.jabref.gui.entryeditor.EntryEditor; +import org.jabref.gui.entryeditor.EntryEditorTab; import org.jabref.logic.l10n.Localization; import org.jabref.logic.pdf.FileAnnotationCache; import org.jabref.model.entry.BibEntry; @@ -43,7 +45,7 @@ import static org.jabref.model.pdf.FileAnnotationType.NONE; -class FileAnnotationTab extends EntryEditorTab { +public class FileAnnotationTab extends EntryEditorTab { private final JList annotationList = new JList<>(); private final JScrollPane annotationScrollPane = new JScrollPane(); @@ -73,7 +75,7 @@ class FileAnnotationTab extends EntryEditorTab { private final EntryEditor parent; private DefaultListModel listModel; - FileAnnotationTab(BibEntry entry, EntryEditor parent, FileAnnotationCache cache) { + public FileAnnotationTab(BibEntry entry, EntryEditor parent, FileAnnotationCache cache) { this.entry = entry; this.fileAnnotationCache = cache; this.parent = parent; @@ -213,7 +215,7 @@ private void setUpGui() { markedTxtArea.setLineWrap(true); fileNameComboBox.setEditable(false); fileNameComboBox.addActionListener(e -> updateFileNameComboBox()); - + swingNode.setContent(FormBuilder.create() .columns("0:grow, $lcgap, 0:grow") .rows("fill:pref:grow") diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabController.java similarity index 84% rename from src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java rename to src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabController.java index e0f15652607..11f19d21d35 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabController.java +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabController.java @@ -1,4 +1,4 @@ -package org.jabref.gui.entryeditor; +package org.jabref.gui.entryeditor.fileannotationtab; import javax.inject.Inject; @@ -23,12 +23,17 @@ public class FileAnnotationTabController extends AbstractController { - @FXML ComboBox files; - @FXML ListView annotationList; - @FXML Label author; + @FXML + ComboBox files; + @FXML + ListView annotationList; + @FXML + Label author; - @Inject private FileAnnotationCache fileAnnotationCache; - @Inject private BibEntry entry; + @Inject + private FileAnnotationCache fileAnnotationCache; + @Inject + private BibEntry entry; @FXML public void initialize() { @@ -54,9 +59,9 @@ public void initialize() { HBox details = new HBox(); details.getStyleClass().setAll("details"); Text page = new Text(); - page.setText(Localization.lang("Page: ") + Integer.toString(annotation.getPage())); + page.setText(Localization.lang("Page") + ": " + Integer.toString(annotation.getPage())); Text author = new Text(); - author.setText(Localization.lang("Author: ") + annotation.getAuthor()); + author.setText(Localization.lang("Author") + ": " + annotation.getAuthor()); details.getChildren().addAll(page, author); node.getChildren().addAll(text, details); diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabView.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabView.java similarity index 93% rename from src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabView.java rename to src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabView.java index d7c0022e9dc..3e216334b61 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabView.java +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabView.java @@ -1,4 +1,4 @@ -package org.jabref.gui.entryeditor; +package org.jabref.gui.entryeditor.fileannotationtab; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabViewModel.java similarity index 90% rename from src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java rename to src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabViewModel.java index 55c337b82fa..700386e1c0e 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationTabViewModel.java +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabViewModel.java @@ -1,4 +1,4 @@ -package org.jabref.gui.entryeditor; +package org.jabref.gui.entryeditor.fileannotationtab; import java.util.ArrayList; import java.util.Comparator; @@ -19,6 +19,7 @@ import javafx.scene.text.Text; import org.jabref.gui.AbstractViewModel; +import org.jabref.logic.l10n.Localization; import org.jabref.logic.pdf.FileAnnotationCache; import org.jabref.model.entry.BibEntry; import org.jabref.model.pdf.FileAnnotation; @@ -34,6 +35,7 @@ public class FileAnnotationTabViewModel extends AbstractViewModel { 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()); @@ -65,26 +67,23 @@ public void notifyNewSelectedAnnotation(FileAnnotationViewModel newAnnotation) { private GridPane setupRightSide() { GridPane rightSide = new GridPane(); - - rightSide.addRow(0, new Label("Author")); - + rightSide.addRow(0, new Label(Localization.lang("Author"))); Text annotationAuthor = new Text(); annotationAuthor.textProperty().bind(currentAuthor); rightSide.addColumn(1, annotationAuthor); - rightSide.addRow(1, new Label("Page")); + rightSide.addRow(1, new Label(Localization.lang("Page"))); Text annotationPage = new Text(); annotationPage.textProperty().bind(currentPage); rightSide.addColumn(1, annotationPage); - rightSide.addRow(2, new Label("Date")); + rightSide.addRow(2, new Label(Localization.lang("Date"))); Text annotationDate = new Text(); annotationDate.textProperty().bind(currentDate); - rightSide.addColumn(1, annotationDate); - rightSide.addRow(3, new Label("Content")); + rightSide.addRow(3, new Label(Localization.lang("Content"))); TextArea annotationContent = new TextArea(); annotationContent.textProperty().bind(currentContent); @@ -92,7 +91,7 @@ private GridPane setupRightSide() { annotationContent.setWrapText(true); rightSide.addColumn(1, annotationContent); - rightSide.addRow(4, new Label("Marking")); + rightSide.addRow(4, new Label(Localization.lang("Marking"))); TextArea markingArea = new TextArea(); markingArea.textProperty().bind(currentMarking); markingArea.setEditable(false); diff --git a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationViewModel.java similarity index 97% rename from src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java rename to src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationViewModel.java index 7e86529f545..a46708022d1 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FileAnnotationViewModel.java +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationViewModel.java @@ -1,4 +1,4 @@ -package org.jabref.gui.entryeditor; +package org.jabref.gui.entryeditor.fileannotationtab; import java.util.Optional; diff --git a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FxFileAnnotationTab.java similarity index 86% rename from src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java rename to src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FxFileAnnotationTab.java index 8a74647e20f..191d6f2d5ca 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FxFileAnnotationTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FxFileAnnotationTab.java @@ -1,7 +1,9 @@ -package org.jabref.gui.entryeditor; +package org.jabref.gui.entryeditor.fileannotationtab; import javafx.scene.control.Tooltip; +import org.jabref.gui.entryeditor.EntryEditor; +import org.jabref.gui.entryeditor.EntryEditorTab; import org.jabref.logic.l10n.Localization; import org.jabref.logic.pdf.FileAnnotationCache; import org.jabref.model.entry.BibEntry; From e91d96a3de59fe8ddd9554e24e8081999dcf9257 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 8 Aug 2017 22:16:55 +0200 Subject: [PATCH 12/21] Finish annotation tab --- .../jabref/gui/entryeditor/EntryEditor.java | 4 +- .../fileannotationtab/FileAnnotationTab.fxml | 71 +++- .../fileannotationtab/FileAnnotationTab.java | 373 +----------------- .../FileAnnotationTabController.java | 42 +- .../FileAnnotationTabViewModel.java | 90 ++--- .../FileAnnotationViewModel.java | 90 +++-- .../FxFileAnnotationTab.java | 38 -- 7 files changed, 198 insertions(+), 510 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FxFileAnnotationTab.java diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index f20dba02bb9..f3ac59564b2 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -48,7 +48,6 @@ import org.jabref.gui.OSXCompatibleToolbar; import org.jabref.gui.actions.Actions; import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab; -import org.jabref.gui.entryeditor.fileannotationtab.FxFileAnnotationTab; import org.jabref.gui.externalfiles.WriteXMPEntryEditorAction; import org.jabref.gui.fieldeditors.FieldEditor; import org.jabref.gui.fieldeditors.TextField; @@ -269,8 +268,7 @@ private void addTabs(String lastTabName) { // Special tabs tabs.add(new MathSciNetTab(entry)); FileAnnotationCache annotationCache = panel.getAnnotationCache(); - tabs.add(new FileAnnotationTab(entry, this, annotationCache)); - tabs.add(new FxFileAnnotationTab(this, annotationCache)); + tabs.add(new FileAnnotationTab(annotationCache, entry)); tabs.add(new RelatedArticlesTab(entry)); // Source tab diff --git a/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.fxml b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.fxml index 73f855dce87..41d3e2bba0d 100644 --- a/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.fxml +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTab.fxml @@ -1,23 +1,42 @@ + + + + + + - + + + - + + + + - -
@@ -26,10 +45,46 @@ - - + + + + + + + + + + + + + + + + +