SettingsDialog.st
changeset 6505 311c27b13f51
parent 6389 9f4010737320
child 6635 e20f08617728
equal deleted inserted replaced
6504:be1d4f767b74 6505:311c27b13f51
   628     (locIcon isNil and:[locClass respondsTo:#defaultIcon]) ifTrue:[ locIcon := locClass defaultIcon].
   628     (locIcon isNil and:[locClass respondsTo:#defaultIcon]) ifTrue:[ locIcon := locClass defaultIcon].
   629     applicationLabel := (aName asCollectionOfSubstringsSeparatedBy:$/) last.
   629     applicationLabel := (aName asCollectionOfSubstringsSeparatedBy:$/) last.
   630 
   630 
   631     ^ self 
   631     ^ self 
   632         createItemName:aName 
   632         createItemName:aName 
   633         label:(resources string:applicationLabel) 
   633         label:applicationLabel 
   634         class:locClass 
   634         class:locClass 
   635         icon:locIcon 
   635         icon:locIcon 
   636         expandParent:doExpand 
   636         expandParent:doExpand 
   637         replaceExisting:false
   637         replaceExisting:false
   638 !
   638 !
   831 
   831 
   832 addCategoriesFor:aName
   832 addCategoriesFor:aName
   833     "create all the categories"
   833     "create all the categories"
   834 
   834 
   835     (aName includes:$/) ifFalse:[ ^ self].
   835     (aName includes:$/) ifFalse:[ ^ self].
   836     self treeName:aName butLast:1 do:[:currentLabel :currentName| | length icon|
   836     self treeName:aName butLast:1 do:[:currentLabel :currentName| 
       
   837         |length icon|
       
   838 
   837         currentLabel notEmpty ifTrue:[
   839         currentLabel notEmpty ifTrue:[
   838             icon := self categoryIcons at:currentName ifAbsent:[nil].
   840             icon := self categoryIcons at:currentName ifAbsent:[nil].
   839             self createItemName:currentName label:currentLabel icon:icon replaceExisting:true.
   841             self createItemName:currentName label:currentLabel icon:icon replaceExisting:true.
   840         ]
   842         ]
   841     ].
   843     ].
   842 !
   844 !
   843 
   845 
   844 createItemForApplication:anApplication class:aClass label:aLabel icon:aIcon expandParent:expandParent replaceExisting:doReplaceExisting
   846 createItemForApplication:anApplication class:aClass label:aLabel icon:anIcon expandParent:expandParent replaceExisting:doReplaceExisting
   845     "create an application item in my application list"
   847     "create an application item in my application list"
   846 
   848 
   847     | newItem parent locIcon item|
   849     | newItem parent locIcon item|
   848 
   850 
   849     parent := self getItemByApplication:anApplication.
   851     parent := self getItemByApplication:anApplication.
   851         ^ nil
   853         ^ nil
   852     ].
   854     ].
   853 
   855 
   854     doReplaceExisting ifTrue:[
   856     doReplaceExisting ifTrue:[
   855         parent children notNil ifTrue:[
   857         parent children notNil ifTrue:[
   856             (item := parent children detect:[ :aItem | aItem application == anApplication] ifNone:[nil]) notNil ifTrue:[
   858             (item := parent children detect:[ :anItem | anItem application == anApplication] ifNone:[nil]) notNil ifTrue:[
   857                 ^ item.
   859                 ^ item.
   858             ]
   860             ]
   859         ]
   861         ]
   860     ].
   862     ].
   861 
   863 
   862     newItem := self class itemClass new.  
   864     newItem := self class itemClass new.  
   863     "/ newItem label:(resources string:aLabel) "allBold".
   865     "/ newItem label:(resources string:aLabel) "allBold".
   864     newItem label:aLabel "allBold".
   866     newItem label:aLabel "allBold".
   865     newItem nameString:(anApplication itemPathName , aLabel).
   867     newItem nameString:(anApplication itemPathName , aLabel).
   866     newItem applicationClass:aClass.
   868     newItem applicationClass:aClass.
   867     locIcon := aIcon.
   869     locIcon := anIcon.
   868     locIcon isNil ifTrue:[ locIcon := self class defaultSettingsAppIcon].
   870     locIcon isNil ifTrue:[ locIcon := self class defaultSettingsAppIcon].
   869     newItem icon:locIcon.
   871     newItem icon:locIcon.
   870     parent add:newItem.
   872     parent add:newItem.
   871     expandParent ifTrue:[
   873     expandParent ifTrue:[
   872         parent expand.
   874         parent expand.
   873     ].
   875     ].
   874     ^ newItem
   876     ^ newItem
   875 !
   877 !
   876 
   878 
   877 createItemName:aNameString label:aLabel class:aClass icon:aIcon
   879 createItemName:aNameString label:aLabel class:aClass icon:anIcon
   878     ^ self createItemName:aNameString label:aLabel class:aClass icon:aIcon expandParent:false
   880     ^ self createItemName:aNameString label:aLabel class:aClass icon:anIcon expandParent:false
   879 !
   881 !
   880 
   882 
   881 createItemName:aNameString label:aLabel class:aClass icon:aIcon expandParent:expandParent
   883 createItemName:aNameString label:aLabel class:aClass icon:anIcon expandParent:expandParent
   882     ^ self
   884     ^ self
   883         createItemName:aNameString label:aLabel class:aClass icon:aIcon 
   885         createItemName:aNameString 
       
   886         label:aLabel 
       
   887         class:aClass 
       
   888         icon:anIcon 
   884         expandParent:expandParent
   889         expandParent:expandParent
   885         replaceExisting:true
   890         replaceExisting:true
   886 !
   891 !
   887 
   892 
   888 createItemName:aNameString label:aLabel class:aClass icon:aIcon expandParent:expandParent replaceExisting:doReplaceExisting
   893 createItemName:aNameString label:untranslatedLabel class:aClass icon:anIcon expandParent:expandParent replaceExisting:doReplaceExisting
   889     "create an application item in my application list"
   894     "create an application item in my application list"
   890 
   895 
   891     | newItem parentsName parent locIcon item|
   896     |newItem parentsName parent locIcon item|
   892 
   897 
   893     (aNameString includes:$/) ifTrue:[
   898     (aNameString includes:$/) ifTrue:[
   894         parentsName := aNameString copyTo:(aNameString lastIndexOf:$/)-1.
   899         parentsName := aNameString copyTo:(aNameString lastIndexOf:$/)-1.
   895         parent := self getItemForName:parentsName.
   900         parent := self getItemForName:parentsName.
   896     ].
   901     ].
   906         ]
   911         ]
   907     ].
   912     ].
   908 
   913 
   909     newItem := self class itemClass new.  
   914     newItem := self class itemClass new.  
   910     "/ newItem label:(resources string:aLabel) "allBold".
   915     "/ newItem label:(resources string:aLabel) "allBold".
   911     newItem label:aLabel "allBold".
   916     newItem label:(resources string:untranslatedLabel) "allBold".
   912     newItem nameString:aNameString.
   917     newItem nameString:aNameString.
   913     newItem applicationClass:aClass.
   918     newItem applicationClass:aClass.
   914     locIcon := aIcon.
   919     locIcon := anIcon.
   915     locIcon isNil ifTrue:[ locIcon := self class defaultSettingsAppIcon].
   920     locIcon isNil ifTrue:[ locIcon := self class defaultSettingsAppIcon].
   916     newItem icon:locIcon.
   921     newItem icon:locIcon.
   917     parent add:newItem.
   922     parent add:newItem.
   918     expandParent ifTrue:[
   923     expandParent ifTrue:[
   919         parent expand.
   924         parent expand.
   920     ].
   925     ].
   921     ^ newItem
   926     ^ newItem
   922 !
   927 !
   923 
   928 
   924 createItemName:aNameString label:aLabel icon:aIcon
   929 createItemName:aNameString label:aLabel icon:anIcon
   925     "create an application item in my application list"
   930     "create an application item in my application list"
   926 
   931 
   927     self createItemName:aNameString label:aLabel class:nil icon:aIcon expandParent:false
   932     self createItemName:aNameString label:aLabel class:nil icon:anIcon expandParent:false
   928 !
   933 !
   929 
   934 
   930 createItemName:aNameString label:aLabel icon:aIcon replaceExisting:doReplaceExisting
   935 createItemName:aNameString label:aLabel icon:anIcon replaceExisting:doReplaceExisting
   931     "create an application item in my application list"
   936     "create an application item in my application list"
   932 
   937 
   933     self createItemName:aNameString label:aLabel class:nil icon:aIcon expandParent:false replaceExisting:doReplaceExisting
   938     self createItemName:aNameString label:aLabel class:nil icon:anIcon expandParent:false replaceExisting:doReplaceExisting
   934 !
   939 !
   935 
   940 
   936 getItemForName:aName
   941 getItemForName:aName
   937     | searchItem|
   942     | searchItem|
   938 
   943 
   943         searchItem isNil ifTrue:[ ^ nil].
   948         searchItem isNil ifTrue:[ ^ nil].
   944     ].
   949     ].
   945     ^ searchItem
   950     ^ searchItem
   946 !
   951 !
   947 
   952 
   948 removeItem:aItem 
   953 removeItem:anItem 
   949     "remove a application from the settingsTree"
   954     "remove a application from the settingsTree"
   950 
   955 
   951     |parent remParent|
   956     |parent remParent|
   952 
   957 
   953     aItem application release.
   958     anItem application release.
   954 
   959 
   955     parent := aItem parent.
   960     parent := anItem parent.
   956     parent isNil ifTrue:[" already removed " ^ self].
   961     parent isNil ifTrue:[" already removed " ^ self].
   957     parent remove:aItem.
   962     parent remove:anItem.
   958     
   963     
   959     [parent isCategory and:[parent children isEmptyOrNil]] whileTrue:[
   964     [parent isCategory and:[parent children isEmptyOrNil]] whileTrue:[
   960         remParent := parent.
   965         remParent := parent.
   961         parent := remParent parent.
   966         parent := remParent parent.
   962         parent remove:remParent.
   967         parent remove:remParent.
   963     ].
   968     ].
   964     self applicationList remove:aItem ifAbsent:[nil].
   969     self applicationList remove:anItem ifAbsent:[nil].
   965     self selectedItem value:parent.
   970     self selectedItem value:parent.
   966 !
   971 !
   967 
   972 
   968 treeName:aName butLast:last do:aBlock 
   973 treeName:aName butLast:last do:aBlock 
   969     | tree  length|
   974     | tree  length|
  1293 ! !
  1298 ! !
  1294 
  1299 
  1295 !SettingsDialog class methodsFor:'documentation'!
  1300 !SettingsDialog class methodsFor:'documentation'!
  1296 
  1301 
  1297 version
  1302 version
  1298     ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.63 2005-10-05 11:37:37 cg Exp $'
  1303     ^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.64 2006-01-30 17:06:47 cg Exp $'
  1299 ! !
  1304 ! !
  1300 
  1305 
  1301 SettingsDialog initialize!
  1306 SettingsDialog initialize!