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
|
|
29 |
instanceVariableNames:'menu stack toolbar'
|
|
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 |
buildMenuFor: anObject
|
|
68 |
|
|
69 |
^self new
|
|
70 |
visit: anObject;
|
|
71 |
menu
|
|
72 |
|
|
73 |
"Created: / 02-06-2011 / 21:52:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
74 |
!
|
|
75 |
|
|
76 |
new
|
|
77 |
"return an initialized instance"
|
|
78 |
|
|
79 |
^ self basicNew initialize.
|
|
80 |
! !
|
|
81 |
|
|
82 |
!BookmarkMenuBuilder methodsFor:'* uncategorized *'!
|
|
83 |
|
|
84 |
menuItemFolder: folder
|
|
85 |
|
|
86 |
^(MenuItem labeled:folder label)
|
|
87 |
|
|
88 |
"Created: / 21-06-2011 / 08:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
89 |
! !
|
|
90 |
|
|
91 |
!BookmarkMenuBuilder methodsFor:'accessing'!
|
|
92 |
|
|
93 |
menu
|
|
94 |
|
|
95 |
^ menu
|
|
96 |
|
|
97 |
"Created: / 23-05-2011 / 10:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
98 |
! !
|
|
99 |
|
|
100 |
!BookmarkMenuBuilder methodsFor:'initialization'!
|
|
101 |
|
|
102 |
initialize
|
|
103 |
|
|
104 |
menu := Menu new.
|
|
105 |
stack := Stack with: menu
|
|
106 |
|
|
107 |
"/ super initialize. -- commented since inherited method does nothing
|
|
108 |
|
|
109 |
"Modified: / 23-05-2011 / 10:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
110 |
! !
|
|
111 |
|
|
112 |
!BookmarkMenuBuilder methodsFor:'utilities'!
|
|
113 |
|
|
114 |
menuItemAddBookmark:anObject
|
|
115 |
|
|
116 |
|
|
117 |
^self menuItemAddBookmark:anObject labeled:'Add Bookmark Here'.
|
|
118 |
|
|
119 |
"Modified: / 21-06-2011 / 08:00:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
120 |
!
|
|
121 |
|
|
122 |
menuItemAddBookmark:anObject labeled: label
|
|
123 |
|item|
|
|
124 |
|
|
125 |
item := MenuItem labeled: label.
|
|
126 |
item
|
|
127 |
value:#menuAddBookmarkTo:;
|
|
128 |
argument:anObject.
|
|
129 |
^ item
|
|
130 |
|
|
131 |
"Created: / 21-06-2011 / 07:59:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
132 |
!
|
|
133 |
|
|
134 |
menuItemGotoBookmark:anObject
|
|
135 |
|item icon label|
|
|
136 |
|
|
137 |
label := anObject label.
|
|
138 |
icon := anObject icon.
|
|
139 |
icon ifNotNil:[ label := LabelAndIcon label:label icon:icon ].
|
|
140 |
item := (MenuItem labeled:label)
|
|
141 |
value:#switchToBookmarkEntry:;
|
|
142 |
argument:anObject.
|
|
143 |
^ item
|
|
144 |
|
|
145 |
"Created: / 21-06-2011 / 07:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
146 |
! !
|
|
147 |
|
|
148 |
!BookmarkMenuBuilder methodsFor:'visiting'!
|
|
149 |
|
|
150 |
visitBookmark:anObject
|
|
151 |
|item|
|
|
152 |
|
|
153 |
item := self menuItemGotoBookmark:anObject.
|
|
154 |
stack top addItem:item
|
|
155 |
|
|
156 |
"Created: / 23-05-2011 / 10:42:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
157 |
"Modified: / 21-06-2011 / 07:55:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
158 |
!
|
|
159 |
|
|
160 |
visitFolder:anObject
|
|
161 |
|item submenu|
|
|
162 |
|
|
163 |
anObject parent isNil
|
|
164 |
ifTrue:[ anObject children ? #() do:[:child | self visit:child ] ]
|
|
165 |
ifFalse:
|
|
166 |
[ item := self menuItemFolder: anObject.
|
|
167 |
stack top addItem:item.
|
|
168 |
submenu := Menu new.
|
|
169 |
item submenu:submenu.
|
|
170 |
stack push:submenu.
|
|
171 |
anObject children ? #() do:[:child | self visit:child ].
|
|
172 |
stack top hasItems ifTrue:[ stack top addSeparator ].
|
|
173 |
item := self menuItemAddBookmark:anObject.
|
|
174 |
stack top addItem:item.
|
|
175 |
stack pop ].
|
|
176 |
|
|
177 |
"Created: / 23-05-2011 / 10:38:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
178 |
"Modified: / 21-06-2011 / 08:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
179 |
!
|
|
180 |
|
|
181 |
visitSeparator:anObject
|
|
182 |
|
|
183 |
stack top addItem: MenuItem separator
|
|
184 |
|
|
185 |
"Created: / 03-06-2011 / 13:41:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
186 |
! !
|
|
187 |
|
|
188 |
!BookmarkMenuBuilder class methodsFor:'documentation'!
|
|
189 |
|
|
190 |
version_CVS
|
10087
|
191 |
^ '$Header: /cvs/stx/stx/libtool/BookmarkMenuBuilder.st,v 1.2 2011-07-03 18:00:59 cg Exp $'
|
9968
|
192 |
!
|
|
193 |
|
|
194 |
version_SVN
|
|
195 |
^ '§Id§'
|
|
196 |
! !
|