2014-07-22 3 views
0

나는 Spec library와 함께 Pharo 3에 있습니다. 다중 열리스트에 헤더를 추가 할 수있는 방법이 없습니다. 그러나 헤더를 추가하는 것은이 같은 TreeColumnModel하고있는 TreeModel를 통해 가능하다 :MultiColumnListModel에 헤더 추가하기

| m col1 col2 | 
m := TreeModel new. 
m roots: #(#a #b #C#d). 
m rootNodeHolder: [ :item | 
    TreeNodeModel new 
     content: item; 
     icon: Smalltalk ui icons smallConfigurationIcon ]. 
m openWithSpec. 
col1 := TreeColumnModel new 
    displayBlock: [ :node | node content asString ]; 
    headerLabel: 'Character'. 
col2 := TreeColumnModel new 
    displayBlock: [ :node | (Character value: node content asString first asciiValue + 1) asString ]; 
    headerLabel: 'Character +1'; 
    headerIcon: Smalltalk ui icons smallBackIcon. 
m 
    columns: {col1. col2}; 
    acceptDropBlock: [ :transfer :event :source :receiver | self halt ]. 
col2 
    headerLabel: 'Character +2'; 
    headerIcon: Smalltalk ui icons smallBackIcon; 
    displayBlock: [ :node | (Character value: node content asString first asciiValue + 2) asString ]. 
m rootNodeHolder: [ :item | 
    TreeNodeModel new 
     content: (Character value: (item asString first asciiValue + 5)) asSymbol; 
     icon: Smalltalk ui icons smallFullscreenIcon ]. 

가 어떻게 다음 MultiColumnListModel의 헤더를 얻을 수 있을까?

MultiColumnListModel new 
    items: {$a. $b. $c. $d. $f.}; 
    displayBlock: [:e | {e asString. e isVowel asString} ]; 
    openWithSpec. 

답변

0

이 방법이 유용할까요?

model := MultiColumnListModel new 
    items: { {'Letter'. 'isVowel'.}. $a. $b. $c. $d. $f.}; 
    displayBlock: [:e | 
    e isArray 
    ifTrue:[{e first asString. e last asString} ] 
    ifFalse:[ 
    {e asString. e isVowel asString} ]]. 
model 
    whenSelectionChanged:[ 
     model getIndex = 1 ifTrue:[  
     model setIndex:0]. 
    ]; 
    openWithSpec.