[ENH] CloseSimilarWindows-nk (v2)

Hernan Tylim htylim at yahoo.com.ar
Mon Aug 30 22:01:58 UTC 2004


ned at squeakland.org wrote:

>from preamble:
>
>"Change Set:		CloseSimilarWindows-nk
>Date:			30 August 2004
>Author:			Ned Konz
>
>v2: adds missing calls to super for some classes.
>
>Adds an item to the Window menu that lets you close the current window
>and all the windows that have the same kind of model.
>
>Handy when you get too many PreDebugWindows or Browsers on the screen.
>
>"!
>  
>
Hi Ned,

    I tried it on 3.7 5987 image and I got two DNUs. The first one was 
for FlapTab>>model, and the second was for PasteUpMorph>>deleteMorphs:, 
both in Object>>closeSimilarWindows.  Here is your .cs again but with 
those DNU fixed.

    BTW. I like this a lot.

Regards,
Hernán
-------------- next part --------------
'From Squeak3.7gamma of ''17 July 2004'' [latest update: #5987] on 30 August 2004 at 6:52:43 pm'!
"Change Set:		CloseSimilarWindows-nk
Date:			30 August 2004
Author:			Ned Konz

v3: Object>>closeSimilarWindows was assuming that all morphs has model and I changed the use of #deleteMorphs: for #removeAllMorphsIn: because the first one didn't exist in my Image (Squeak 3.7 5987 image) (hpt)

v2: adds missing calls to super for some classes.

Adds an item to the Window menu that lets you close the current window and all the windows that have the same kind of model.

Handy when you get too many PreDebugWindows or Browsers on the screen.

"!


!Object methodsFor: 'user interface' stamp: 'nk 8/30/2004 10:54'!
addModelItemsToWindowMenu: aMenu
	"aMenu is being constructed to be presented to the user in response to the user's pressing on the menu widget in the title bar of a morphic window.  Here, the model is given the opportunity to add any model-specific items to the menu, whose default target is the SystemWindow itself."

	Smalltalk isMorphic ifTrue: [
		aMenu addLine.
		aMenu add: 'close similar windows' translated target: self selector: #closeSimilarWindows.
	].
	^aMenu ! !

!Object methodsFor: 'user interface' stamp: 'hpt 8/30/2004 18:49'!
closeSimilarWindows
	| myWorld |
	myWorld :=  self dependents first world.
	myWorld ifNil: [ ^self ].
	myWorld removeAllMorphsIn: (myWorld submorphsSatisfying: [ :m |
		(m respondsTo: #model) and: [(m model class == self class) and: [ m model okToChange ] ] ]).
! !


!ChangeSetBrowser methodsFor: 'initialization' stamp: 'nk 8/30/2004 11:05'!
addModelItemsToWindowMenu: aMenu
	"Add model-related items to the given window menu"

	| oldTarget |
	super addModelItemsToWindowMenu: aMenu.

	oldTarget _ aMenu defaultTarget.
	aMenu defaultTarget: self.
	aMenu addLine.
	aMenu add: 'rename change set' action: #rename.
	aMenu add: 'make changes go to me' action: #newCurrent.
	aMenu addLine.
	aMenu add: 'file out' action: #fileOut.
	aMenu add: 'browse methods' action: #browseChangeSet.
	aMenu addLine.
	myChangeSet hasPreamble
		ifTrue:
			[aMenu add: 'edit preamble' action: #addPreamble.
			aMenu add: 'remove preamble' action: #removePreamble]
		ifFalse:
			[aMenu add: 'add preamble' action: #addPreamble].

	myChangeSet hasPostscript
		ifTrue:
			[aMenu add: 'edit postscript...' action: #editPostscript.
			aMenu add: 'remove postscript' action: #removePostscript]
		ifFalse:
			[aMenu add: 'add postscript...' action: #editPostscript].
	aMenu addLine.
	
	aMenu add: 'destroy change set' action: #remove.
	aMenu addLine.
	Smalltalk isMorphic ifTrue:
		[aMenu addLine.
		aMenu add: 'what to show...' target: self action: #offerWhatToShowMenu].
	aMenu addLine.
	aMenu add: 'more...' action: #offerShiftedChangeSetMenu.
	aMenu defaultTarget: oldTarget.

	^ aMenu! !


!Preferences class methodsFor: 'misc' stamp: 'nk 8/30/2004 11:05'!
addModelItemsToWindowMenu: aMenu
	super addModelItemsToWindowMenu: aMenu.
	aMenu addLine.
	aMenu add: 'restore default preference settings' target: self action: #chooseInitialSettings.
	aMenu add: 'restore default text highlighting' target: self action: #initializeTextHighlightingParameters! !


!PreferencesPanel methodsFor: 'initialization' stamp: 'nk 8/30/2004 11:07'!
addModelItemsToWindowMenu: aMenu
	"aMenu is being constructed to be presented to the user in response to the user's pressing on the menu widget in the title bar of a morphic SystemWindow.  Here, the model is given the opportunity to add any model-specific items to the menu, whose default target is the SystemWindow itself."

	super addModelItemsToWindowMenu: aMenu.

	true ifTrue: [^ self].  

	"The below are provisionally disenfranchised, because their function is now directly available in the ? category"
	aMenu addLine.
	aMenu add: 'find preference... (f)' target: self action: #findPreference:.
	aMenu add: 'inspect parameters' target: Preferences action: #inspectParameters! !


!TestRunner methodsFor: 'menus' stamp: 'nk 8/30/2004 11:05'!
addModelItemsToWindowMenu: aMenu
	super addModelItemsToWindowMenu: aMenu.

	aMenu addLine.
	self listMenu: aMenu shifted: false.
	aMenu addLine.
	aMenu add: 'log to Transcript' target: self selector: #showResult.
	^aMenu.
! !


!Workspace methodsFor: 'menu commands' stamp: 'nk 8/30/2004 11:04'!
addModelItemsToWindowMenu: aMenu
	"Add model-related items to the supplied window menu"

	super addModelItemsToWindowMenu: aMenu.

	aMenu addLine.
	aMenu add: 'save contents to file...' target: self action: #saveContentsInFile.
	aMenu add: 'append contents of file...' target: self action: #appendContentsOfFile.
	aMenu addLine.
	aMenu 
		addUpdating: #acceptDroppedMorphsWording
		target: self
		action: #toggleDroppingMorphForReference! !



More information about the Squeak-dev mailing list