Skip to content

Commit

Permalink
[25560] IContactSelectorDialog, fix search condition, and images
Browse files Browse the repository at this point in the history
  • Loading branch information
col-panic committed Aug 29, 2023
1 parent a540119 commit c924c57
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import ch.elexis.core.services.IModelService;
import ch.elexis.core.services.IQuery;
import ch.elexis.core.services.IQuery.COMPARATOR;
import ch.elexis.core.types.Gender;
import ch.elexis.core.ui.icons.Images;

public class IContactSelectorDialog extends TitleAreaDialog {
Expand All @@ -45,7 +46,7 @@ public class IContactSelectorDialog extends TitleAreaDialog {
private List<? extends IContact> initialInput;
private String _message;
private String _title;

public IContactSelectorDialog(Shell parentShell, IModelService coreModelService) {
this(parentShell, coreModelService, IContact.class);
}
Expand All @@ -60,7 +61,7 @@ public IContactSelectorDialog(Shell parentShell, IModelService coreModelService,
@Override
public void create() {
super.create();
if(_title != null) {
if (_title != null) {
super.setTitle(_title);
} else {
setTitle(Messages.Core_Please_Select_Contact);
Expand Down Expand Up @@ -112,6 +113,9 @@ public Image getImage(Object element) {
IContact contact = ((IContact) element);
if (contact.isOrganization() || contact.isLaboratory()) {
return Images.IMG_ORGANISATION.getImage();
} else if (contact.isPatient()) {
return (Gender.MALE == contact.asIPatient().getGender()) ? Images.IMG_MANN.getImage()
: Images.IMG_FRAU.getImage();
}
return Images.IMG_PERSON.getImage();
}
Expand All @@ -135,10 +139,14 @@ public Image getImage(Object element) {
private void refresh() {
String _text = text.getText();
if (StringUtils.isNotBlank(_text) && _text.length() > 2) {
String value = "%" + _text + "%";

IQuery<? extends IContact> query = coreModelService.getQuery(queryClass);
query.and(ModelPackage.Literals.ICONTACT__DESCRIPTION1, COMPARATOR.LIKE, "%" + _text + "%");
query.or(ModelPackage.Literals.ICONTACT__DESCRIPTION2, COMPARATOR.LIKE, "%" + _text + "%");
query.or(ModelPackage.Literals.ICONTACT__DESCRIPTION3, COMPARATOR.LIKE, "%" + _text + "%");
query.startGroup();
query.and(ModelPackage.Literals.ICONTACT__DESCRIPTION1, COMPARATOR.LIKE, value, true);
query.or(ModelPackage.Literals.ICONTACT__DESCRIPTION2, COMPARATOR.LIKE, value, true);
query.or(ModelPackage.Literals.ICONTACT__DESCRIPTION3, COMPARATOR.LIKE, value, true);
query.andJoinGroups();
query.limit(50);
tableViewerContacts.setInput(query.execute());
} else {
Expand Down Expand Up @@ -166,7 +174,7 @@ public IContact getSelectedContact() {
public void setMessage(String message) {
this._message = message;
}

@Override
public void setTitle(String title) {
this._title = title;
Expand Down

0 comments on commit c924c57

Please sign in to comment.