Revision e9af789c
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureStateWizardPage.java | ||
---|---|---|
20 | 20 |
import eu.etaxonomy.cdm.model.description.Feature; |
21 | 21 |
import eu.etaxonomy.cdm.model.description.FeatureState; |
22 | 22 |
import eu.etaxonomy.cdm.model.description.State; |
23 |
import eu.etaxonomy.cdm.model.term.TermNode; |
|
23 | 24 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
24 | 25 |
import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage; |
25 | 26 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
26 | 27 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
27 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
|
28 | 28 |
|
29 | 29 |
/** |
30 | 30 |
* @author pplitzner |
... | ... | |
33 | 33 |
*/ |
34 | 34 |
public class FeatureStateWizardPage extends AbstractEntityCollectionElementWizardPage { |
35 | 35 |
|
36 |
private TermComboElement<Feature> comboFeature; |
|
36 | 37 |
private TermComboElement<State> comboState; |
37 |
private EntitySelectionElement<Feature> selectFeature; |
|
38 | 38 |
private String comboLabel; |
39 |
private TermNode<? extends Feature> termNode; |
|
39 | 40 |
|
40 |
protected FeatureStateWizardPage(String pageName, String comboLabel, CdmFormFactory formFactory) { |
|
41 |
protected FeatureStateWizardPage(String pageName, String comboLabel, TermNode<? extends Feature> termNode, CdmFormFactory formFactory) {
|
|
41 | 42 |
super(pageName, formFactory); |
42 | 43 |
this.comboLabel = comboLabel; |
44 |
this.termNode = termNode; |
|
43 | 45 |
setTitle("Create Feature State"); |
44 | 46 |
setDescription("Select Feature and State"); |
45 | 47 |
} |
... | ... | |
48 | 50 |
public void createControl(Composite parent) { |
49 | 51 |
super.createControl(parent); |
50 | 52 |
|
51 |
selectFeature = formFactory.createSelectionElement(Feature.class, rootElement, "Feature", null, EntitySelectionElement.SELECTABLE, SWT.NONE); |
|
53 |
comboFeature = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, rootElement, "Parent Feature", null, SWT.NONE); |
|
54 |
updateFeatureCombo(); |
|
55 |
|
|
52 | 56 |
comboState = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, rootElement, comboLabel, null, SWT.NONE); |
53 | 57 |
comboState.setEnabled(false); |
54 | 58 |
|
... | ... | |
56 | 60 |
} |
57 | 61 |
|
58 | 62 |
FeatureState getFeatureState(){ |
59 |
return FeatureState.NewInstance(selectFeature.getSelection(), comboState.getSelection()); |
|
63 |
return FeatureState.NewInstance(comboFeature.getSelection(), comboState.getSelection()); |
|
64 |
} |
|
65 |
|
|
66 |
private void updateFeatureCombo(){ |
|
67 |
List<Feature> features = new ArrayList<>(); |
|
68 |
TermNode<? extends Feature> parent = termNode.getParent(); |
|
69 |
while(parent!=null){ |
|
70 |
features.add(parent.getTerm()); |
|
71 |
parent = parent.getParent(); |
|
72 |
} |
|
73 |
comboFeature.setTerms(features); |
|
60 | 74 |
} |
61 | 75 |
|
62 |
private void updateCombo(Feature feature){ |
|
76 |
private void updateStateCombo(Feature feature){
|
|
63 | 77 |
comboState.setEnabled(true); |
64 |
List<State> stateTerms = new ArrayList<State>();
|
|
78 |
List<State> stateTerms = new ArrayList<>(); |
|
65 | 79 |
Set<TermVocabulary<State>> stateVocabularies = feature.getSupportedCategoricalEnumerations(); |
66 | 80 |
for (TermVocabulary<State> termVocabulary : stateVocabularies) { |
67 | 81 |
stateTerms.addAll(termVocabulary.getTerms()); |
... | ... | |
71 | 85 |
|
72 | 86 |
@Override |
73 | 87 |
public boolean isPageComplete() { |
74 |
return selectFeature.getSelection()!=null && comboState.getSelection()!=null;
|
|
88 |
return comboFeature.getSelection()!=null && comboState.getSelection()!=null;
|
|
75 | 89 |
} |
76 | 90 |
|
77 | 91 |
@Override |
78 | 92 |
public void propertyChange(PropertyChangeEvent event) { |
79 |
if(event.getSource()==selectFeature){
|
|
80 |
Feature feature = selectFeature.getSelection();
|
|
81 |
updateCombo(feature); |
|
93 |
if(event.getSource()==comboFeature){
|
|
94 |
Feature feature = comboFeature.getSelection();
|
|
95 |
updateStateCombo(feature);
|
|
82 | 96 |
} |
83 | 97 |
getWizard().getContainer().updateButtons(); |
84 | 98 |
} |
Also available in: Unified diff
ref #8475 Filter available feature to only parent features