#FEATURE by cg cvs_MAIN
authorClaus Gittinger <cg@exept.de>
Thu, 12 Dec 2019 18:35:03 +0100
branchcvs_MAIN
changeset 1117 80a909e9841c
parent 1115 2182c6e411dc
child 1118 b1618f481968
#FEATURE by cg class: SmallSense::CriticsWindow class definition added: #annotationLineNr #annotationLineNr: #processOutsideButtonEventWhileModal: #service #service: changed: #processEvent: class: SmallSense::CriticsWindow class added: #documentation #examples
SmallSense__CriticsWindow.st
--- a/SmallSense__CriticsWindow.st	Tue Dec 10 14:59:54 2019 +0100
+++ b/SmallSense__CriticsWindow.st	Thu Dec 12 18:35:03 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
 Copyright (C) 2013-2014 Jan Vrany
@@ -22,7 +24,7 @@
 
 SimpleDialog subclass:#CriticsWindow
 	instanceVariableNames:'ruleHolder ruleRationaleAndFixesHTMLHolder rationalView fixer
-		entered codeView closeOnLeave'
+		entered codeView closeOnLeave service annotationLineNr'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SmallSense-Core-Interface'
@@ -49,6 +51,58 @@
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 "
+!
+
+documentation
+"
+    documentation to be added.
+
+    class:
+        <a short class summary here, describing what instances represent>
+
+    responsibilities:    
+        <describing what my main role is>
+
+    collaborators:    
+        <describing with whom and how I talk to>
+
+    API:
+        <public api and main messages>
+        
+    example:
+        <a one-line examples on how to use - can also be in a separate example method>
+
+    implementation:
+        <implementation points>
+
+    [author:]
+        cg
+
+    [instance variables:]
+
+    [class variables:]
+
+    [see also:]
+
+"
+!
+
+examples
+"
+ Notice that everything between [exBegin] and [exEnd] is extracted by the html-doc generator
+ to create nicely formatted and clickable executable examples in the generated html-doc.
+ (see the browser's class-documentation menu items for more)
+
+ opening the application:
+                                                        [exBegin]
+    SmallSense::CriticsWindow open
+                                                        [exEnd]
+
+ opening the application on some model:
+                                                        [exBegin]
+    SmallSense::CriticsWindow openOn:aModel
+                                                        [exEnd]
+"
 ! !
 
 !CriticsWindow class methodsFor:'help specs'!
@@ -196,6 +250,18 @@
 
 !CriticsWindow methodsFor:'accessing'!
 
+annotationLineNr
+    "the lineNr of my annotation in the gutter"
+
+    ^ annotationLineNr
+!
+
+annotationLineNr:anInteger
+    "the lineNr of my annotation in the gutter"
+
+    annotationLineNr := anInteger.
+!
+
 closeOnLeave
     "set if used as a flyBy tooltip, which should close automatically.
      false, if used as a modal dialog, which needs explicit close.
@@ -236,6 +302,18 @@
     ^self ruleHolder value: anRBLintRule
 
     "Created: / 30-01-2012 / 21:45:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+service
+    "the (SmallLint-) service which opened me"
+
+    ^ service
+!
+
+service:aSmallLintService
+    "the service which opened me"
+
+    service := aSmallLintService.
 ! !
 
 !CriticsWindow methodsFor:'actions'!
@@ -578,29 +656,42 @@
 !CriticsWindow methodsFor:'event processing'!
 
 processEvent: anEvent
+    "because I am a modal popup, I will get events for all windows.
+     Return true if handled, false if not."
+
+    |v|
+
     "/ always stay on top
     (anEvent isPointerEnterLeaveEvent
-    or:[ anEvent isFocusEvent
-    or:[ anEvent view notNil and:[ anEvent view isComponentOf:codeView topView ]]]) ifTrue:[
-	self window raise.
+      or:[ anEvent isFocusEvent
+      or:[ (v := anEvent view) notNil and:[ v isComponentOf:codeView topView ]]]
+    ) ifTrue:[
+        self window raise.
+    ].
+
+    anEvent isButtonPressEvent ifTrue:[
+        anEvent view == codeView gutterView ifTrue:[
+            self halt.
+            ^ true
+        ].
     ].
 
     anEvent isKeyReleaseEvent ifTrue:[
-	anEvent key == #Escape ifTrue:[
-	    self closeRequest. "/ closeDownViews.
-	    ^true.
-	].
+        anEvent key == #Escape ifTrue:[
+            self closeRequest. "/ closeDownViews.
+            ^ true.
+        ].
     ].
 
     "/ cg: if this is a modal dialog - do not exit on leave.
     "/ if used as a flyBy, set the closeOnLeave flag.
     self closeOnLeave ifTrue:[
-	anEvent isPointerLeaveEvent ifTrue:[
-	    anEvent view == self window ifTrue:[
-		self closeRequest. "/ closeDownViews.
-		^true.
-	    ]
-	].
+        anEvent isPointerLeaveEvent ifTrue:[
+            anEvent view == self window ifTrue:[
+                self closeRequest. "/ closeDownViews.
+                ^true.
+            ]
+        ].
     ].
 
     ^false
@@ -608,6 +699,24 @@
     "Created: / 16-02-2012 / 14:09:33 / Jan Vrany"
     "Modified (format): / 31-03-2014 / 16:53:41 / Jan Vrany"
     "Modified (comment): / 18-03-2017 / 14:26:11 / cg"
+!
+
+processOutsideButtonEventWhileModal:anEvent
+    |lineNr|
+
+    anEvent view == codeView gutterView ifTrue:[
+        lineNr := codeView yVisibleToLineNr:anEvent y.
+        lineNr notNil ifTrue:[
+            lineNr == annotationLineNr ifTrue:[
+                "/ clicked on my annotation - close me
+                self hide.
+            ] ifFalse:[
+                "/ close me and open another (by telling my service)
+            ].
+        ].
+        ^ true
+    ].
+    ^ false
 ! !
 
 !CriticsWindow methodsFor:'hooks'!
@@ -667,3 +776,4 @@
 version_SVN
     ^ '$Id$'
 ! !
+