SmallSense__CriticsWindow.st
branchcvs_MAIN
changeset 988 75d5f2c16454
parent 968 4cd706e4706e
child 989 fe33765d67a6
--- a/SmallSense__CriticsWindow.st	Tue Oct 04 13:06:00 2016 +0200
+++ b/SmallSense__CriticsWindow.st	Fri Oct 14 17:57:17 2016 +0200
@@ -21,11 +21,11 @@
 "{ NameSpace: SmallSense }"
 
 SimpleDialog subclass:#CriticsWindow
-        instanceVariableNames:'ruleHolder ruleRationaleAndFixesHTMLHolder rationalView fixer
-                entered codeView closeOnLeave'
-        classVariableNames:''
-        poolDictionaries:''
-        category:'SmallSense-Core-Interface'
+	instanceVariableNames:'ruleHolder ruleRationaleAndFixesHTMLHolder rationalView fixer
+		entered codeView closeOnLeave'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'SmallSense-Core-Interface'
 !
 
 !CriticsWindow class methodsFor:'documentation'!
@@ -68,6 +68,9 @@
 
     ^ super flyByHelpSpec addPairsFrom:#(
 
+#applyRuleIn
+'Apply this rule on more code.'
+
 #disableRule
 'Disable this rule in the future\(for the rest of this session, unless you save the ruleset)'
 
@@ -143,6 +146,19 @@
              keepSpaceForOSXResizeHandleH: true
            )
           (LinkButtonSpec
+             label: 'Apply this Rule In...'
+             name: 'Button5'
+             layout: (AlignmentOrigin 0 1 -59 1 1 0)
+             activeHelpKey: applyRuleIn
+             level: 0
+             translateLabel: true
+             labelChannel: applyRuleInString
+             resizeForLabel: true
+             adjust: left
+             model: applyLintRuleIn
+             keepSpaceForOSXResizeHandleH: true
+           )
+          (LinkButtonSpec
              name: 'Button1'
              layout: (LayoutFrame 0 0 -29 1 -16 1 0 1)
              activeHelpKey: browseRule
@@ -224,6 +240,46 @@
 
 !CriticsWindow methodsFor:'actions'!
 
+applyLintRuleIn
+    |rule dialog cls pkg|
+
+    rule := self ruleHolder value.
+    rule isNil ifTrue:[^ self].
+
+    cls := codeView textView editedClass.
+    cls notNil ifTrue:[
+        pkg := cls package
+    ].    
+    dialog := Tools::SearchDialog new
+        currentClass:cls;
+        currentPackage:pkg;
+        setupToAskForMethodSearchTitle:(resources string:'Apply rule in:')
+        forBrowser:nil
+        searchWhat:nil searchArea:#everywhere
+        withCaseIgnore:false withMatch:false
+        withMethodList:false
+        allowFind:false allowBuffer:false allowBrowser:true
+        withTextEntry:false.
+
+    [:restart|
+        dialog askThenDo:[
+            |classes methods keepResultList browser|
+
+            classes := dialog classesToSearch.
+            "/ methods := dialog methodsToSearch.
+            browser := Tools::NewSystemBrowser new.
+            browser allButOpen.
+            browser
+                smalllintRun:ruleHolder value
+                onEnvironment:(ClassEnvironment new
+                                classes:classes;
+                                label:'Lint on more classes').
+            browser openWindow.                
+        ].    
+    ] valueWithRestart.
+    self hide.
+!
+
 browseLintRule
     self browseLintRule:self ruleHolder value
 !
@@ -272,6 +328,10 @@
 
 !CriticsWindow methodsFor:'aspects'!
 
+applyRuleInString
+    ^ 'Apply this Rule In...' asActionLinkTo:[ self applyLintRuleIn ]
+!
+
 closeIcon
     ^ ToolbarIconLibrary removeTab16x16Icon
 !