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