Skip to content

Commit c758df4

Browse files
authored
Change color generation and add a referential in the RecordBrowser
* feat: adding larger extent to browser * refactor: record colors * feat: displaying color referential * feat: resizable color referential * test: adding test for getWindowColorFrom * fix: refactoring colors in accessors * fix: prevent timerWindow open from generating an event * fix: doc mistake * feat: adding larger extent to browser * refactor: record colors * feat: displaying color referential * feat: resizable color referential * test: adding test for getWindowColorFrom * fix: refactoring colors in accessors * fix: prevent timerWindow open from generating an event * fix: doc mistake * refactor: toolInfo and colors refactoring * refactor: colors and window types by dispatch * feat: window color indicator on timer window + adding some tests * feat: adding larger extent to browser * refactor: record colors * feat: displaying color referential * feat: resizable color referential * test: adding test for getWindowColorFrom * fix: refactoring colors in accessors * fix: prevent timerWindow open from generating an event * fix: doc mistake * feat: displaying color referential * feat: resizable color referential * refactor: toolInfo and colors refactoring * refactor: colors and window types by dispatch * feat: window color indicator on timer window + adding some tests * fix: better colors * fix: PR changes * refactor: getWindowType * refactor: removing DSWindowRecord type and using its toolInfo instead * refactor: windowColor for DSWindowRecord & DSToolInfo * test: DSTimerWindow >> #testBuildLayout
1 parent e88ffc2 commit c758df4

27 files changed

+403
-305
lines changed

DebuggingSpy-Anonymizer-Tests/DSAnonymizeTest.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ DSAnonymizeTest >> testMouseEventRecord [
130130
| record anonymousRecord |
131131
record := DSMouseEventRecord new
132132
windowId: 1;
133-
toolInfo: (DSToolInfo toolNamed: #StPlayground id: 0 windowId: 1);
133+
toolInfo: (DSToolInfo toolClass: StPlayground id: 0 windowId: 1);
134134
yourself.
135135
anonymousRecord := record anonymize.
136136

@@ -191,7 +191,7 @@ DSAnonymizeTest >> testWindowEventRecord [
191191

192192
record := DSWindowEventRecord new
193193
windowName: 'aWindow';
194-
toolInfo: (DSToolInfo toolNamed: #StPlayground id: 0 windowId: 1);
194+
toolInfo: (DSToolInfo toolClass: StPlayground id: 0 windowId: 1);
195195
yourself.
196196

197197
anonymousRecord := record anonymize.

DebuggingSpy-Anonymizer-Tests/DSToolInfoTest.class.st

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,22 @@ Class {
99
DSToolInfoTest >> testAnonymizeWithCorrectTool [
1010

1111
| tool |
12-
tool := DSToolInfo toolNamed: #StPlayground id: 0 windowId: 1.
12+
tool := DSToolInfo toolClass: StPlayground id: 0 windowId: 1.
1313
tool := tool anonymize.
14-
15-
self assert: tool toolClassName equals: #StPlayground.
14+
15+
self assert: tool toolClass equals: StPlayground.
1616
self assert: tool toolIdentityHash equals: 0.
17-
self assert: tool windowIdentityHash equals: 1.
18-
19-
17+
self assert: tool windowIdentityHash equals: 1
2018
]
2119

2220
{ #category : 'tests' }
2321
DSToolInfoTest >> testAnonymizeWithIncorrectTool [
2422

2523
| tool |
26-
27-
tool := DSToolInfo toolNamed: #DSRecordDataFilter id: 0 windowId: 1.
24+
tool := DSToolInfo toolClass: DSRecordDataFilter id: 0 windowId: 1.
2825
tool := tool anonymize.
2926

30-
self assert: tool toolClassName equals: #DSRecordDataFilter identityHash.
27+
self assert: tool toolClass equals: DSRecordDataFilter identityHash.
3128
self assert: tool toolIdentityHash equals: 0.
3229
self assert: tool windowIdentityHash equals: 1
3330
]

DebuggingSpy-Anonymizer/DSRecordDataFilter.class.st

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ DSRecordDataFilter >> applyOn: aRecord [
4242
"Applies the filter on the specified record and returns the resulting filtered record"
4343

4444
| newRecord |
45-
newRecord := aRecord deepCopy.
45+
newRecord := aRecord class new.
4646

47-
newRecord class allSlots do: [ :slot |
47+
aRecord class allSlots do: [ :slot |
4848
operations
4949
at: slot name asSymbol
50-
ifPresent: [ :block | slot write: (block value: (newRecord readSlotNamed: slot name)) to: newRecord ]
50+
ifPresent: [ :block | slot write: (block value: (aRecord readSlotNamed: slot name)) to: newRecord ]
5151
ifAbsent: [ slot write: nil to: newRecord ] ].
5252

5353
^ newRecord

DebuggingSpy-Anonymizer/DSToolInfo.extension.st

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ DSToolInfo class >> anonymousFilter [
1414
^ DSRecordDataFilter new
1515
with: #toolIdentityHash;
1616
with: #windowIdentityHash;
17-
transform: #toolClassName with: [ :tool |
18-
(SystemBuildInfo current systemPackages includes: (self class environment at: tool) package)
19-
ifTrue: [ tool ]
20-
ifFalse: [ tool identityHash ] ];
17+
transform: #toolClass with: [ :toolClass |
18+
(SystemBuildInfo current systemPackages includes: toolClass package)
19+
ifTrue: [ toolClass ]
20+
ifFalse: [ toolClass identityHash ] ];
2121
yourself
2222
]

DebuggingSpy-Browser-Tests/DSRecordBrowserPresenterTest.class.st

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ DSRecordBrowserPresenterTest >> testClosingBrowser [
147147
self deny: DSRecordBrowserPresenter uniqueInstance window isOpen
148148
]
149149

150+
{ #category : 'tests' }
151+
DSRecordBrowserPresenterTest >> testColorAssociations [
152+
153+
| associations |
154+
associations := {
155+
((Color fromHexString: '#1f48ff') -> 'Browser').
156+
((Color fromHexString: '#ff0fef') -> 'Debug point browser').
157+
((Color fromHexString: '#345e54') -> 'Epicea').
158+
((Color fromHexString: '#00e5ff') -> 'Iceberg').
159+
((Color fromHexString: '#ff8f1f') -> 'Critique browser').
160+
((Color fromHexString: '#ff2200') -> 'Debugger').
161+
((Color fromHexString: '#fad314') -> 'Inspector').
162+
((Color fromHexString: '#70B77E') -> 'Playground').
163+
((Color fromHexString: '#292929') -> 'Rewriter') }.
164+
165+
self assert: (associations allSatisfy: [ :asso | DSRecordBrowserPresenter colorAssociations includes: asso ])
166+
]
167+
150168
{ #category : 'tests' }
151169
DSRecordBrowserPresenterTest >> testCreatingAndOpeningBrowser [
152170

@@ -197,8 +215,8 @@ DSRecordBrowserPresenterTest >> testGetRecordColorAssociationsFrom [
197215

198216
| windows colorAssociations |
199217
windows := { (DSWindowRecord new
200-
toolInfos: (DSToolInfo new
201-
toolClassName: 'StPlaygroundPresenter';
218+
toolInfo: (DSToolInfo new
219+
toolClass: StPlaygroundPresenter;
202220
yourself);
203221
events: {
204222
DSWindowOpenedRecord new.
@@ -312,6 +330,15 @@ DSRecordBrowserPresenterTest >> testUpdateRecordsTableWhenAddingFile [
312330
self assert: self recordsTablePresenter roots last key class equals: DSInspectItRecord
313331
]
314332

333+
{ #category : 'tests' }
334+
DSRecordBrowserPresenterTest >> testWindowColorFrom [
335+
336+
| record |
337+
record := DSWindowRecord new toolInfo: (DSToolInfo new toolClass: StDebugger).
338+
self assert: (DSRecordBrowserPresenter windowColorFrom: record) equals: (Color fromHexString: '#ff2200').
339+
self assert: (DSRecordBrowserPresenter windowColorFrom: nil) equals: (Color fromHexString: '#b3b3b3')
340+
]
341+
315342
{ #category : 'helpers' }
316343
DSRecordBrowserPresenterTest >> timelinePresenter [
317344

DebuggingSpy-Browser-Tests/DSTimerWindowTest.class.st

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ DSTimerWindowTest >> setUp [
2222
timerWindow := DSTimerWindow new.
2323
]
2424

25+
{ #category : 'tests' }
26+
DSTimerWindowTest >> testBuildLayout [
27+
"buildLayout has been already called from initialize"
28+
29+
| submorphs |
30+
submorphs := timerWindow submorphs.
31+
32+
self assert: ({ 'timerMorph'. 'currentTimeMorph'. 'lastEventMorph'. 'windowColorIndicator' } allSatisfy: [ :slotName |
33+
(timerWindow readSlotNamed: slotName) isNotNil ]).
34+
35+
self assert: submorphs size equals: 6.
36+
self assert: (submorphs last class = StringMorph and: submorphs last contents = ' ').
37+
self assert: ((submorphs at: 5) class = StringMorph and: (submorphs at: 5) contents = 'No last record').
38+
self assert: ((submorphs at: 4) class = ImageMorph and: (submorphs at: 4) form = (self iconNamed: #glamorousRedCircle)).
39+
self assert: ((submorphs at: 3) class = StringMorph and: (submorphs at: 3) contents = '00:00:00').
40+
self assert: (submorphs second class = StringMorph and: submorphs second contents = Time current print24).
41+
self assert: (submorphs first class = PluggableButtonMorph and: submorphs first label class = IconicListItemMorph)
42+
]
43+
2544
{ #category : 'tests' }
2645
DSTimerWindowTest >> testCurrentTimeMorph [
2746

@@ -50,7 +69,7 @@ DSTimerWindowTest >> testEmptyTimerMorph [
5069
DSTimerWindowTest >> testGetFormattedNameFrom [
5170

5271
| toolInfo |
53-
toolInfo := DSToolInfo new toolClassName: 'DSTimerWindowTest'.
72+
toolInfo := DSToolInfo new toolClass: self class.
5473

5574
self assert: (timerWindow getFormattedNameFrom: DSBrowseRecord new) equals: 'Browse'.
5675
self
@@ -59,13 +78,26 @@ DSTimerWindowTest >> testGetFormattedNameFrom [
5978
self assert: (timerWindow getFormattedNameFrom: DSBrowseRecord new) equals: 'Browse (DSTimerWindowTest)'
6079
]
6180

81+
{ #category : 'tests' }
82+
DSTimerWindowTest >> testGetRecordColorFrom [
83+
84+
| toolInfo |
85+
toolInfo := DSToolInfo new toolClass: StPlayground.
86+
87+
self assert: (timerWindow getRecordColorFrom: DSAbstractEventRecord new) equals: (Color fromHexString: '#b3b3b3').
88+
89+
self
90+
assert: (timerWindow getRecordColorFrom: (DSMouseEventRecord new toolInfo: toolInfo))
91+
equals: (Color fromHexString: '#70B77E')
92+
]
93+
6294
{ #category : 'tests' }
6395
DSTimerWindowTest >> testGetToolInfoFor [
6496

6597
| toolInfo record |
6698
self assert: (timerWindow getToolInfoFor: DSAbstractEventRecord new) isNil.
6799

68-
toolInfo := DSToolInfo new toolClassName: 'DSTimerWindowTest'.
100+
toolInfo := DSToolInfo new toolClass: self class.
69101
record := DSMouseEnterWindowRecord new
70102
toolInfo: toolInfo;
71103
yourself.
@@ -104,6 +136,14 @@ DSTimerWindowTest >> testStartTimer [
104136
DSSpy recordingSession: false
105137
]
106138

139+
{ #category : 'tests' }
140+
DSTimerWindowTest >> testWindowColorIndicator [
141+
142+
timerWindow writeSlotNamed: 'windowColorIndicator' value: nil.
143+
self assert: timerWindow windowColorIndicator isNotNil.
144+
self assert: (timerWindow readSlotNamed: 'windowColorIndicator') isNotNil
145+
]
146+
107147
{ #category : 'layout' }
108148
DSTimerWindowTest >> timerMorph [
109149
"Returns the window's timerMorph."
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Extension { #name : 'ClyFullBrowserMorph' }
2+
3+
{ #category : '*DebuggingSpy-Browser' }
4+
ClyFullBrowserMorph class >> windowColor [
5+
6+
<DSWindowColor>
7+
^ Color fromHexString: '#1f48ff'
8+
]
9+
10+
{ #category : '*DebuggingSpy-Browser' }
11+
ClyFullBrowserMorph class >> windowType [
12+
13+
^ 'Browser'
14+
]

DebuggingSpy-Browser/DSRecordBrowserPresenter.class.st

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,30 @@ Class {
2525
#package : 'DebuggingSpy-Browser'
2626
}
2727

28+
{ #category : 'accessing' }
29+
DSRecordBrowserPresenter class >> colorAssociations [
30+
"Return all associations between the color and the corresponding window type."
31+
32+
| method methodClass |
33+
^ (Pragma allNamed: #DSWindowColor) collect: [ :pragma |
34+
method := pragma method.
35+
methodClass := method methodClass.
36+
(method valueWithReceiver: methodClass) -> (methodClass >> #windowType valueWithReceiver: methodClass) ]
37+
]
38+
39+
{ #category : 'accessing' }
40+
DSRecordBrowserPresenter class >> defaultExtent [
41+
42+
^ 1000 @ 600
43+
]
44+
45+
{ #category : 'accessing' }
46+
DSRecordBrowserPresenter class >> defaultWindowColor [
47+
"Returns the default color for windows."
48+
49+
^ Color fromHexString: '#b3b3b3'
50+
]
51+
2852
{ #category : 'world menu' }
2953
DSRecordBrowserPresenter class >> menuCommandOn: aBuilder [
3054
"Adds the DSSpy button on topside bar."
@@ -63,6 +87,14 @@ DSRecordBrowserPresenter class >> uniqueInstance [
6387
^ uniqueInstance ifNil: [ uniqueInstance := self new ]
6488
]
6589

90+
{ #category : 'accessing' }
91+
DSRecordBrowserPresenter class >> windowColorFrom: anObject [
92+
"If the specified object is nil, returns the default windowColor, else return its window color."
93+
94+
anObject ifNil: [ ^ self defaultWindowColor ].
95+
^ anObject windowColor
96+
]
97+
6698
{ #category : 'files' }
6799
DSRecordBrowserPresenter >> addFile: aFileReference [
68100
"Adds a file in the presenter and set is as selected, which updates the records displayed."
@@ -87,6 +119,26 @@ DSRecordBrowserPresenter >> addRecordButton [
87119
yourself
88120
]
89121

122+
{ #category : 'layout' }
123+
DSRecordBrowserPresenter >> colorReferential [
124+
"Instanciates a new table that displays the color referential."
125+
126+
^ self newTreeTable
127+
addColumn: (SpStringTableColumn new
128+
title: 'Color';
129+
evaluated: [ ];
130+
displayBackgroundColor: [ :association | association key ];
131+
yourself);
132+
addColumn: (SpStringTableColumn new
133+
title: 'Window type';
134+
evaluated: [ :association | association value ];
135+
displayColor: [ :aRecord | Color white ];
136+
yourself);
137+
roots: self class colorAssociations;
138+
beResizable;
139+
yourself
140+
]
141+
90142
{ #category : 'initialization' }
91143
DSRecordBrowserPresenter >> connectPresenters [
92144
"Updates the records and the timeline whenever the selected file is changed."
@@ -105,7 +157,11 @@ DSRecordBrowserPresenter >> defaultLayout [
105157
add: toolbarPresenter expand: false;
106158
add: (SpPanedLayout newHorizontal
107159
positionOfSlider: 30 percent;
108-
add: fileListPresenter;
160+
add: (SpPanedLayout newTopToBottom
161+
add: fileListPresenter;
162+
add: self colorReferential;
163+
positionOfSlider: 57 percent;
164+
yourself);
109165
add: (SpBoxLayout newTopToBottom
110166
add: (SpTabLayout new
111167
add: recordsTablePresenter label: 'Records';
@@ -159,7 +215,8 @@ DSRecordBrowserPresenter >> getRecordColorAssociationsFrom: aWindowRecordCollect
159215
recordColorsAssociations := OrderedCollection new.
160216

161217
aWindowRecordCollection do: [ :windowRecord |
162-
recordColorsAssociations addAll: (windowRecord events collect: [ :record | record -> (self getWindowColorFrom: windowRecord) ]) ].
218+
recordColorsAssociations addAll:
219+
(windowRecord events collect: [ :record | record -> windowRecord windowColor ]) ].
163220

164221
^ recordColorsAssociations sorted: [ :recordA :recordB | recordA key dateTime < recordB key dateTime ]
165222
]
@@ -168,31 +225,13 @@ DSRecordBrowserPresenter >> getRecordColorAssociationsFrom: aWindowRecordCollect
168225
DSRecordBrowserPresenter >> getTimelinePointsFrom: aHistory [
169226
"Returns a list of plots for the timeline chart."
170227

171-
^ aHistory windows collectWithIndex: [ :w :index |
228+
^ aHistory windows collectWithIndex: [ :windowRecord :index |
172229
RSTimeLinePlot new
173230
entries: {
174-
w events first dateTime asNanoSeconds.
175-
w events last dateTime asNanoSeconds }
231+
windowRecord events first dateTime asNanoSeconds.
232+
windowRecord events last dateTime asNanoSeconds }
176233
at: index;
177-
color: (self getWindowColorFrom: w) ]
178-
]
179-
180-
{ #category : 'color' }
181-
DSRecordBrowserPresenter >> getWindowColorFrom: aWindowRecord [
182-
"Returns the window associated color, and the default color otherwise."
183-
184-
aWindowRecord isBrowser ifTrue: [ ^ Color fromHexString: '#2A2AB7' ].
185-
aWindowRecord isInspector ifTrue: [ ^ Color fromHexString: '#FFC300' ].
186-
aWindowRecord isDebugger ifTrue: [ ^ Color fromHexString: '#C41E3D' ].
187-
188-
aWindowRecord isPlayground ifTrue: [ ^ Color fromHexString: '#70B77E' ].
189-
aWindowRecord isDebugPointBrowser ifTrue: [ ^ Color fromHexString: '#7C238C' ].
190-
aWindowRecord isCritiqueBrowser ifTrue: [ ^ Color fromHexString: '#A45C15' ].
191-
aWindowRecord isEpicea ifTrue: [ ^ Color fromHexString: '#345e54' ].
192-
aWindowRecord isIceberg ifTrue: [ ^ Color fromHexString: '#2B5BA9' ].
193-
aWindowRecord isRewriter ifTrue: [ ^ Color fromHexString: '#292929' ].
194-
195-
^ Color gray
234+
color: windowRecord windowColor ]
196235
]
197236

198237
{ #category : 'initialization' }
@@ -326,13 +365,13 @@ DSRecordBrowserPresenter >> startRecordButton [
326365

327366
{ #category : 'recording' }
328367
DSRecordBrowserPresenter >> startRecording [
329-
"Starts recording events and instianciates a timerWindow which displays a timer and shows that Debugging Spy is recordering."
368+
"Starts recording events and instianciates a timerWindow which displays a timer and shows that Debugging Spy is recording."
330369

331-
DSSpyInstrumenter instrumentSystem.
332370
timerWindow := DSTimerWindow new
333371
openInWorld;
334-
startTimer;
335372
yourself.
373+
DSSpyInstrumenter instrumentSystem.
374+
timerWindow startTimer.
336375
self updateToolbar
337376
]
338377

@@ -367,7 +406,7 @@ DSRecordBrowserPresenter >> timelineChart [
367406
fileListPresenter selectedItem ifNil: [ ^ nil ].
368407

369408
history := self getHistoryFrom: fileListPresenter selectedItem.
370-
names := history windows collect: [ :i | i getWindowType ].
409+
names := history windows collect: [ :i | i windowType ].
371410

372411
data := self getTimelinePointsFrom: history.
373412
data size < 2 ifTrue: [ ^ nil ].

0 commit comments

Comments
 (0)