author | Jan Vrany <jan.vrany@labware.com> |
Sat, 30 Sep 2023 22:55:25 +0100 | |
branch | jv |
changeset 19648 | 5df52d354504 |
parent 15566 | 184cea584be5 |
permissions | -rw-r--r-- |
9968 | 1 |
" |
10087 | 2 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
3 |
Copyright (c) 2009-2010 eXept Software AG |
|
9968 | 4 |
|
10087 | 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. |
|
9968 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
15339 | 28 |
"{ NameSpace: Smalltalk }" |
29 |
||
9968 | 30 |
BookmarkVisitor subclass:#BookmarkMenuBuilder |
10281 | 31 |
instanceVariableNames:'resources menu stack toolbar' |
9968 | 32 |
classVariableNames:'' |
33 |
poolDictionaries:'' |
|
34 |
category:'Interface-Bookmarks' |
|
35 |
! |
|
36 |
||
37 |
!BookmarkMenuBuilder class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
10087 | 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: |
|
9968 | 52 |
|
10087 | 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. |
|
9968 | 64 |
" |
65 |
! ! |
|
66 |
||
67 |
!BookmarkMenuBuilder class methodsFor:'instance creation'! |
|
68 |
||
69 |
new |
|
70 |
"return an initialized instance" |
|
71 |
||
72 |
^ self basicNew initialize. |
|
73 |
! ! |
|
74 |
||
75 |
!BookmarkMenuBuilder methodsFor:'accessing'! |
|
76 |
||
77 |
menu |
|
78 |
||
79 |
^ menu |
|
80 |
||
81 |
"Created: / 23-05-2011 / 10:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10281 | 82 |
! |
83 |
||
84 |
resources:something |
|
85 |
resources := something. |
|
9968 | 86 |
! ! |
87 |
||
88 |
!BookmarkMenuBuilder methodsFor:'initialization'! |
|
89 |
||
90 |
initialize |
|
91 |
||
92 |
menu := Menu new. |
|
10296
020772a7653e
BookmarkMenuBuilder>>initialize: initialize resources to empty one
vrany
parents:
10281
diff
changeset
|
93 |
stack := Stack with: menu. |
020772a7653e
BookmarkMenuBuilder>>initialize: initialize resources to empty one
vrany
parents:
10281
diff
changeset
|
94 |
resources := ResourcePack new. |
9968 | 95 |
|
96 |
"/ super initialize. -- commented since inherited method does nothing |
|
97 |
||
10296
020772a7653e
BookmarkMenuBuilder>>initialize: initialize resources to empty one
vrany
parents:
10281
diff
changeset
|
98 |
"Modified: / 08-07-2011 / 13:49:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9968 | 99 |
! ! |
100 |
||
101 |
!BookmarkMenuBuilder methodsFor:'utilities'! |
|
102 |
||
103 |
menuItemAddBookmark:anObject |
|
104 |
||
105 |
||
106 |
^self menuItemAddBookmark:anObject labeled:'Add Bookmark Here'. |
|
107 |
||
108 |
"Modified: / 21-06-2011 / 08:00:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10281 | 109 |
"Modified: / 08-07-2011 / 11:39:31 / cg" |
9968 | 110 |
! |
111 |
||
112 |
menuItemAddBookmark:anObject labeled: label |
|
14580 | 113 |
^ (MenuItem |
13435 | 114 |
label:(resources string:label) |
115 |
itemValue:#menuAddBookmarkTo: |
|
14580 | 116 |
argument:anObject) |
117 |
translateLabel:false. |
|
9968 | 118 |
|
119 |
"Created: / 21-06-2011 / 07:59:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10281 | 120 |
"Modified: / 08-07-2011 / 11:39:40 / cg" |
9968 | 121 |
! |
122 |
||
10547
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
123 |
menuItemFolder: folder |
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
124 |
|
14580 | 125 |
^ (MenuItem |
126 |
label:folder label) |
|
127 |
translateLabel:false. |
|
10547
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
128 |
|
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
129 |
"Created: / 21-06-2011 / 08:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
130 |
! |
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
131 |
|
9968 | 132 |
menuItemGotoBookmark:anObject |
13435 | 133 |
|icon label| |
9968 | 134 |
|
135 |
label := anObject label. |
|
136 |
icon := anObject icon. |
|
10912 | 137 |
icon notNil ifTrue:[ label := LabelAndIcon label:label icon:icon ]. |
15339 | 138 |
^ (MenuItem |
14580 | 139 |
label:label |
140 |
itemValue:#switchToBookmarkEntry: |
|
141 |
argument:anObject) |
|
15341 | 142 |
activeHelpKey:(anObject flyByHelpText); |
15339 | 143 |
translateLabel:false. |
9968 | 144 |
|
145 |
"Created: / 21-06-2011 / 07:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10912 | 146 |
"Modified: / 29-11-2011 / 11:21:20 / cg" |
9968 | 147 |
! ! |
148 |
||
149 |
!BookmarkMenuBuilder methodsFor:'visiting'! |
|
150 |
||
10281 | 151 |
buildMenuFor: anObject |
152 |
^ self |
|
153 |
visit: anObject; |
|
154 |
menu |
|
155 |
||
156 |
"Created: / 02-06-2011 / 21:52:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
157 |
"Created: / 08-07-2011 / 11:37:42 / cg" |
|
158 |
! |
|
159 |
||
9968 | 160 |
visitBookmark:anObject |
161 |
|item| |
|
162 |
||
163 |
item := self menuItemGotoBookmark:anObject. |
|
164 |
stack top addItem:item |
|
165 |
||
166 |
"Created: / 23-05-2011 / 10:42:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
167 |
"Modified: / 21-06-2011 / 07:55:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
168 |
! |
|
169 |
||
170 |
visitFolder:anObject |
|
171 |
|item submenu| |
|
172 |
||
173 |
anObject parent isNil |
|
174 |
ifTrue:[ anObject children ? #() do:[:child | self visit:child ] ] |
|
175 |
ifFalse: |
|
176 |
[ item := self menuItemFolder: anObject. |
|
177 |
stack top addItem:item. |
|
178 |
submenu := Menu new. |
|
179 |
item submenu:submenu. |
|
180 |
stack push:submenu. |
|
181 |
anObject children ? #() do:[:child | self visit:child ]. |
|
182 |
stack top hasItems ifTrue:[ stack top addSeparator ]. |
|
183 |
item := self menuItemAddBookmark:anObject. |
|
184 |
stack top addItem:item. |
|
185 |
stack pop ]. |
|
186 |
||
187 |
"Created: / 23-05-2011 / 10:38:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
188 |
"Modified: / 21-06-2011 / 08:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
189 |
! |
|
190 |
||
191 |
visitSeparator:anObject |
|
192 |
||
193 |
stack top addItem: MenuItem separator |
|
194 |
||
195 |
"Created: / 03-06-2011 / 13:41:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
196 |
! ! |
|
197 |
||
198 |
!BookmarkMenuBuilder class methodsFor:'documentation'! |
|
199 |
||
15341 | 200 |
version |
201 |
^ '$Header: /cvs/stx/stx/libtool/BookmarkMenuBuilder.st,v 1.10 2015-02-20 15:37:15 cg Exp $' |
|
202 |
! |
|
203 |
||
9968 | 204 |
version_CVS |
15341 | 205 |
^ '$Header: /cvs/stx/stx/libtool/BookmarkMenuBuilder.st,v 1.10 2015-02-20 15:37:15 cg Exp $' |
9968 | 206 |
! |
207 |
||
208 |
version_SVN |
|
15341 | 209 |
^ '$Id: BookmarkMenuBuilder.st,v 1.10 2015-02-20 15:37:15 cg Exp $' |
9968 | 210 |
! ! |
13435 | 211 |