當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。