diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeDetailsView.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeDetailsView.java index 7e3d6c18ff5f..e4d1ab047c3d 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangeDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeDetailsView.java @@ -1,5 +1,6 @@ package org.jabref.gui.collab; +import javafx.scene.Node; import javafx.scene.layout.AnchorPane; import org.jabref.gui.collab.entrychange.EntryChangeDetailsView; @@ -12,5 +13,31 @@ import org.jabref.gui.collab.stringdelete.BibTexStringDeleteDetailsView; import org.jabref.gui.collab.stringrename.BibTexStringRenameDetailsView; -public sealed abstract class DatabaseChangeDetailsView extends AnchorPane permits EntryWithPreviewAndSourceDetailsView, GroupChangeDetailsView, MetadataChangeDetailsView, PreambleChangeDetailsView, BibTexStringAddDetailsView, BibTexStringChangeDetailsView, BibTexStringDeleteDetailsView, BibTexStringRenameDetailsView, EntryChangeDetailsView { +public sealed abstract class DatabaseChangeDetailsView extends AnchorPane permits + EntryWithPreviewAndSourceDetailsView, + GroupChangeDetailsView, + MetadataChangeDetailsView, + PreambleChangeDetailsView, + BibTexStringAddDetailsView, + BibTexStringChangeDetailsView, + BibTexStringDeleteDetailsView, + BibTexStringRenameDetailsView, + EntryChangeDetailsView { + + private static Double ANCHOR_PANE_OFFSET = 8d; + + /** + * Set left, top, right, bottom anchors based on common offset parameter for the given child + * and attach it to children. + * @param child the child node of the implementation + * @see AnchorPane#getChildren() + * @see javafx.collections.ObservableList#setAll(Object[]) + */ + protected void setAllAnchorsAndAttachChild(Node child) { + setLeftAnchor(child, ANCHOR_PANE_OFFSET); + setTopAnchor(child, ANCHOR_PANE_OFFSET); + setRightAnchor(child, ANCHOR_PANE_OFFSET); + setBottomAnchor(child, ANCHOR_PANE_OFFSET); + this.getChildren().setAll(child); + } } diff --git a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java index 4043ac4a920c..f2722c5ee499 100644 --- a/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/entrychange/EntryChangeDetailsView.java @@ -72,12 +72,7 @@ public EntryChangeDetailsView(BibEntry oldEntry, SplitPane split = new SplitPane(containerOld, containerNew); split.setOrientation(Orientation.HORIZONTAL); - setLeftAnchor(split, 8d); - setTopAnchor(split, 8d); - setRightAnchor(split, 8d); - setBottomAnchor(split, 8d); - - this.getChildren().add(split); + this.setAllAnchorsAndAttachChild(split); } // Method adapted from: diff --git a/src/main/java/org/jabref/gui/collab/groupchange/GroupChangeDetailsView.java b/src/main/java/org/jabref/gui/collab/groupchange/GroupChangeDetailsView.java index 673c716ce12c..de428484f295 100644 --- a/src/main/java/org/jabref/gui/collab/groupchange/GroupChangeDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/groupchange/GroupChangeDetailsView.java @@ -17,11 +17,6 @@ public GroupChangeDetailsView(GroupChange groupChange) { Label label = new Label(labelValue); label.setWrapText(true); - setLeftAnchor(label, 8d); - setTopAnchor(label, 8d); - setRightAnchor(label, 8d); - setBottomAnchor(label, 8d); - - getChildren().setAll(label); + this.setAllAnchorsAndAttachChild(label); } } diff --git a/src/main/java/org/jabref/gui/collab/metedatachange/MetadataChangeDetailsView.java b/src/main/java/org/jabref/gui/collab/metedatachange/MetadataChangeDetailsView.java index 199057036ffb..7a6da5205b92 100644 --- a/src/main/java/org/jabref/gui/collab/metedatachange/MetadataChangeDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/metedatachange/MetadataChangeDetailsView.java @@ -25,12 +25,8 @@ public MetadataChangeDetailsView(MetadataChange metadataChange, GlobalCitationKe } ScrollPane scrollPane = new ScrollPane(container); - getChildren().setAll(scrollPane); - setLeftAnchor(scrollPane, 8d); - setTopAnchor(scrollPane, 8d); - setRightAnchor(scrollPane, 8d); - setBottomAnchor(scrollPane, 8d); + this.setAllAnchorsAndAttachChild(scrollPane); } private String getDifferenceString(MetaDataDiff.DifferenceType changeType) { diff --git a/src/main/java/org/jabref/gui/collab/preamblechange/PreambleChangeDetailsView.java b/src/main/java/org/jabref/gui/collab/preamblechange/PreambleChangeDetailsView.java index 8630f62c240c..c49182f1d2e3 100644 --- a/src/main/java/org/jabref/gui/collab/preamblechange/PreambleChangeDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/preamblechange/PreambleChangeDetailsView.java @@ -27,11 +27,7 @@ public PreambleChangeDetailsView(PreambleChange preambleChange) { } else { container.getChildren().add(new Label(Localization.lang("Value cleared externally"))); } - setLeftAnchor(container, 8d); - setTopAnchor(container, 8d); - setRightAnchor(container, 8d); - setBottomAnchor(container, 8d); - getChildren().setAll(container); + this.setAllAnchorsAndAttachChild(container); } } diff --git a/src/main/java/org/jabref/gui/collab/stringadd/BibTexStringAddDetailsView.java b/src/main/java/org/jabref/gui/collab/stringadd/BibTexStringAddDetailsView.java index 5e34729d108c..ffca7b4d7ba6 100644 --- a/src/main/java/org/jabref/gui/collab/stringadd/BibTexStringAddDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/stringadd/BibTexStringAddDetailsView.java @@ -17,11 +17,7 @@ public BibTexStringAddDetailsView(BibTexStringAdd stringAdd) { new Label(Localization.lang("Label: %0", stringAdd.getAddedString().getName())), new Label(Localization.lang("Content: %0", stringAdd.getAddedString().getContent())) ); - setLeftAnchor(container, 8d); - setTopAnchor(container, 8d); - setRightAnchor(container, 8d); - setBottomAnchor(container, 8d); - getChildren().setAll(container); + this.setAllAnchorsAndAttachChild(container); } } diff --git a/src/main/java/org/jabref/gui/collab/stringchange/BibTexStringChangeDetailsView.java b/src/main/java/org/jabref/gui/collab/stringchange/BibTexStringChangeDetailsView.java index 58fa700aa2cd..880f5661ad85 100644 --- a/src/main/java/org/jabref/gui/collab/stringchange/BibTexStringChangeDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/stringchange/BibTexStringChangeDetailsView.java @@ -19,11 +19,7 @@ public BibTexStringChangeDetailsView(BibTexStringChange stringChange) { ); container.getChildren().add(new Label(Localization.lang("Current content: %0", stringChange.getOldString().getContent()))); - setLeftAnchor(container, 8d); - setTopAnchor(container, 8d); - setRightAnchor(container, 8d); - setBottomAnchor(container, 8d); - getChildren().setAll(container); + this.setAllAnchorsAndAttachChild(container); } } diff --git a/src/main/java/org/jabref/gui/collab/stringdelete/BibTexStringDeleteDetailsView.java b/src/main/java/org/jabref/gui/collab/stringdelete/BibTexStringDeleteDetailsView.java index 2d35145b51d8..31a63e5504c3 100644 --- a/src/main/java/org/jabref/gui/collab/stringdelete/BibTexStringDeleteDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/stringdelete/BibTexStringDeleteDetailsView.java @@ -17,11 +17,7 @@ public BibTexStringDeleteDetailsView(BibTexStringDelete stringDelete) { new Label(Localization.lang("Label: %0", stringDelete.getDeletedString().getName())), new Label(Localization.lang("Content: %0", stringDelete.getDeletedString().getContent())) ); - setLeftAnchor(container, 8d); - setTopAnchor(container, 8d); - setRightAnchor(container, 8d); - setBottomAnchor(container, 8d); - getChildren().setAll(container); + this.setAllAnchorsAndAttachChild(container); } } diff --git a/src/main/java/org/jabref/gui/collab/stringrename/BibTexStringRenameDetailsView.java b/src/main/java/org/jabref/gui/collab/stringrename/BibTexStringRenameDetailsView.java index b810a1c526e8..fa826b08e8f3 100644 --- a/src/main/java/org/jabref/gui/collab/stringrename/BibTexStringRenameDetailsView.java +++ b/src/main/java/org/jabref/gui/collab/stringrename/BibTexStringRenameDetailsView.java @@ -8,11 +8,7 @@ public final class BibTexStringRenameDetailsView extends DatabaseChangeDetailsVi public BibTexStringRenameDetailsView(BibTexStringRename stringRename) { Label label = new Label(stringRename.getNewString().getName() + " : " + stringRename.getOldString().getContent()); - setLeftAnchor(label, 8d); - setTopAnchor(label, 8d); - setRightAnchor(label, 8d); - setBottomAnchor(label, 8d); - getChildren().setAll(label); + this.setAllAnchorsAndAttachChild(label); } }