I represent a path navigation such as the one that is displayed on the top of the web inspector when you toggle on the halos. Here is an example of path: xxx >> yyy >> zzz Useful methods are - #currentSegment returns zzz - pushSegment: anObject name: 'lulu'
ProtoObjectObjectWAPresenterWAComponentWAPath
| stack |
| instance | class |
|---|---|
| accessing behavior initialize rendering | example |
| stack |
|---|
| accessing |
|---|
| currentSegment |
^ stack isEmpty ifTrue: [nil] ifFalse: [stack last value] |
| behavior |
|---|
| choose: anAssociation |
"Install a new stack of navigation from the old one and the specified association." | newStack | newStack := Array new writeStream. stack do: [:ea | newStack nextPut: ea. ea == anAssociation ifTrue: [stack := newStack contents. ^ self]] |
| pushSegment: anObject name: aString |
stack _ stack, (Array with: aString -> anObject) |
| initialize |
|---|
| initialize |
stack _ #(). self session registerObjectForBacktracking: self. |
| rendering |
|---|
| renderContentOn: html |
stack isEmpty ifTrue: [^ self]. html divNamed: 'path' with: [ stack allButLast do: [:assoc | html anchorWithAction: [self choose: assoc] text: assoc key. html text: ' >> ']. html bold: stack last key]. |
| example |
|---|
| example |
^self new pushSegment: 123 name: 'xxx'; pushSegment: 456 name: 'yyy'; pushSegment: 789 name: 'zzz'; yourself. |