Show GenericResultForm.java syntax highlighted
/*
* Copyright (c) 2004
* Helsinki Institute of Physics
* see LICENSE file for details
*
* ResultForm.java
* Created on Sep 10, 2004
*/
package fi.hip.gb.client;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import fi.hip.gb.midlet.core.LiteResult;
/**
* Generic form for results. Contains common functionalities used
* by every type of result
*
* @author Juho Karppinen
*/
public abstract class GenericResultForm extends Form implements CommandListener {
/** save the result to the memory */
protected Command saveCommand = new Command("Save result", Command.SCREEN, 1);
/** show the information about the results */
protected Command infoCommand = new Command("Information", Command.SCREEN, 1);
/** reference to the result object */
protected LiteResult result;
/**
* @param title title of the screen
* @param resultContainer result to be shown and stored inside this
* abstract class
*/
public GenericResultForm(String title, LiteResult resultContainer) {
super(title);
this.result = resultContainer;
setCommandListener(this);
addCommand(new Command("Back", Command.BACK, 1));
/*
if(resultContainer.getRecordID() == -1) {
addCommand(this.saveCommand);
}
*/
}
public void commandAction(Command c, Displayable disp) {
if ((c.getCommandType() == Command.BACK)) {
MIDui.back(true);
/*
} else if(c.getLabel().equals("Delete")) {
try {
_result.deleteRecord(Results.RESULT_STORAGE);
_midlet.showAlert("Result deleted",
_result.getFilename() + " deleted succesfully",
AlertType.INFO,
_parent);
} catch (RecordStoreException rse) {
rse.printStackTrace();
_midlet.showAlert("Cannot delete result",
"Failed to delete " + _result.getFilename()
+ " : " + rse.getClass().getName()
+ "\n " + rse.getMessage(),
AlertType.ERROR,
_parent);
}
*/
} else if(c == this.saveCommand) {
removeCommand(this.saveCommand);
MIDui.saveResult(this.result);
} else if (c == this.infoCommand) {
MIDui.next(new InfoForm(this.result, this.getTitle()));
}
}
}
See more files for this project here