class: Tools::LintRuleSettingsApplication
authorClaus Gittinger <cg@exept.de>
Sun, 01 Mar 2015 14:52:42 +0100
changeset 15484 aa6b6dd894a2
parent 15483 7142c70e4a6b
child 15485 4b9cb0affe4d
class: Tools::LintRuleSettingsApplication added: #hasSmallSenseLoaded #hasSmallSenseNotLoaded changed:5 methods automate loading of smallsense, if required.
Tools__LintRuleSettingsApplication.st
--- a/Tools__LintRuleSettingsApplication.st	Sun Mar 01 14:52:11 2015 +0100
+++ b/Tools__LintRuleSettingsApplication.st	Sun Mar 01 14:52:42 2015 +0100
@@ -157,10 +157,11 @@
             (SpecCollection
                collection: (
                 (CheckBoxSpec
-                   label: 'Enable Lintrule Checking in Codeview (SmallSense)'
+                   label: 'Enable Lintrule Checking in Codeview (Load SmallSense Package)'
                    name: 'CheckBox1'
+                   activeHelpKey: smallSenseEnabled
+                   enableChannel: hasSmallSenseNotLoaded
                    model: smallSenseEnabledHolder
-                   activeHelpKey: smallSenseEnabled
                    translateLabel: true
                    useDefaultExtent: true
                  )
@@ -190,7 +191,7 @@
                        )
                       (VerticalPanelViewSpec
                          name: 'Buttons1'
-                         layout: (LayoutFrame -128 1 30 0 0 1 -65 0.70000000000000007)
+                         layout: (LayoutFrame -128 1 30 0 0 1 -65 0.70000000000000018)
                          horizontalLayout: fit
                          verticalLayout: top
                          horizontalSpace: 5
@@ -239,7 +240,7 @@
                        )
                       (VerticalPanelViewSpec
                          name: 'Buttons2'
-                         layout: (LayoutFrame -128 1 -64 0.70000000000000007 0 1 0 1)
+                         layout: (LayoutFrame -128 1 -64 0.70000000000000018 0 1 0 1)
                          horizontalLayout: fit
                          verticalLayout: bottom
                          horizontalSpace: 5
@@ -509,6 +510,7 @@
 smallSenseEnabledHolder
     smallSenseEnabledHolder isNil ifTrue:[
         smallSenseEnabledHolder := ValueHolder with:false.
+        smallSenseEnabledHolder onChangeSend:#updateModifiedChannel to:self
     ].
     ^ smallSenseEnabledHolder
 ! !
@@ -518,49 +520,56 @@
 basicReadSettings
     "superclass AbstractSettingsApplication says that I am responsible to implement this method"
 
+    |rbCompositeLintRuleClass|
+
     self smallSenseEnabledHolder 
-        value:(SmallSense::SmalltalkChecker notNil
+        value:((Smalltalk at:#'SmallSense::SmalltalkChecker') notNil
                and:[ UserPreferences current perform:#smallSenseEnabled ifNotUnderstood:false]).
 
-    RBCompositeLintRule isNil ifTrue:[ 
+    rbCompositeLintRuleClass := Smalltalk at:#'RBCompositeLintRule'.
+
+    rbCompositeLintRuleClass isNil ifTrue:[ 
         "/ Not loaded?
         [
             Smalltalk loadPackage: #'stx:goodies/refactoryBrowser/lint'.
         ] on: PackageLoadError do:[:ex | 
             Dialog warn: (resources string: 'SmallLint package could not be loaded!!').
             ^ self.
-        ]
+        ].
+        rbCompositeLintRuleClass := Smalltalk at:#'RBCompositeLintRule'.
     ].
 
-    RBCompositeLintRule notNil ifTrue:[
+    rbCompositeLintRuleClass notNil ifTrue:[
         self rulesetList 
             removeAll; 
-            addAll: RBCompositeLintRule rulesetsBuiltin;            
-            addAll: RBCompositeLintRule rulesetsUserDefined deepCopy
+            addAll: rbCompositeLintRuleClass rulesetsBuiltin;            
+            addAll: rbCompositeLintRuleClass rulesetsUserDefined deepCopy
     ].
 
     "Modified: / 11-11-2014 / 15:08:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 basicSaveSettings
-    | oldRulesets newRulesets toRemove toAdd |
+    | oldRulesets newRulesets toRemove toAdd rbCompositeLintRuleClass|
 
     self smallSenseEnabledHolder value ifTrue:[
         UserPreferences current addPreloadedPackage:'stx:goodies/smallsense'
     ] ifFalse:[
         UserPreferences current removePreloadedPackage:'stx:goodies/smallsense'
     ].
-    SmallSense::SmalltalkChecker notNil ifTrue:[
+    (Smalltalk at:#'SmallSense::SmalltalkChecker') notNil ifTrue:[
         UserPreferences current 
             perform:#smallSenseEnabled: with:(self smallSenseEnabledHolder value) ifNotUnderstood:[]
     ].
 
-    oldRulesets := RBCompositeLintRule rulesetsUserDefined.
+    rbCompositeLintRuleClass := Smalltalk at:#'RBCompositeLintRule'.
+
+    oldRulesets := rbCompositeLintRuleClass rulesetsUserDefined.
     newRulesets := self rulesetList reject:[:e|e isBuiltin].
 
     toAdd := OrderedCollection withAll: newRulesets.
     toRemove := Set new.
-    RBCompositeLintRule rulesetsUserDefined do:[:oldRuleset | 
+    rbCompositeLintRuleClass rulesetsUserDefined do:[:oldRuleset | 
         | newRuleset |
 
         newRuleset := newRulesets detect:[:each | each name = oldRuleset name ] ifNone: nil.
@@ -573,11 +582,19 @@
     ].
     oldRulesets removeAll:toRemove.
     oldRulesets addAll:toAdd.
-    RBCompositeLintRule rulesetsUserDefined: oldRulesets.
+    rbCompositeLintRuleClass rulesetsUserDefined: oldRulesets.
 
     "Modified: / 24-11-2014 / 11:21:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+hasSmallSenseLoaded
+   ^ (Smalltalk at:#'SmallSense::SmalltalkChecker') notNil
+!
+
+hasSmallSenseNotLoaded
+   ^ self hasSmallSenseLoaded not
+!
+
 helpFilename
     "subclasses must return the relative name of a helpFile
      in the doc/online/<language>/help directory.
@@ -593,9 +610,18 @@
 hasUnsavedChanges
     "superclass AbstractSettingsApplication says that I am responsible to implement this method"
 
-    |defaultRules currentRules firstTry|
+    |defaultRules currentRules firstTry rbCompositeLintRuleClass|
 
-    RBCompositeLintRule isNil ifTrue:[^ false].
+    self smallSenseEnabledHolder value ifTrue:[
+        UserPreferences current addPreloadedPackage:'stx:goodies/smallsense'
+    ].
+    (UserPreferences current perform:#smallSenseEnabled ifNotUnderstood:false)
+            ~= (self smallSenseEnabledHolder value) 
+    ifTrue:[
+        ^ true
+    ].
+    rbCompositeLintRuleClass := Smalltalk at:#'RBCompositeLintRule'.
+    rbCompositeLintRuleClass isNil ifTrue:[^ false].
 
     firstTry := true.
     SequenceableCollection missingClassInLiteralArrayErrorSignal handle:[:ex |
@@ -609,13 +635,14 @@
         ].
         ex reject.
     ] do:[
-        defaultRules := RBCompositeLintRule rulesetsUserDefined copyAsOrderedCollection.
+        defaultRules := rbCompositeLintRuleClass rulesetsUserDefined copyAsOrderedCollection.
         currentRules := self rulesetList copyAsOrderedCollection.
         "/ I will always add the defaultRule
-        defaultRules removeAllFoundIn:RBCompositeLintRule rulesetsBuiltin.
-        currentRules removeAllFoundIn:RBCompositeLintRule rulesetsBuiltin.
+        defaultRules removeAllFoundIn:rbCompositeLintRuleClass rulesetsBuiltin.
+        currentRules removeAllFoundIn:rbCompositeLintRuleClass rulesetsBuiltin.
         ^ defaultRules ~= currentRules
     ].
+    ^ false.
 
     "Modified: / 28-02-2013 / 10:03:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -623,11 +650,11 @@
 !LintRuleSettingsApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSettingsApplication.st,v 1.21 2015-02-28 02:09:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSettingsApplication.st,v 1.22 2015-03-01 13:52:42 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSettingsApplication.st,v 1.21 2015-02-28 02:09:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__LintRuleSettingsApplication.st,v 1.22 2015-03-01 13:52:42 cg Exp $'
 ! !