Project

General

Profile

Download (3.05 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

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

    
12
import java.util.ArrayList;
13
import java.util.Collection;
14

    
15
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
16
import eu.etaxonomy.cdm.model.description.Distribution;
17
import eu.etaxonomy.taxeditor.editor.IDistributionEditorPart;
18
import eu.etaxonomy.taxeditor.model.AbstractUtility;
19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
24

    
25
/**
26
 * <p>DescriptionElementDetailElement class.</p>
27
 *
28
 * @author n.hoffmann
29
 * @created Mar 5, 2010
30
 * @version 1.0
31
 */
32
public class DescriptionElementDetailElement extends
33
		AbstractCdmDetailElement<DescriptionElementBase> {
34

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

    
47
	/** {@inheritDoc} */
48
	@Override
49
	protected void createControls(ICdmFormElement formElement, DescriptionElementBase entity, int style) {
50
	
51
		setEnabled(!((getEntity().getInDescription() != null && (getEntity().getInDescription().isComputed() || getEntity().getInDescription().isCloneForSource())&& PreferencesUtil.isComputedDesciptionHandlingDisabled()) || (getEntity() instanceof Distribution && AbstractUtility.getActivePart() instanceof IDistributionEditorPart)));
52
		formFactory.createDetailedDescriptionDetailElement(formElement, entity, style, isEnabled());
53
	}
54

    
55
	/** {@inheritDoc} */
56
	@Override
57
	public void handleEvent(Object eventSource) {
58

    
59
	}
60

    
61
	@Override
62
    protected void updateControlStates(){
63
        Collection<Object> except = new ArrayList<Object>();
64
        for(ICdmFormElement formElement:getElements()){
65
            if(formElement instanceof IEnableableFormElement && !((IEnableableFormElement) formElement).isEnabled()){
66
                except.add(formElement);
67
            }
68
        }
69
        if ((getEntity().getInDescription() != null && (getEntity().getInDescription().isComputed() || getEntity().getInDescription().isCloneForSource())&& PreferencesUtil.isComputedDesciptionHandlingDisabled()) || (getEntity() instanceof Distribution && AbstractUtility.getActivePart() instanceof IDistributionEditorPart)){
70
            enabled = false;
71
         }else{
72
            enabled = true;
73
        }
74
        setEnabled(enabled, except);
75
    }
76

    
77
	@Override
78
	public void fillFields() {
79
		// TODO actually not used
80
		
81
	}
82
}
(6-6/26)