9989
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libtool' }"
|
8778
|
13 |
|
|
14 |
"{ NameSpace: Tools }"
|
|
15 |
|
|
16 |
Object subclass:#NavigationHistory
|
|
17 |
instanceVariableNames:'items position'
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Interface-History'
|
|
21 |
!
|
|
22 |
|
9989
|
23 |
!NavigationHistory class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
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 |
"
|
|
37 |
! !
|
8778
|
38 |
|
|
39 |
!NavigationHistory class methodsFor:'instance creation'!
|
|
40 |
|
|
41 |
new
|
|
42 |
^ self basicNew initialize.
|
|
43 |
|
|
44 |
"Created: / 21-02-2008 / 15:26:05 / janfrog"
|
|
45 |
! !
|
|
46 |
|
|
47 |
!NavigationHistory methodsFor:'accessing'!
|
|
48 |
|
|
49 |
currentItem
|
|
50 |
|
|
51 |
^(position between:1 and: items size)
|
|
52 |
ifTrue:[items at: position]
|
|
53 |
ifFalse:[nil]
|
|
54 |
|
|
55 |
"Created: / 27-02-2008 / 08:46:37 / janfrog"
|
|
56 |
!
|
|
57 |
|
|
58 |
currentItem: anObject
|
|
59 |
|
|
60 |
self goTo: anObject
|
|
61 |
|
|
62 |
"Created: / 27-02-2008 / 08:47:04 / janfrog"
|
|
63 |
!
|
|
64 |
|
|
65 |
goBackItems
|
|
66 |
^ (items copyTo:position - 1) reverse
|
|
67 |
|
|
68 |
"Created: / 27-02-2008 / 11:52:12 / janfrog"
|
|
69 |
!
|
|
70 |
|
|
71 |
goForwardItems
|
|
72 |
^ items copyFrom:position + 1
|
|
73 |
|
|
74 |
"Created: / 27-02-2008 / 11:52:26 / janfrog"
|
|
75 |
! !
|
|
76 |
|
|
77 |
!NavigationHistory methodsFor:'initialization'!
|
|
78 |
|
|
79 |
initialize
|
|
80 |
"Invoked when a new instance is created."
|
|
81 |
|
|
82 |
"/ please change as required (and remove this comment)
|
|
83 |
"/ items := nil.
|
|
84 |
"/ position := nil.
|
|
85 |
|
|
86 |
"/ super initialize. -- commented since inherited method does nothing
|
|
87 |
items := OrderedCollection new.
|
|
88 |
position := 0
|
|
89 |
|
|
90 |
"Created: / 21-02-2008 / 15:26:05 / janfrog"
|
|
91 |
! !
|
|
92 |
|
|
93 |
!NavigationHistory methodsFor:'menu & menu actions'!
|
|
94 |
|
|
95 |
goBackMenu
|
|
96 |
|menu|
|
|
97 |
|
|
98 |
menu := Menu new.
|
|
99 |
self goBackItems do:[:item |
|
|
100 |
menu addItem:(MenuItem label:item displayString value:[ self goTo:item ])
|
|
101 |
].
|
|
102 |
^ menu
|
|
103 |
|
|
104 |
"Created: / 22-02-2008 / 16:57:46 / janfrog"
|
|
105 |
"Modified: / 27-02-2008 / 11:52:12 / janfrog"
|
|
106 |
!
|
|
107 |
|
|
108 |
goForwardMenu
|
|
109 |
|menu|
|
|
110 |
|
|
111 |
menu := Menu new.
|
|
112 |
self goForwardItems do:[:item |
|
|
113 |
menu addItem:(MenuItem label:item displayString value:[ self goTo:item ])
|
|
114 |
].
|
|
115 |
^ menu
|
|
116 |
|
|
117 |
"Created: / 22-02-2008 / 16:58:11 / janfrog"
|
|
118 |
"Modified: / 27-02-2008 / 11:52:26 / janfrog"
|
|
119 |
! !
|
|
120 |
|
|
121 |
!NavigationHistory methodsFor:'navigation'!
|
|
122 |
|
|
123 |
goBack
|
|
124 |
|
|
125 |
| value |
|
|
126 |
position := (position - 1) max: 1.
|
|
127 |
self changed: #currentItem with: (value := self currentItem).
|
|
128 |
^value
|
|
129 |
|
|
130 |
"Created: / 21-02-2008 / 16:37:37 / janfrog"
|
|
131 |
"Modified: / 27-02-2008 / 08:48:14 / janfrog"
|
|
132 |
!
|
|
133 |
|
|
134 |
goForward
|
|
135 |
|
|
136 |
| value |
|
|
137 |
position := (position + 1) min: items size.
|
|
138 |
self changed: #currentItem with: (value := self currentItem).
|
|
139 |
^value
|
|
140 |
|
|
141 |
"Created: / 21-02-2008 / 16:37:37 / janfrog"
|
|
142 |
"Modified: / 27-02-2008 / 08:48:24 / janfrog"
|
|
143 |
!
|
|
144 |
|
|
145 |
goTo: navigationHistoryItem
|
|
146 |
|
|
147 |
| idx |
|
|
148 |
idx := items indexOf:navigationHistoryItem.
|
|
149 |
idx isZero
|
|
150 |
ifFalse:
|
|
151 |
[position := idx]
|
|
152 |
ifTrue:
|
|
153 |
[position < items size ifTrue:
|
|
154 |
[items removeFromIndex: position + 1 toIndex: items size].
|
|
155 |
items addLast: navigationHistoryItem.
|
|
156 |
position := position + 1].
|
|
157 |
self changed: #value with: navigationHistoryItem.
|
|
158 |
^navigationHistoryItem
|
|
159 |
|
|
160 |
"Created: / 21-02-2008 / 16:40:39 / janfrog"
|
|
161 |
"Modified: / 21-02-2008 / 19:12:35 / janfrog"
|
|
162 |
! !
|
|
163 |
|
|
164 |
!NavigationHistory methodsFor:'queries'!
|
|
165 |
|
|
166 |
canGoBack
|
|
167 |
|
|
168 |
^position > 1
|
|
169 |
|
|
170 |
"Created: / 21-02-2008 / 16:40:48 / janfrog"
|
|
171 |
!
|
|
172 |
|
|
173 |
canGoForward
|
|
174 |
|
|
175 |
^position < items size
|
|
176 |
|
|
177 |
"Created: / 21-02-2008 / 16:40:48 / janfrog"
|
|
178 |
! !
|
|
179 |
|
|
180 |
!NavigationHistory class methodsFor:'documentation'!
|
|
181 |
|
8804
|
182 |
version_CVS
|
9989
|
183 |
^ '$Header: /cvs/stx/stx/libtool/Tools__NavigationHistory.st,v 1.4 2011-07-01 13:25:23 cg Exp $'
|
8804
|
184 |
!
|
|
185 |
|
8818
|
186 |
version_CVS_jvrany
|
9989
|
187 |
^ '§Header: /opt/data/cvs/stx/goodies/libtool3/Tools__NavigationHistory.st,v 1.2 2008-02-27 13:45:21 vranyj1 Exp §'
|
|
188 |
!
|
|
189 |
|
|
190 |
version_SVN
|
|
191 |
^ '§Id: Tools__NavigationHistory.st 7486 2009-10-26 22:06:24Z vranyj1 §'
|
8778
|
192 |
! !
|