ShowMeHowItWorks.st
changeset 3803 34ea88ec4dc4
parent 3801 e45e18e26a7d
child 3804 2355596aec0a
equal deleted inserted replaced
3802:908abf2676e7 3803:34ea88ec4dc4
     6 
     6 
     7 Object subclass:#ShowMeHowItWorks
     7 Object subclass:#ShowMeHowItWorks
     8 	instanceVariableNames:'application opStream streamStack lastComponentName lastComponent
     8 	instanceVariableNames:'application opStream streamStack lastComponentName lastComponent
     9 		lastResult voice translate language verifying
     9 		lastResult voice translate language verifying
    10 		closeApplicationWhenFinished defaultComponentWaitTime ui
    10 		closeApplicationWhenFinished defaultComponentWaitTime ui
    11 		theShowFile defaultElementTimeout'
    11 		theShowFile defaultElementTimeout applicationStack'
    12 	classVariableNames:'IntroShownCount DebugMode StartLabel'
    12 	classVariableNames:'IntroShownCount DebugMode StartLabel'
    13 	poolDictionaries:''
    13 	poolDictionaries:''
    14 	category:'Interface-Help'
    14 	category:'Interface-Help'
    15 !
    15 !
    16 
    16 
   218 ! !
   218 ! !
   219 
   219 
   220 !ShowMeHowItWorks methodsFor:'accessing'!
   220 !ShowMeHowItWorks methodsFor:'accessing'!
   221 
   221 
   222 application:anApplication
   222 application:anApplication
   223     "if set, only that application is presented (widget search is limtied to that one)"
   223     "if set, only that application is presented (widget search is limited to that one)"
   224 
   224 
   225     application := anApplication.
   225     application := anApplication.
   226 !
   226 !
   227 
   227 
   228 setLanguage:lang
   228 setLanguage:lang
   313 
   313 
   314     "Created: / 19-07-2019 / 15:03:17 / Claus Gittinger"
   314     "Created: / 19-07-2019 / 15:03:17 / Claus Gittinger"
   315     "Modified: / 19-07-2019 / 16:13:33 / Claus Gittinger"
   315     "Modified: / 19-07-2019 / 16:13:33 / Claus Gittinger"
   316 !
   316 !
   317 
   317 
       
   318 popApplication
       
   319     <action>
       
   320 
       
   321     "go back to the previous app"
       
   322 
       
   323     application := applicationStack removeLast.
       
   324 !
       
   325 
       
   326 pushApplication:newApplicationOrName
       
   327     <action>
       
   328 
       
   329     "goto another app, remembering where we were before"
       
   330 
       
   331     |newApplication|
       
   332 
       
   333     (newApplication := newApplicationOrName) isString ifTrue:[
       
   334         newApplication := self findApplication:newApplicationOrName ifMultiple:nil.
       
   335         self assert: newApplication notNil.
       
   336     ].
       
   337 
       
   338     applicationStack isNil ifTrue:[applicationStack := OrderedCollection new].
       
   339 
       
   340     applicationStack add:application.
       
   341     self application:newApplication.
       
   342 !
       
   343 
   318 raise:what
   344 raise:what
   319     <action>
   345     <action>
   320 
   346 
   321     verifying ifTrue:[^ self].
   347     verifying ifTrue:[^ self].
   322 
   348 
   415     <action>
   441     <action>
   416     
   442     
   417     |xLatedMessage messageView talkDone|
   443     |xLatedMessage messageView talkDone|
   418 
   444 
   419     xLatedMessage := (translate and:[application notNil]) 
   445     xLatedMessage := (translate and:[application notNil]) 
   420                             ifTrue:[application resources string:message]
   446                             ifTrue:[application resources stringWithCRs:message]
   421                             ifFalse:[message].
   447                             ifFalse:[message withCRs].
   422     
   448     
   423     self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]).
   449     self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]).
   424 
   450 
   425     messageView := ActiveHelpView for:xLatedMessage.
   451     messageView := ActiveHelpView for:xLatedMessage.
   426     "/ messageView shapeStyle:#cartoon.
   452     "/ messageView shapeStyle:#cartoon.
   870 !
   896 !
   871 
   897 
   872 select:itemsIndexOrLabelOrPattern
   898 select:itemsIndexOrLabelOrPattern
   873     "select an item by label,
   899     "select an item by label,
   874      allowed after moving to:
   900      allowed after moving to:
   875         aComboBox
   901         a ComboBox
   876         aSelectionInListView
   902         a SelectionInListView
       
   903         a NoteBook
       
   904         a DSVColumnView
   877     "    
   905     "    
   878 
   906 
   879     <action>
   907     <action>
   880 
   908 
   881     |idx component|
   909     |idx component yPos tab|
   882 
   910 
   883     verifying ifTrue:[^ self].
   911     verifying ifTrue:[^ self].
   884 
   912 
   885     ((component := lastComponent) isKindOf:ScrollableView) ifTrue:[
   913     ((component := lastComponent) isKindOf:ScrollableView) ifTrue:[
   886         component := component scrolledView.
   914         component := component scrolledView.
   909             component shownMenu hide.
   937             component shownMenu hide.
   910         ].    
   938         ].    
   911         ^ self
   939         ^ self
   912     ].    
   940     ].    
   913     (component isKindOf:HierarchicalListView) ifTrue:[
   941     (component isKindOf:HierarchicalListView) ifTrue:[
   914         |idx yPos|
       
   915 
       
   916         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   942         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   917             idx := itemsIndexOrLabelOrPattern
   943             idx := itemsIndexOrLabelOrPattern
   918         ] ifFalse:[
   944         ] ifFalse:[
   919             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
   945             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
   920                 idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
   946                 idx := component indexOfElementForWhich:[:el | itemsIndexOrLabelOrPattern match:el label string].
   932         component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
   958         component simulateButtonRelease:1 at:(0 @ (yPos + 3)) sendDisplayEvent:false.
   933         "/ component selection:idx.
   959         "/ component selection:idx.
   934         ^ self
   960         ^ self
   935     ].
   961     ].
   936     (component isKindOf:SelectionInListModelView) ifTrue:[
   962     (component isKindOf:SelectionInListModelView) ifTrue:[
   937         |idx yPos|
       
   938 
       
   939         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   963         itemsIndexOrLabelOrPattern isInteger ifTrue:[
   940             idx := itemsIndexOrLabelOrPattern
   964             idx := itemsIndexOrLabelOrPattern
   941         ] ifFalse:[
   965         ] ifFalse:[
   942             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
   966             itemsIndexOrLabelOrPattern includesMatchCharacters ifTrue:[
   943                 idx := component indexOfElementForWhich:[:el | el notNil and:[itemsIndexOrLabelOrPattern match:el string]]. 
   967                 idx := component indexOfElementForWhich:[:el | el notNil and:[itemsIndexOrLabelOrPattern match:el string]]. 
   958     ].
   982     ].
   959 
   983 
   960     (component isKindOf:ItemInView) ifTrue:[
   984     (component isKindOf:ItemInView) ifTrue:[
   961         component isMenuItem ifTrue:[
   985         component isMenuItem ifTrue:[
   962             self movePointerToComponent:component.
   986             self movePointerToComponent:component.
       
   987             self click.
       
   988             ^ self
       
   989         ].
       
   990     ].
       
   991 
       
   992     (component isKindOf:NoteBookView) ifTrue:[
       
   993         (idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
       
   994             idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
       
   995         ].
       
   996         tab := component tabAtIndex:idx.
       
   997         self movePointerToComponent:component offset:(tab layout center).
       
   998         component selection:idx.
       
   999         ^ self
       
  1000     ].
       
  1001     (component isKindOf:DSVColumnView) ifTrue:[
       
  1002         (idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
   963             self halt.
  1003             self halt.
   964         ].
  1004         ].
   965     ].
  1005         yPos := ((component yVisibleOfRowNr:idx) + (component yVisibleOfRowNr:idx+1)) // 2.
   966 
  1006         self movePointerToComponent:component offset:(1 @ yPos).
   967     self error:('cannot select this component: %1' bindWith:component className)
  1007         component selectRow:idx.
       
  1008         ^ self
       
  1009     ].
       
  1010 
       
  1011     self error:('cannot select "%1" this component: %2' bindWith:itemsIndexOrLabelOrPattern with:component className)
   968 
  1012 
   969     "Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
  1013     "Created: / 19-07-2019 / 12:34:25 / Claus Gittinger"
   970     "Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
  1014     "Modified (format): / 19-07-2019 / 14:55:34 / Claus Gittinger"
       
  1015 !
       
  1016 
       
  1017 selectComponent:componentName
       
  1018     "Leaves component in lastComponent without moving"
       
  1019 
       
  1020     <action>
       
  1021 
       
  1022     |component|
       
  1023 
       
  1024     component := self componentNamed:componentName.
   971 !
  1025 !
   972 
  1026 
   973 selectIndex:itemsIndex
  1027 selectIndex:itemsIndex
   974     "select an item by index,
  1028     "select an item by index,
   975      allowed after moving to:
  1029      allowed after moving to:
  1267     lastComponent := component.
  1321     lastComponent := component.
  1268     ^ component
  1322     ^ component
  1269 
  1323 
  1270     "Created: / 19-07-2019 / 15:37:35 / Claus Gittinger"
  1324     "Created: / 19-07-2019 / 15:37:35 / Claus Gittinger"
  1271     "Modified (comment): / 23-07-2019 / 09:31:53 / Claus Gittinger"
  1325     "Modified (comment): / 23-07-2019 / 09:31:53 / Claus Gittinger"
       
  1326 !
       
  1327 
       
  1328 findApplication:classNameOrWindowTitle ifMultiple:exceptionalValue
       
  1329     "find an application by name"
       
  1330     
       
  1331     |candidates|
       
  1332 
       
  1333     candidates := IdentitySet new.
       
  1334 
       
  1335     "/ search through all current applications
       
  1336     WindowGroup scheduledWindowGroups do:[:eachWG |
       
  1337         |eachApp|
       
  1338 
       
  1339         (eachApp := eachWG application) notNil ifTrue:[
       
  1340             ((classNameOrWindowTitle match:eachApp className) 
       
  1341             or:[(classNameOrWindowTitle match:eachApp class nameWithoutPrefix)
       
  1342             or:[(classNameOrWindowTitle match:eachApp mainWindow label)]]) ifTrue:[
       
  1343                 candidates add:eachApp
       
  1344             ].
       
  1345         ].
       
  1346     ].
       
  1347     candidates size == 1 ifTrue:[
       
  1348         ^ candidates first
       
  1349     ].
       
  1350     candidates notEmpty ifTrue:[
       
  1351         "/ multiple elements (probably there are multiple topviews open...
       
  1352         "/ check the current windowGroup
       
  1353         ^ exceptionalValue value
       
  1354     ].
       
  1355     ^ nil
       
  1356 
       
  1357     "
       
  1358      ShowMeHowItWorks basicNew findApplication:'Inspector*' ifMultiple:nil.
       
  1359     "
       
  1360 
       
  1361     "Created: / 19-07-2019 / 12:02:30 / Claus Gittinger"
       
  1362     "Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger"
       
  1363     "Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
  1272 !
  1364 !
  1273 
  1365 
  1274 findComponent:componentName
  1366 findComponent:componentName
  1275     "find a component by name - in the active and possibly in any app.
  1367     "find a component by name - in the active and possibly in any app.
  1276      Can return either a view or a menu item"
  1368      Can return either a view or a menu item"