@@ -53,7 +53,7 @@ public final class StandardEditorWindows {
5353 * re-seeded from the current code, so application-shipped windows never go stale in the
5454 * preferences. User-authored windows live in the user-windows folder and are untouched.
5555 */
56- private static final int CURRENT_STANDARD_WINDOWS_VERSION = 11 ;
56+ private static final int CURRENT_STANDARD_WINDOWS_VERSION = 12 ;
5757
5858 /** Preferences key holding the version the seeded standard windows were created from. */
5959 private static final String STANDARD_WINDOWS_VERSION_KEY = "STANDARD-WINDOWS-VERSION" ;
@@ -271,7 +271,10 @@ private static void showDescriptionTextOnly(EditorPatternModel descriptionPatter
271271 * then its data type — the field-purpose column is left out). The Meaning and Purpose pattern and the fully
272272 * qualified name column are required when the window is opened in the Journal in create mode —
273273 * so, as in the Concept window, the pattern can only be created once it has a fully qualified
274- * name; Fields is not required (a membership pattern has no fields).
274+ * name; Fields is not required (a membership pattern has no fields). Once the pattern exists
275+ * (the window is in edit mode) neither the Meaning and Purpose pattern nor the Fields pattern
276+ * accepts new semantics — a pattern has one meaning and purpose, and its fields are fixed — and a
277+ * committed field's data type can no longer be changed.
275278 * Unlike the Concept window it keeps the default grey
276279 * chrome (see the concept-window-theme rules in kview.css, applied only to
277280 * {@link EditorWindowType#STANDARD_CONCEPT}).
@@ -365,10 +368,24 @@ private static EditorSectionModel createFieldsSection(ViewCalculator viewCalcula
365368 KlPatternSemanticsFactories .byClassName (KlPatternSemanticsFactories .TABLE_FACTORY_CLASS_NAME )
366369 .ifPresent (fieldsPattern ::setFactory );
367370 arrangeFieldColumns (fieldsPattern , viewCalculator );
371+ // The fields of a committed pattern are fixed: no field can be added once the pattern exists,
372+ // and an existing field keeps its data type (its meaning can still be corrected).
373+ fieldsPattern .setAllowNewSemantics (false );
374+ fixFieldDataType (fieldsPattern , viewCalculator );
368375 fieldsSection .getPatterns ().add (fieldsPattern );
369376 return fieldsSection ;
370377 }
371378
379+ /**
380+ * Makes the Fields pattern's "Field data type" field not editable, so the data type of a committed
381+ * field is shown in the Journal's edit form but can't be changed (see
382+ * {@link EditorPatternModel#fieldEditableProperty(int)}).
383+ */
384+ private static void fixFieldDataType (EditorPatternModel fieldsPattern , ViewCalculator viewCalculator ) {
385+ viewCalculator .latestPatternEntityVersion (PatternDefinitionTerms .FIELDS_PATTERN ).ifPresent (patternVersion ->
386+ fieldsPattern .fieldEditableProperty (patternVersion .indexForMeaning (KlTerms .FIELD_DATA_TYPE )).set (false ));
387+ }
388+
372389 /**
373390 * Arranges the Fields pattern's placement so the Fields table shows each field as its meaning
374391 * followed by its data type: the "Field purpose" field is removed, and the meaning field is
@@ -398,6 +415,9 @@ private static void populateDefinitionSection(ViewCalculator viewCalculator, Edi
398415 EditorPatternModel meaningAndPurposePattern = new EditorPatternModel (viewCalculator ,
399416 PatternDefinitionTerms .MEANING_AND_PURPOSE_PATTERN .nid ());
400417 meaningAndPurposePattern .setRequired (true );
418+ // A pattern has exactly one meaning and purpose: the semantic created with the pattern can be
419+ // edited, but no second one can be added once the pattern exists.
420+ meaningAndPurposePattern .setAllowNewSemantics (false );
401421
402422 // The pattern's two fields side by side — meaning in the left column, purpose in the right
403423 // (the pattern defines them in that order) — rather than stacked one per row.
0 commit comments