- @Override
- protected List<TextPart> getLabel(int index, int width, boolean selected,
- boolean focused) {
- // TODO: from ini file?
- int SIZE_COL_1 = 15;
-
- Element el = (focused && selected) ? Element.CONTACT_LINE_SELECTED
- : Element.CONTACT_LINE;
- Element elSep = (focused && selected) ? Element.CONTACT_LINE_SEPARATOR_SELECTED
- : Element.CONTACT_LINE_SEPARATOR;
- Element elDirty = (focused && selected) ? Element.CONTACT_LINE_DIRTY_SELECTED
- : Element.CONTACT_LINE_DIRTY;
-
- Data data = contact.getContent().get(index);
-
- List<TextPart> parts = new LinkedList<TextPart>();
- if (data.isDirty()) {
- parts.add(new TextPart(" ", el));
- parts.add(new TextPart("*", elDirty));
- } else {
- parts.add(new TextPart(" ", elSep));
- }
- String name = " " + data.getName() + " ";
- String value = null;
-
- StringBuilder valueBuilder = new StringBuilder(" ");
- switch (mode) {
- case 0:
- valueBuilder.append(data.getValue());
- if (data.getGroup() != null && data.getGroup().length() > 0) {
- valueBuilder.append("(");
- valueBuilder.append(data.getGroup());
- valueBuilder.append(")");
- }
- break;
- case 1:
- for (TypeInfo type : data.getTypes()) {
- if (valueBuilder.length() > 1)
- valueBuilder.append(", ");
- valueBuilder.append(type.getName());
- valueBuilder.append(": ");
- valueBuilder.append(type.getValue());
+ public void setContact(Contact contact) {
+ Image img = null;
+ this.contact = contact;
+
+ if (contact != null) {
+ Data photo = contact.getPreferredData("PHOTO");
+ if (photo != null) {
+ TypeInfo encoding = null;
+ TypeInfo type = null;
+ for (TypeInfo info : photo.getTypes()) {
+ if (info.getName() != null) {
+ if (info.getName().equalsIgnoreCase("ENCODING"))
+ encoding = info;
+ if (info.getName().equalsIgnoreCase("TYPE"))
+ type = info;
+ }
+ }
+
+ if (encoding != null && encoding.getValue() != null
+ && encoding.getValue().equalsIgnoreCase("b")) {
+
+ img = new ImageIcon(Base64.getDecoder().decode(
+ photo.getValue())).getImage();
+ }