Project

General

Profile

Revision 521ddbfc

ID521ddbfcf7bdb7ec6205a7ad941ca21c3eb607bd
Parent 43c739f3
Child bb67f3ba

Added by Patrick Plitzner 8 months ago

ref #7502 Refactor column generation

  • move constants and column properties to bulk editor input

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java
89 89
 */
90 90
public class BulkEditorE4Composite extends Composite {
91 91

  
92
    public static final String TYPE_PROPERTY = Messages.BulkEditorE4_TYPE;
93

  
94
    public static final String ID_PROPERTY = "Id"; //$NON-NLS-1$
95

  
96
    public static final String UUID_PROPERTY = "Uuid"; //$NON-NLS-1$
97

  
98 92
    public static final String LABEL_CANDIDATE = "LABEL_CANDIDATE"; //$NON-NLS-1$
99 93
    public static final String LABEL_CANDIDATE_ICON = "LABEL_CANDIDATE_ICON"; //$NON-NLS-1$
100 94

  
......
145 139
	@SuppressWarnings("unused")
146 140
    public void init(AbstractBulkEditorInput<?> input){
147 141

  
148
        columnList.add(input.getName());
149
        columnList.add(TYPE_PROPERTY);
150
        columnList.add(UUID_PROPERTY);
151
        columnList.add(ID_PROPERTY);
142
        input.getPropertyKeys().forEach(key->columnList.add(key));
152 143

  
153 144
	    new BulkEditorSearchE4(this, topComposite, SWT.NONE);
154 145
	    //layout needed because the search bar is added after @PostConstuct method
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorPropertyAccessor.java
20 20
 */
21 21
public class BulkEditorPropertyAccessor implements IColumnPropertyAccessor<CdmBase> {
22 22

  
23
        private AbstractBulkEditorInput input;
24
        BulkEditorE4Composite bulkEditorComposite;
23
        private AbstractBulkEditorInput<CdmBase> input;
24
        private BulkEditorE4Composite bulkEditorComposite;
25 25

  
26 26
        public BulkEditorPropertyAccessor(BulkEditorE4Composite bulkEditorComposite, AbstractBulkEditorInput<CdmBase> input) {
27 27
            super();
......
30 30
        }
31 31

  
32 32
        @Override
33
        public Object getDataValue(CdmBase rowObject, int columnIndex) {
33
        public Object getDataValue(CdmBase cdmBase, int columnIndex) {
34 34
            String property = bulkEditorComposite.getColumnList().get(columnIndex);
35
            if(property.equals(input.getName())){
36
                return input.getText(rowObject);
37
            }if(property.equals(BulkEditorE4Composite.TYPE_PROPERTY)){
38
                return input.getTypeText(rowObject);
39
            }if(property.equals(BulkEditorE4Composite.UUID_PROPERTY)){
40
                return rowObject.getUuid();
41
            }if(property.equals(BulkEditorE4Composite.ID_PROPERTY)){
42
                return rowObject.getId();
43
            }
44
            return null;
35
            return input.getPropertyValue(cdmBase, property);
45 36
        }
46 37

  
47 38
        @Override
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
57 57
public abstract class AbstractBulkEditorInput<T extends CdmBase> extends CdmEntitySessionInput implements
58 58
    IEntityPersistenceService<T> {
59 59

  
60

  
61
    private static final String TYPE_PROPERTY = Messages.BulkEditorE4_TYPE;
62
    private static final String ID_PROPERTY = "Id"; //$NON-NLS-1$
63
    private static final String UUID_PROPERTY = "Uuid"; //$NON-NLS-1$
64

  
60 65
	private UUID entityUuid;
61 66

  
62 67
	private BasicEventList<T> model = new BasicEventList<>();
......
112 117

  
113 118
	protected abstract T loadEntity(UUID entityUuid);
114 119

  
120
    public List<String> getPropertyKeys(){
121
        List<String> properties = new ArrayList<>();
122
        properties.add(getName());
123
        properties.add(TYPE_PROPERTY);
124
        properties.addAll(getPropertyKeys_internal());
125
        properties.add(ID_PROPERTY);
126
        properties.add(UUID_PROPERTY);
127
        return properties;
128
    }
129

  
130
    protected abstract List<String> getPropertyKeys_internal();
131

  
132

  
133
    public Object getPropertyValue(T cdmBase, String property){
134
        if(property.equals(getName())){
135
            return getText(cdmBase);
136
        }else if(property.equals(TYPE_PROPERTY)){
137
            return getTypeText(cdmBase);
138
        }else if(property.equals(UUID_PROPERTY)){
139
            return cdmBase.getUuid();
140
        }else if(property.equals(ID_PROPERTY)){
141
            return cdmBase.getId();
142
        }
143
        return null;
144
    }
145

  
115 146
	public Comparator<T> getTitleComparator(){
116 147
	    return new TitleCacheComparator();
117 148
	}
......
403 434
    public void setMergedEntities(HashMap<T, Set<T>> mergedEntities) {
404 435
        this.mergedEntities = mergedEntities;
405 436
    }
437

  
406 438
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.bulkeditor.input;
10 10

  
11
import java.util.ArrayList;
11 12
import java.util.Arrays;
12 13
import java.util.List;
13 14
import java.util.UUID;
......
47 48

  
48 49
	private static AgentEditorInput instance;
49 50

  
51
	private static final String PROPERTY_NOMENCLATURAL_TITLE = "PROPERTY_NOMENCLATURAL_TITLE";
52

  
50 53
	public static String getID() {
51 54
		return ID;
52 55
	}
53 56

  
57
	@Override
58
	protected List<String> getPropertyKeys_internal() {
59
	    List<String> propertyKeysInternal = new ArrayList<>();
60
	    return propertyKeysInternal;
61
	}
62

  
63
	@Override
64
	public Object getPropertyValue(TeamOrPersonBase cdmBase, String property) {
65
	    if(property.equals(PROPERTY_NOMENCLATURAL_TITLE)){
66
	        return cdmBase.getNomenclaturalTitle();
67
	    }
68
	    return super.getPropertyValue(cdmBase, property);
69
	}
70

  
54 71
    @Override
55 72
    public String getName() {
56 73
		return BulkEditorInputType.AGENT.label;
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.bulkeditor.input;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.Arrays;
13 14
import java.util.Comparator;
14 15
import java.util.List;
......
50 51
	}
51 52

  
52 53
    @Override
54
    protected List<String> getPropertyKeys_internal() {
55
        List<String> propertyKeysInternal = new ArrayList<>();
56
        return propertyKeysInternal;
57
    }
58

  
59
    @Override
53 60
	public String getName() {
54 61
		return BulkEditorInputType.GROUP.label;
55 62
	}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/MediaEditorInput.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.bulkeditor.input;
10 10

  
11
import java.util.ArrayList;
11 12
import java.util.Arrays;
12 13
import java.util.List;
13 14
import java.util.UUID;
......
46 47
    }
47 48

  
48 49
    @Override
50
    protected List<String> getPropertyKeys_internal() {
51
        List<String> propertyKeysInternal = new ArrayList<>();
52
        return propertyKeysInternal;
53
    }
54

  
55
    @Override
49 56
    public String getName() {
50 57
        return BulkEditorInputType.MEDIA.label;
51 58
    }
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameEditorInput.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.bulkeditor.input;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.Arrays;
13 14
import java.util.List;
14 15
import java.util.UUID;
......
51 52
		return instance;
52 53
	}
53 54

  
55
	@Override
56
    protected List<String> getPropertyKeys_internal() {
57
        List<String> propertyKeysInternal = new ArrayList<>();
58
        return propertyKeysInternal;
59
    }
60

  
54 61
    @Override
55 62
    public String getName() {
56 63
		return BulkEditorInputType.NAME.label;
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameRelationshipEditorInput.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.bulkeditor.input;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.Arrays;
13 14
import java.util.List;
14 15
import java.util.UUID;
......
52 53
	}
53 54

  
54 55
    @Override
56
    protected List<String> getPropertyKeys_internal() {
57
        List<String> propertyKeysInternal = new ArrayList<>();
58
        return propertyKeysInternal;
59
    }
60

  
61
    @Override
55 62
	public String getName() {
56 63
		return BulkEditorInputType.NAME_RELATIONSHIP.label;
57 64
	}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/OccurrenceEditorInput.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.bulkeditor.input;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.Arrays;
13 14
import java.util.List;
14 15
import java.util.UUID;
......
58 59
		return instance;
59 60
	}
60 61

  
62
    @Override
63
    protected List<String> getPropertyKeys_internal() {
64
        List<String> propertyKeysInternal = new ArrayList<>();
65
        return propertyKeysInternal;
66
    }
67

  
61 68
	@Override
62 69
	protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) {
63 70
	    return CdmStore.getService(IOccurrenceService.class).countByTitle(configurator);
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/ReferenceEditorInput.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.bulkeditor.input;
10 10

  
11
import java.util.ArrayList;
11 12
import java.util.Arrays;
12 13
import java.util.List;
13 14
import java.util.UUID;
......
54 55
	}
55 56

  
56 57
    @Override
58
    protected List<String> getPropertyKeys_internal() {
59
        List<String> propertyKeysInternal = new ArrayList<>();
60
        return propertyKeysInternal;
61
    }
62

  
63
    @Override
57 64
    public String getName() {
58 65
		return BulkEditorInputType.REFERENCE.label;
59 66
	}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/TaxonEditorInput.java
47 47
	}
48 48

  
49 49
    @Override
50
    protected List<String> getPropertyKeys_internal() {
51
        List<String> propertyKeysInternal = new ArrayList<>();
52
        return propertyKeysInternal;
53
    }
54

  
55
    @Override
50 56
	public String getName() {
51 57
		return BulkEditorInputType.TAXON.label;
52 58
	}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/UserEditorInput.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.bulkeditor.input;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.Arrays;
13 14
import java.util.Comparator;
14 15
import java.util.List;
......
48 49
	}
49 50

  
50 51
    @Override
52
    protected List<String> getPropertyKeys_internal() {
53
        List<String> propertyKeysInternal = new ArrayList<>();
54
        return propertyKeysInternal;
55
    }
56

  
57
    @Override
51 58
	public String getName() {
52 59
		return BulkEditorInputType.USER.label;
53 60
	}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)