Skip to content

Commit

Permalink
multiple multi-diagram project fixes, fixed disappearing notes
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Dec 4, 2024
1 parent a1a861b commit a3ae9e7
Show file tree
Hide file tree
Showing 97 changed files with 1,235 additions and 1,056 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ OPAbstractDiagramControllerTest >> setUp [

super setUp.
controller model: model.
controller diagramElement: OPDiagram new.
controller diagramElement: (OPOpenPonkDiagram forModelElement: model).
controller canvasPresenter: (OPCanvasPresenter new
canvas: RSCanvas new;
yourself)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,6 @@ OPAbstractDirectionalRelationshipControllerTest >> testCreateUsingAddAsTarget [
equals: self diagramElementClass
]

{ #category : 'tests - construction' }
OPAbstractDirectionalRelationshipControllerTest >> testFigureWasRendered [

self showInDiagram.
self assert:
(diagramController canvas lines includes: controller roassalShape)
]

{ #category : 'tests' }
OPAbstractDirectionalRelationshipControllerTest >> testRemovalOfSourceRemovesRelationship [

Expand Down Expand Up @@ -273,6 +265,14 @@ OPAbstractDirectionalRelationshipControllerTest >> testRemoveController [
hasSameElements: { }
]

{ #category : 'tests - construction' }
OPAbstractDirectionalRelationshipControllerTest >> testRoassalShapeWasRendered [

self showInDiagram.
self assert:
(diagramController canvas lines includes: controller roassalShape)
]

{ #category : 'as yet unclassified' }
OPAbstractDirectionalRelationshipControllerTest >> testSetupOfTheTest [
"tests mostly whether the creationTarget is really the same thing as source - in case it is not, it is probably fault of the test class itself"
Expand Down
188 changes: 163 additions & 25 deletions repository/OpenPonk-Core/OPAbstractElementControllerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ OPAbstractElementControllerTest >> setUp [
diagramController canvasPresenter: (OPCanvasPresenter new
canvas: RSCanvas new;
yourself).
diagramController diagramElement: OPDiagram new.
diagramController diagramElement:
(OPOpenPonkDiagram forModelElement: diagramController model).
self setUpCreationTarget
]

Expand Down Expand Up @@ -122,11 +123,142 @@ OPAbstractElementControllerTest >> testAddController [
self prepareToShow.
diagramController addController: controller.
self
assert: (diagramController controllerForModel: model)
assert: (diagramController controllerForModel: self model)
equals: controller.
self assert: controller diagramController equals: diagramController
]

{ #category : 'tests - ui interaction' }
OPAbstractElementControllerTest >> testBeingCopiedWithDiagram [

| diagram diagramElement diagramControllerOfCopy |
self assertEmpty: diagramController controllers.
self showInDiagram.
diagram := diagramController diagramElement.
diagramElement := controller diagramElement.
self assert: (diagramController hasControllerForModel: self model).
self
assertCollection: diagram allOwnedElements
includesAll: { diagramElement }.
self
assertCollection: diagramController controllers
includesAll: { controller }.
diagramControllerOfCopy := self diagramControllerClass new.
diagramControllerOfCopy model: diagramController model.
self
shouldnt: [ diagramControllerOfCopy diagramElement: diagram newCopy ]
raise: OPInvalidWarning.
diagramControllerOfCopy canvasPresenter: (OPCanvasPresenter new
canvas: RSCanvas new;
yourself).
diagramControllerOfCopy diagramFocused.
self
assertCollection:
(diagramControllerOfCopy diagram allOwnedElements collect:
#modelElement)
hasSameElements:
(diagramController diagram allOwnedElements collect: #modelElement).
self
assertCollection:
(diagramControllerOfCopy controllers collect: #model)
hasSameElements: (diagramController controllers collect: #model)
]

{ #category : 'tests - ui interaction' }
OPAbstractElementControllerTest >> testBeingKeptWhenEditorFocusChanges [

self
assertCollection: diagramController controllers
hasSameElements: { }.
self showInDiagram.
self
assertCollection: diagramController controllers
includesAll: { controller }.
diagramController diagramFocused.
self
assertCollection: diagramController controllers
includesAll: { controller }
]

{ #category : 'tests - ui interaction' }
OPAbstractElementControllerTest >> testBeingRemovedAfterModelRemovalWhenNotRendered [

| diagram diagramElement newDiagramControllerBlock diagramControllerOfCopy controllerOfCopy recreatedDiagramController |
self
denyCollection: diagramController controllers
includesAll: { controller }.
self showInDiagram.
diagram := diagramController diagramElement.
diagramElement := controller diagramElement.
self
assertCollection: diagram allOwnedElements
includesAll: { diagramElement }.
self
assertCollection: diagramController controllers
includesAll: { controller }.
self assert: diagramElement isRendered.
diagramController removeController.
self
assertCollection: diagram allOwnedElements
includesAll: { diagramElement }.
self deny: diagramElement isRendered.
self
denyCollection: diagramController controllers
includesAll: { controller }.
newDiagramControllerBlock := [ :copyOfDiagram |
| newDiagramController |
newDiagramController := self
diagramControllerClass
new.
newDiagramController model:
diagramController model.
newDiagramController diagramElement:
copyOfDiagram.
newDiagramController canvasPresenter:
(OPCanvasPresenter new
canvas: RSCanvas new;
yourself).
newDiagramController diagramFocused.
newDiagramController ].


self
shouldnt: [
diagramControllerOfCopy := newDiagramControllerBlock value:
diagram newCopy ]
raise: OPInvalidWarning.
controllerOfCopy := diagramControllerOfCopy controllerForModel: model.
controllerOfCopy removeModel.
recreatedDiagramController := newDiagramControllerBlock value:
diagram.
recreatedDiagramController validate.
self
denyCollection: diagram allOwnedElements
includesAll: { diagramElement }.
self deny: diagramElement isRendered.
self
denyCollection: recreatedDiagramController controllers
includesAll: { controller }
]

{ #category : 'tests - ui interaction' }
OPAbstractElementControllerTest >> testBeingRemovedAfterModelRemovalWhenRendered [

self
denyCollection: diagramController controllers
includesAll: { controller }.
self showInDiagram.
self
assertCollection: diagramController controllers
includesAll: { controller }.
controller removeModel.
controller model: model.
diagramController diagramFocused.
self
denyCollection: diagramController controllers
includesAll: { controller }
]

{ #category : 'tests' }
OPAbstractElementControllerTest >> testClassSideModelClass [

Expand All @@ -145,7 +277,11 @@ OPAbstractElementControllerTest >> testCreateAndShow [
includesAll: { controller }.
self
assertCollection: diagramController canvas shapes
includesAll: { controller roassalShape }
includesAll: { controller roassalShape }.
self
assert: diagramController isRendered
description:
'Diagram controller not showing as rendered when element is'
]

{ #category : 'tests' }
Expand Down Expand Up @@ -223,27 +359,11 @@ OPAbstractElementControllerTest >> testDescriptionName [
diagramElement should receive modelChanged
]

{ #category : 'tests - controllers' }
OPAbstractElementControllerTest >> testFigureForModel [

self showInDiagram.
self
assert: (diagramController roassalShapeForModel: model)
equals: controller roassalShape
]

{ #category : 'tests - construction' }
OPAbstractElementControllerTest >> testFigureWasRendered [

self showInDiagram.
self assert:
(diagramController canvas nodes includes: controller roassalShape)
]

{ #category : 'tests' }
OPAbstractElementControllerTest >> testIsSupported [

self assert: (diagramController hasSupportForModel: model)
self assert:
(diagramController hasSupportForModel: self controllersByModelsKey)
]

{ #category : 'tests' }
Expand All @@ -257,12 +377,13 @@ OPAbstractElementControllerTest >> testModelForFigure [
self showInDiagram.
self
assert: (diagramController modelForFigure: controller roassalShape)
equals: model
equals: self model
]

{ #category : 'tests - controllers' }
OPAbstractElementControllerTest >> testNewController [
controller := diagramController newControllerFor: model.
OPAbstractElementControllerTest >> testNewControllerFor [

controller := diagramController newControllerFor: self controllersByModelsKey.
self assert: controller class equals: self controllerClass
]

Expand Down Expand Up @@ -321,6 +442,23 @@ OPAbstractElementControllerTest >> testRemoveModel [
self denyCollection: self allElements includesAll: { model }
]

{ #category : 'tests - controllers' }
OPAbstractElementControllerTest >> testRoassalShapeForModel [

self showInDiagram.
self
assert: (diagramController roassalShapeForModel: self model)
equals: controller roassalShape
]

{ #category : 'tests - construction' }
OPAbstractElementControllerTest >> testRoassalShapeWasRendered [

self showInDiagram.
self assert:
(diagramController canvas nodes includes: controller roassalShape)
]

{ #category : 'tests - construction' }
OPAbstractElementControllerTest >> testShowInDiagram [

Expand All @@ -331,5 +469,5 @@ OPAbstractElementControllerTest >> testShowInDiagram [
controller roassalShape)
equals: controller.
self assert: (diagramController canvas shapes anySatisfy: [ :each |
each model isNotNil and: [ each model modelElement = model ] ])
each model isNotNil and: [ each model modelElement = self model ] ])
]
2 changes: 1 addition & 1 deletion repository/OpenPonk-Core/OPAbstractNodeTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Class {
OPAbstractNodeTest >> testDoesNotMoveOnShapeCreation [

| diagram originalRoassalPosition movedRoassalPosition newShape |
diagram := OPDiagram new.
diagram := OPOpenPonkDiagram new.
diagram renderIn: canvas.
shape owningElement: diagram.
shape modelElement: model.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : 'OPAllFiguresDeselected',
#superclass : 'Announcement',
#category : 'OpenPonk-Core-Controllers',
#package : 'OpenPonk-Core',
#tag : 'Controllers'
}
Class {
#name : 'OPAllShapesDeselected',
#superclass : 'Announcement',
#category : 'OpenPonk-Core-Controllers',
#package : 'OpenPonk-Core',
#tag : 'Controllers'
}
12 changes: 12 additions & 0 deletions repository/OpenPonk-Core/OPBaseControllerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ OPBaseControllerTest >> controllerClass [
^ self subclassResponsibility
]

{ #category : 'accessing' }
OPBaseControllerTest >> controllersByModelsKey [

^ self model
]

{ #category : 'accessing' }
OPBaseControllerTest >> model [

^ model
]

{ #category : 'accessing' }
OPBaseControllerTest >> modelClass [
^ self subclassResponsibility
Expand Down
6 changes: 0 additions & 6 deletions repository/OpenPonk-Core/OPBoundaryControllerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,3 @@ OPBoundaryControllerTest >> diagramModelClass [

^ OPTestContainerModel
]

{ #category : 'accessing' }
OPBoundaryControllerTest >> modelClass [

^ self diagramElementClass
]
12 changes: 10 additions & 2 deletions repository/OpenPonk-Core/OPCommonElementController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ OPCommonElementController >> createModelIn: aParentModel [

"do nothing - common model elements are not part of any model"

^ nil
^ self model
]

{ #category : 'accessing' }
Expand All @@ -45,6 +45,12 @@ OPCommonElementController >> isCommon [
^ true
]

{ #category : 'testing' }
OPCommonElementController >> isDiagramOnly [

^ true
]

{ #category : 'testing' }
OPCommonElementController >> isHideable [

Expand All @@ -59,8 +65,10 @@ OPCommonElementController >> model [

{ #category : 'accessing' }
OPCommonElementController >> model: aModel [
"do nothing - common model elements do not have a model"

self diagramElement: aModel
self assert:
(aModel isNil or: [ aModel isKindOf: self diagramElementClass ])
]

{ #category : 'accessing' }
Expand Down
Loading

0 comments on commit a3ae9e7

Please sign in to comment.