本文整理汇总了Java中org.commcare.suite.model.DetailField类的典型用法代码示例。如果您正苦于以下问题:Java DetailField类的具体用法?Java DetailField怎么用?Java DetailField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DetailField类属于org.commcare.suite.model包,在下文中一共展示了DetailField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDetailStructure
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
@Test
public void testDetailStructure() {
// A suite detail can have a lookup block for performing an app callout
Callout callout =
mApp.getSession().getPlatform().getDetail("m0_case_short").getCallout();
// specifies the callout's intent type
Assert.assertEquals(callout.getRawCalloutData().getType(), "text/plain");
// If the detail block represents an entity list, then the 'lookup' can
// have a detail field describing the UI for displaying callout result
// data in the case list.
DetailField lookupCalloutDetailField = callout.getResponseDetailField();
// The header is the data's title
Assert.assertTrue(lookupCalloutDetailField.getHeader() != null);
// The template defines the key used to map an entity to the callout
// result data. callout result data is a mapping from keys to string
// values, so each entity who's template evalutates to a key will have
// the associated result data attached to it.
Assert.assertTrue(lookupCalloutDetailField.getTemplate() instanceof Text);
}
示例2: createRow
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
private String createRow(DetailField field, EvaluationContext ec) {
StringBuilder row = new StringBuilder();
String header = field.getHeader().evaluate(ec);
CliUtils.addPaddedStringToBuilder(row, header, SCREEN_WIDTH / 2);
row.append(" | ");
String value;
Object o = field.getTemplate().evaluate(ec);
if (!(o instanceof String)) {
value = "{ " + field.getTemplateForm() + " data}";
} else {
value = (String)o;
}
CliUtils.addPaddedStringToBuilder(row, value, SCREEN_WIDTH / 2);
return row.toString();
}
示例3: createHeader
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
private String createHeader(Detail shortDetail, EvaluationContext context) {
DetailField[] fields = shortDetail.getFields();
StringBuilder row = new StringBuilder();
int i = 0;
for (DetailField field : fields) {
String s = field.getHeader().evaluate(context);
int widthHint = SCREEN_WIDTH / fields.length;
try {
widthHint = Integer.parseInt(field.getHeaderWidthHint());
} catch (Exception e) {
//Really don't care if it didn't work
}
CliUtils.addPaddedStringToBuilder(row, s, widthHint);
i++;
if (i != fields.length) {
row.append(" | ");
}
}
return row.toString();
}
示例4: parse
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
public Callout parse() throws InvalidStructureException, IOException, XmlPullParserException {
String actionName = parser.getAttributeValue(null, "action");
String image = parser.getAttributeValue(null, "image");
String displayName = parser.getAttributeValue(null, "name");
String type = parser.getAttributeValue(null, "type");
Hashtable<String, String> extras = new Hashtable<String, String>();
Vector<String> responses = new Vector<String>();
DetailField responseDetailField = null;
while (nextTagInBlock("lookup")) {
String tagName = parser.getName();
if ("extra".equals(tagName)) {
extras.put(parser.getAttributeValue(null, "key"), parser.getAttributeValue(null, "value"));
} else if ("response".equals(tagName)) {
responses.addElement(parser.getAttributeValue(null, "key"));
} else if ("field".equals(tagName)) {
responseDetailField = new DetailFieldParser(parser, null, "'lookup callout detail field'").parse();
}
}
return new Callout(actionName, image, displayName, extras, responses, responseDetailField, type);
}
示例5: PrintableDetailField
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
public PrintableDetailField(DetailFieldPrintInfo printInfo) {
DetailField field = printInfo.field;
Entity entity = printInfo.entity;
int fieldIndex = printInfo.index;
this.fieldForm = field.getTemplateForm();
String fieldAsString = entity.getFieldString(fieldIndex);
if ("".equals(fieldAsString) || fieldAsString == null) {
// this field can't be automatically represented as a string
if (isGraphDetailField()) {
parseGraphPrintData(entity, field, fieldIndex);
} else {
// this field is of some other form for which printing is currently not supported
this.valueString = "";
}
} else {
this.valueString = fieldAsString;
}
}
示例6: AsyncEntity
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
public AsyncEntity(DetailField[] fields, EvaluationContext ec,
TreeReference t, Hashtable<String, XPathExpression> variables,
EntityStorageCache cache, String cacheIndex, String detailId,
String extraKey) {
super(t, extraKey);
this.fields = fields;
this.data = new Object[fields.length];
this.sortData = new String[fields.length];
this.sortDataPieces = new String[fields.length][];
this.relevancyData = new boolean[fields.length];
this.context = ec;
this.mVariableDeclarations = variables;
this.mEntityStorageCache = cache;
//TODO: It's weird that we pass this in, kind of, but the thing is that we don't want to figure out
//if this ref is _cachable_ every time, since it's a pretty big lift
this.mCacheIndex = cacheIndex;
this.mDetailId = detailId;
}
示例7: buildValidKeys
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
private String buildValidKeys(Vector<Integer> sortKeys, DetailField[] fields) {
String validKeys = "(";
boolean added = false;
for (int i = 0; i < fields.length; ++i) {
//We're only gonna pull out the fields we can index/sort on
if (fields[i].getSort() != null) {
sortKeys.add(i);
validKeys += "?, ";
added = true;
}
}
if (added) {
return validKeys.substring(0, validKeys.length() - 2) + ")";
} else {
return "";
}
}
示例8: parse
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
@Override
public Callout parse() throws InvalidStructureException, IOException, XmlPullParserException {
String actionName = parser.getAttributeValue(null, "action");
String image = parser.getAttributeValue(null, "image");
String displayName = parser.getAttributeValue(null, "name");
String type = parser.getAttributeValue(null, "type");
boolean isAutoLaunching = "true".equals(parser.getAttributeValue(null, "auto_launch"));
Hashtable<String, String> extras = new Hashtable<>();
Vector<String> responses = new Vector<>();
DetailField responseDetailField = null;
while (nextTagInBlock("lookup")) {
String tagName = parser.getName();
if ("extra".equals(tagName)) {
extras.put(parser.getAttributeValue(null, "key"), parser.getAttributeValue(null, "value"));
} else if ("response".equals(tagName)) {
responses.addElement(parser.getAttributeValue(null, "key"));
} else if ("field".equals(tagName)) {
responseDetailField = new DetailFieldParser(parser, null, "'lookup callout detail field'").parse();
}
}
return new Callout(actionName, image, displayName, extras, responses, responseDetailField, type, isAutoLaunching);
}
示例9: createRow
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
private String createRow(DetailField field, EvaluationContext ec, Object o) {
StringBuilder row = new StringBuilder();
String header = field.getHeader().evaluate(ec);
ScreenUtils.addPaddedStringToBuilder(row, header, SCREEN_WIDTH / 2);
row.append(" | ");
String value;
if (!(o instanceof String)) {
value = "{ " + field.getTemplateForm() + " data}";
} else {
value = (String)o;
}
ScreenUtils.addPaddedStringToBuilder(row, value, SCREEN_WIDTH / 2);
return row.toString();
}
示例10: createHeader
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
private static String createHeader(Detail shortDetail, EvaluationContext context) {
DetailField[] fields = shortDetail.getFields();
StringBuilder row = new StringBuilder();
int i = 0;
for (DetailField field : fields) {
String s = field.getHeader().evaluate(context);
int widthHint = SCREEN_WIDTH / fields.length;
try {
widthHint = Integer.parseInt(field.getHeaderWidthHint());
} catch (Exception e) {
//Really don't care if it didn't work
}
ScreenUtils.addPaddedStringToBuilder(row, s, widthHint);
i++;
if (i != fields.length) {
row.append(" | ");
}
}
return row.toString();
}
示例11: testDetailStructure
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
@Test
public void testDetailStructure() {
// A suite detail can have a lookup block for performing an app callout
Callout callout =
mApp.getSession().getPlatform().getDetail("m0_case_short").getCallout();
// specifies the callout's intent type
assertEquals(callout.evaluate(mApp.getSession().getEvaluationContext()).getType(), "text/plain");
// If the detail block represents an entity list, then the 'lookup' can
// have a detail field describing the UI for displaying callout result
// data in the case list.
DetailField lookupCalloutDetailField = callout.getResponseDetailField();
// The header is the data's title
Assert.assertTrue(lookupCalloutDetailField.getHeader() != null);
// The template defines the key used to map an entity to the callout
// result data. callout result data is a mapping from keys to string
// values, so each entity who's template evalutates to a key will have
// the associated result data attached to it.
Assert.assertTrue(lookupCalloutDetailField.getTemplate() instanceof Text);
}
示例12: print
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
private void print(Suite s, Entry e, int level) {
String head = "";
String emptyhead = "";
for(int i = 0; i < level; ++i ){
head += "|- ";
emptyhead += " ";
}
if (e.isView()) {
print.println(head + "View: " + e.getText().evaluate());
} else {
print.println(head + "Entry: " + e.getText().evaluate());
}
for(SessionDatum datum : e.getSessionDataReqs()) {
if(datum instanceof FormIdDatum) {
print.println(emptyhead + "Form: " + datum.getValue());
} else if (datum instanceof EntityDatum) {
String shortDetailId = ((EntityDatum)datum).getShortDetail();
if(shortDetailId != null) {
Detail d = s.getDetail(shortDetailId);
try {
print.println(emptyhead + "|Select: " + d.getTitle().getText().evaluate(new EvaluationContext(null)));
} catch(XPathMissingInstanceException ex) {
print.println(emptyhead + "|Select: " + "(dynamic title)");
}
print.print(emptyhead + "| ");
for(DetailField f : d.getFields()) {
print.print(f.getHeader().evaluate() + " | ");
}
print.print("\n");
}
}
}
}
示例13: EntityDetailSubscreen
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
public EntityDetailSubscreen(int currentIndex, Detail detail, EvaluationContext subContext, String[] detailListTitles) {
DetailField[] fields = detail.getFields();
rows = new String[fields.length];
detail.populateEvaluationContextVariables(subContext);
for (int i = 0; i < fields.length; ++i) {
rows[i] = createRow(fields[i], subContext);
}
mDetailListTitles = detailListTitles;
mCurrentIndex = currentIndex;
}
示例14: parseStyle
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
private void parseStyle(DetailField.Builder builder) throws InvalidStructureException, IOException, XmlPullParserException {
//style
if (parser.getName().toLowerCase().equals("style")) {
StyleParser styleParser = new StyleParser(builder, parser);
styleParser.parse();
//Header
GridParser gridParser = new GridParser(builder, parser);
gridParser.parse();
//exit style block
parser.nextTag();
parser.nextTag();
}
}
示例15: parseTemplate
import org.commcare.suite.model.DetailField; //导入依赖的package包/类
private void parseTemplate(DetailField.Builder builder) throws InvalidStructureException, IOException, XmlPullParserException {
//Template
checkNode("template");
builder.setTemplateWidthHint(parser.getAttributeValue(null, "width"));
String form = parser.getAttributeValue(null, "form");
if (form == null) {
form = "";
}
builder.setTemplateForm(form);
parser.nextTag();
DetailTemplate template;
if (form.equals("graph")) {
template = graphParser.parse();
} else if (form.equals("callout")) {
template = new CalloutParser(parser).parse();
} else {
checkNode("text");
try {
template = new TextParser(parser).parse();
} catch (InvalidStructureException ise) {
throw new InvalidStructureException("Error in suite detail with id " + id + " : " + ise.getMessage(), parser);
}
}
builder.setTemplate(template);
}