diff --git a/repository/OpenPonk-ClassEditor/OPTUmlBaseController.trait.st b/repository/OpenPonk-ClassEditor/OPTUmlBaseController.trait.st index cef7a188..7a301efc 100644 --- a/repository/OpenPonk-ClassEditor/OPTUmlBaseController.trait.st +++ b/repository/OpenPonk-ClassEditor/OPTUmlBaseController.trait.st @@ -88,15 +88,35 @@ OPTUmlBaseController >> descriptionVisibility [ OPTUmlBaseController >> validateProperty: aProperty [ aProperty ifNil: [ ^ self ]. - aProperty owningClass + (aProperty association isNotNil and: [ + (aProperty respondsTo: #oclIsKindOf:) not or: [ + aProperty oclIsKindOf: #Classifier ] ]) ifTrue: [ + self validationFailedAssociationPropertyWithoutClassifierType: + aProperty ]. + aProperty owningAssociation ifNil: [ - aProperty owningAssociation ifNil: [ + aProperty owningClass ifNil: [ self validationFailedPropertyWithoutOwner: aProperty ] ] ifNotNil: [ - aProperty owningAssociation ifNotNil: [ + aProperty owningClass ifNotNil: [ self validationFailedPropertyWithTwoOwners: aProperty ] ] ] +{ #category : 'validation' } +OPTUmlBaseController >> validationFailedAssociationPropertyWithoutClassifierType: aProperty [ + + OPModelInvalid signal: (String streamContents: [ :s | + s << 'Property "' << aProperty name asString << '" has type ' + << aProperty type asString << ' although it is part of ' + << aProperty association asString ]). + + "Try to use opposite owningClass as type" + aProperty opposite owningClass ifNotNil: [ :oppositeOwner | + aProperty type: oppositeOwner ] + + "No way to fix this - the association end information is lost" +] + { #category : 'validation' } OPTUmlBaseController >> validationFailedPropertyWithTwoOwners: aProperty [ diff --git a/repository/OpenPonk-ClassEditor/OPUmlAttributeController.class.st b/repository/OpenPonk-ClassEditor/OPUmlAttributeController.class.st index 5576d89a..f434e9af 100644 --- a/repository/OpenPonk-ClassEditor/OPUmlAttributeController.class.st +++ b/repository/OpenPonk-ClassEditor/OPUmlAttributeController.class.st @@ -140,17 +140,27 @@ OPUmlAttributeController >> descriptionMultiplicity [ OPUmlAttributeController >> descriptionType [ - ^ MAStringDescription new - accessor: (MAPluggableAccessor - read: [ :me | me model type ifNil: [ '' ] ifNotNil: #name ] - write: [ :me :newValue | - newValue - ifEmpty: [ me model type: nil ] - ifNotEmpty: [ me model type: (self typeNamed: newValue) ]. - self modelChanged ]); - label: 'Type'; - priority: 5; - yourself + | description writeBlock | + description := MAStringDescription new. + writeBlock := self model association + ifNotNil: [ + description beReadOnly. + [ :me :newValue | ] ] + ifNil: [ + [ :me :newValue | + newValue + ifEmpty: [ me model type: nil ] + ifNotEmpty: [ + me model type: (self typeNamed: newValue) ]. + self modelChanged ] ]. + description + accessor: (MAPluggableAccessor + read: [ :me | + me model type ifNil: [ '' ] ifNotNil: [ :type | type name ] ] + write: writeBlock); + label: 'Type'; + priority: 5. + ^ description ] { #category : 'figures' } diff --git a/repository/OpenPonk-ClassEditor/OPUmlPropertyMagritteDescriptions.class.st b/repository/OpenPonk-ClassEditor/OPUmlPropertyMagritteDescriptions.class.st index e6c1d810..8727c91a 100644 --- a/repository/OpenPonk-ClassEditor/OPUmlPropertyMagritteDescriptions.class.st +++ b/repository/OpenPonk-ClassEditor/OPUmlPropertyMagritteDescriptions.class.st @@ -180,16 +180,19 @@ OPUmlPropertyMagritteDescriptions >> descriptionName [ { #category : 'descriptions' } OPUmlPropertyMagritteDescriptions >> descriptionType [ + ^ MAStringDescription new - beReadOnly; - accessor: - (MAPluggableAccessor - read: [ :me | (reader value: me) type name ] - write: [ :me :newValue | ]); - label: labelPrefix; - priority: 1; - yourself + beReadOnly; + accessor: (MAPluggableAccessor + read: [ :me | + (reader value: me) type + ifNil: [ '' ] + ifNotNil: [ :type | type name ] ] + write: [ :me :newValue | ]); + label: labelPrefix; + priority: 1; + yourself ] { #category : 'descriptions' }