@@ -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
0 commit comments