-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pdenzler
authored and
pdenzler
committed
Dec 2, 2024
1 parent
7023d57
commit aa963a9
Showing
4 changed files
with
79 additions
and
64 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
bundles/ch.elexis.core.services/OSGI-INF/ch.elexis.core.services.OrderService.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="ch.elexis.core.services.OrderService"> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="ch.elexis.core.services.OrderService"> | ||
<service> | ||
<provide interface="ch.elexis.core.services.IOrderService"/> | ||
</service> | ||
<reference cardinality="1..1" field="modelService" interface="ch.elexis.core.services.IModelService" name="modelService" target="(service.model.name=ch.elexis.core.model)"/> | ||
<implementation class="ch.elexis.core.services.OrderService"/> | ||
</scr:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...elexis.core.ui.mediorder/src/ch/elexis/core/ui/mediorder/MedicationHistoryComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package ch.elexis.core.ui.mediorder; | ||
|
||
import java.time.format.DateTimeFormatter; | ||
import java.util.Comparator; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.jface.viewers.Viewer; | ||
import org.eclipse.jface.viewers.ViewerComparator; | ||
|
||
import ch.elexis.core.model.IOrderEntry; | ||
|
||
public class MedicationHistoryComparator extends ViewerComparator { | ||
private int propertyIndex; | ||
private int direction; | ||
private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); | ||
|
||
public MedicationHistoryComparator() { | ||
this.propertyIndex = 0; | ||
this.direction = -1; | ||
} | ||
|
||
public void setColumn(int column) { | ||
if (column == this.propertyIndex) { | ||
direction *= -1; | ||
} | ||
this.propertyIndex = column; | ||
} | ||
|
||
@Override | ||
public int compare(Viewer viewer, Object o1, Object o2) { | ||
IOrderEntry orderEntry1 = (IOrderEntry) o1; | ||
IOrderEntry orderEntry2 = (IOrderEntry) o2; | ||
|
||
switch (propertyIndex) { | ||
case 0: | ||
String articleName1 = orderEntry1.getArticle().getName(); | ||
String articleName2 = orderEntry2.getArticle().getName(); | ||
return Objects.compare(articleName1, articleName2, Comparator.nullsFirst(Comparator.naturalOrder())) | ||
* direction; | ||
case 1: | ||
String orderAmount1 = String.valueOf(orderEntry1.getAmount()); | ||
String orderAmount2 = String.valueOf(orderEntry2.getAmount()); | ||
return Objects.compare(orderAmount1, orderAmount2, Comparator.nullsFirst(Comparator.naturalOrder())) | ||
* direction; | ||
case 2: | ||
String orderDate1 = orderEntry1.getOrder().getTimestamp().format(dateFormatter); | ||
String orderDate2 = orderEntry2.getOrder().getTimestamp().format(dateFormatter); | ||
return Objects.compare(orderDate1, orderDate2, Comparator.nullsFirst(Comparator.naturalOrder())) | ||
* direction; | ||
} | ||
|
||
return super.compare(viewer, o1, o2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters