Loading bundles/ch.elexis.core.documents/src/ch/elexis/core/documents/DocumentStore.java +2 −2 Original line number Diff line number Diff line Loading @@ -71,12 +71,12 @@ public class DocumentStore { Map<ICategory, List<IDocument>> map = new HashMap<>(); List<IDocument> documents = getDocuments(patientId, null, null, null); for (IDocument iDocument : documents) { List<IDocument> categoryDocuments = map.get(iDocument.getCategory()); List<IDocument> categoryDocuments = map.get(new FilterCategory(iDocument.getCategory())); if (categoryDocuments == null) { categoryDocuments = new ArrayList<>(); } categoryDocuments.add(iDocument); map.put(iDocument.getCategory(), categoryDocuments); map.put(new FilterCategory(iDocument.getCategory()), categoryDocuments); } return map; } Loading bundles/ch.elexis.core.documents/src/ch/elexis/core/documents/FilterCategory.java 0 → 100644 +62 −0 Original line number Diff line number Diff line package ch.elexis.core.documents; import java.util.Objects; import ch.elexis.core.model.ICategory; public class FilterCategory implements ICategory { private String name; private String lbl; public FilterCategory(){ this.name = null; this.lbl = "Alle"; } public FilterCategory(ICategory category){ this.name = category.getName(); } public FilterCategory(String name, String lbl){ this.name = name; this.lbl = lbl; } @Override public String getName(){ return name; } @Override public void setName(String name){ this.name = name; } public String getLbl(){ return lbl; } public boolean isAll(){ return name == null; } @Override public int hashCode(){ return Objects.hash(name); } @Override public boolean equals(Object obj){ if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FilterCategory other = (FilterCategory) obj; return Objects.equals(name, other.name); } } bundles/ch.elexis.core.ui.documents/META-INF/MANIFEST.MF +1 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ Bundle-Vendor: medevit.at Import-Package: ch.elexis.admin, ch.elexis.core.data.activator, ch.elexis.core.data.events, ch.elexis.core.ui, ch.elexis.core.ui.actions, ch.elexis.core.ui.events, ch.elexis.core.ui.icons, Loading bundles/ch.elexis.core.ui.documents/src/ch/elexis/core/ui/documents/views/DocumentsFilterBarComposite.java 0 → 100644 +117 −0 Original line number Diff line number Diff line package ch.elexis.core.ui.documents.views; import java.util.List; import java.util.Optional; import org.eclipse.core.runtime.ListenerList; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import ch.elexis.core.documents.FilterCategory; import ch.elexis.core.ui.UiDesk; public class DocumentsFilterBarComposite extends Composite implements ISelectionProvider { private DocumentTypeAction currentSelection; private ListenerList<ISelectionChangedListener> selectionChangedListeners; private List<FilterCategory> filters; private ToolBarManager manager; public DocumentsFilterBarComposite(Composite parent, int style, List<FilterCategory> filters){ super(parent, style); currentSelection = null; selectionChangedListeners = new ListenerList<>(); this.filters = filters; createContent(); } private void createContent(){ setBackground(UiDesk.getColor(UiDesk.COL_WHITE)); setLayout(new FillLayout()); manager = new ToolBarManager(SWT.WRAP); manager.createControl(this); refresh(); } public void refresh(){ updateVisible(); updateSelected(); } private void updateVisible(){ manager.removeAll(); if (filters != null) { for (FilterCategory cf : filters) { manager.add(new DocumentTypeAction(cf)); } } manager.update(true); this.getParent().layout(true); } private void updateSelected(){ fireSelectionChanged(); manager.update(true); } public void addSelectionChangedListener(ISelectionChangedListener listener){ selectionChangedListeners.add(listener); } public void removeSelectionChangedListener(ISelectionChangedListener listener){ selectionChangedListeners.remove(listener); } @Override public ISelection getSelection(){ if (currentSelection != null && currentSelection.getFilter() != null) { return new StructuredSelection(currentSelection.getFilter()); } return new StructuredSelection(Optional.empty()); } @Override public void setSelection(ISelection selection){ // ignore until needed } private void fireSelectionChanged(){ ISelection selection = getSelection(); for (ISelectionChangedListener listener : selectionChangedListeners) { SelectionChangedEvent event = new SelectionChangedEvent(this, selection); listener.selectionChanged(event); } } private class DocumentTypeAction extends Action { private FilterCategory filter; public DocumentTypeAction(FilterCategory filter){ super(filter.getLbl(), Action.AS_RADIO_BUTTON); this.filter = filter; } public FilterCategory getFilter(){ return filter; } @Override public void run(){ currentSelection = this; if (isChecked()) { fireSelectionChanged(); } manager.update(true); } } } bundles/ch.elexis.core.ui.documents/src/ch/elexis/core/ui/documents/views/DocumentsMetaDataDialog.java +7 −6 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ package ch.elexis.core.ui.documents.views; import java.text.MessageFormat; import java.util.List; import java.util.Objects; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.InputDialog; Loading Loading @@ -187,7 +188,7 @@ public class DocumentsMetaDataDialog extends TitleAreaDialog { tKeywords.setEnabled(keywordsCrudAllowed); tTitle.setText(document.getTitle()); tKeywords.setText(document.getKeywords()); tKeywords.setText(Objects.toString(document.getKeywords(), "")); Object cbSelection = document.getCategory() != null ? document.getCategory() : cbCategories.getElementAt(0); if (cbSelection != null) { Loading @@ -211,10 +212,6 @@ public class DocumentsMetaDataDialog extends TitleAreaDialog { @Override protected void okPressed(){ if (keywordsCrudAllowed) { keywords = tKeywords.getText(); } title = tTitle.getText(); StructuredSelection comboSelection = (StructuredSelection) cbCategories.getSelection(); if (document != null) { Loading @@ -223,7 +220,11 @@ public class DocumentsMetaDataDialog extends TitleAreaDialog { document.setCategory((ICategory) comboSelection.getFirstElement()); } document.setTitle(title); document.setKeywords(tKeywords.getText()); if (keywordsCrudAllowed) { keywords = tKeywords.getText(); document.setKeywords(keywords); } } super.okPressed(); } Loading Loading
bundles/ch.elexis.core.documents/src/ch/elexis/core/documents/DocumentStore.java +2 −2 Original line number Diff line number Diff line Loading @@ -71,12 +71,12 @@ public class DocumentStore { Map<ICategory, List<IDocument>> map = new HashMap<>(); List<IDocument> documents = getDocuments(patientId, null, null, null); for (IDocument iDocument : documents) { List<IDocument> categoryDocuments = map.get(iDocument.getCategory()); List<IDocument> categoryDocuments = map.get(new FilterCategory(iDocument.getCategory())); if (categoryDocuments == null) { categoryDocuments = new ArrayList<>(); } categoryDocuments.add(iDocument); map.put(iDocument.getCategory(), categoryDocuments); map.put(new FilterCategory(iDocument.getCategory()), categoryDocuments); } return map; } Loading
bundles/ch.elexis.core.documents/src/ch/elexis/core/documents/FilterCategory.java 0 → 100644 +62 −0 Original line number Diff line number Diff line package ch.elexis.core.documents; import java.util.Objects; import ch.elexis.core.model.ICategory; public class FilterCategory implements ICategory { private String name; private String lbl; public FilterCategory(){ this.name = null; this.lbl = "Alle"; } public FilterCategory(ICategory category){ this.name = category.getName(); } public FilterCategory(String name, String lbl){ this.name = name; this.lbl = lbl; } @Override public String getName(){ return name; } @Override public void setName(String name){ this.name = name; } public String getLbl(){ return lbl; } public boolean isAll(){ return name == null; } @Override public int hashCode(){ return Objects.hash(name); } @Override public boolean equals(Object obj){ if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FilterCategory other = (FilterCategory) obj; return Objects.equals(name, other.name); } }
bundles/ch.elexis.core.ui.documents/META-INF/MANIFEST.MF +1 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ Bundle-Vendor: medevit.at Import-Package: ch.elexis.admin, ch.elexis.core.data.activator, ch.elexis.core.data.events, ch.elexis.core.ui, ch.elexis.core.ui.actions, ch.elexis.core.ui.events, ch.elexis.core.ui.icons, Loading
bundles/ch.elexis.core.ui.documents/src/ch/elexis/core/ui/documents/views/DocumentsFilterBarComposite.java 0 → 100644 +117 −0 Original line number Diff line number Diff line package ch.elexis.core.ui.documents.views; import java.util.List; import java.util.Optional; import org.eclipse.core.runtime.ListenerList; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import ch.elexis.core.documents.FilterCategory; import ch.elexis.core.ui.UiDesk; public class DocumentsFilterBarComposite extends Composite implements ISelectionProvider { private DocumentTypeAction currentSelection; private ListenerList<ISelectionChangedListener> selectionChangedListeners; private List<FilterCategory> filters; private ToolBarManager manager; public DocumentsFilterBarComposite(Composite parent, int style, List<FilterCategory> filters){ super(parent, style); currentSelection = null; selectionChangedListeners = new ListenerList<>(); this.filters = filters; createContent(); } private void createContent(){ setBackground(UiDesk.getColor(UiDesk.COL_WHITE)); setLayout(new FillLayout()); manager = new ToolBarManager(SWT.WRAP); manager.createControl(this); refresh(); } public void refresh(){ updateVisible(); updateSelected(); } private void updateVisible(){ manager.removeAll(); if (filters != null) { for (FilterCategory cf : filters) { manager.add(new DocumentTypeAction(cf)); } } manager.update(true); this.getParent().layout(true); } private void updateSelected(){ fireSelectionChanged(); manager.update(true); } public void addSelectionChangedListener(ISelectionChangedListener listener){ selectionChangedListeners.add(listener); } public void removeSelectionChangedListener(ISelectionChangedListener listener){ selectionChangedListeners.remove(listener); } @Override public ISelection getSelection(){ if (currentSelection != null && currentSelection.getFilter() != null) { return new StructuredSelection(currentSelection.getFilter()); } return new StructuredSelection(Optional.empty()); } @Override public void setSelection(ISelection selection){ // ignore until needed } private void fireSelectionChanged(){ ISelection selection = getSelection(); for (ISelectionChangedListener listener : selectionChangedListeners) { SelectionChangedEvent event = new SelectionChangedEvent(this, selection); listener.selectionChanged(event); } } private class DocumentTypeAction extends Action { private FilterCategory filter; public DocumentTypeAction(FilterCategory filter){ super(filter.getLbl(), Action.AS_RADIO_BUTTON); this.filter = filter; } public FilterCategory getFilter(){ return filter; } @Override public void run(){ currentSelection = this; if (isChecked()) { fireSelectionChanged(); } manager.update(true); } } }
bundles/ch.elexis.core.ui.documents/src/ch/elexis/core/ui/documents/views/DocumentsMetaDataDialog.java +7 −6 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ package ch.elexis.core.ui.documents.views; import java.text.MessageFormat; import java.util.List; import java.util.Objects; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.InputDialog; Loading Loading @@ -187,7 +188,7 @@ public class DocumentsMetaDataDialog extends TitleAreaDialog { tKeywords.setEnabled(keywordsCrudAllowed); tTitle.setText(document.getTitle()); tKeywords.setText(document.getKeywords()); tKeywords.setText(Objects.toString(document.getKeywords(), "")); Object cbSelection = document.getCategory() != null ? document.getCategory() : cbCategories.getElementAt(0); if (cbSelection != null) { Loading @@ -211,10 +212,6 @@ public class DocumentsMetaDataDialog extends TitleAreaDialog { @Override protected void okPressed(){ if (keywordsCrudAllowed) { keywords = tKeywords.getText(); } title = tTitle.getText(); StructuredSelection comboSelection = (StructuredSelection) cbCategories.getSelection(); if (document != null) { Loading @@ -223,7 +220,11 @@ public class DocumentsMetaDataDialog extends TitleAreaDialog { document.setCategory((ICategory) comboSelection.getFirstElement()); } document.setTitle(title); document.setKeywords(tKeywords.getText()); if (keywordsCrudAllowed) { keywords = tKeywords.getText(); document.setKeywords(keywords); } } super.okPressed(); } Loading