AbstractLauncherApplication.st
changeset 11487 6e9ed78c5500
parent 11468 3d585b53fb82
child 11490 62451ecb3d3b
equal deleted inserted replaced
11486:9a8bdba7c0e7 11487:6e9ed78c5500
   592     "Modified: / 31.7.1998 / 22:47:33 / cg"
   592     "Modified: / 31.7.1998 / 22:47:33 / cg"
   593 ! !
   593 ! !
   594 
   594 
   595 !AbstractLauncherApplication methodsFor:'private'!
   595 !AbstractLauncherApplication methodsFor:'private'!
   596 
   596 
       
   597 allTopViewsAndLabelsSortedFilteringWindowGroups: windowGroupFilterOrNil
       
   598     "helper returning all windows on all screens sorted by a label to suite"
       
   599 
       
   600     |knownTopViewsAndLabels|
       
   601 
       
   602     knownTopViewsAndLabels := OrderedCollection new.
       
   603     self allTopViewsFilteringWindowGroups: windowGroupFilterOrNil withLabelsDo: [:v :lbl |
       
   604         knownTopViewsAndLabels add:(lbl -> v)
       
   605     ].
       
   606     knownTopViewsAndLabels sort:[:a :b | a key < b key].
       
   607     ^ knownTopViewsAndLabels
       
   608 
       
   609     "Created: / 27-04-2012 / 13:04:21 / cg"
       
   610 !
       
   611 
       
   612 allTopViewsFilteringWindowGroups: windowGroupFilterOrNil withLabelsDo: aBlock
       
   613     "helper enumerating all windows on all screens with a label to suite"
       
   614 
       
   615     |knownTopViews genLabel|
       
   616 
       
   617 
       
   618     genLabel := [:v | 
       
   619                     |app appName|
       
   620 
       
   621                     app := v application.
       
   622                     appName := (app isNil 
       
   623                                     ifTrue:[''] 
       
   624                                     ifFalse:[app class nameWithoutPrefix,': ']).
       
   625                     appName , '"' , (v label ? 'aView') , '"'
       
   626                 ].
       
   627 
       
   628     knownTopViews := IdentitySet new.
       
   629     Screen allScreens do:[:aScreen |
       
   630         aScreen knownViews do:[:aView |
       
   631             |top showIt wg|
       
   632 
       
   633             aView notNil ifTrue:[
       
   634                 top := aView topView.
       
   635                 (knownTopViews includes:top) ifFalse:[
       
   636 
       
   637                     (top isKindOf:DebugView) ifTrue:[
       
   638                         "/ although modal, show it.
       
   639                         showIt := top realized
       
   640                     ] ifFalse:[
       
   641                         (top isKindOf:TopView) ifTrue:[
       
   642                             wg := top windowGroup.
       
   643                             showIt := (wg notNil and:[wg isModal not]).
       
   644                             showIt ifTrue:[
       
   645                                 windowGroupFilterOrNil notNil ifTrue:[
       
   646                                     showIt := windowGroupFilterOrNil includes:wg
       
   647                                 ]
       
   648                             ]
       
   649                         ] ifFalse:[
       
   650                             showIt := false
       
   651                         ].
       
   652                     ].
       
   653                     showIt ifTrue:[
       
   654                         aBlock value: top value:(genLabel value:top).
       
   655                         knownTopViews add: top.
       
   656                     ]
       
   657                 ]
       
   658             ]
       
   659         ]
       
   660     ].
       
   661 
       
   662     "Created: / 27-04-2012 / 12:56:53 / cg"
       
   663 !
       
   664 
   597 findApplicationClass:classOrClassName nameSpace:aNameSpace
   665 findApplicationClass:classOrClassName nameSpace:aNameSpace
   598     "find some application, given the classes name.
   666     "find some application, given the classes name.
   599      Look for it in Smalltalk and the given nameSpace"
   667      Look for it in Smalltalk and the given nameSpace"
   600 
   668 
   601     |cls|
   669     |cls|
   630 
   698 
   631 findWindow:title windowGroupFilter:windowGroupFilterOrNil
   699 findWindow:title windowGroupFilter:windowGroupFilterOrNil
   632     "a helper for find & destroy and find & raise operations;
   700     "a helper for find & destroy and find & raise operations;
   633      let user choose a view and return it; return nil on cancel"
   701      let user choose a view and return it; return nil on cancel"
   634 
   702 
   635     |knownTopViews nameList box genLabel|
   703     |knownTopViewsAndLabels nameList box|
   636 
   704 
   637     knownTopViews := IdentitySet new.
   705     knownTopViewsAndLabels := OrderedCollection new.
   638     Screen allScreens do:[:aScreen |
   706     self allTopViewsFilteringWindowGroups: windowGroupFilterOrNil withLabelsDo: [:v :lbl |
   639         aScreen knownViews do:[:aView |
   707         knownTopViewsAndLabels add:(lbl -> v)
   640             |top showIt wg|
   708     ].
   641 
   709     knownTopViewsAndLabels sort:[:a :b | a key < b key].
   642             aView notNil ifTrue:[
   710 
   643                 top := aView topView.
   711     nameList := knownTopViewsAndLabels collect:[:lblAndView |
   644                 (top isKindOf:DebugView) ifTrue:[
   712                                         |v l isDead wg p|
   645                     "/ although modal, show it.
   713 
   646                     showIt := top realized
   714                                         l := lblAndView key.
   647                 ] ifFalse:[
   715                                         v := lblAndView value.
   648                     wg := top windowGroup.
       
   649                     showIt := (wg notNil and:[wg isModal not]).
       
   650                     showIt ifTrue:[
       
   651                         windowGroupFilterOrNil notNil ifTrue:[
       
   652                             showIt := windowGroupFilterOrNil includes:wg
       
   653                         ]
       
   654                     ]
       
   655                 ].
       
   656                 showIt ifTrue:[
       
   657                     knownTopViews add:top
       
   658                 ]
       
   659             ]
       
   660         ]
       
   661     ].
       
   662 
       
   663     genLabel := [:v | |app appName|
       
   664                     app := v application.
       
   665                     appName := (app isNil 
       
   666                                     ifTrue:[''] 
       
   667                                     ifFalse:[app class nameWithoutPrefix,': ']).
       
   668                     appName , '"' , (v label ? 'aView') , '"'
       
   669                 ].
       
   670 
       
   671     knownTopViews := knownTopViews asOrderedCollection.
       
   672     knownTopViews sort:[:v1 :v2 |
       
   673                                 (genLabel value:v1) < (genLabel value:v2).
       
   674                        ].
       
   675 
       
   676     nameList := knownTopViews collect:[:v |
       
   677                                         |isDead wg p l|
       
   678 
       
   679                                         l := genLabel value:v.
       
   680                                         v device == Display ifFalse:[
   716                                         v device == Display ifFalse:[
   681                                             l := l , ' [' , (v device displayName ? '?') , ']'
   717                                             l := l , ' [' , (v device displayName ? '?') , ']'
   682                                         ].
   718                                         ].
   683                                         ((wg := v windowGroup) notNil
   719                                         ((wg := v windowGroup) notNil
   684                                         and:[(p := wg process) notNil
   720                                         and:[(p := wg process) notNil
   689                                         ]
   725                                         ]
   690                                       ].
   726                                       ].
   691 
   727 
   692     box := ListSelectionBox new.
   728     box := ListSelectionBox new.
   693     box selectionChangeCallback:[:selectionIndex |   |v|
   729     box selectionChangeCallback:[:selectionIndex |   |v|
   694                                     v := knownTopViews at:box selectionIndex.
   730                                     v := (knownTopViewsAndLabels at:box selectionIndex) value.
   695                                     v raise. box raise
   731                                     v raise. box raise
   696                                 ].
   732                                 ].
   697     box noEnterField.
   733     box noEnterField.
   698     box list:nameList.
   734     box list:nameList.
   699     box label:(resources string:'View Selection').
   735     box label:(resources string:'View Selection').
   700     box title:(resources stringWithCRs:title).
   736     box title:(resources stringWithCRs:title).
   701     box action:[:selection |
   737     box action:[:selection |
   702         |v|
   738         |v|
   703 
   739 
   704         v := knownTopViews at:box selectionIndex.
   740         v := (knownTopViewsAndLabels at:box selectionIndex) value.
   705         box destroy.
   741         box destroy.
   706         ^ v
   742         ^ v
   707     ].
   743     ].
   708     box extent:400@300.
   744     box extent:400@300.
   709     box open.
   745     box open.
   710     ^ nil
   746     ^ nil
   711 
   747 
   712     "Modified: / 03-03-2012 / 05:15:11 / cg"
   748     "Modified: / 27-04-2012 / 12:59:37 / cg"
   713 !
   749 !
   714 
   750 
   715 openApplication: classOrClassName
   751 openApplication: classOrClassName
   716      "open an application, given by the classe name."
   752      "open an application, given by the classe name."
   717 
   753 
  2037                             defaultName:'screen'
  2073                             defaultName:'screen'
  2038                       ]
  2074                       ]
  2039         afterSeconds:(self window sensor shiftDown ifTrue:5 ifFalse:1)
  2075         afterSeconds:(self window sensor shiftDown ifTrue:5 ifFalse:1)
  2040 !
  2076 !
  2041 
  2077 
       
  2078 hardcopyOfView: aView
       
  2079     "after a second (to allow redraw of views under menu ...),
       
  2080      save a view's contents as bitmap image."
       
  2081 
       
  2082     aView topView raiseDeiconified.
       
  2083     aView topView makeFullyVisible.
       
  2084     "do a pushEvent, in case its me myself and I have to redraw first..."
       
  2085     self enqueueDelayedAction:[
       
  2086         Delay waitForSeconds:1.   "/ give view a chance to redraw itself.
       
  2087         self saveScreenImage:(Image fromView:(aView topView)) defaultName:'hardcopy'
       
  2088     ].
       
  2089     aView windowGroup processExposeEvents
       
  2090 
       
  2091     "Created: / 27-04-2012 / 13:23:40 / cg"
       
  2092 !
       
  2093 
  2042 iconifyAllWindows
  2094 iconifyAllWindows
  2043     |setOfViews currentScreen|
  2095     |setOfViews currentScreen|
  2044 
  2096 
  2045     setOfViews := Project current views asIdentitySet.
  2097     setOfViews := Project current views asIdentitySet.
  2046     setOfViews addAll:(Project defaultProject views).
  2098     setOfViews addAll:(Project defaultProject views).
  2083 
  2135 
  2084     aWindow windowGroup isModal ifTrue:[
  2136     aWindow windowGroup isModal ifTrue:[
  2085         self warn:'Sorry - I cannot migrate a modalBox; please migrate the owning View.'.
  2137         self warn:'Sorry - I cannot migrate a modalBox; please migrate the owning View.'.
  2086         ^ self
  2138         ^ self
  2087     ].
  2139     ].
  2088     self migrateWindow:aWindow withBackOption:(self confirm:'Show ''Return Back'' Button on the other display ?')
  2140     self 
  2089 
  2141         migrateWindow:aWindow 
       
  2142         withBackOption:(self confirm:'Show ''Return Back'' Button on the other display ?')
       
  2143 
       
  2144     "Modified (format): / 27-04-2012 / 13:15:23 / cg"
  2090 !
  2145 !
  2091 
  2146 
  2092 migrateWindow:aWindow withBackOption:withBackOption
  2147 migrateWindow:aWindow withBackOption:withBackOption
  2093     "migrate a view to some other display"
  2148     "migrate a view to some other display"
  2094 
  2149 
  2260 
  2315 
  2261     Processor
  2316     Processor
  2262         addTimedBlock:[
  2317         addTimedBlock:[
  2263                         |v|
  2318                         |v|
  2264                         (v := Screen current viewFromUser) notNil ifTrue:[
  2319                         (v := Screen current viewFromUser) notNil ifTrue:[
  2265                             v topView raise.
  2320                             self hardcopyOfView: v
  2266                             v topView makeFullyVisible.
       
  2267                             Delay waitForSeconds:0.5.   "/ give view a chance to redraw itself.
       
  2268                             self saveScreenImage:(Image fromView:(v topView)) defaultName:'hardcopy'
       
  2269                         ]
  2321                         ]
  2270                       ]
  2322                       ]
  2271         afterSeconds:(self window sensor shiftDown ifTrue:5 ifFalse:1)
  2323         afterSeconds:(self window sensor shiftDown ifTrue:5 ifFalse:1)
       
  2324 
       
  2325     "Modified: / 27-04-2012 / 13:24:23 / cg"
  2272 !
  2326 !
  2273 
  2327 
  2274 viewInspect
  2328 viewInspect
  2275     "let user pick a view and inspect it. Only smalltalk views are allowed"
  2329     "let user pick a view and inspect it. Only smalltalk views are allowed"
  2276 
  2330 
  6907 ! !
  6961 ! !
  6908 
  6962 
  6909 !AbstractLauncherApplication class methodsFor:'documentation'!
  6963 !AbstractLauncherApplication class methodsFor:'documentation'!
  6910 
  6964 
  6911 version
  6965 version
  6912     ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.413 2012-03-26 09:54:15 cg Exp $'
  6966     ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.414 2012-04-27 11:55:14 cg Exp $'
  6913 !
  6967 !
  6914 
  6968 
  6915 version_CVS
  6969 version_CVS
  6916     ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.413 2012-03-26 09:54:15 cg Exp $'
  6970     ^ '$Header: /cvs/stx/stx/libtool/AbstractLauncherApplication.st,v 1.414 2012-04-27 11:55:14 cg Exp $'
  6917 !
  6971 !
  6918 
  6972 
  6919 version_SVN
  6973 version_SVN
  6920     ^ '§Id: AbstractLauncherApplication.st 7796 2011-06-23 16:01:32Z vranyj1 §'
  6974     ^ '§Id: AbstractLauncherApplication.st 7796 2011-06-23 16:01:32Z vranyj1 §'
  6921 ! !
  6975 ! !