Show InfoForm.java syntax highlighted
/*
* Copyright (c) 2004
* Helsinki Institute of Physics
* see LICENSE file for details
*
* InfoForm.java
* Created on Nov 10, 2004
*/
package fi.hip.gb.client;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.StringItem;
import fi.hip.gb.midlet.core.LiteResult;
/**
* Shows information about results.
*
* @author Juho Karppinen
*/
public class InfoForm extends GenericResultForm {
public InfoForm(LiteResult res, int index) {
this(res, "Result #" + (index + 1));
}
public InfoForm(LiteResult res, String title) {
super(title, res);
boolean midp2 = System.getProperty("microedition.profiles").startsWith("MIDP-2");
StringItem item = new StringItem("File name: ", res.getName());
if(midp2) {
item.setLayout(Item.LAYOUT_NEWLINE_AFTER);
}
append(item);
item = new StringItem("Size on the server: ", res.getSize() + " bytes");
if(midp2) {
item.setLayout(Item.LAYOUT_NEWLINE_AFTER);
}
append(item);
item = new StringItem("Downloaded size: ", res.getPayloadSize() + " bytes");
if(midp2) {
item.setLayout(Item.LAYOUT_NEWLINE_AFTER);
}
append(item);
// format the description
String originalDesc = res.getDescription();
/*
String desc = "";
int ls = 0;
int br = -1;
while((br = originalDesc.indexOf("<br>", ls)) != -1) {
desc += "*" + originalDesc.substring(ls, br) + "\n";
ls = br+4;
}*/
item = new StringItem("Description: ", originalDesc);
if(midp2) {
item.setLayout(Item.LAYOUT_NEWLINE_AFTER);
}
append(item);
}
}
See more files for this project here