diff --git a/src/Pyramid-Tests/PyramidSaveModelVerifierTest.class.st b/src/Pyramid-Tests/PyramidSaveModelVerifierTest.class.st index dcd91a99..7be7dfbf 100644 --- a/src/Pyramid-Tests/PyramidSaveModelVerifierTest.class.st +++ b/src/Pyramid-Tests/PyramidSaveModelVerifierTest.class.st @@ -22,7 +22,7 @@ PyramidSaveModelVerifierTest >> testModelNilError [ | verifier | verifier := PyramidSaveModelVerifier modelNotNil. verifier verify: nil. "Send a nil model" - verifier showOn: PyramidSaveInputsView new. + verifier showOn: PyramidSaveProjectConfigurationView new. ] { #category : #test } diff --git a/src/Pyramid/PyramidSaveInputsController.class.st b/src/Pyramid/PyramidSaveInputsController.class.st deleted file mode 100644 index 08ae2070..00000000 --- a/src/Pyramid/PyramidSaveInputsController.class.st +++ /dev/null @@ -1,84 +0,0 @@ -Class { - #name : #PyramidSaveInputsController, - #superclass : #Object, - #instVars : [ - 'view', - 'model', - 'verifier' - ], - #category : #'Pyramid-plugin-save' -} - -{ #category : #accessing } -PyramidSaveInputsController >> model [ - - model ifNil: [ model := PyramidSaveModel new ]. - ^ model -] - -{ #category : #accessing } -PyramidSaveInputsController >> model: aPyramidSaveModel [ - - model := aPyramidSaveModel. - self view model: aPyramidSaveModel -] - -{ #category : #'as yet unclassified' } -PyramidSaveInputsController >> radioUpdatedOnClassSide: aBoolean [ - - aBoolean - ifTrue: [ self model onClass ] - ifFalse: [ self model onInstance ]. self updateView -] - -{ #category : #'as yet unclassified' } -PyramidSaveInputsController >> textUpdatedFromClass: aString [ - - self model savingClassName: aString. - self updateView -] - -{ #category : #'as yet unclassified' } -PyramidSaveInputsController >> textUpdatedFromMethod: aString [ - - self model savingMethodName: aString. - self updateView -] - -{ #category : #'as yet unclassified' } -PyramidSaveInputsController >> textUpdatedFromPackage: aString [ - - self model savingPackageName: aString. - self updateView -] - -{ #category : #'as yet unclassified' } -PyramidSaveInputsController >> updateView [ - - | errors | - errors := self verifier allErrors: self model. - self view hideLabels. - errors do: [ :each | each showOn: self view ] -] - -{ #category : #accessing } -PyramidSaveInputsController >> verifier [ - - verifier ifNil: [ - verifier := PyramidSaveModelVerifier verifierNoErrorForInputsView ]. - ^ verifier -] - -{ #category : #accessing } -PyramidSaveInputsController >> view [ - - view ifNil: [ view := PyramidSaveInputsView new. - view controller: self; model: self model ]. - ^ view -] - -{ #category : #accessing } -PyramidSaveInputsController >> view: anObject [ - - view := anObject -] diff --git a/src/Pyramid/PyramidSavePlugin.class.st b/src/Pyramid/PyramidSavePlugin.class.st index 4b1b4b21..b6f4682c 100644 --- a/src/Pyramid/PyramidSavePlugin.class.st +++ b/src/Pyramid/PyramidSavePlugin.class.st @@ -10,7 +10,6 @@ Class { 'inputsButton', 'savingService', 'saveButton', - 'inputsPopover', 'projectModel' ], #category : #'Pyramid-plugin-save' @@ -59,29 +58,27 @@ PyramidSavePlugin >> connectOn: aPyramidEditor [ { #category : #initialization } PyramidSavePlugin >> initialize [ - inputsController := PyramidSaveInputsController new. + inputsController := PyramidSaveProjectConfigurationController new. inputsView := inputsController view. saveModel := inputsController model. savingService := PyramidSavingService new savingModel: saveModel; - methodBuilder: PyramidSavingMethodBuilder ston; yourself. inputsButton := SpButtonPresenter new icon: (self iconNamed: #smallRemoteOpen); - help: 'Project configuration'; - action: [ inputsPopover popup ]; - yourself. - inputsPopover := PyramidPopoverFactory + help: 'Project configuration'; + action: [( PyramidPopoverFactory makeWithPresenter: inputsView relativeTo: inputsButton - position: SpPopoverPosition right. + position: SpPopoverPosition right) popup. ]; + yourself. saveButton := SpButtonPresenter new icon: (self iconNamed: #smallSave); - help: 'Save project'; + help: 'Save project'; action: [ self saveAction ]; yourself ] @@ -109,7 +106,9 @@ PyramidSavePlugin >> openOn: aSaveModel [ self inputsView inputClass text: aSaveModel savingClassName. self inputsView inputMethod text: aSaveModel savingMethodName. - self inputsView inputPackage text: aSaveModel savingPackageName + self inputsView inputPackage text: aSaveModel savingPackageName. + aSaveModel isClassSide ifTrue: [ self inputsView buttonClass click ] ifFalse: [ self inputsView buttonInstance click ] + ] { #category : #accessing } diff --git a/src/Pyramid/PyramidSaveProjectConfigurationController.class.st b/src/Pyramid/PyramidSaveProjectConfigurationController.class.st new file mode 100644 index 00000000..3d2444ae --- /dev/null +++ b/src/Pyramid/PyramidSaveProjectConfigurationController.class.st @@ -0,0 +1,105 @@ +Class { + #name : #PyramidSaveProjectConfigurationController, + #superclass : #Object, + #instVars : [ + 'view', + 'model', + 'verifier' + ], + #category : #'Pyramid-plugin-save' +} + +{ #category : #tests } +PyramidSaveProjectConfigurationController >> browseProjectClass [ + + | class | + class := self class environment classNamed: + self model savingClassName. + class ifNil: [ + UIManager default inform: 'Class do not exist yet. It will be created the first time you saved it.'. + ^ self ]. + self model isClassSide + ifTrue: [ + Smalltalk tools browser + openOnClass: class class + selector: self model savingMethodName ] + ifFalse: [ + Smalltalk tools browser + openOnClass: class + selector: self model savingMethodName ] +] + +{ #category : #accessing } +PyramidSaveProjectConfigurationController >> model [ + + model ifNil: [ model := PyramidSaveModel new ]. + ^ model +] + +{ #category : #accessing } +PyramidSaveProjectConfigurationController >> model: aPyramidSaveModel [ + + model := aPyramidSaveModel. + self view model: aPyramidSaveModel +] + +{ #category : #'as yet unclassified' } +PyramidSaveProjectConfigurationController >> radioUpdatedOnClassSide: aBoolean [ + + aBoolean + ifTrue: [ self model onClass ] + ifFalse: [ self model onInstance ]. self updateView +] + +{ #category : #'as yet unclassified' } +PyramidSaveProjectConfigurationController >> textUpdatedFromClass: aString [ + + self model savingClassName: aString. + self updateView +] + +{ #category : #'as yet unclassified' } +PyramidSaveProjectConfigurationController >> textUpdatedFromMethod: aString [ + + self model savingMethodName: aString. + self updateView +] + +{ #category : #'as yet unclassified' } +PyramidSaveProjectConfigurationController >> textUpdatedFromPackage: aString [ + + self model savingPackageName: aString. + self updateView +] + +{ #category : #'as yet unclassified' } +PyramidSaveProjectConfigurationController >> updateView [ + + | errors | + errors := self verifier allErrors: self model. + self view hideLabels. + self view buttonBrowse enabled: errors isEmpty. + errors do: [ :each | each showOn: self view ] +] + +{ #category : #accessing } +PyramidSaveProjectConfigurationController >> verifier [ + + verifier ifNil: [ + verifier := PyramidSaveModelVerifier verifierNoErrorForInputsView ]. + ^ verifier +] + +{ #category : #accessing } +PyramidSaveProjectConfigurationController >> view [ + + view ifNil: [ view := PyramidSaveProjectConfigurationView new. + view controller: self; model: self model ]. + ^ view +] + +{ #category : #accessing } +PyramidSaveProjectConfigurationController >> view: anObject [ + + view := anObject +] diff --git a/src/Pyramid/PyramidSaveInputsView.class.st b/src/Pyramid/PyramidSaveProjectConfigurationView.class.st similarity index 60% rename from src/Pyramid/PyramidSaveInputsView.class.st rename to src/Pyramid/PyramidSaveProjectConfigurationView.class.st index 5d9ea5f5..8aa50fb3 100644 --- a/src/Pyramid/PyramidSaveInputsView.class.st +++ b/src/Pyramid/PyramidSaveProjectConfigurationView.class.st @@ -1,5 +1,5 @@ Class { - #name : #PyramidSaveInputsView, + #name : #PyramidSaveProjectConfigurationView, #superclass : #SpPresenter, #instVars : [ 'inputPackage', @@ -7,6 +7,7 @@ Class { 'inputMethod', 'buttonClass', 'buttonInstance', + 'buttonBrowse', 'labelErrorPackage', 'labelErrorClass', 'labelErrorMethod', @@ -16,71 +17,95 @@ Class { #category : #'Pyramid-plugin-save' } +{ #category : #layout } +PyramidSaveProjectConfigurationView >> buttonBrowse [ + + ^ buttonBrowse +] + { #category : #accessing } -PyramidSaveInputsView >> buttonClass [ +PyramidSaveProjectConfigurationView >> buttonClass [ ^ buttonClass ] { #category : #accessing } -PyramidSaveInputsView >> buttonInstance [ +PyramidSaveProjectConfigurationView >> buttonInstance [ ^ buttonInstance ] { #category : #accessing } -PyramidSaveInputsView >> controller [ +PyramidSaveProjectConfigurationView >> controller [ controller ifNil: [ - controller := PyramidSaveInputsController new + controller := PyramidSaveProjectConfigurationController new view: self; yourself ]. ^ controller ] { #category : #accessing } -PyramidSaveInputsView >> controller: aPySaveFormController [ +PyramidSaveProjectConfigurationView >> controller: aPySaveFormController [ controller := aPySaveFormController ] { #category : #layout } -PyramidSaveInputsView >> defaultLayout [ +PyramidSaveProjectConfigurationView >> defaultLayout [ ^ SpBoxLayout newVertical spacing: 4; - add: self inputPackage expand: false; + add: (SpLabelPresenter new + label: 'Project configuration'; + displayBold: [ :c | true ]; + yourself) + expand: false; + add: (SpBoxLayout newHorizontal + spacing: 4; + add: (self iconNamed: #packageColored) expand: false; + add: self inputPackage) + expand: false; add: self labelErrorPackage expand: false; - add: self inputClass expand: false; + add: (SpBoxLayout newHorizontal + spacing: 4; + add: (self iconNamed: #class) expand: false; + add: self inputClass) + expand: false; add: self labelErrorClass expand: false; - add: self inputMethod expand: false; + add: (SpBoxLayout newHorizontal + spacing: 4; + add: (self iconNamed: #changeUpdate) expand: false; + add: self inputMethod) + expand: false; add: self labelErrorMethod expand: false; add: (SpBoxLayout newHorizontal add: self buttonClass; add: self buttonInstance; + add: self buttonBrowse width: 32; yourself) expand: false; yourself ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> hideLabelClass [ +PyramidSaveProjectConfigurationView >> hideLabelClass [ self labelErrorClass label: ''. ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> hideLabelMethod [ +PyramidSaveProjectConfigurationView >> hideLabelMethod [ self labelErrorMethod label: '' ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> hideLabelPackage [ +PyramidSaveProjectConfigurationView >> hideLabelPackage [ self labelErrorPackage label: '' ] { #category : #configuration } -PyramidSaveInputsView >> hideLabels [ +PyramidSaveProjectConfigurationView >> hideLabels [ self labelErrorClass label: ''. self labelErrorMethod label: ''. @@ -88,7 +113,7 @@ PyramidSaveInputsView >> hideLabels [ ] { #category : #initialization } -PyramidSaveInputsView >> initializePresenters [ +PyramidSaveProjectConfigurationView >> initializePresenters [ inputPackage := self newTextInput placeholder: 'Enter a package name'; @@ -118,50 +143,57 @@ PyramidSaveInputsView >> initializePresenters [ yourself. buttonClass associatedRadioButtons: { buttonInstance }. + buttonBrowse := SpButtonPresenter new + help: 'Browse project class'; + icon: (self iconNamed: #nautilus); + action: [ self controller browseProjectClass ]; + enabled: false; + yourself. + labelErrorPackage := self newLabel. labelErrorClass := self newLabel. labelErrorMethod := self newLabel ] { #category : #accessing } -PyramidSaveInputsView >> inputClass [ +PyramidSaveProjectConfigurationView >> inputClass [ ^ inputClass ] { #category : #accessing } -PyramidSaveInputsView >> inputMethod [ +PyramidSaveProjectConfigurationView >> inputMethod [ ^ inputMethod ] { #category : #accessing } -PyramidSaveInputsView >> inputPackage [ +PyramidSaveProjectConfigurationView >> inputPackage [ ^ inputPackage ] { #category : #accessing } -PyramidSaveInputsView >> labelErrorClass [ +PyramidSaveProjectConfigurationView >> labelErrorClass [ ^ labelErrorClass ] { #category : #accessing } -PyramidSaveInputsView >> labelErrorMethod [ +PyramidSaveProjectConfigurationView >> labelErrorMethod [ ^ labelErrorMethod ] { #category : #accessing } -PyramidSaveInputsView >> labelErrorPackage [ +PyramidSaveProjectConfigurationView >> labelErrorPackage [ ^ labelErrorPackage ] { #category : #accessing } -PyramidSaveInputsView >> model [ +PyramidSaveProjectConfigurationView >> model [ model ifNil: [ model := PyramidSaveModel new @@ -170,14 +202,14 @@ PyramidSaveInputsView >> model [ ] { #category : #accessing } -PyramidSaveInputsView >> model: aPySaveModel [ +PyramidSaveProjectConfigurationView >> model: aPySaveModel [ model := aPySaveModel. self updateFromModel. ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> showClassIsNotValidError [ +PyramidSaveProjectConfigurationView >> showClassIsNotValidError [ self labelErrorClass displayColor: [ Color red ]; @@ -185,7 +217,7 @@ PyramidSaveInputsView >> showClassIsNotValidError [ ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> showClassPackageIsNotEqualError [ +PyramidSaveProjectConfigurationView >> showClassPackageIsNotEqualError [ self labelErrorClass displayColor: [ Color red ]; @@ -193,7 +225,7 @@ PyramidSaveInputsView >> showClassPackageIsNotEqualError [ ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> showMethodIsNotValidError [ +PyramidSaveProjectConfigurationView >> showMethodIsNotValidError [ self labelErrorMethod displayColor: [ Color red ]; @@ -201,7 +233,7 @@ PyramidSaveInputsView >> showMethodIsNotValidError [ ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> showModelNilError [ +PyramidSaveProjectConfigurationView >> showModelNilError [ self labelErrorPackage displayColor: [Color red]; @@ -209,7 +241,7 @@ PyramidSaveInputsView >> showModelNilError [ ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> showPackageIsNotValidError [ +PyramidSaveProjectConfigurationView >> showPackageIsNotValidError [ self labelErrorPackage displayColor: [ Color red ]; @@ -217,7 +249,7 @@ PyramidSaveInputsView >> showPackageIsNotValidError [ ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> showProjectNilError [ +PyramidSaveProjectConfigurationView >> showProjectNilError [ self labelErrorPackage displayColor: [Color red]; @@ -225,7 +257,7 @@ PyramidSaveInputsView >> showProjectNilError [ ] { #category : #'as yet unclassified' } -PyramidSaveInputsView >> updateFromModel [ +PyramidSaveProjectConfigurationView >> updateFromModel [ self inputPackage text: self model savingPackageName. self inputClass text: self model savingClassName.