Skip to content

Commit 7d5c12d

Browse files
committed
fix height constrains / row constraints
1 parent fbc6ec8 commit 7d5c12d

File tree

2 files changed

+36
-39
lines changed

2 files changed

+36
-39
lines changed

kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/DescriptionBaseController.java

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ public abstract class DescriptionBaseController<T> extends AbstractBasicControll
6262
@FXML
6363
protected ComboBox<T> languageComboBox;
6464

65-
// Dialects (only visible in edit mode)
65+
6666
@FXML
67-
protected VBox dialectsContainer;
67+
protected RowConstraints dialectCommentsRowConstraints; // shared constrain in edit/add mode
6868

6969
@FXML
70-
protected RowConstraints dialectRowConstraints; // Add fx:id to the row constraints
70+
protected Label commentsLabel; // label shown in add mode only
71+
72+
73+
// Dialects (only visible in edit mode)
74+
@FXML
75+
protected VBox dialectsContainer;
7176

7277
@FXML
7378
protected Label dialect1;
@@ -110,15 +115,9 @@ public final void initialize() {
110115
eventBus = EvtBusFactory.getDefaultEvtBus();
111116
clearView();
112117

113-
114-
// Configure the form based on type
115-
//configureForm();
116-
117118
// Let subclasses do their specific initialization
118119
initializeData();
119120

120-
// Post-initialization hook for subclasses
121-
//postInitialize();
122121
}
123122

124123
protected abstract void initializeData();
@@ -159,10 +158,6 @@ protected void handleCancel() {
159158

160159
@FXML
161160
protected void handleSubmit() {
162-
// Common validation logic
163-
//if (!validateForm()) {
164-
// return;
165-
//}
166161
onSubmit();
167162
}
168163

@@ -302,27 +297,31 @@ protected void close(Button button) {
302297

303298
protected void configureDialectVisibility(boolean showDialects) {
304299

300+
301+
if (commentsLabel != null) {
302+
commentsLabel.setVisible(!showDialects);
303+
commentsLabel.setManaged(!showDialects);
304+
}
305+
305306
if (dialectsContainer != null) {
306307
dialectsContainer.setVisible(showDialects);
307308
dialectsContainer.setManaged(showDialects);
308309

309-
// Adjust BorderPane minimum height based on dialect visibility
310-
BorderPane rootPane = (BorderPane) dialectsContainer.getParent().getParent(); // Adjust path as needed
311-
if (showDialects) { // Height with dialects
312-
rootPane.setMinHeight(670.0);
313-
rootPane.setPrefWidth(670.0);
314-
} else { // Height without dialects
315-
rootPane.setMinHeight(450.0);
316-
rootPane.setPrefWidth(450.0);
317-
}
318-
}
319-
// Also hide the row constraints for dialects
320-
if (dialectRowConstraints != null) {
321-
dialectRowConstraints.setMaxHeight(showDialects ? Region.USE_COMPUTED_SIZE : 0);
322-
dialectRowConstraints.setMinHeight(showDialects ? Region.USE_COMPUTED_SIZE : 0);
323-
dialectRowConstraints.setPrefHeight(showDialects ? Region.USE_COMPUTED_SIZE : 0);
324310
}
325311

312+
// Sets the correct minHeight constraint depending on add/edit mode
313+
if (dialectCommentsRowConstraints != null) {
314+
// a alternative solution would be to introduce a duplicated description-form.fxml for add / edit mode
315+
if (showDialects) {
316+
dialectCommentsRowConstraints.setMaxHeight(200.0);
317+
dialectCommentsRowConstraints.setMinHeight(200.0);
318+
dialectCommentsRowConstraints.setPrefHeight(200.0);
319+
} else {
320+
dialectCommentsRowConstraints.setMaxHeight(40.0);
321+
dialectCommentsRowConstraints.setMinHeight(40.0);
322+
dialectCommentsRowConstraints.setPrefHeight(40.0);
323+
}
324+
}
326325

327326
}
328327

kview/src/main/resources/dev/ikm/komet/kview/mvvm/view/properties/description-form.fxml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
<BorderPane minWidth="100.0" prefWidth="487.0" stylesheets="@../kview.css" xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1">
1818
<top>
19-
<HBox alignment="TOP_CENTER" prefHeight="0.0" prefWidth="0.0" styleClass="edit-concept-label-container" BorderPane.alignment="TOP_CENTER">
19+
<HBox alignment="TOP_CENTER" minHeight="40.0" prefHeight="40.0" prefWidth="0.0" styleClass="edit-concept-label-container" BorderPane.alignment="TOP_CENTER">
2020
<children>
2121
<Label fx:id="titleLabel" alignment="TOP_CENTER" styleClass="edit-concept-title" text="Description Form" textAlignment="CENTER" />
2222
</children>
2323
</HBox>
2424
</top>
2525
<bottom>
26-
<VBox alignment="TOP_CENTER" BorderPane.alignment="CENTER">
26+
<VBox alignment="TOP_CENTER" BorderPane.alignment="CENTER" minHeight="80.0" prefHeight="80.0">
2727
<children>
2828
<HBox alignment="BOTTOM_RIGHT" styleClass="add-description-bottom-label">
2929
<children>
@@ -62,15 +62,13 @@
6262
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
6363
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
6464
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
65-
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
66-
<RowConstraints maxHeight="1.7976931348623157E308" vgrow="NEVER" />
67-
<!-- Dialects section - will be hidden for non-edit modes -->
68-
<RowConstraints fx:id="dialectRowConstraints" maxHeight="1.7976931348623157E308" vgrow="ALWAYS" />
65+
<!-- Dialects section / Comments label : depending on edit mode will set all Height parameters programatically -->
66+
<RowConstraints fx:id="dialectCommentsRowConstraints" minHeight="40.0" prefHeight="40.0" maxHeight="40" vgrow="SOMETIMES" />
6967
<!-- Comments section -->
70-
<RowConstraints vgrow="SOMETIMES" />
68+
<RowConstraints vgrow="SOMETIMES" minHeight="80.0"/>
7169
</rowConstraints>
7270
<children>
73-
<Label styleClass="add-description-label" text="Name" />
71+
<Label styleClass="add-description-label" text="Name" GridPane.rowIndex="0" />
7472
<Label styleClass="add-description-label" text="Type" GridPane.rowIndex="1" />
7573
<Label prefWidth="100.0" styleClass="add-description-label" text="Case Significance" wrapText="true" GridPane.rowIndex="2" />
7674
<Label styleClass="add-description-label" text="Status" GridPane.rowIndex="3" />
@@ -79,7 +77,7 @@
7977
<Label fx:id="commentsLabel" styleClass="add-description-label" text="Comments" GridPane.rowIndex="6" />
8078

8179
<!-- Name field -->
82-
<TextField fx:id="nameTextField" styleClass="komet-text-field" prefHeight="25.0" promptText="Enter Name" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS">
80+
<TextField fx:id="nameTextField" styleClass="komet-text-field" prefHeight="25.0" promptText="Enter Name" GridPane.columnIndex="1" GridPane.rowIndex="0" GridPane.hgrow="ALWAYS">
8381
<GridPane.margin>
8482
<Insets right="15.0" />
8583
</GridPane.margin>
@@ -121,7 +119,7 @@
121119
</SortedComboBox>
122120

123121
<!-- Dialects section (hidden by default for add modes) -->
124-
<VBox fx:id="dialectsContainer" GridPane.columnSpan="2" GridPane.rowIndex="8">
122+
<VBox fx:id="dialectsContainer" GridPane.columnSpan="2" GridPane.rowIndex="6">
125123
<children>
126124
<HBox depthTest="ENABLE" styleClass="dialect-container">
127125
<children>
@@ -196,7 +194,7 @@
196194
</VBox>
197195

198196
<!-- Comments -->
199-
<TextArea fx:id="commentsTextArea" styleClass="komet-text-area" maxHeight="80.0" maxWidth="1.7976931348623157E308" text="Add comment here..." GridPane.columnSpan="2" GridPane.rowIndex="9">
197+
<TextArea fx:id="commentsTextArea" styleClass="komet-text-area" maxHeight="80.0" maxWidth="1.7976931348623157E308" text="Add comment here..." GridPane.columnSpan="2" GridPane.rowIndex="7" GridPane.valignment="TOP">
200198
<GridPane.margin>
201199
<Insets left="15.0" right="15.0" />
202200
</GridPane.margin>

0 commit comments

Comments
 (0)