9968
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libtool' }"
|
|
13 |
|
|
14 |
BookmarkVisitor subclass:#BookmarkMenuBuilder
|
|
15 |
instanceVariableNames:'menu stack toolbar'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'Interface-Bookmarks'
|
|
19 |
!
|
|
20 |
|
|
21 |
!BookmarkMenuBuilder class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
! !
|
|
36 |
|
|
37 |
!BookmarkMenuBuilder class methodsFor:'instance creation'!
|
|
38 |
|
|
39 |
buildMenuFor: anObject
|
|
40 |
|
|
41 |
^self new
|
|
42 |
visit: anObject;
|
|
43 |
menu
|
|
44 |
|
|
45 |
"Created: / 02-06-2011 / 21:52:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
46 |
!
|
|
47 |
|
|
48 |
new
|
|
49 |
"return an initialized instance"
|
|
50 |
|
|
51 |
^ self basicNew initialize.
|
|
52 |
! !
|
|
53 |
|
|
54 |
!BookmarkMenuBuilder methodsFor:'* uncategorized *'!
|
|
55 |
|
|
56 |
menuItemFolder: folder
|
|
57 |
|
|
58 |
^(MenuItem labeled:folder label)
|
|
59 |
|
|
60 |
"Created: / 21-06-2011 / 08:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
61 |
! !
|
|
62 |
|
|
63 |
!BookmarkMenuBuilder methodsFor:'accessing'!
|
|
64 |
|
|
65 |
menu
|
|
66 |
|
|
67 |
^ menu
|
|
68 |
|
|
69 |
"Created: / 23-05-2011 / 10:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
70 |
! !
|
|
71 |
|
|
72 |
!BookmarkMenuBuilder methodsFor:'initialization'!
|
|
73 |
|
|
74 |
initialize
|
|
75 |
|
|
76 |
menu := Menu new.
|
|
77 |
stack := Stack with: menu
|
|
78 |
|
|
79 |
"/ super initialize. -- commented since inherited method does nothing
|
|
80 |
|
|
81 |
"Modified: / 23-05-2011 / 10:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
82 |
! !
|
|
83 |
|
|
84 |
!BookmarkMenuBuilder methodsFor:'utilities'!
|
|
85 |
|
|
86 |
menuItemAddBookmark:anObject
|
|
87 |
|
|
88 |
|
|
89 |
^self menuItemAddBookmark:anObject labeled:'Add Bookmark Here'.
|
|
90 |
|
|
91 |
"Modified: / 21-06-2011 / 08:00:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
92 |
!
|
|
93 |
|
|
94 |
menuItemAddBookmark:anObject labeled: label
|
|
95 |
|item|
|
|
96 |
|
|
97 |
item := MenuItem labeled: label.
|
|
98 |
item
|
|
99 |
value:#menuAddBookmarkTo:;
|
|
100 |
argument:anObject.
|
|
101 |
^ item
|
|
102 |
|
|
103 |
"Created: / 21-06-2011 / 07:59:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
104 |
!
|
|
105 |
|
|
106 |
menuItemGotoBookmark:anObject
|
|
107 |
|item icon label|
|
|
108 |
|
|
109 |
label := anObject label.
|
|
110 |
icon := anObject icon.
|
|
111 |
icon ifNotNil:[ label := LabelAndIcon label:label icon:icon ].
|
|
112 |
item := (MenuItem labeled:label)
|
|
113 |
value:#switchToBookmarkEntry:;
|
|
114 |
argument:anObject.
|
|
115 |
^ item
|
|
116 |
|
|
117 |
"Created: / 21-06-2011 / 07:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
118 |
! !
|
|
119 |
|
|
120 |
!BookmarkMenuBuilder methodsFor:'visiting'!
|
|
121 |
|
|
122 |
visitBookmark:anObject
|
|
123 |
|item|
|
|
124 |
|
|
125 |
item := self menuItemGotoBookmark:anObject.
|
|
126 |
stack top addItem:item
|
|
127 |
|
|
128 |
"Created: / 23-05-2011 / 10:42:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
129 |
"Modified: / 21-06-2011 / 07:55:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
130 |
!
|
|
131 |
|
|
132 |
visitFolder:anObject
|
|
133 |
|item submenu|
|
|
134 |
|
|
135 |
anObject parent isNil
|
|
136 |
ifTrue:[ anObject children ? #() do:[:child | self visit:child ] ]
|
|
137 |
ifFalse:
|
|
138 |
[ item := self menuItemFolder: anObject.
|
|
139 |
stack top addItem:item.
|
|
140 |
submenu := Menu new.
|
|
141 |
item submenu:submenu.
|
|
142 |
stack push:submenu.
|
|
143 |
anObject children ? #() do:[:child | self visit:child ].
|
|
144 |
stack top hasItems ifTrue:[ stack top addSeparator ].
|
|
145 |
item := self menuItemAddBookmark:anObject.
|
|
146 |
stack top addItem:item.
|
|
147 |
stack pop ].
|
|
148 |
|
|
149 |
"Created: / 23-05-2011 / 10:38:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
150 |
"Modified: / 21-06-2011 / 08:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
151 |
!
|
|
152 |
|
|
153 |
visitSeparator:anObject
|
|
154 |
|
|
155 |
stack top addItem: MenuItem separator
|
|
156 |
|
|
157 |
"Created: / 03-06-2011 / 13:41:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
158 |
! !
|
|
159 |
|
|
160 |
!BookmarkMenuBuilder class methodsFor:'documentation'!
|
|
161 |
|
|
162 |
version_CVS
|
|
163 |
^ '$Header: /cvs/stx/stx/libtool/BookmarkMenuBuilder.st,v 1.1 2011-07-01 13:14:18 cg Exp $'
|
|
164 |
!
|
|
165 |
|
|
166 |
version_SVN
|
|
167 |
^ '§Id§'
|
|
168 |
! !
|