10016
|
1 |
"
|
10098
|
2 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
|
|
3 |
Copyright (c) 2009-2010 eXept Software AG
|
10016
|
4 |
|
10098
|
5 |
Permission is hereby granted, free of charge, to any person
|
|
6 |
obtaining a copy of this software and associated documentation
|
|
7 |
files (the 'Software'), to deal in the Software without
|
|
8 |
restriction, including without limitation the rights to use,
|
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10 |
copies of the Software, and to permit persons to whom the
|
|
11 |
Software is furnished to do so, subject to the following
|
|
12 |
conditions:
|
|
13 |
|
|
14 |
The above copyright notice and this permission notice shall be
|
|
15 |
included in all copies or substantial portions of the Software.
|
|
16 |
|
|
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24 |
OTHER DEALINGS IN THE SOFTWARE.
|
10016
|
25 |
"
|
|
26 |
"{ Package: 'stx:libtool' }"
|
|
27 |
|
|
28 |
"{ NameSpace: Tools }"
|
|
29 |
|
|
30 |
SimpleDialog subclass:#ProjectLoader
|
|
31 |
instanceVariableNames:'projectList'
|
|
32 |
classVariableNames:''
|
|
33 |
poolDictionaries:''
|
|
34 |
category:'Interface-Tools'
|
|
35 |
!
|
|
36 |
|
|
37 |
!ProjectLoader class methodsFor:'documentation'!
|
|
38 |
|
|
39 |
copyright
|
|
40 |
"
|
10098
|
41 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
|
|
42 |
Copyright (c) 2009-2010 eXept Software AG
|
|
43 |
|
|
44 |
Permission is hereby granted, free of charge, to any person
|
|
45 |
obtaining a copy of this software and associated documentation
|
|
46 |
files (the 'Software'), to deal in the Software without
|
|
47 |
restriction, including without limitation the rights to use,
|
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
49 |
copies of the Software, and to permit persons to whom the
|
|
50 |
Software is furnished to do so, subject to the following
|
|
51 |
conditions:
|
10016
|
52 |
|
10098
|
53 |
The above copyright notice and this permission notice shall be
|
|
54 |
included in all copies or substantial portions of the Software.
|
|
55 |
|
|
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
63 |
OTHER DEALINGS IN THE SOFTWARE.
|
10016
|
64 |
"
|
|
65 |
! !
|
|
66 |
|
|
67 |
!ProjectLoader class methodsFor:'initialization'!
|
|
68 |
|
|
69 |
initialize
|
|
70 |
|
|
71 |
| item |
|
|
72 |
item := (MenuItem label:'Load project')
|
|
73 |
nameKey:'LoadProject';
|
|
74 |
value:[(Smalltalk at: self fullName asSymbol) open].
|
|
75 |
|
|
76 |
NewLauncher
|
|
77 |
addMenuItem: item
|
|
78 |
from: nil
|
|
79 |
in: 'menu'
|
|
80 |
position: #after
|
|
81 |
space: true.
|
|
82 |
|
|
83 |
"
|
|
84 |
self initialize
|
|
85 |
"
|
|
86 |
|
|
87 |
"Created: / 22-11-2008 / 09:58:03 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
88 |
"Modified: / 26-11-2008 / 10:00:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
89 |
! !
|
|
90 |
|
|
91 |
!ProjectLoader class methodsFor:'accessing'!
|
|
92 |
|
|
93 |
projectSites
|
|
94 |
|
|
95 |
^UserPreferences current projectLoaderProjectSites
|
|
96 |
|
|
97 |
"Created: / 22-11-2008 / 09:13:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
98 |
"Modified: / 26-11-2008 / 10:13:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
99 |
! !
|
|
100 |
|
|
101 |
!ProjectLoader class methodsFor:'defaults'!
|
|
102 |
|
|
103 |
defaultProjectFile
|
|
104 |
^ (Filename homeDirectory construct:'.smalltalk') construct:'projects.rc'
|
|
105 |
|
|
106 |
"Created: / 26-11-2008 / 10:15:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
107 |
!
|
|
108 |
|
|
109 |
defaultProjects
|
|
110 |
|
|
111 |
^#(
|
|
112 |
(
|
|
113 |
'CellStore'
|
|
114 |
('cvut:fel/cellstore/core')
|
|
115 |
)
|
|
116 |
|
|
117 |
(
|
|
118 |
'Perseus'
|
|
119 |
('cvut:fel/perseus/core'
|
|
120 |
'cvut:fel/perseus/core_ui'
|
|
121 |
'cvut:fel/perseus/smallscript'
|
|
122 |
'cvut:fel/perseus/pascal'
|
|
123 |
'stx:goodies/xmlsuite/xquery')
|
|
124 |
)
|
|
125 |
|
|
126 |
(
|
|
127 |
'IZAR'
|
|
128 |
('cvut:fel/izar')
|
|
129 |
)
|
|
130 |
)
|
|
131 |
|
|
132 |
"Created: / 26-11-2008 / 10:06:14 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
133 |
! !
|
|
134 |
|
|
135 |
!ProjectLoader class methodsFor:'interface specs'!
|
|
136 |
|
|
137 |
windowSpec
|
|
138 |
"This resource specification was automatically generated
|
|
139 |
by the UIPainter of ST/X."
|
|
140 |
|
|
141 |
"Do not manually edit this!! If it is corrupted,
|
|
142 |
the UIPainter may not be able to read the specification."
|
|
143 |
|
|
144 |
"
|
|
145 |
UIPainter new openOnClass:Tools::ProjectLoadDialog andSelector:#windowSpec
|
|
146 |
Tools::ProjectLoadDialog new openInterface:#windowSpec
|
|
147 |
Tools::ProjectLoadDialog open
|
|
148 |
"
|
|
149 |
|
|
150 |
<resource: #canvas>
|
|
151 |
|
|
152 |
^
|
|
153 |
#(FullSpec
|
|
154 |
name: windowSpec
|
|
155 |
window:
|
|
156 |
(WindowSpec
|
|
157 |
label: 'Select project'
|
|
158 |
name: 'Select project'
|
|
159 |
min: (Point 10 10)
|
|
160 |
bounds: (Rectangle 0 0 402 301)
|
|
161 |
)
|
|
162 |
component:
|
|
163 |
(SpecCollection
|
|
164 |
collection: (
|
|
165 |
(VerticalPanelViewSpec
|
|
166 |
name: 'Main'
|
|
167 |
layout: (LayoutFrame 3 0 3 0 -3 1 -3 1)
|
|
168 |
horizontalLayout: fitSpace
|
|
169 |
verticalLayout: bottomSpaceFit
|
|
170 |
horizontalSpace: 3
|
|
171 |
verticalSpace: 3
|
|
172 |
component:
|
|
173 |
(SpecCollection
|
|
174 |
collection: (
|
|
175 |
(SelectionInListModelViewSpec
|
|
176 |
name: 'ProjectList'
|
|
177 |
model: projectSelectionHolder
|
|
178 |
hasHorizontalScrollBar: true
|
|
179 |
hasVerticalScrollBar: true
|
|
180 |
listModel: projectNamesHolder
|
|
181 |
highlightMode: line
|
|
182 |
doubleClickSelector: doAccept
|
|
183 |
extent: (Point 390 240)
|
|
184 |
)
|
|
185 |
(ActionButtonSpec
|
|
186 |
label: 'Update list from network'
|
|
187 |
name: 'Update'
|
|
188 |
translateLabel: true
|
|
189 |
model: doUpdateFromNetwork
|
|
190 |
initiallyDisabled: false
|
|
191 |
useDefaultExtent: true
|
|
192 |
)
|
|
193 |
(HorizontalPanelViewSpec
|
|
194 |
name: 'ButtonPanel'
|
|
195 |
horizontalLayout: fit
|
|
196 |
verticalLayout: fitSpace
|
|
197 |
horizontalSpace: 3
|
|
198 |
verticalSpace: 3
|
|
199 |
component:
|
|
200 |
(SpecCollection
|
|
201 |
collection: (
|
|
202 |
(ActionButtonSpec
|
|
203 |
label: 'Cancel'
|
|
204 |
name: 'CancelButton'
|
|
205 |
translateLabel: true
|
|
206 |
model: doCancel
|
|
207 |
useDefaultExtent: true
|
|
208 |
)
|
|
209 |
(ActionButtonSpec
|
|
210 |
label: 'Load'
|
|
211 |
name: 'LoadButton'
|
|
212 |
translateLabel: true
|
|
213 |
model: doAccept
|
|
214 |
enableChannel: canDoAcceptHolder
|
|
215 |
useDefaultExtent: true
|
|
216 |
)
|
|
217 |
)
|
|
218 |
|
|
219 |
)
|
|
220 |
useDefaultExtent: true
|
|
221 |
)
|
|
222 |
)
|
|
223 |
|
|
224 |
)
|
|
225 |
)
|
|
226 |
)
|
|
227 |
|
|
228 |
)
|
|
229 |
)
|
|
230 |
|
|
231 |
"Modified: / 26-11-2008 / 09:16:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
232 |
! !
|
|
233 |
|
|
234 |
!ProjectLoader class methodsFor:'load & save'!
|
|
235 |
|
|
236 |
loadProjects
|
|
237 |
|projectFile|
|
|
238 |
|
|
239 |
projectFile := self defaultProjectFile.
|
|
240 |
projectFile exists ifFalse:[
|
|
241 |
^ self defaultProjects
|
|
242 |
].
|
|
243 |
^ Compiler
|
|
244 |
evaluate:projectFile contents asString
|
|
245 |
ifFail:[ self defaultProjects ].
|
|
246 |
|
|
247 |
"
|
|
248 |
self projectList"
|
|
249 |
|
|
250 |
"Created: / 22-11-2008 / 09:41:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
251 |
"Modified: / 26-11-2008 / 10:17:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
252 |
!
|
|
253 |
|
|
254 |
saveProjects:projects
|
|
255 |
|projectFile|
|
|
256 |
|
|
257 |
projectFile := self defaultProjectFile.
|
|
258 |
projectFile writeStream nextPutAll:projects storeString
|
|
259 |
|
|
260 |
"Created: / 26-11-2008 / 10:07:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
261 |
! !
|
|
262 |
|
|
263 |
!ProjectLoader methodsFor:'actions'!
|
|
264 |
|
|
265 |
doAccept
|
|
266 |
|
|
267 |
| packages |
|
|
268 |
self canDoAcceptHolder value ifFalse:[^self].
|
|
269 |
packages := (projectList at: self projectSelectionHolder value) second.
|
|
270 |
packages do:
|
|
271 |
[:pkg|Smalltalk loadPackage: pkg].
|
|
272 |
super doAccept.
|
|
273 |
|
|
274 |
"Created: / 22-11-2008 / 09:55:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
275 |
!
|
|
276 |
|
|
277 |
doUpdateFromNetwork
|
|
278 |
<resource: #uiCallback>
|
|
279 |
|
|
280 |
| projects newProjects |
|
|
281 |
projects := self class loadProjects asOrderedCollection.
|
|
282 |
self class projectSites do:
|
|
283 |
[:site|
|
|
284 |
| siteUrl response |
|
|
285 |
siteUrl := site asURL.
|
|
286 |
response := HTTPInterface get: siteUrl path fromHost: siteUrl host.
|
|
287 |
newProjects := Compiler evaluate: response data ifFail:[#()].
|
|
288 |
newProjects do:
|
|
289 |
[:newPrj|
|
|
290 |
| oldPrj |
|
|
291 |
oldPrj := projects
|
|
292 |
detect:[:oldPrj|oldPrj first = newPrj first]
|
|
293 |
ifNone:[projects add: newPrj].
|
|
294 |
oldPrj at:2 put: newPrj second.
|
|
295 |
]
|
|
296 |
].
|
|
297 |
projects := projects asArray.
|
|
298 |
|
|
299 |
projectList := projects.
|
|
300 |
self class saveProjects: projects.
|
|
301 |
self projectListChanged
|
|
302 |
|
|
303 |
|
|
304 |
"
|
|
305 |
Tools::ProjectLoadDialog new doUpdateFromNetwork
|
|
306 |
|
|
307 |
"
|
|
308 |
|
|
309 |
"Modified: / 26-11-2008 / 10:28:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
310 |
! !
|
|
311 |
|
|
312 |
!ProjectLoader methodsFor:'aspects'!
|
|
313 |
|
|
314 |
canDoAcceptHolder
|
|
315 |
<resource: #uiAspect>
|
|
316 |
|
|
317 |
"automatically generated by UIPainter ..."
|
|
318 |
|
|
319 |
"*** the code below creates a default model when invoked."
|
|
320 |
"*** (which may not be the one you wanted)"
|
|
321 |
"*** Please change as required and accept it in the browser."
|
|
322 |
"*** (and replace this comment by something more useful ;-)"
|
|
323 |
|
|
324 |
|holder|
|
|
325 |
|
|
326 |
(holder := builder bindingAt:#canDoAcceptHolder) isNil ifTrue:[
|
|
327 |
holder := false asValue.
|
|
328 |
builder aspectAt:#canDoAcceptHolder put:holder.
|
|
329 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
330 |
"/ holder addDependent:self.
|
|
331 |
"/ holder onChangeSend:#canDoAcceptHolderChanged to:self.
|
|
332 |
].
|
|
333 |
^ holder.
|
|
334 |
|
|
335 |
"Created: / 22-11-2008 / 09:51:34 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
336 |
!
|
|
337 |
|
|
338 |
projectNamesHolder
|
|
339 |
<resource: #uiAspect>
|
|
340 |
|
|
341 |
"automatically generated by UIPainter ..."
|
|
342 |
|
|
343 |
"*** the code below creates a default model when invoked."
|
|
344 |
"*** (which may not be the one you wanted)"
|
|
345 |
"*** Please change as required and accept it in the browser."
|
|
346 |
"*** (and replace this comment by something more useful ;-)"
|
|
347 |
|
|
348 |
|holder|
|
|
349 |
|
|
350 |
(holder := builder bindingAt:#projectNamesHolder) isNil ifTrue:[
|
|
351 |
holder := #() asValue.
|
|
352 |
builder aspectAt:#projectNamesHolder put:holder.
|
|
353 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
354 |
"/ holder addDependent:self.
|
|
355 |
"/ holder onChangeSend:#projectNamesHolderChanged to:self.
|
|
356 |
].
|
|
357 |
^ holder.
|
|
358 |
|
|
359 |
"Created: / 22-11-2008 / 08:59:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
360 |
!
|
|
361 |
|
|
362 |
projectSelectionHolder
|
|
363 |
<resource: #uiAspect>
|
|
364 |
|
|
365 |
"automatically generated by UIPainter ..."
|
|
366 |
|
|
367 |
"*** the code below creates a default model when invoked."
|
|
368 |
"*** (which may not be the one you wanted)"
|
|
369 |
"*** Please change as required and accept it in the browser."
|
|
370 |
"*** (and replace this comment by something more useful ;-)"
|
|
371 |
|
|
372 |
|holder|
|
|
373 |
|
|
374 |
(holder := builder bindingAt:#projectSelectionHolder) isNil ifTrue:[
|
|
375 |
holder := ValueHolder new.
|
|
376 |
builder aspectAt:#projectSelectionHolder put:holder.
|
|
377 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
378 |
holder addDependent:self.
|
|
379 |
holder onChangeSend:#projectSelectionHolderChanged to:self.
|
|
380 |
].
|
|
381 |
^ holder.
|
|
382 |
|
|
383 |
"Created: / 22-11-2008 / 08:59:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
384 |
! !
|
|
385 |
|
|
386 |
!ProjectLoader methodsFor:'change & update'!
|
|
387 |
|
|
388 |
projectListChanged
|
|
389 |
|
|
390 |
self projectNamesHolder value:
|
|
391 |
(projectList collect:[:prj|prj first])
|
|
392 |
|
|
393 |
"Created: / 22-11-2008 / 09:52:47 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
394 |
!
|
|
395 |
|
|
396 |
projectSelectionHolderChanged
|
|
397 |
|
|
398 |
| selection |
|
|
399 |
selection := self projectSelectionHolder value.
|
|
400 |
|
|
401 |
self canDoAcceptHolder value:
|
|
402 |
(selection notNil and:[selection ~= 0])
|
|
403 |
|
|
404 |
"Created: / 22-11-2008 / 09:52:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
405 |
! !
|
|
406 |
|
|
407 |
!ProjectLoader methodsFor:'hooks'!
|
|
408 |
|
|
409 |
commonPostOpen
|
|
410 |
|
|
411 |
projectList := self class loadProjects.
|
|
412 |
self projectListChanged
|
|
413 |
|
|
414 |
"Created: / 22-11-2008 / 09:43:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
415 |
"Modified: / 26-11-2008 / 10:16:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
416 |
! !
|
|
417 |
|
|
418 |
!ProjectLoader class methodsFor:'documentation'!
|
|
419 |
|
|
420 |
version_CVS
|
10098
|
421 |
^ '$Header: /cvs/stx/stx/libtool/Tools__ProjectLoader.st,v 1.2 2011-07-03 19:41:59 cg Exp $'
|
10016
|
422 |
!
|
|
423 |
|
|
424 |
version_SVN
|
|
425 |
^ '§Id: Tools__ProjectLoader.st 7486 2009-10-26 22:06:24Z vranyj1 §'
|
|
426 |
! !
|
|
427 |
|
|
428 |
ProjectLoader initialize!
|