Settings dialog refactored
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 13 Jan 2015 09:46:33 +0000
changeset 371 dc7cb10ae079
parent 315 0a4845a0c211
child 372 84d4383f002e
child 374 e65bd2bf892a
Settings dialog refactored * Layout widgets in a more structured way. * Added info text about swizzling.
Make.proto
SmallSense__SettingsAppl.st
smallsense.rc
stx_goodies_smallsense.st
--- a/Make.proto	Mon Dec 15 20:46:27 2014 +0000
+++ b/Make.proto	Tue Jan 13 09:46:33 2015 +0000
@@ -143,7 +143,7 @@
 
 
 # build all packages containing referenced classes for this package
-# they are nor needed to compile the package
+# they are not needed to compile the package (but later, to load it)
 references:
 
 
--- a/SmallSense__SettingsAppl.st	Mon Dec 15 20:46:27 2014 +0000
+++ b/SmallSense__SettingsAppl.st	Tue Jan 13 09:46:33 2015 +0000
@@ -21,9 +21,11 @@
 "{ NameSpace: SmallSense }"
 
 AbstractSettingsApplication subclass:#SettingsAppl
-	instanceVariableNames:'smallSenseBackgroundTypingEnabled smallSenseBackgroundLintEnabled
-		smallSenseEnabled smallSenseElectricEditSupportEnabled
-		smallSenseCompleteIfUnambiguous smallSenseCompletionEnabled'
+	instanceVariableNames:'smallSenseEnabled smallSenseEnabledAndMethodsSwizzledHolder
+		smallSenseBackgroundTypingEnabled smallSenseBackgroundLintEnabled
+		smallSenseElectricEditSupportEnabled
+		smallSenseCompleteIfUnambiguous smallSenseCompletionEnabled
+		smallSenseSwizzledInfoHolder'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SmallSense-Core-Interface'
@@ -104,7 +106,8 @@
 !SettingsAppl class methodsFor:'interface specs'!
 
 windowSpec
-    "This resource specification was automatically generated by the UIPainter of ST/X."
+    "This resource specification was automatically generated
+     by the UIPainter of ST/X."
 
     "Do not manually edit this!! If it is corrupted,
      the UIPainter may not be able to read the specification."
@@ -115,19 +118,19 @@
      SmallSense::SettingsAppl open
     "
 
-
+    <resource: #canvas>
 
-    ^
+    ^ 
     #(FullSpec
        name: windowSpec
-       window:
+       window: 
       (WindowSpec
          label: 'SmallSense Settings'
          name: 'SmallSense Settings'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 536 651)
        )
-       component:
+       component: 
       (SpecCollection
          collection: (
           (CheckBoxSpec
@@ -138,20 +141,49 @@
              model: smallSenseEnabled
              translateLabel: true
            )
+          (LabelSpec
+             label: 'Methods not swizzled, some features may not be available'
+             name: 'SwizzlingInfo'
+             layout: (LayoutFrame 23 0 30 0 0 1 55 0)
+             visibilityChannel: hasMethodsToSwizzle
+             translateLabel: true
+             labelChannel: smallSenseSwizzledInfoHolder
+             adjust: left
+           )
+          (LinkButtonSpec
+             label: 'What''s this?'
+             name: 'Button1'
+             layout: (LayoutFrame -100 1 30 0 0 1 55 0)
+             visibilityChannel: hasMethodsToSwizzle
+             foregroundColor: (Color 0.0 0.0 100.0)
+             translateLabel: true
+             model: smallSenseSwizzlingDocumentationOpen
+           )
           (DividerSpec
              name: 'Separator'
-             layout: (LayoutFrame 5 0 30 0 -5 1 34 0)
+             layout: (LayoutFrame 5 0 56 0 -5 1 60 0)
            )
           (VerticalPanelViewSpec
              name: 'Panel'
-             layout: (LayoutFrame 0 0 37 0 0 1 0 1)
+             layout: (LayoutFrame 5 0 61 0 -5 1 26 1)
              horizontalLayout: fit
              verticalLayout: top
              horizontalSpace: 3
              verticalSpace: 3
-             component:
+             component: 
             (SpecCollection
                collection: (
+                (ViewSpec
+                   name: 'Spacer1'
+                   extent: (Point 526 15)
+                 )
+                (LabelSpec
+                   label: 'Code Editor'
+                   name: 'Label1'
+                   translateLabel: true
+                   adjust: left
+                   extent: (Point 526 22)
+                 )
                 (CheckBoxSpec
                    label: 'Enable Code Analysis (Lint)'
                    name: 'LintEnabled'
@@ -159,16 +191,16 @@
                    enableChannel: smallSenseEnabled
                    model: smallSenseBackgroundLintEnabled
                    translateLabel: true
-                   extent: (Point 536 22)
+                   extent: (Point 526 22)
                  )
                 (CheckBoxSpec
                    label: 'Enable Background Type Inferencer'
                    name: 'CheckBox2'
                    activeHelpKey: smallSenseBackgroundTypingEnabled
-                   enableChannel: smallSenseEnabled
+                   enableChannel: smallSenseEnabledAndMethodsSwizzledHolder
                    model: smallSenseBackgroundTypingEnabled
                    translateLabel: true
-                   extent: (Point 536 22)
+                   extent: (Point 526 22)
                  )
                 (CheckBoxSpec
                    label: 'Enable "Electric Edit" Support'
@@ -177,34 +209,46 @@
                    enableChannel: smallSenseEnabled
                    model: smallSenseElectricEditSupportEnabled
                    translateLabel: true
-                   extent: (Point 536 22)
+                   extent: (Point 526 22)
                  )
                 (CheckBoxSpec
                    label: 'Enable Code Completion (using SmallSense Completion Engine)'
                    name: 'CheckBox4'
+                   activeHelpKey: smallSenseCompletionEnabled
                    enableChannel: smallSenseEnabled
                    model: smallSenseCompletionEnabled
-                   extent: (Point 536 22)
-                   activeHelpKey: smallSenseCompletionEnabled
+                   translateLabel: true
+                   extent: (Point 526 22)
                  )
                 (CheckBoxSpec
                    label: 'Auto-complete when Completion is Unambiguous'
                    name: 'CheckBox5'
+                   activeHelpKey: smallSenseCompleteIfUnambiguous
                    enableChannel: smallSenseEnabledAndCompletionEnabled
                    model: smallSenseCompleteIfUnambiguous
-                   extent: (Point 536 22)
-                   activeHelpKey: smallSenseCompleteIfUnambiguous
+                   translateLabel: true
+                   extent: (Point 526 22)
                  )
                 )
-
+              
              )
            )
           )
-
+        
        )
      )
 ! !
 
+!SettingsAppl methodsFor:'actions'!
+
+smallSenseSwizzlingDocumentationOpen
+    <resource: #uiCallback>
+
+   OperatingSystem openApplicationForDocument: 'https://bitbucket.org/janvrany/stx-goodies-smallsense/wiki/Swizzling.md'  operation: #open
+
+    "Modified: / 13-01-2015 / 09:28:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !SettingsAppl methodsFor:'aspects'!
 
 smallSenseBackgroundLintEnabled
@@ -283,6 +327,38 @@
     ^ BlockValue forLogical: self smallSenseEnabled and: self smallSenseCompletionEnabled
 
     "Created: / 27-02-2014 / 09:41:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+smallSenseEnabledAndMethodsSwizzledHolder
+    smallSenseEnabledAndMethodsSwizzledHolder isNil ifTrue:[
+        smallSenseEnabledAndMethodsSwizzledHolder := 
+            PluggableAdaptor on: self smallSenseEnabled getter:[ :model | model value and:[ self smallSenseSwizzled ] ]
+    ].
+    ^ smallSenseEnabledAndMethodsSwizzledHolder.
+
+    "Created: / 13-01-2015 / 09:44:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+smallSenseSwizzled
+    ^ (Smalltalk at: #stx_goodies_smallsense) swizzled
+
+    "Created: / 12-01-2015 / 07:25:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+smallSenseSwizzledInfoHolder
+    smallSenseSwizzledInfoHolder isNil ifTrue:[ 
+        smallSenseSwizzledInfoHolder := ValueHolder new.
+        (Smalltalk at: #stx_goodies_smallsense) swizzled ifTrue:[ 
+            smallSenseSwizzledInfoHolder value:
+                ((resources string: 'Methods swizzled.') asText allBold colorizeAllWith: Color green darker).
+        ] ifFalse:[ 
+            smallSenseSwizzledInfoHolder value:
+                (resources string: 'Methods not swizzled, some features may not be available.')
+        ].
+    ].
+    ^ smallSenseSwizzledInfoHolder
+
+    "Created: / 12-01-2015 / 07:20:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SettingsAppl methodsFor:'protocol'!
@@ -326,6 +402,23 @@
 
 !SettingsAppl methodsFor:'queries'!
 
+hasMethodsToSwizzle
+    "Return true, if this SmallSense version has anything to swizzle"
+
+    ^ (Smalltalk at: #stx_goodies_smallsense) extensionMethods
+        anySatisfy: [ :m | (m annotationAt: #swizzle:) notNil or:[(m annotationAt: #swizzle:checksum:) notNil ] ]
+
+    "
+    SmallSense::SettingsAppl basicNew hasMethodsToSwizzle
+
+    (Smalltalk at: #stx_goodies_smallsense) extensionMethods
+        select: [ :m | (m annotationAt: #swizzle:) notNil or:[(m annotationAt: #swizzle:checksum:) notNil ] ]
+      
+    "
+
+    "Created: / 13-01-2015 / 09:33:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 hasUnsavedChanges
     ^ self
         hasChangedAspectIn: self basicAspects
--- a/smallsense.rc	Mon Dec 15 20:46:27 2014 +0000
+++ b/smallsense.rc	Tue Jan 13 09:46:33 2015 +0000
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Jan Vrany 2013-2014\0"
       VALUE "ProductName", "SmallSense\0"
       VALUE "ProductVersion", "6.2.5.0\0"
-      VALUE "ProductDate", "Wed, 03 Dec 2014 10:29:19 GMT\0"
+      VALUE "ProductDate", "Mon, 12 Jan 2015 09:42:27 GMT\0"
     END
 
   END
--- a/stx_goodies_smallsense.st	Mon Dec 15 20:46:27 2014 +0000
+++ b/stx_goodies_smallsense.st	Tue Jan 13 09:46:33 2015 +0000
@@ -18,6 +18,8 @@
 "
 "{ Package: 'stx:goodies/smallsense' }"
 
+"{ NameSpace: Smalltalk }"
+
 LibraryDefinition subclass:#stx_goodies_smallsense
 	instanceVariableNames:''
 	classVariableNames:'Swizzled'
@@ -491,6 +493,14 @@
 
     "Created: / 10-05-2014 / 00:23:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 07-10-2014 / 15:09:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+swizzled
+    "Return true, if methods has been swizled"
+
+    ^ Swizzled == true
+
+    "Created: / 12-01-2015 / 06:53:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !stx_goodies_smallsense class methodsFor:'documentation'!