David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.174.mcz ==================== Summary ==================== Name: System-dtl.174 Author: dtl Time: 25 November 2009, 2:19:34 am UUID: 187d4597-8be9-4eca-b2ce-d82bb3130def Ancestors: System-ar.173 Move project navigation and menu methods from class side of Project to instance methods. Replace #isMorphic logic with dispatch to appropriate project instances for MVC and Morphic conditions. =============== Diff against System-ar.173 =============== Item was changed: ----- Method: Project class>>jumpToProject (in category 'utilities') ----- jumpToProject "Project jumpToProject" "Present a list of potential projects and enter the one selected." + self current jumpToProject! - self current class jumpToProject! Item was added: + ----- Method: Project>>addItem:toMenu:selection:project: (in category 'utilities') ----- + addItem: item toMenu: menu selection: action project: aProject + "Request aProject to add a menu item to represent it in the menu" + + ^ aProject addItem: item toMenu: menu selection: action requestor: self! Item was added: + ----- Method: Project>>buildJumpToMenu: (in category 'utilities') ----- + buildJumpToMenu: menu + "Make the supplied menu offer a list of potential projects, consisting of: + * The previous-project chain + * The next project, if any + * The parent project, if any + * All projects, alphabetically or hierarchically" + + | prev listed i next toAdd | + listed := OrderedCollection with: self. + i := 0. + + "The previous Project chain" + prev := self previousProject. + [(prev ~~ nil and: [(listed includes: prev) not])] whileTrue: + [i := i + 1. + listed add: prev. + self addItem: prev name , ' (', ('back {1}' translated format:{i} ), ')' + toMenu: menu + selection: ('%back' , i printString) + project: prev. + prev := prev previousProject]. + i > 0 ifTrue: [menu addLine]. + + + "Then the next Project" + (((next := self nextProject) ~~ nil) and: [(listed includes: next) not]) ifTrue: + [self addItem: (next name, ' (', ('forward {1}' translated format:{1}), ')') + toMenu: menu + selection: next name + project: next]. + next ~~ nil ifTrue: [menu addLine]. + + "Then the parent" + self isTopProject ifFalse: + [self addItem: self parent name , ' (', 'parent' translated, ')' + toMenu: menu + selection: #parent + project: self parent. + menu addLine]. + + "Finally all the projects, in hierarchical or alphabetical order:" + (Preferences alphabeticalProjectMenu + ifTrue: + [Project allNamesAndProjects] + ifFalse: + [Project hierarchyOfNamesAndProjects]) do: + + [:aPair | + toAdd := aPair last isCurrentProject + ifTrue: + [aPair first, ' (', 'current' translated, ')'] + ifFalse: + [aPair first]. + self addItem: toAdd + toMenu: menu + selection: aPair first + project: aPair last]. + ^ menu! Item was added: + ----- Method: Project>>jumpToProject (in category 'utilities') ----- + jumpToProject + "Present a list of potential projects and enter the one selected." + + "Project current jumpToProject" + + self subclassResponsibility! Item was added: + ----- Method: Project>>addItem:toMenu:selection:color:thumbnail: (in category 'utilities') ----- + addItem: item toMenu: menu selection: action color: aColor thumbnail: aForm + "Add menu item representing the sender to a menu" + + self subclassResponsibility! Item was added: + ----- Method: Project>>jumpToSelection: (in category 'utilities') ----- + jumpToSelection: selection + "Enter the project corresponding to this menu selection." + + "Project jumpToProject" + | nBack prev pr | + selection ifNil: [^ self]. + (selection beginsWith: '%back') ifTrue: + [nBack := (selection copyFrom: 6 to: selection size) asNumber. + prev := CurrentProject previousProject. + 1 to: nBack-1 do: + [:i | prev ifNotNil: [prev := prev previousProject]]. + prev ifNotNil: [prev enter: true revert: false saveForRevert: false]]. + selection = #parent ifTrue: + [CurrentProject parent enter: false revert: false saveForRevert: false. + ^ self]. + (pr := Project namedWithDepth: selection) ifNil: [^ self]. + pr enter: false revert: false saveForRevert: false! Item was changed: ----- Method: Project class>>jumpToSelection: (in category 'utilities') ----- jumpToSelection: selection "Enter the project corresponding to this menu selection." + + self flag: #toRemove. "Project current jumpToProject" + ^ self current jumpToSelection: selection + ! - - "Project jumpToProject" - | nBack prev pr | - selection ifNil: [^ self]. - (selection beginsWith: '%back') ifTrue: - [nBack := (selection copyFrom: 6 to: selection size) asNumber. - prev := CurrentProject previousProject. - 1 to: nBack-1 do: - [:i | prev ifNotNil: [prev := prev previousProject]]. - prev ifNotNil: [prev enter: true revert: false saveForRevert: false]]. - selection = #parent ifTrue: - [CurrentProject parent enter: false revert: false saveForRevert: false. - ^ self]. - (pr := Project namedWithDepth: selection) ifNil: [^ self]. - pr enter: false revert: false saveForRevert: false! Item was added: + ----- Method: Project>>addItem:toMenu:selection:requestor: (in category 'utilities') ----- + addItem: item toMenu: menu selection: action requestor: requestingProject + "Add a menu item representing this project to a menu being created by requestingProject" + + self subclassResponsibility! Item was removed: - ----- Method: Project class>>addItem:toMenu:selection:project: (in category 'utilities') ----- - addItem: item toMenu: menu selection: action project: aProject - | color | - color := aProject isMorphic - ifTrue: [aProject world isInMemory - ifTrue: [Color black] - ifFalse: [Color brown]] - ifFalse: [aProject world isInMemory - ifTrue: [Color veryVeryDarkGray] - ifFalse: [Color blue]]. - (menu isKindOf: MenuMorph) - ifTrue: [| thumbnail | - menu - add: item - selector: #jumpToSelection: - argument: action. - menu lastItem color: color. - thumbnail := aProject thumbnail. - thumbnail isNil - ifFalse: [menu lastItem - icon: (thumbnail scaledIntoFormOfSize: (Preferences tinyDisplay ifTrue: [16] ifFalse: [28]))]] - ifFalse: [menu add: item action: action]! Item was removed: - ----- Method: Project class>>buildJumpToMenu: (in category 'utilities') ----- - buildJumpToMenu: menu - "Make the supplied menu offer a list of potential projects, consisting of: - * The previous-project chain - * The next project, if any - * The parent project, if any - * All projects, alphabetically or hierarchically" - - | prev listed i next toAdd | - listed := OrderedCollection with: CurrentProject. - i := 0. - - "The previous Project chain" - prev := CurrentProject previousProject. - [(prev ~~ nil and: [(listed includes: prev) not])] whileTrue: - [i := i + 1. - listed add: prev. - self addItem: prev name , ' (', ('back {1}' translated format:{i} ), ')' - toMenu: menu - selection: ('%back' , i printString) - project: prev. - prev := prev previousProject]. - i > 0 ifTrue: [menu addLine]. - - - "Then the next Project" - (((next := CurrentProject nextProject) ~~ nil) and: [(listed includes: next) not]) ifTrue: - [self addItem: (next name, ' (', ('forward {1}' translated format:{1}), ')') - toMenu: menu - selection: next name - project: next]. - next ~~ nil ifTrue: [menu addLine]. - - "Then the parent" - CurrentProject isTopProject ifFalse: - [self addItem: CurrentProject parent name , ' (', 'parent' translated, ')' - toMenu: menu - selection: #parent - project: CurrentProject parent. - menu addLine]. - - "Finally all the projects, in hierarchical or alphabetical order:" - (Preferences alphabeticalProjectMenu - ifTrue: - [Project allNamesAndProjects] - ifFalse: - [Project hierarchyOfNamesAndProjects]) do: - - [:aPair | - toAdd := aPair last isCurrentProject - ifTrue: - [aPair first, ' (', 'current' translated, ')'] - ifFalse: - [aPair first]. - self addItem: toAdd - toMenu: menu - selection: aPair first - project: aPair last]. - ^ menu! Item was removed: - ----- Method: Project class>>addItem:toMenu:selection: (in category 'utilities') ----- - addItem: item toMenu: menu selection: action - (menu isKindOf: MenuMorph) - ifTrue: [menu add: item selector: #jumpToSelection: argument: action] - ifFalse: [menu add: item action: action]! |
Free forum by Nabble | Edit this page |