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