WALibraryBrowser


Seaside-Components-Tools

Comment:



Hierarchy:

ProtoObject
Object
WAPresenter
WAComponent
WALibraryBrowser

Summary:

instance variables:

group hits library search selector

methods:

instance class
as yet unclassified no messages

Detail:

instance variables:

group
hits
library
search
selector

instance methods:

as yet unclassified
find: aString

	| inst |
	self libraries do:
		[:ea |
		inst _ ea new.
		ea selectors do: 
			[:sel |
			((inst perform: sel) includesSubString: aString)
				ifTrue: [(hits at: (Array with: ea with: sel) ifAbsentPut: [SortedCollection new]) add: aString]]]
findAll: aString

	hits _ Dictionary new.
	(aString findTokens: ' ') do: [:ea | self find: ea].
	hits isEmpty ifFalse: [self goto: self orderedHits first]
goto: anArray

	library _ anArray first.
	selector _ anArray second
hits

	^ hits ifNil: [#()]
libraries

	^ (WAStyleLibrary subclasses, WAScriptLibrary subclasses) asSortedCollection: [:a :b | a name <= b name]
library

	^ library
library: aLibraryClass

	library _ aLibraryClass.
	selector _ nil.
orderedHits

	^ hits keys asSortedCollection: [:a :b | (hits at: a) size >= (hits at: b) size]
renderColumnsOn: html

	html attributes
			size: 10;
			submitOnChange.
		html
			selectFromList: self libraries
			selected: self library
			callback: [:v | self library: v].
		html attributes
			size: 10;
			submitOnChange.
		html
			selectFromList: self selectors
			selected: self selector
			callback: [:v | self selector: v].
renderContentOn: html

	html divClass: 'stylebrowser-columns' with: [
		html form: [self renderColumnsOn: html].
	].
	html divClass: 'stylebrowser-search' with: [
		html form: [
			html textInputWithValue: search callback: [:v | search _ v].
			html space.
			html submitButtonWithAction: [self findAll: search] text: 'Search'.
		].
		html list: self orderedHits do:
			[:pair |
			self renderHit: pair on: html].
	].
	html divClass: 'stylebrowser-editor' with: [
		html form: [
			self renderEditorOn: html.
			html paragraph.
			html submitButtonWithAction: [self save] text: 'Save'.
		]
	].
renderEditorOn: html

	html attributes
		rows: 20;
		cols: 80.
	html textAreaWithValue: self string callback: [:v | self string: v].
renderHit: anArray on: html

	| text |
	text _ String streamContents:
			[:s |
			s nextPutAll: anArray first name.
			s nextPutAll: '>>'.
			s nextPutAll: anArray second.
			s space.
			s nextPutAll: '('.
			(hits at: anArray)
				do: [:ea | s nextPutAll: ea]
				separatedBy: [s nextPutAll: ', '].
			s nextPutAll: ')'].
	html anchorWithAction: [self goto: anArray] text: text.
	
save

search: aString

	search _ aString.
	self findAll: search
selector

	^ selector
selector: aSymbol

	(library selectors includes: aSymbol) ifTrue: [selector _ aSymbol]
selectors

	^ library ifNil: [#()] ifNotNil: [library selectors]
string

	^ self selector ifNotNilDo: [:s | library new perform: s]
string: aString

	self selector ifNotNilDo:
		[:sel |
		library compile: (sel, '
	^ ', aString printString)]
style

	^ '
	.stylebrowser-search {float: left}
	.stylebrowser-columns {float: left}
	.stylebrowser-editor {clear: both}
	'

class methods:

^top


- made by Dandelion -