class: Tools::ViewTreeInspectorApplication
authorClaus Gittinger <cg@exept.de>
Thu, 18 Dec 2014 00:52:06 +0100
changeset 3174 cd45c49a0d63
parent 3173 801e6bfe2581
child 3175 c205d80403ef
class: Tools::ViewTreeInspectorApplication added:5 methods comment/format in: #selectionChanged changed: #menu navigate directly to the windowSpec.
Tools__ViewTreeApplication.st
--- a/Tools__ViewTreeApplication.st	Sun Dec 14 18:01:38 2014 +0100
+++ b/Tools__ViewTreeApplication.st	Thu Dec 18 00:52:06 2014 +0100
@@ -437,7 +437,7 @@
      by the MenuEditor of ST/X."
 
     "Do not manually edit this!! If it is corrupted,
-     the MenuEditor may not be able to read the specification."
+     the MenuEditor may not be able to read the specification."      
 
 
     "
@@ -580,6 +580,19 @@
                   label: '-'
                 )
                (MenuItem
+                  enabled: canBrowseWindowSpecMethod
+                  label: 'Browse Window Spec Method'
+                  itemValue: doBrowseWindowSpecMethod
+                )
+               (MenuItem
+                  enabled: canEditWindowSpec
+                  label: 'Edit Window Spec'
+                  itemValue: doEditWindowSpec
+                )
+               (MenuItem
+                  label: '-'
+                )
+               (MenuItem
                   enabled: hasTargetWidgetChannel
                   label: 'All Applications'
                   submenuChannel: submenuApplications:
@@ -937,6 +950,14 @@
 
 !ViewTreeInspectorApplication methodsFor:'aspects'!
 
+canBrowseWindowSpecMethod
+    ^ self hasSingleSelectionHolder value and:[ self windowSpecMethodOfSelection notNil ]
+!
+
+canEditWindowSpec
+    ^ self hasSingleSelectionHolder value and:[ self windowSpecMethodOfSelection notNil ]
+!
+
 followFocusChannel
     "boolean holder, which indicates whether selection changed dependend on the focus view"
 
@@ -1049,6 +1070,52 @@
      true:  no  input events are eaten and no  selection is shown on the target view."
 
     ^ model testModeChannel
+!
+
+windowSpecMethodOfSelection
+    |item view app spec builder specSelector implementors|
+
+    item := model selectedItem.
+    item isNil ifTrue:[^ nil]. 
+
+    view := item widget.
+    view isNil ifTrue:[^ nil]. 
+
+    app := view application.
+    app isNil ifTrue:[^ nil]. 
+
+    builder := app builder.
+    builder isNil ifTrue:[^ nil]. 
+
+    spec := builder spec.
+    spec isNil ifTrue:[^ nil].
+
+    specSelector := spec name.
+    specSelector isNil ifTrue:[^ nil].
+
+    (app class theNonMetaclass canUnderstand:specSelector) ifTrue:[
+        ^ app class theNonMetaclass lookupMethodFor:specSelector.
+    ].
+    (app class theMetaclass canUnderstand:specSelector) ifTrue:[
+        ^ app class theMetaclass lookupMethodFor:specSelector.
+    ].
+
+    "/ maybe a simple dialog given a spec
+    app masterApplication notNil ifTrue:[
+        (app masterApplication class theNonMetaclass canUnderstand:specSelector) ifTrue:[     
+            ^ app masterApplication class theNonMetaclass lookupMethodFor:specSelector.
+        ].
+        (app masterApplication class theMetaclass canUnderstand:specSelector) ifTrue:[    
+            ^ app masterApplication class theMetaclass lookupMethodFor:specSelector.
+        ].
+    ].
+
+    implementors := Smalltalk allImplementorsOf: specSelector.
+    implementors size == 1 ifTrue:[
+        ^ implementors first compiledMethodAt:specSelector.
+    ].
+
+    ^ nil
 ! !
 
 !ViewTreeInspectorApplication methodsFor:'change & update'!
@@ -1063,8 +1130,9 @@
     |info view item|
 
     item := model selectedItem.
-
-    item notNil ifTrue:[ |state|
+    item notNil ifTrue:[ 
+        |state|
+
         view := item widget.
 
         view id isNil ifTrue:[
@@ -1078,7 +1146,6 @@
         ].
         info := '%1 [%2] - %3' bindWith:(view class name)
                                    with:(view name ? '') with:state allBold.
-
     ] ifFalse:[
         info := ''
     ].
@@ -1940,6 +2007,13 @@
     "Modified: / 28-08-2013 / 23:57:42 / cg"
 !
 
+doBrowseWindowSpecMethod
+    |mthd|
+
+    mthd := self windowSpecMethodOfSelection.
+    NewSystemBrowser openInClass:mthd mclass selector:mthd selector
+!
+
 doCatchEvents
     model catchEvents:true.
     isCatchingEventsChannel value:true.
@@ -1996,6 +2070,13 @@
     ].
 !
 
+doEditWindowSpec
+    |mthd|
+
+    mthd := self windowSpecMethodOfSelection.
+    UIPainter openOnClass:mthd mclass andSelector:mthd selector
+!
+
 doFlash
     "flash the selected view"