Skip to content

Commit

Permalink
Merge deaba54
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Nov 16, 2024
2 parents 0930482 + deaba54 commit 317e542
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ OPTUmlAutoAccomodatingShape >> accomodateContents [
encompassingRectangle.
extentOfContents := self extentToFitContents max: self minExtent.
self roassalShape extent: extentOfContents.
(originalEncompassingRectangle height closeTo: extentOfContents y)
(originalEncompassingRectangle height closeTo: extentOfContents y)
ifTrue: [ ^ self ].
self roassalShape translateTo: self roassalShape position x
@
Expand Down
46 changes: 33 additions & 13 deletions repository/OpenPonk-ClassEditor/OPTUmlBaseController.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OPTUmlBaseController >> descriptionAccessor: aSymbol [
read: [ :me | me model perform: aSymbol ]
write: [ :me :newValue |
me model perform: (aSymbol , ':') asSymbol with: newValue.
self diagramElement modelChanged ]
self modelChanged ]
]

{ #category : 'forms' }
Expand All @@ -22,18 +22,18 @@ OPTUmlBaseController >> descriptionComment [
^ MAMemoDescription new
required: false;
accessor: (MAPluggableAccessor
read: [ :me |
read: [ :me |
me model ownedComments
ifEmpty: [ '' ]
ifNotEmpty: [ :oc | oc first body asString ] ]
write: [ :me :newValue |
write: [ :me :newValue |
newValue asString
ifEmpty: [ me model ownedComments: OrderedCollection new ]
ifNotEmpty: [
me model ownedComments ifEmpty: [
ifNotEmpty: [
me model ownedComments ifEmpty: [
me model ownedComments add: OPUMLComment new ].
me model ownedComments first body: newValue asString ].
self diagramElement modelChanged ]);
self modelChanged ]);
label: 'Comment';
priority: 100;
lineCount: 10;
Expand Down Expand Up @@ -66,7 +66,7 @@ OPTUmlBaseController >> descriptionVisibility [

<magritteDescription>
^ MASingleOptionDescription new
optionsAndLabels: {
optionsAndLabels: {
(nil -> '').
(OPUMLVisibilityKind public -> 'public').
(OPUMLVisibilityKind protected -> 'protected').
Expand All @@ -75,27 +75,47 @@ OPTUmlBaseController >> descriptionVisibility [
reference: MAStringDescription new;
accessor: (MAPluggableAccessor
read: [ :me | me model visibility ]
write: [ :me :newValue |
write: [ :me :newValue |
me model visibility: newValue.
self diagramElement modelChanged ]);
self modelChanged ]);
label: 'Visibility';
priority: 8;
beSorted;
yourself
]

{ #category : 'as yet unclassified' }
{ #category : 'validation' }
OPTUmlBaseController >> validateProperty: aProperty [

aProperty ifNil: [ ^ self ].
aProperty owningClass ifNil: [ ^ self ].
aProperty owningAssociation ifNil: [ ^ self ].
aProperty owningClass
ifNil: [
aProperty owningAssociation ifNil: [
self validationFailedPropertyWithoutOwner: aProperty ] ]
ifNotNil: [
aProperty owningAssociation ifNotNil: [
self validationFailedPropertyWithTwoOwners: aProperty ] ]
]

{ #category : 'validation' }
OPTUmlBaseController >> validationFailedPropertyWithTwoOwners: aProperty [

OPModelInvalid signal: (String streamContents: [ :s |
s << 'Property "' << aProperty name asString << '" owned by '
<< aProperty owningClass asString << ' is also owned by '
<< aProperty owningAssociation asString ]).

"Remove the ownership by the association in order to load the model"
aProperty owningAssociation: nil
]

{ #category : 'validation' }
OPTUmlBaseController >> validationFailedPropertyWithoutOwner: aProperty [

OPModelInvalid signal: (String streamContents: [ :s |
s << 'Property "' << aProperty name asString << '" with type '
<< aProperty type asString << ' has no owner' ]).

"Attempt to create an ownership"
aProperty type ifNotNil: [ aProperty owningClass: aProperty type ]
]
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OPTUmlStereotypedElementController >> descriptionStereotypeContent [
applyStereotype:
(stereotypes detect: [ :each | each name = newValue ])
to: me model ].
me diagramElement modelChanged ]);
me modelChanged ]);
label: 'Stereotype';
priority: 4;
yourself
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ Class {
#tag : 'Controllers'
}

{ #category : 'announcements' }
OPUmlAbstractAssociationController >> classAttributeChanged [

super modelChanged
]

{ #category : 'accessing' }
OPUmlAbstractAssociationController >> elementsToShowInside [

^ super elementsToShowInside , self model memberEnds
]

{ #category : 'announcements' }
OPUmlAbstractAssociationController >> modelChanged [

super modelChanged.
self model memberEnds
select: [ :each | each owningClass isNotNil ]
thenDo: [ :each |
self diagramController
controllerForModel: each
ifFound: [ :controller | controller associationChanged ] ]
]

{ #category : 'accessing' }
OPUmlAbstractAssociationController >> modelSource [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ OPUmlAssociationController >> descriptionActionSwitchSourceTarget [
self canSwitchSourceAndTarget ifFalse: [ ^ self ].
description := OPMAActionDescription new.
description
action: [
action: [
self switchSourceAndTarget.
self diagramController editor openFormOn: self.
self diagramElement modelChanged ];
self modelChanged ];
label: 'Switch source/target';
priority: 9.05.
^ description
Expand Down
36 changes: 30 additions & 6 deletions repository/OpenPonk-ClassEditor/OPUmlAttributeController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ OPUmlAttributeController >> addDiagramElementToOwner [
self ownerDiagramElement addAttribute: self diagramElement
]

{ #category : 'announcements' }
OPUmlAttributeController >> associationChanged [

super modelChanged
]

{ #category : 'figures' }
OPUmlAttributeController >> createDiagramElement [

Expand Down Expand Up @@ -63,7 +69,7 @@ OPUmlAttributeController >> descriptionDefaultValue [
ifTrue: [
me model defaultValue bodies:
(newValue ifEmpty: [ { } ] ifNotEmpty: [ { newValue } ]) ].
self diagramElement modelChanged ]);
self modelChanged ]);
label: 'Default Value';
priority: 42;
yourself
Expand Down Expand Up @@ -118,12 +124,12 @@ OPUmlAttributeController >> descriptionMultiplicity [
options: #( '0..1' '1..1' '0..*' '1..*' );
reference: MAStringDescription new;
accessor: (MAPluggableAccessor
read: [ :me |
read: [ :me |
me model lowerBound asString , '..'
, me model upperBound asString ]
write: [ :me :newValue |
write: [ :me :newValue |
self writeMultiplicityFrom: newValue to: me model.
self diagramElement modelChanged ]);
self modelChanged ]);
label: 'Multiplicity';
priority: 9;
beSorted;
Expand All @@ -137,11 +143,11 @@ OPUmlAttributeController >> descriptionType [
^ MAStringDescription new
accessor: (MAPluggableAccessor
read: [ :me | me model type ifNil: [ '' ] ifNotNil: #name ]
write: [ :me :newValue |
write: [ :me :newValue |
newValue
ifEmpty: [ me model type: nil ]
ifNotEmpty: [ me model type: (self typeNamed: newValue) ].
self diagramElement modelChanged ]);
self modelChanged ]);
label: 'Type';
priority: 5;
yourself
Expand All @@ -153,6 +159,16 @@ OPUmlAttributeController >> diagramElementClass [
^ OPUmlAttributeLabel
]

{ #category : 'announcements' }
OPUmlAttributeController >> modelChanged [

super modelChanged.
self model association ifNotNil: [ :association |
self diagramController
controllerForModel: association
ifFound: [ :controller | controller classAttributeChanged ] ]
]

{ #category : 'accessing' }
OPUmlAttributeController >> modelClass [
^ OPUMLProperty
Expand Down Expand Up @@ -203,10 +219,18 @@ OPUmlAttributeController >> removeDiagramElement [
OPUmlAttributeController >> removeModel [
"could be any of those, so just nil all of them"

self model association ifNotNil: [ ^ self switchOwnerToAssociation ].
self model owningAssociation: nil.
super removeModel
]

{ #category : 'removing' }
OPUmlAttributeController >> switchOwnerToAssociation [

self model owningClass: nil.
self model owningAssociation: self model association
]

{ #category : 'accessing' }
OPUmlAttributeController >> typeNamed: aName [
OPUMLXMISpecsStorage primitivesMap at: aName ifPresent: [ :prim | ^ prim ].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ OPUmlClassController >> createAttributeAdornmentBy: builder [
self diagramController editor palette selectTool: tool.
tool whenCreated: [ :ctrl |
OPRenameElementCommand executeOn: ctrl.
ctrl diagramElement modelChanged ].
ctrl modelChanged ].
tool selectedControllers: { self } ]
]

Expand Down
2 changes: 1 addition & 1 deletion repository/OpenPonk-ClassEditor/OPUmlClassShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ OPUmlClassShape >> addAttribute: anAttributeShape [
{ #category : 'rendering' }
OPUmlClassShape >> addOperation: anOperationShape [

operations ifNil: [
operations ifNil: [
operations := OPUmlFeaturesListCompartment in: self.

self sortOwnedElements ].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ OPUmlClassifierController >> descriptionName [
| accessor |
accessor := MAPluggableAccessor
read: [ :me | me model name ]
write: [ :me :newValue |
write: [ :me :newValue |
me model name: newValue.
self diagramElement modelChanged ].
self modelChanged ].
^ MAMemoDescription new
accessor: accessor;
label: 'Name';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ OPUmlClassifierItemController >> descriptionName [
| text |
text := newValue trim ifEmpty: [ self placeholderName ].
me model name: text.
self diagramElement modelChanged ].
self modelChanged ].
^ description
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ OPUmlCompartmentableShape >> layoutSeparators [
]

{ #category : 'as yet unclassified' }
OPUmlCompartmentableShape >> ownedElement: aShape renderedIn: aCanvas [
OPUmlCompartmentableShape >> recursivelyOwnedElement: aShape renderedIn: aCanvas [

| wasRendered |
wasRendered := self isRenderedWithOwnedElements.
super ownedElement: aShape renderedIn: aCanvas.
wasRendered ifTrue: [ self updateRenderFromModel ]
super recursivelyOwnedElement: aShape renderedIn: aCanvas.
self isRenderedWithOwnedElements ifTrue: [
self updateRenderFromModel ]
]

{ #category : 'removing' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ OPUmlPackageDiagramController >> descriptionAppliedProfiles [
OPUMLProfileApplication new appliedProfile:
each yourself ]).
self rebuildPalette.
self diagramElement modelChanged ]);
self modelChanged ]);
label: 'Applied Profiles';
priority: 10;
beSorted;
Expand Down Expand Up @@ -308,47 +308,47 @@ OPUmlPackageDiagramController >> initializePalette: aPalette [
OPUmlPackageDiagramController >> initializeProfile: aProfile palette: aPalette [

| stereotypes elements relationships isForRelationship isForClass |
stereotypes := (aProfile ownedStereotype reject: #isAbstract)
stereotypes := (aProfile ownedStereotype reject: #isAbstract)
sorted: [ :a :b | a name < b name ].
isForRelationship := [ :attr |
isForRelationship := [ :attr |
(OPUMLXMISpecsStorage metaClassNamed:
attr type name) allParents anySatisfy: [
attr type name) allParents anySatisfy: [
:parent | parent name = 'Relationship' ] ].
isForClass := [ :attr |
isForClass := [ :attr |
| metaclass |
metaclass := OPUMLXMISpecsStorage metaClassNamed:
attr type name.
metaclass name = 'Class' or: [
metaclass allParents anySatisfy: [ :parent |
metaclass name = 'Class' or: [
metaclass allParents anySatisfy: [ :parent |
parent name = 'Class' ] ] ].
elements := stereotypes select: [ :each |
each allAttributes anySatisfy: [ :attr |
(attr name beginsWith: 'base_') and: [
elements := stereotypes select: [ :each |
each allAttributes anySatisfy: [ :attr |
(attr name beginsWith: 'base_') and: [
isForClass value: attr ] ] ].
relationships := stereotypes select: [ :each |
each allAttributes anySatisfy: [ :attr |
(attr name beginsWith: 'base_') and: [
relationships := stereotypes select: [ :each |
each allAttributes anySatisfy: [ :attr |
(attr name beginsWith: 'base_') and: [
isForRelationship value: attr ] ] ].
elements ifNotEmpty: [ aPalette newSeparator ].
elements do: [ :stereotype |
elements do: [ :stereotype |
(aPalette newCreationEntry: [ OPUmlClassController new ])
label: stereotype name;
icon: OPUmlIcons classIcon;
whenCreated: [ :ctrl |
whenCreated: [ :ctrl |
ctrl model applyStereotype: stereotype implementationClass new.
ctrl model name: stereotype name.
ctrl diagramElement modelChanged.
ctrl modelChanged.
OPInitialSetElementCommand executeOn: ctrl.
ctrl diagramElement modelChanged ] ].
ctrl modelChanged ] ].
relationships ifNotEmpty: [ aPalette newSeparator ].
relationships do: [ :stereotype |
(aPalette newConnectionCreationEntry: [
relationships do: [ :stereotype |
(aPalette newConnectionCreationEntry: [
OPUmlAssociationController new ])
label: stereotype name;
icon: OPUmlIcons directedAssociationIcon;
whenCreated: [ :ctrl |
whenCreated: [ :ctrl |
ctrl model applyStereotype: stereotype implementationClass new.
ctrl diagramElement modelChanged ] ]
ctrl modelChanged ] ]
]

{ #category : 'palette' }
Expand Down
Loading

0 comments on commit 317e542

Please sign in to comment.