Project

General

Profile

« Previous | Next » 

Revision 663a45e5

Added by Katja Luther about 5 years ago

ref #7854: fix filter for none status and adapt filter to status display preference

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/FilterRowConfiguration.java
104 104

  
105 105
            configRegistry.registerConfigAttribute(
106 106
                    FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER,
107
                    new StatusDisplayConverter(),
107
                    new FilterStatusDisplayConverter(),
108 108
                    DisplayMode.NORMAL,
109 109
                    FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX+i);
110 110

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/FilterStatusDisplayConverter.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.editor.view.checklist.e4;
10 10

  
11
import org.apache.commons.lang.StringUtils;
11 12
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
12 13

  
13 14
import eu.etaxonomy.cdm.model.common.Representation;
14 15
import eu.etaxonomy.cdm.model.description.Distribution;
15 16
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
17
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
18
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
16 20
import eu.etaxonomy.taxeditor.store.CdmStore;
17 21

  
18 22
/**
......
21 25
 *
22 26
 */
23 27
public class FilterStatusDisplayConverter extends DisplayConverter{
24
    public static final String DEFAULT_ENTRY = "";
28
    public static final String DEFAULT_ENTRY = " ";
25 29
    /**
26 30
     * {@inheritDoc}
27 31
     */
......
32 36
            if (distribution.getStatus() != null){
33 37

  
34 38
                Representation rep = distribution.getStatus().getPreferredRepresentation(CdmStore.getDefaultLanguage());
39
                String displayStatus = PreferencesUtil.getStringValue(EditorPreferencePredicate.DisplayOfStatus.getKey());
35 40
                String label = rep.getLabel();
36
                return (label != null)?label:DEFAULT_ENTRY;
41
                if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary.getKey())){
42
                    return (StringUtils.isNotBlank(distribution.getStatus().getIdInVocabulary()))?distribution.getStatus().getIdInVocabulary():label;
43
                }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1.getKey())){
44

  
45
                    return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label;
46
                }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2.getKey())){
47
                    return (StringUtils.isNotBlank(distribution.getStatus().getSymbol2() ))?distribution.getStatus().getSymbol2():label;
48
                }else{
49
                    return (label != null)?label:DEFAULT_ENTRY;
50
                }
51

  
52

  
37 53

  
38 54
            }
39 55

  
40 56
            return "";
41 57
        }else if(canonicalValue instanceof PresenceAbsenceTerm){
42
            return ((PresenceAbsenceTerm)canonicalValue).getLabel();
58
            PresenceAbsenceTerm status = (PresenceAbsenceTerm)canonicalValue;
59
            Representation rep = status.getPreferredRepresentation(CdmStore.getDefaultLanguage());
60
            String displayStatus = PreferencesUtil.getStringValue(EditorPreferencePredicate.DisplayOfStatus.getKey());
61
            String label = rep.getLabel();
62
            if (status.getId() == 0){
63
                return DEFAULT_ENTRY;
64
            }
65
            if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary.getKey())){
66
                return (StringUtils.isNotBlank(status.getIdInVocabulary()))?status.getIdInVocabulary():label;
67
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1.getKey())){
68

  
69
                return (StringUtils.isNotBlank(status.getSymbol() ))?status.getSymbol():label;
70
            }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2.getKey())){
71
                return (StringUtils.isNotBlank(status.getSymbol2() ))?status.getSymbol2():label;
72
            }else{
73
                return (label != null)?label:DEFAULT_ENTRY;
74
            }
75

  
76

  
43 77
        } else if(canonicalValue!=null){
44 78
            return canonicalValue.toString();
45 79
        }
46
        return null;
80
        return DEFAULT_ENTRY;
47 81
    }
48 82

  
49 83
    /**
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/StatusDisplayConverter.java
24 24
 *
25 25
 */
26 26
public class StatusDisplayConverter extends DisplayConverter{
27
    public static final String DEFAULT_ENTRY = "";
27
    public static final String DEFAULT_ENTRY = " ";
28 28
    /**
29 29
     * {@inheritDoc}
30 30
     */
......
57 57
                }
58 58
            }
59 59

  
60
            return "";
60
            return DEFAULT_ENTRY;
61 61
        }else if(canonicalValue instanceof PresenceAbsenceTerm){
62 62
            return ((PresenceAbsenceTerm)canonicalValue).getLabel();
63 63
        } else if(canonicalValue!=null){

Also available in: Unified diff