[squeak-dev] The Inbox: WorldMenuRegistry-sbw.2.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Apr 25 15:13:28 UTC 2010


A new version of WorldMenuRegistry was added to project The Inbox:
http://source.squeak.org/inbox/WorldMenuRegistry-sbw.2.mcz

==================== Summary ====================

Name: WorldMenuRegistry-sbw.2
Author: sbw
Time: 25 April 2010, 10:13:23.442 am
UUID: 3163f513-3ac2-44e5-b93e-a5a5451207b1
Ancestors: WorldMenuRegistry-sbw.1

Initial project release for Squeak 4.1.
Includes unit test for new menu registries.
Menu registries now supported:
	Open
	Appearance
	Project
	Help
	Changes

This allows developers to extend any of the listed
World sub-menus without code collision.


==================== Snapshot ====================

SystemOrganization addCategory: #'WorldMenuRegistry-Tests'!

----- Method: TheWorldMenu class>>appearanceMenuRegistry (in category '*WorldMenuRegistry-appearance menu') -----
appearanceMenuRegistry
	(self registry includesKey: #appearance) ifFalse: [self initializeAppearanceMenuRegistry].
	^self registry at: #appearance!

----- Method: TheWorldMenu class>>changesMenuRegistry (in category '*WorldMenuRegistry-changes menu') -----
changesMenuRegistry
	(self registry includesKey: #changes) ifFalse: [self initializeChangesMenuRegistry].
	^self registry at: #changes!

----- Method: TheWorldMenu class>>convertMenuRegistry (in category '*WorldMenuRegistry-private') -----
convertMenuRegistry
	"The registry may already be instantiated as an OrderedCollection of open  
	menu registration entries. Convert it to a properly populated Dictionary  
	object if required."
	| copy |
	OpenMenuRegistry class == Dictionary
		ifFalse: [copy := OpenMenuRegistry copy.
			self initializeMenuRegistry.
			self registry at: #open put: copy]!

----- Method: TheWorldMenu class>>helpMenuRegistry (in category '*WorldMenuRegistry-help menu') -----
helpMenuRegistry
	(self registry includesKey: #help) ifFalse: [self initializeHelpMenuRegistry].
	^self registry at: #help!

----- Method: TheWorldMenu class>>initializeAppearanceMenuRegistry (in category '*WorldMenuRegistry-appearance menu') -----
initializeAppearanceMenuRegistry
	self registry at: #appearance put: OrderedCollection new!

----- Method: TheWorldMenu class>>initializeChangesMenuRegistry (in category '*WorldMenuRegistry-changes menu') -----
initializeChangesMenuRegistry
	self registry at: #changes put: OrderedCollection new!

----- Method: TheWorldMenu class>>initializeHelpMenuRegistry (in category '*WorldMenuRegistry-help menu') -----
initializeHelpMenuRegistry
	self registry at: #help put: OrderedCollection new!

----- Method: TheWorldMenu class>>initializeMenuRegistry (in category '*WorldMenuRegistry-private') -----
initializeMenuRegistry
	"This will wipe out pre-existing entries.  Use with caution."
	"TheWorldMenu initializeMenuRegistry"
	self registry: Dictionary new.
	self
		initializeOpenMenuRegistry;
		initializeAppearanceMenuRegistry;
		initializeProjectMenuRegistry;
		initializeChangesMenuRegistry;
		initializeHelpMenuRegistry!

----- Method: TheWorldMenu class>>initializeOpenMenuRegistry (in category '*WorldMenuRegistry-open menu') -----
initializeOpenMenuRegistry
	self registry at: #open put: OrderedCollection new!

----- Method: TheWorldMenu class>>initializeProjectMenuRegistry (in category '*WorldMenuRegistry-project menu') -----
initializeProjectMenuRegistry
	self registry at: #project put: OrderedCollection new!

----- Method: TheWorldMenu class>>openMenuRegistry (in category '*WorldMenuRegistry-open menu') -----
openMenuRegistry
	(self registry includesKey: #open) ifFalse: [self initializeOpenMenuRegistry].
	^self registry at: #open!

----- Method: TheWorldMenu class>>projectMenuRegistry (in category '*WorldMenuRegistry-project menu') -----
projectMenuRegistry
	(self registry includesKey: #project) ifFalse: [self initializeProjectMenuRegistry].
	^ self registry at: #project!

----- Method: TheWorldMenu class>>registerAppearanceCommand: (in category '*WorldMenuRegistry-appearance menu') -----
registerAppearanceCommand: anArray 
	"The array received should be of form {'A Label String'. {TargetObject.  
	#command} 'A Help String'} ; the final element is optional but if present will 
	be  
	used to supply balloon help for the menu item in the appearance menu.  
	If any previous registration of the same label string is already known, 
	delete the  
	old one."
	self unregisterAppearanceCommand: anArray first.
	self appearanceMenuRegistry addLast: anArray!

----- Method: TheWorldMenu class>>registerChangesCommand: (in category '*WorldMenuRegistry-changes menu') -----
registerChangesCommand: anArray 
	"The array received should be of form {'A Label String'. {TargetObject.  
	#command} 'A Help String'} ; the final element is optional but if present will 
	be  
	used to supply balloon help for the menu item in the changes menu.  
	If any previous registration of the same label string is already known, 
	delete the  
	old one."
	self unregisterChangesCommand: anArray first.
	self changesMenuRegistry addLast: anArray!

----- Method: TheWorldMenu class>>registerHelpCommand: (in category '*WorldMenuRegistry-help menu') -----
registerHelpCommand: anArray 
	"The array received should be of form {'A Label String'. {TargetObject.  
	#command} 'A Help String'} ; the final element is optional but if present will 
	be  
	used to supply balloon help for the menu item in the help menu.  
	If any previous registration of the same label string is already known, 
	delete the  
	old one."
	self unregisterHelpCommand: anArray first.
	self helpMenuRegistry addLast: anArray!

----- Method: TheWorldMenu class>>registerOpenCommand: (in category '*WorldMenuRegistry-open menu') -----
registerOpenCommand: anArray
	"The array received should be of form {'A Label String'. {TargetObject. #command}  'A Help String'} ; the final element is optional but if present will be used to supply balloon help for the menu item in the Open menu.
	If any previous registration of the same label string is already known, delete the old one."

	self unregisterOpenCommand: anArray first.
	self openMenuRegistry addLast: anArray!

----- Method: TheWorldMenu class>>registerProjectCommand: (in category '*WorldMenuRegistry-project menu') -----
registerProjectCommand: anArray 
	"The array received should be of form {'A Label String'. {TargetObject.  
	#command} 'A Help String'} ; the final element is optional but if present will 
	be  used to supply balloon help for the menu item in the project menu.  
	If any previous registration of the same label string is already known, 
	delete the  old one."
	self unregisterProjectCommand: anArray first.
	self projectMenuRegistry addLast: anArray!

----- Method: TheWorldMenu class>>registeredAppearanceCommands (in category '*WorldMenuRegistry-appearance menu') -----
registeredAppearanceCommands
	"Answer the list of dynamic appearance commands, sorted by description"
	^ self appearanceMenuRegistry asArray
		sort: [:a :b | a first asLowercase < b first asLowercase]!

----- Method: TheWorldMenu class>>registeredChangesCommands (in category '*WorldMenuRegistry-changes menu') -----
registeredChangesCommands
	"Answer the list of dynamic changes commands, sorted by description"
	^ self changesMenuRegistry asArray
		sort: [:a :b | a first asLowercase < b first asLowercase]!

----- Method: TheWorldMenu class>>registeredHelpCommands (in category '*WorldMenuRegistry-help menu') -----
registeredHelpCommands
	"Answer the list of dynamic help commands, sorted by description"
	^ self helpMenuRegistry asArray
		sort: [:a :b | a first asLowercase < b first asLowercase]!

----- Method: TheWorldMenu class>>registeredOpenCommands (in category '*WorldMenuRegistry-open menu') -----
registeredOpenCommands
	"Answer the list of dynamic open commands, sorted by description"
	^ self openMenuRegistry asArray
		sort: [:a :b | a first asLowercase < b first asLowercase]!

----- Method: TheWorldMenu class>>registeredProjectCommands (in category '*WorldMenuRegistry-project menu') -----
registeredProjectCommands
	"Answer the list of dynamic project commands, sorted by description"
	^ self projectMenuRegistry asArray
		sort: [:a :b | a first asLowercase < b first asLowercase]!

----- Method: TheWorldMenu class>>registry (in category '*WorldMenuRegistry-accessing') -----
registry
	"Answer the registry of dynamic menu commands"
	"One day we should just rename this class variable to be MenuRegistry. - sbw "
	OpenMenuRegistry == nil
		ifTrue: [self initializeMenuRegistry].
	OpenMenuRegistry class == Dictionary
		ifFalse: [self convertMenuRegistry].
	^ OpenMenuRegistry!

----- Method: TheWorldMenu class>>registry: (in category '*WorldMenuRegistry-accessing') -----
registry: aCollection 
	^ OpenMenuRegistry := aCollection!

----- Method: TheWorldMenu class>>unregisterAppearanceCommand: (in category '*WorldMenuRegistry-appearance menu') -----
unregisterAppearanceCommand: label 
	"Remove the appearance command with the given label from the registry"
	self appearanceMenuRegistry
		removeAllSuchThat: [:e | e first = label]!

----- Method: TheWorldMenu class>>unregisterAppearanceCommandWithReceiver: (in category '*WorldMenuRegistry-appearance menu') -----
unregisterAppearanceCommandWithReceiver: aReceiver 
	"Remove the appearance command with the given object as receiver from the 
	registry "
	self appearanceMenuRegistry
		removeAllSuchThat: [:e | e second first == aReceiver]!

----- Method: TheWorldMenu class>>unregisterChangesCommand: (in category '*WorldMenuRegistry-changes menu') -----
unregisterChangesCommand: label 
	"Remove the changes command with the given label from the registry"
	self changesMenuRegistry
		removeAllSuchThat: [:e | e first = label]!

----- Method: TheWorldMenu class>>unregisterChangesCommandWithReceiver: (in category '*WorldMenuRegistry-changes menu') -----
unregisterChangesCommandWithReceiver: aReceiver 
	"Remove the changes command with the given object as receiver from the 
	registry "
	self changesMenuRegistry
		removeAllSuchThat: [:e | e second first == aReceiver]!

----- Method: TheWorldMenu class>>unregisterHelpCommand: (in category '*WorldMenuRegistry-help menu') -----
unregisterHelpCommand: label 
	"Remove the help command with the given label from the registry"
	self helpMenuRegistry
		removeAllSuchThat: [:e | e first = label]!

----- Method: TheWorldMenu class>>unregisterHelpCommandWithReceiver: (in category '*WorldMenuRegistry-help menu') -----
unregisterHelpCommandWithReceiver: aReceiver 
	"Remove the help command with the given object as receiver from the 
	registry "
	self helpMenuRegistry
		removeAllSuchThat: [:e | e second first == aReceiver]!

----- Method: TheWorldMenu class>>unregisterOpenCommand: (in category '*WorldMenuRegistry-open menu') -----
unregisterOpenCommand: label 
	"Remove the open command with the given label from the registry"
	self openMenuRegistry
		removeAllSuchThat: [:e | e first = label]!

----- Method: TheWorldMenu class>>unregisterOpenCommandWithReceiver: (in category '*WorldMenuRegistry-open menu') -----
unregisterOpenCommandWithReceiver: aReceiver 
	"Remove the open command with the given object as receiver from the 
	registry "
	self openMenuRegistry
		removeAllSuchThat: [:e | e second first == aReceiver]!

----- Method: TheWorldMenu class>>unregisterProjectCommand: (in category '*WorldMenuRegistry-project menu') -----
unregisterProjectCommand: label 
	"Remove the project command with the given label from the registry"
	self projectMenuRegistry
		removeAllSuchThat: [:e | e first = label]!

----- Method: TheWorldMenu class>>unregisterProjectCommandWithReceiver: (in category '*WorldMenuRegistry-project menu') -----
unregisterProjectCommandWithReceiver: aReceiver 
	"Remove the project command with the given object as receiver from the 
	registry "
	self projectMenuRegistry
		removeAllSuchThat: [:e | e second first == aReceiver]!

----- Method: TheWorldMenu>>appearanceMenu (in category '*WorldMenuRegistry') -----
appearanceMenu
	"Build the appearance menu for the world."
	| menu registeredItems |
	menu := self menu: 'appearance...'.
	self fillIn: menu from: self originalAppearanceMenuContents.
	registeredItems := self class registeredAppearanceCommands.
	registeredItems notEmpty ifTrue: [
		menu addLine.
		self fillIn: menu from: registeredItems].
	^ menu
!

----- Method: TheWorldMenu>>changesMenu (in category '*WorldMenuRegistry') -----
changesMenu
        "Build the changes menu for the world."
	| menu registeredItems |
	menu := self menu: 'changes...'.
	self fillIn: menu from: self originalChangesMenuContents.
	registeredItems := self class registeredChangesCommands.
	registeredItems notEmpty ifTrue: [
		menu addLine.
		self fillIn: menu from: registeredItems].
	^ menu!

----- Method: TheWorldMenu>>helpMenu (in category '*WorldMenuRegistry') -----
helpMenu
        "Build the help menu for the world."
        |  menu registeredItems |

  	menu := self menu: 'help...'.

        self fillIn: menu from:
        {
                {'about this system...'. {SmalltalkImage current. #aboutThisSystem}. 'current version information.'}.
                {'update code from server'. {Utilities. #updateFromServer}. 'load latest code updates via the internet'}.
                {'preferences...'. {self. #openPreferencesBrowser}. 'view and change various options.'}.
			 {'set language...' . {Project. #chooseNaturalLanguage}. 'choose the language in which tiles should be displayed.'} .
                nil.
               {'command-key help'. { Utilities . #openCommandKeyHelp}. 'summary of keyboard shortcuts.'}
	}.

	self addGestureHelpItemsTo: menu.

	self fillIn: menu from:
	{
                {'world menu help'. { self . #worldMenuHelp}. 'helps find menu items buried in submenus.'}.
                        "{'info about flaps' . { Utilities . #explainFlaps}. 'describes how to enable and use flaps.'}."
                {'font size summary' . { TextStyle . #fontSizeSummary}.  'summary of names and sizes of available fonts.'}.
                {'useful expressions' . { Utilities . #openStandardWorkspace}. 'a window full of useful expressions.'}.
			 {'annotation setup...' . { Preferences . #editAnnotations}. 'Click here to get a little window that will allow you to specify which types of annotations, in which order, you wish to see in the annotation panes of browsers and other tools'}.
			nil.
                {'graphical imports' . { Imports default . #viewImages}.  'view the global repository called ImageImports; you can easily import external graphics into ImageImports via the FileList'}.
                {'standard graphics library' . { ScriptingSystem . #inspectFormDictionary}.  'lets you view and change the system''s standard library of graphics.'}.
                nil.
                {'telemorphic...' . {self. #remoteDo}.  'commands for doing multi-machine "telemorphic" experiments'}.
                {#soundEnablingString . { Preferences . #toggleSoundEnabling}. 'turning sound off will completely disable Squeak''s use of sound.'}.
                nil.

                {'set author initials...' . { Utilities . #setAuthorInitials }. 'supply initials to be used to identify the author of code and other content.'}.
                {'vm statistics' . { self . #vmStatistics}.  'obtain some intriguing data about the vm.'}.
			  nil.
			  {'purge undo records' . { CommandHistory . #resetAllHistory }. 'save space by removing all the undo information remembered in all projects.'}.
                {'space left' . { self . #garbageCollect}. 'perform a full garbage-collection and report how many bytes of space remain in the image.'}.
        }.

	registeredItems := self class registeredHelpCommands.
	registeredItems notEmpty ifTrue: [
		menu addLine.
		self fillIn: menu from: registeredItems].

	^menu

!

----- Method: TheWorldMenu>>originalAppearanceMenuContents (in category '*WorldMenuRegistry') -----
originalAppearanceMenuContents
	^{
		{'preferences...' . { self . #openPreferencesBrowser} . 'Opens a "Preferences Browser" which allows you to alter many settings' } .
		{'choose theme...' . { Preferences . #offerThemesMenu} . 'Presents you with a menu of themes; each item''s balloon-help will tell you about the theme.  If you choose a theme, many different preferences that come along with that theme are set at the same time; you can subsequently change any settings by using a Preferences Panel'} .
		nil .
		{'system fonts...' . { self . #standardFontDo} . 'Choose the standard fonts to use for code, lists, menus, window titles, etc.'}.
		{'text highlight color...' . { Preferences . #chooseTextHighlightColor} . 'Choose which color should be used for text highlighting in Morphic.'}.
		{'insertion point color...' . { Preferences . #chooseInsertionPointColor} . 'Choose which color to use for the text insertion point in Morphic.'}.
		{'keyboard focus color' . { Preferences . #chooseKeyboardFocusColor} . 'Choose which color to use for highlighting which pane has the keyboard focus'}.
		nil.
		{#menuColorString . { Preferences . #toggleMenuColorPolicy} . 'Governs whether menu colors should be derived from the desktop color.'}.
		{#roundedCornersString . { Preferences . #toggleRoundedCorners} . 'Governs whether morphic windows and menus should have rounded corners.'}.
		nil.
		{'full screen on' . { Project current . #fullScreenOn} . 'puts you in full-screen mode, if not already there.'}.
		{'full screen off' . { Project current . #fullScreenOff} . 'if in full-screen mode, takes you out of it.'}.
		nil.
		{'set display depth...' . {self. #setDisplayDepth} . 'choose how many bits per pixel.'}.
		{'set desktop color...' . {self. #changeBackgroundColor} . 'choose a uniform color to use as desktop background.'}.
		{'set gradient color...' . {self. #setGradientColor} . 'choose second color to use as gradient for desktop background.'}.
		{'use texture background' . { #myWorld . #setStandardTexture} . 'apply a graph-paper-like texture background to the desktop.'}.
		nil.
		{'clear turtle trails from desktop' . { #myWorld . #clearTurtleTrails} . 'remove any pigment laid down on the desktop by objects moving with their pens down.'}.
		{'pen-trail arrowhead size...' . { Preferences. #setArrowheads} . 'choose the shape to be used in arrowheads on pen trails.'}.
	}!

----- Method: TheWorldMenu>>originalChangesMenuContents (in category '*WorldMenuRegistry') -----
originalChangesMenuContents
	^{

                { 'file out current change set' . { ChangeSet current . #verboseFileOut}.
                                'Write the current change set out to a file whose name reflects the change set name and the current date & time.'}.
                { 'create new change set...' . { ChangeSet . #newChangeSet}. 'Create a new change set and make it the current one.'}.
                { 'browse changed methods' . { ChangeSet  . #browseChangedMessages}.  'Open a message-list browser showing all methods in the current change set'}.
                { 'check change set for slips' . { self  . #lookForSlips}.
                                'Check the current change set for halts, references to the Transcript, etc., and if any such thing is found, open up a message-list browser detailing all possible slips.'}.

                nil.
                { 'simple change sorter' . {self. #openChangeSorter1}.  'Open a 3-paned changed-set viewing tool'}.
                { 'dual change sorter' . {self. #openChangeSorter2}.
                                'Open a change sorter that shows you two change sets at a time, making it easy to copy and move methods and classes between them.'}.
               { 'find a change sorter (C)' . { #myWorld . #findAChangeSorter: }. 'Brings an open change sorter to the front, creating one if necessary, and makes it the active window'}.
                nil.
                { 'browse recent submissions' . { Utilities . #browseRecentSubmissions}.
                                'Open a new recent-submissions browser.  A recent-submissions browser is a message-list browser that shows the most recent methods that have been submitted.  If you submit changes within that browser, it will keep up-to-date, always showing the most recent submissions.'}.

                { 'find recent submissions (R)' . { #myWorld . #openRecentSubmissionsBrowser:}.
                                'Make an open recent-submissions browser be the front-window, expanding a collapsed one or creating a new one if necessary.  A recent-submissions browser is a message-list browser that shows the most recent methods that have been submitted, latest first.  If you submit changes within that browser, it will keep up-to-date, always showing the most recent submissions at the top of the browser.'}.

			nil.
                { 'recently logged changes...' . { self . #browseRecentLog}.'Open a change-list browser on the latter part of the changes log.  You can use this browser to recover logged changes which were not saved in your image, in the event of a crash or other interruption.'}.

                { 'recent log file...' . { Smalltalk . #writeRecentToFile}.
                                'Create a file holding the logged changes (going as far back as you wish), and open a window on that file.'}.

                nil.
                { 'save world as morph file' . {self. #saveWorldInFile}. 'Save a file that, when reloaded, reconstitutes the current World.'}.
                nil.
        }!

----- Method: TheWorldMenu>>projectMenu (in category '*WorldMenuRegistry') -----
projectMenu
	"Build the project menu for the world."
	| menu registeredItems |
	menu := self menu: 'projects...'.
	self fillIn: menu from: { 
		{ 'save on server (also makes a local copy)' . { #myProject . #storeOnServer } }.
		{ 'save to a different server' . { #myProject . #saveAs } }.
		{ 'save project on local file only' . { #myWorld . #saveOnFile } }.
		{ 'see if server version is more recent...' . { #myProject . #loadFromServer } }.
		{ 'load project from file...' . { self . #loadProject } }.
		nil.
	}.

	registeredItems := self class registeredProjectCommands.
	registeredItems notEmpty ifTrue: [
		menu addLine.
		self fillIn: menu from: registeredItems].

	self mvcProjectsAllowed ifTrue: [
		self fillIn: menu from: {
			{ 'create new mvc project'. { self . #openMVCProject } }.
		}
	].
	self fillIn: menu from: { 
		{ 'create new morphic project' . { self . #openMorphicProject } }.
		nil.
		{ 'go to previous project' . { Project . #returnToPreviousProject } }.
		{ 'go to next project' . { Project . #advanceToNextProject } }.
		{ 'jump to project...' . { #myWorld . #jumpToProject } }.
	}.
	Preferences simpleMenus ifFalse: [
		self fillIn: menu from: { 
			nil.
			{ 'save for future revert' . { #myProject . #saveForRevert } }.
			{ 'revert to saved copy' . { #myProject . #revert } }.
		}.
	].
	^ menu!

TestCase subclass: #TheWorldMenuTest
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'WorldMenuRegistry-Tests'!

----- Method: TheWorldMenuTest>>testAddAndRemoveRegisteredAppearanceMenuItem (in category 'testing') -----
testAddAndRemoveRegisteredAppearanceMenuItem

	| menuLabel |
	self should: [TheWorldMenu registry includesKey: #appearance].

	menuLabel := 'test of a new appearance menu item'.
	TheWorldMenu registerAppearanceCommand: {
		menuLabel. 
		{TheWorldMenuTest. #yourself}.  
		'A help string for my new appearance menu entry.'
		}.
	self should: [TheWorldMenu new appearanceMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterAppearanceCommand: menuLabel.
	self shouldnt: [TheWorldMenu new appearanceMenu allWordings includes: menuLabel].

	menuLabel := 'test of a new appearance menu again'.
	TheWorldMenu registerAppearanceCommand: {menuLabel. {TheWorldMenuTest. #yourself}}.
	self should: [TheWorldMenu new appearanceMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterAppearanceCommandWithReceiver: TheWorldMenuTest.
	self shouldnt: [TheWorldMenu new appearanceMenu allWordings includes: menuLabel].
!

----- Method: TheWorldMenuTest>>testAddAndRemoveRegisteredChangesMenuItem (in category 'testing') -----
testAddAndRemoveRegisteredChangesMenuItem

	| menuLabel |
	self should: [TheWorldMenu registry includesKey: #changes].

	menuLabel := 'test of a new changes menu item'.
	TheWorldMenu registerChangesCommand: {
		menuLabel. 
		{TheWorldMenuTest. #yourself}.  
		'A help string for my new changes menu entry.'
		}.
	self should: [TheWorldMenu new changesMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterChangesCommand: menuLabel.
	self shouldnt: [TheWorldMenu new changesMenu allWordings includes: menuLabel].

	menuLabel := 'test of a new changes menu again'.
	TheWorldMenu registerChangesCommand: {menuLabel. {TheWorldMenuTest. #yourself}}.
	self should: [TheWorldMenu new changesMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterChangesCommandWithReceiver: TheWorldMenuTest.
	self shouldnt: [TheWorldMenu new changesMenu allWordings includes: menuLabel].
!

----- Method: TheWorldMenuTest>>testAddAndRemoveRegisteredHelpMenuItem (in category 'testing') -----
testAddAndRemoveRegisteredHelpMenuItem

	| menuLabel |
	self should: [TheWorldMenu registry includesKey: #help].

	menuLabel := 'test of a new help menu item'.
	TheWorldMenu registerHelpCommand: {
		menuLabel. 
		{TheWorldMenuTest. #yourself}.  
		'A help string for my new help menu entry.'
		}.
	self should: [TheWorldMenu new helpMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterHelpCommand: menuLabel.
	self shouldnt: [TheWorldMenu new helpMenu allWordings includes: menuLabel].

	menuLabel := 'test of a new help menu again'.
	TheWorldMenu registerHelpCommand: {menuLabel. {TheWorldMenuTest. #yourself}}.
	self should: [TheWorldMenu new helpMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterHelpCommandWithReceiver: TheWorldMenuTest.
	self shouldnt: [TheWorldMenu new helpMenu allWordings includes: menuLabel].
!

----- Method: TheWorldMenuTest>>testAddAndRemoveRegisteredOpenMenuItem (in category 'testing') -----
testAddAndRemoveRegisteredOpenMenuItem

	| menuLabel |
	self should: [TheWorldMenu registry includesKey: #open].

	menuLabel := 'test of a new open menu'.
	TheWorldMenu registerOpenCommand: {menuLabel. {TheWorldMenuTest. #yourself}.  'A help string for my new open menu entry.'}.
	self should: [TheWorldMenu new openMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterOpenCommand: menuLabel.
	self shouldnt: [TheWorldMenu new openMenu allWordings includes: menuLabel].

	menuLabel := 'test of a new open menu again'.
	TheWorldMenu registerOpenCommand: {menuLabel. {TheWorldMenuTest. #yourself}}.
	self should: [TheWorldMenu new openMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterOpenCommandWithReceiver: TheWorldMenuTest.
	self shouldnt: [TheWorldMenu new openMenu allWordings includes: menuLabel].
!

----- Method: TheWorldMenuTest>>testAddAndRemoveRegisteredProjectMenuItem (in category 'testing') -----
testAddAndRemoveRegisteredProjectMenuItem

	| menuLabel |
	self should: [TheWorldMenu registry includesKey: #project].

	menuLabel := 'test of a new appearance menu item'.
	TheWorldMenu registerProjectCommand: {
		menuLabel. 
		{TheWorldMenuTest. #yourself}.  
		'A help string for my new project menu entry.'
		}.
	self should: [TheWorldMenu new projectMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterProjectCommand: menuLabel.
	self shouldnt: [TheWorldMenu new projectMenu allWordings includes: menuLabel].

	menuLabel := 'test of a new project menu again'.
	TheWorldMenu registerProjectCommand: {menuLabel. {TheWorldMenuTest. #yourself}}.
	self should: [TheWorldMenu new projectMenu allWordings includes: menuLabel].
	TheWorldMenu unregisterProjectCommandWithReceiver: TheWorldMenuTest.
	self shouldnt: [TheWorldMenu new projectMenu allWordings includes: menuLabel].
!




More information about the Squeak-dev mailing list