Project

General

Profile

« Previous | Next » 

Revision eec20175

Added by Katja Luther almost 2 years ago

ref #10033: vocabulary representation should be editable in taxeditor

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/TermTreeDetailElement.java
10 10

  
11 11
import org.eclipse.swt.widgets.Label;
12 12

  
13
import eu.etaxonomy.cdm.model.common.Language;
14
import eu.etaxonomy.cdm.model.term.Representation;
13 15
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto;
14 16
import eu.etaxonomy.taxeditor.event.EventUtility;
15 17
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
16 18
import eu.etaxonomy.taxeditor.model.ColorResources;
17 19
import eu.etaxonomy.taxeditor.preference.Resources;
20
import eu.etaxonomy.taxeditor.store.CdmStore;
18 21
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 22
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
20 23
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.element.RepresentationElement;
21 25
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
22 26
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
23 27

  
......
31 35
    private CheckboxElement orderRelevant;
32 36
    private CheckboxElement isFlat;
33 37

  
34
    private TextWithLabelElement titleCacheText;
38
    //private TextWithLabelElement titleCacheText;
39
    protected RepresentationElement element_Representation;
35 40

  
36 41
	public TermTreeDetailElement(CdmFormFactory formFactory,
37 42
			ICdmFormElement formElement) {
......
46 51
	    lblStructureText.setText(entity.getTermType().getLabel());
47 52
	    lblStructureText.setForeground(ColorResources.getColor(Resources.BLACK));
48 53

  
49
	    titleCacheText = formFactory.createTextWithLabelElement(
50
                formElement, "Title Cache", entity.getTitleCache(), style);
51

  
54
//	    titleCacheText = formFactory.createTextWithLabelElement(
55
//                formElement, "Title Cache", entity.getTitleCache(), style);
56
	    element_Representation = formFactory.createTranslatableRepresentationElementDto(formElement,  entity.getPreferredRepresentation(CdmStore.getDefaultLanguage()),entity, 100, style, true);
52 57
	    allowDuplicates = formFactory.createCheckbox(formElement, "Allow duplicates", entity.isAllowDuplicate(), style);
53 58
	    if (entity.isContainsDuplicates() && entity.isAllowDuplicate()){
54 59
	        allowDuplicates.setEnabled(false);
......
68 73

  
69 74
	@Override
70 75
	public void handleEvent(Object eventSource) {
71
	    if (eventSource == titleCacheText) {
72
	            getEntity().setTitleCache(titleCacheText.getText());
76
	    if (eventSource == element_Representation) {
77
//	            getEntity().setTitleCache(titleCacheText.getText());
78
	    	Representation selectedRepresentation = element_Representation.getSelectedRepresentation();
79
            if(selectedRepresentation!=null){
80
                Language representationLanguage = selectedRepresentation.getLanguage();
81
                if(representationLanguage==null){
82
                    representationLanguage = Language.getDefaultLanguage();
83
                }
84
//                getEntity().setLabel(selectedRepresentation.getLabel(),  representationLanguage);
85
                Representation rep = getEntity().getRepresentation(representationLanguage);
86
                if (rep == null){
87
                	rep = new Representation(selectedRepresentation.getDescription(), selectedRepresentation.getLabel(), selectedRepresentation.getAbbreviatedLabel(), representationLanguage);
88
                	getEntity().addRepresentation(rep);
89
                }else{
90
                	getEntity().getRepresentation(representationLanguage).setLabel(selectedRepresentation.getLabel());
91
                	getEntity().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
92
                	getEntity().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription());
93
                }
94
            }
95
            getEntity().setTitleCache(null);
73 96
        }
74 97
	    else
75 98
	    if (eventSource == allowDuplicates) {

Also available in: Unified diff