author | Claus Gittinger <cg@exept.de> |
Sat, 13 Jul 2019 14:00:30 +0200 | |
changeset 18895 | f081b08d0755 |
parent 18894 | 1b99fefd5825 |
permissions | -rw-r--r-- |
18895 | 1 |
"{ Encoding: utf8 }" |
2 |
||
9968 | 3 |
" |
10087 | 4 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
5 |
Copyright (c) 2009-2010 eXept Software AG |
|
9968 | 6 |
|
10087 | 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. |
|
9968 | 27 |
" |
28 |
"{ Package: 'stx:libtool' }" |
|
29 |
||
15339 | 30 |
"{ NameSpace: Smalltalk }" |
31 |
||
9968 | 32 |
BookmarkVisitor subclass:#BookmarkMenuBuilder |
18894 | 33 |
instanceVariableNames:'menu stack toolbar' |
9968 | 34 |
classVariableNames:'' |
35 |
poolDictionaries:'' |
|
36 |
category:'Interface-Bookmarks' |
|
37 |
! |
|
38 |
||
39 |
!BookmarkMenuBuilder class methodsFor:'documentation'! |
|
40 |
||
41 |
copyright |
|
42 |
" |
|
10087 | 43 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
44 |
Copyright (c) 2009-2010 eXept Software AG |
|
45 |
||
46 |
Permission is hereby granted, free of charge, to any person |
|
47 |
obtaining a copy of this software and associated documentation |
|
48 |
files (the 'Software'), to deal in the Software without |
|
49 |
restriction, including without limitation the rights to use, |
|
50 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
51 |
copies of the Software, and to permit persons to whom the |
|
52 |
Software is furnished to do so, subject to the following |
|
53 |
conditions: |
|
9968 | 54 |
|
10087 | 55 |
The above copyright notice and this permission notice shall be |
56 |
included in all copies or substantial portions of the Software. |
|
57 |
||
58 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
59 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
60 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
61 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
62 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
63 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
64 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
65 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9968 | 66 |
" |
67 |
! ! |
|
68 |
||
69 |
!BookmarkMenuBuilder class methodsFor:'instance creation'! |
|
70 |
||
71 |
new |
|
72 |
"return an initialized instance" |
|
73 |
||
74 |
^ self basicNew initialize. |
|
75 |
! ! |
|
76 |
||
77 |
!BookmarkMenuBuilder methodsFor:'accessing'! |
|
78 |
||
79 |
menu |
|
80 |
||
81 |
^ menu |
|
82 |
||
83 |
"Created: / 23-05-2011 / 10:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
84 |
! ! |
|
85 |
||
86 |
!BookmarkMenuBuilder methodsFor:'initialization'! |
|
87 |
||
88 |
initialize |
|
89 |
menu := Menu new. |
|
10296
020772a7653e
BookmarkMenuBuilder>>initialize: initialize resources to empty one
vrany
parents:
10281
diff
changeset
|
90 |
stack := Stack with: menu. |
9968 | 91 |
|
10296
020772a7653e
BookmarkMenuBuilder>>initialize: initialize resources to empty one
vrany
parents:
10281
diff
changeset
|
92 |
"Modified: / 08-07-2011 / 13:49:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9968 | 93 |
! ! |
94 |
||
95 |
!BookmarkMenuBuilder methodsFor:'utilities'! |
|
96 |
||
97 |
menuItemAddBookmark:anObject |
|
98 |
||
99 |
||
100 |
^self menuItemAddBookmark:anObject labeled:'Add Bookmark Here'. |
|
101 |
||
102 |
"Modified: / 21-06-2011 / 08:00:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10281 | 103 |
"Modified: / 08-07-2011 / 11:39:31 / cg" |
9968 | 104 |
! |
105 |
||
106 |
menuItemAddBookmark:anObject labeled: label |
|
14580 | 107 |
^ (MenuItem |
18895 | 108 |
label:((Smalltalk at:#stx_libtool) classResources string:label) |
13435 | 109 |
itemValue:#menuAddBookmarkTo: |
14580 | 110 |
argument:anObject) |
111 |
translateLabel:false. |
|
9968 | 112 |
|
113 |
"Created: / 21-06-2011 / 07:59:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10281 | 114 |
"Modified: / 08-07-2011 / 11:39:40 / cg" |
18895 | 115 |
"Modified: / 13-07-2019 / 14:00:25 / Claus Gittinger" |
9968 | 116 |
! |
117 |
||
10547
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
118 |
menuItemFolder: folder |
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
119 |
|
14580 | 120 |
^ (MenuItem |
121 |
label:folder label) |
|
122 |
translateLabel:false. |
|
10547
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
123 |
|
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
124 |
"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
|
125 |
! |
1003e0421fcf
category of: #menuItemFolder:
Claus Gittinger <cg@exept.de>
parents:
10296
diff
changeset
|
126 |
|
17955 | 127 |
menuItemGotoBookmark:anObject |
128 |
|label icon menuItem| |
|
9968 | 129 |
|
130 |
label := anObject label. |
|
131 |
icon := anObject icon. |
|
17955 | 132 |
menuItem := MenuItem |
133 |
label:label |
|
134 |
itemValue:#switchToBookmarkEntry: |
|
135 |
argument:anObject. |
|
136 |
icon notNil ifTrue:[ menuItem labelImage:(LabelAndIcon label:label icon:icon). ]. |
|
137 |
menuItem activeHelpKey:(anObject helpText). |
|
138 |
menuItem translateLabel:false. |
|
139 |
||
140 |
^ menuItem |
|
9968 | 141 |
|
142 |
"Created: / 21-06-2011 / 07:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10912 | 143 |
"Modified: / 29-11-2011 / 11:21:20 / cg" |
17955 | 144 |
"Modified: / 24-01-2018 / 16:17:03 / mawalch" |
9968 | 145 |
! ! |
146 |
||
147 |
!BookmarkMenuBuilder methodsFor:'visiting'! |
|
148 |
||
10281 | 149 |
buildMenuFor: anObject |
150 |
^ self |
|
151 |
visit: anObject; |
|
152 |
menu |
|
153 |
||
154 |
"Created: / 02-06-2011 / 21:52:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
155 |
"Created: / 08-07-2011 / 11:37:42 / cg" |
|
156 |
! |
|
157 |
||
9968 | 158 |
visitBookmark:anObject |
159 |
|item| |
|
160 |
||
161 |
item := self menuItemGotoBookmark:anObject. |
|
162 |
stack top addItem:item |
|
163 |
||
164 |
"Created: / 23-05-2011 / 10:42:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
165 |
"Modified: / 21-06-2011 / 07:55:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
166 |
! |
|
167 |
||
168 |
visitFolder:anObject |
|
169 |
|item submenu| |
|
170 |
||
17491 | 171 |
anObject parent isNil ifTrue:[ |
172 |
anObject children ? #() do:[:child | self visit:child ] |
|
173 |
] ifFalse:[ |
|
174 |
item := self menuItemFolder: anObject. |
|
175 |
stack top addItem:item. |
|
176 |
submenu := Menu new. |
|
177 |
item submenu:submenu. |
|
178 |
stack push:submenu. |
|
179 |
anObject children ? #() do:[:child | self visit:child ]. |
|
180 |
stack top hasItems ifTrue:[ stack top addSeparator ]. |
|
181 |
item := self menuItemAddBookmark:anObject. |
|
182 |
stack top addItem:item. |
|
183 |
stack pop |
|
184 |
]. |
|
9968 | 185 |
|
186 |
"Created: / 23-05-2011 / 10:38:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
187 |
"Modified: / 21-06-2011 / 08:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
17491 | 188 |
"Modified (format): / 11-04-2017 / 01:57:33 / cg" |
9968 | 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 |
17491 | 201 |
^ '$Header$' |
15341 | 202 |
! |
203 |
||
9968 | 204 |
version_CVS |
17491 | 205 |
^ '$Header$' |
9968 | 206 |
! |
207 |
||
208 |
version_SVN |
|
17491 | 209 |
^ '$Id$' |
9968 | 210 |
! ! |
13435 | 211 |