author | Stefan Vogel <sv@exept.de> |
Fri, 17 May 2019 17:11:44 +0200 | |
changeset 18767 | 0478d93cdb75 |
parent 17955 | d0ef962513da |
child 18894 | 1b99fefd5825 |
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 |
|
17955 | 132 |
menuItemGotoBookmark:anObject |
133 |
|label icon menuItem| |
|
9968 | 134 |
|
135 |
label := anObject label. |
|
136 |
icon := anObject icon. |
|
17955 | 137 |
menuItem := MenuItem |
138 |
label:label |
|
139 |
itemValue:#switchToBookmarkEntry: |
|
140 |
argument:anObject. |
|
141 |
icon notNil ifTrue:[ menuItem labelImage:(LabelAndIcon label:label icon:icon). ]. |
|
142 |
menuItem activeHelpKey:(anObject helpText). |
|
143 |
menuItem translateLabel:false. |
|
144 |
||
145 |
^ menuItem |
|
9968 | 146 |
|
147 |
"Created: / 21-06-2011 / 07:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10912 | 148 |
"Modified: / 29-11-2011 / 11:21:20 / cg" |
17955 | 149 |
"Modified: / 24-01-2018 / 16:17:03 / mawalch" |
9968 | 150 |
! ! |
151 |
||
152 |
!BookmarkMenuBuilder methodsFor:'visiting'! |
|
153 |
||
10281 | 154 |
buildMenuFor: anObject |
155 |
^ self |
|
156 |
visit: anObject; |
|
157 |
menu |
|
158 |
||
159 |
"Created: / 02-06-2011 / 21:52:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
160 |
"Created: / 08-07-2011 / 11:37:42 / cg" |
|
161 |
! |
|
162 |
||
9968 | 163 |
visitBookmark:anObject |
164 |
|item| |
|
165 |
||
166 |
item := self menuItemGotoBookmark:anObject. |
|
167 |
stack top addItem:item |
|
168 |
||
169 |
"Created: / 23-05-2011 / 10:42:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
170 |
"Modified: / 21-06-2011 / 07:55:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
171 |
! |
|
172 |
||
173 |
visitFolder:anObject |
|
174 |
|item submenu| |
|
175 |
||
17491 | 176 |
anObject parent isNil ifTrue:[ |
177 |
anObject children ? #() do:[:child | self visit:child ] |
|
178 |
] ifFalse:[ |
|
179 |
item := self menuItemFolder: anObject. |
|
180 |
stack top addItem:item. |
|
181 |
submenu := Menu new. |
|
182 |
item submenu:submenu. |
|
183 |
stack push:submenu. |
|
184 |
anObject children ? #() do:[:child | self visit:child ]. |
|
185 |
stack top hasItems ifTrue:[ stack top addSeparator ]. |
|
186 |
item := self menuItemAddBookmark:anObject. |
|
187 |
stack top addItem:item. |
|
188 |
stack pop |
|
189 |
]. |
|
9968 | 190 |
|
191 |
"Created: / 23-05-2011 / 10:38:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
192 |
"Modified: / 21-06-2011 / 08:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
17491 | 193 |
"Modified (format): / 11-04-2017 / 01:57:33 / cg" |
9968 | 194 |
! |
195 |
||
196 |
visitSeparator:anObject |
|
197 |
||
198 |
stack top addItem: MenuItem separator |
|
199 |
||
200 |
"Created: / 03-06-2011 / 13:41:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
201 |
! ! |
|
202 |
||
203 |
!BookmarkMenuBuilder class methodsFor:'documentation'! |
|
204 |
||
15341 | 205 |
version |
17491 | 206 |
^ '$Header$' |
15341 | 207 |
! |
208 |
||
9968 | 209 |
version_CVS |
17491 | 210 |
^ '$Header$' |
9968 | 211 |
! |
212 |
||
213 |
version_SVN |
|
17491 | 214 |
^ '$Id$' |
9968 | 215 |
! ! |
13435 | 216 |