author | Claus Gittinger <cg@exept.de> |
Mon, 15 Jul 2019 18:47:18 +0200 | |
changeset 18902 | c2dea21fb224 |
parent 17483 | 406802aafd7d |
child 19023 | f246f2c30f8b |
permissions | -rw-r--r-- |
9989 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
3 |
All Rights Reserved |
9989 | 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' }" |
|
8778 | 13 |
|
14 |
"{ NameSpace: Tools }" |
|
15 |
||
16 |
Object subclass:#NavigationHistory |
|
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
17 |
instanceVariableNames:'items position isGlobalHistory maxNumberOfItems' |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
18 |
classVariableNames:'' |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
19 |
poolDictionaries:'' |
11775 | 20 |
category:'Interface-Browsers-New-History' |
8778 | 21 |
! |
22 |
||
9989 | 23 |
!NavigationHistory class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
28 |
All Rights Reserved |
9989 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
37 |
! |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
38 |
|
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
39 |
documentation |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
40 |
" |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
41 |
two variants: |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
42 |
a forward-backward history, as in a browser: |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
43 |
navigating backward moves a pointer in a list |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
44 |
a global history |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
45 |
navigating moves the navigated item to the front position |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
46 |
|
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
47 |
hack: configurable to behave either as a global history |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
48 |
or as a local-tab navigation history. |
16668 | 49 |
Also implement backward compatible list-style access interface, |
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
50 |
to support old browsers (I guess, this is temporary and the other |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
51 |
users of the global history (debugger, old systembrowser etc. should |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
52 |
be changed) |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
53 |
" |
9989 | 54 |
! ! |
8778 | 55 |
|
56 |
!NavigationHistory class methodsFor:'instance creation'! |
|
57 |
||
58 |
new |
|
59 |
^ self basicNew initialize. |
|
60 |
||
61 |
"Created: / 21-02-2008 / 15:26:05 / janfrog" |
|
62 |
! ! |
|
63 |
||
64 |
!NavigationHistory methodsFor:'accessing'! |
|
65 |
||
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
66 |
addFirst:anEntry |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
67 |
"list protocol" |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
68 |
|
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
69 |
maxNumberOfItems == 0 ifTrue:[^ self]. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
70 |
|
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
71 |
items addFirst:anEntry. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
72 |
items size > maxNumberOfItems ifTrue:[ |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
73 |
items removeLast |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
74 |
]. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
75 |
self changed: #value with: anEntry. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
76 |
|
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
77 |
"Created: / 03-07-2011 / 13:26:48 / cg" |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
78 |
! |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
79 |
|
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
80 |
addLast:anEntry |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
81 |
"list protocol" |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
82 |
|
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
83 |
maxNumberOfItems == 0 ifTrue:[^ self]. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
84 |
|
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
85 |
items addLast:anEntry. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
86 |
items size > maxNumberOfItems ifTrue:[ |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
87 |
items removeFirst |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
88 |
]. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
89 |
self changed: #value with: anEntry. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
90 |
|
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
91 |
"Created: / 03-07-2011 / 13:26:48 / cg" |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
92 |
! |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
93 |
|
8778 | 94 |
currentItem |
95 |
||
96 |
^(position between:1 and: items size) |
|
97 |
ifTrue:[items at: position] |
|
98 |
ifFalse:[nil] |
|
99 |
||
100 |
"Created: / 27-02-2008 / 08:46:37 / janfrog" |
|
101 |
! |
|
102 |
||
103 |
currentItem: anObject |
|
104 |
||
105 |
self goTo: anObject |
|
106 |
||
107 |
"Created: / 27-02-2008 / 08:47:04 / janfrog" |
|
108 |
! |
|
109 |
||
110 |
goBackItems |
|
10176 | 111 |
isGlobalHistory ifTrue:[^ items "isEmpty ifTrue:[items] ifFalse:[items copyFrom:2]"]. |
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
112 |
|
8778 | 113 |
^ (items copyTo:position - 1) reverse |
114 |
||
115 |
"Created: / 27-02-2008 / 11:52:12 / janfrog" |
|
10176 | 116 |
"Modified: / 05-07-2011 / 16:53:18 / cg" |
8778 | 117 |
! |
118 |
||
119 |
goForwardItems |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
120 |
isGlobalHistory ifTrue:[^ #()]. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
121 |
|
8778 | 122 |
^ items copyFrom:position + 1 |
123 |
||
124 |
"Created: / 27-02-2008 / 11:52:26 / janfrog" |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
125 |
"Modified: / 03-07-2011 / 16:00:45 / cg" |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
126 |
! |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
127 |
|
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
128 |
maxItemsInHistory:aNumber |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
129 |
maxNumberOfItems := aNumber max:1. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
130 |
maxNumberOfItems > items size ifTrue:[ |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
131 |
items removeFromIndex:maxNumberOfItems+1 toIndex:items size. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
132 |
position := maxNumberOfItems. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
133 |
self changed. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
134 |
]. |
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
135 |
! ! |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
136 |
|
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
137 |
!NavigationHistory methodsFor:'backward list compatibility'! |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
138 |
|
10142 | 139 |
collect:aBlock |
140 |
"backward compatible list protocol" |
|
141 |
||
142 |
^ items collect:aBlock |
|
143 |
||
144 |
"Created: / 04-07-2011 / 22:45:21 / cg" |
|
145 |
! |
|
146 |
||
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
147 |
collect:aBlock thenSelect:filter |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
148 |
"backward compatible list protocol" |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
149 |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
150 |
^ items collect:aBlock thenSelect:filter |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
151 |
|
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
152 |
"Created: / 03-07-2011 / 13:34:14 / cg" |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
153 |
! |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
154 |
|
16303 | 155 |
detect:aBlock ifNone:exceptionalValue |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
156 |
"backward compatible list protocol" |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
157 |
|
16303 | 158 |
^ items detect:aBlock ifNone:exceptionalValue |
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
159 |
|
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
160 |
"Created: / 03-07-2011 / 13:25:37 / cg" |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
161 |
! |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
162 |
|
12058 | 163 |
do:aBlock |
164 |
"backward compatible list protocol" |
|
165 |
||
166 |
^ items do:aBlock |
|
167 |
! |
|
168 |
||
11904 | 169 |
first |
170 |
"backward compatible list protocol" |
|
171 |
||
172 |
^ items first |
|
173 |
||
174 |
"Created: / 04-07-2011 / 22:45:21 / cg" |
|
175 |
! |
|
176 |
||
10142 | 177 |
isEmpty |
178 |
"backward compatible list protocol" |
|
179 |
||
180 |
^ items isEmpty |
|
181 |
||
182 |
"Created: / 04-07-2011 / 22:44:54 / cg" |
|
183 |
! |
|
184 |
||
11906 | 185 |
isEmptyOrNil |
186 |
"backward compatible list protocol" |
|
187 |
||
188 |
^ items isEmptyOrNil |
|
189 |
||
190 |
"Created: / 04-07-2011 / 22:44:54 / cg" |
|
191 |
! |
|
192 |
||
10142 | 193 |
notEmpty |
194 |
"backward compatible list protocol" |
|
195 |
||
196 |
^ items notEmpty |
|
197 |
||
198 |
"Created: / 04-07-2011 / 22:45:45 / cg" |
|
199 |
! |
|
200 |
||
11906 | 201 |
notEmptyOrNil |
202 |
"backward compatible list protocol" |
|
203 |
||
204 |
^ items notEmptyOrNil |
|
205 |
||
206 |
"Created: / 04-07-2011 / 22:45:45 / cg" |
|
207 |
! |
|
208 |
||
10715 | 209 |
removeAll |
14137
e8d33bcf9513
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12959
diff
changeset
|
210 |
"backward compatible list protocol" |
e8d33bcf9513
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12959
diff
changeset
|
211 |
|
10715 | 212 |
items removeAll. |
213 |
||
214 |
"Created: / 21-09-2011 / 16:27:38 / cg" |
|
215 |
! |
|
216 |
||
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
217 |
removeIdentical:anEntry |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
218 |
"backward compatible list protocol" |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
219 |
|
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
220 |
items removeIdentical:anEntry. |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
221 |
self changed: #value with:nil. |
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
222 |
|
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
223 |
"Created: / 03-07-2011 / 13:27:34 / cg" |
10142 | 224 |
! |
225 |
||
226 |
reverseDo:aBlock |
|
227 |
"backward compatible list protocol" |
|
228 |
||
229 |
items reverseDo:aBlock |
|
230 |
||
231 |
"Created: / 04-07-2011 / 22:44:28 / cg" |
|
8778 | 232 |
! ! |
233 |
||
234 |
!NavigationHistory methodsFor:'initialization'! |
|
235 |
||
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
236 |
beGlobalHistory |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
237 |
isGlobalHistory := true |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
238 |
|
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
239 |
"Created: / 03-07-2011 / 14:42:57 / cg" |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
240 |
! |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
241 |
|
8778 | 242 |
initialize |
243 |
"Invoked when a new instance is created." |
|
244 |
||
245 |
"/ please change as required (and remove this comment) |
|
246 |
"/ items := nil. |
|
247 |
"/ position := nil. |
|
248 |
||
249 |
"/ super initialize. -- commented since inherited method does nothing |
|
250 |
items := OrderedCollection new. |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
251 |
position := 0. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
252 |
isGlobalHistory := false. |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
253 |
maxNumberOfItems := maxNumberOfItems ? 30. |
8778 | 254 |
|
255 |
"Created: / 21-02-2008 / 15:26:05 / janfrog" |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
256 |
"Modified: / 03-07-2011 / 14:43:08 / cg" |
8778 | 257 |
! ! |
258 |
||
259 |
!NavigationHistory methodsFor:'menu & menu actions'! |
|
260 |
||
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
261 |
clearHistory |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
262 |
self removeAll. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
263 |
position := 0. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
264 |
self changed. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
265 |
! |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
266 |
|
8778 | 267 |
goBackMenu |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
268 |
|menu any| |
8778 | 269 |
|
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
270 |
any := false. |
8778 | 271 |
menu := Menu new. |
272 |
self goBackItems do:[:item | |
|
12959
5e2fa8919e77
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12890
diff
changeset
|
273 |
menu addItem:(MenuItem label:item displayString itemValue:[ self goTo:item ]). |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
274 |
any := true. |
8778 | 275 |
]. |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
276 |
menu addSeparator. |
17483 | 277 |
menu addItem:((MenuItem label:'Clear History' itemValue:[ self clearHistory]) enabled:any). |
8778 | 278 |
^ menu |
279 |
||
280 |
"Created: / 22-02-2008 / 16:57:46 / janfrog" |
|
281 |
"Modified: / 27-02-2008 / 11:52:12 / janfrog" |
|
17483 | 282 |
"Modified: / 29-03-2017 / 13:03:27 / stefan" |
8778 | 283 |
! |
284 |
||
285 |
goForwardMenu |
|
286 |
|menu| |
|
287 |
||
288 |
menu := Menu new. |
|
289 |
self goForwardItems do:[:item | |
|
12959
5e2fa8919e77
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12890
diff
changeset
|
290 |
menu addItem:(MenuItem label:item displayString itemValue:[ self goTo:item ]) |
8778 | 291 |
]. |
292 |
^ menu |
|
293 |
||
294 |
"Created: / 22-02-2008 / 16:58:11 / janfrog" |
|
295 |
"Modified: / 27-02-2008 / 11:52:26 / janfrog" |
|
296 |
! ! |
|
297 |
||
298 |
!NavigationHistory methodsFor:'navigation'! |
|
299 |
||
300 |
goBack |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
301 |
| value | |
8778 | 302 |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
303 |
isGlobalHistory ifTrue:[ |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
304 |
items size <= 1 ifTrue:[^ nil]. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
305 |
^ self goTo:(items second). |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
306 |
]. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
307 |
|
8778 | 308 |
position := (position - 1) max: 1. |
309 |
self changed: #currentItem with: (value := self currentItem). |
|
310 |
^value |
|
311 |
||
312 |
"Created: / 21-02-2008 / 16:37:37 / janfrog" |
|
313 |
"Modified: / 27-02-2008 / 08:48:14 / janfrog" |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
314 |
"Modified: / 03-07-2011 / 16:19:27 / cg" |
8778 | 315 |
! |
316 |
||
317 |
goForward |
|
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
318 |
| value | |
8778 | 319 |
|
320 |
position := (position + 1) min: items size. |
|
321 |
self changed: #currentItem with: (value := self currentItem). |
|
322 |
^value |
|
323 |
||
324 |
"Created: / 21-02-2008 / 16:37:37 / janfrog" |
|
325 |
"Modified: / 27-02-2008 / 08:48:24 / janfrog" |
|
326 |
! |
|
327 |
||
328 |
goTo: navigationHistoryItem |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
329 |
| idx | |
8778 | 330 |
|
331 |
idx := items indexOf:navigationHistoryItem. |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
332 |
isGlobalHistory ifTrue:[ |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
333 |
idx ~~ 0 ifTrue:[ |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
334 |
items removeIndex:idx. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
335 |
]. |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
336 |
self addFirst:navigationHistoryItem. |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
337 |
] ifFalse:[ |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
338 |
idx ~~ 0 ifTrue: [ |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
339 |
"/ already in list |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
340 |
position := idx |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
341 |
] ifFalse:[ |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
342 |
position < items size ifTrue:[ |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
343 |
items removeFromIndex: position + 1 toIndex: items size |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
344 |
]. |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
345 |
items addLast: navigationHistoryItem. |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
346 |
items size > maxNumberOfItems ifTrue:[ |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
347 |
items removeFirst |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
348 |
] ifFalse:[ |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
349 |
position := position + 1 |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
350 |
]. |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
351 |
]. |
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
352 |
]. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
353 |
|
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
354 |
"/ for the canGoXXX apect. |
8778 | 355 |
self changed: #value with: navigationHistoryItem. |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
356 |
^ navigationHistoryItem |
8778 | 357 |
|
358 |
"Created: / 21-02-2008 / 16:40:39 / janfrog" |
|
359 |
"Modified: / 21-02-2008 / 19:12:35 / janfrog" |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
360 |
"Modified: / 03-07-2011 / 16:03:11 / cg" |
8778 | 361 |
! ! |
362 |
||
363 |
!NavigationHistory methodsFor:'queries'! |
|
364 |
||
365 |
canGoBack |
|
10122 | 366 |
isGlobalHistory ifTrue:[ |
367 |
^ items size > 2 |
|
368 |
]. |
|
8778 | 369 |
|
10122 | 370 |
^ position > 1 |
8778 | 371 |
|
372 |
"Created: / 21-02-2008 / 16:40:48 / janfrog" |
|
373 |
! |
|
374 |
||
375 |
canGoForward |
|
376 |
||
377 |
^position < items size |
|
378 |
||
379 |
"Created: / 21-02-2008 / 16:40:48 / janfrog" |
|
380 |
! ! |
|
381 |
||
382 |
!NavigationHistory class methodsFor:'documentation'! |
|
383 |
||
8804 | 384 |
version_CVS |
16303 | 385 |
^ '$Header$' |
8804 | 386 |
! |
387 |
||
8818 | 388 |
version_CVS_jvrany |
16303 | 389 |
^ '$Header$' |
9989 | 390 |
! |
391 |
||
392 |
version_SVN |
|
16303 | 393 |
^ '$Id$' |
8778 | 394 |
! ! |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
395 |