author | viric@llimona |
Wed, 17 Jan 2007 19:14:26 +0100 | |
changeset 12 | 3932322b7d83 |
parent 10 | 757b42639637 |
permissions | -rw-r--r-- |
0 | 1 |
package horaris; |
2 |
||
3 |
import ogdl.*; |
|
4 |
||
5 |
import javax.microedition.lcdui.*; |
|
6 |
import java.util.Vector; |
|
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
7 |
import java.util.Hashtable; |
0 | 8 |
import java.lang.Exception; |
9 |
||
5 | 10 |
public class HoraroTransporta |
11 |
implements CommandListener, ItemStateListener, Ekrano |
|
0 | 12 |
{ |
12 | 13 |
private Horaro h; |
0 | 14 |
|
15 |
private Form myform; |
|
16 |
private ChoiceGroup ftagoj; |
|
17 |
private ChoiceGroup fsenco; |
|
18 |
private ChoiceGroup fkomenco; |
|
19 |
private ChoiceGroup ffino; |
|
20 |
private Command cmd_sercxi; |
|
21 |
private Command cmd_malantauxen; |
|
5 | 22 |
|
23 |
private Ekrano last; |
|
0 | 24 |
|
25 |
private TimeList mytimelist; |
|
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
26 |
|
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
27 |
private Vector temporezulto; |
8 | 28 |
private Vector tmpTempoj; |
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
29 |
private Hashtable inforezulto; |
0 | 30 |
|
31 |
||
12 | 32 |
public HoraroTransporta(Horaro _h, Ekrano _last) throws Exception |
0 | 33 |
{ |
12 | 34 |
h = _h; |
5 | 35 |
last = _last; |
0 | 36 |
|
37 |
myform = new Form("Cerca"); |
|
38 |
||
39 |
/* Items */ |
|
40 |
ftagoj = new ChoiceGroup("Dia", ChoiceGroup.MULTIPLE); |
|
41 |
addTagoj(ftagoj); |
|
42 |
myform.append(ftagoj); |
|
4
f92e04d4bfe5
Default Tagoj. Implicit Main List. Less println.
viric@llimona
parents:
2
diff
changeset
|
43 |
defaultTagoj(); |
0 | 44 |
|
45 |
fsenco = new ChoiceGroup("Sentit", ChoiceGroup.EXCLUSIVE); |
|
46 |
addSencoj(fsenco); |
|
47 |
myform.append(fsenco); |
|
48 |
||
9
9f8e342f193e
Moving from MIDP2/CLDC1.1 to MIDP1/CLDC1.0. Added About windows.
viric@mandarina
parents:
8
diff
changeset
|
49 |
fkomenco = new ChoiceGroup("Origen", ChoiceGroup.EXCLUSIVE); |
0 | 50 |
addLokoj(fkomenco); |
51 |
myform.append(fkomenco); |
|
52 |
||
9
9f8e342f193e
Moving from MIDP2/CLDC1.1 to MIDP1/CLDC1.0. Added About windows.
viric@mandarina
parents:
8
diff
changeset
|
53 |
ffino = new ChoiceGroup("DestÃ", ChoiceGroup.EXCLUSIVE); |
0 | 54 |
addLokoj(ffino); |
55 |
myform.append(ffino); |
|
56 |
||
12 | 57 |
/* |
2 | 58 |
defaultKomencoFino(); |
12 | 59 |
*/ |
2 | 60 |
|
0 | 61 |
/* Commands */ |
62 |
cmd_sercxi = new Command("Buscar", Command.OK, 0); |
|
63 |
cmd_malantauxen = new Command("Enrera", Command.BACK, 0); |
|
64 |
myform.addCommand(cmd_sercxi); |
|
65 |
myform.addCommand(cmd_malantauxen); |
|
66 |
myform.setCommandListener(this); |
|
67 |
myform.setItemStateListener(this); |
|
10 | 68 |
|
69 |
show(); |
|
70 |
} |
|
71 |
||
72 |
public void show() |
|
73 |
{ |
|
74 |
mytimelist = null; |
|
5 | 75 |
Main.display.setCurrent(myform); |
0 | 76 |
} |
77 |
||
78 |
private void addTagoj(ChoiceGroup g) |
|
79 |
{ |
|
12 | 80 |
for (int i=0; i < h.tagoj.size(); i++) |
81 |
g.append((String) h.tagoj.elementAt(i), null); |
|
0 | 82 |
} |
83 |
||
84 |
private void addSencoj(ChoiceGroup g) { |
|
85 |
||
12 | 86 |
for (int i=0; i < h.sencoj.size(); i++) |
87 |
g.append((String) h.sencoj.elementAt(i), null); |
|
0 | 88 |
} |
89 |
||
90 |
private void addLokoj(ChoiceGroup g) { |
|
91 |
||
12 | 92 |
for (int i=0; i < h.lokoj.size(); i++) |
93 |
g.append((String) h.lokoj.elementAt(i), null); |
|
0 | 94 |
} |
95 |
||
96 |
private boolean inVector(Vector v, String s) |
|
97 |
{ |
|
98 |
for (int i=0; i < v.size(); i++) |
|
99 |
if(s.equals((String)v.elementAt(i))) |
|
100 |
return true; |
|
101 |
return false; |
|
102 |
} |
|
103 |
||
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
104 |
private void sercxiTempojn(Vector tagoj, String senco, |
0 | 105 |
String komenco, String fino) |
106 |
{ |
|
12 | 107 |
// temporezulto = new Vector(); |
108 |
// tmpTempoj = new Vector(); |
|
109 |
// inforezulto = new Hashtable(); |
|
110 |
// |
|
111 |
// for (int i=0; i < radiko.size(); i++) |
|
112 |
// { |
|
113 |
// if (! radiko.get(i).getName().equals("Comboi")) |
|
114 |
// continue; |
|
115 |
// |
|
116 |
// Graph veturo = radiko.get(i); |
|
117 |
// Graph gtmp; |
|
118 |
// boolean bona; |
|
119 |
// |
|
120 |
// String elirtempo = null, alventempo = null; |
|
121 |
// |
|
122 |
// /* Dies */ |
|
123 |
// gtmp = veturo.getNode("Dies"); |
|
124 |
// bona = false; |
|
125 |
// for(int j=0; j < gtmp.size(); j++) |
|
126 |
// { |
|
127 |
// if (inVector(tagoj, gtmp.get(j).getName()) ) |
|
128 |
// bona = true; |
|
129 |
// } |
|
130 |
// if (bona != true) |
|
131 |
// continue; |
|
132 |
// |
|
133 |
// /* Sentits */ |
|
134 |
// gtmp = veturo.getNode("Sentit"); |
|
135 |
// bona = false; |
|
136 |
// for(int j=0; j < gtmp.size(); j++) |
|
137 |
// { |
|
138 |
// if (senco.equals(gtmp.get(j).getName())) |
|
139 |
// bona = true; |
|
140 |
// } |
|
141 |
// if (bona != true) |
|
142 |
// continue; |
|
143 |
// |
|
144 |
// /* Komenco kaj Fino */ |
|
145 |
// gtmp = veturo.getNode("Hores"); |
|
146 |
// for(int j=0; j < gtmp.size(); j++) |
|
147 |
// { |
|
148 |
// String stacio = gtmp.get(j).get(0).getName(); |
|
149 |
// |
|
150 |
// if (stacio.equals(komenco)) |
|
151 |
// { |
|
152 |
// elirtempo = gtmp.get(j).getName(); |
|
153 |
// } |
|
154 |
// else if (stacio.equals(fino)) |
|
155 |
// { |
|
156 |
// alventempo = gtmp.get(j).getName(); |
|
157 |
// } |
|
158 |
// } |
|
159 |
// if (elirtempo == null || alventempo == null) |
|
160 |
// continue; |
|
161 |
// |
|
162 |
// /* Krei la informon aldonan */ |
|
163 |
// gtmp = veturo.getNode("Comentari"); |
|
164 |
// Vector comments = new Vector(); |
|
165 |
// if (gtmp != null) |
|
166 |
// { |
|
167 |
// for (int j = 0; j < gtmp.size(); j++) |
|
168 |
// { |
|
169 |
// comments.addElement(gtmp.get(j).getName()); |
|
170 |
// } |
|
171 |
// } |
|
172 |
// |
|
173 |
// /* Trovita! */ |
|
174 |
// addSortedTime(elirtempo, alventempo, comments); |
|
175 |
// } |
|
176 |
// |
|
177 |
// /* Free memory */ |
|
178 |
// tmpTempoj = null; |
|
0 | 179 |
} |
2 | 180 |
|
181 |
private Tempo str2Tempo(String s) |
|
182 |
{ |
|
183 |
int i = s.indexOf('-'); |
|
184 |
return new Tempo(s.substring(0,i)); |
|
185 |
} |
|
186 |
||
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
187 |
private void addSortedTime(String eliro, String alveno, Vector comments) |
2 | 188 |
{ |
189 |
Tempo teliro = new Tempo(eliro); |
|
190 |
boolean set = false; |
|
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
191 |
|
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
192 |
String montro = eliro + "-" + alveno; |
2 | 193 |
|
8 | 194 |
for(int i=0; i< tmpTempoj.size(); i++) |
2 | 195 |
{ |
196 |
Tempo tmp; |
|
8 | 197 |
tmp = (Tempo) tmpTempoj.elementAt(i); |
2 | 198 |
if (tmp.compareTo(teliro) > 0) |
199 |
{ |
|
200 |
set = true; |
|
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
201 |
temporezulto.insertElementAt(montro, i); |
8 | 202 |
tmpTempoj.insertElementAt(teliro, i); |
2 | 203 |
break; |
204 |
} |
|
205 |
} |
|
206 |
if (set == false) |
|
207 |
{ |
|
8 | 208 |
temporezulto.addElement(montro); |
209 |
tmpTempoj.addElement(teliro); |
|
2 | 210 |
} |
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
211 |
inforezulto.put(montro, comments); |
2 | 212 |
} |
0 | 213 |
|
214 |
public void commandAction(Command c, Displayable d) |
|
215 |
{ |
|
216 |
||
217 |
if (c == cmd_sercxi) |
|
218 |
{ |
|
12 | 219 |
/* |
0 | 220 |
Vector tagoj = new Vector(); |
221 |
for (int i = 0; i < ftagoj.size(); i++) |
|
222 |
{ |
|
223 |
if (ftagoj.isSelected(i)) |
|
224 |
tagoj.addElement(ftagoj.getString(i)); |
|
225 |
} |
|
226 |
String senco = |
|
227 |
fsenco.getString(fsenco.getSelectedIndex()); |
|
228 |
String komenco = |
|
229 |
fkomenco.getString(fkomenco.getSelectedIndex()); |
|
230 |
String fino = |
|
231 |
ffino.getString(ffino.getSelectedIndex()); |
|
12 | 232 |
*/ |
0 | 233 |
|
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
234 |
/* Donos rezulton en temporezulto kaj inforezulto */ |
12 | 235 |
/* |
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
236 |
sercxiTempojn(tagoj, senco, komenco, fino); |
12 | 237 |
*/ |
0 | 238 |
|
12 | 239 |
/* |
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
240 |
if (temporezulto.size() > 0) |
0 | 241 |
{ |
7
19f4a2b1a4b9
Added option for showing comments for each Convoy.
viric@mandarina
parents:
5
diff
changeset
|
242 |
mytimelist = new TimeList(temporezulto, inforezulto, this); |
0 | 243 |
mytimelist.show(); |
244 |
} |
|
12 | 245 |
*/ |
0 | 246 |
} else if (c == cmd_malantauxen) |
247 |
{ |
|
5 | 248 |
last.show(); |
0 | 249 |
} |
250 |
} |
|
251 |
||
4
f92e04d4bfe5
Default Tagoj. Implicit Main List. Less println.
viric@llimona
parents:
2
diff
changeset
|
252 |
private void defaultTagoj() |
f92e04d4bfe5
Default Tagoj. Implicit Main List. Less println.
viric@llimona
parents:
2
diff
changeset
|
253 |
{ |
12 | 254 |
ftagoj.setSelectedIndex(h.defaulttago, true); |
4
f92e04d4bfe5
Default Tagoj. Implicit Main List. Less println.
viric@llimona
parents:
2
diff
changeset
|
255 |
} |
f92e04d4bfe5
Default Tagoj. Implicit Main List. Less println.
viric@llimona
parents:
2
diff
changeset
|
256 |
|
12 | 257 |
/* |
2 | 258 |
private void defaultKomencoFino() |
259 |
{ |
|
260 |
String elektita; |
|
261 |
elektita = fsenco.getString(fsenco.getSelectedIndex()); |
|
262 |
||
263 |
Graph komenco; |
|
264 |
komenco = sencoj.getNode(elektita).get(0); |
|
265 |
if (komenco == null) |
|
266 |
return; |
|
267 |
||
268 |
for (int i = 0; i < fkomenco.size(); i++) |
|
269 |
if (fkomenco.getString(i).equals(komenco.getName())) |
|
270 |
fkomenco.setSelectedIndex(i, true); |
|
271 |
||
272 |
Graph fino; |
|
273 |
fino = sencoj.getNode(elektita).get(1); |
|
274 |
if (fino == null) |
|
275 |
return; |
|
276 |
||
277 |
for (int i = 0; i < ffino.size(); i++) |
|
278 |
if (ffino.getString(i).equals(fino.getName())) |
|
279 |
ffino.setSelectedIndex(i, true); |
|
280 |
} |
|
12 | 281 |
*/ |
2 | 282 |
|
0 | 283 |
public void itemStateChanged(Item item) |
284 |
{ |
|
2 | 285 |
if (item == fsenco) |
286 |
{ |
|
12 | 287 |
/* |
2 | 288 |
defaultKomencoFino(); |
12 | 289 |
*/ |
2 | 290 |
} |
0 | 291 |
} |
292 |
} |