125
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCCodeTool subclass:#MCPatchBrowser
|
|
4 |
instanceVariableNames:'selection'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
665
|
7 |
category:'SCM-Monticello-UI'
|
125
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCPatchBrowser class methodsFor:'as yet unclassified'!
|
|
12 |
|
|
13 |
forPatch: aPatch
|
|
14 |
^ self new patch: aPatch
|
|
15 |
! !
|
|
16 |
|
|
17 |
!MCPatchBrowser methodsFor:'accessing'!
|
|
18 |
|
|
19 |
items
|
|
20 |
^ items
|
|
21 |
!
|
|
22 |
|
|
23 |
list
|
|
24 |
^ self items collect: [:ea | ea summary]
|
|
25 |
!
|
|
26 |
|
|
27 |
patch: aPatch
|
|
28 |
items _ aPatch operations asSortedCollection
|
|
29 |
! !
|
|
30 |
|
|
31 |
!MCPatchBrowser methodsFor:'as yet unclassified'!
|
|
32 |
|
|
33 |
annotations
|
|
34 |
^selection ifNil: [ super annotations ]
|
|
35 |
ifNotNil: [ selection annotations ]
|
|
36 |
!
|
|
37 |
|
|
38 |
changeSetNameForInstall
|
|
39 |
"Answer the name of the change set into which my selection will be installed.
|
|
40 |
Derive this from my label.
|
|
41 |
If I have no label, use the current change set."
|
|
42 |
|
|
43 |
| tokens |
|
|
44 |
label ifNil: [ ^ChangeSet current name ].
|
|
45 |
tokens := label findTokens: ' '.
|
|
46 |
tokens removeAllFoundIn: { 'changes'. 'between'. 'and' }.
|
|
47 |
(tokens size = 3 and: [ tokens second = '<working' ]) ifTrue: [ ^tokens first, '-to-working' ].
|
|
48 |
tokens size = 2 ifFalse: [ ^'InstalledPatches' ].
|
|
49 |
^'{1}-to-{2}' format: tokens
|
|
50 |
!
|
|
51 |
|
|
52 |
installSelection
|
|
53 |
| loader |
|
|
54 |
selection ifNotNil:
|
|
55 |
[loader _ MCPackageLoader new.
|
|
56 |
selection applyTo: loader.
|
|
57 |
loader loadWithName: self changeSetNameForInstall ]
|
|
58 |
! !
|
|
59 |
|
|
60 |
!MCPatchBrowser methodsFor:'menus'!
|
|
61 |
|
|
62 |
methodListMenu: aMenu
|
|
63 |
selection ifNotNil:
|
|
64 |
[aMenu addList:#(('install' installSelection) -)].
|
|
65 |
super methodListMenu: aMenu.
|
|
66 |
^ aMenu
|
|
67 |
! !
|
|
68 |
|
|
69 |
!MCPatchBrowser methodsFor:'morphic ui'!
|
|
70 |
|
|
71 |
buttonSpecs
|
|
72 |
^ #((Invert invert 'Show the reverse set of changes')
|
|
73 |
(Export export 'Export the changes as a change set'))
|
|
74 |
!
|
|
75 |
|
|
76 |
defaultLabel
|
|
77 |
^ 'Patch Browser'
|
|
78 |
!
|
|
79 |
|
|
80 |
perform: selector orSendTo: otherTarget
|
|
81 |
"Selector was just chosen from a menu by a user. If can respond, then
|
|
82 |
perform it on myself. If not, send it to otherTarget, presumably the
|
|
83 |
editPane from which the menu was invoked."
|
|
84 |
|
|
85 |
(self respondsTo: selector)
|
|
86 |
ifTrue: [^ self perform: selector]
|
|
87 |
ifFalse: [^ otherTarget perform: selector]
|
|
88 |
!
|
|
89 |
|
|
90 |
widgetSpecs
|
|
91 |
Preferences annotationPanes ifFalse: [ ^#(
|
|
92 |
((listMorph:selection:menu: list selection methodListMenu:) (0 0 1 0.4) (0 0 0 0))
|
|
93 |
((textMorph: text) (0 0.4 1 1))
|
|
94 |
) ].
|
|
95 |
|
|
96 |
^ {
|
|
97 |
#((listMorph:selection:menu: list selection methodListMenu: ) (0 0 1 0.4) (0 0 0 0)).
|
|
98 |
{ #(textMorph: annotations). #(0 0.4 1 0.4). { 0. 0. 0. self defaultAnnotationPaneHeight. } }.
|
|
99 |
{ #(textMorph: text). #(0 0.4 1 1). { 0. self defaultAnnotationPaneHeight. 0. 0. } }.
|
|
100 |
}
|
|
101 |
! !
|
|
102 |
|
|
103 |
!MCPatchBrowser methodsFor:'selecting'!
|
|
104 |
|
|
105 |
invert
|
|
106 |
items _ items collect: [:ea | ea inverse].
|
|
107 |
self changed: #list; changed: #text; changed: #selection
|
|
108 |
!
|
|
109 |
|
|
110 |
selection
|
|
111 |
^ selection
|
|
112 |
ifNil: [0]
|
|
113 |
ifNotNil: [self items indexOf: selection]
|
|
114 |
!
|
|
115 |
|
|
116 |
selection: aNumber
|
|
117 |
selection _ aNumber = 0 ifFalse: [self items at: aNumber].
|
|
118 |
self changed: #selection; changed: #text; changed: #annotations
|
|
119 |
! !
|
|
120 |
|
|
121 |
!MCPatchBrowser methodsFor:'subclassResponsibility'!
|
|
122 |
|
|
123 |
selectedClass
|
|
124 |
| definition |
|
|
125 |
selection ifNil: [ ^nil ].
|
|
126 |
(definition _ selection definition) ifNil: [ ^nil ].
|
|
127 |
definition isMethodDefinition ifFalse: [ ^nil ].
|
|
128 |
^Smalltalk at: definition className ifAbsent: [ ]
|
|
129 |
!
|
|
130 |
|
|
131 |
selectedClassOrMetaClass
|
|
132 |
| definition |
|
|
133 |
selection ifNil: [ ^nil ].
|
|
134 |
(definition _ selection definition) ifNil: [ ^nil ].
|
|
135 |
definition isMethodDefinition ifFalse: [ ^nil ].
|
|
136 |
^definition actualClass
|
|
137 |
!
|
|
138 |
|
|
139 |
selectedMessageCategoryName
|
|
140 |
| definition |
|
|
141 |
selection ifNil: [ ^nil ].
|
|
142 |
(definition _ selection definition) ifNil: [ ^nil ].
|
|
143 |
definition isMethodDefinition ifFalse: [ ^nil ].
|
|
144 |
^definition category
|
|
145 |
!
|
|
146 |
|
|
147 |
selectedMessageName
|
|
148 |
| definition |
|
|
149 |
selection ifNil: [ ^nil ].
|
|
150 |
(definition _ selection definition) ifNil: [ ^nil ].
|
|
151 |
definition isMethodDefinition ifFalse: [ ^nil ].
|
|
152 |
^definition selector
|
|
153 |
! !
|
|
154 |
|
|
155 |
!MCPatchBrowser methodsFor:'text'!
|
|
156 |
|
|
157 |
text
|
|
158 |
^ selection ifNil: [''] ifNotNil: [selection source]
|
|
159 |
!
|
|
160 |
|
|
161 |
text: aTextOrString
|
|
162 |
self changed: #text
|
|
163 |
! !
|
|
164 |
|
|
165 |
!MCPatchBrowser class methodsFor:'documentation'!
|
|
166 |
|
|
167 |
version
|
665
|
168 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCPatchBrowser.st,v 1.2 2012-09-11 21:25:27 cg Exp $'
|
125
|
169 |
! !
|