WAPath


Seaside-Components-Widgets

Comment:

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'

Hierarchy:

ProtoObject
Object
WAPresenter
WAComponent
WAPath

Summary:

instance variables:

stack

methods:

instance class
accessing behavior initialize rendering example

Detail:

instance variables:

stack

instance methods:

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].

class methods:

example
example

	^self new 
		pushSegment: 123 name: 'xxx'; 
		pushSegment: 456 name: 'yyy';
		pushSegment: 789 name: 'zzz';
		yourself.

^top


- made by Dandelion -