@@ -62,12 +62,17 @@ public abstract class DescriptionBaseController<T> extends AbstractBasicControll
62
62
@ FXML
63
63
protected ComboBox <T > languageComboBox ;
64
64
65
- // Dialects (only visible in edit mode)
65
+
66
66
@ FXML
67
- protected VBox dialectsContainer ;
67
+ protected RowConstraints dialectCommentsRowConstraints ; // shared constrain in edit/add mode
68
68
69
69
@ 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 ;
71
76
72
77
@ FXML
73
78
protected Label dialect1 ;
@@ -110,15 +115,9 @@ public final void initialize() {
110
115
eventBus = EvtBusFactory .getDefaultEvtBus ();
111
116
clearView ();
112
117
113
-
114
- // Configure the form based on type
115
- //configureForm();
116
-
117
118
// Let subclasses do their specific initialization
118
119
initializeData ();
119
120
120
- // Post-initialization hook for subclasses
121
- //postInitialize();
122
121
}
123
122
124
123
protected abstract void initializeData ();
@@ -159,10 +158,6 @@ protected void handleCancel() {
159
158
160
159
@ FXML
161
160
protected void handleSubmit () {
162
- // Common validation logic
163
- //if (!validateForm()) {
164
- // return;
165
- //}
166
161
onSubmit ();
167
162
}
168
163
@@ -302,27 +297,31 @@ protected void close(Button button) {
302
297
303
298
protected void configureDialectVisibility (boolean showDialects ) {
304
299
300
+
301
+ if (commentsLabel != null ) {
302
+ commentsLabel .setVisible (!showDialects );
303
+ commentsLabel .setManaged (!showDialects );
304
+ }
305
+
305
306
if (dialectsContainer != null ) {
306
307
dialectsContainer .setVisible (showDialects );
307
308
dialectsContainer .setManaged (showDialects );
308
309
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 );
324
310
}
325
311
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
+ }
326
325
327
326
}
328
327
0 commit comments