author | Jan Vrany <jan.vrany@labware.com> |
Sat, 30 Sep 2023 22:55:25 +0100 | |
branch | jv |
changeset 19648 | 5df52d354504 |
parent 18226 | 346376844040 |
permissions | -rw-r--r-- |
9989 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
18226 | 3 |
COPYRIGHT (c) 2015 Jan Vrany |
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
4 |
All Rights Reserved |
9989 | 5 |
|
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
13 |
"{ Package: 'stx:libtool' }" |
|
8778 | 14 |
|
15 |
"{ NameSpace: Tools }" |
|
16 |
||
17 |
Object subclass:#NavigationHistory |
|
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
18 |
instanceVariableNames:'items position isGlobalHistory maxNumberOfItems' |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
19 |
classVariableNames:'' |
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
20 |
poolDictionaries:'' |
11775 | 21 |
category:'Interface-Browsers-New-History' |
8778 | 22 |
! |
23 |
||
9989 | 24 |
!NavigationHistory class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
18226 | 29 |
COPYRIGHT (c) 2015 Jan Vrany |
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 |
||
168 |
^ items do:aBlock |
|
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. |
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
279 |
menu addItem:((MenuItem label:'Clear History' value:[ 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" |
|
284 |
! |
|
285 |
||
286 |
goForwardMenu |
|
287 |
|menu| |
|
288 |
||
289 |
menu := Menu new. |
|
290 |
self goForwardItems do:[:item | |
|
12959
5e2fa8919e77
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12890
diff
changeset
|
291 |
menu addItem:(MenuItem label:item displayString itemValue:[ self goTo:item ]) |
8778 | 292 |
]. |
293 |
^ menu |
|
294 |
||
295 |
"Created: / 22-02-2008 / 16:58:11 / janfrog" |
|
296 |
"Modified: / 27-02-2008 / 11:52:26 / janfrog" |
|
297 |
! ! |
|
298 |
||
299 |
!NavigationHistory methodsFor:'navigation'! |
|
300 |
||
301 |
goBack |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
302 |
| value | |
8778 | 303 |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
304 |
isGlobalHistory ifTrue:[ |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
305 |
items size <= 1 ifTrue:[^ nil]. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
306 |
^ self goTo:(items second). |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
307 |
]. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
308 |
|
8778 | 309 |
position := (position - 1) max: 1. |
310 |
self changed: #currentItem with: (value := self currentItem). |
|
311 |
^value |
|
312 |
||
313 |
"Created: / 21-02-2008 / 16:37:37 / janfrog" |
|
314 |
"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
|
315 |
"Modified: / 03-07-2011 / 16:19:27 / cg" |
8778 | 316 |
! |
317 |
||
318 |
goForward |
|
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
319 |
| value | |
8778 | 320 |
|
321 |
position := (position + 1) min: items size. |
|
322 |
self changed: #currentItem with: (value := self currentItem). |
|
323 |
^value |
|
324 |
||
325 |
"Created: / 21-02-2008 / 16:37:37 / janfrog" |
|
326 |
"Modified: / 27-02-2008 / 08:48:24 / janfrog" |
|
327 |
! |
|
328 |
||
329 |
goTo: navigationHistoryItem |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
330 |
| idx | |
8778 | 331 |
|
15844
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
332 |
idx := items lastIndexOf:navigationHistoryItem. |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
333 |
"/ do not uodate history if we go twice in a row into a same item... |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
334 |
(idx ~~ 0 and:[ idx == position ]) ifTrue:[ ^ self ]. |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
335 |
|
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
336 |
isGlobalHistory ifTrue:[ |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
337 |
idx ~~ 0 ifTrue:[ |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
338 |
items removeIndex:idx. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
339 |
]. |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
340 |
self addFirst:navigationHistoryItem. |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
341 |
] ifFalse:[ |
15844
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
342 |
position < items size ifTrue:[ |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
343 |
items removeFromIndex: position + 1 toIndex: items size |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
344 |
]. |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
345 |
items addLast: navigationHistoryItem. |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
346 |
items size > maxNumberOfItems ifTrue:[ |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
347 |
items removeFirst |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
348 |
] ifFalse:[ |
15844
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
349 |
position := position + 1 |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
350 |
]. |
10049
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
351 |
]. |
8b6c0289ff0a
hack: configurable to behave either as a global history
Claus Gittinger <cg@exept.de>
parents:
9989
diff
changeset
|
352 |
|
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
353 |
"/ for the canGoXXX apect. |
8778 | 354 |
self changed: #value with: navigationHistoryItem. |
10121
9ffc433015ec
comment/format in: #goForward
Claus Gittinger <cg@exept.de>
parents:
10049
diff
changeset
|
355 |
^ navigationHistoryItem |
8778 | 356 |
|
357 |
"Created: / 21-02-2008 / 16:40:39 / janfrog" |
|
358 |
"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
|
359 |
"Modified: / 03-07-2011 / 16:03:11 / cg" |
15844
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
360 |
"Modified (comment): / 04-09-2015 / 07:24:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
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 |
||
15844
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
392 |
version_HG |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
393 |
|
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
394 |
^ '$Changeset: <not expanded> $' |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
395 |
! |
024b2d99744a
More standard behaviour of navigation history
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15566
diff
changeset
|
396 |
|
9989 | 397 |
version_SVN |
16303 | 398 |
^ '$Id$' |
8778 | 399 |
! ! |
12890
0db0cf4e8a72
class: Tools::NavigationHistory
Claus Gittinger <cg@exept.de>
parents:
12058
diff
changeset
|
400 |