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
|
formFactory.createDetailedDescriptionDetailElement(formElement, entity, style, isEnabled());
|
51
|
}
|
52
|
|
53
|
/** {@inheritDoc} */
|
54
|
@Override
|
55
|
public void handleEvent(Object eventSource) {
|
56
|
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
protected void updateControlStates(){
|
61
|
Collection<Object> except = new ArrayList<Object>();
|
62
|
for(ICdmFormElement formElement:getElements()){
|
63
|
if(formElement instanceof IEnableableFormElement && !((IEnableableFormElement) formElement).isEnabled()){
|
64
|
except.add(formElement);
|
65
|
}
|
66
|
}
|
67
|
if ((getEntity().getInDescription() != null && getEntity().getInDescription().isComputed() && PreferencesUtil.isComputedDesciptionHandlingDisabled()) || (getEntity() instanceof Distribution && AbstractUtility.getActivePart() instanceof IDistributionEditorPart)){
|
68
|
enabled = false;
|
69
|
}else{
|
70
|
enabled = true;
|
71
|
}
|
72
|
setEnabled(enabled, except);
|
73
|
}
|
74
|
}
|