ResourceSelectionBrowser.st
changeset 1986 5cb77205ce00
parent 1978 c4334704dc58
child 2026 df5b0b3902de
equal deleted inserted replaced
1985:8c887bee94fa 1986:5cb77205ce00
   355                         )
   355                         )
   356                        (InputFieldSpec
   356                        (InputFieldSpec
   357                           name: 'classNameInputField'
   357                           name: 'classNameInputField'
   358                           layout: (LayoutFrame 2 0.0 -22 1 -1 1.0 0 1)
   358                           layout: (LayoutFrame 2 0.0 -22 1 -1 1.0 0 1)
   359                           tabable: true
   359                           tabable: true
   360                           model: valueOfClassName
   360                           model: classNameHolder
   361                           acceptOnLeave: true
   361                           acceptOnLeave: true
   362                           acceptOnLostFocus: true
   362                           acceptOnLostFocus: true
   363                           acceptOnPointerLeave: true
   363                           acceptOnPointerLeave: true
   364                         )
   364                         )
   365                        )
   365                        )
   390                         )
   390                         )
   391                        (InputFieldSpec
   391                        (InputFieldSpec
   392                           name: 'selectorInputField'
   392                           name: 'selectorInputField'
   393                           layout: (LayoutFrame 2 0.0 -22 1 -2 1.0 0 1)
   393                           layout: (LayoutFrame 2 0.0 -22 1 -2 1.0 0 1)
   394                           tabable: true
   394                           tabable: true
   395                           model: valueOfResourceSelector
   395                           model: resourceSelectorHolder
   396                           acceptOnLeave: true
   396                           acceptOnLeave: true
   397                           acceptOnLostFocus: true
   397                           acceptOnLostFocus: true
   398                           acceptOnPointerLeave: true
   398                           acceptOnPointerLeave: true
   399                         )
   399                         )
   400                        )
   400                        )
   490      )
   490      )
   491 ! !
   491 ! !
   492 
   492 
   493 !ResourceSelectionBrowser methodsFor:'aspects'!
   493 !ResourceSelectionBrowser methodsFor:'aspects'!
   494 
   494 
       
   495 classNameHolder
       
   496     "returns the value holder for the name of the class"
       
   497 
       
   498     |holder|
       
   499 
       
   500     (holder := builder bindingAt:#valueOfClassName) isNil ifTrue:[
       
   501         builder aspectAt:#valueOfClassName put:(holder :=  '' asValue).
       
   502         holder onChangeEvaluate:[self classSelectionUpdate:holder value].
       
   503     ].
       
   504     ^ holder
       
   505 !
       
   506 
   495 helpEnabled
   507 helpEnabled
   496     "returns whether there is a documentation file"
   508     "returns whether there is a documentation file"
   497 
   509 
   498     ^true
   510     ^true
   499 !
   511 !
   509 
   521 
   510     |holder|
   522     |holder|
   511     (holder := builder bindingAt:#resourceMethodColumns) isNil ifTrue:[
   523     (holder := builder bindingAt:#resourceMethodColumns) isNil ifTrue:[
   512         builder aspectAt:#resourceMethodColumns put:(holder := List new).
   524         builder aspectAt:#resourceMethodColumns put:(holder := List new).
   513         holder addAll: (self class tableColumnsForResourceMethodAttributes collect: [:i| i decodeAsLiteralArray]).
   525         holder addAll: (self class tableColumnsForResourceMethodAttributes collect: [:i| i decodeAsLiteralArray]).
       
   526     ].
       
   527     ^ holder
       
   528 !
       
   529 
       
   530 resourceSelectorHolder
       
   531     "returns the value holder for the name of the selector"
       
   532 
       
   533     |holder|
       
   534     (holder := builder bindingAt:#valueOfResourceSelector) isNil ifTrue:[
       
   535         builder aspectAt:#valueOfResourceSelector put:(holder :=  '' asValue).
   514     ].
   536     ].
   515     ^ holder
   537     ^ holder
   516 !
   538 !
   517 
   539 
   518 rootOfClassCategories
   540 rootOfClassCategories
   584                       comp := builder componentAt: #listOfClassCategoriesView.
   606                       comp := builder componentAt: #listOfClassCategoriesView.
   585                       newRoot := self rootOfClassCategories. 
   607                       newRoot := self rootOfClassCategories. 
   586                  ].
   608                  ].
   587                  comp root:newRoot.
   609                  comp root:newRoot.
   588                  comp raise. 
   610                  comp raise. 
   589                  classSelectionBlock value: self valueOfClassName value
   611                  classSelectionBlock value: self classNameHolder value
   590             ]
   612             ]
   591     ].
   613     ].
   592     ^ holder
   614     ^ holder
   593 !
   615 !
   594 
   616 
   603 !
   625 !
   604 
   626 
   605 valueOfClassName
   627 valueOfClassName
   606     "returns the value holder for the name of the class"
   628     "returns the value holder for the name of the class"
   607 
   629 
   608     |holder|                   
   630     self obsoleteMethodWarning:'stupid name - use #classNameHolder'.
   609     (holder := builder bindingAt:#valueOfClassName) isNil ifTrue:[
   631     ^ self classNameHolder
   610         builder aspectAt:#valueOfClassName put:(holder :=  '' asValue).
       
   611         holder onChangeEvaluate:[self classSelectionUpdate:holder value].
       
   612     ].
       
   613     ^ holder
       
   614 !
   632 !
   615 
   633 
   616 valueOfResourceSelector
   634 valueOfResourceSelector
   617     "returns the value holder for the name of the selector"
   635     "returns the value holder for the name of the selector"
   618 
   636 
   619     |holder|
   637     self obsoleteMethodWarning:'stupid name - use #resourceSelectorHolder'.
   620     (holder := builder bindingAt:#valueOfResourceSelector) isNil ifTrue:[
   638     ^ self resourceSelectorHolder
   621 	builder aspectAt:#valueOfResourceSelector put:(holder :=  '' asValue).
       
   622     ].
       
   623     ^ holder
       
   624 ! !
   639 ! !
   625 
   640 
   626 !ResourceSelectionBrowser methodsFor:'callbacks-class list'!
   641 !ResourceSelectionBrowser methodsFor:'callbacks-class list'!
   627 
   642 
   628 treeViewClassCategoryChildren
   643 treeViewClassCategoryChildren
   779             hierItem notNil ifTrue:[
   794             hierItem notNil ifTrue:[
   780                 self selectionOfClassCategories value: hierItem.
   795                 self selectionOfClassCategories value: hierItem.
   781             ].
   796             ].
   782         ].
   797         ].
   783     ].
   798     ].
   784     self valueOfClassName value: clsPattern.
   799     self classNameHolder value: clsPattern.
   785     self updateResourceMethodList.
   800     self updateResourceMethodList.
   786 !
   801 !
   787 
   802 
   788 resourceDoubleClicked
   803 resourceDoubleClicked
   789     "after a double click on resource method, accept it and close"
   804     "after a double click on resource method, accept it and close"
   794 
   809 
   795 resourceSelected
   810 resourceSelected
   796     "after a click on a resource method, set its selector into the field"
   811     "after a click on a resource method, set its selector into the field"
   797 
   812 
   798     self selectionOfResourceMethod value notNil
   813     self selectionOfResourceMethod value notNil
   799 	ifTrue: [self valueOfResourceSelector value: self selectionOfResourceMethod value selector]
   814         ifTrue: [self resourceSelectorHolder value: self selectionOfResourceMethod value selector]
   800 !
   815 !
   801 
   816 
   802 updateResourceMethodList
   817 updateResourceMethodList
   803     "read the allowed resource methods of the selected class"
   818     "read the allowed resource methods of the selected class"
   804 
   819 
   822     self withWaitCursorDo:[
   837     self withWaitCursorDo:[
   823         |newContents|           
   838         |newContents|           
   824 
   839 
   825         resourceTypes isNil ifTrue: [resourceTypes := Method resourceTypes].
   840         resourceTypes isNil ifTrue: [resourceTypes := Method resourceTypes].
   826 
   841 
   827         self valueOfClassName value: className.
   842         self classNameHolder value: className.
   828         self class lastSelection: className.
   843         self class lastSelection: className.
   829 
   844 
   830         newContents := class class methodDictionary asOrderedCollection 
   845         newContents := class class methodDictionary asOrderedCollection 
   831                        select: [:m | m resources notNil 
   846                        select: [:m | m resources notNil 
   832                                      and: [resourceTypes includes: m resourceType]
   847                                      and: [resourceTypes includes: m resourceType]
   860             cls notNil ifTrue:[
   875             cls notNil ifTrue:[
   861                 resourceClass := cls
   876                 resourceClass := cls
   862             ]
   877             ]
   863         ]
   878         ]
   864     ].            
   879     ].            
   865     self valueOfResourceSelector value:(aSelector ? '').
   880     self resourceSelectorHolder value:(aSelector ? '').
   866     self open.
   881     self open.
   867 
   882 
   868     (selectedClass := self selectionOfClassHierarchy value) isNil ifTrue:[
   883     (selectedClass := self selectionOfClassHierarchy value) isNil ifTrue:[
   869         (selectedClass := self selectionOfClassCategories value) isNil ifTrue:[
   884         (selectedClass := self selectionOfClassCategories value) isNil ifTrue:[
   870             (enteredClassName := self valueOfClassName value) isNil ifTrue:[
   885             (enteredClassName := self classNameHolder value) isNil ifTrue:[
   871                 accept value ifTrue:[
   886                 accept value ifTrue:[
   872                     self warn:'No valid class selected/entered'.
   887                     self warn:'No valid class selected/entered'.
   873                 ].
   888                 ].
   874                 ^ nil
   889                 ^ nil
   875             ]
   890             ]
   880     className isNil ifTrue:[
   895     className isNil ifTrue:[
   881         className := selectedClass name
   896         className := selectedClass name
   882     ].
   897     ].
   883     cls := Smalltalk classNamed:className.
   898     cls := Smalltalk classNamed:className.
   884     (cls isClass and:[accept value]) ifTrue:[            
   899     (cls isClass and:[accept value]) ifTrue:[            
   885         ^ Method::MethodWhoInfo class:cls selector:(self valueOfResourceSelector value)
   900         ^ Method::MethodWhoInfo class:cls selector:(self resourceSelectorHolder value)
   886     ].
   901     ].
   887 
   902 
   888     accept value ifTrue:[
   903     accept value ifTrue:[
   889         self warn:'No valid class selected/entered'.
   904         self warn:'No valid class selected/entered'.
   890     ].
   905     ].
   908         ifTrue: [classSelection :=  self class lastSelection].
   923         ifTrue: [classSelection :=  self class lastSelection].
   909 "/    (classSelection isNil or:[Smalltalk at: classSelection]) isNil 
   924 "/    (classSelection isNil or:[Smalltalk at: classSelection]) isNil 
   910 "/        ifTrue: [classSelection :=  self treeViewContents].
   925 "/        ifTrue: [classSelection :=  self treeViewContents].
   911 
   926 
   912     classSelectionBlock := [:clsPattern | self classSelectionUpdate:clsPattern].
   927     classSelectionBlock := [:clsPattern | self classSelectionUpdate:clsPattern].
   913     self valueOfClassName value:classSelection.  
   928     self classNameHolder value:classSelection.  
   914 
   929 
   915     (classNameInputField := builder componentAt: #classNameInputField) 
   930     (classNameInputField := builder componentAt: #classNameInputField) 
   916         entryCompletionBlock:
   931         entryCompletionBlock:
   917             [:value|
   932             [:value|
   918                 |s what m|
   933                 |s what m|
   929 "/                classNameInputField contents:what first.
   944 "/                classNameInputField contents:what first.
   930 "/                oldClassName = classNameInputField contents ifTrue:[classNameInputField flash].
   945 "/                oldClassName = classNameInputField contents ifTrue:[classNameInputField flash].
   931 "/                classSelectionBlock value: classNameInputField contents
   946 "/                classSelectionBlock value: classNameInputField contents
   932             ].
   947             ].
   933 
   948 
   934     classSelectionBlock value: self valueOfClassName value.
   949     classSelectionBlock value: self classNameHolder value.
   935     self updateResourceMethodList.
   950     self updateResourceMethodList.
   936     self selectionOfResourceMethod value: (self listOfResourceMethods detect: [:m| m selector == resourceMethod] ifNone: nil).
   951     self selectionOfResourceMethod value: (self listOfResourceMethods detect: [:m| m selector == resourceMethod] ifNone: nil).
   937 
   952 
   938     ^super postBuildWith:aBuilder
   953     ^super postBuildWith:aBuilder
   939 !
   954 !