ShowMeHowItWorks.st
changeset 3859 18cd7c43d15e
parent 3855 0cc52b04a4a5
child 3860 c1824d0bfeb5
equal deleted inserted replaced
3858:236ce50a9d68 3859:18cd7c43d15e
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 2018 by eXept Software AG
     4  COPYRIGHT (c) 2018 by eXept Software AG
     3               All Rights Reserved
     5               All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   150 
   152 
   151 
   153 
   152 "
   154 "
   153 ! !
   155 ! !
   154 
   156 
       
   157 !ShowMeHowItWorks class methodsFor:'instance creation'!
       
   158 
       
   159 new
       
   160     "return an initialized instance"
       
   161 
       
   162     ^ self basicNew initialize.
       
   163 ! !
       
   164 
   155 !ShowMeHowItWorks class methodsFor:'running'!
   165 !ShowMeHowItWorks class methodsFor:'running'!
   156 
   166 
   157 application:anApplicationOrNilForAll do:specArray 
   167 application:anApplicationOrNilForAll do:specArray 
   158     "spec contains a list of action commands (show: / moveTo: etc.)"
   168     "spec contains a list of action commands (show: / moveTo: etc.)"
   159 
   169 
   163 
   173 
   164     "
   174     "
   165      ShowMeHowItWorks do:
   175      ShowMeHowItWorks do:
   166         #(
   176         #(
   167             (language: de)
   177             (language: de)
   168             (show: 'üben üben üben')
   178             (show: 'üben üben üben')
   169             (wait: 0.5)
   179             (wait: 0.5)
   170             (moveTo: NameOfComponent)
   180             (moveTo: NameOfComponent)
   171         )    
   181         )    
   172     "
   182     "
   173 
   183 
   184 
   194 
   185     "
   195     "
   186      ShowMeHowItWorks do:
   196      ShowMeHowItWorks do:
   187         #(
   197         #(
   188             (language: de)
   198             (language: de)
   189             (show: 'üben üben üben')
   199             (show: 'üben üben üben')
   190             (wait: 0.5)
   200             (wait: 0.5)
   191             (moveTo: NameOfComponent)
   201             (moveTo: NameOfComponent)
   192         )    
   202         )    
   193     "
   203     "
   194 
   204 
   203 
   213 
   204     "
   214     "
   205      ShowMeHowItWorks do:
   215      ShowMeHowItWorks do:
   206         #(
   216         #(
   207             (language: de)
   217             (language: de)
   208             (show: 'üben üben üben')
   218             (show: 'üben üben üben')
   209             (wait: 0.5)
   219             (wait: 0.5)
   210             (moveTo: NameOfComponent)
   220             (moveTo: NameOfComponent)
   211         )    
   221         )    
   212     "
   222     "
   213 
   223 
   225 
   235 
   226     "
   236     "
   227      ShowMeHowItWorks 
   237      ShowMeHowItWorks 
   228         do:#(
   238         do:#(
   229             (language: de)
   239             (language: de)
   230             (show: 'üben üben üben')
   240             (show: 'üben üben üben')
   231             (wait: 0.5)
   241             (wait: 0.5)
   232             (moveTo: NameOfComponent)
   242             (moveTo: NameOfComponent)
   233         )
   243         )
   234         withUI:true
   244         withUI:true
   235     "
   245     "
   245 
   255 
   246     "
   256     "
   247      ShowMeHowItWorks 
   257      ShowMeHowItWorks 
   248         do:#(
   258         do:#(
   249             (language: de)
   259             (language: de)
   250             (show: 'üben üben üben')
   260             (show: 'üben üben üben')
   251             (wait: 0.5)
   261             (wait: 0.5)
   252             (moveTo: NameOfComponent)
   262             (moveTo: NameOfComponent)
   253         )
   263         )
   254         withUI:true
   264         withUI:true
   255     "
   265     "
   288 
   298 
   289     (diagramEditor := lastComponent) isScrollWrapper ifTrue:[
   299     (diagramEditor := lastComponent) isScrollWrapper ifTrue:[
   290         diagramEditor := lastComponent scrolledView
   300         diagramEditor := lastComponent scrolledView
   291     ].
   301     ].
   292     pinPO := self pinPOForPin:pinName ofStep:stepName. 
   302     pinPO := self pinPOForPin:pinName ofStep:stepName. 
       
   303     pinPO isNil ifTrue:[
       
   304         self error:('No pin named "%1" for step "%2" found in diagram' bindWith:pinName with:stepName).
       
   305         ^ self.
       
   306     ].
   293 
   307 
   294     diagramEditor selection:{ pinPO }.
   308     diagramEditor selection:{ pinPO }.
   295     diagramEditor doubleClickOn:pinPO.
   309     diagramEditor doubleClickOn:pinPO.
   296     self fastMoveTo:(lastComponentName,'/','EditField').
   310     self fastMoveTo:(lastComponentName,'/','EditField').
   297     self click.
   311     self click.
   386 
   400 
   387     |newApplication|
   401     |newApplication|
   388 
   402 
   389     (newApplication := newApplicationOrName) isString ifTrue:[
   403     (newApplication := newApplicationOrName) isString ifTrue:[
   390         newApplication := self findApplication:newApplicationOrName ifMultiple:nil.
   404         newApplication := self findApplication:newApplicationOrName ifMultiple:nil.
   391         self assert: newApplication notNil.
   405         newApplication isNil ifTrue:[
       
   406             self error:('Could not find an application named "%1" (to switch to)' bindWith:newApplicationOrName).
       
   407         ].
       
   408         "/ self assert: newApplication notNil.
   392     ].
   409     ].
   393 
   410 
   394     applicationStack isNil ifTrue:[applicationStack := OrderedCollection new].
   411     applicationStack isNil ifTrue:[applicationStack := OrderedCollection new].
   395 
   412 
   396     applicationStack add:application.
   413     applicationStack add:application.
   429     count := 0.
   446     count := 0.
   430     [
   447     [
   431         Delay waitForSeconds:0.1.
   448         Delay waitForSeconds:0.1.
   432         pinPO := self pinPOForPin:pinName ofStep:stepName.
   449         pinPO := self pinPOForPin:pinName ofStep:stepName.
   433     ] doWhile:[pinPO isNil and:[ (count := count+1) < 20]].
   450     ] doWhile:[pinPO isNil and:[ (count := count+1) < 20]].
   434 
   451     pinPO isNil ifTrue:[
       
   452         self error:('No pin named "%1" for step "%2" found in diagram' bindWith:pinName with:stepName).
       
   453         ^ self.
       
   454     ].
   435     self movePointerToComponent:diagramEditor offset:(pinPO frame center).
   455     self movePointerToComponent:diagramEditor offset:(pinPO frame center).
   436     diagramEditor selection:{ pinPO }. 
   456     diagramEditor selection:{ pinPO }. 
   437 !
   457 !
   438 
   458 
   439 show:message
   459 show:message
  1110         ].
  1130         ].
  1111     ].
  1131     ].
  1112 
  1132 
  1113     (component isKindOf:NoteBookView) ifTrue:[
  1133     (component isKindOf:NoteBookView) ifTrue:[
  1114         (idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
  1134         (idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
  1115             idx := component list
  1135             idx := component tabList
  1116                     findFirst:[:eachNotebookTab| 
  1136                     findFirst:[:eachNotebookTab| 
  1117                         eachNotebookTab label string = itemsIndexOrLabelOrPattern string
  1137                         eachNotebookTab labelString string = itemsIndexOrLabelOrPattern string
  1118                         or:[ eachNotebookTab printableLabel string = itemsIndexOrLabelOrPattern string ]
  1138                         or:[ (eachNotebookTab printableLabel string = itemsIndexOrLabelOrPattern string)
  1119                     ].
  1139                         or:[ eachNotebookTab label isString not
       
  1140                              and:[eachNotebookTab label label = itemsIndexOrLabelOrPattern string ]]]
       
  1141                     ]. 
       
  1142             idx == 0 ifTrue:[
       
  1143                 self error:('No tab named "%1" found' with:itemsIndexOrLabelOrPattern string)
       
  1144             ].
  1120             "/ idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
  1145             "/ idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
  1121         ].
  1146         ].
  1122         tab := component tabAtIndex:idx.
  1147         tab := component tabAtIndex:idx.
  1123         self movePointerToComponent:component offset:(tab layout center).
  1148         self movePointerToComponent:component offset:(tab layout center).
  1124         component selection:idx.
  1149         component selection:idx.
  1909 
  1934 
  1910 click:buttonNr inComponent:viewOrMenuItem clickTime:clickTime 
  1935 click:buttonNr inComponent:viewOrMenuItem clickTime:clickTime 
  1911     "press-release in a component"
  1936     "press-release in a component"
  1912 
  1937 
  1913     self withViewAndPositionFor:viewOrMenuItem do:[:viewToClick :clickPos |
  1938     self withViewAndPositionFor:viewOrMenuItem do:[:viewToClick :clickPos |
       
  1939         |clickDone|
       
  1940 
       
  1941         clickDone := false.
  1914         Display activePointerGrab == Display rootView ifTrue:[
  1942         Display activePointerGrab == Display rootView ifTrue:[
  1915             |pos|
  1943             |pos|
  1916 
  1944 
  1917             pos := Display translatePoint:clickPos fromView:viewToClick toView:nil.
  1945             pos := Display translatePoint:clickPos fromView:viewToClick toView:nil.
  1918             OperatingSystem isOSXlike ifTrue:[
  1946             Error handle:[:ex |
  1919                 OperatingSystem 
  1947             ] do:[    
  1920                     generateMouseMoveEventX:pos x y:pos y;
  1948                 OperatingSystem isOSXlike ifTrue:[
  1921                     generateButtonEvent:buttonNr down:true x:pos x y:pos y;
  1949                     OperatingSystem 
  1922                     yourself.
  1950                         generateMouseMoveEventX:pos x y:pos y;
       
  1951                         generateButtonEvent:buttonNr down:true x:pos x y:pos y;
       
  1952                         yourself.
       
  1953                     Delay waitForSeconds:clickTime.
       
  1954                     OperatingSystem 
       
  1955                         generateButtonEvent:buttonNr down:false x:pos x y:pos y;
       
  1956                         "/ generateButtonEvent:buttonNr down:true x:pos x y:pos y;
       
  1957                         "/ generateButtonEvent:buttonNr down:false x:pos x y:pos y;
       
  1958                         yourself.
       
  1959                     ^ self.
       
  1960                 ].
       
  1961                 Display rootView simulateButtonPress:buttonNr at:pos sendDisplayEvent:true.
  1923                 Delay waitForSeconds:clickTime.
  1962                 Delay waitForSeconds:clickTime.
  1924                 OperatingSystem 
  1963                 Display rootView simulateButtonRelease:buttonNr at:pos sendDisplayEvent:true.
  1925                     generateButtonEvent:buttonNr down:false x:pos x y:pos y;
  1964                 clickDone := true.
  1926                     "/ generateButtonEvent:buttonNr down:true x:pos x y:pos y;
  1965             ].
  1927                     "/ generateButtonEvent:buttonNr down:false x:pos x y:pos y;
  1966         ].
  1928                     yourself.
  1967         clickDone ifFalse:[
  1929                 ^ self.
       
  1930             ].
       
  1931             Display rootView simulateButtonPress:buttonNr at:pos sendDisplayEvent:true.
       
  1932             Delay waitForSeconds:clickTime.
       
  1933             Display rootView simulateButtonRelease:buttonNr at:pos sendDisplayEvent:true.
       
  1934         ] ifFalse:[
       
  1935             viewToClick simulateButtonPress:buttonNr at:clickPos sendDisplayEvent:false.
  1968             viewToClick simulateButtonPress:buttonNr at:clickPos sendDisplayEvent:false.
  1936             Delay waitForSeconds:clickTime.
  1969             Delay waitForSeconds:clickTime.
  1937             viewToClick simulateButtonRelease:buttonNr at:clickPos sendDisplayEvent:false.
  1970             viewToClick simulateButtonRelease:buttonNr at:clickPos sendDisplayEvent:false.
  1938         ].
  1971         ].
  1939     ].
  1972     ].
  2183     ].
  2216     ].
  2184     where == #bottomRight ifTrue:[
  2217     where == #bottomRight ifTrue:[
  2185         ^ aComponent bottomLeft - (5 @ 5)
  2218         ^ aComponent bottomLeft - (5 @ 5)
  2186     ].
  2219     ].
  2187     self error:'where is this'
  2220     self error:'where is this'
       
  2221 ! !
       
  2222 
       
  2223 !ShowMeHowItWorks methodsFor:'initialization'!
       
  2224 
       
  2225 initialize
       
  2226     "Invoked when a new instance is created."
       
  2227 
       
  2228     "/ please change as required (and remove this comment)
       
  2229     "/ application := nil.
       
  2230     "/ opStream := nil.
       
  2231     "/ streamStack := nil.
       
  2232     "/ lastComponentName := nil.
       
  2233     "/ lastComponent := nil.
       
  2234     "/ lastResult := nil.
       
  2235     "/ voice := nil.
       
  2236     "/ translate := nil.
       
  2237     "/ language := nil.
       
  2238     verifying := false.
       
  2239     "/ closeApplicationWhenFinished := nil.
       
  2240     "/ defaultComponentWaitTime := nil.
       
  2241     "/ ui := nil.
       
  2242     "/ theShowFile := nil.
       
  2243     "/ defaultElementTimeout := nil.
       
  2244     "/ applicationStack := nil.
       
  2245     "/ pronunciations := nil.
       
  2246 
       
  2247     "/ super initialize.   -- commented since inherited method does nothing
  2188 ! !
  2248 ! !
  2189 
  2249 
  2190 !ShowMeHowItWorks methodsFor:'running'!
  2250 !ShowMeHowItWorks methodsFor:'running'!
  2191 
  2251 
  2192 do:specArray
  2252 do:specArray