| package | package := Package name: 'CJDViewFinder'. package paxVersion: 0; basicComment: 'Release 1 (12-4-2001) By: Christopher J. Demers Copyright 2001 (Freeware) The code may be freely used and freely modified, but please don''t redistributed modified versions (without asking me). Use this code at your own risk. see: http://www.mitchellscientific.com/smalltalk/ for much more information. This is a visual view finder tool. After the package is installed it should add a menu item (Tools\Additional Tools\CJD View Finder). The tool is used by dragging and dropping the green square over the view you wish to select. Both shells and child views can be selected so make sure the tool displays the appropriate Presenter, View and Caption (or name) as you drag. Browse Presenter - Open a class browser on the selected view''s presenter class. Inspect Presenter - Open an inspector on the selected view''s presenter instance. Close View - Sends the #close message to the selected view. This may change to #destroy in the future. It can be useful for closing views stuck in a loop that prohibits a normal close. Feedback at cdemers@mitchellscientific.com is appreciated. '. package basicPackageVersion: '1.01'. "Add the package scripts" "Add the class names, loose method names, global names, resource names" package classNames add: #CJDViewDragSelectionTool; add: #CJDViewFinder; add: #CJDViewSelectorDragDropSession; yourself. package methodNames yourself. package globalNames yourself. package resourceNames yourself. "Binary Global Names" package binaryGlobalNames: (Set new yourself). "Resource Names" package allResourceNames: (Set new add: #CJDViewFinder -> 'CJDViewDragSelectionTool'; add: #CJDViewFinder -> 'Default view'; yourself). "Add the prerequisite names" package setPrerequisites: (IdentitySet new add: 'Development System'; add: 'Dolphin'; yourself). package! "Class Definitions"! InternalDragDropSession subclass: #CJDViewSelectorDragDropSession instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' classInstanceVariableNames: ''! SmalltalkToolShell subclass: #CJDViewFinder instanceVariableNames: 'dragLBPresenter targetView viewTBPresenter presenterTBPresenter dragToolPresenter captionTBPresenter drag' classVariableNames: '' poolDictionaries: '' classInstanceVariableNames: ''! StaticText subclass: #CJDViewDragSelectionTool instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' classInstanceVariableNames: ''! "Loose Methods"! "End of package definition"! CJDViewSelectorDragDropSession comment: 'cdemers 12-4-2001 This class provides a way for an observer to be notified as the draging session is moved over new views. This DragDropSession is used for visual view selection.'! CJDViewSelectorDragDropSession guid: (GUID fromString: '{84D24C02-E50C-11D5-80E9-006008C07585}')! !CJDViewSelectorDragDropSession categoriesForClass!Unclassified! ! !CJDViewSelectorDragDropSession methodsFor! dropTargetEnter "Private - Inform the drop target that the receiver has has entered its air space." "cdemers - 12/4/2001 I trigger an event here so observers know when the dropTarget has changed." super dropTargetEnter. self trigger: #dropTargetEntered: with: dropTarget.! getCustomDragImages "cdemers - 12/4/2001 Set the object image. I think I eventualy want to find an image that better conveys where the pointer target is (like an arrow). For now the questionmark conveys the nature of the session, it is like a prompter." | dragged icon | "dragged := self dragObjects first." icon := Icon question. "icon := Icon fromSystemId: 32512." "icon := dragged isObjectAvailable ifTrue: [dragged object icon] ifFalse: [Icon question]." self imageAt: #Object put: icon. dragSource isDragSource ifTrue: [dragSource ddGetImages: self]! initialize "Private - Initialize the receiver." "cdemers - 12/4/2001 Replaced none to look less forbidding." defaultOperation := #move. imageDict := IdentityDictionary new. self imageAt: #none put: Cursor arrow; imageAt: #move put: Cursor ddMove; imageAt: #copy put: Cursor ddCopy; imageAt: #link put: Cursor ddLink; imageAt: #moveScroll put: Cursor ddMoveScroll; imageAt: #copyScroll put: Cursor ddCopy; imageAt: #linkScroll put: Cursor ddLink.! ! !CJDViewSelectorDragDropSession categoriesFor: #dropTargetEnter!drag & drop-target!private! ! !CJDViewSelectorDragDropSession categoriesFor: #getCustomDragImages!drag & drop-source!private! ! !CJDViewSelectorDragDropSession categoriesFor: #initialize!initializing!private! ! CJDViewFinder comment: 'cdemers 12-4-2001 See package for comments.'! CJDViewFinder guid: (GUID fromString: '{17E36F01-E383-11D5-80E9-006008C07585}')! !CJDViewFinder categoriesForClass!Unclassified! ! !CJDViewFinder methodsFor! browsePresenter "cdemers - 12/2/2001 Browse the presenter." targetView presenter browse.! closeView "cdemers - 11/30/2001 Close the target view." (MessageBox confirm: 'Are you sure you want to forcefully close the selected view?') ifTrue: [targetView close]. "I could also use destroy here."! createComponents " (AutoGenerated) Create the presenters contained by the receiver." super createComponents. "(AutoGenerated on 3:02:12 AM, 12/2/2001)" presenterTBPresenter := self add: TextPresenter new name: 'presenterTB'. "dragToolPresenter := self add: Presenter new name: 'dragTool'." viewTBPresenter := self add: TextPresenter new name: 'viewTB'. captionTBPresenter := self add: TextPresenter new name: 'captionTB'. ! createSchematicWiring "cdemers - 12/4/2001" " dragLBPresenter when: #drag: send: #dragSession: to: self." (self view viewNamed: 'dragTool') when: #drag: send: #dragSession: to: self. ! displayDropTarget: aDropTarget "cdemers - 12/4/2001" | targetPresenter | targetView := aDropTarget. targetPresenter := targetView presenter. presenterTBPresenter value: targetPresenter class printString. viewTBPresenter value: targetView class printString. (targetView respondsTo: #caption) ifTrue:[captionTBPresenter value: targetView caption] ifFalse: [captionTBPresenter value: targetView name].! dragSession: aDragSession "cdemers - 12/4/2001" drag := aDragSession. drag when: #dropTargetEntered: send: #displayDropTarget: to: self. ! inspectPresenter "cdemers - 12/2/2001 Inspect the presenter." targetView presenter inspect.! ! !CJDViewFinder categoriesFor: #browsePresenter!*-unclassified!public! ! !CJDViewFinder categoriesFor: #closeView!*-unclassified!public! ! !CJDViewFinder categoriesFor: #createComponents!*-unclassified!public! ! !CJDViewFinder categoriesFor: #createSchematicWiring!*-unclassified!public! ! !CJDViewFinder categoriesFor: #displayDropTarget:!*-unclassified!public! ! !CJDViewFinder categoriesFor: #dragSession:!*-unclassified!public! ! !CJDViewFinder categoriesFor: #inspectPresenter!*-unclassified!public! ! !CJDViewFinder class methodsFor! displayOn: aStream "Append, to aStream, a String whose characters are a representation of the receiver as a user would want to see it." aStream nextPutAll: 'CJD View Finder' ! initialize "Private - Initialize the receiver. self initializeAfterLoad. self initialize. " Smalltalk developmentSystem addAdditionalToolsFolderIcon: self toolsFolderIcon; registerTool: self. self reuseIfOpen: true. ! uninitialize "Private - Un-register the system tools folder icon for the receiver to allow clean removal of this class from the system. self uninitialize Note: As in all Development classes, this method must be stripped to prevent it generating an error when this class is removed." Smalltalk developmentSystem removeSystemFolderIconNamed: self toolDescription; unregisterTool: self ! ! !CJDViewFinder class categoriesFor: #displayOn:!*-unclassified!public! ! !CJDViewFinder class categoriesFor: #initialize!initializing!private! ! !CJDViewFinder class categoriesFor: #uninitialize!class hierarchy-removing!private! ! CJDViewDragSelectionTool comment: 'cdemers 12-4-2001 This class is needed to override the dragdrop session with my own. To create the view resource: CJDViewDragSelectionTool makeResource: ''CJDViewDragSelectionTool'' inClass: CJDViewFinder'! CJDViewDragSelectionTool guid: (GUID fromString: '{84D24C01-E50C-11D5-80E9-006008C07585}')! !CJDViewDragSelectionTool categoriesForClass!Unclassified! ! !CJDViewDragSelectionTool methodsFor! onBegin: dragOp drag: dragee "cdemers - 12/4/2001 Override to use CJDViewSelectorDragDropSession." | vk | vk := ##(IdentityDictionary new at: #left put: VK_LBUTTON; at: #right put: VK_RBUTTON; at: #middle put: VK_MBUTTON; yourself) at: dragOp. "self halt." (Keyboard default isKeyDown: vk) ifTrue: [ (CJDViewSelectorDragDropSession dragSource: self item: dragee) doDragDropAt: Cursor position button: dragOp]! onLeftButtonPressed: aMouseEvent "cdemers - 12/4/2001" super onLeftButtonPressed: aMouseEvent. self onBegin: #left drag: 'Drag me'. ! requestDragObjects: session "cdemers - 12/4/2001 The object is not important so just return a string." session addDragObject: (InternalDragDropObject object: 'Test'). "But let any observers override with their own suggestion" super requestDragObjects: session! ! !CJDViewDragSelectionTool categoriesFor: #onBegin:drag:!event handling!public! ! !CJDViewDragSelectionTool categoriesFor: #onLeftButtonPressed:!*-unclassified!public! ! !CJDViewDragSelectionTool categoriesFor: #requestDragObjects:!drag & drop!public! ! "Binary Globals"! "Resources"! (ResourceIdentifier class: CJDViewFinder name: 'CJDViewDragSelectionTool') assign: (Object fromBinaryStoreBytes: (ByteArray fromHexString: '2153544220302046020C0001000000566965775265736F75726365000000000E0124005354425265736F757263655354424279746541727261794163636573736F7250726F78790000000036000900427974654172726179C9020000215354422030204E080C000A0000005354425669657750726F7879000000004E020D0001000000535442436C61737350726F78790000000036000600537472696E670D000000434A445669657746696E6465729200000018000000434A44566965774472616753656C656374696F6E546F6F6C260005004172726179100000000000000000000000C20000000200000036000C004C61726765496E746567657204000000000180440100000060000000000000000603030052474200000000010000000101000001010000000000000700000000000000000000000000000000000000120100000000000001000000FF010000FF010000F2000000040000007073E17706020D004E756C6C436F6E7665727465720000000000000000000000000000000006010F004D65737361676553657175656E6365000000000E021200535442436F6C6C656374696F6E50726F7879000000007A000000000000009200000007000000446F6C7068696E92000000110000004F726465726564436F6C6C656374696F6EC20000000200000006030B004D65737361676553656E64000000000E010E0053544253796D626F6C50726F787900000000920000001000000063726561746541743A657874656E743AC20000000200000006020500506F696E74000000001F0000000B0000005202000000000000830000006F00000060000000F2010000000000001A020000000000009200000005000000746578743AC200000001000000920000001900000044726167206D6520746F2073656C656374206120766965772E6000000006010F0057494E444F57504C4143454D454E5400000000360009004279746541727261792C0000002C0000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0F00000005000000500000003C0000009A01000000000000B0010000C2000000000000005202000000000000C1000000C10000000000000013000000460504000300000049636F6E0000000000000000100000000E02110053544253696E676C65746F6E50726F7879000000004E020D0001000000535442436C61737350726F78790000000036000600537472696E6707000000446F6C7068696E1201000018000000496D61676552656C617469766546696C654C6F6361746F720E010E0053544253796D626F6C50726F787900000000120100000700000063757272656E74120100000E000000537461746963546578742E69636F0E021F0053544245787465726E616C5265736F757263654C69627261727950726F7879000000001201000010000000646F6C7068696E64723030342E646C6C00000000'))! (ResourceIdentifier class: CJDViewFinder name: 'Default view') assign: (Object fromBinaryStoreBytes: (ByteArray fromHexString: '2153544220302046020C0001000000566965775265736F75726365000000000E0124005354425265736F757263655354424279746541727261794163636573736F7250726F7879000000003600090042797465417272617921130000215354422030204E080C000A0000005354425669657750726F7879000000004E020D0001000000535442436C61737350726F78790000000036000600537472696E6707000000446F6C7068696E92000000090000005368656C6C566965772600050041727261791B0000000000000000000000C20000000200000001009E0101010200600000000000000006010B0053797374656D436F6C6F72000000001F000000000000000700000000000000000000000000000000000000000000000E021A005354424964656E7469747944696374696F6E61727950726F7879000000007A00000000000000A000000092000000120000004964656E7469747944696374696F6E617279C2000000080000005A000000000000007A00000000000000A000000092000000080000005465787445646974C2000000100000000000000060000000C20000000200000036000C004C61726765496E7465676572040000008000014401040000600100000000000000000000000000000F0000000000000000000000000000000000000000000000B2010000040000006F30E27706020D004E756C6C436F6E7665727465720000000000000000000000000300000006010F004D65737361676553657175656E6365000000000E021200535442436F6C6C656374696F6E50726F7879000000007A00000000000000A000000092000000110000004F726465726564436F6C6C656374696F6EC20000000300000006030B004D65737361676553656E64000000000E010E0053544253796D626F6C50726F787900000000920000001000000063726561746541743A657874656E743AC20000000200000006020500506F696E74000000008300000015000000D2020000000000001D020000330000006001000072020000000000009A02000000000000920000000F00000073656C656374696F6E52616E67653AC20000000100000006030800496E74657276616C000000000300000001000000030000006001000072020000000000009A02000000000000920000000F0000006973546578744D6F6469666965643AC200000001000000200000006001000006010F0057494E444F57504C4143454D454E5400000000360009004279746541727261792C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF410000000A0000004F010000230000002A0200000000000040020000C200000000000000D202000000000000C1000000C10000000000000013000000920000000B00000070726573656E74657254425A0000000000000070010000C2000000100000000000000060000000C200000002000000B201000004000000800001440104000020040000000000000000000000000000070000000000000000000000000000000000000000000000B2010000040000006F30E277E20100000000000000000000000000000300000002020000000000002A0200000000000040020000C2000000030000007202000000000000A0020000C200000002000000D2020000000000008300000079000000D2020000000000001D0200003300000020040000720200000000000010030000C200000001000000420300000000000003000000010000000300000020040000720200000000000070030000C2000000010000002000000020040000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF410000003C0000004F010000550000002A0200000000000040020000F0030000000400000000000013000000920000000900000063617074696F6E54425A0000000000000070010000C2000000100000000000000060000000C200000002000000B2010000040000008000014401040000800500000000000000000000000000000F0000000000000000000000000000000000000000000000B2010000040000006F30E277E20100000000000000000000000000000300000002020000000000002A0200000000000040020000C2000000030000007202000000000000A0020000C200000002000000D2020000000000008300000047000000D2020000000000001D0200003300000080050000720200000000000010030000C200000001000000420300000000000003000000010000000300000080050000720200000000000070030000C2000000010000002000000080050000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF41000000230000004F0100003C0000002A0200000000000040020000F003000000040000000000001300000092000000060000007669657754425A000000000000007A00000000000000920000000D000000434A445669657746696E6465729200000018000000434A44566965774472616753656C656374696F6E546F6F6CC2000000100000000000000060000000C200000002000000B2010000040000000001804401000000E0060000000000000603030052474200000000010000000101000001010000000000000F00000000000000000000000000000000000000520700000000000001000000FF010000FF010000B2010000040000007073E177E20100000000000000000000000000000000000002020000000000002A0200000000000040020000C2000000020000007202000000000000A0020000C200000002000000D20200000000000001000000AB000000D202000000000000830000006F000000E006000072020000000000009A020000000000009200000005000000746578743AC200000001000000920000001900000044726167206D6520746F2073656C656374206120766965772EE0060000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000055000000410000008C0000002A0200000000000040020000F0030000000400000000000013000000920000000800000064726167546F6F6C0000000000000000000000000000000000000000010000000000000000000000000000000000000001000000000000000000000002020000000000002A0200000000000040020000C2000000030000007202000000000000A0020000C200000002000000D2020000000000000B0000000B000000D202000000000000B30200005501000060000000720200000000000020080000C200000001000000920000000F000000434A4420566965772046696E6465726000000072020000000000009A0200000000000092000000080000006D656E754261723AC2000000010000000000000060000000A203000000000000C20300002C0000002C0000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF05000000050000005E010000AF0000002A0200000000000040020000C20000000A000000600100005A000000000000007A00000000000000A0000000920000000A00000050757368427574746F6EC2000000110000000000000060000000C200000002000000B2010000040000000020014401000000C0090000000000000000000000000000070000000000000000000000000000000000000000000000B2010000040000006EB2E1774604120002000000436F6D6D616E644465736372697074696F6E000000009A02000000000000920000000F00000062726F77736550726573656E746572920000001000000042726F7773652050726573656E7465720100000000000000000000000100000002020000000000002A0200000000000040020000C2000000030000007202000000000000A0020000C200000002000000D20200000000000097000000BF000000D202000000000000970000005B000000C009000072020000000000009A02000000000000920000000A0000006973456E61626C65643AC20000000100000020000000C0090000720200000000000020080000C200000001000000920000001000000042726F7773652050726573656E746572C0090000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4B0000005F000000960000008C0000002A0200000000000040020000F00300000004000000000000130000005A00000000000000D0090000C2000000110000000000000060000000C200000002000000B2010000040000000020014401000000900B0000000000000000000000000000070000000000000000000000000000000000000000000000B2010000040000006EB2E177320A0000000000009A020000000000009200000009000000636C6F736556696577920000000A000000436C6F736520566965770100000000000000000000000100000002020000000000002A0200000000000040020000C2000000030000007202000000000000A0020000C200000002000000D202000000000000C3010000BF000000D202000000000000970000005B000000900B00007202000000000000000B0000C20000000100000020000000900B0000720200000000000020080000C200000001000000920000000A000000436C6F73652056696577900B0000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE10000005F0000002C0100008C0000002A0200000000000040020000F0030000000400000000000013000000800500005A000000000000007A00000000000000A0000000920000000A00000053746174696354657874C2000000100000000000000060000000C200000002000000B2010000040000000001004401000000100D0000000000000000000000000000070000000000000000000000000000000000000000000000B2010000040000007073E177E20100000000000000000000000000000000000002020000000000002A0200000000000040020000C2000000020000007202000000000000A0020000C200000002000000D2020000000000000100000015000000D2020000000000008300000033000000100D0000720200000000000020080000C200000001000000920000000A00000050726573656E7465723A100D0000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000A00000041000000230000002A0200000000000040020000F00300000004000000000000130000005A00000000000000200D0000C2000000100000000000000060000000C200000002000000B2010000040000000001004401000000600E0000000000000000000000000000070000000000000000000000000000000000000000000000B2010000040000007073E177E20100000000000000000000000000000000000002020000000000002A0200000000000040020000C2000000020000007202000000000000A0020000C200000002000000D2020000000000000100000047000000D2020000000000008D00000033000000600E0000720200000000000020080000C2000000010000009200000005000000566965773A600E0000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000023000000460000003C0000002A0200000000000040020000F0030000000400000000000013000000200400005A00000000000000200D0000C2000000100000000000000060000000C200000002000000B2010000040000000001004401000000900F0000000000000000000000000000070000000000000000000000000000000000000000000000B2010000040000007073E177E20100000000000000000000000000000000000002020000000000002A0200000000000040020000C2000000020000007202000000000000A0020000C200000002000000D2020000000000000100000079000000D2020000000000008300000033000000900F0000720200000000000020080000C200000001000000920000000800000043617074696F6E3A900F0000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000003C00000041000000550000002A0200000000000040020000F00300000004000000000000130000005A00000000000000D0090000C2000000110000000000000060000000C200000002000000B2010000040000000020014401000000C0100000000000000000000000000000070000000000000000000000000000000000000000000000B2010000040000006EB2E177320A0000000000009A020000000000009200000010000000696E737065637450726573656E7465729200000011000000496E73706563742050726573656E7465720100000000000000000000000100000002020000000000002A0200000000000040020000C2000000030000007202000000000000A0020000C200000002000000D2020000000000002D010000BF000000D202000000000000970000005B000000C01000007202000000000000000B0000C20000000100000020000000C0100000720200000000000020080000C2000000010000009200000011000000496E73706563742050726573656E746572C0100000A203000000000000C20300002C0000002C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF960000005F000000E10000008C0000002A0200000000000040020000F0030000000400000000000013000000E0060000000400000000000015000000460504000300000049636F6E0000000000000000100000000E02110053544253696E676C65746F6E50726F7879000000004E020D0001000000535442436C61737350726F78790000000036000600537472696E6707000000446F6C7068696E1201000018000000496D61676552656C617469766546696C654C6F6361746F720E010E0053544253796D626F6C50726F787900000000120100000700000063757272656E74120100000D0000005368656C6C566965772E69636F0E021F0053544245787465726E616C5265736F757263654C69627261727950726F7879000000001201000010000000646F6C7068696E64723030342E646C6C00000000'))!