Skip to content

Commit

Permalink
sync class attribute and association end, enlarge class for contents …
Browse files Browse the repository at this point in the history
…properly
  • Loading branch information
JanBliznicenko committed Nov 16, 2024
1 parent 117966b commit deaba54
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 57 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
18 changes: 9 additions & 9 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,9 +75,9 @@ 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;
Expand Down
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,12 +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
28 changes: 22 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ OPUmlPropertyMagritteDescriptions >> descriptionAccessor: aSymbol [
(reader value: me)
perform: (aSymbol , ':') asSymbol
with: newValue.
me ifNotNil: [ me diagramElement modelChanged ] ]
me ifNotNil: [ me modelChanged ] ]
]

{ #category : 'descriptions' }
Expand Down Expand Up @@ -99,9 +99,9 @@ OPUmlPropertyMagritteDescriptions >> descriptionIsNavigable [
^ MABooleanDescription new
accessor: (MAPluggableAccessor
read: [ :me | (reader value: me) isNavigable ]
write: [ :me :newValue |
write: [ :me :newValue |
me writeNavigability: newValue to: (reader value: me).
me diagramElement modelChanged ]);
me modelChanged ]);
label: 'Is Navigable';
priority: 10;
yourself
Expand Down Expand Up @@ -156,12 +156,12 @@ OPUmlPropertyMagritteDescriptions >> descriptionMultiplicity [
options: #( '0..1' '1..1' '0..*' '1..*' );
reference: MAStringDescription new;
accessor: (MAPluggableAccessor
read: [ :me |
read: [ :me |
(reader value: me) lowerBound asString , '..'
, (reader value: me) upperBound asString ]
write: [ :me :newValue |
write: [ :me :newValue |
me writeMultiplicityFrom: newValue to: (reader value: me).
me diagramElement modelChanged ]);
me modelChanged ]);
label: 'Multiplicity';
priority: 9;
beSorted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ OPUmlStereotypeDescriptions >> accessorFor: anAttribute of: aStereotype [
aStereotype
perform: (anAttribute name , ':') asSymbol
with: newValue.
controller diagramElement modelChanged ]
controller modelChanged ]
]

{ #category : 'adding' }
Expand Down

0 comments on commit deaba54

Please sign in to comment.