Project

General

Profile

« Previous | Next » 

Revision dea3754f

Added by Katja Luther over 3 years ago

ref #9307: add preference page for termtrees and adapt label provider

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermDtoLabelProvider.java
49 49
    @Override
50 50
    public void update(ViewerCell cell) {
51 51
        Object element = cell.getElement();
52

  
53
        String text = getText(element);
52
        boolean showIdInVoc = PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_VOCABULARY_ID_FOR_TERM_LABELS, true);
53
        String text = getText(element, showIdInVoc);
54 54
        cell.setText(text);
55 55

  
56 56
        Styler styler = null;
......
69 69
        super.update(cell);
70 70
    }
71 71

  
72
    public String getText(Object element) {
72
    public String getText(Object element, boolean showIdInVocabulary) {
73 73
        String label = null;
74 74
        if(element instanceof AbstractTermDto){
75 75
            AbstractTermDto termDto = (AbstractTermDto)element;
76 76
            termDto.localize(new TermRepresentation_L10n());
77 77
            label = termDto.getRepresentation_L10n();
78 78

  
79
            if(PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_VOCABULARY_ID_FOR_TERM_LABELS, true)
80
                    && element instanceof TermDto && ((TermDto) termDto).getIdInVocabulary()!=null){
79
            if(showIdInVocabulary && element instanceof TermDto && ((TermDto) termDto).getIdInVocabulary()!=null){
81 80
                label = CdmUtils.concat(" : ", ((TermDto) termDto).getIdInVocabulary(), label);
82 81
            }
83 82
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/FeatureTreeLabelProvider.java
11 11

  
12 12
import java.util.ArrayList;
13 13

  
14
import org.eclipse.jface.viewers.LabelProvider;
15

  
16 14
import eu.etaxonomy.cdm.model.common.Language;
17 15
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
18 16
import eu.etaxonomy.cdm.model.term.Representation;
......
21 19
import eu.etaxonomy.cdm.persistence.dto.TermDto;
22 20
import eu.etaxonomy.cdm.persistence.dto.TermNodeDto;
23 21
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto;
22
import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoLabelProvider;
23
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
24 24
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
25 25

  
26 26
/**
......
29 29
 * @created Aug 5, 2010
30 30
 * @version 1.0
31 31
 */
32
public class FeatureTreeLabelProvider extends LabelProvider {
32
public class FeatureTreeLabelProvider extends TermDtoLabelProvider{
33 33

  
34 34
	/** {@inheritDoc} */
35 35
	@Override
36
	public String getText(Object element) {
36
	public String getText(Object element, boolean showIdInVoc) {
37 37
		if(element instanceof TermTreeDto){
38 38
			return ((TermTreeDto) element).getRepresentation_L10n() != null? ((TermTreeDto) element).getRepresentation_L10n() :((TermTreeDto) element).getTitleCache()  ;
39 39
		}else if(element instanceof TermNodeDto){
40 40
		    TermDto term = ((TermNodeDto) element).getTerm();
41 41
		    if(term!=null){
42
		        String rep = term.getRepresentation_L10n();
43
//		        if (rep == null){
44
//		            rep = term.getPreferredRepresentation(new ArrayList<Language>());
45
//		        }
46
		        return rep != null? rep : term.getTitleCache();
42
		        showIdInVoc = PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_VOCABULARY_ID_FOR_TERM_LABELS_IN_TREE_EDITOR, true);
43
		        return super.getText(term, showIdInVoc);
47 44
		    }
48 45

  
49 46
		}else if(element instanceof TermNode){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/AbstractTermTreeEditor.java
280 280
        }
281 281

  
282 282
        // commit the conversation and start a new transaction immediately
283
        Object[] expandedElements = this.viewer.getExpandedElements();
283 284
        conversation.commit(true);
284 285
        if (operationList != null && !operationList.isEmpty()){
285 286
            for (AbstractPostOperation<TermNode> operation: operationList){
......
301 302
//        initializeTrees();
302 303

  
303 304
        this.setDirty(false);
305
        this.viewer.setExpandedElements(expandedElements);
304 306
	}
305 307

  
306 308
    private void initializeTrees() {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/cdmlight/CdmLightExportWizardE4.java
61 61
    @Override
62 62
    public void init() {
63 63
        configurator = new CdmLightExportConfigurator(null);
64
//        configurator.setCreateCondensedDistributionString(PreferencesUtil.getBooleanValue(PreferencePredicate.CdmLightExportCondensedDistributionString.getKey()));
65
//        if (configurator.isCreateCondensedDistributionString()){
66 64
        String recipeString = PreferencesUtil.getStringValue(PreferencePredicate.CondensedDistributionRecipe.getKey());
67 65
        if (StringUtils.isNotBlank(recipeString)){
68 66
            configurator.setCondensedDistributionRecipe(CondensedDistributionRecipe.valueOf(recipeString));
69 67
        }
70
//        }
71 68
        if (selection instanceof TreeSelection && !selection.isEmpty() &&  selection.getFirstElement() instanceof TaxonNodeDto){
72 69
            selectedNode = (TaxonNodeDto)selection.getFirstElement();
73 70

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java
54 54
	 * Whether to show vocabulary of the term when displaying it's label.
55 55
	 */
56 56
	public static final String SHOW_VOCABULARY_ID_FOR_TERM_LABELS = "eu.etaxonomy.taxeditor.showVocabularyIdForTermLabels";
57
	/**
58
     * Whether to show vocabulary of the term when displaying it's label.
59
     */
60
    public static final String SHOW_VOCABULARY_ID_FOR_TERM_LABELS_IN_TREE_EDITOR = "eu.etaxonomy.taxeditor.showVocabularyIdForTermLabelsInTreeEditor";
57 61

  
58 62
	/**
59 63
	 *
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/TermTreePreference.java
1
/**
2
* Copyright (C) 2020 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.preference;
10

  
11
import org.eclipse.jface.preference.BooleanFieldEditor;
12

  
13
import eu.etaxonomy.taxeditor.l10n.Messages;
14
import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4;
15

  
16
/**
17
 * @author k.luther
18
 * @since Nov 20, 2020
19
 */
20
public class TermTreePreference extends FieldEditorPreferencePageE4 {
21

  
22
    @Override
23
    protected void createFieldEditors() {
24
        addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SHOW_VOCABULARY_ID_FOR_TERM_LABELS_IN_TREE_EDITOR),
25
                Messages.DescriptionPreferences_1,
26
                getFieldEditorParent()));
27

  
28
    }
29

  
30
}

Also available in: Unified diff