Project

General

Profile

Download (3.3 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.description;
10

    
11
import java.util.stream.Collectors;
12

    
13
import org.eclipse.jface.util.PropertyChangeEvent;
14

    
15
import eu.etaxonomy.cdm.model.description.DescriptionBase;
16
import eu.etaxonomy.cdm.model.description.DescriptionType;
17
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
19
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
20
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
21

    
22
/**
23
 * <p>DescriptionDetailElement class.</p>
24
 *
25
 * @author n.hoffmann
26
 * @created Mar 5, 2010
27
 */
28
public class DescriptionDetailElement
29
        extends AbstractIdentifiableEntityDetailElement<DescriptionBase<?>> {
30

    
31
//	private EntitySelectionElement<FeatureTree> selection_featureTree;
32
    private TextWithLabelElement txtDescriptionTypes;
33

    
34
	public DescriptionDetailElement(CdmFormFactory cdmFormFactory,
35
			ICdmFormElement formElement, int style) {
36
		super(cdmFormFactory, formElement);
37
		setEnabled(enabled);
38
	}
39

    
40
	@Override
41
	protected void createControls(ICdmFormElement formElement, DescriptionBase entity, int style) {
42
        toggleable_cache = formFactory.createToggleableTextField(this, "Label",
43
                entity.getTitleCache(), entity.isProtectedTitleCache(), style);
44
        toggleable_cache.setEnabled(!entity.isComputed());
45
		// TODO I initially thought that we can handle the entity's descriptive system with a feature tree
46
		// Since descriptiveSystem is a Set of Features that are present or allowed for the current description,
47
		// it is similar to a FeatureTree (you can get this information from a feature tree) but not the same.
48
		// Please correct this once it is clear what descriptive system will be used for in CDM
49
//		selection_featureTree = formFactory.createSelectionElement(FeatureTree.class, getConversationHolder(), formElement, "Feature Tree", null, EntitySelectionElement.ALL, style);
50

    
51
        Object typesString = entity.getTypes().stream().filter(type->type instanceof DescriptionType)
52
        		.map(type->((DescriptionType)type).getLabel())
53
        		.collect(Collectors.joining(","));
54
        txtDescriptionTypes = formFactory.createTextWithLabelElement(formElement, "Types", typesString, style);
55
        txtDescriptionTypes.setEnabled(false);
56

    
57
	}
58

    
59
//	@Override
60
//    protected void updateControlStates(){
61
//
62
//        if (getEntity().isComputed()){
63
//            enabled = false;
64
//         }else{
65
//            enabled = true;
66
//        }
67
//        setEnabled(enabled);
68
//    }
69

    
70

    
71

    
72
    @Override
73
    protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) {
74
        if(!getEntity().isProtectedTitleCache()){
75
            String title = getEntity().generateTitle();
76
            getEntity().setTitleCache(title, false);
77
        }
78
        super.updateToggleableCacheField();
79
    }
80

    
81
	@Override
82
	public void handleEvent(Object eventSource) {
83
        if (eventSource == toggleable_cache) {
84
            getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
85
            updateCacheRelevance();
86
        }
87
	}
88
}
(4-4/26)