Project

General

Profile

« Previous | Next » 

Revision e9af789c

Added by Patrick Plitzner over 4 years ago

ref #8475 Filter available feature to only parent features

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/FeatureStateWizard.java
10 10

  
11 11
import org.eclipse.jface.wizard.Wizard;
12 12

  
13
import eu.etaxonomy.cdm.model.description.Feature;
13 14
import eu.etaxonomy.cdm.model.description.FeatureState;
15
import eu.etaxonomy.cdm.model.term.TermNode;
14 16
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
15 17

  
16 18
/**
......
23 25
    private FeatureStateWizardPage page;
24 26
    private CdmFormFactory formFactory;
25 27
    private String comboLabel;
28
    private TermNode<? extends Feature> termNode;
26 29

  
27
    public FeatureStateWizard(CdmFormFactory formFactory, String comboLabel) {
30
    public FeatureStateWizard(String comboLabel, TermNode<? extends Feature> termNode, CdmFormFactory formFactory) {
28 31
        super();
29 32
        this.formFactory = formFactory;
33
        this.termNode = termNode;
30 34
        this.comboLabel = comboLabel;
31 35
        setWindowTitle("Create Feature State");
32 36
    }
33 37

  
34 38
    @Override
35 39
    public void addPages() {
36
        page = new FeatureStateWizardPage("Create Feature State", comboLabel, formFactory);
40
        page = new FeatureStateWizardPage("Create Feature State", comboLabel, termNode, formFactory);
37 41
        addPage(page);
38 42
    }
39 43

  
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
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/InapplicableIfEntityCollectionSection.java
16 16
import org.eclipse.jface.wizard.WizardDialog;
17 17

  
18 18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19
import eu.etaxonomy.cdm.model.description.Feature;
19 20
import eu.etaxonomy.cdm.model.description.FeatureState;
20 21
import eu.etaxonomy.cdm.model.term.TermNode;
21 22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
28 29
 * @date 06.03.2018
29 30
 *
30 31
 */
31
public class InapplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode, FeatureState>{
32
public class InapplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode<? extends Feature>, FeatureState>{
32 33

  
33 34
    public InapplicableIfEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation,
34 35
            ICdmFormElement parentElement, int style) {
......
39 40
     * {@inheritDoc}
40 41
     */
41 42
    @Override
42
    public Collection<FeatureState> getCollection(TermNode entity) {
43
    public Collection<FeatureState> getCollection(TermNode <? extends Feature>entity) {
43 44
        return entity.getInapplicableIf();
44 45
    }
45 46

  
......
57 58
     */
58 59
    @Override
59 60
    public FeatureState createNewElement() {
60
        FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Inapplicable If");
61
        FeatureStateWizard wizard = new FeatureStateWizard("Inapplicable If", getEntity(), formFactory);
61 62
        WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
62 63
        int status = dialog.open();
63 64
        if(status == IStatus.OK) {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/OnlyApplicableIfEntityCollectionSection.java
16 16
import org.eclipse.jface.wizard.WizardDialog;
17 17

  
18 18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19
import eu.etaxonomy.cdm.model.description.Feature;
19 20
import eu.etaxonomy.cdm.model.description.FeatureState;
20 21
import eu.etaxonomy.cdm.model.term.TermNode;
21 22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
......
28 29
 * @date 06.03.2018
29 30
 *
30 31
 */
31
public class OnlyApplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode, FeatureState>{
32
public class OnlyApplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode<? extends Feature>, FeatureState>{
32 33

  
33 34
    public OnlyApplicableIfEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation,
34 35
            ICdmFormElement parentElement, int style) {
......
39 40
     * {@inheritDoc}
40 41
     */
41 42
    @Override
42
    public Collection<FeatureState> getCollection(TermNode entity) {
43
    public Collection<FeatureState> getCollection(TermNode<? extends Feature> entity) {
43 44
        return entity.getOnlyApplicableIf();
44 45
    }
45 46

  
......
56 57
     */
57 58
    @Override
58 59
    public FeatureState createNewElement() {
59
        FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Only applicable if");
60
        FeatureStateWizard wizard = new FeatureStateWizard("Only applicable if", getEntity(), formFactory);
60 61
        WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
61 62
        int status = dialog.open();
62 63
        if(status == IStatus.OK) {

Also available in: Unified diff