2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.description
;
12 import java
.util
.Arrays
;
13 import java
.util
.stream
.Collectors
;
15 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
17 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
18 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionType
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractIdentifiableEntityDetailElement
;
25 * <p>DescriptionDetailElement class.</p>
28 * @created Mar 5, 2010
31 public class DescriptionDetailElement
extends AbstractIdentifiableEntityDetailElement
<DescriptionBase
> {
33 // private EntitySelectionElement<FeatureTree> selection_featureTree;
34 private TextWithLabelElement txtDescriptionTypes
;
36 public DescriptionDetailElement(CdmFormFactory cdmFormFactory
,
37 ICdmFormElement formElement
, int style
) {
38 super(cdmFormFactory
, formElement
);
42 protected void createControls(ICdmFormElement formElement
, DescriptionBase entity
, int style
) {
43 toggleable_cache
= formFactory
.createToggleableTextField(this, "Label", entity
.getTitleCache(), entity
.isProtectedTitleCache(), style
);
44 // TODO I initially thought that we can handle the entity's descriptive system with a feature tree
45 // Since descriptiveSystem is a Set of Features that are present or allowed for the current description,
46 // it is similar to a FeatureTree (you can get this information from a feature tree) but not the same.
47 // Please correct this once it is clear what descriptive system will be used for in CDM
48 // selection_featureTree = formFactory.createSelectionElement(FeatureTree.class, getConversationHolder(), formElement, "Feature Tree", null, EntitySelectionElement.ALL, style);
50 Object typesString
= entity
.getTypes().stream().filter(type
->type
instanceof DescriptionType
)
51 .map(type
->((DescriptionType
)type
).getMessage())
52 .collect(Collectors
.joining(","));
53 txtDescriptionTypes
= formFactory
.createTextWithLabelElement(formElement
, "Types", typesString
, style
);
54 txtDescriptionTypes
.setEnabled(false);
58 protected void updateContent() {
59 super.updateContent();
60 toggleable_cache
.setEnabled(getEntity().isProtectedTitleCache());
61 setIrrelevant(toggleable_cache
.getState(),
62 Arrays
.asList(new Object
[] { txtDescriptionTypes
, toggleable_cache
}));
66 protected void handleTitleCacheRelevantChange(PropertyChangeEvent event
) {
67 if(!getEntity().isProtectedTitleCache()){
68 String title
= getEntity().generateTitle();
69 getEntity().setTitleCache(title
, false);
71 super.updateToggleableCacheField();
75 public void handleEvent(Object eventSource
) {
76 if (eventSource
== toggleable_cache
) {
77 getEntity().setTitleCache(toggleable_cache
.getText(), toggleable_cache
.getState());
78 setIrrelevant(toggleable_cache
.getState(), Arrays
.asList(new Object
[] { toggleable_cache
}));