Highlight protocols already defined in a class or superclasses
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 17 Aug 2016 22:07:04 +0100
changeset 983 7379ac82aade
parent 975 589eb0269c9f
child 984 819ea9a4a34a
Highlight protocols already defined in a class or superclasses ...when adding a protocol to a class.
SmallSense__ProtocolSelectDialog.st
extensions.st
--- a/SmallSense__ProtocolSelectDialog.st	Sat Jul 16 01:44:05 2016 +0100
+++ b/SmallSense__ProtocolSelectDialog.st	Wed Aug 17 22:07:04 2016 +0100
@@ -21,7 +21,7 @@
 "{ NameSpace: SmallSense }"
 
 CetegoryOrProtocolSelectDialog subclass:#ProtocolSelectDialog
-	instanceVariableNames:''
+	instanceVariableNames:'protocolsToHighlight'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SmallSense-Core-Interface-Search'
@@ -50,6 +50,16 @@
 "
 ! !
 
+!ProtocolSelectDialog methodsFor:'accessing'!
+
+protocolsToHighlight
+    ^ protocolsToHighlight
+!
+
+protocolsToHighlight:aCollection
+    protocolsToHighlight := aCollection.
+! !
+
 !ProtocolSelectDialog methodsFor:'accessing-defaults'!
 
 defaultTitle
@@ -65,6 +75,14 @@
 
     environment := self environment.
     protocols := Set new.
+    "/ Convert highlighted protocols to a Set because
+    "/ (i)  Set>>includes: is faster O(1)
+    "/ (ii) the collection passed in by client might be an iterator so
+    "/      doing so actually caches the value. We want this for
+    "/      performance reasons.
+    protocolsToHighlight notNil ifTrue:[
+        protocolsToHighlight := protocolsToHighlight asSet.
+    ].
 
     environment allMethodsDo:[ :mth | 
         | protocol |
@@ -78,9 +96,17 @@
     ].
     protocols := protocols asArray.
     protocols sort: [ :a :b | a < b ].
-    ^ protocols collect:[ :e | PluggablePO new label: e; subject: e ].
+    ^ protocols collect:[ :each | 
+        | label |
+
+        label := each.
+        (protocolsToHighlight notNil and:[protocolsToHighlight includes: each]) ifTrue:[  
+            label := label asText allBold.
+        ].
+        PluggablePO new label: label; subject: each 
+    ].
 
     "Created: / 13-12-2014 / 08:42:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 13-12-2014 / 12:55:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-08-2016 / 15:56:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
--- a/extensions.st	Sat Jul 16 01:44:05 2016 +0100
+++ b/extensions.st	Wed Aug 17 22:07:04 2016 +0100
@@ -857,6 +857,15 @@
     dialog title: (resources string: question).
     dialog addButtonCancel.   
     dialog addButtonAcceptWithLabel: (resources string: okLabel).  
+    dialog protocolsToHighlight: (Iterator on:[ :whatToDo |
+        self selectedClasses value do:[:each | 
+            each withAllSuperclassesDo:[ :cls |
+                cls methodDictionary do:[:method | 
+                    whatToDo value: method category.
+                ]
+            ].
+        ].
+    ]).
     initialText notNil ifTrue:[ 
         dialog pattern: initialText.
         dialog selection: initialText. 
@@ -867,7 +876,7 @@
     "
 
     "Created: / 09-01-2015 / 10:44:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (comment): / 21-02-2015 / 17:52:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-08-2016 / 16:01:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !Tools::NewSystemBrowser methodsFor:'menu actions-category-SmallSense'!