Project

General

Profile

Revision fd9044a1

IDfd9044a1a21ea77c2bcd6805e180b72c26f7e50d
Parent e6d23538
Child fa1dc0a8

Added by Patrick Plitzner over 1 year ago

ref #8200 Replace description label with cache element in details view

  • Fix potential cache update problems

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java
13 13
import java.util.HashMap;
14 14
import java.util.List;
15 15
import java.util.Map;
16
import java.util.Set;
17 16

  
18 17
import javax.annotation.PostConstruct;
19 18
import javax.inject.Inject;
......
36 35
import org.eclipse.swt.widgets.Composite;
37 36
import org.eclipse.swt.widgets.Tree;
38 37

  
39
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
40 38
import eu.etaxonomy.cdm.model.common.CdmBase;
41 39
import eu.etaxonomy.cdm.model.description.DescriptionBase;
42 40
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
43 41
import eu.etaxonomy.cdm.model.description.IDescribable;
44
import eu.etaxonomy.cdm.model.description.TaxonDescription;
45 42
import eu.etaxonomy.cdm.model.name.TaxonName;
46 43
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
47
import eu.etaxonomy.cdm.model.taxon.Taxon;
48 44
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
49 45
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
50 46
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
......
209 205
    @Optional
210 206
    private void updateView(@UIEventTopic(WorkbenchEventConstants.SAVE_TAXON)boolean refresh){
211 207
        if(refresh){
212
            List<? extends CdmBase> rootEntities = getRootEntities();
213
            for (CdmBase cdmBase : rootEntities) {
214
                if (cdmBase != null){
215
                    if(cdmBase.isInstanceOf(Taxon.class)){
216
                        Taxon taxon = HibernateProxyHelper.deproxy(cdmBase, Taxon.class);
217
                        Set<TaxonDescription> descriptions = taxon.getDescriptions();
218
                        for (TaxonDescription taxonDescription : descriptions) {
219
                            taxonDescription.setTitleCache(null, false);
220
                        }
221
                    }
222
                }
223
            }
224 208
            viewer.refresh();
225 209
        }
226 210
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionDetailElement.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9 9

  
10 10
package eu.etaxonomy.taxeditor.ui.section.description;
11 11

  
12
import org.eclipse.swt.SWT;
12
import java.util.Arrays;
13

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

  
14 16
import eu.etaxonomy.cdm.model.description.DescriptionBase;
15
import eu.etaxonomy.cdm.model.term.FeatureTree;
16 17
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17 18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
18
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
19
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
20
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
19
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
21 20

  
22 21
/**
23 22
 * <p>DescriptionDetailElement class.</p>
......
26 25
 * @created Mar 5, 2010
27 26
 * @version 1.0
28 27
 */
29
public class DescriptionDetailElement extends AbstractCdmDetailElement<DescriptionBase> {
28
public class DescriptionDetailElement extends AbstractIdentifiableEntityDetailElement<DescriptionBase> {
30 29

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

  
34
	/**
35
	 * <p>Constructor for DescriptionDetailElement.</p>
36
	 *
37
	 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
38
	 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
39
	 * @param style a int.
40
	 */
41 32
	public DescriptionDetailElement(CdmFormFactory cdmFormFactory,
42 33
			ICdmFormElement formElement, int style) {
43 34
		super(cdmFormFactory, formElement);
44 35
	}
45
	
46
	/** {@inheritDoc} */
36

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

  
47
    @Override
48
    protected void updateContent() {
49
        super.updateContent();
50
        toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
51
        setIrrelevant(toggleable_cache.getState(),
52
                Arrays.asList(new Object[] { toggleable_cache}));
53
    }
54

  
55
    @Override
56
    protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) {
57
        if(!getEntity().isProtectedTitleCache()){
58
            String title = getEntity().generateTitle();
59
            getEntity().setTitleCache(title, false);
60
        }
61
        super.updateToggleableCacheField();
62
    }
63

  
60 64
	@Override
61 65
	public void handleEvent(Object eventSource) {
62
		if(eventSource == detailDescription){
63
			getEntity().setTitleCache(detailDescription.getText(), true);
64
		}
65
		else if(eventSource == selection_featureTree){
66
			FeatureTree featureTree = selection_featureTree.getSelection();
67
			//descriptive system is not available anymore since v3.3 
68
//			getEntity().setDescriptiveSystem(featureTree.getDistinctFeatures());
69
		}
66
        if (eventSource == toggleable_cache) {
67
            getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
68
            setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[] { toggleable_cache }));
69
        }
70 70
	}
71 71
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)