+ infoPanel.removeAllComponents();
+
+ String name = contact.getPreferredDataValue("FN");
+ infoPanel.addComponent(UiColors.createLabel(
+ ColorOption.VIEW_CONTACT_NAME, name));
+ infoPanel.addComponent(UiColors.createLabel(
+ ColorOption.VIEW_CONTACT_NORMAL, ""));
+
+ // List of infos:
+ String[] infos = infoFormat.split("\\|");
+ for (String info : infos) {
+ // # - "=FIELD" will take the preferred value for this field
+ // # - "+FIELD" will take the preferred value for this field and
+ // highlight it
+ // # - "#FIELD" will take all the values with this field's name
+ // # - "*FIELD" will take all the values with this field's name,
+ // highlighting the preferred one
+ // #
+
+ boolean hl = false;
+ boolean all = false;
+ if (info.contains("+") || info.contains("#"))
+ hl = true;
+ if (info.contains("*") || info.contains("#"))
+ all = true;
+
+ if (all || hl || info.contains("=")) {
+ ColorOption el = hl ? ColorOption.VIEW_CONTACT_HIGHLIGHT
+ : ColorOption.VIEW_CONTACT_NORMAL;
+
+ int index = info.indexOf('=');
+ if (index < 0)
+ index = info.indexOf('+');
+ if (index < 0)
+ index = info.indexOf('#');
+ if (index < 0)
+ index = info.indexOf('*');
+
+ String label = info.substring(0, index);
+ String field = info.substring(index + 1);
+
+ if (all) {
+ Data pref = contact.getPreferredData(field);
+ for (Data data : contact.getData(field)) {
+ if (data == pref) {
+ infoPanel.addComponent(UiColors.createLabel(el,
+ StringUtils.padString(label, labelSize)
+ + data.toString()));
+ } else {
+ infoPanel.addComponent(UiColors.createLabel(
+ ColorOption.VIEW_CONTACT_NORMAL,
+ StringUtils.padString(label, labelSize)
+ + data.toString()));
+ }
+ }
+ } else {
+ String val = contact.getPreferredDataValue(field);
+ if (val == null)
+ val = "";
+ infoPanel.addComponent(UiColors.createLabel(el,
+ StringUtils.padString(label, labelSize) + val));
+ }
+ } else {
+ String label = info;
+ infoPanel.addComponent(UiColors.createLabel(
+ ColorOption.VIEW_CONTACT_NORMAL,
+ StringUtils.padString(label, labelSize)));
+ }
+ }
+ // end of list
+
+ infoPanel.addComponent(UiColors.createLabel(
+ ColorOption.VIEW_CONTACT_NORMAL, ""));
+
+ String notes = contact.getPreferredDataValue("NOTE");
+ if (notes == null)
+ notes = "";
+ note.setText(notes);
+