Skip to content

Commit

Permalink
Added validation of model elements
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Oct 17, 2024
1 parent 8820cc9 commit 1307ac8
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 21 deletions.
6 changes: 3 additions & 3 deletions repository/BaselineOfOpenPonk/BaselineOfOpenPonk.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"
I am baseline for the core and all-in-one dynacase.
https://dynacase.github.io/
I am baseline for the core of Openponk.
https://openponk.org/
"
Class {
#name : 'BaselineOfOpenPonk',
Expand Down Expand Up @@ -37,7 +37,7 @@ BaselineOfOpenPonk >> externalProjectsBaseline: spec [
spec
baseline: 'XPath'
with: [
spec repository: 'github://pharo-contributions/XML-XPath:2aa720c' ].
spec repository: 'github://pharo-contributions/XML-XPath:v2.3.x' ].

spec baseline: 'Magritte' with: [
spec
Expand Down
6 changes: 6 additions & 0 deletions repository/OpenPonk-Core/OPController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,9 @@ OPController >> updateAfterDiagramFocused [

self subclassResponsibility
]

{ #category : 'validation' }
OPController >> validate [

"do nothing by default"
]
9 changes: 8 additions & 1 deletion repository/OpenPonk-Core/OPDiagramController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ OPDiagramController >> showDiagramElement: aDiagramElement [
ifFound: [ :ctrl |
ctrl isRendered ifTrue: [
aDiagramElement isRendered ifTrue: [ ^ ctrl ].
^ self error: 'Controller is already rendered' ].
^ self error:
'Controller is already rendered by a different diagram element' ].
ctrl ]
ifNone: [
self newControllerFor:
Expand Down Expand Up @@ -840,6 +841,12 @@ OPDiagramController >> updateView [
^ self updateCanvas
]

{ #category : 'validation' }
OPDiagramController >> validate [

self controllers do: [ :each | each validate ]
]

{ #category : 'accessing' }
OPDiagramController >> view [

Expand Down
1 change: 1 addition & 0 deletions repository/OpenPonk-Core/OPElementController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ OPElementController >> renderFigureIn: aCanvas [
{ #category : 'construction' }
OPElementController >> showWithoutDependentInDiagram: aDiagramController [

self validate.
self ensureShownDependenciesInDiagram: aDiagramController.
aDiagramController addController: self.
self ensureDiagramElement.
Expand Down
7 changes: 7 additions & 0 deletions repository/OpenPonk-Core/OPModelInvalid.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Class {
#name : 'OPModelInvalid',
#superclass : 'Warning',
#category : 'OpenPonk-Core-Controllers',
#package : 'OpenPonk-Core',
#tag : 'Controllers'
}
7 changes: 4 additions & 3 deletions repository/OpenPonk-Core/OPProjectController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,16 @@ OPProjectController >> selectInDiagram: aModelElement [
OPProjectController >> updateDiagram: aDiagram [

| focusedController |
focusedController := workbench focusedEditor ifNotNil: [ :editor |
controllers do: [ :each | each validate ].
focusedController := workbench focusedEditor ifNotNil: [ :editor |
editor diagramController ].
controllers
detect: [ :ctrl | ctrl diagramElement = aDiagram ]
ifFound: [ :ctrl |
ifFound: [ :ctrl |
aDiagram isOpen: true.
aDiagram isRendered ifTrue: [ aDiagram updateFromRender ].
aDiagram isSelected: ctrl = focusedController ]
ifNone: [
ifNone: [
aDiagram
isOpen: false;
isSelected: false ]
Expand Down
3 changes: 3 additions & 0 deletions repository/OpenPonk-Core/OPShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ OPShape >> modelElement [
OPShape >> modelElement: anObject [

anObject ifNil: [ ^ self modelElements: #( ) ].
(self modelElements size = 1 and: [
self modelElements first == anObject ]) ifTrue: [ ^ self ].
self modelElements: { anObject }
]

Expand Down Expand Up @@ -319,6 +321,7 @@ OPShape >> ownedElement: aShape renderedIn: aCanvas [

{ #category : 'accessing' }
OPShape >> ownedElements [

^ ownedElements
]

Expand Down
13 changes: 12 additions & 1 deletion repository/OpenPonk-Spec/OPEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ OPEditor >> setModelBeforeInitialization: aPlugin [
]

{ #category : 'updating' }
OPEditor >> tabDeleted [
OPEditor >> tabClosed [

self workbench projectController updateDiagram:
diagramController diagramElement.
Expand All @@ -271,6 +271,17 @@ OPEditor >> tabDeleted [
diagramController removeRender
]

{ #category : 'updating' }
OPEditor >> tabClosedWhileClosingWorkbench: discardingChanges [

discardingChanges ifTrue: [ ^ self ].
self workbench projectController updateDiagram:
diagramController diagramElement.
self workbench projectController removeDiagramController:
diagramController.
diagramController removeRender
]

{ #category : 'updating' }
OPEditor >> updateUndoRedo [
self flag: #unused.
Expand Down
31 changes: 18 additions & 13 deletions repository/OpenPonk-Spec/OPWorkbench.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,22 @@ OPWorkbench >> closeEditorOfDiagram: aDiagram [
{ #category : 'opening' }
OPWorkbench >> closedTabOfEditor: anEditor [

self projectController updateDiagram:
anEditor diagramController diagramElement.
anEditor tabDeleted.
topToolbar activeEditor: nil.
editors removeKey: anEditor diagramController diagramElement.
anEditor diagramController diagramElement isSelected: false.
focusedEditor = anEditor ifTrue: [
self closedTabOfEditor: anEditor whileClosingWorkbench: false
]

{ #category : 'opening' }
OPWorkbench >> closedTabOfEditor: anEditor whileClosingWorkbench: discardChanges [

focusedEditor = anEditor ifTrue: [
focusedEditor := nil.
self announce: (OPEditorUnfocused on: anEditor) ].
anEditor tabClosedWhileClosingWorkbench: discardChanges.
topToolbar activeEditor: nil.
editors removeKey: anEditor diagramController diagramElement.
self announce: (OPEditorClosed on: anEditor)
]

{ #category : 'as yet unclassified' }
{ #category : 'initialization' }
OPWorkbench >> connectPresenters [

super connectPresenters.
Expand Down Expand Up @@ -197,7 +200,7 @@ OPWorkbench >> initialize [
super initialize
]

{ #category : 'as yet unclassified' }
{ #category : 'initialization' }
OPWorkbench >> initializePresenters [

topToolbar := self instantiate: OPWorkbenchToolbar.
Expand All @@ -211,7 +214,7 @@ OPWorkbench >> initializePresenters [
add: notebook
]

{ #category : 'as yet unclassified' }
{ #category : 'initialization' }
OPWorkbench >> initializeWindow: aWindow [

aWindow
Expand All @@ -220,7 +223,9 @@ OPWorkbench >> initializeWindow: aWindow [
initialExtent: self class initialExtent;
whenClosedDo: [
editors valuesDo: [ :each |
self closedTabOfEditor: (each at: #editor) ] ]
self
closedTabOfEditor: (each at: #editor)
whileClosingWorkbench: true ] ]
]

{ #category : 'accessing - spec' }
Expand Down Expand Up @@ -284,7 +289,7 @@ OPWorkbench >> openProject: aProject [
self updateTitle.
]

{ #category : 'as yet unclassified' }
{ #category : 'opening' }
OPWorkbench >> pageRemoved: aPage [

"activePresenter is editor"
Expand All @@ -307,7 +312,7 @@ OPWorkbench >> projectTree [
^ projectTree
]

{ #category : 'as yet unclassified' }
{ #category : 'opening' }
OPWorkbench >> showAllElementsInAllDiagrams [

self projectController controllers do: [ :each |
Expand Down

0 comments on commit 1307ac8

Please sign in to comment.