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