SmallSense__MethodSearchDialog.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 20 Jun 2014 13:56:46 +0100
changeset 346 88c1d211f9be
parent 344 88d012c17762
child 347 d76d7d8d17a3
permissions -rw-r--r--
Reintroduced PO>>subject. This method is usefull when writing generic code (such as the one in search dialogs). However, PO>>subject is now considered 'private' and should be used with care. It's name is not very intention revealing and it is not clear what it really returns. Don't use it in non-generic code that does care what's the return value.

"{ Package: 'jv:smallsense' }"

"{ NameSpace: SmallSense }"

AbstractSearchDialog subclass:#MethodSearchDialog
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'SmallSense-Core-Interface-Search'
!

!MethodSearchDialog class methodsFor:'interface specs-content'!

optionsPaneSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:SmallSense::ClassSearchDialog andSelector:#optionsPaneSpec
     SmallSense::ClassSearchDialog new openInterface:#optionsPaneSpec
    "

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: optionsPaneSpec
       window: 
      (WindowSpec
         label: 'Search Options...'
         name: 'Search Options...'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 634 25)
       )
       component: 
      (SpecCollection
         collection: (
          (VerticalPanelViewSpec
             name: 'Options'
             layout: (LayoutFrame 0 0 0 0 0 1 0 1)
             horizontalLayout: fit
             verticalLayout: fit
             horizontalSpace: 3
             verticalSpace: 3
             component: 
            (SpecCollection
               collection: (
                (CheckBoxSpec
                   label: 'Match fully qualified class names'
                   name: 'CheckBox1'
                   model: matchFullyQualifiedClassNameHolder
                   extent: (Point 634 25)
                 )
                )
              
             )
           )
          )
        
       )
     )
! !

!MethodSearchDialog methodsFor:'accessing-defaults'!

defaultTitle
    ^ (resources string: 'Search Method...')

    "Created: / 05-05-2014 / 23:39:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MethodSearchDialog methodsFor:'change & update'!

updateMatchingObjectsIgnorePattern
    "/ There's a lot of method, do not display them all but
    "/ rather display only recent selections.                   

    matchingObjects := self recentlySearchedObjects asArray reversed.
    self updateMatchingObjects: matchingObjects.

    "Created: / 10-05-2014 / 11:50:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MethodSearchDialog methodsFor:'hooks'!

commonPostOpen
"/    self updateMatching.
"/    recentlySearchedPatterns notEmptyOrNil ifTrue:[
"/        matchPatternView contents: self recentlySearchedPatterns last.
"/        matchPatternView selectAll.
"/    ].
    matchPatternHolder addDependent:self.          
    self recentlySearchedObjects notEmptyOrNil ifTrue:[
        self updateMatchingObjects: self recentlySearchedObjects asArray reverse.
        self updateMatchingLabelToRecentSearches.
    ].
    self updateAcceptEnabled.

    "Created: / 08-03-2013 / 13:15:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 10-05-2014 / 01:06:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MethodSearchDialog methodsFor:'queries'!

canSelect: selection
    ^ selection askFor: #isSmallSenseMethodPO.

    "Created: / 22-04-2014 / 13:08:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 06-05-2014 / 00:27:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!MethodSearchDialog methodsFor:'searching'!

matchingObjectPOsFor: objects
    ^ (objects collect:[:each | MethodPO name:each selector class: each mclass ])
        sort:[ :a :b | a name == b name ifTrue:[ a klass name < b klass name] ifFalse:[ a name < b name ] ];
        yourself

    "Created: / 30-04-2014 / 09:50:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 06-05-2014 / 00:31:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

matchingObjectsForPattern:pattern inEnvironment:environment 
    | matching |

    matching := OrderedCollection new.
    self matchPatternHolder value notEmptyOrNil ifTrue:[
        environment 
            allMethodsDo:[:mthd |
                | name |

                name := mthd selector.
                mthd isJavaMethod ifTrue:[ name := name upTo: $( ].
                ((filter isNil or:[filter value: mthd]) and:[(pattern match:name)]) ifTrue:[
                    matching add:mthd.
                ].
            ].
    ].

    ^ matching

    "Created: / 28-04-2014 / 23:20:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 06-05-2014 / 00:34:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !