Added option for showing comments for each Convoy.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/horaris/Ekrano.java Sun Jan 14 11:49:55 2007 +0100
@@ -0,0 +1,6 @@
+package horaris;
+
+public interface Ekrano
+{
+ public void show();
+}
--- a/src/horaris/HoraroTransporta.java Sat Jan 13 15:41:06 2007 +0100
+++ b/src/horaris/HoraroTransporta.java Sun Jan 14 11:49:55 2007 +0100
@@ -4,6 +4,7 @@
import javax.microedition.lcdui.*;
import java.util.Vector;
+import java.util.Hashtable;
import java.lang.Exception;
public class HoraroTransporta
@@ -26,6 +27,9 @@
private Ekrano last;
private TimeList mytimelist;
+
+ private Vector temporezulto;
+ private Hashtable inforezulto;
public HoraroTransporta(Graph _radiko, Ekrano _last) throws Exception
@@ -106,10 +110,11 @@
return false;
}
- private Vector sercxiTempojn(Vector tagoj, String senco,
+ private void sercxiTempojn(Vector tagoj, String senco,
String komenco, String fino)
{
- Vector v = new Vector();
+ temporezulto = new Vector();
+ inforezulto = new Hashtable();
for (int i=0; i < radiko.size(); i++)
{
@@ -162,11 +167,17 @@
if (elirtempo == null || alventempo == null)
continue;
+ /* Krei la informon aldonan */
+ gtmp = veturo.getNode("Comentari");
+ Vector comments = new Vector();
+ for (int j = 0; j < gtmp.size(); j++)
+ {
+ comments.addElement(gtmp.get(j).getName());
+ }
+
/* Trovita! */
- addSortedTime(v, elirtempo, alventempo);
+ addSortedTime(elirtempo, alventempo, comments);
}
-
- return v;
}
private Tempo str2Tempo(String s)
@@ -175,26 +186,29 @@
return new Tempo(s.substring(0,i));
}
- private void addSortedTime(Vector v, String eliro, String alveno)
+ private void addSortedTime(String eliro, String alveno, Vector comments)
{
Tempo teliro = new Tempo(eliro);
boolean set = false;
+
+ String montro = eliro + "-" + alveno;
- for(int i=0; i< v.size(); i++)
+ for(int i=0; i< temporezulto.size(); i++)
{
Tempo tmp;
- tmp = str2Tempo((String) v.elementAt(i));
+ tmp = str2Tempo((String) temporezulto.elementAt(i));
if (tmp.compareTo(teliro) > 0)
{
set = true;
- v.insertElementAt(eliro + "-" + alveno, i);
+ temporezulto.insertElementAt(montro, i);
break;
}
}
if (set == false)
{
- v.insertElementAt(eliro + "-" + alveno, v.size());
+ temporezulto.insertElementAt(montro, temporezulto.size());
}
+ inforezulto.put(montro, comments);
}
public void commandAction(Command c, Displayable d)
@@ -215,11 +229,12 @@
String fino =
ffino.getString(ffino.getSelectedIndex());
- Vector t = sercxiTempojn(tagoj, senco, komenco, fino);
+ /* Donos rezulton en temporezulto kaj inforezulto */
+ sercxiTempojn(tagoj, senco, komenco, fino);
- if (t.size() > 0)
+ if (temporezulto.size() > 0)
{
- mytimelist = new TimeList(t,this);
+ mytimelist = new TimeList(temporezulto, inforezulto, this);
mytimelist.show();
}
} else if (c == cmd_malantauxen)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/horaris/ShowText.java Sun Jan 14 11:49:55 2007 +0100
@@ -0,0 +1,59 @@
+package horaris;
+
+import ogdl.*;
+
+import javax.microedition.lcdui.*;
+import java.util.Vector;
+import java.lang.Exception;
+
+public class ShowText
+ implements CommandListener, Ekrano
+{
+ private Form myform;
+ private Command cmd_malantauxen;
+
+ private Ekrano last;
+
+ private Vector texts;
+
+
+ public ShowText(Vector _texts, Ekrano _last)
+ {
+ texts = _texts;
+ last = _last;
+ show();
+ }
+
+ public ShowText(String text, Ekrano _last)
+ {
+ texts = new Vector();
+ texts.addElement(text);
+ show();
+ }
+
+ public void show()
+ {
+ myform = new Form("Info");
+
+ for (int i = 0; i < texts.size(); i++)
+ {
+ StringItem sitem = new StringItem(null, (String) texts.elementAt(i));
+ myform.append(sitem);
+ }
+
+ /* Commands */
+ cmd_malantauxen = new Command("Enrera", Command.BACK, 0);
+ myform.addCommand(cmd_malantauxen);
+ myform.setCommandListener(this);
+ Main.display.setCurrent(myform);
+ }
+
+ public void commandAction(Command c, Displayable d)
+ {
+
+ if (c == cmd_malantauxen)
+ {
+ last.show();
+ }
+ }
+}
--- a/src/horaris/TimeList.java Sat Jan 13 15:41:06 2007 +0100
+++ b/src/horaris/TimeList.java Sun Jan 14 11:49:55 2007 +0100
@@ -2,6 +2,7 @@
import javax.microedition.lcdui.*;
import java.util.Vector;
+import java.util.Hashtable;
import ogdl.*;
@@ -11,11 +12,13 @@
private List mylist;
private Command cmd_malantauxen;
private Vector vtempoj;
+ private Hashtable hinfo;
private Ekrano last;
- public TimeList(Vector t, Ekrano _last)
+ public TimeList(Vector t, Hashtable info, Ekrano _last)
{
vtempoj = t;
+ hinfo = info;
last = _last;
}
@@ -40,6 +43,8 @@
last.show();
} else if (c == List.SELECT_COMMAND)
{
+ String str = mylist.getString(mylist.getSelectedIndex());
+ ShowText st = new ShowText((Vector) hinfo.get(str), this);
}
}
}