equal
deleted
inserted
replaced
12 "{ Package: 'stx:libtool' }" |
12 "{ Package: 'stx:libtool' }" |
13 |
13 |
14 "{ NameSpace: Tools }" |
14 "{ NameSpace: Tools }" |
15 |
15 |
16 Object subclass:#NavigationHistory |
16 Object subclass:#NavigationHistory |
17 instanceVariableNames:'items position isGlobalHistory' |
17 instanceVariableNames:'items position isGlobalHistory maxNumberOfItems' |
18 classVariableNames:'' |
18 classVariableNames:'' |
19 poolDictionaries:'' |
19 poolDictionaries:'' |
20 category:'Interface-Browsers-New-History' |
20 category:'Interface-Browsers-New-History' |
21 ! |
21 ! |
22 |
22 |
61 "Created: / 21-02-2008 / 15:26:05 / janfrog" |
61 "Created: / 21-02-2008 / 15:26:05 / janfrog" |
62 ! ! |
62 ! ! |
63 |
63 |
64 !NavigationHistory methodsFor:'accessing'! |
64 !NavigationHistory methodsFor:'accessing'! |
65 |
65 |
|
66 addFirst:anEntry |
|
67 "list protocol" |
|
68 |
|
69 maxNumberOfItems == 0 ifTrue:[^ self]. |
|
70 |
|
71 items addFirst:anEntry. |
|
72 items size > maxNumberOfItems ifTrue:[ |
|
73 items removeLast |
|
74 ]. |
|
75 self changed: #value with: anEntry. |
|
76 |
|
77 "Created: / 03-07-2011 / 13:26:48 / cg" |
|
78 ! |
|
79 |
|
80 addLast:anEntry |
|
81 "list protocol" |
|
82 |
|
83 maxNumberOfItems == 0 ifTrue:[^ self]. |
|
84 |
|
85 items addLast:anEntry. |
|
86 items size > maxNumberOfItems ifTrue:[ |
|
87 items removeFirst |
|
88 ]. |
|
89 self changed: #value with: anEntry. |
|
90 |
|
91 "Created: / 03-07-2011 / 13:26:48 / cg" |
|
92 ! |
|
93 |
66 currentItem |
94 currentItem |
67 |
95 |
68 ^(position between:1 and: items size) |
96 ^(position between:1 and: items size) |
69 ifTrue:[items at: position] |
97 ifTrue:[items at: position] |
70 ifFalse:[nil] |
98 ifFalse:[nil] |
93 |
121 |
94 ^ items copyFrom:position + 1 |
122 ^ items copyFrom:position + 1 |
95 |
123 |
96 "Created: / 27-02-2008 / 11:52:26 / janfrog" |
124 "Created: / 27-02-2008 / 11:52:26 / janfrog" |
97 "Modified: / 03-07-2011 / 16:00:45 / cg" |
125 "Modified: / 03-07-2011 / 16:00:45 / cg" |
|
126 ! |
|
127 |
|
128 maxItemsInHistory:aNumber |
|
129 maxNumberOfItems := aNumber max:1. |
|
130 maxNumberOfItems > items size ifTrue:[ |
|
131 items removeFromIndex:maxNumberOfItems+1 toIndex:items size. |
|
132 position := maxNumberOfItems. |
|
133 self changed. |
|
134 ]. |
98 ! ! |
135 ! ! |
99 |
136 |
100 !NavigationHistory methodsFor:'backward list compatibility'! |
137 !NavigationHistory methodsFor:'backward list compatibility'! |
101 |
|
102 addFirst:anEntry |
|
103 "backward compatible list protocol" |
|
104 |
|
105 items addFirst:anEntry. |
|
106 items size > 30 ifTrue:[ |
|
107 items removeLast |
|
108 ]. |
|
109 self changed: #value with: anEntry. |
|
110 |
|
111 "Created: / 03-07-2011 / 13:26:48 / cg" |
|
112 ! |
|
113 |
138 |
114 collect:aBlock |
139 collect:aBlock |
115 "backward compatible list protocol" |
140 "backward compatible list protocol" |
116 |
141 |
117 ^ items collect:aBlock |
142 ^ items collect:aBlock |
221 |
246 |
222 "/ super initialize. -- commented since inherited method does nothing |
247 "/ super initialize. -- commented since inherited method does nothing |
223 items := OrderedCollection new. |
248 items := OrderedCollection new. |
224 position := 0. |
249 position := 0. |
225 isGlobalHistory := false. |
250 isGlobalHistory := false. |
|
251 maxNumberOfItems := maxNumberOfItems ? 30. |
226 |
252 |
227 "Created: / 21-02-2008 / 15:26:05 / janfrog" |
253 "Created: / 21-02-2008 / 15:26:05 / janfrog" |
228 "Modified: / 03-07-2011 / 14:43:08 / cg" |
254 "Modified: / 03-07-2011 / 14:43:08 / cg" |
229 ! ! |
255 ! ! |
230 |
256 |
231 !NavigationHistory methodsFor:'menu & menu actions'! |
257 !NavigationHistory methodsFor:'menu & menu actions'! |
232 |
258 |
|
259 clearHistory |
|
260 self removeAll. |
|
261 position := 0. |
|
262 self changed. |
|
263 ! |
|
264 |
233 goBackMenu |
265 goBackMenu |
234 |menu| |
266 |menu any| |
235 |
267 |
|
268 any := false. |
236 menu := Menu new. |
269 menu := Menu new. |
237 self goBackItems do:[:item | |
270 self goBackItems do:[:item | |
238 menu addItem:(MenuItem label:item displayString value:[ self goTo:item ]) |
271 menu addItem:(MenuItem label:item displayString itemValue:[ self goTo:item ]). |
239 ]. |
272 any := true. |
|
273 ]. |
|
274 menu addSeparator. |
|
275 menu addItem:((MenuItem label:'Clear History' value:[ self clearHistory]) enabled:any). |
240 ^ menu |
276 ^ menu |
241 |
277 |
242 "Created: / 22-02-2008 / 16:57:46 / janfrog" |
278 "Created: / 22-02-2008 / 16:57:46 / janfrog" |
243 "Modified: / 27-02-2008 / 11:52:12 / janfrog" |
279 "Modified: / 27-02-2008 / 11:52:12 / janfrog" |
244 ! |
280 ! |
246 goForwardMenu |
282 goForwardMenu |
247 |menu| |
283 |menu| |
248 |
284 |
249 menu := Menu new. |
285 menu := Menu new. |
250 self goForwardItems do:[:item | |
286 self goForwardItems do:[:item | |
251 menu addItem:(MenuItem label:item displayString value:[ self goTo:item ]) |
287 menu addItem:(MenuItem label:item displayString itemValue:[ self goTo:item ]) |
252 ]. |
288 ]. |
253 ^ menu |
289 ^ menu |
254 |
290 |
255 "Created: / 22-02-2008 / 16:58:11 / janfrog" |
291 "Created: / 22-02-2008 / 16:58:11 / janfrog" |
256 "Modified: / 27-02-2008 / 11:52:26 / janfrog" |
292 "Modified: / 27-02-2008 / 11:52:26 / janfrog" |
292 idx := items indexOf:navigationHistoryItem. |
328 idx := items indexOf:navigationHistoryItem. |
293 isGlobalHistory ifTrue:[ |
329 isGlobalHistory ifTrue:[ |
294 idx ~~ 0 ifTrue:[ |
330 idx ~~ 0 ifTrue:[ |
295 items removeIndex:idx. |
331 items removeIndex:idx. |
296 ]. |
332 ]. |
297 items addFirst:navigationHistoryItem. |
333 self addFirst:navigationHistoryItem. |
298 ] ifFalse:[ |
334 ] ifFalse:[ |
299 idx == 0 ifFalse: [ |
335 idx ~~ 0 ifTrue: [ |
|
336 "/ already in list |
300 position := idx |
337 position := idx |
301 ] ifTrue:[ |
338 ] ifFalse:[ |
302 position < items size ifTrue:[ |
339 position < items size ifTrue:[ |
303 items removeFromIndex: position + 1 toIndex: items size |
340 items removeFromIndex: position + 1 toIndex: items size |
304 ]. |
341 ]. |
305 items addLast: navigationHistoryItem. |
342 items addLast: navigationHistoryItem. |
306 position := position + 1 |
343 items size > maxNumberOfItems ifTrue:[ |
|
344 items removeFirst |
|
345 ] ifFalse:[ |
|
346 position := position + 1 |
|
347 ]. |
307 ]. |
348 ]. |
308 ]. |
349 ]. |
309 |
350 |
310 "/ for the canGoXXX apect. |
351 "/ for the canGoXXX apect. |
311 self changed: #value with: navigationHistoryItem. |
352 self changed: #value with: navigationHistoryItem. |
336 ! ! |
377 ! ! |
337 |
378 |
338 !NavigationHistory class methodsFor:'documentation'! |
379 !NavigationHistory class methodsFor:'documentation'! |
339 |
380 |
340 version_CVS |
381 version_CVS |
341 ^ '$Header: /cvs/stx/stx/libtool/Tools__NavigationHistory.st,v 1.14 2012-11-13 09:07:18 mb Exp $' |
382 ^ '$Header: /cvs/stx/stx/libtool/Tools__NavigationHistory.st,v 1.16 2013-06-21 00:43:18 cg Exp $' |
342 ! |
383 ! |
343 |
384 |
344 version_CVS_jvrany |
385 version_CVS_jvrany |
345 ^ '§Header: /opt/data/cvs/stx/goodies/libtool3/Tools__NavigationHistory.st,v 1.2 2008-02-27 13:45:21 vranyj1 Exp §' |
386 ^ '$Header: /cvs/stx/stx/libtool/Tools__NavigationHistory.st,v 1.16 2013-06-21 00:43:18 cg Exp $' |
346 ! |
387 ! |
347 |
388 |
348 version_HG |
389 version_HG |
349 |
390 |
350 ^ '$Changeset: <not expanded> $' |
391 ^ '$Changeset: <not expanded> $' |
351 ! |
392 ! |
352 |
393 |
353 version_SVN |
394 version_SVN |
354 ^ '§Id: Tools__NavigationHistory.st 7486 2009-10-26 22:06:24Z vranyj1 §' |
395 ^ '$Id: Tools__NavigationHistory.st,v 1.16 2013-06-21 00:43:18 cg Exp $' |
355 ! ! |
396 ! ! |
356 |
397 |