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);
    }
}

@@ -30,16 +30,51 @@
 ditor;%0A%0A
+import javafx.scene.control.Label;%0A
 import j
@@ -229,45 +229,8 @@
 ne;%0A
-import javafx.scene.layout.Priority;%0A
 impo
@@ -1185,12 +1185,8 @@
 ions
- NEW
 %22));
@@ -1544,17 +1544,16 @@
 Pane%22);%0A
-%0A
         
@@ -1570,28 +1570,34 @@
 traints 
-columnExpand
+leftSideConstraint
  = new C
@@ -1628,57 +1628,56 @@
     
-columnExpand.setHgrow(Priority.ALWAYS
+leftSideConstraint.setPercentWidth(50
 );%0A
-%0A
         
 Colu
@@ -1664,32 +1664,44 @@
 th(50);%0A        
+gridPane.get
 ColumnConstraint
@@ -1705,41 +1705,26 @@
 ints
- columnDoNotContract = new Column
+().addAll(leftSide
 Cons
@@ -1729,29 +1729,28 @@
 nstraint
-s(
 );%0A
+%0A
         
 columnDo
@@ -1745,72 +1745,56 @@
     
-columnDoNotContract.setMinWidth(Region.USE_PREF_SIZE
+gridPane.addColumn(0, setupLeftSide()
 );%0A
-%0A
         
 // T
@@ -1793,31 +1793,48 @@
     
-// TODO: actual content
+gridPane.addColumn(1, setupRightSide());
 %0A%0A  
@@ -2213,32 +2213,627 @@
 ollPane;%0A    %7D%0A%0A
+    private GridPane setupRightSide() %7B%0A        GridPane rightSide = new GridPane();%0A%0A        rightSide.addRow(0, new Label(%22Author%22));%0A        rightSide.addRow(1, new Label(%22date%22));%0A%0A        rightSide.addRow(2, new Label(%22page%22));%0A        rightSide.addRow(3, new Label(%22content%22));%0A%0A        rightSide.addRow(4, new Label(%22highlight%22));%0A        return rightSide;%0A    %7D%0A%0A    private GridPane setupLeftSide() %7B%0A        GridPane leftSide = new GridPane();%0A        leftSide.addRow(0, new Label(%22filename%22));%0A        leftSide.addRow(1, new Label(%22AnnotationsList%22));%0A        return leftSide;%0A    %7D%0A%0A
     @Override%0A  
@@ -2942,17 +2942,16 @@
 %0A    %7D%0A%0A
-%0A
     @Ove

Add content placeholders