Code aufräumen

This commit is contained in:
2026-04-28 08:52:59 +02:00
parent 27b4292c2f
commit 8bb0aabb51
5 changed files with 9 additions and 66 deletions
@@ -2608,50 +2608,6 @@ public final class GuiConfigurationEditorWorkspace {
return label; return label;
} }
/**
* Builds a labelled path-field row as a {@link VBox} containing a grid row with the field
* and picker button, plus an optional error-slot label directly beneath.
* <p>
* The method uses an 8-pixel top padding to separate consecutive field rows visually, matching
* the former grid vgap behaviour.
*
* @param labelText the row label text; must not be {@code null}
* @param field the text field; must not be {@code null}
* @param errorLabel the field-level error label, or {@code null} for no error slot
* @param onPick action invoked when the picker button is clicked; must not be {@code null}
* @return a VBox containing the labelled row and optional error slot
*/
private static VBox buildPathFieldRow(String labelText, TextField field,
Label errorLabel, Runnable onPick) {
Label label = new Label(labelText);
Button pickButton = new Button("");
pickButton.setOnAction(e -> onPick.run());
pickButton.setMinWidth(32);
HBox fieldBox = new HBox(4, field, pickButton);
HBox.setHgrow(field, Priority.ALWAYS);
fieldBox.setAlignment(Pos.CENTER_LEFT);
GridPane grid = new GridPane();
grid.setHgap(12);
grid.setVgap(0);
javafx.scene.layout.ColumnConstraints labelCol = new javafx.scene.layout.ColumnConstraints();
labelCol.setMinWidth(180);
labelCol.setPrefWidth(200);
javafx.scene.layout.ColumnConstraints fieldCol = new javafx.scene.layout.ColumnConstraints();
fieldCol.setFillWidth(true);
fieldCol.setHgrow(Priority.ALWAYS);
grid.getColumnConstraints().addAll(labelCol, fieldCol);
grid.add(label, 0, 0);
grid.add(fieldBox, 1, 0);
grid.setPadding(new Insets(4, 0, 0, 0));
VBox slot = new VBox(0, grid);
if (errorLabel != null) {
slot.getChildren().add(errorLabel);
}
return slot;
}
/** /**
* Baut zwei Pfad-Felder nebeneinander in einer HBox. Jedes Feld hat ein Label und einen Picker-Button. * Baut zwei Pfad-Felder nebeneinander in einer HBox. Jedes Feld hat ein Label und einen Picker-Button.
* Error-Labels werden untereinander angezeigt. * Error-Labels werden untereinander angezeigt.
@@ -2786,19 +2742,6 @@ public final class GuiConfigurationEditorWorkspace {
return field; return field;
} }
/**
* Adds a label and a text field (without a picker button) to the given grid row.
*
* @param grid the target grid pane
* @param row the grid row index
* @param labelText the row label text
* @param field the text field to place
*/
private static void addSimpleRow(GridPane grid, int row, String labelText, TextField field) {
grid.add(new Label(labelText), 0, row);
grid.add(field, 1, row);
}
/** /**
* Erstellt ein GridPane für Konfigurationsfelder mit kompaktem vertikalen Abstand. * Erstellt ein GridPane für Konfigurationsfelder mit kompaktem vertikalen Abstand.
*/ */
@@ -204,7 +204,6 @@ public final class GuiBatchRunTab {
private final GuiBatchRunCoordinator coordinator; private final GuiBatchRunCoordinator coordinator;
private final Supplier<GuiManualFileRenamePort> manualFileRenamePortSupplier; private final Supplier<GuiManualFileRenamePort> manualFileRenamePortSupplier;
private final Supplier<GuiManualFileCopyPort> manualFileCopyPortSupplier; private final Supplier<GuiManualFileCopyPort> manualFileCopyPortSupplier;
private final Supplier<GuiHistoricalDocumentContextPort> historicalDocumentContextPortSupplier;
private final Supplier<Optional<Path>> sourceFolderSupplier; private final Supplier<Optional<Path>> sourceFolderSupplier;
private final Supplier<Optional<String>> targetFolderSupplier; private final Supplier<Optional<String>> targetFolderSupplier;
@@ -275,7 +274,7 @@ public final class GuiBatchRunTab {
manualFileRenamePortSupplier, "manualFileRenamePortSupplier must not be null"); manualFileRenamePortSupplier, "manualFileRenamePortSupplier must not be null");
this.manualFileCopyPortSupplier = Objects.requireNonNull( this.manualFileCopyPortSupplier = Objects.requireNonNull(
manualFileCopyPortSupplier, "manualFileCopyPortSupplier must not be null"); manualFileCopyPortSupplier, "manualFileCopyPortSupplier must not be null");
this.historicalDocumentContextPortSupplier = Objects.requireNonNull( Objects.requireNonNull(
historicalDocumentContextPortSupplier, "historicalDocumentContextPortSupplier must not be null"); historicalDocumentContextPortSupplier, "historicalDocumentContextPortSupplier must not be null");
this.sourceFolderSupplier = Objects.requireNonNull( this.sourceFolderSupplier = Objects.requireNonNull(
sourceFolderSupplier, "sourceFolderSupplier must not be null"); sourceFolderSupplier, "sourceFolderSupplier must not be null");
@@ -654,8 +653,8 @@ public final class GuiBatchRunTab {
} }
}); });
resultTable.getColumns().setAll( resultTable.getColumns().setAll(List.of(
checkboxCol, iconCol, nameCol, newNameCol, dateCol, durationCol); checkboxCol, iconCol, nameCol, newNameCol, dateCol, durationCol));
// Selektion im TableView synchronisiert selectedRows und Checkboxen. // Selektion im TableView synchronisiert selectedRows und Checkboxen.
resultTable.getSelectionModel().getSelectedItems().addListener( resultTable.getSelectionModel().getSelectedItems().addListener(
@@ -21,8 +21,7 @@ class GuiBatchRunResultRowTest {
private static final DocumentFingerprint FP = private static final DocumentFingerprint FP =
new DocumentFingerprint("a".repeat(64)); new DocumentFingerprint("a".repeat(64));
private static final DocumentFingerprint FP2 =
new DocumentFingerprint("b".repeat(64));
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Basic construction // Basic construction
@@ -9,7 +9,9 @@ package de.gecheckt.pdf.umbenenner.bootstrap.singleinstance;
*/ */
public class AnotherInstanceRunningException extends RuntimeException { public class AnotherInstanceRunningException extends RuntimeException {
/** private static final long serialVersionUID = 159711019801174340L;
/**
* Erstellt eine neue {@code AnotherInstanceRunningException} mit der angegebenen Nachricht. * Erstellt eine neue {@code AnotherInstanceRunningException} mit der angegebenen Nachricht.
* *
* @param message die Fehlernachricht; darf {@code null} sein * @param message die Fehlernachricht; darf {@code null} sein
@@ -39,10 +39,10 @@ class SingleInstanceGuardTest {
@Test @Test
void zweiterAcquireWirftAnotherInstanceRunningException() throws Exception { void zweiterAcquireWirftAnotherInstanceRunningException() throws Exception {
int port = freienPortErmitteln(); int port = freienPortErmitteln();
try (SingleInstanceGuard ersterGuard = new SingleInstanceGuard(port)) { try (SingleInstanceGuard ersterGuard = new SingleInstanceGuard(port);
SingleInstanceGuard zweiterGuard = new SingleInstanceGuard(port)) {
ersterGuard.acquire(); ersterGuard.acquire();
SingleInstanceGuard zweiterGuard = new SingleInstanceGuard(port);
assertThrows(AnotherInstanceRunningException.class, zweiterGuard::acquire, assertThrows(AnotherInstanceRunningException.class, zweiterGuard::acquire,
"Während der erste Guard aktiv ist, soll der zweite acquire() eine " "Während der erste Guard aktiv ist, soll der zweite acquire() eine "
+ "AnotherInstanceRunningException werfen."); + "AnotherInstanceRunningException werfen.");