How to define a Magritte form field

A form field is defined by a MADescription MAObject subclass: #MADescription instanceVariableNames: 'accessor' classVariableNames: '' package: 'Magritte-Model-Description' . A description takes a label, names for accessors, and some optional properties. From that information, it generates a form field.

In the case of the class form shown in the main page of the gt4magritte section, the superclass name looks like this:

GtClassCreationForm>>#superclassDescription superclassDescription <magritteDescription> ^ MAStringDescription new label: 'Superclass'; priority: 2; accessor: #superclassName; blocCompletion: [ GtStringsCompletionStrategy new completions: (GtPharoIndex current classNameTree) ]; blocShortcuts: [ {BlShortcutWithAction new name: 'Browse class'; description: 'Browses the class indicated by the editor'; combination: BlKeyCombination primaryB; action: [ :anEvent | anEvent target phlow spawnTool: (GtClassCoderTool forClass: anEvent target text asString asClass) ]. BlShortcutWithAction new name: 'Inspect class'; description: 'Inspects the class indicated by the editor'; combination: BlKeyCombination primaryG; action: [ :anEvent | anEvent target phlow spawnObject: anEvent target text asString asClass ]. BlShortcutWithAction new name: 'Browse class references'; description: 'Browses references to the class indicated by the editor'; combination: BlKeyCombination primaryN; action: [ :anEvent | anEvent target phlow spawnObject: anEvent target text asString asClass gtReferences ]} ]; editorAptitude: [ BrGlamorousRegularEditorAptitude new glamorousFormEditorCodeFontAndSize+ (BrGlamorousWithContextMenuAptitude content: [ BrGlamorousSimpleContextMenuContent new items: (self contextMenuItemsForSuperclass) ]) ]; labelAptitude: [ BrGlamorousLabelAptitude new glamorousFormLabelStyle ]; addCondition: [ :aValue | (Smalltalk classNamed: aValue trim) isNotNil ] labelled: 'Unknown class'; addCondition: [ :aValue | | aClass | aClass := Smalltalk classNamed: aValue trim. aClass isNil or: [ aClass isClass ] ] labelled: 'Must be a class'; addCondition: [ :aValue | | aClass | aClass := Smalltalk classNamed: aValue trim. aClass isNil or: [ aClass isInstanceSide ] ] labelled: 'Must be an instance-side class'; beRequired

In this case we also set, apart from the required properties, a priority, a completion strategy, and a validation condition.

You can also use custom widget stencils in the descriptions, as exemplified by the class vars, for example:

GtClassCreationForm>>#classVarsDescription classVarsDescription <magritteDescription> ^ MAToManyRelationDescription new label: 'Class vars'; priority: 8; accessor: #classVars; labelAptitude: [ (BrGlamorousLabelAptitude new glamorousFormLabelStyle) + (BrGlamorousWithLabelTooltipAptitude new text: 'Variables whose values (memory) is shared across all instances of a class and its subclasses.') ]; classes: {String}; blocListStencil: (self taggerStencilWithCompletion: nil andContextMenuBlock: nil)

In either case, the pragma magritteDescription is needed. How to use this to build a form can be discovered in How to build a Magritte form.