2525
2626import ch .elexis .core .common .ElexisEventTopics ;
2727import ch .elexis .core .data .events .ElexisEvent ;
28- import ch .elexis .core .data .events .ElexisEventDispatcher ;
2928import ch .elexis .core .exceptions .ElexisException ;
3029import ch .elexis .core .l10n .Messages ;
3130import ch .elexis .core .model .IDocument ;
31+ import ch .elexis .core .model .IPatient ;
3232import ch .elexis .core .model .Identifiable ;
3333import ch .elexis .core .services .holder .ContextServiceHolder ;
3434import ch .elexis .core .ui .documents .service .DocumentStoreServiceHolder ;
3737import ch .elexis .core .ui .locks .AcquireLockBlockingUi ;
3838import ch .elexis .core .ui .locks .ILockHandler ;
3939import ch .elexis .core .ui .util .SWTHelper ;
40- import ch .elexis .data .Patient ;
4140
4241public class DocumentCrudHandler extends AbstractHandler implements IHandler {
4342 private static Logger logger = LoggerFactory .getLogger (DocumentCrudHandler .class );
@@ -52,7 +51,7 @@ public class DocumentCrudHandler extends AbstractHandler implements IHandler {
5251 @ Override
5352 public Object execute (ExecutionEvent event ) throws ExecutionException {
5453
55- Patient patient = ElexisEventDispatcher . getSelectedPatient ( );
54+ IPatient patient = ContextServiceHolder . get (). getActivePatient (). orElse ( null );
5655 if (patient != null && patient .getId () != null ) {
5756 Shell shell = PlatformUI .getWorkbench ().getDisplay ().getActiveShell ();
5857
@@ -140,14 +139,12 @@ public void lockFailed() {
140139 @ Override
141140 public void lockAcquired () {
142141 DocumentStoreServiceHolder .getService ().removeDocument (document );
143- ElexisEventDispatcher .getInstance ().fire (
144- new ElexisEvent (document , IDocument .class , eventType , ElexisEvent .PRIORITY_NORMAL ));
142+ ContextServiceHolder .get ().postEvent (ElexisEventTopics .EVENT_UPDATE , document );
145143 }
146144 });
147145 } else {
148146 DocumentStoreServiceHolder .getService ().removeDocument (document );
149- ElexisEventDispatcher .getInstance ()
150- .fire (new ElexisEvent (document , IDocument .class , eventType , ElexisEvent .PRIORITY_NORMAL ));
147+ ContextServiceHolder .get ().postEvent (ElexisEventTopics .EVENT_UPDATE , document );
151148 }
152149 }
153150 }
@@ -192,8 +189,7 @@ private Optional<IDocument> openMetaDataDialogNoLocking(Shell shell, IDocument d
192189 if (file != null ) {
193190 try (InputStream fin = new FileInputStream (file )) {
194191 IDocument savedDocument = DocumentStoreServiceHolder .getService ().saveDocument (document , fin );
195- ElexisEventDispatcher .getInstance ().fire (new ElexisEvent (savedDocument , IDocument .class ,
196- eventType , ElexisEvent .PRIORITY_NORMAL ));
192+ ContextServiceHolder .get ().postEvent (ElexisEventTopics .EVENT_UPDATE , savedDocument );
197193 return Optional .of (savedDocument );
198194 }
199195 } else {
0 commit comments