Commit 9f84a6c7 authored by Thomas Huster's avatar Thomas Huster

[8733] updated DocumentsView with e4 di, fixed local edit of document

parent 307f8d36
Pipeline #12471 passed with stages
in 5 minutes and 21 seconds
......@@ -10,11 +10,13 @@ Require-Bundle: ch.elexis.core.documents;bundle-version="1.0.0",
ch.elexis.core;bundle-version="3.2.0",
org.eclipse.core.expressions,
org.eclipse.e4.core.contexts,
ch.elexis.core.l10n;bundle-version="3.5.0"
ch.elexis.core.l10n;bundle-version="3.5.0",
org.eclipse.e4.ui.di
Bundle-Vendor: medevit.at
Import-Package: ch.elexis.admin,
ch.elexis.core.data.activator,
ch.elexis.core.data.events,
ch.elexis.core.services.holder,
ch.elexis.core.ui,
ch.elexis.core.ui.actions,
ch.elexis.core.ui.events,
......@@ -25,6 +27,7 @@ Import-Package: ch.elexis.admin,
ch.elexis.data,
ch.rgw.tools,
org.apache.commons.io;version="2.4.0",
org.eclipse.e4.core.di.annotations;version="1.6.0",
org.osgi.service.component.annotations,
org.slf4j;version="1.7.2"
Service-Component: OSGI-INF/ch.elexis.core.ui.documents.service.DocumentStoreServiceHolder.xml,
......
......@@ -8,6 +8,7 @@
class="ch.elexis.core.ui.documents.views.DocumentsView"
icon="platform:/plugin/ch.elexis.core.ui.icons/icons/16x16/dokument.gif"
id="ch.elexis.core.ui.documents.views.DocumentsView"
inject="true"
name="%view.name">
</view>
</extension>
......
......@@ -20,6 +20,9 @@ import ch.elexis.core.data.interfaces.IPersistentObject;
import ch.elexis.core.data.service.LocalLockServiceHolder;
import ch.elexis.core.data.util.BriefExternUtil;
import ch.elexis.core.data.util.LocalLock;
import ch.elexis.core.data.util.NoPoUtil;
import ch.elexis.core.model.IDocumentLetter;
import ch.elexis.core.model.Identifiable;
import ch.elexis.core.services.IConflictHandler;
import ch.elexis.core.services.ILocalDocumentService;
import ch.elexis.core.services.ILocalLockService.Status;
......@@ -41,20 +44,26 @@ public class StartEditLocalDocumentHandler extends AbstractHandler implements IH
List<?> selected = selection.toList();
Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
for (Object object : selected) {
object = getAsPersistentObject(object);
// direct extern open if Brief on file system
if (object instanceof Brief && BriefExternUtil.isExternFile()) {
Optional<File> file = BriefExternUtil.getExternFile((Brief) object);
if (file.isPresent()) {
Program.launch(file.get().getAbsolutePath());
} else {
MessageDialog.openError(parentShell, Messages.StartEditLocalDocumentHandler_errortitle,
MessageDialog.openError(parentShell,
Messages.StartEditLocalDocumentHandler_errortitle,
Messages.StartEditLocalDocumentHandler_errormessage);
}
} else {
LocalDocumentServiceHolder.getService().ifPresent(service -> {
Optional<ILocalDocumentService> localDocumentService =
LocalDocumentServiceHolder.getService();
if (localDocumentService.isPresent()) {
ILocalDocumentService service = localDocumentService.get();
if (LocalLockServiceHolder.get().getStatus() == Status.REMOTE) {
AcquireLockUi.aquireAndRun((IPersistentObject) object,
new ILockHandler() {
if (object instanceof IPersistentObject) {
IPersistentObject lockObject = (IPersistentObject) object;
AcquireLockUi.aquireAndRun(lockObject, new ILockHandler() {
@Override
public void lockFailed(){
// no action required ...
......@@ -62,9 +71,23 @@ public class StartEditLocalDocumentHandler extends AbstractHandler implements IH
@Override
public void lockAcquired(){
startEditLocal(object, service, parentShell);
startEditLocal(lockObject, service, parentShell);
}
});
} else if (object instanceof Identifiable) {
Identifiable lockObject = (Identifiable) object;
AcquireLockUi.aquireAndRun(lockObject, new ILockHandler() {
@Override
public void lockFailed(){
// no action required ...
}
@Override
public void lockAcquired(){
startEditLocal(lockObject, service, parentShell);
}
});
}
} else {
LocalLock lock = new LocalLock(object);
if (!lock.tryLock()) {
......@@ -80,21 +103,28 @@ public class StartEditLocalDocumentHandler extends AbstractHandler implements IH
MessageDialog.openError(parentShell,
Messages.StartEditLocalDocumentHandler_errortitle,
Messages.StartEditLocalDocumentHandler_errormessage);
return;
return null;
}
} else {
return;
return null;
}
}
startEditLocal(object, service, parentShell);
}
});
}
}
}
}
return null;
}
private Object getAsPersistentObject(Object object){
if (object instanceof IDocumentLetter) {
return NoPoUtil.loadAsPersistentObject((IDocumentLetter) object);
}
return object;
}
private void startEditLocal(Object object, ILocalDocumentService service, Shell parentShell){
Optional<File> file = service.add(object, new IConflictHandler() {
@Override
......
......@@ -61,7 +61,8 @@ public class ElexisProcessor {
"ch.elexis.Konsdetail", "ch.elexis.PatListView",
"ch.elexis.core.ui.medication.views.MedicationView", "ch.elexis.icpc.encounterView",
"ch.elexis.icpc.episodesView", "ch.elexis.omnivore.views.OmnivoreView",
"ch.elexis.omnivoredirect_view", "ch.elexis.schoebufaelle", "ch.elexis.HistoryView"
"ch.elexis.omnivoredirect_view", "ch.elexis.schoebufaelle", "ch.elexis.HistoryView",
"ch.elexis.core.ui.documents.views.DocumentsView"
};
private void updateInjectViews(){
......
......@@ -28,6 +28,7 @@ import ch.elexis.core.data.service.CoreModelServiceHolder;
import ch.elexis.core.data.service.StoreToStringServiceHolder;
import ch.elexis.core.model.IContact;
import ch.elexis.core.model.ICoverage;
import ch.elexis.core.model.IDocumentLetter;
import ch.elexis.core.model.IEncounter;
import ch.elexis.core.model.IMandator;
import ch.elexis.core.model.IPatient;
......@@ -41,6 +42,7 @@ import ch.elexis.core.services.IModelService;
import ch.elexis.core.services.IQuery;
import ch.elexis.core.services.IQuery.COMPARATOR;
import ch.elexis.data.Anwender;
import ch.elexis.data.Brief;
import ch.elexis.data.Fall;
import ch.elexis.data.Konsultation;
import ch.elexis.data.Mandant;
......@@ -422,6 +424,8 @@ public class ContextService implements IContextService, EventHandler {
return Optional.of(ICoverage.class);
} else if (elexisClazz == Prescription.class) {
return Optional.of(IPrescription.class);
} else if (elexisClazz == Brief.class) {
return Optional.of(IDocumentLetter.class);
}
return Optional.empty();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment