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