Project

General

Profile

« Previous | Next » 

Revision 6e52cede

Added by Patrick Plitzner over 4 years ago

ref #6330 Adapt comparator to specific sorting

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceSection.java
3 3
 */
4 4
package eu.etaxonomy.taxeditor.ui.section.description;
5 5

  
6
import java.util.ArrayList;
7 6
import java.util.Collection;
8
import java.util.Collections;
9 7
import java.util.Comparator;
10
import java.util.List;
11 8

  
12 9
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
13 10
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
......
16 13
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17 14
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
18 15
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
19
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
20 16

  
21 17
/**
22 18
 * <p>
......
61 57
    /** {@inheritDoc} */
62 58
    @Override
63 59
    public Collection<DescriptionElementSource> getCollection(DescriptionElementBase entity) {
64
        List<DescriptionElementSource> sources = new ArrayList<DescriptionElementSource>(entity.getSources());
65
        Collections.sort(sources, new SourceComparator());
66
        return sources;
60
        return entity.getSources();
67 61
    }
68 62

  
69 63
    @Override
70 64
    public Comparator<DescriptionElementSource> getComparator() {
71
        return new DefaultCdmBaseComparator<>();
65
        return new SourceComparator();
72 66
    }
73 67

  
74 68
    /** {@inheritDoc} */
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/SourceComparator.java
12 12
 * @date Apr 13, 2016
13 13
 *
14 14
 */
15
public class SourceComparator implements Comparator<OriginalSourceBase> {
15
public class SourceComparator  <T extends OriginalSourceBase> implements Comparator<T> {
16 16
    @Override
17
    public int compare(OriginalSourceBase o1, OriginalSourceBase o2) {
17
    public int compare(T o1, T o2) {
18 18
        int id1 = o1.getId();
19 19
        int id2 = o2.getId();
20 20
        OriginalSourceType type1 = o1.getType();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/SourceSection.java
3 3
 */
4 4
package eu.etaxonomy.taxeditor.ui.section.supplemental;
5 5

  
6
import java.util.ArrayList;
7 6
import java.util.Collection;
8
import java.util.Collections;
9 7
import java.util.Comparator;
10
import java.util.List;
11 8

  
12 9
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
13 10
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
......
17 14
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18 15
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
19 16
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
20
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
21 17
import eu.etaxonomy.taxeditor.ui.section.description.SourceComparator;
22 18

  
23 19
/**
......
60 56
	@Override
61 57
	public Collection<IdentifiableSource> getCollection(
62 58
			IIdentifiableEntity entity) {
63
		List<IdentifiableSource> sources = new ArrayList<IdentifiableSource>(entity.getSources());
64
		Collections.sort(sources, new SourceComparator());
65
        return sources;
59
		return entity.getSources();
66 60
	}
67 61

  
68 62
	@Override
69 63
	public Comparator<IdentifiableSource> getComparator() {
70
        return new DefaultCdmBaseComparator<>();
64
        return new SourceComparator();
71 65
	}
72 66

  
73 67
	/** {@inheritDoc} */

Also available in: Unified diff