#REFACTORING by exept
class: ShowMeHowItWorks
changed:
#findComponent:in:
#waitFor:timeout:
--- a/ShowMeHowItWorks.st Sun Oct 13 23:27:40 2019 +0200
+++ b/ShowMeHowItWorks.st Mon Oct 14 10:31:43 2019 +0200
@@ -307,11 +307,11 @@
|endTime|
- DebugMode == true ifTrue:[^ self].
+ verifying ifTrue:[^ self].
+
endTime := Timestamp now + seconds.
[
(self findComponent:componentName) notNil ifTrue:[
- self halt.
^ self
].
Delay waitForSeconds:0.05.
@@ -794,7 +794,7 @@
"Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger"
!
-findComponent:componentNameOrPath in:anApplicationOrView
+findComponent:componentNameOrPath in:anApplicationOrViewOrMenuItem
"find a component by name inside an app or inside a view.
Uses the NameKey of the spec, and optionally the label or modelKey.
Can return either a view or a menu item"
@@ -808,7 +808,7 @@
containerName := componentNameOrPath copyTo:idx-1.
restPath := componentNameOrPath copyFrom:idx+1.
- container := self findComponent:containerName in:anApplicationOrView.
+ container := self findComponent:containerName in:anApplicationOrViewOrMenuItem.
container isNil ifTrue:[ ^ nil ].
^ self findComponent:restPath in:container
]
@@ -816,14 +816,18 @@
componentNameSymbol := componentNameOrPath asSymbolIfInterned ? componentNameOrPath.
- (app := anApplicationOrView) isView ifTrue:[
- window := anApplicationOrView.
- app := anApplicationOrView application
+ (app := anApplicationOrViewOrMenuItem) isView ifTrue:[
+ window := anApplicationOrViewOrMenuItem.
+ app := anApplicationOrViewOrMenuItem application
].
- app notNil ifTrue:[
+ app isApplicationModel ifTrue:[
(component := app componentAt:componentNameSymbol) notNil ifTrue:[^ component].
window := window ? app window.
- ].
+ ] ifFalse:[
+ app isMenuItem ifTrue:[
+ window := app submenu.
+ ]
+ ].
"/ mhmh - search through all widgets of anApplication;
"/ maybe it was not created via the builder/spec,
@@ -851,9 +855,6 @@
] on:MessageNotUnderstood do:[:ex | ].
foundIt ifFalse:[
each isMenu ifTrue:[
- verifying ifFalse:[
- componentNameSymbol = 'NewTestSuite' ifTrue:[self halt].
- ].
(item := each detectItemForNameKey:componentNameSymbol) notNil ifTrue:[
foundByName add:item. foundIt := true
].