Project

General

Profile

Revision 1dfcb0a6

ID1dfcb0a63001d4c6c98ab5cf52b8b5633e89e222
Parent 806114a3
Child 55e4ecd4

Added by Patrick Plitzner almost 4 years ago

ref #7095 Filter out specimens that are already added

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/SpecimenSelectionDialog.java
20 20
import org.eclipse.jface.viewers.IStructuredSelection;
21 21
import org.eclipse.jface.viewers.LabelProvider;
22 22
import org.eclipse.jface.viewers.TableViewer;
23
import org.eclipse.swt.graphics.Image;
24 23
import org.eclipse.swt.layout.FillLayout;
25 24
import org.eclipse.swt.widgets.Composite;
26 25
import org.eclipse.swt.widgets.Control;
......
33 32
import eu.etaxonomy.cdm.model.description.WorkingSet;
34 33
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
35 34
import eu.etaxonomy.cdm.model.taxon.Taxon;
36
import eu.etaxonomy.taxeditor.model.ImageResources;
37 35
import eu.etaxonomy.taxeditor.store.CdmStore;
38 36

  
39 37
/**
......
59 57
        Composite composite = (Composite) super.createDialogArea(parent);
60 58
        composite.setLayout(new FillLayout());
61 59
        list = new TableViewer(composite);
62
        list.setContentProvider(new ArrayContentProvider());
63
        list.setLabelProvider(new DescriptionLabelProvider());
60
        list.setContentProvider(new DescriptionContentProvider());
61
        list.setLabelProvider(new LabelProvider());
64 62

  
65 63
        //gather descriptions
66 64
        Set<SpecimenOrObservationBase> specimens = new HashSet<>();
......
106 104
        return selectedSpecimens;
107 105
    }
108 106

  
109
    private class DescriptionLabelProvider extends LabelProvider{
107
    private class DescriptionContentProvider extends ArrayContentProvider{
108

  
110 109
        /**
111 110
         * {@inheritDoc}
112 111
         */
113 112
        @Override
114
        public Image getImage(Object element) {
115
            if(workingSet.getDescriptions().contains(element)){
116
                return ImageResources.getImage(ImageResources.SYNCED);
117
            }
118
            return null;
113
        public Object[] getElements(Object inputElement) {
114
            return ((Collection<SpecimenOrObservationBase>) inputElement).stream().filter(specimen ->
115
                specimen.getDescriptions().stream().noneMatch(description ->
116
                workingSet.getDescriptions().contains(description))).toArray();
119 117
        }
120 118
    }
121 119
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)