#REFACTORING by exept
authorClaus Gittinger <cg@exept.de>
Mon, 14 Oct 2019 14:48:08 +0200
changeset 3784 f6654cc10071
parent 3783 e935b92253c9
child 3785 eb827930328b
#REFACTORING by exept class: ShowMeHowItWorks class definition added: #do:withUI: #prepare #verify: changed: #componentNamed: #do: class: ShowMeHowItWorks class added: #do:withUI: changed: #do:
ShowMeHowItWorks.st
--- a/ShowMeHowItWorks.st	Mon Oct 14 11:42:39 2019 +0200
+++ b/ShowMeHowItWorks.st	Mon Oct 14 14:48:08 2019 +0200
@@ -7,7 +7,7 @@
 Object subclass:#ShowMeHowItWorks
 	instanceVariableNames:'application opStream streamStack lastComponentName lastComponent
 		lastResult voice translate language verifying
-		closeApplicationWhenFinished defaultComponentWaitTime'
+		closeApplicationWhenFinished defaultComponentWaitTime ui'
 	classVariableNames:'IntroShownCount DebugMode'
 	poolDictionaries:''
 	category:'Interface-Help'
@@ -79,7 +79,7 @@
 do:specArray
     "spec contains a list of action commands (show: / moveTo: etc.)"
 
-    self new do:specArray
+    self do:specArray withUI:false
 
     "
      ShowMeHowItWorks do:
@@ -93,6 +93,26 @@
 
     "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
     "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
+!
+
+do:specArray withUI:withUIBoolean
+    "spec contains a list of action commands (show: / moveTo: etc.)"
+
+    self new do:specArray withUI:withUIBoolean
+
+    "
+     ShowMeHowItWorks 
+        do:#(
+            (language: de)
+            (show: 'üben üben üben')
+            (wait: 0.5)
+            (moveTo: NameOfComponent)
+        )
+        withUI:true
+    "
+
+    "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger"
+    "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger"
 ! !
 
 !ShowMeHowItWorks methodsFor:'accessing'!
@@ -741,7 +761,8 @@
 
     component := self findComponent:componentName.
     component isNil ifTrue:[
-        self error:'no component found for: ',componentName.
+        self error:'no component found for: ',componentName mayProceed:verifying.
+        ^ nil
     ].
     lastComponent := component.
     ^ component
@@ -1218,7 +1239,66 @@
     (wasActive := ActiveHelp isActive) ifTrue:[
         ActiveHelp stop.
     ].
+    self prepare.
 
+    "/ run pnce in verifying mode
+    [
+        self verify:specArray.
+    ] ensure:[
+        wasActive ifTrue:[ActiveHelp start].
+    ].
+
+    [
+        ActiveHelp stop.
+        [
+            Error handle:[:ex |
+                Dialog warn:(self class classResources 
+                                    stringWithCRs:'An error was encountered in the show:\\%1' 
+                                    with:ex description withCRs)
+            ] do:[
+                self doStream:(specArray readStream)
+            ].
+        ] ensure:[
+            wasActive ifTrue:[ActiveHelp start].
+        ].
+    ] fork.
+
+    "
+     ShowMeHowItWorks do:
+        #(
+            (show: 'blah blah')
+            (moveTo: NameOfComponent)
+        )    
+    "
+
+    "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
+    "Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
+!
+
+do:specArray withUI:withUIBoolean
+    "must run as a separate process;
+     otherwise - if started by the app itself -
+     no events will be processed while running"
+
+    withUIBoolean ifTrue:[
+        ui := ShowMeHowItWorksRunner openOn:self.
+    ].
+    self do:specArray
+
+    "
+     ShowMeHowItWorks 
+        do:#(
+            (show: 'blah blah')
+            (moveTo: NameOfComponent)
+        )
+        withUI:true
+    "
+
+    "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
+    "Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
+!
+
+prepare
     language isNil ifTrue:[
         self language:(Smalltalk language).
     ].
@@ -1230,43 +1310,25 @@
     closeApplicationWhenFinished := false.
     defaultComponentWaitTime isNil ifTrue:[ defaultComponentWaitTime := 1 ].
 
+    "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
+    "Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
+!
+
+verify:specArray
     "/ run in verifying mode
     verifying := true.
     [
         Error handle:[:ex |
-            Transcript showCR:'Possible error (encountered while verifying):\\%1\\Debug?' with:ex description.
+            Transcript showCR:('Possible error (encountered while verifying):\.... %1' withCRs)
+                         with:ex description withCRs.
             Display ctrlDown ifTrue:[ex reject].
         ] do:[
+            self show:' '. "/ to avoid an audible disturbance on OSX
             self doStream:(specArray readStream)
         ].
     ] ensure:[
         verifying := false.
-        wasActive ifTrue:[ActiveHelp start].
     ].
-
-    [
-        ActiveHelp stop.
-        [
-            Error handle:[:ex |
-                Dialog warn:(self class classResources stringWithCRs:'An error was encountered in the show:\\%1' with:ex description)
-            ] do:[
-                self doStream:(specArray readStream)
-            ].
-        ] ensure:[
-            wasActive ifTrue:[ActiveHelp start].
-        ].
-    ] fork.
-
-    "
-     ShowMeHowItWorks do:
-        #(
-            (show: 'bla bla')
-            (moveTo: NameOfComponent)
-        )    
-    "
-
-    "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger"
-    "Modified: / 25-07-2019 / 11:48:53 / Claus Gittinger"
 ! !
 
 !ShowMeHowItWorks methodsFor:'running - private'!