--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SmallSense__MethodSearchDialog.st Tue May 06 08:23:16 2014 +0100
@@ -0,0 +1,160 @@
+"{ 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'!
+
+updateMatchingObjects
+ | environment |
+
+ matchingObjects := nil.
+ environment := self environment.
+ self matchPatternHolder value notEmptyOrNil ifTrue:[
+ | pattern |
+ pattern := StringPattern fromString: self matchPatternHolder value.
+"/ [
+"/ self updateMatchingLabelToSearching.
+ matchingObjects := self matchingObjectsForPattern: pattern inEnvironment: environment.
+"/ ] ensure:[
+"/ self updateMatchingLabelToNormal.
+"/ ]
+ ] ifFalse:[
+ matchingObjects := self recentlySearchedObjects asArray reversed.
+ ].
+ self updateMatchingObjects: matchingObjects.
+
+ "Created: / 27-04-2014 / 23:48:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-04-2014 / 11:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!MethodSearchDialog methodsFor:'hooks'!
+
+commonPostOpen
+"/ self updateMatching.
+"/ recentlySearchedPatterns notEmptyOrNil ifTrue:[
+"/ matchPatternView contents: self recentlySearchedPatterns last.
+"/ matchPatternView selectAll.
+"/ ].
+ 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: / 30-04-2014 / 11:48:16 / 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>"
+! !
+