Icons in profiler tool, update for search models change

db4
Slava Pestov 2009-02-17 08:23:46 -06:00
parent 9990663a85
commit d14fba5b98
1 changed files with 49 additions and 25 deletions

View File

@ -1,14 +1,15 @@
! Copyright (C) 2007, 2009 Slava Pestov. ! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel quotations accessors fry assocs present math.order USING: kernel quotations accessors fry assocs present math.order
math.vectors arrays locals models.search models.sort models math.vectors arrays locals models.search models.sort models sequences
sequences vocabs tools.profiler words prettyprint ui ui.commands vocabs tools.profiler words prettyprint combinators.smart
ui.gadgets ui.gadgets.panes ui.gadgets.scrollers definitions.icons ui ui.commands ui.gadgets ui.gadgets.panes
ui.gadgets.tracks ui.gestures ui.gadgets.buttons ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons
ui.gadgets.tables ui.gadgets.search-tables ui.gadgets.labeled ui.gadgets.tables ui.gadgets.search-tables ui.gadgets.labeled
ui.gadgets.buttons ui.gadgets.packs ui.gadgets.labels ui.gadgets.buttons ui.gadgets.packs ui.gadgets.labels
ui.gadgets.tabbed ui.gadgets.status-bar ui.gadgets.borders ui.gadgets.tabbed ui.gadgets.status-bar ui.gadgets.borders
ui.tools.browser ui.tools.common ui.baseline-alignment ; ui.tools.browser ui.tools.common ui.baseline-alignment
ui.operations ui.images ;
FROM: models.filter => <filter> ; FROM: models.filter => <filter> ;
FROM: models.compose => <compose> ; FROM: models.compose => <compose> ;
IN: ui.tools.profiler IN: ui.tools.profiler
@ -23,34 +24,52 @@ generic class ;
SINGLETONS: word-renderer vocab-renderer ; SINGLETONS: word-renderer vocab-renderer ;
UNION: profiler-renderer word-renderer vocab-renderer ; UNION: profiler-renderer word-renderer vocab-renderer ;
<PRIVATE
: with-datastack* ( seq quot -- seq' )
'[ _ input<sequence ] output>array ; inline
PRIVATE>
! Value is a { word count } pair ! Value is a { word count } pair
M: profiler-renderer row-columns M: profiler-renderer row-columns
drop [ [ present ] map ] [ { "All" "" } ] if* ; drop
[
[
[ [ definition-icon <image-name> ] [ present ] bi ]
[ present ]
bi*
] with-datastack*
] [ { "" "All" "" } ] if* ;
M: profiler-renderer prototype-row
drop \ = definition-icon <image-name> "" "" 3array ;
M: profiler-renderer row-value M: profiler-renderer row-value
drop dup [ first ] when ; drop dup [ first ] when ;
M: vocab-renderer row-value M: profiler-renderer column-alignment drop { 0 0 1 } ;
call-next-method dup [ vocab ] when ; M: profiler-renderer filled-column drop 1 ;
M: profiler-renderer column-alignment drop { 0 1 } ; M: word-renderer column-titles drop { "" "Word" "Count" } ;
M: profiler-renderer filled-column drop 0 ; M: vocab-renderer column-titles drop { "" "Vocabulary" "Count" } ;
M: word-renderer column-titles drop { "Word" "Count" } ;
M: vocab-renderer column-titles drop { "Vocabulary" "Count" } ;
SINGLETON: method-renderer SINGLETON: method-renderer
M: method-renderer column-alignment drop { 0 1 } ; M: method-renderer column-alignment drop { 0 0 1 } ;
M: method-renderer filled-column drop 0 ; M: method-renderer filled-column drop 1 ;
! Value is a { method-body count } pair ! Value is a { method-body count } pair
M: method-renderer row-columns M: method-renderer row-columns
drop [ first synopsis ] [ second present ] bi 2array ; drop [
[ [ definition-icon <image-name> ] [ synopsis ] bi ]
[ present ]
bi*
] with-datastack* ;
M: method-renderer row-value drop first ; M: method-renderer row-value drop first ;
M: method-renderer column-titles drop { "Method" "Count" } ; M: method-renderer column-titles drop { "" "Method" "Count" } ;
: <profiler-model> ( values profiler -- model ) : <profiler-model> ( values profiler -- model )
[ [ filter-counts ] <filter> ] [ sort>> ] bi* <sort> ; [ [ filter-counts ] <filter> ] [ sort>> ] bi* <sort> ;
@ -67,17 +86,16 @@ M: method-renderer column-titles drop { "Method" "Count" } ;
] <search> ] <search>
] keep <profiler-model> ; ] keep <profiler-model> ;
: match? ( pair/f str -- ? )
swap dup [ first present subseq? ] [ 2drop t ] if ;
: <profiler-table> ( model renderer -- table ) : <profiler-table> ( model renderer -- table )
[ match? ] <search-table> ; [ first present ] <search-table>
[ invoke-primary-operation ] >>action ;
: <profiler-filter-model> ( counts profiler -- model' ) : <profiler-filter-model> ( counts profiler -- model' )
[ <model> ] dip <profiler-model> [ f prefix ] <filter> ; [ <model> ] dip <profiler-model> [ f prefix ] <filter> ;
: <vocabs-model> ( profiler -- model ) : <vocabs-model> ( profiler -- model )
[ vocab-counters ] dip <profiler-filter-model> ; [ vocab-counters [ [ vocab ] dip ] assoc-map ] dip
<profiler-filter-model> ;
: <generic-model> ( profiler -- model ) : <generic-model> ( profiler -- model )
[ generic-counters ] dip <profiler-filter-model> ; [ generic-counters ] dip <profiler-filter-model> ;
@ -98,10 +116,16 @@ M: method-renderer column-titles drop { "Method" "Count" } ;
[ first3 '[ _ _ method-matches? ] filter ] <filter> [ first3 '[ _ _ method-matches? ] filter ] <filter>
] keep <profiler-model> ; ] keep <profiler-model> ;
: sort-by-name ( obj1 obj2 -- <=> )
[ first name>> ] compare ;
: sort-by-call-count ( obj1 obj2 -- <=> )
[ second ] compare invert-comparison ;
: sort-options ( -- alist ) : sort-options ( -- alist )
{ {
{ [ [ first ] compare ] "by name" } { [ sort-by-name ] "by name" }
{ [ [ second ] compare invert-comparison ] "by call count" } { [ sort-by-call-count ] "by call count" }
} ; } ;
: <sort-options> ( model -- gadget ) : <sort-options> ( model -- gadget )
@ -160,7 +184,7 @@ M: method-renderer column-titles drop { "Method" "Count" } ;
: <profiler-gadget> ( -- profiler ) : <profiler-gadget> ( -- profiler )
vertical profiler-gadget new-track vertical profiler-gadget new-track
{ 5 5 } >>gap { 5 5 } >>gap
[ [ first ] compare ] <model> >>sort [ sort-by-name ] <model> >>sort
all-words counters <model> >>words all-words counters <model> >>words
<selection-model> >>vocab <selection-model> >>vocab
dup <vocabs-model> >>vocabs dup <vocabs-model> >>vocabs