Skip to content

Commit 3710bad

Browse files
committed
Creating new input for UI of grid properties in Workplace Properties. Edit testHistory because problem with it
1 parent 1a5ca97 commit 3710bad

5 files changed

Lines changed: 164 additions & 12 deletions

src/Pyramid-Bloc/PyramidMainExtension.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ PyramidMainExtension >> initialize [
250250
spacingTextValue: self defaultGridSpacing;
251251
whenSpacingTextChangedDo: [ :value |
252252
(self checkZeroOrSubZeroGridSpacingValue: value)
253-
ifTrue: [ gridSpacing := 1. self workplacePropertiesView spacingTextValue: 1 ]
253+
ifTrue: [ gridSpacing := self defaultGridSpacing ]
254254
ifFalse: [ gridSpacing := value ].
255255
self createGrid ];
256256
gridColorValue: self defaultGridColor;

src/Pyramid-Bloc/PyramidWorkplacePropertiesPresenter.class.st

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ PyramidWorkplacePropertiesPresenter >> initializePresenter [
115115
yourself.
116116

117117
spacingLabel := (SpLabelPresenter new label: 'Spacing :'; yourself).
118-
spacingText := PyramidNumberInputPresenter new.
118+
spacingText := "PyramidNumberInputPresenter"PyramidNumberFilterOnlyDigitsInputPresenter new.
119119

120120
gridColorLabel := (SpLabelPresenter new label: 'Color :'; yourself).
121121
gridColor := PyramidColorInputSingleLineWithPickupButtonPresenter new.
@@ -137,7 +137,8 @@ PyramidWorkplacePropertiesPresenter >> spacingTextValue [
137137
{ #category : #'as yet unclassified' }
138138
PyramidWorkplacePropertiesPresenter >> spacingTextValue: aValue [
139139

140-
spacingText value: aValue
140+
self spacingText value: aValue.
141+
self spacingText defaultValue: aValue
141142
]
142143

143144
{ #category : #accessing }

src/Pyramid-Tests/PyramidLayoutBlocCommandTest.class.st

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,85 @@ PyramidLayoutBlocCommandTest >> command [
1414

1515
{ #category : #'as yet unclassified' }
1616
PyramidLayoutBlocCommandTest >> targetContainers [
17-
17+
| flowLayoutVertical basicLayout proportionalLayout |
18+
19+
flowLayoutVertical := BlFlowLayout vertical.
20+
basicLayout := BlBasicLayout new.
21+
proportionalLayout := BlProportionalLayout new.
22+
1823
^ {
1924
(PyramidCommandTestContainer
2025
no: BlElement new
2126
with: (BlElement new
22-
layout: BlFlowLayout vertical;
27+
layout: flowLayoutVertical;
2328
yourself)
24-
prop: BlFlowLayout vertical).
29+
prop: flowLayoutVertical).
2530
(PyramidCommandTestContainer
2631
no: (BlElement new
27-
layout: BlFlowLayout vertical;
32+
layout: flowLayoutVertical;
2833
yourself)
2934
with: (BlElement new
30-
layout: BlBasicLayout new;
35+
layout: basicLayout;
3136
yourself)
32-
prop: BlBasicLayout new).
37+
prop: basicLayout).
3338
(PyramidCommandTestContainer
3439
no: BlElement new
3540
with: (BlElement new
36-
layout: BlProportionalLayout new;
41+
layout: proportionalLayout;
3742
yourself)
38-
prop: BlProportionalLayout new) }
43+
prop: proportionalLayout) }
44+
]
45+
46+
{ #category : #'as yet unclassified' }
47+
PyramidLayoutBlocCommandTest >> targetsCanBeUsedFor [
48+
49+
"^ self targetContainers flatCollect: [ :each | { each targetNoProp . each targetWithProp } ]."
50+
^ self targetContainers collect: [ :each | each targetNoProp ].
51+
]
52+
53+
{ #category : #tests }
54+
PyramidLayoutBlocCommandTest >> testHistory [
55+
"Do once.
56+
undo
57+
redo
58+
undo
59+
redo"
60+
61+
| history commandExecutor targets |
62+
targets := self targetsCanBeUsedFor.
63+
history := PyramidHistory new.
64+
commandExecutor := PyramidHistoryCommandExecutor new
65+
history: history;
66+
wrappee: PyramidMainCommandExecutor new;
67+
yourself.
68+
69+
"Do once"
70+
self argumentsForHistory do: [ :each |
71+
commandExecutor use: self command on: targets with: each ].
72+
73+
"Undo all"
74+
self argumentsForHistory reverseDo: [ :argument |
75+
targets do: [ :target |
76+
self
77+
assert: (self command getValueFor: target) class
78+
equals: argument class ].
79+
history canUndo ifTrue: [ history undo ] ].
80+
81+
"Redo all"
82+
self argumentsForHistory do: [ :argument |
83+
history canRedo ifTrue: [ history redo ].
84+
targets do: [ :target |
85+
self assert: (self command getValueFor: target) class equals: argument class] ].
86+
87+
"Undo all"
88+
self argumentsForHistory reverseDo: [ :argument |
89+
targets do: [ :target |
90+
self assert: (self command getValueFor: target) class equals: argument class].
91+
history canUndo ifTrue: [ history undo ] ].
92+
93+
"Redo all"
94+
self argumentsForHistory do: [ :argument |
95+
history canRedo ifTrue: [ history redo ].
96+
targets do: [ :target |
97+
self assert: (self command getValueFor: target) class equals: argument class ] ]
3998
]
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Class {
2+
#name : #PyramidNumberFilterOnlyDigitsInputPresenter,
3+
#superclass : #PyramidInputPresenter,
4+
#instVars : [
5+
'inputNumber',
6+
'submitBlock',
7+
'defaultValue'
8+
],
9+
#category : #'Pyramid-specs-custom'
10+
}
11+
12+
{ #category : #'as yet unclassified' }
13+
PyramidNumberFilterOnlyDigitsInputPresenter >> applyInputModel [
14+
15+
self inputNumber help: self inputModel help
16+
]
17+
18+
{ #category : #layout }
19+
PyramidNumberFilterOnlyDigitsInputPresenter >> defaultLayout [
20+
21+
^ SpBoxLayout newHorizontal
22+
add: self inputNumber;
23+
yourself
24+
]
25+
26+
{ #category : #accessing }
27+
PyramidNumberFilterOnlyDigitsInputPresenter >> defaultValue [
28+
29+
^ defaultValue
30+
]
31+
32+
{ #category : #accessing }
33+
PyramidNumberFilterOnlyDigitsInputPresenter >> defaultValue: aValue [
34+
35+
defaultValue := aValue
36+
]
37+
38+
{ #category : #'as yet unclassified' }
39+
PyramidNumberFilterOnlyDigitsInputPresenter >> getNumberFrom: aString [
40+
41+
^ NumberParser parse: aString onError: [ PyramidUnknowState new ]
42+
]
43+
44+
{ #category : #initialization }
45+
PyramidNumberFilterOnlyDigitsInputPresenter >> initializePresenters [
46+
47+
| newText |
48+
inputNumber := SpTextInputFieldPresenter new whenSubmitDo: [ :text |
49+
newText := text isEmpty
50+
ifTrue: [ self defaultValue asString ]
51+
ifFalse: [
52+
AlbTextEditorDigitInputFilter new
53+
filter: text ].
54+
newText value asNumber = 0 ifTrue: [
55+
newText := self defaultValue asString ].
56+
self submitBlock value: (self getNumberFrom: newText).
57+
self inputNumber text: newText ]
58+
]
59+
60+
{ #category : #accessing }
61+
PyramidNumberFilterOnlyDigitsInputPresenter >> inputNumber [
62+
^ inputNumber
63+
]
64+
65+
{ #category : #accessing }
66+
PyramidNumberFilterOnlyDigitsInputPresenter >> submitBlock [
67+
68+
submitBlock ifNil: [ submitBlock := [ :n | ] ].
69+
^ submitBlock
70+
]
71+
72+
{ #category : #'as yet unclassified' }
73+
PyramidNumberFilterOnlyDigitsInputPresenter >> value [
74+
75+
^ self getNumberFrom: self inputNumber text
76+
]
77+
78+
{ #category : #'as yet unclassified' }
79+
PyramidNumberFilterOnlyDigitsInputPresenter >> value: aNumber [
80+
81+
aNumber isNumber ifTrue: [
82+
self inputNumber text: aNumber asFloat reduce printString.
83+
^ self ].
84+
self inputNumber text: '--'
85+
]
86+
87+
{ #category : #'as yet unclassified' }
88+
PyramidNumberFilterOnlyDigitsInputPresenter >> whenValueChangedDo: aBlock [
89+
90+
submitBlock := aBlock
91+
]

src/Pyramid/PyramidNumberInputPresenter.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ PyramidNumberInputPresenter >> getNumberFrom: aString [
3434
{ #category : #'initialization - deprecated' }
3535
PyramidNumberInputPresenter >> initializePresenters [
3636

37-
inputNumber := SpTextInputFieldPresenter new whenSubmitDo: [ :text |
37+
inputNumber := SpTextInputFieldPresenter new
38+
whenSubmitDo: [ :text |
3839
self submitBlock value: (self getNumberFrom: text); yourself ]
3940
]
4041

0 commit comments

Comments
 (0)