Skip to content

Commit

Permalink
Fixed save file extension, code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Oct 3, 2024
1 parent 6ad143e commit 53d325b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ OPAbstractElementControllerTest >> showInDiagram [
controller showWithoutDependentInDiagram: diagramController
]

{ #category : 'support' }
OPAbstractElementControllerTest >> stubRefresh [
controller stub figure willReturn: Mock new.
controller stub refreshFigure willReturn: controller
]

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

Expand Down Expand Up @@ -212,17 +206,19 @@ OPAbstractElementControllerTest >> testCreateUsingAddAsTarget [

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

| diagramElement |
model := Mock new.
model stub name willReturn: 'bravo'.
diagramElement := Mock new.
controller model: model.
controller diagramElement: diagramElement.
self stubRefresh.
controller descriptionName accessor write: 'charlie' to: controller.
model should receive name: 'charlie'.
self assert: (controller descriptionName accessor read: controller) equals: 'bravo'.
diagramElement should receive modelChanged
self
assert: (controller descriptionName accessor read: controller)
equals: 'bravo'.
diagramElement should receive modelChanged
]

{ #category : 'tests - controllers' }
Expand Down
12 changes: 2 additions & 10 deletions repository/OpenPonk-Core/OPController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ OPController >> dependentElements [
^ self elementsToShowInside
]

{ #category : 'forms' }
OPController >> descriptionAccessor: aSymbol [
^ MAPluggableAccessor
read: [ :me | me model perform: aSymbol ]
write: [ :me :newValue |
me model perform: aSymbol asMutator with: newValue.
self modelChanged ]
]

{ #category : 'forms' }
OPController >> descriptionName [

Expand Down Expand Up @@ -204,7 +195,8 @@ OPController >> model: aModel [

{ #category : 'announcements' }
OPController >> modelChanged [
self figure ifNotNil: [ self refreshFigure ]

self diagramElement ifNotNil: [ :de | de modelChanged ]
]

{ #category : 'accessing' }
Expand Down
8 changes: 4 additions & 4 deletions repository/OpenPonk-Core/OPDiagramController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ OPDiagramController >> cachedControllerForModel: aModel ifFound: aFoundBlock [
OPDiagramController >> cachedControllerForModel: aModel ifFound: aFoundBlock ifNone: aNoneBlock [

| ctrl |
modelToControllerCache ifNil: [
modelToControllerCache ifNil: [
modelToControllerCache := Dictionary new.
self controllers do: [ :each |
self controllers do: [ :each |
modelToControllerCache at: each model put: each ] ].
ctrl := modelToControllerCache at: aModel ifPresent: #yourself.
(self controllers includes: ctrl) ifTrue: [
(self controllers includes: ctrl) ifTrue: [
^ aFoundBlock value: ctrl ].
^ self controllers
detect: [ :fresh | fresh model = aModel ]
ifFound: [ :found |
ifFound: [ :found |
modelToControllerCache at: aModel put: found.
aFoundBlock cull: found ]
ifNone: aNoneBlock
Expand Down
2 changes: 1 addition & 1 deletion repository/OpenPonk-Core/OPProjectController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ OPProjectController >> removeModel: aModel [
{ #category : 'saving' }
OPProjectController >> replaceWritableProjectFile [

^ self project storageFile: ((StFileDialogPresenter new
^ self project storageFile: ((StSaveFilePresenter new
title: 'Set a file for saving an OpenPonk project';
extensions: #( opp ) named: 'OP projects';
openModal) ifNil: [ OPProjectSaveCanceledException signal ])
Expand Down
2 changes: 1 addition & 1 deletion repository/OpenPonk-Spec/OPCanvasPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ OPCanvasPresenter >> exportAsPng: aFile [
OPCanvasPresenter >> exportAsSvg [

self flag: 'default name not supported in file browser'.
StFBSaveFileDialog new
StSaveFilePresenter new
title: 'Choose a SVG file to export the diagram';
okAction: [ :file |
OPCanvasSVGExporter
Expand Down
16 changes: 9 additions & 7 deletions repository/OpenPonk-Spec/OPDiagramExplorer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,21 @@ OPDiagramExplorer >> showDependentFor: aModelObject [

{ #category : 'actions' }
OPDiagramExplorer >> showElement: aModelObject [

| existingCtrl ctrl |
self diagramController deselectAll.
aModelObject = diagramController model
ifTrue: [ ^ diagramController showAllElements ].
aModelObject = diagramController model ifTrue: [
^ diagramController showAllElements ].
diagramController disableRefresh.
self halt.
existingCtrl := diagramController
controllerForModel: aModelObject
ifNone: [ nil ].
ctrl := diagramController
showWithoutDependentInDiagramModel: aModelObject.
controllerForModel: aModelObject
ifNone: [ nil ].
ctrl := diagramController showWithoutDependentInDiagramModel:
aModelObject.
diagramController enableRefresh.
existingCtrl ifNil: [ ^ self ].
ctrl refreshFigure
ctrl diagramElement modelChanged
]

{ #category : 'actions' }
Expand Down
10 changes: 5 additions & 5 deletions repository/OpenPonk-Spec/OPDynamicFormMagritteVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ OPDynamicFormMagritteVisitor >> visitBooleanDescription: aBooleanDescription [

(form addCheckbox: aBooleanDescription label)
state: (aBooleanDescription accessor read: controller);
whenChangedDo: [ :newValue |
whenChangedDo: [ :newValue |
aBooleanDescription accessor write: newValue to: controller ]
]

Expand All @@ -83,7 +83,7 @@ OPDynamicFormMagritteVisitor >> visitMemoDescription: aMemoDescription [
OPDynamicFormMagritteVisitor >> visitMultipleOptionDescription: aMultipleOptionDescription [

| dropList |
aMultipleOptionDescription isExtensible ifTrue: [
aMultipleOptionDescription isExtensible ifTrue: [
self notify: 'Extensibility of multilists not yet supported'.
^ self ].
dropList := form addList: aMultipleOptionDescription label.
Expand All @@ -92,11 +92,11 @@ OPDynamicFormMagritteVisitor >> visitMultipleOptionDescription: aMultipleOptionD
items: aMultipleOptionDescription options;
enabled: aMultipleOptionDescription isReadOnly not;
display: [ :each | aMultipleOptionDescription labelForOption: each ];
displayIcon: [ :each :item |
displayIcon: [ :each :item |
aMultipleOptionDescription iconForOption: each ];
selectItems: (aMultipleOptionDescription accessor read: controller);
whenSelectionChangedDo: [ :selection |
selection accessor write: selection selectedItems to: controller ]
whenSelectionChangedDo: [ :selection |
aMultipleOptionDescription accessor write: selection selectedItems to: controller ]
]

{ #category : 'visiting' }
Expand Down

0 comments on commit 53d325b

Please sign in to comment.