Loading bundles/ch.elexis.core.ui.documents/META-INF/MANIFEST.MF +4 −1 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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, Loading bundles/ch.elexis.core.ui.documents/plugin.xml +1 −0 Original line number Diff line number Diff line Loading @@ -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> Loading bundles/ch.elexis.core.ui.documents/src/ch/elexis/core/ui/documents/views/DocumentsView.java +66 −107 Original line number Diff line number Diff line Loading @@ -19,7 +19,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import javax.inject.Inject; import org.eclipse.core.commands.Command; import org.eclipse.core.commands.ExecutionEvent; Loading @@ -28,6 +29,8 @@ import org.eclipse.core.commands.NotEnabledException; import org.eclipse.core.commands.NotHandledException; import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.ui.di.UIEventTopic; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.dialogs.MessageDialog; Loading Loading @@ -63,6 +66,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; Loading @@ -72,22 +76,21 @@ import org.eclipse.ui.part.ViewPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ch.elexis.core.data.events.ElexisEvent; import ch.elexis.core.data.events.ElexisEventDispatcher; import ch.elexis.core.common.ElexisEventTopics; import ch.elexis.core.documents.FilterCategory; import ch.elexis.core.exceptions.ElexisException; import ch.elexis.core.model.BriefConstants; import ch.elexis.core.model.ICategory; import ch.elexis.core.model.IDocument; import ch.elexis.core.model.IPatient; import ch.elexis.core.model.Identifiable; import ch.elexis.core.services.holder.ContextServiceHolder; import ch.elexis.core.ui.documents.Messages; import ch.elexis.core.ui.documents.handler.DocumentCrudHandler; import ch.elexis.core.ui.documents.service.DocumentStoreServiceHolder; import ch.elexis.core.ui.events.ElexisUiEventListenerImpl; import ch.elexis.core.ui.icons.Images; import ch.elexis.core.ui.services.LocalDocumentServiceHolder; import ch.elexis.core.ui.util.SWTHelper; import ch.elexis.data.Patient; import ch.rgw.tools.TimeTool; /** Loading @@ -103,12 +106,9 @@ public class DocumentsView extends ViewPart { public static String importAction_ID = "ch.elexis.omnivore.data.DocumentView.importAction"; private final String[] colLabels = { "", "", Messages.DocumentView_categoryColumn, Messages.DocumentView_lastChangedColumn, Messages.DocumentView_titleColumn, Messages.DocumentView_keywordsColumn private final String[] colLabels = { "", "", Messages.DocumentView_categoryColumn, Messages.DocumentView_lastChangedColumn, Messages.DocumentView_titleColumn, Messages.DocumentView_keywordsColumn }; private final String colWidth = "20,20,100,100,200,500"; private final String sortSettings = "0,1,-1,false"; Loading @@ -117,64 +117,33 @@ public class DocumentsView extends ViewPart { private DocumentsViewerComparator ovComparator; private Action doubleClickAction; private final ElexisUiEventListenerImpl eeli_pat = new ElexisUiEventListenerImpl(Patient.class, ElexisEvent.EVENT_SELECTED) { @Override public void runInUi(ElexisEvent ev){ viewer.setInput(ev.getObject()); @Inject void activePatient(@Optional IPatient patient){ if (viewer != null && !viewer.getControl().isDisposed()) { Display.getDefault().asyncExec(() -> { viewer.setInput(patient); viewer.expandAll(); }); } }; private final ElexisUiEventListenerImpl eeli_doc_edit = new ElexisUiEventListenerImpl(IDocument.class, ElexisEvent.EVENT_UPDATE) { @Override public void runInUi(ElexisEvent ev){ ViewContentProvider viewContentProvider = (ViewContentProvider) viewer.getContentProvider(); viewContentProvider.updateElement((IDocument) ev.getGenericObject()); } }; private final ElexisUiEventListenerImpl eeli_doc_create = new ElexisUiEventListenerImpl(IDocument.class, ElexisEvent.EVENT_CREATE) { @Override public void runInUi(ElexisEvent ev){ @Optional @Inject void udpateDocument(@UIEventTopic(ElexisEventTopics.EVENT_UPDATE) IDocument document){ //TODO the event update is not type safe if (document != null && viewer != null && !viewer.getControl().isDisposed()) { ViewContentProvider viewContentProvider = (ViewContentProvider) viewer.getContentProvider(); viewContentProvider.createElement((IDocument) ev.getGenericObject()); viewContentProvider.updateElement(document); } }; private final ElexisUiEventListenerImpl eeli_doc_delete = new ElexisUiEventListenerImpl(IDocument.class, ElexisEvent.EVENT_DELETE) { @Override public void runInUi(ElexisEvent ev){ ViewContentProvider viewContentProvider = (ViewContentProvider) viewer.getContentProvider(); viewContentProvider.removeElement((IDocument) ev.getGenericObject()); } }; private final ElexisUiEventListenerImpl eeli_doc_reload = new ElexisUiEventListenerImpl(IDocument.class, ElexisEvent.EVENT_RELOAD) { @Override public void runInUi(ElexisEvent ev){ @Inject void reloadDocument(@Optional @UIEventTopic(ElexisEventTopics.EVENT_RELOAD) IDocument document){ if (viewer != null && !viewer.getControl().isDisposed()) { viewer.refresh(); } }; } class ViewFilterProvider extends ViewerFilter { Loading Loading @@ -202,8 +171,8 @@ public class DocumentsView extends ViewPart { if (iDocument.getTitle().toLowerCase().contains(searchText)) { return true; } if (iDocument.getKeywords() != null && iDocument.getKeywords().toLowerCase().contains(searchText.toLowerCase())) { if (iDocument.getKeywords() != null && iDocument.getKeywords().toLowerCase() .contains(searchText.toLowerCase())) { return true; } } Loading @@ -221,8 +190,8 @@ public class DocumentsView extends ViewPart { public void inputChanged(Viewer v, Object oldInput, Object newInput){ documentsMap.clear(); if (newInput instanceof Patient) { loadByFilterCategory((Patient) newInput); if (newInput instanceof IPatient) { loadByFilterCategory((IPatient) newInput); } } Loading @@ -239,14 +208,14 @@ public class DocumentsView extends ViewPart { return this; } private void loadByFilterCategory(Patient patient){ if (patient != null) { private void loadByFilterCategory(IPatient newInput){ if (newInput != null) { if (selectedFilter.isAll()) { documentsMap = DocumentStoreServiceHolder.getService() .getDocumentsByPatientId(patient.getId()); .getDocumentsByPatientId(newInput.getId()); viewer.refresh(true); } else { loadElementsByCategory(patient.getId(), selectedFilter); loadElementsByCategory(newInput.getId(), selectedFilter); } } } Loading @@ -263,8 +232,7 @@ public class DocumentsView extends ViewPart { public void createElement(IDocument iDocument){ FilterCategory filterCategory = new FilterCategory(iDocument.getCategory()); List<IDocument> iDocuments = documentsMap.get(filterCategory); List<IDocument> iDocuments = documentsMap.get(filterCategory); if (iDocuments == null) { iDocuments = new ArrayList<>(); } Loading @@ -290,7 +258,8 @@ public class DocumentsView extends ViewPart { List<IDocument> iDocuments = DocumentStoreServiceHolder.getService() .getDocumentsByCategory(patientId, iCategory); if (!iDocuments.isEmpty()) { documentsMap.put(new FilterCategory(iDocuments.get(0).getCategory()), iDocuments); documentsMap.put(new FilterCategory(iDocuments.get(0).getCategory()), iDocuments); } } viewer.refresh(true); Loading Loading @@ -325,7 +294,6 @@ public class DocumentsView extends ViewPart { public void dispose(){} public Object[] getElements(Object parent){ if (selectedFilter.isAll()) { List<ICategory> keys = new ArrayList<>(documentsMap.keySet()); Loading Loading @@ -392,15 +360,14 @@ public class DocumentsView extends ViewPart { if (index == 4) { if (obj instanceof IDocument && LocalDocumentServiceHolder.getService().isPresent()) { Optional<Identifiable> opt = DocumentStoreServiceHolder.getService() java.util.Optional<Identifiable> opt = DocumentStoreServiceHolder.getService() .getPersistenceObject((IDocument) obj); if (opt.isPresent() && LocalDocumentServiceHolder.getService().get().contains(opt.get())) { return Images.IMG_EDIT.getImage(); } } } else if (index == 2 && obj instanceof ICategory) { } else if (index == 2 && obj instanceof ICategory) { return Images.IMG_FOLDER.getImage(); } return null; Loading Loading @@ -459,7 +426,8 @@ public class DocumentsView extends ViewPart { DocumentsFilterBarComposite filterBarComposite = addFilterBar(parent); viewer.setContentProvider(new ViewContentProvider().selectFilterCategory(filterBarComposite.getSelection())); viewer.setContentProvider( new ViewContentProvider().selectFilterCategory(filterBarComposite.getSelection())); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setUseHashlookup(true); viewer.addFilter(new ViewFilterProvider()); Loading Loading @@ -532,6 +500,7 @@ public class DocumentsView extends ViewPart { }; viewer.addDragSupport(DND.DROP_COPY, dragTransferTypes, new DragSourceAdapter() { private boolean failure; @Override public void dragStart(DragSourceEvent event){ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Loading Loading @@ -574,8 +543,7 @@ public class DocumentsView extends ViewPart { public void dragFinished(DragSourceEvent event){ if (!failure) { super.dragFinished(event); } else { } else { SWTHelper.showError(Messages.DocumentView_exportErrorCaption, Messages.DocumentView_exportErrorEmptyText); } Loading @@ -585,14 +553,10 @@ public class DocumentsView extends ViewPart { MenuManager menuManager = new MenuManager(); viewer.getControl().setMenu(menuManager.createContextMenu(viewer.getControl())); getSite().registerContextMenu(menuManager, viewer); getSite().registerContextMenu(menuManager, viewer); getSite().setSelectionProvider(viewer); ElexisEventDispatcher.getInstance().addListeners(eeli_pat, eeli_doc_delete, eeli_doc_edit, eeli_doc_create, eeli_doc_reload); viewer.setInput(ElexisEventDispatcher.getSelectedPatient()); viewer.setInput(ContextServiceHolder.get().getActivePatient().orElse(null)); } private DocumentsFilterBarComposite addFilterBar(Composite parent){ Loading @@ -603,9 +567,9 @@ public class DocumentsView extends ViewPart { filters.add(new FilterCategory(BriefConstants.AUZ, "Auf")); filters.add(new FilterCategory(BriefConstants.RP, "Rezepte")); DocumentsFilterBarComposite filterBarComposite = new DocumentsFilterBarComposite(parent, SWT.NONE, filters); filterBarComposite .setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); DocumentsFilterBarComposite filterBarComposite = new DocumentsFilterBarComposite(parent, SWT.NONE, filters); filterBarComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); filterBarComposite.addSelectionChangedListener(new ISelectionChangedListener() { @Override Loading Loading @@ -673,14 +637,10 @@ public class DocumentsView extends ViewPart { @Override public void dispose(){ ElexisEventDispatcher.getInstance().removeListeners(eeli_pat, eeli_doc_delete, eeli_doc_edit, eeli_doc_create, eeli_doc_reload); //saveSortSettings(); super.dispose(); } /** * Passing the focus request to the viewer's control. */ Loading Loading @@ -729,9 +689,8 @@ public class DocumentsView extends ViewPart { .getWorkbench().getService(ICommandService.class); Command command = commandService .getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(po)); PlatformUI.getWorkbench().getService(IEclipseContext.class).set( command.getId().concat(".selection"), new StructuredSelection(po)); try { command.executeWithChecks( new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); Loading @@ -742,7 +701,7 @@ public class DocumentsView extends ViewPart { e.printStackTrace(); } }); viewer.refresh(obj); ContextServiceHolder.get().postEvent(ElexisEventTopics.EVENT_UPDATE, dh); } } }; Loading bundles/ch.elexis.core.ui/src/ch/elexis/core/ui/commands/StartEditLocalDocumentHandler.java +38 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 ... Loading @@ -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()) { Loading @@ -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 Loading bundles/ch.elexis.core.ui/src/ch/elexis/core/ui/processor/ElexisProcessor.java +2 −1 Original line number Diff line number Diff line Loading @@ -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(){ Loading Loading
bundles/ch.elexis.core.ui.documents/META-INF/MANIFEST.MF +4 −1 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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, Loading
bundles/ch.elexis.core.ui.documents/plugin.xml +1 −0 Original line number Diff line number Diff line Loading @@ -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> Loading
bundles/ch.elexis.core.ui.documents/src/ch/elexis/core/ui/documents/views/DocumentsView.java +66 −107 Original line number Diff line number Diff line Loading @@ -19,7 +19,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import javax.inject.Inject; import org.eclipse.core.commands.Command; import org.eclipse.core.commands.ExecutionEvent; Loading @@ -28,6 +29,8 @@ import org.eclipse.core.commands.NotEnabledException; import org.eclipse.core.commands.NotHandledException; import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.ui.di.UIEventTopic; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.dialogs.MessageDialog; Loading Loading @@ -63,6 +66,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; Loading @@ -72,22 +76,21 @@ import org.eclipse.ui.part.ViewPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ch.elexis.core.data.events.ElexisEvent; import ch.elexis.core.data.events.ElexisEventDispatcher; import ch.elexis.core.common.ElexisEventTopics; import ch.elexis.core.documents.FilterCategory; import ch.elexis.core.exceptions.ElexisException; import ch.elexis.core.model.BriefConstants; import ch.elexis.core.model.ICategory; import ch.elexis.core.model.IDocument; import ch.elexis.core.model.IPatient; import ch.elexis.core.model.Identifiable; import ch.elexis.core.services.holder.ContextServiceHolder; import ch.elexis.core.ui.documents.Messages; import ch.elexis.core.ui.documents.handler.DocumentCrudHandler; import ch.elexis.core.ui.documents.service.DocumentStoreServiceHolder; import ch.elexis.core.ui.events.ElexisUiEventListenerImpl; import ch.elexis.core.ui.icons.Images; import ch.elexis.core.ui.services.LocalDocumentServiceHolder; import ch.elexis.core.ui.util.SWTHelper; import ch.elexis.data.Patient; import ch.rgw.tools.TimeTool; /** Loading @@ -103,12 +106,9 @@ public class DocumentsView extends ViewPart { public static String importAction_ID = "ch.elexis.omnivore.data.DocumentView.importAction"; private final String[] colLabels = { "", "", Messages.DocumentView_categoryColumn, Messages.DocumentView_lastChangedColumn, Messages.DocumentView_titleColumn, Messages.DocumentView_keywordsColumn private final String[] colLabels = { "", "", Messages.DocumentView_categoryColumn, Messages.DocumentView_lastChangedColumn, Messages.DocumentView_titleColumn, Messages.DocumentView_keywordsColumn }; private final String colWidth = "20,20,100,100,200,500"; private final String sortSettings = "0,1,-1,false"; Loading @@ -117,64 +117,33 @@ public class DocumentsView extends ViewPart { private DocumentsViewerComparator ovComparator; private Action doubleClickAction; private final ElexisUiEventListenerImpl eeli_pat = new ElexisUiEventListenerImpl(Patient.class, ElexisEvent.EVENT_SELECTED) { @Override public void runInUi(ElexisEvent ev){ viewer.setInput(ev.getObject()); @Inject void activePatient(@Optional IPatient patient){ if (viewer != null && !viewer.getControl().isDisposed()) { Display.getDefault().asyncExec(() -> { viewer.setInput(patient); viewer.expandAll(); }); } }; private final ElexisUiEventListenerImpl eeli_doc_edit = new ElexisUiEventListenerImpl(IDocument.class, ElexisEvent.EVENT_UPDATE) { @Override public void runInUi(ElexisEvent ev){ ViewContentProvider viewContentProvider = (ViewContentProvider) viewer.getContentProvider(); viewContentProvider.updateElement((IDocument) ev.getGenericObject()); } }; private final ElexisUiEventListenerImpl eeli_doc_create = new ElexisUiEventListenerImpl(IDocument.class, ElexisEvent.EVENT_CREATE) { @Override public void runInUi(ElexisEvent ev){ @Optional @Inject void udpateDocument(@UIEventTopic(ElexisEventTopics.EVENT_UPDATE) IDocument document){ //TODO the event update is not type safe if (document != null && viewer != null && !viewer.getControl().isDisposed()) { ViewContentProvider viewContentProvider = (ViewContentProvider) viewer.getContentProvider(); viewContentProvider.createElement((IDocument) ev.getGenericObject()); viewContentProvider.updateElement(document); } }; private final ElexisUiEventListenerImpl eeli_doc_delete = new ElexisUiEventListenerImpl(IDocument.class, ElexisEvent.EVENT_DELETE) { @Override public void runInUi(ElexisEvent ev){ ViewContentProvider viewContentProvider = (ViewContentProvider) viewer.getContentProvider(); viewContentProvider.removeElement((IDocument) ev.getGenericObject()); } }; private final ElexisUiEventListenerImpl eeli_doc_reload = new ElexisUiEventListenerImpl(IDocument.class, ElexisEvent.EVENT_RELOAD) { @Override public void runInUi(ElexisEvent ev){ @Inject void reloadDocument(@Optional @UIEventTopic(ElexisEventTopics.EVENT_RELOAD) IDocument document){ if (viewer != null && !viewer.getControl().isDisposed()) { viewer.refresh(); } }; } class ViewFilterProvider extends ViewerFilter { Loading Loading @@ -202,8 +171,8 @@ public class DocumentsView extends ViewPart { if (iDocument.getTitle().toLowerCase().contains(searchText)) { return true; } if (iDocument.getKeywords() != null && iDocument.getKeywords().toLowerCase().contains(searchText.toLowerCase())) { if (iDocument.getKeywords() != null && iDocument.getKeywords().toLowerCase() .contains(searchText.toLowerCase())) { return true; } } Loading @@ -221,8 +190,8 @@ public class DocumentsView extends ViewPart { public void inputChanged(Viewer v, Object oldInput, Object newInput){ documentsMap.clear(); if (newInput instanceof Patient) { loadByFilterCategory((Patient) newInput); if (newInput instanceof IPatient) { loadByFilterCategory((IPatient) newInput); } } Loading @@ -239,14 +208,14 @@ public class DocumentsView extends ViewPart { return this; } private void loadByFilterCategory(Patient patient){ if (patient != null) { private void loadByFilterCategory(IPatient newInput){ if (newInput != null) { if (selectedFilter.isAll()) { documentsMap = DocumentStoreServiceHolder.getService() .getDocumentsByPatientId(patient.getId()); .getDocumentsByPatientId(newInput.getId()); viewer.refresh(true); } else { loadElementsByCategory(patient.getId(), selectedFilter); loadElementsByCategory(newInput.getId(), selectedFilter); } } } Loading @@ -263,8 +232,7 @@ public class DocumentsView extends ViewPart { public void createElement(IDocument iDocument){ FilterCategory filterCategory = new FilterCategory(iDocument.getCategory()); List<IDocument> iDocuments = documentsMap.get(filterCategory); List<IDocument> iDocuments = documentsMap.get(filterCategory); if (iDocuments == null) { iDocuments = new ArrayList<>(); } Loading @@ -290,7 +258,8 @@ public class DocumentsView extends ViewPart { List<IDocument> iDocuments = DocumentStoreServiceHolder.getService() .getDocumentsByCategory(patientId, iCategory); if (!iDocuments.isEmpty()) { documentsMap.put(new FilterCategory(iDocuments.get(0).getCategory()), iDocuments); documentsMap.put(new FilterCategory(iDocuments.get(0).getCategory()), iDocuments); } } viewer.refresh(true); Loading Loading @@ -325,7 +294,6 @@ public class DocumentsView extends ViewPart { public void dispose(){} public Object[] getElements(Object parent){ if (selectedFilter.isAll()) { List<ICategory> keys = new ArrayList<>(documentsMap.keySet()); Loading Loading @@ -392,15 +360,14 @@ public class DocumentsView extends ViewPart { if (index == 4) { if (obj instanceof IDocument && LocalDocumentServiceHolder.getService().isPresent()) { Optional<Identifiable> opt = DocumentStoreServiceHolder.getService() java.util.Optional<Identifiable> opt = DocumentStoreServiceHolder.getService() .getPersistenceObject((IDocument) obj); if (opt.isPresent() && LocalDocumentServiceHolder.getService().get().contains(opt.get())) { return Images.IMG_EDIT.getImage(); } } } else if (index == 2 && obj instanceof ICategory) { } else if (index == 2 && obj instanceof ICategory) { return Images.IMG_FOLDER.getImage(); } return null; Loading Loading @@ -459,7 +426,8 @@ public class DocumentsView extends ViewPart { DocumentsFilterBarComposite filterBarComposite = addFilterBar(parent); viewer.setContentProvider(new ViewContentProvider().selectFilterCategory(filterBarComposite.getSelection())); viewer.setContentProvider( new ViewContentProvider().selectFilterCategory(filterBarComposite.getSelection())); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setUseHashlookup(true); viewer.addFilter(new ViewFilterProvider()); Loading Loading @@ -532,6 +500,7 @@ public class DocumentsView extends ViewPart { }; viewer.addDragSupport(DND.DROP_COPY, dragTransferTypes, new DragSourceAdapter() { private boolean failure; @Override public void dragStart(DragSourceEvent event){ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Loading Loading @@ -574,8 +543,7 @@ public class DocumentsView extends ViewPart { public void dragFinished(DragSourceEvent event){ if (!failure) { super.dragFinished(event); } else { } else { SWTHelper.showError(Messages.DocumentView_exportErrorCaption, Messages.DocumentView_exportErrorEmptyText); } Loading @@ -585,14 +553,10 @@ public class DocumentsView extends ViewPart { MenuManager menuManager = new MenuManager(); viewer.getControl().setMenu(menuManager.createContextMenu(viewer.getControl())); getSite().registerContextMenu(menuManager, viewer); getSite().registerContextMenu(menuManager, viewer); getSite().setSelectionProvider(viewer); ElexisEventDispatcher.getInstance().addListeners(eeli_pat, eeli_doc_delete, eeli_doc_edit, eeli_doc_create, eeli_doc_reload); viewer.setInput(ElexisEventDispatcher.getSelectedPatient()); viewer.setInput(ContextServiceHolder.get().getActivePatient().orElse(null)); } private DocumentsFilterBarComposite addFilterBar(Composite parent){ Loading @@ -603,9 +567,9 @@ public class DocumentsView extends ViewPart { filters.add(new FilterCategory(BriefConstants.AUZ, "Auf")); filters.add(new FilterCategory(BriefConstants.RP, "Rezepte")); DocumentsFilterBarComposite filterBarComposite = new DocumentsFilterBarComposite(parent, SWT.NONE, filters); filterBarComposite .setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); DocumentsFilterBarComposite filterBarComposite = new DocumentsFilterBarComposite(parent, SWT.NONE, filters); filterBarComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); filterBarComposite.addSelectionChangedListener(new ISelectionChangedListener() { @Override Loading Loading @@ -673,14 +637,10 @@ public class DocumentsView extends ViewPart { @Override public void dispose(){ ElexisEventDispatcher.getInstance().removeListeners(eeli_pat, eeli_doc_delete, eeli_doc_edit, eeli_doc_create, eeli_doc_reload); //saveSortSettings(); super.dispose(); } /** * Passing the focus request to the viewer's control. */ Loading Loading @@ -729,9 +689,8 @@ public class DocumentsView extends ViewPart { .getWorkbench().getService(ICommandService.class); Command command = commandService .getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(po)); PlatformUI.getWorkbench().getService(IEclipseContext.class).set( command.getId().concat(".selection"), new StructuredSelection(po)); try { command.executeWithChecks( new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); Loading @@ -742,7 +701,7 @@ public class DocumentsView extends ViewPart { e.printStackTrace(); } }); viewer.refresh(obj); ContextServiceHolder.get().postEvent(ElexisEventTopics.EVENT_UPDATE, dh); } } }; Loading
bundles/ch.elexis.core.ui/src/ch/elexis/core/ui/commands/StartEditLocalDocumentHandler.java +38 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 ... Loading @@ -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()) { Loading @@ -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 Loading
bundles/ch.elexis.core.ui/src/ch/elexis/core/ui/processor/ElexisProcessor.java +2 −1 Original line number Diff line number Diff line Loading @@ -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(){ Loading