<commit_before>package ch.elexis.core.ui.dialogs.provider;

import org.apache.commons.lang3.StringUtils;
import ch.elexis.core.constants.StringConstants;
import ch.elexis.core.ui.util.viewers.DefaultLabelProvider;
import ch.elexis.data.Kontakt;
import ch.elexis.data.PersistentObject;
import ch.elexis.data.Person;

public class KontaktSelektorLabelProvider extends DefaultLabelProvider {
	@Override
	public String getText(Object element) {
		if (element instanceof Kontakt) {
			Kontakt k = (Kontakt) element;

			String label = k.getLabel();
			if (k.istPerson()) {
				label = label + " (" + k.get(Person.BIRTHDATE) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
			}
			if (StringConstants.ONE.equals(k.get(Kontakt.FLD_IS_USER))) {
				label = k.get(Kontakt.FLD_NAME1) + StringUtils.SPACE + k.get(Kontakt.FLD_NAME2) + " - " + label; //$NON-NLS-1$
			}
			return label;
		} else if (element instanceof PersistentObject) {
			PersistentObject po = (PersistentObject) element;
			return po.getLabel();
		}
		return element.toString();
	}

	public String getColumnText(Object element, int columnIndex) {
		return getText(element);
	}

}<commit_msg>[24736] add sticker image, background and foreground to kontakt selector<commit_after>package ch.elexis.core.ui.dialogs.provider;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;

import ch.elexis.core.constants.StringConstants;
import ch.elexis.core.model.IContact;
import ch.elexis.core.model.ISticker;
import ch.elexis.core.model.OrganizationConstants;
import ch.elexis.core.services.holder.StickerServiceHolder;
import ch.elexis.core.ui.util.CoreUiUtil;
import ch.elexis.core.ui.util.viewers.DefaultLabelProvider;
import ch.elexis.data.Kontakt;
import ch.elexis.data.PersistentObject;
import ch.elexis.data.Person;

public class KontaktSelektorLabelProvider extends DefaultLabelProvider implements ITableColorProvider {
	@Override
	public String getText(Object element) {
		if (element instanceof Kontakt) {
			Kontakt k = (Kontakt) element;

			String label = k.getLabel();
			if (k.istPerson()) {
				label = label + " (" + k.get(Person.BIRTHDATE) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
			}
			if (StringConstants.ONE.equals(k.get(Kontakt.FLD_IS_USER))) {
				label = k.get(Kontakt.FLD_NAME1) + StringUtils.SPACE + k.get(Kontakt.FLD_NAME2) + " - " + label; //$NON-NLS-1$
			}
			if (k.istOrganisation() && StringUtils.isNotBlank(
					(String) k.getExtInfoStoredObjectByKey(OrganizationConstants.FLD_EXT_ALLOWED_BILLINGLAW))) {
				label = label + " (" //$NON-NLS-1$
						+ (String) k.getExtInfoStoredObjectByKey(OrganizationConstants.FLD_EXT_ALLOWED_BILLINGLAW)
						+ ")"; //$NON-NLS-1$
			}
			return label;
		} else if (element instanceof PersistentObject) {
			PersistentObject po = (PersistentObject) element;
			return po.getLabel();
		}
		return element.toString();
	}

	public String getColumnText(Object element, int columnIndex) {
		return getText(element);
	}

	@Override
	public Image getColumnImage(final Object element, final int columnIndex) {
		if (element instanceof Kontakt) {
			IContact pat = ((Kontakt) element).toIContact();
			ISticker sticker = StickerServiceHolder.get().getSticker(pat).orElse(null);
			if (sticker != null && sticker.getImage() != null) {
				return CoreUiUtil.getImageAsIcon(sticker.getImage());
			}
		}
		return super.getColumnImage(element, columnIndex);
	}

	@Override
	public Color getForeground(Object element, int columnIndex) {
		if (element instanceof Kontakt) {
			IContact pat = ((Kontakt) element).toIContact();
			ISticker sticker = StickerServiceHolder.get().getSticker(pat).orElse(null);
			if (sticker != null && StringUtils.isNotBlank(sticker.getForeground())) {
				return CoreUiUtil.getColorForString(sticker.getForeground());
			}
		}
		return null;
	}

	@Override
	public Color getBackground(final Object element, final int columnIndex) {
		if (element instanceof Kontakt) {
			IContact pat = ((Kontakt) element).toIContact();
			ISticker sticker = StickerServiceHolder.get().getSticker(pat).orElse(null);
			if (sticker != null && StringUtils.isNotBlank(sticker.getBackground())) {
				return CoreUiUtil.getColorForString(sticker.getBackground());
			}
		}
		return null;
	}
}
{'fraction_non_alphanumeric': 0.1291444470206353, 'fraction_numerical': 0.004405286343612335, 'mean_word_length': 4.595330739299611, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '381953', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1480, 'n_words': 268}