[Pkg] The Trunk: Tools-topa.636.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Oct 7 22:14:57 UTC 2015
Tobias Pape uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-topa.636.mcz
==================== Summary ====================
Name: Tools-topa.636
Author: topa
Time: 8 October 2015, 12:14:44.631 am
UUID: 50636bc8-21a6-44f1-8c0e-000dd2fc029c
Ancestors: Tools-mt.635
Pull up menu building to Model so that also non-StringHolder-Tools can benefit
=============== Diff against Tools-mt.635 ===============
Item was added:
+ ----- Method: Model>>buildMenu:withBuilders:shifted: (in category '*Tools-pluggable menus') -----
+ buildMenu: aMenu withBuilders: builders shifted: aBoolean
+ " We let every builder modify the menu.
+ The builder should indicate whether to abort by returning nil."
+ | menu |
+ menu := aMenu.
+ builders do: [:builder |
+ menu := self perform: builder method selector withEnoughArguments: { menu . aBoolean }.
+ menu ifNil: [^ aMenu]].
+ ^ menu
+ !
Item was added:
+ ----- Method: Model>>menu:for: (in category '*Tools-pluggable menus') -----
+ menu: aMenu for: aMenuSymbolOrCollection
+
+ ^ self menu: aMenu for: aMenuSymbolOrCollection shifted: false!
Item was added:
+ ----- Method: Model>>menu:for:shifted: (in category '*Tools-pluggable menus') -----
+ menu: aMenu for: aMenuSymbolOrCollection shifted: aBoolean
+
+ | builders |
+ builders := self menuBuildersFor: aMenuSymbolOrCollection in: self class shifted: aBoolean.
+ builders := self sortMenuBuilders: builders.
+ ^ self buildMenu: aMenu withBuilders: builders shifted: aBoolean
+ !
Item was added:
+ ----- Method: Model>>menuBuildersFor:in:shifted: (in category '*Tools-pluggable menus') -----
+ menuBuildersFor: someMenus in: aClass shifted: aBoolean
+ "Find all builders but reject the ones not matching the shift state "
+ | pragmas |
+ pragmas := (self menuPragmasFor: someMenus in: aClass) .
+ ^ aBoolean
+ ifTrue: [pragmas reject: [:builder | builder arguments = #(false)]]
+ ifFalse: [pragmas reject: [:builder | builder arguments = #(true)]].
+ !
Item was added:
+ ----- Method: Model>>menuPragmasFor:in: (in category '*Tools-pluggable menus') -----
+ menuPragmasFor: aMenuSymbolOrCollection in: aClass
+
+ ^ aMenuSymbolOrCollection isCollection
+ ifTrue: [aMenuSymbolOrCollection gather: [:aMenuSymbol |
+ Pragma allNamed: aMenuSymbol from: aClass to: Object]]
+ ifFalse: [Pragma allNamed: aMenuSymbolOrCollection from: aClass to: Object]!
Item was added:
+ ----- Method: Model>>methodMenuPriority: (in category '*Tools-pluggable menus') -----
+ methodMenuPriority: aMethod
+ "The pirority of a menu method indicated by a <menuPriority: ...> pragma.
+ Defaults to 500"
+ ^ (aMethod pragmas detect: [:p | p keyword == #menuPriority: ] ifNone: [^ 500])
+ argumentAt: 1
+ !
Item was added:
+ ----- Method: Model>>sortMenuBuilders: (in category '*Tools-pluggable menus') -----
+ sortMenuBuilders: builders
+ " Sort them by
+ 1. Priority (default 500)
+ 2. selector name
+ "
+ ^ builders sorted: [:a :b |
+ | ma mb pa pb |
+ ma := a method.
+ mb := b method.
+ pa := self methodMenuPriority: ma.
+ pb := self methodMenuPriority: mb.
+ pa < pb or: [pa = pb and: [ma selector <= mb selector]]]
+ !
Item was removed:
- ----- Method: StringHolder>>buildMenu:withBuilders:shifted: (in category '*Tools-pluggable menus') -----
- buildMenu: aMenu withBuilders: builders shifted: aBoolean
- " We let every builder modify the menu.
- The builder should indicate whether to abort by returning nil."
- | menu |
- menu := aMenu.
- builders do: [:builder |
- menu := self perform: builder method selector withEnoughArguments: { menu . aBoolean }.
- menu ifNil: [^ aMenu]].
- ^ menu
- !
Item was removed:
- ----- Method: StringHolder>>menu:for: (in category '*Tools-pluggable menus') -----
- menu: aMenu for: aMenuSymbolOrCollection
-
- ^ self menu: aMenu for: aMenuSymbolOrCollection shifted: false!
Item was removed:
- ----- Method: StringHolder>>menu:for:shifted: (in category '*Tools-pluggable menus') -----
- menu: aMenu for: aMenuSymbolOrCollection shifted: aBoolean
-
- | builders |
- builders := self menuBuildersFor: aMenuSymbolOrCollection in: self class shifted: aBoolean.
- builders := self sortMenuBuilders: builders.
- ^ self buildMenu: aMenu withBuilders: builders shifted: aBoolean
- !
Item was removed:
- ----- Method: StringHolder>>menuBuildersFor:in:shifted: (in category '*Tools-pluggable menus') -----
- menuBuildersFor: someMenus in: aClass shifted: aBoolean
- "Find all builders but reject the ones not matching the shift state "
- | pragmas |
- pragmas := (self menuPragmasFor: someMenus in: aClass) .
- ^ aBoolean
- ifTrue: [pragmas reject: [:builder | builder arguments = #(false)]]
- ifFalse: [pragmas reject: [:builder | builder arguments = #(true)]].
- !
Item was removed:
- ----- Method: StringHolder>>menuPragmasFor:in: (in category '*Tools-pluggable menus') -----
- menuPragmasFor: aMenuSymbolOrCollection in: aClass
-
- ^ aMenuSymbolOrCollection isCollection
- ifTrue: [aMenuSymbolOrCollection gather: [:aMenuSymbol |
- Pragma allNamed: aMenuSymbol from: aClass to: Object]]
- ifFalse: [Pragma allNamed: aMenuSymbolOrCollection from: aClass to: Object]!
Item was removed:
- ----- Method: StringHolder>>methodMenuPriority: (in category '*Tools-pluggable menus') -----
- methodMenuPriority: aMethod
- "The pirority of a menu method indicated by a <menuPriority: ...> pragma.
- Defaults to 500"
- ^ (aMethod pragmas detect: [:p | p keyword == #menuPriority: ] ifNone: [^ 500])
- argumentAt: 1
- !
Item was removed:
- ----- Method: StringHolder>>sortMenuBuilders: (in category '*Tools-pluggable menus') -----
- sortMenuBuilders: builders
- " Sort them by
- 1. Priority (default 500)
- 2. selector name
- "
- ^ builders sorted: [:a :b |
- | ma mb pa pb |
- ma := a method.
- mb := b method.
- pa := self methodMenuPriority: ma.
- pb := self methodMenuPriority: mb.
- pa < pb or: [pa = pb and: [ma selector <= mb selector]]]
- !
More information about the Packages
mailing list