Few changes in SmallLint Critics Window
authorClaus Gittinger
Thu, 04 Dec 2014 09:14:28 +0000
changeset 312 ce4e697a363c
parent 309 ff6d19b5d0df
child 313 a636cee89de4
Few changes in SmallLint Critics Window * moved HTML generation out of SmallSenseQuickFixer * made CriticsWindow a dialog instead of popup (hack because of some buggy window managers)
SmallSense__CriticsWindow.st
SmallSense__SmalltalkLintService.st
SmallSense__SmalltalkQuickFixer.st
--- a/SmallSense__CriticsWindow.st	Fri Nov 28 16:05:43 2014 +0000
+++ b/SmallSense__CriticsWindow.st	Thu Dec 04 09:14:28 2014 +0000
@@ -16,6 +16,8 @@
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 "
+'From Smalltalk/X, Version:6.2.5.0 on 03-12-2014 at 23:46:57'                   !
+
 "{ Package: 'stx:goodies/smallsense' }"
 
 "{ NameSpace: SmallSense }"
@@ -69,7 +71,7 @@
     ^ super flyByHelpSpec addPairsFrom:#(
 
 #disableRule
-'Disable this rule in the future'
+'Disable this rule in the future\(for the rest of this session, unless you save the ruleset)'
 
 #browseRule
 'Open a browser on the rule'
@@ -92,21 +94,21 @@
      SmallSense::CriticsWindow open
     "
 
-
+    <resource: #canvas>
 
-    ^
+    ^ 
     #(FullSpec
        name: windowSpec
-       window:
+       window: 
       (WindowSpec
          label: 'SmalllintRuleDetail'
          name: 'SmalllintRuleDetail'
          min: (Point 10 10)
-         bounds: (Rectangle 0 0 472 308)
+         bounds: (Rectangle 0 0 563 384)
          backgroundColor: (Color 100.0 100.0 75.0)
          forceRecursiveBackgroundOfDefaultBackground: true
        )
-       component:
+       component: 
       (SpecCollection
          collection: (
           (ActionButtonSpec
@@ -120,17 +122,31 @@
            )
           (HTMLViewSpec
              name: 'Rationale'
-             layout: (LayoutFrame 0 0 20 0 -20 1 -60 1)
+             layout: (LayoutFrame 0 0 20 0 0 1 -65 1)
              level: 0
              visibilityChannel: rationaleVisibleHolder
              hasHorizontalScrollBar: true
              hasVerticalScrollBar: true
+             miniScrollerHorizontal: true
+             miniScrollerVertical: true
              htmlText: ruleRationaleAndFixesHTMLHolder
              postBuildCallback: setupHTMLView:
            )
           (LinkButtonSpec
+             label: 'Disable this Rule'
+             name: 'Button3'
+             layout: (LayoutFrame -1 0 -59 1 -16 1 -30 1)
+             activeHelpKey: disableRule
+             level: 0
+             translateLabel: true
+             labelChannel: disableRuleString
+             adjust: left
+             model: disableLintRule
+             keepSpaceForOSXResizeHandleH: true
+           )
+          (LinkButtonSpec
              name: 'Button1'
-             layout: (LayoutFrame -1 0 -59 1 -31 1 -30 1)
+             layout: (LayoutFrame 0 0 -29 1 -16 1 0 1)
              activeHelpKey: browseRule
              level: 0
              translateLabel: true
@@ -139,20 +155,8 @@
              model: browseLintRule
              keepSpaceForOSXResizeHandleH: true
            )
-          (LinkButtonSpec
-             label: 'Disable this Rule'
-             name: 'Button3'
-             layout: (LayoutFrame 0 0 -29 1 -30 1 0 1)
-             activeHelpKey: disableRule
-             level: 0
-             translateLabel: true
-             labelChannel: disableRuleString
-             adjust: left
-             model: disableLintRule
-             keepSpaceForOSXResizeHandleH: true
-           )
           )
-
+        
        )
      )
 ! !
@@ -223,17 +227,14 @@
 !CriticsWindow methodsFor:'actions'!
 
 browseLintRule
-    |rule ruleClass sel|
+    |rule ruleClass|
 
     rule := self ruleHolder value.
     rule isNil ifTrue:[^ self].
     ruleClass := rule class.
-    (ruleClass implements:#rationale) ifTrue:[
-        sel := #rationale.
-    ].
     self close.
     UserPreferences current systemBrowserClass
-       openInClass:ruleClass selector:sel.
+       openInClass:ruleClass selector:#rationale
 
     "Created: / 07-09-2011 / 04:09:38 / cg"
     "Modified: / 31-01-2012 / 11:30:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -250,9 +251,9 @@
 !
 
 doQuickFix: quickFixNo
-
     self closeDownViews.
-    [ fixer performFix: quickFixNo ] fork.
+    "/ cg: why fork here?
+    "[" fixer performFix: quickFixNo "] fork".
 
     "Created: / 16-02-2012 / 14:19:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -266,8 +267,8 @@
 disableRuleString
 
 
-    ^ 'Disable this Rule'
-        colorizeAllWith: Color blue;
+    ^ ('Disable this Rule'
+        colorizeAllWith: Color blue)
         actionForAll:[ self disableLintRule]
 !
 
@@ -310,8 +311,8 @@
         holder := BlockValue
                     with:[:h |
                         "/ h displayString , ' ' , (('[browse]' actionForAll:[ self browseLintRule]) colorizeAllWith:Color blue)
-                        ('Browse "',h name,'"-Rule (',h class name,')' "displayString")
-                            colorizeAllWith: Color blue;
+                        (('Browse Rule Class (',h class name,')' "displayString")
+                            colorizeAllWith: Color blue)
                             actionForAll:[ self browseLintRule]
                     ]
                     argument: self ruleHolder.
@@ -336,6 +337,30 @@
 
 !CriticsWindow methodsFor:'change & update'!
 
+printHTMLForFixesOn:aStream
+    "/ fixer printHtmlOn: s.
+
+    |fixes|
+
+    (fixes := fixer fixes) isEmptyOrNil ifTrue:[ ^ self ].
+
+    aStream nextPutAll: '<p>'.
+    fixes size > 1 ifTrue:[
+        aStream nextPutAll: '<br>'.
+        aStream nextPutLine: 'Possible fixes:'.
+    ].
+    aStream nextPutLine:'<ul indent="0">'.
+    fixes withIndexDo:[:fix :index|
+        aStream
+            nextPutAll:'<li><a action="doit: self doQuickFix:';
+            nextPutAll: index printString;
+            nextPutAll:'">';
+            nextPutAll: fix label;
+            nextPutAll:'</a></li>'.
+    ].
+    aStream nextPutLine:'</ul>'.
+!
+
 update:something with:aParameter from:changedObject
     "Invoked when an object that I depend upon sends a change notification."
 
@@ -362,7 +387,8 @@
                         nextPutAll: rule name; 
                         nextPutAll:'<P>';  
                         nextPutLine: rule rationale.
-                    fixer printHtmlOn: s.
+                    self printHTMLForFixesOn:s.
+                    "/ fixer printHtmlOn: s.
                 ]
     ].
 
@@ -409,10 +435,7 @@
 
     entered := false.
     self updateRationaleAndFixes.
-    aBuilder window
-        "windowGroup: codeView windowGroup;"
-        bePopUpView;
-        beSlave.
+    aBuilder window beSlave.
 
     "Created: / 03-04-2011 / 10:45:10 / Jan Vrany "
     "Modified: / 16-02-2012 / 14:14:07 / Jan Vrany "
--- a/SmallSense__SmalltalkLintService.st	Fri Nov 28 16:05:43 2014 +0000
+++ b/SmallSense__SmalltalkLintService.st	Thu Dec 04 09:14:28 2014 +0000
@@ -9,6 +9,8 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
+'From Smalltalk/X, Version:6.2.5.0 on 03-12-2014 at 16:00:02'                   !
+
 "{ Package: 'stx:goodies/smallsense' }"
 
 "{ NameSpace: SmallSense }"
@@ -346,11 +348,14 @@
     ann := self annotationAtLine: lineNo.
     ann isNil ifTrue:[ ^ false ].
 
+    codeView topView beMaster.
+
     CriticsWindow new
         rule: ann rule;
         codeView: codeView;
         allButOpen;
-        openWindowAt: (Screen current pointerPosition - (20@20)).
+        "/ openWindowAt: (Screen current pointerPosition - (20@20)).
+        openWindowAs:#popUp at: (Screen current pointerPosition - (20@20)).
 
     ^true
 
@@ -367,7 +372,7 @@
 
     | lang annotation |
 
-    ((lang := codeView language) isNil or:[lang isSmalltalk not]) ifTrue:[ ^ self ].
+    "/ ((lang := codeView language) isNil or:[lang isSmalltalk not]) ifTrue:[ ^ self ].
 
     annotation :=  self annotationAtLine: lineNo.
     annotation notNil ifTrue:[
--- a/SmallSense__SmalltalkQuickFixer.st	Fri Nov 28 16:05:43 2014 +0000
+++ b/SmallSense__SmalltalkQuickFixer.st	Thu Dec 04 09:14:28 2014 +0000
@@ -16,6 +16,8 @@
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 "
+'From Smalltalk/X, Version:6.2.5.0 on 03-12-2014 at 23:46:45'                   !
+
 "{ Package: 'stx:goodies/smallsense' }"
 
 "{ NameSpace: SmallSense }"
@@ -73,6 +75,12 @@
     "Created: / 17-02-2012 / 00:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!SmalltalkQuickFixer methodsFor:'accessing'!
+
+fixes
+    ^ fixes
+! !
+
 !SmalltalkQuickFixer methodsFor:'adding'!
 
 fix
@@ -113,29 +121,6 @@
     "Created: / 16-02-2012 / 14:48:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
-!SmalltalkQuickFixer methodsFor:'printing & storing'!
-
-printHtmlOn: html
-
-    fixes isEmptyOrNil ifTrue:[ ^ self ].
-    fixes size > 1 ifTrue:[
-        html nextPutAll: '<br>'.
-        html nextPutLine: 'Possible fixes'.
-    ].
-    html nextPutLine:'<ul>'.
-    fixes withIndexDo:[:fix :index|
-        html 
-            nextPutAll:'<li><a action="doit: self doQuickFix:';
-            nextPutAll: index printString;
-            nextPutAll:'">';
-            nextPutAll: fix label;
-            nextPutAll:'</a></li>'.
-    ].
-    html nextPutLine:'</ul>'.
-
-    "Created: / 01-02-2012 / 12:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
 !SmalltalkQuickFixer methodsFor:'utilities'!
 
 apply: changes