-// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
package eu.etaxonomy.taxeditor.ui.section.description;
+import java.util.ArrayList;
+import java.util.Collection;
+
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Distribution;
+import eu.etaxonomy.taxeditor.editor.IDistributionEditorPart;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
/**
ICdmFormElement formElement, int style) {
super(cdmFormFactory, formElement);
}
-
+
/** {@inheritDoc} */
@Override
protected void createControls(ICdmFormElement formElement, DescriptionElementBase entity, int style) {
- formFactory.createDetailedDescriptionDetailElement(formElement, entity, style);
- }
+ setEnabled(!((getEntity().getInDescription() != null && (getEntity().getInDescription().isComputed() || getEntity().getInDescription().isCloneForSource())&& PreferencesUtil.isComputedDesciptionHandlingDisabled()) || (getEntity() instanceof Distribution && AbstractUtility.getActivePart() instanceof IDistributionEditorPart)));
+ formFactory.createDetailedDescriptionDetailElement(formElement, entity, style, isEnabled());
+ }
+
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
-
+
}
+
+ @Override
+ protected void updateControlStates(){
+ Collection<Object> except = new ArrayList<Object>();
+ for(ICdmFormElement formElement:getElements()){
+ if(formElement instanceof IEnableableFormElement && !((IEnableableFormElement) formElement).isEnabled()){
+ except.add(formElement);
+ }
+ }
+ if ((getEntity().getInDescription() != null && (getEntity().getInDescription().isComputed() || getEntity().getInDescription().isCloneForSource())&& PreferencesUtil.isComputedDesciptionHandlingDisabled()) || (getEntity() instanceof Distribution && AbstractUtility.getActivePart() instanceof IDistributionEditorPart)){
+ enabled = false;
+ }else{
+ enabled = true;
+ }
+ setEnabled(enabled, except);
+ }
}