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 |
}
|
ref #8200 Replace description label with cache element in details view