Skip to content

Commit

Permalink
[26167] move SELECTIONFALLBACK constant from holder to IContextService
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed Feb 28, 2024
1 parent 9ab9c78 commit fae5bd7
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import ch.elexis.core.model.IPatient;
import ch.elexis.core.services.IAppointmentService;
import ch.elexis.core.services.IConfigService;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.IQuery;
import ch.elexis.core.services.IQuery.COMPARATOR;
import ch.elexis.core.services.holder.AppointmentServiceHolder;
Expand Down Expand Up @@ -265,7 +266,7 @@ public void selectionChanged(SelectionChangedEvent event) {
Object sel = event.getStructuredSelection().getFirstElement();
if (dayBar != null && sel instanceof IAppointment && !sel.equals(appointment)) {
reloadAppointment((IAppointment) sel);
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK, sel);
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK, sel);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import ch.elexis.core.model.IAppointment;
import ch.elexis.core.model.IContact;
import ch.elexis.core.model.IPatient;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;

Expand All @@ -27,13 +28,13 @@ public Object function(Object[] arguments) {
IAppointment termin = CoreModelServiceHolder.get().load((String) arguments[0], IAppointment.class)
.orElse(null);
if (termin != null) {
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK, termin);
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK, termin);
if (selectionProvider != null) {
selectionProvider.setSelection(new StructuredSelection(termin));
}
IContact contact = termin.getContact();
if (contact != null && contact.isPatient()) {
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK,
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK,
CoreModelServiceHolder.get().load(contact.getId(), IPatient.class).get());
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import ch.elexis.core.model.IPrescription;
import ch.elexis.core.model.builder.IPrescriptionBuilder;
import ch.elexis.core.model.prescription.EntryType;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.services.holder.MedicationServiceHolder;
Expand Down Expand Up @@ -52,7 +53,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {

IPatient patient = CoreModelServiceHolder.get().load(patientid, IPatient.class).orElse(null);
if (patient != null) {
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK, patient);
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK, patient);

List<IPrescription> currentMedication = getPrescriptions(patient, medicationType);
LocalDateTime now = LocalDateTime.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import ch.elexis.core.data.events.ElexisEventDispatcher;
import ch.elexis.core.model.IMandator;
import ch.elexis.core.model.IPatient;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.ui.e4.util.CoreUiUtil;
Expand Down Expand Up @@ -317,10 +318,10 @@ public void selectionChanged(SelectionChangedEvent event) {
if (setAutoSelectPatient) {
Object selectedElement = ((StructuredSelection) selection).getFirstElement();
if (selectedElement instanceof IInboxElement) {
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK,
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK,
((IInboxElement) selectedElement).getPatient());
} else if (selectedElement instanceof PatientInboxElements) {
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK,
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK,
((PatientInboxElements) selectedElement).getPatient());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import at.medevit.elexis.outbox.ui.part.OutboxView;
import at.medevit.elexis.outbox.ui.part.model.PatientOutboxElements;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.ContextServiceHolder;

public class ActivatePatientCommand extends AbstractHandler implements IHandler {
Expand All @@ -25,7 +26,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {

if (element instanceof PatientOutboxElements) {
PatientOutboxElements patElement = (PatientOutboxElements) element;
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK,
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK,
patElement.getPatient());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import at.medevit.elexis.outbox.ui.preferences.Preferences;
import ch.elexis.core.common.ElexisEventTopics;
import ch.elexis.core.model.IMandator;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.ui.e4.util.CoreUiUtil;
Expand Down Expand Up @@ -142,7 +143,7 @@ public void createPartControl(Composite parent) {
if (setAutoSelectPatient) {
Object selectedElement = ((StructuredSelection) selection).getFirstElement();
if (selectedElement instanceof IOutboxElement) {
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK,
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK,
((IOutboxElement) selectedElement).getPatient());
} else if (selectedElement instanceof PatientOutboxElements) {
ContextServiceHolder.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ public void selectionChanged(SelectionChangedEvent event) {
Object firstElement = ss.getFirstElement();
if (firstElement != null) {
IEsrRecord selRecord = (IEsrRecord) firstElement;
contextService.getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK,
contextService.getRootContext().setNamed(IContextService.SELECTIONFALLBACK,
selRecord);
IInvoice rn = selRecord.getInvoice();
if (rn != null) {
contextService.getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK, rn);
contextService.getRootContext().setNamed(IContextService.SELECTIONFALLBACK, rn);
}
} else {
ElexisEventDispatcher.clearSelection(ESRRecord.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void setGlobalInboxEntry(
if (isActive) {
IPatient patient = globalInboxEntry.getPatient();
if (patient != null) {
contextService.getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK, patient);
contextService.getRootContext().setNamed(IContextService.SELECTIONFALLBACK, patient);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion bundles/ch.elexis.icpc/src/ch/elexis/icpc/KonsExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import ch.elexis.core.common.ElexisEventTopics;
import ch.elexis.core.model.IDiagnosis;
import ch.elexis.core.model.IEncounter;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.text.model.Samdas;
Expand Down Expand Up @@ -50,7 +51,7 @@ public boolean doLayout(final StyleRange n, final String provider, final String
public boolean doXRef(final String refProvider, final String refID) {
IcpcEncounter enc = IcpcModelServiceHolder.get().load(refID, IcpcEncounter.class).orElse(null);
if (enc != null) {
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK, enc);
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK, enc);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.eclipse.swt.custom.StyleRange;

import ch.elexis.core.data.events.ElexisEventDispatcher;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.ui.UiDesk;
import ch.elexis.core.ui.text.IRichTextDisplay;
Expand Down Expand Up @@ -41,7 +42,7 @@ public boolean doXRef(String refProvider, String refID) {
Optional<IDocumentHandle> handle = OmnivoreModelServiceHolder.get().load(refID, IDocumentHandle.class);
if (handle.isPresent()) {
UiUtils.open(handle.get());
ContextServiceHolder.get().getRootContext().setNamed(ContextServiceHolder.SELECTIONFALLBACK, handle.get());
ContextServiceHolder.get().getRootContext().setNamed(IContextService.SELECTIONFALLBACK, handle.get());
}
return true;
}
Expand Down

0 comments on commit fae5bd7

Please sign in to comment.