SmallSense__ClassPO.st
changeset 233 fb33bd6466a4
parent 212 a2caebc602a7
parent 232 a95a378b4248
child 249 8bc64027b189
child 343 b3d22e8c0a05
--- a/SmallSense__ClassPO.st	Mon May 19 16:57:14 2014 +0100
+++ b/SmallSense__ClassPO.st	Thu May 22 16:15:30 2014 +0100
@@ -3,7 +3,7 @@
 "{ NameSpace: SmallSense }"
 
 PO subclass:#ClassPO
-	instanceVariableNames:'showPrefix'
+	instanceVariableNames:'showPrefix klass icon'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SmallSense-Core-Interface-PO'
@@ -12,50 +12,69 @@
 
 !ClassPO methodsFor:'accessing'!
 
+hint
+    | namespace |
+
+    namespace := nil.
+    showPrefix ifFalse:[
+	namespace := klass isJavaClass
+			ifTrue:[klass javaPackage]
+			ifFalse:[klass nameSpace name].
+	(namespace notNil and:[namespace ~~ #Smalltalk]) ifTrue:[
+	    ^ 'in ', namespace.
+	].
+    ].
+    ^ nil
+
+    "Created: / 20-05-2014 / 12:21:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 icon
 
-    icon ifNil:[icon := SystemBrowser iconForClass: subject].
+    icon ifNil:[icon := SystemBrowser iconForClass: klass].
     ^icon
 
     "Created: / 06-04-2011 / 23:36:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 klass
-    ^ subject
+    ^ klass
 
     "Created: / 25-08-2013 / 13:07:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-klass: klass
-    ^ subject := klass
+klass: aClass
+    ^ klass := aClass
 
     "Created: / 25-08-2013 / 13:07:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 20-05-2014 / 10:05:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-name
-
-    | nm |
+label
+    label isNil ifTrue:[
+	showPrefix ifTrue:[
+	    label := klass name.
+	    (context notNil and:[klass isJavaClass]) ifTrue:[
+		context language isJava ifTrue:[
+		    label := klass javaName
+		] ifFalse:[
+		    context language isSmalltalk ifTrue:[
+		       label := 'JAVA ' , (klass  binaryName copyReplaceAll: $/ with: Character space)
+		     ]
+		]
+	    ].
+	] ifFalse:[
+	    label := klass nameWithoutPrefix.
+	].
+    ].
 
-    showPrefix ifTrue:[
-        nm := subject name.
-        (context notNil and:[subject isJavaClass]) ifTrue:[
-            context language isJavaLike ifTrue:[
-                nm := subject javaName
-            ] ifFalse:[
-                context language isSmalltalk ifTrue:[
-                   nm := 'JAVA ' , (subject  binaryName copyReplaceAll: $/ with: Character space)
-                 ]
-            ]
-        ].
-    ] ifFalse:[
-        nm := subject nameWithoutPrefix.
-    ].
-    ^nm
+    ^label
 
-    "Created: / 26-08-2013 / 10:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 15-05-2014 / 07:28:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 20-05-2014 / 11:29:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+
+
 showPrefix
     ^ showPrefix
 !
@@ -65,23 +84,23 @@
 !
 
 stringAlreadyWritten
-    "Answers a string already written in the textview"    
+    "Answers a string already written in the textview"
 
-    subject isJavaClass ifTrue:[
-        context language isSmalltalk ifTrue:[
-            | rec |
+    klass isJavaClass ifTrue:[
+	context language isSmalltalk ifTrue:[
+	    | rec |
 
-            rec := context node .
-            [ rec isUnaryMessage ] whileTrue:[
-                rec := rec receiver.
-            ].
-            (rec isVariableNode and:['JAVA' startsWith: rec name]) ifTrue:[
-                ^ context codeView contents asString copyFrom: rec startPosition to: context node endPosition
-            ].
-        ] ifFalse:[ 
-        context language isJavaLike ifTrue:[
-             ^ context wordBeforeCursorConsisitingOfCharactersMatching:[:c | c isAlphaNumeric or:['$_.' includes: c] ]
-        ]].
+	    rec := context node .
+	    [ rec isUnaryMessage ] whileTrue:[
+		rec := rec receiver.
+	    ].
+	    (rec isVariableNode and:['JAVA' startsWith: rec name]) ifTrue:[
+		^ context codeView contents asString copyFrom: rec startPosition to: context node endPosition
+	    ].
+	] ifFalse:[
+	context language isJavaLike ifTrue:[
+	     ^ context wordBeforeCursorConsisitingOfCharactersMatching:[:c | c isAlphaNumeric or:['$_.' includes: c] ]
+	]].
     ].
     ^ super stringAlreadyWritten
 
@@ -90,31 +109,25 @@
 !
 
 stringToCompleteForLanguage: language
-    ^ (subject isJavaClass and:[language isSmalltalk]) ifTrue:[
-        'JAVA ', (subject binaryName copyReplaceAll: $/ with: Character space)
+    ^ (klass isJavaClass and:[language isSmalltalk]) ifTrue:[
+	'JAVA ', (klass binaryName copyReplaceAll: $/ with: Character space)
     ] ifFalse:[
-        super stringToCompleteForLanguage: language
+	self label
     ].
 
     "Created: / 03-10-2013 / 16:42:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 20-10-2013 / 02:35:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 20-05-2014 / 11:41:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-subject: aClass
-
-    super subject: aClass.
-
-    "Created: / 06-04-2011 / 21:02:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 03-10-2013 / 16:30:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
+ !
 
 !ClassPO methodsFor:'converting'!
 
 asString
-    ^subject isJavaClass ifTrue:[
-        subject javaName
+    ^klass isJavaClass ifTrue:[
+	klass javaName
     ] ifFalse:[
-        subject name
+	klass name
     ].
 
     "Created: / 04-04-2012 / 13:00:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -123,40 +136,9 @@
 
 !ClassPO methodsFor:'displaying'!
 
-displayLabel:aLabel h:lH on:aGC x:x y:y h:h
-    | namespace y0 lw cnw fg |
 
-    super displayLabel:aLabel h:lH on:aGC x:x y:y h:h.
-
-    showPrefix ifFalse:[
-        namespace := subject isJavaClass 
-                        ifFalse:[subject  nameSpace name]
-                        ifTrue:[subject javaPackage].
-        (namespace notNil and:[namespace ~~ #Smalltalk]) ifTrue:[
-            namespace := 'in ', namespace.
-            lw :=  x + IconWidth + (aLabel widthOn: aGC).
-            y0 := y - (lH + 1 - h // 2).
-            y0 := y0 + (namespace ascentOn:aGC). 
-            cnw := aGC widthOfString: namespace.
 
-            (aGC width > (lw + cnw + 5)) ifTrue:[
-                fg := aGC paint.
-                aGC paint: (Color gray: 40).
-                namespace displayOn:aGC x: aGC width - cnw - 5 y:y0.
-                aGC paint: fg.
-            ]
-        ]
-    ]
-
-    "Created: / 18-09-2013 / 00:17:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-displayString
-    ^ self name
-
-    "Created: / 20-04-2012 / 18:19:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 26-08-2013 / 10:27:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
+ !
 
 !ClassPO methodsFor:'initialization'!
 
@@ -166,10 +148,18 @@
     "/ please change as required (and remove this comment)
     "/ showPrefix := nil.
 
-    super initialize.  
+    super initialize.
     showPrefix := false.
 
     "Modified: / 20-10-2013 / 02:38:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+initializeWithClass: aClass
+
+    klass := aClass.
+    showPrefix := false.
+
+    "Created: / 20-05-2014 / 09:56:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ClassPO methodsFor:'testing'!
@@ -188,4 +178,3 @@
 version_SVN
     ^ '$Id: SmallSense__ClassPO.st,v 1.2 2014/02/12 14:49:29 sr Exp $'
 ! !
-