-// $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 org.eclipse.swt.SWT;
+import java.util.Arrays;
+
+import org.eclipse.jface.util.PropertyChangeEvent;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
-import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
-import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
-import eu.etaxonomy.taxeditor.ui.selection.FeatureTreeSelectionElement;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
/**
* <p>DescriptionDetailElement class.</p>
* @created Mar 5, 2010
* @version 1.0
*/
-public class DescriptionDetailElement extends AbstractCdmDetailElement<DescriptionBase> {
+public class DescriptionDetailElement extends AbstractIdentifiableEntityDetailElement<DescriptionBase> {
- private TextWithLabelElement detailDescription;
- private FeatureTreeSelectionElement selection_featureTree;
+// private EntitySelectionElement<FeatureTree> selection_featureTree;
- /**
- * <p>Constructor for DescriptionDetailElement.</p>
- *
- * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
- * @param style a int.
- */
public DescriptionDetailElement(CdmFormFactory cdmFormFactory,
ICdmFormElement formElement, int style) {
super(cdmFormFactory, formElement);
}
-
- /** {@inheritDoc} */
+
@Override
protected void createControls(ICdmFormElement formElement, DescriptionBase entity, int style) {
- detailDescription = formFactory.createMultilineTextWithLabel(this, "Label", 50, SWT.WRAP);
- detailDescription.setText(entity.getTitleCache());
-
- selection_featureTree = (FeatureTreeSelectionElement) formFactory.createSelectionElement(SelectionType.FEATURE_TREE, getConversationHolder(), formElement, "Feature Tree", null, style, 1);
+ toggleable_cache = formFactory.createToggleableTextField(this, "Label", entity.getTitleCache(), entity.isProtectedTitleCache(), style);
+ // TODO I initially thought that we can handle the entity's descriptive system with a feature tree
+ // Since descriptiveSystem is a Set of Features that are present or allowed for the current description,
+ // it is similar to a FeatureTree (you can get this information from a feature tree) but not the same.
+ // Please correct this once it is clear what descriptive system will be used for in CDM
+// selection_featureTree = formFactory.createSelectionElement(FeatureTree.class, getConversationHolder(), formElement, "Feature Tree", null, EntitySelectionElement.ALL, style);
}
-
- /** {@inheritDoc} */
+
+ @Override
+ protected void updateContent() {
+ super.updateContent();
+ toggleable_cache.setEnabled(getEntity().isProtectedTitleCache());
+ setIrrelevant(toggleable_cache.getState(),
+ Arrays.asList(new Object[] { toggleable_cache}));
+ }
+
+ @Override
+ protected void handleTitleCacheRelevantChange(PropertyChangeEvent event) {
+ if(!getEntity().isProtectedTitleCache()){
+ String title = getEntity().generateTitle();
+ getEntity().setTitleCache(title, false);
+ }
+ super.updateToggleableCacheField();
+ }
+
@Override
public void handleEvent(Object eventSource) {
- if(eventSource == detailDescription){
- getEntity().setTitleCache(detailDescription.getText(), true);
- }
- else if(eventSource == selection_featureTree){
- FeatureTree featureTree = selection_featureTree.getSelection();
- getEntity().setDescriptiveSystem(featureTree.getDistinctFeatures());
- }
+ if (eventSource == toggleable_cache) {
+ getEntity().setTitleCache(toggleable_cache.getText(), toggleable_cache.getState());
+ setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[] { toggleable_cache }));
+ }
}
}