author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 05 May 2012 22:28:49 +0100 | |
branch | jv |
changeset 12239 | 9a8aa0b0e982 |
parent 12128 | a7ff7d66ee85 |
child 12431 | 9f0c59c742d5 |
permissions | -rw-r--r-- |
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 |
||
12239 | 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. |
|
10016 | 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>" |
|
12239 | 89 |
"Modified: / 05-05-2012 / 19:07:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10016 | 90 |
! ! |
91 |
||
92 |
!ProjectLoader class methodsFor:'accessing'! |
|
93 |
||
94 |
projectSites |
|
95 |
||
96 |
^UserPreferences current projectLoaderProjectSites |
|
97 |
||
98 |
"Created: / 22-11-2008 / 09:13:55 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
99 |
"Modified: / 26-11-2008 / 10:13:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
100 |
! ! |
|
101 |
||
102 |
!ProjectLoader class methodsFor:'defaults'! |
|
103 |
||
104 |
defaultProjectFile |
|
105 |
^ (Filename homeDirectory construct:'.smalltalk') construct:'projects.rc' |
|
106 |
||
107 |
"Created: / 26-11-2008 / 10:15:02 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
108 |
! |
|
109 |
||
110 |
defaultProjects |
|
111 |
||
112 |
^#( |
|
113 |
( |
|
114 |
'CellStore' |
|
115 |
('cvut:fel/cellstore/core') |
|
116 |
) |
|
117 |
||
118 |
( |
|
119 |
'Perseus' |
|
120 |
('cvut:fel/perseus/core' |
|
121 |
'cvut:fel/perseus/core_ui' |
|
122 |
'cvut:fel/perseus/smallscript' |
|
123 |
'cvut:fel/perseus/pascal' |
|
124 |
'stx:goodies/xmlsuite/xquery') |
|
125 |
) |
|
126 |
||
127 |
( |
|
128 |
'IZAR' |
|
129 |
('cvut:fel/izar') |
|
130 |
) |
|
131 |
) |
|
132 |
||
133 |
"Created: / 26-11-2008 / 10:06:14 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
134 |
! ! |
|
135 |
||
136 |
!ProjectLoader class methodsFor:'interface specs'! |
|
137 |
||
138 |
windowSpec |
|
139 |
"This resource specification was automatically generated |
|
140 |
by the UIPainter of ST/X." |
|
141 |
||
142 |
"Do not manually edit this!! If it is corrupted, |
|
143 |
the UIPainter may not be able to read the specification." |
|
144 |
||
145 |
" |
|
146 |
UIPainter new openOnClass:Tools::ProjectLoadDialog andSelector:#windowSpec |
|
147 |
Tools::ProjectLoadDialog new openInterface:#windowSpec |
|
148 |
Tools::ProjectLoadDialog open |
|
149 |
" |
|
150 |
||
151 |
<resource: #canvas> |
|
152 |
||
153 |
^ |
|
154 |
#(FullSpec |
|
155 |
name: windowSpec |
|
156 |
window: |
|
157 |
(WindowSpec |
|
158 |
label: 'Select project' |
|
159 |
name: 'Select project' |
|
160 |
min: (Point 10 10) |
|
161 |
bounds: (Rectangle 0 0 402 301) |
|
162 |
) |
|
163 |
component: |
|
164 |
(SpecCollection |
|
165 |
collection: ( |
|
166 |
(VerticalPanelViewSpec |
|
167 |
name: 'Main' |
|
168 |
layout: (LayoutFrame 3 0 3 0 -3 1 -3 1) |
|
169 |
horizontalLayout: fitSpace |
|
170 |
verticalLayout: bottomSpaceFit |
|
171 |
horizontalSpace: 3 |
|
172 |
verticalSpace: 3 |
|
173 |
component: |
|
174 |
(SpecCollection |
|
175 |
collection: ( |
|
176 |
(SelectionInListModelViewSpec |
|
177 |
name: 'ProjectList' |
|
178 |
model: projectSelectionHolder |
|
179 |
hasHorizontalScrollBar: true |
|
180 |
hasVerticalScrollBar: true |
|
181 |
listModel: projectNamesHolder |
|
182 |
highlightMode: line |
|
183 |
doubleClickSelector: doAccept |
|
184 |
extent: (Point 390 240) |
|
185 |
) |
|
186 |
(ActionButtonSpec |
|
187 |
label: 'Update list from network' |
|
188 |
name: 'Update' |
|
189 |
translateLabel: true |
|
190 |
model: doUpdateFromNetwork |
|
191 |
initiallyDisabled: false |
|
192 |
useDefaultExtent: true |
|
193 |
) |
|
194 |
(HorizontalPanelViewSpec |
|
195 |
name: 'ButtonPanel' |
|
196 |
horizontalLayout: fit |
|
197 |
verticalLayout: fitSpace |
|
198 |
horizontalSpace: 3 |
|
199 |
verticalSpace: 3 |
|
200 |
component: |
|
201 |
(SpecCollection |
|
202 |
collection: ( |
|
203 |
(ActionButtonSpec |
|
204 |
label: 'Cancel' |
|
205 |
name: 'CancelButton' |
|
206 |
translateLabel: true |
|
207 |
model: doCancel |
|
208 |
useDefaultExtent: true |
|
209 |
) |
|
210 |
(ActionButtonSpec |
|
211 |
label: 'Load' |
|
212 |
name: 'LoadButton' |
|
213 |
translateLabel: true |
|
214 |
model: doAccept |
|
215 |
enableChannel: canDoAcceptHolder |
|
216 |
useDefaultExtent: true |
|
217 |
) |
|
218 |
) |
|
219 |
||
220 |
) |
|
221 |
useDefaultExtent: true |
|
222 |
) |
|
223 |
) |
|
224 |
||
225 |
) |
|
226 |
) |
|
227 |
) |
|
228 |
||
229 |
) |
|
230 |
) |
|
231 |
||
232 |
"Modified: / 26-11-2008 / 09:16:59 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
233 |
! ! |
|
234 |
||
235 |
!ProjectLoader class methodsFor:'load & save'! |
|
236 |
||
237 |
loadProjects |
|
238 |
|projectFile| |
|
239 |
||
240 |
projectFile := self defaultProjectFile. |
|
241 |
projectFile exists ifFalse:[ |
|
242 |
^ self defaultProjects |
|
243 |
]. |
|
244 |
^ Compiler |
|
245 |
evaluate:projectFile contents asString |
|
246 |
ifFail:[ self defaultProjects ]. |
|
247 |
||
248 |
" |
|
249 |
self projectList" |
|
250 |
||
251 |
"Created: / 22-11-2008 / 09:41:22 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
252 |
"Modified: / 26-11-2008 / 10:17:23 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
253 |
! |
|
254 |
||
255 |
saveProjects:projects |
|
256 |
|projectFile| |
|
257 |
||
258 |
projectFile := self defaultProjectFile. |
|
259 |
projectFile writeStream nextPutAll:projects storeString |
|
260 |
||
261 |
"Created: / 26-11-2008 / 10:07:42 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
262 |
! ! |
|
263 |
||
264 |
!ProjectLoader methodsFor:'actions'! |
|
265 |
||
266 |
doAccept |
|
267 |
||
268 |
| packages | |
|
269 |
self canDoAcceptHolder value ifFalse:[^self]. |
|
270 |
packages := (projectList at: self projectSelectionHolder value) second. |
|
271 |
packages do: |
|
272 |
[:pkg|Smalltalk loadPackage: pkg]. |
|
273 |
super doAccept. |
|
274 |
||
275 |
"Created: / 22-11-2008 / 09:55:17 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
276 |
! |
|
277 |
||
278 |
doUpdateFromNetwork |
|
279 |
<resource: #uiCallback> |
|
280 |
||
281 |
| projects newProjects | |
|
282 |
projects := self class loadProjects asOrderedCollection. |
|
283 |
self class projectSites do: |
|
284 |
[:site| |
|
285 |
| siteUrl response | |
|
286 |
siteUrl := site asURL. |
|
287 |
response := HTTPInterface get: siteUrl path fromHost: siteUrl host. |
|
288 |
newProjects := Compiler evaluate: response data ifFail:[#()]. |
|
289 |
newProjects do: |
|
290 |
[:newPrj| |
|
291 |
| oldPrj | |
|
292 |
oldPrj := projects |
|
293 |
detect:[:oldPrj|oldPrj first = newPrj first] |
|
294 |
ifNone:[projects add: newPrj]. |
|
295 |
oldPrj at:2 put: newPrj second. |
|
296 |
] |
|
297 |
]. |
|
298 |
projects := projects asArray. |
|
299 |
||
300 |
projectList := projects. |
|
301 |
self class saveProjects: projects. |
|
302 |
self projectListChanged |
|
303 |
||
304 |
||
305 |
" |
|
306 |
Tools::ProjectLoadDialog new doUpdateFromNetwork |
|
307 |
||
308 |
" |
|
309 |
||
310 |
"Modified: / 26-11-2008 / 10:28:00 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
311 |
! ! |
|
312 |
||
313 |
!ProjectLoader methodsFor:'aspects'! |
|
314 |
||
315 |
canDoAcceptHolder |
|
316 |
<resource: #uiAspect> |
|
317 |
||
318 |
"automatically generated by UIPainter ..." |
|
319 |
||
320 |
"*** the code below creates a default model when invoked." |
|
321 |
"*** (which may not be the one you wanted)" |
|
322 |
"*** Please change as required and accept it in the browser." |
|
323 |
"*** (and replace this comment by something more useful ;-)" |
|
324 |
||
325 |
|holder| |
|
326 |
||
327 |
(holder := builder bindingAt:#canDoAcceptHolder) isNil ifTrue:[ |
|
328 |
holder := false asValue. |
|
329 |
builder aspectAt:#canDoAcceptHolder put:holder. |
|
330 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
331 |
"/ holder addDependent:self. |
|
332 |
"/ holder onChangeSend:#canDoAcceptHolderChanged to:self. |
|
333 |
]. |
|
334 |
^ holder. |
|
335 |
||
336 |
"Created: / 22-11-2008 / 09:51:34 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
337 |
! |
|
338 |
||
339 |
projectNamesHolder |
|
340 |
<resource: #uiAspect> |
|
341 |
||
342 |
"automatically generated by UIPainter ..." |
|
343 |
||
344 |
"*** the code below creates a default model when invoked." |
|
345 |
"*** (which may not be the one you wanted)" |
|
346 |
"*** Please change as required and accept it in the browser." |
|
347 |
"*** (and replace this comment by something more useful ;-)" |
|
348 |
||
349 |
|holder| |
|
350 |
||
351 |
(holder := builder bindingAt:#projectNamesHolder) isNil ifTrue:[ |
|
352 |
holder := #() asValue. |
|
353 |
builder aspectAt:#projectNamesHolder put:holder. |
|
354 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
355 |
"/ holder addDependent:self. |
|
356 |
"/ holder onChangeSend:#projectNamesHolderChanged to:self. |
|
357 |
]. |
|
358 |
^ holder. |
|
359 |
||
360 |
"Created: / 22-11-2008 / 08:59:43 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
361 |
! |
|
362 |
||
363 |
projectSelectionHolder |
|
364 |
<resource: #uiAspect> |
|
365 |
||
366 |
"automatically generated by UIPainter ..." |
|
367 |
||
368 |
"*** the code below creates a default model when invoked." |
|
369 |
"*** (which may not be the one you wanted)" |
|
370 |
"*** Please change as required and accept it in the browser." |
|
371 |
"*** (and replace this comment by something more useful ;-)" |
|
372 |
||
373 |
|holder| |
|
374 |
||
375 |
(holder := builder bindingAt:#projectSelectionHolder) isNil ifTrue:[ |
|
376 |
holder := ValueHolder new. |
|
377 |
builder aspectAt:#projectSelectionHolder put:holder. |
|
378 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
379 |
holder addDependent:self. |
|
380 |
holder onChangeSend:#projectSelectionHolderChanged to:self. |
|
381 |
]. |
|
382 |
^ holder. |
|
383 |
||
384 |
"Created: / 22-11-2008 / 08:59:43 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
385 |
! ! |
|
386 |
||
387 |
!ProjectLoader methodsFor:'change & update'! |
|
388 |
||
389 |
projectListChanged |
|
390 |
||
391 |
self projectNamesHolder value: |
|
392 |
(projectList collect:[:prj|prj first]) |
|
393 |
||
394 |
"Created: / 22-11-2008 / 09:52:47 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
395 |
! |
|
396 |
||
397 |
projectSelectionHolderChanged |
|
398 |
||
399 |
| selection | |
|
400 |
selection := self projectSelectionHolder value. |
|
401 |
||
402 |
self canDoAcceptHolder value: |
|
403 |
(selection notNil and:[selection ~= 0]) |
|
404 |
||
405 |
"Created: / 22-11-2008 / 09:52:20 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
406 |
! ! |
|
407 |
||
408 |
!ProjectLoader methodsFor:'hooks'! |
|
409 |
||
410 |
commonPostOpen |
|
411 |
||
412 |
projectList := self class loadProjects. |
|
413 |
self projectListChanged |
|
414 |
||
415 |
"Created: / 22-11-2008 / 09:43:04 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
416 |
"Modified: / 26-11-2008 / 10:16:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
417 |
! ! |
|
418 |
||
419 |
!ProjectLoader class methodsFor:'documentation'! |
|
420 |
||
421 |
version_CVS |
|
12123
4bde08cebd48
trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10098
diff
changeset
|
422 |
^ '§Header: /cvs/stx/stx/libtool/Tools__ProjectLoader.st,v 1.2 2011/07/03 19:41:59 cg Exp §' |
10016 | 423 |
! |
424 |
||
425 |
version_SVN |
|
12239 | 426 |
^ '$Id: Tools__ProjectLoader.st 7989 2012-05-05 21:28:49Z vranyj1 $' |
10016 | 427 |
! ! |
428 |
||
12239 | 429 |
ProjectLoader initialize! |