@@ -17,17 +17,19 @@ import (
1717
1818// PropertyDef describes a single property from a widget XML definition.
1919type PropertyDef struct {
20- Key string // e.g. "staticDataSourceCaption"
21- Type string // XML type: "attribute", "expression", "textTemplate", "widgets", etc.
22- Caption string
23- Description string
24- Category string // from enclosing propertyGroup captions, joined with "::"
25- Required bool
26- DefaultValue string // for enumeration/boolean/integer types
27- IsList bool
28- IsSystem bool // true for <systemProperty> elements
29- DataSource string // dataSource attribute reference
30- ReturnType string // for expression properties: the <returnType type="..."/> Mendix type
20+ Key string // e.g. "staticDataSourceCaption"
21+ Type string // XML type: "attribute", "expression", "textTemplate", "widgets", etc.
22+ Caption string
23+ Description string
24+ Category string // from enclosing propertyGroup captions, joined with "::"
25+ Required bool
26+ DefaultValue string // for enumeration/boolean/integer types
27+ IsList bool
28+ Multiline bool // for string/textTemplate: multiline="true"
29+ SelectionTypes []string // for selection properties: <selectionType name="..."/>
30+ IsSystem bool // true for <systemProperty> elements
31+ DataSource string // dataSource attribute reference
32+ ReturnType string // for expression properties: the <returnType type="..."/> Mendix type
3133 // ReturnTypeAssignableTo is the <returnType assignableTo="..."/> reference (e.g.
3234 // "../staticAttribute"), when the expression's return type is derived from another
3335 // property rather than a concrete type. mxbuild emits Type "None" with this set.
@@ -94,17 +96,19 @@ type xmlWidgetFile struct {
9496
9597// xmlWidget represents <widget> root element in widget XML.
9698type xmlWidget struct {
97- ID string `xml:"id,attr"`
98- PluginWidget string `xml:"pluginWidget,attr"`
99- OfflineCapable string `xml:"offlineCapable,attr"`
100- NeedsEntityContext string `xml:"needsEntityContext,attr"`
101- SupportedPlatform string `xml:"supportedPlatform,attr"`
102- HelpURL string `xml:"helpUrl,attr"`
103- StudioCategory string `xml:"studioCategory,attr"`
104- StudioProCategory string `xml:"studioProCategory,attr"`
105- Name string `xml:"name"`
106- Description string `xml:"description"`
107- PropertyGroups []xmlPropGroup `xml:"properties>propertyGroup"`
99+ ID string `xml:"id,attr"`
100+ PluginWidget string `xml:"pluginWidget,attr"`
101+ OfflineCapable string `xml:"offlineCapable,attr"`
102+ NeedsEntityContext string `xml:"needsEntityContext,attr"`
103+ SupportedPlatform string `xml:"supportedPlatform,attr"`
104+ // helpUrl, studioCategory, studioProCategory are child ELEMENTS in Mendix
105+ // widget XML (e.g. <studioProCategory>Charts</studioProCategory>), not attributes.
106+ HelpURL string `xml:"helpUrl"`
107+ StudioCategory string `xml:"studioCategory"`
108+ StudioProCategory string `xml:"studioProCategory"`
109+ Name string `xml:"name"`
110+ Description string `xml:"description"`
111+ PropertyGroups []xmlPropGroup `xml:"properties>propertyGroup"`
108112}
109113
110114// xmlPropGroup represents <propertyGroup caption="..."> element.
@@ -198,17 +202,24 @@ type xmlProperty struct {
198202 DefaultValue string `xml:"defaultValue,attr"`
199203 Required string `xml:"required,attr"`
200204 IsList string `xml:"isList,attr"`
205+ Multiline string `xml:"multiline,attr"`
201206 DataSource string `xml:"dataSource,attr"`
202207 Caption string `xml:"caption"`
203208 Description string `xml:"description"`
204209 AttributeTypes []xmlAttributeType `xml:"attributeTypes>attributeType"`
205210 EnumValues []xmlEnumValue `xml:"enumerationValues>enumerationValue"`
211+ SelectionTypes []xmlSelectionType `xml:"selectionTypes>selectionType"`
206212 ReturnType xmlReturnType `xml:"returnType"`
207213 Translations []xmlTranslation `xml:"translations>translation"`
208214 // Nested properties for object type
209215 NestedProps []xmlPropGroup `xml:"properties>propertyGroup"`
210216}
211217
218+ // xmlSelectionType represents <selectionType name="..."/> on a selection property.
219+ type xmlSelectionType struct {
220+ Name string `xml:"name,attr"`
221+ }
222+
212223// xmlReturnType represents <returnType type="..."/> or
213224// <returnType assignableTo="../otherProp"/> on an expression property. A widget may
214225// declare either a concrete Mendix type or an assignableTo reference (the expression
@@ -382,6 +393,8 @@ func walkPropertyGroup(pg xmlPropGroup, parentCategory string, def *WidgetDefini
382393 Required : p .Required != "false" ,
383394 DefaultValue : p .DefaultValue ,
384395 IsList : p .IsList == "true" ,
396+ Multiline : p .Multiline == "true" ,
397+ SelectionTypes : toSelectionTypes (p .SelectionTypes ),
385398 DataSource : p .DataSource ,
386399 ReturnType : p .ReturnType .Type ,
387400 ReturnTypeAssignableTo : p .ReturnType .AssignableTo ,
@@ -452,6 +465,8 @@ func collectNestedProperties(pg xmlPropGroup, parent *PropertyDef, parentCategor
452465 Required : p .Required != "false" ,
453466 DefaultValue : p .DefaultValue ,
454467 IsList : p .IsList == "true" ,
468+ Multiline : p .Multiline == "true" ,
469+ SelectionTypes : toSelectionTypes (p .SelectionTypes ),
455470 DataSource : p .DataSource ,
456471 ReturnType : p .ReturnType .Type ,
457472 ReturnTypeAssignableTo : p .ReturnType .AssignableTo ,
@@ -473,6 +488,21 @@ func collectNestedProperties(pg xmlPropGroup, parent *PropertyDef, parentCategor
473488 }
474489}
475490
491+ // toSelectionTypes converts parsed <selectionType> XML elements to a name list
492+ // (e.g. ["None","Single"]), the ValueType.SelectionTypes a selection property carries.
493+ func toSelectionTypes (xs []xmlSelectionType ) []string {
494+ if len (xs ) == 0 {
495+ return nil
496+ }
497+ out := make ([]string , 0 , len (xs ))
498+ for _ , x := range xs {
499+ if x .Name != "" {
500+ out = append (out , x .Name )
501+ }
502+ }
503+ return out
504+ }
505+
476506// toTranslations converts parsed <translation> XML elements to Translation records,
477507// trimming caption whitespace (the XML pretty-prints chardata with indentation).
478508func toTranslations (xts []xmlTranslation ) []Translation {
@@ -721,7 +751,7 @@ func buildDefinition(widget *xmlWidget, version string) *WidgetDefinition {
721751 byKey [def .Properties [i ].Key ] = & def .Properties [i ]
722752 }
723753 for _ , pg := range widget .PropertyGroups {
724- collectTopLevelOrder (pg , def , byKey )
754+ collectTopLevelOrder (pg , "" , def , byKey )
725755 }
726756 return def
727757}
@@ -732,17 +762,26 @@ func buildDefinition(widget *xmlWidget, version string) *WidgetDefinition {
732762// PropertyDef (via byKey); system entries are recorded as Key + IsSystem. It does
733763// not descend into an object property's nested properties — only the top-level
734764// PropertyType order is reproduced here.
735- func collectTopLevelOrder (pg xmlPropGroup , def * WidgetDefinition , byKey map [string ]* PropertyDef ) {
765+ func collectTopLevelOrder (pg xmlPropGroup , parentCategory string , def * WidgetDefinition , byKey map [string ]* PropertyDef ) {
766+ category := pg .Caption
767+ if parentCategory != "" && category != "" {
768+ category = parentCategory + "::" + category
769+ } else if parentCategory != "" {
770+ category = parentCategory
771+ }
736772 for _ , c := range pg .Children {
737773 switch {
738774 case c .Property != nil :
739775 if pd := byKey [c .Property .Key ]; pd != nil {
740776 def .AllTopLevel = append (def .AllTopLevel , * pd )
741777 }
742778 case c .SystemProp != nil :
743- def .AllTopLevel = append (def .AllTopLevel , PropertyDef {Key : c .SystemProp .Key , IsSystem : true })
779+ // Category is the enclosing group chain (e.g. "General::Common"),
780+ // mirroring walkPropertyGroup; GenerateFromMPK emits it on the System
781+ // PropertyType so a generated widget matches mxbuild's definition.
782+ def .AllTopLevel = append (def .AllTopLevel , PropertyDef {Key : c .SystemProp .Key , IsSystem : true , Category : category })
744783 case c .SubGroup != nil :
745- collectTopLevelOrder (* c .SubGroup , def , byKey )
784+ collectTopLevelOrder (* c .SubGroup , category , def , byKey )
746785 }
747786 }
748787}
0 commit comments