}
public void setView(Displayable view) {
view.addCommand(new NavigationCommand("quit", "${quit}", Command.SCREEN, 9));
//#ifdef FILE_API
view.addCommand(new ActionCommand("${export}", Command.SCREEN, 8) {
public Navigation execute(Displayable d) throws Exception {
Exporter exporter = new Exporter();
javax.microedition.io.file.FileConnection fc =
(javax.microedition.io.file.FileConnection) Connector.open(CSV_PATH, Connector.READ_WRITE);
try {
if (fc.exists())
fc.delete();
fc.create();
exporter.exportToCSV(fc.openOutputStream(), controler);
} finally {
fc.close();
}
return null;
}
});
view.addCommand(new ActionCommand("${import}", Command.SCREEN, 8) {
public Navigation execute(Displayable d) throws Exception {
Exporter exporter = new Exporter();
javax.microedition.io.file.FileConnection fc =
(javax.microedition.io.file.FileConnection) Connector.open(CSV_PATH,
Connector.READ);
try {
exporter.importFromCSV(fc.openDataInputStream(), fc.fileSize(), controler);
} finally {
fc.close();
}
return null;
}
});
//#endif
//#ifdef DEBUG
view.addCommand(new ActionCommand("D:sample data", Command.SCREEN, 101) {
public Navigation execute(Displayable d) throws Exception {
Calendar date = Calendar.getInstance();
Random random = new Random();
controler.progressListner.setMaxValue(30);
Observation o = null;
Period period = new Period(new Date());
controler.getPeriodDAO().setObservationIds(period, new Vector());
for(int i=1; i < 5; ++i) {
date.set(Calendar.DAY_OF_MONTH, i);
o = new Observation(date.getTime(),
Observation.NO_TEMPERATURE,
MucusRegistry.instance().find(1),
true, random.nextInt() % 5 == 0, "");
LogicDAO.addObservationToPeriod(o, new Period[]{period}, controler);
controler.progressListner.setValue(i);
}
for (int i = 5; i < 30; ++i) {
date.set(Calendar.DAY_OF_MONTH, i);
o = new Observation(date.getTime(),
3620 + random.nextInt() % 60,
MucusRegistry.instance().find(i % 3 + 1),
false, random.nextInt() % 10 == 0, "");
LogicDAO.addObservationToPeriod(o, new Period[]{period}, controler);
controler.progressListner.setValue(i);
}
return new Navigation("graph", period, o);
}
});
view.addCommand(new ActionCommand("D:reset rms", Command.SCREEN, 102){
public Navigation execute(Displayable d) throws Exception {
controler.getPeriodDAO().deleteAll();
controler.getObservationDAO().deleteAll();
return new Navigation("quit",null);
}