当前位置: 首页>>代码示例>>Java>>正文


Java DetailField类代码示例

本文整理汇总了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);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:24,代码来源:AppStructureTests.java

示例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();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:19,代码来源:EntityDetailSubscreen.java

示例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();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:EntityListSubscreen.java

示例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);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:CalloutParser.java

示例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;
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:20,代码来源:PrintableDetailField.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:22,代码来源:AsyncEntity.java

示例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 "";
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:18,代码来源:AsyncNodeEntityFactory.java

示例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);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:25,代码来源:CalloutParser.java

示例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();
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:18,代码来源:EntityDetailSubscreen.java

示例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();
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:23,代码来源:EntityListSubscreen.java

示例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);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:24,代码来源:AppStructureTests.java

示例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");
            }
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:34,代码来源:CommCareConfigEngine.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:14,代码来源:EntityDetailSubscreen.java

示例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();
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:15,代码来源:DetailFieldParser.java

示例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);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:29,代码来源:DetailFieldParser.java


注:本文中的org.commcare.suite.model.DetailField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。