author | Claus Gittinger <cg@exept.de> |
Mon, 20 Jan 2020 21:02:47 +0100 | |
changeset 19422 | c6ca1c3e0fd7 |
parent 19084 | 9921dbc44880 |
permissions | -rw-r--r-- |
19084 | 1 |
"{ Encoding: utf8 }" |
2 |
||
9974 | 3 |
" |
10080 | 4 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
5 |
Copyright (c) 2009-2010 eXept Software AG |
|
9974 | 6 |
|
10080 | 7 |
Permission is hereby granted, free of charge, to any person |
8 |
obtaining a copy of this software and associated documentation |
|
9 |
files (the 'Software'), to deal in the Software without |
|
10 |
restriction, including without limitation the rights to use, |
|
11 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
12 |
copies of the Software, and to permit persons to whom the |
|
13 |
Software is furnished to do so, subject to the following |
|
14 |
conditions: |
|
15 |
||
16 |
The above copyright notice and this permission notice shall be |
|
17 |
included in all copies or substantial portions of the Software. |
|
18 |
||
19 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
20 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
21 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
22 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
23 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
24 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
25 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
26 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9974 | 27 |
" |
28 |
"{ Package: 'stx:libtool' }" |
|
29 |
||
16196 | 30 |
"{ NameSpace: Smalltalk }" |
31 |
||
9974 | 32 |
ApplicationModel subclass:#BookmarkBar |
33 |
instanceVariableNames:'bookmarkHolder bookmarksHolder menuHolder |
|
34 |
bookmarkButtonIconHolder hasBookmarkHolder' |
|
35 |
classVariableNames:'' |
|
36 |
poolDictionaries:'' |
|
37 |
category:'Interface-Bookmarks' |
|
38 |
! |
|
39 |
||
40 |
!BookmarkBar class methodsFor:'documentation'! |
|
41 |
||
42 |
copyright |
|
43 |
" |
|
10080 | 44 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
45 |
Copyright (c) 2009-2010 eXept Software AG |
|
46 |
||
47 |
Permission is hereby granted, free of charge, to any person |
|
48 |
obtaining a copy of this software and associated documentation |
|
49 |
files (the 'Software'), to deal in the Software without |
|
50 |
restriction, including without limitation the rights to use, |
|
51 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
52 |
copies of the Software, and to permit persons to whom the |
|
53 |
Software is furnished to do so, subject to the following |
|
54 |
conditions: |
|
9974 | 55 |
|
10080 | 56 |
The above copyright notice and this permission notice shall be |
57 |
included in all copies or substantial portions of the Software. |
|
58 |
||
59 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
60 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
61 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
62 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
63 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
64 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
65 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
66 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9974 | 67 |
" |
68 |
! ! |
|
69 |
||
10115 | 70 |
!BookmarkBar class methodsFor:'help specs'! |
71 |
||
17918 | 72 |
helpSpec |
10115 | 73 |
"This resource specification was automatically generated |
74 |
by the UIHelpTool of ST/X." |
|
75 |
||
76 |
"Do not manually edit this!! If it is corrupted, |
|
77 |
the UIHelpTool may not be able to read the specification." |
|
78 |
||
79 |
" |
|
80 |
UIHelpTool openOnClass:BookmarkBar |
|
81 |
" |
|
82 |
||
83 |
<resource: #help> |
|
84 |
||
17918 | 85 |
^ super helpSpec addPairsFrom:#( |
10115 | 86 |
|
87 |
#starButton |
|
88 |
'Click for bookmark menu' |
|
89 |
||
90 |
) |
|
91 |
||
92 |
"Created: / 03-07-2011 / 23:09:48 / cg" |
|
93 |
! ! |
|
94 |
||
9974 | 95 |
!BookmarkBar class methodsFor:'interface specs'! |
96 |
||
97 |
windowSpec |
|
98 |
"This resource specification was automatically generated |
|
99 |
by the UIPainter of ST/X." |
|
100 |
||
101 |
"Do not manually edit this!! If it is corrupted, |
|
102 |
the UIPainter may not be able to read the specification." |
|
103 |
||
104 |
" |
|
105 |
UIPainter new openOnClass:BookmarkBar andSelector:#windowSpec |
|
106 |
BookmarkBar new openInterface:#windowSpec |
|
107 |
BookmarkBar open |
|
108 |
" |
|
109 |
||
110 |
<resource: #canvas> |
|
111 |
||
112 |
^ |
|
113 |
#(FullSpec |
|
114 |
name: windowSpec |
|
115 |
window: |
|
116 |
(WindowSpec |
|
117 |
label: 'Bookmark bar' |
|
118 |
name: 'Bookmark bar' |
|
119 |
min: (Point 10 10) |
|
120 |
bounds: (Rectangle 0 0 600 25) |
|
121 |
) |
|
122 |
component: |
|
123 |
(SpecCollection |
|
124 |
collection: ( |
|
125 |
(MenuPanelSpec |
|
126 |
name: 'Bookmarks' |
|
127 |
layout: (LayoutFrame 0 0 0 0 -40 1 0 1) |
|
128 |
level: 0 |
|
129 |
menu: menuHolder |
|
130 |
textDefault: true |
|
131 |
) |
|
132 |
(ActionButtonSpec |
|
133 |
name: 'BookmarkButton' |
|
11046 | 134 |
layout: (LayoutFrame -25 1 1 0 0 1 22 0) |
10115 | 135 |
activeHelpKey: starButton |
9974 | 136 |
level: 0 |
137 |
hasCharacterOrientedLabel: false |
|
138 |
labelChannel: bookmarkButtonIconHolder |
|
139 |
model: bookmarkMenu |
|
10115 | 140 |
postBuildCallback: postBuiltStarButton: |
9974 | 141 |
) |
142 |
(ActionButtonSpec |
|
143 |
label: 'OK' |
|
144 |
name: 'menu' |
|
145 |
layout: (LayoutFrame -13 1 0 0 -3 1 0 1) |
|
146 |
initiallyInvisible: true |
|
147 |
hasCharacterOrientedLabel: false |
|
148 |
translateLabel: true |
|
149 |
labelChannel: menuButtonIcon |
|
150 |
model: bookmarkMenu |
|
151 |
) |
|
152 |
) |
|
153 |
||
154 |
) |
|
155 |
) |
|
156 |
! ! |
|
157 |
||
158 |
!BookmarkBar class methodsFor:'menu specs'! |
|
159 |
||
160 |
bookmarkMenu |
|
161 |
"This resource specification was automatically generated |
|
162 |
by the MenuEditor of ST/X." |
|
163 |
||
164 |
"Do not manually edit this!! If it is corrupted, |
|
165 |
the MenuEditor may not be able to read the specification." |
|
166 |
||
167 |
" |
|
168 |
MenuEditor new openOnClass:BookmarkBar andSelector:#bookmarkMenu |
|
169 |
(Menu new fromLiteralArrayEncoding:(BookmarkBar bookmarkMenu)) startUp |
|
170 |
" |
|
171 |
||
172 |
<resource: #menu> |
|
173 |
||
174 |
^ |
|
175 |
#(Menu |
|
176 |
( |
|
177 |
(MenuItem |
|
178 |
label: 'Add' |
|
179 |
translateLabel: true |
|
180 |
submenuChannel: bookmarkMenuAddSlice |
|
181 |
isMenuSlice: true |
|
182 |
) |
|
183 |
(MenuItem |
|
184 |
label: '-' |
|
185 |
) |
|
186 |
(MenuItem |
|
187 |
label: 'Bookmark Editor' |
|
188 |
itemValue: menuOpenBookmarkEditor |
|
189 |
translateLabel: true |
|
190 |
) |
|
191 |
) |
|
192 |
nil |
|
193 |
nil |
|
194 |
) |
|
195 |
! ! |
|
196 |
||
197 |
!BookmarkBar class methodsFor:'plugIn spec'! |
|
198 |
||
199 |
aspectSelectors |
|
200 |
"This resource specification was automatically generated |
|
201 |
by the UIPainter of ST/X." |
|
202 |
||
203 |
"Do not manually edit this. If it is corrupted, |
|
204 |
the UIPainter may not be able to read the specification." |
|
205 |
||
206 |
"Return a description of exported aspects; |
|
207 |
these can be connected to aspects of an embedding application |
|
208 |
(if this app is embedded in a subCanvas)." |
|
209 |
||
210 |
^ #( |
|
10115 | 211 |
#bookmarkHolder |
9974 | 212 |
#bookmarksHolder |
213 |
). |
|
214 |
||
215 |
! ! |
|
216 |
||
217 |
!BookmarkBar methodsFor:'actions'! |
|
218 |
||
219 |
bookmark |
|
220 |
<resource: #uiCallback> |
|
221 |
||
222 |
self menuAddBookmark |
|
223 |
||
224 |
"Modified: / 02-06-2011 / 21:39:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
225 |
! |
|
226 |
||
227 |
bookmarkMenu |
|
228 |
<resource: #uiCallback> |
|
229 |
|menu| |
|
230 |
||
231 |
menu := self class bookmarkMenu decodeAsLiteralArray. |
|
232 |
menu findGuiResourcesIn:self. |
|
233 |
menu startUp |
|
234 |
||
235 |
"Modified: / 02-06-2011 / 20:05:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
236 |
! ! |
|
237 |
||
238 |
!BookmarkBar methodsFor:'aspects'! |
|
239 |
||
240 |
bookmarkButtonIconHolder |
|
241 |
<resource: #uiAspect> |
|
242 |
||
243 |
bookmarkButtonIconHolder isNil ifTrue:[ |
|
11045
3406500fc0b0
changed: #bookmarkButtonIconHolder
Claus Gittinger <cg@exept.de>
parents:
11043
diff
changeset
|
244 |
bookmarkButtonIconHolder := ToolbarIconLibrary bookmarks14x14 asValue. |
9974 | 245 |
]. |
246 |
^ bookmarkButtonIconHolder. |
|
247 |
||
248 |
"Modified: / 18-05-2011 / 18:22:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11045
3406500fc0b0
changed: #bookmarkButtonIconHolder
Claus Gittinger <cg@exept.de>
parents:
11043
diff
changeset
|
249 |
"Modified: / 31-12-2011 / 15:47:13 / cg" |
9974 | 250 |
! |
251 |
||
252 |
bookmarkHolder |
|
253 |
"return/create the 'bookmarkHolder' value holder (automatically generated)" |
|
254 |
||
255 |
bookmarkHolder isNil ifTrue:[ |
|
256 |
bookmarkHolder := ValueHolder new. |
|
257 |
bookmarkHolder addDependent:self. |
|
258 |
]. |
|
259 |
^ bookmarkHolder |
|
260 |
! |
|
261 |
||
262 |
bookmarkHolder:something |
|
263 |
"set the 'bookmarkHolder' value holder (automatically generated)" |
|
264 |
||
265 |
|oldValue newValue| |
|
266 |
||
267 |
bookmarkHolder notNil ifTrue:[ |
|
268 |
oldValue := bookmarkHolder value. |
|
269 |
bookmarkHolder removeDependent:self. |
|
270 |
]. |
|
271 |
bookmarkHolder := something. |
|
272 |
bookmarkHolder notNil ifTrue:[ |
|
273 |
bookmarkHolder addDependent:self. |
|
274 |
]. |
|
275 |
newValue := bookmarkHolder value. |
|
276 |
oldValue ~~ newValue ifTrue:[ |
|
277 |
self update:#value with:newValue from:bookmarkHolder. |
|
278 |
]. |
|
279 |
! |
|
280 |
||
281 |
bookmarksHolder |
|
282 |
"return/create the 'bookmarksHolder' value holder (automatically generated)" |
|
283 |
||
284 |
bookmarksHolder isNil ifTrue:[ |
|
285 |
bookmarksHolder := ValueHolder new. |
|
286 |
bookmarksHolder addDependent:self. |
|
287 |
]. |
|
288 |
^ bookmarksHolder |
|
289 |
! |
|
290 |
||
291 |
bookmarksHolder:something |
|
292 |
"set the 'bookmarksHolder' value holder (automatically generated)" |
|
293 |
||
294 |
|oldValue newValue| |
|
295 |
||
296 |
bookmarksHolder notNil ifTrue:[ |
|
297 |
oldValue := bookmarksHolder value. |
|
298 |
bookmarksHolder removeDependent:self. |
|
299 |
]. |
|
300 |
bookmarksHolder := something. |
|
301 |
bookmarksHolder notNil ifTrue:[ |
|
302 |
bookmarksHolder addDependent:self. |
|
303 |
]. |
|
304 |
newValue := bookmarksHolder value. |
|
305 |
oldValue ~~ newValue ifTrue:[ |
|
306 |
self update:#value with:newValue from:bookmarksHolder. |
|
307 |
]. |
|
308 |
! |
|
309 |
||
310 |
hasBookmarkHolder |
|
311 |
"return/create the 'bookmarkHolder' value holder (automatically generated)" |
|
312 |
||
313 |
hasBookmarkHolder isNil ifTrue:[ |
|
314 |
hasBookmarkHolder := (AspectAdaptor forAspect:#notNil) |
|
315 |
subjectChannel: (self bookmarkHolder) |
|
316 |
]. |
|
317 |
^ hasBookmarkHolder |
|
318 |
||
319 |
"Created: / 08-06-2011 / 12:39:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
320 |
! |
|
321 |
||
322 |
menuButtonIcon |
|
323 |
<resource: #uiAspect> |
|
324 |
||
325 |
^ToolbarIconLibrary sortIndicatorIcon |
|
326 |
||
327 |
"Created: / 02-06-2011 / 19:55:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
328 |
! |
|
329 |
||
330 |
menuHolder |
|
331 |
"return/create the 'menuHolder' value holder (automatically generated)" |
|
332 |
||
333 |
menuHolder isNil ifTrue:[ |
|
334 |
menuHolder := ValueHolder new. |
|
335 |
]. |
|
336 |
^ menuHolder |
|
337 |
||
338 |
"Modified: / 18-05-2011 / 18:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
339 |
! ! |
|
340 |
||
341 |
!BookmarkBar methodsFor:'change & update'! |
|
342 |
||
343 |
update:something with:aParameter from:changedObject |
|
344 |
"Invoked when an object that I depend upon sends a change notification." |
|
345 |
||
346 |
changedObject == bookmarksHolder ifTrue:[ |
|
347 |
self updateMenu. |
|
348 |
^ self. |
|
349 |
]. |
|
350 |
||
351 |
changedObject == bookmarkHolder ifTrue:[ |
|
352 |
self updateBookmarkButton. |
|
353 |
^ self. |
|
354 |
]. |
|
355 |
||
356 |
super update:something with:aParameter from:changedObject |
|
357 |
||
358 |
"Modified: / 02-06-2011 / 22:47:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
359 |
! |
|
360 |
||
361 |
updateBookmarkButton |
|
362 |
||
363 |
"Created: / 02-06-2011 / 22:47:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
364 |
! |
|
365 |
||
366 |
updateMenu |
|
367 |
||
368 |
| menu item | |
|
369 |
||
370 |
self window isVisible ifFalse:[^self]. |
|
371 |
menu := self bookmarksHolder value asMenu. |
|
372 |
menu hasItems ifFalse:[ |
|
13436 | 373 |
item := MenuItem |
19084 | 374 |
label: ('No bookmarks yet, click here or on star to add one' allGray) |
13436 | 375 |
itemValue: #bookmarkMenu |
376 |
enabled: self hasBookmarkHolder. |
|
9974 | 377 |
item isButton: true. |
378 |
menu addItem: item. |
|
379 |
]. |
|
380 |
||
381 |
||
382 |
menu findGuiResourcesIn:self. |
|
383 |
menuHolder value: menu. |
|
384 |
||
385 |
"Created: / 18-05-2011 / 18:00:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
386 |
"Modified: / 08-06-2011 / 12:40:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11784 | 387 |
"Modified: / 09-09-2012 / 13:07:51 / cg" |
9974 | 388 |
! ! |
389 |
||
390 |
!BookmarkBar methodsFor:'hooks'! |
|
391 |
||
11422 | 392 |
closeDownViews |
393 |
self release. |
|
394 |
super closeDownViews |
|
395 |
||
396 |
"Created: / 15-03-2012 / 13:26:54 / Jan Vrany <jan.vrany.fit.cvut.cz>" |
|
397 |
! |
|
398 |
||
9974 | 399 |
commonPostOpen |
10863 | 400 |
|bh| |
9974 | 401 |
|
402 |
super commonPostOpen. |
|
17317 | 403 |
|
10863 | 404 |
bh := self bookmarksHolder. |
405 |
bh value isNil ifTrue:[ |
|
406 |
bh value: BookmarkList forSystemBrowser |
|
407 |
]. |
|
9974 | 408 |
self updateMenu. |
409 |
||
410 |
"Created: / 18-05-2011 / 18:58:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
411 |
"Modified: / 02-06-2011 / 19:51:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10863 | 412 |
"Modified: / 18-11-2011 / 14:31:54 / cg" |
10115 | 413 |
! |
414 |
||
415 |
postBuiltStarButton:aButton |
|
416 |
aButton enterLevel:1. |
|
417 |
aButton leaveLevel:0. |
|
418 |
||
419 |
"Created: / 03-07-2011 / 23:08:01 / cg" |
|
9974 | 420 |
! ! |
421 |
||
11422 | 422 |
!BookmarkBar methodsFor:'initialization & release'! |
423 |
||
424 |
release |
|
425 |
||
426 |
bookmarksHolder notNil ifTrue:[ |
|
17424 | 427 |
bookmarksHolder removeDependent:self. |
428 |
]. |
|
429 |
bookmarkHolder notNil ifTrue:[ |
|
430 |
bookmarkHolder removeDependent:self. |
|
11422 | 431 |
]. |
14063 | 432 |
super release |
11422 | 433 |
|
434 |
"Created: / 15-03-2012 / 13:30:56 / Jan Vrany <jan.vrany.fit.cvut.cz>" |
|
17424 | 435 |
"Modified: / 21-02-2017 / 10:16:31 / stefan" |
11422 | 436 |
! |
437 |
||
438 |
releaseAsSubCanvas |
|
439 |
self release. |
|
440 |
super releaseAsSubCanvas |
|
441 |
||
442 |
"Created: / 15-03-2012 / 13:28:48 / Jan Vrany <jan.vrany.fit.cvut.cz>" |
|
443 |
! ! |
|
444 |
||
9974 | 445 |
!BookmarkBar methodsFor:'menu'! |
446 |
||
447 |
bookmarkMenuAddSlice |
|
10282 | 448 |
^ BookmarkAddMenuBuilder new buildMenuFor:self bookmarksHolder value |
9974 | 449 |
|
450 |
"Created: / 02-06-2011 / 21:54:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10282 | 451 |
"Modified: / 08-07-2011 / 11:38:29 / cg" |
9974 | 452 |
! ! |
453 |
||
454 |
!BookmarkBar methodsFor:'menu actions'! |
|
455 |
||
456 |
menuAddBookmark |
|
457 |
||
458 |
self menuAddBookmarkTo: self bookmarksHolder value root. |
|
459 |
||
460 |
"Created: / 02-06-2011 / 21:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
461 |
! |
|
462 |
||
463 |
menuAddBookmarkTo: folder |
|
10863 | 464 |
| bookmark | |
9974 | 465 |
|
466 |
bookmark := self bookmarkHolder value. |
|
10863 | 467 |
bookmark isNil ifTrue:[^self]. |
9974 | 468 |
folder add: bookmark. |
469 |
self bookmarksHolder value save. |
|
470 |
||
471 |
"Created: / 02-06-2011 / 22:17:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10863 | 472 |
"Modified: / 18-11-2011 / 14:32:07 / cg" |
9974 | 473 |
! |
474 |
||
475 |
menuOpenBookmarkEditor |
|
476 |
||
477 |
BookmarkListEditor new |
|
478 |
bookmarkList: self bookmarksHolder value; |
|
479 |
open. |
|
480 |
||
481 |
"Modified: / 02-06-2011 / 20:02:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
482 |
! ! |
|
483 |
||
484 |
!BookmarkBar class methodsFor:'documentation'! |
|
485 |
||
11045
3406500fc0b0
changed: #bookmarkButtonIconHolder
Claus Gittinger <cg@exept.de>
parents:
11043
diff
changeset
|
486 |
version |
16196 | 487 |
^ '$Header$' |
11045
3406500fc0b0
changed: #bookmarkButtonIconHolder
Claus Gittinger <cg@exept.de>
parents:
11043
diff
changeset
|
488 |
! |
3406500fc0b0
changed: #bookmarkButtonIconHolder
Claus Gittinger <cg@exept.de>
parents:
11043
diff
changeset
|
489 |
|
9974 | 490 |
version_CVS |
16196 | 491 |
^ '$Header$' |
9974 | 492 |
! |
493 |
||
494 |
version_SVN |
|
16196 | 495 |
^ '$Id$' |
9974 | 496 |
! ! |
13436 | 497 |