Revision 593915d2
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/InapplicableIfCollectionElement.java | ||
---|---|---|
11 | 11 |
import org.eclipse.swt.events.SelectionListener; |
12 | 12 |
import org.eclipse.swt.graphics.Color; |
13 | 13 |
|
14 |
import eu.etaxonomy.cdm.model.description.State; |
|
15 |
import eu.etaxonomy.cdm.model.term.TermNode; |
|
16 |
import eu.etaxonomy.cdm.model.term.TermType; |
|
17 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
|
14 |
import eu.etaxonomy.cdm.model.description.FeatureState; |
|
18 | 15 |
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; |
19 | 16 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
20 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
21 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement; |
|
22 | 17 |
|
23 | 18 |
/** |
24 | 19 |
* @author pplitzner |
25 | 20 |
* @date Apr 27, 2015 |
26 | 21 |
* |
27 | 22 |
*/ |
28 |
public class InapplicableIfCollectionElement extends AbstractEntityCollectionElement<State> {
|
|
23 |
public class InapplicableIfCollectionElement extends AbstractApplicableElement {
|
|
29 | 24 |
|
30 |
private TermComboElement<State> comboState; |
|
31 |
|
|
32 |
public InapplicableIfCollectionElement(CdmFormFactory formFactory, AbstractFormSection section, State entity, |
|
25 |
public InapplicableIfCollectionElement(CdmFormFactory formFactory, AbstractFormSection section, FeatureState entity, |
|
33 | 26 |
SelectionListener removeListener, Color backgroundColor, int style) { |
34 | 27 |
super(formFactory, section, entity, removeListener, backgroundColor, style); |
35 |
|
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public void createControls(ICdmFormElement element, int style) { |
|
40 |
comboState = formFactory.createDefinedTermComboElement(TermType.State, element, "Inapplicable if", null, style); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public void setEntity(State entity) { |
|
45 |
this.entity = entity; |
|
46 |
if(entity.getId()!=0){ |
|
47 |
comboState.setSelection(entity); |
|
48 |
comboState.removeEmptyElement(); |
|
49 |
} |
|
50 | 28 |
} |
51 | 29 |
|
52 | 30 |
@Override |
53 |
public void handleEvent(Object eventSource) { |
|
54 |
if(eventSource==comboState && comboState.getSelection()!=null){ |
|
55 |
if(getParentElement() instanceof InapplicableIfEntityCollectionSection){ |
|
56 |
InapplicableIfEntityCollectionSection parentElement = (InapplicableIfEntityCollectionSection) getParentElement(); |
|
57 |
TermNode node = parentElement.getEntity(); |
|
58 |
node.removeInapplicableState(entity); |
|
59 |
State state = comboState.getSelection(); |
|
60 |
node.addInapplicableState(state); |
|
61 |
entity = state; |
|
62 |
parentElement.removeElementAndUpdate(null); |
|
63 |
} |
|
64 |
} |
|
31 |
protected String getComboLabel() { |
|
32 |
// TODO Auto-generated method stub |
|
33 |
return "Inapplicable if"; |
|
65 | 34 |
} |
66 | 35 |
|
67 | 36 |
} |
Also available in: Unified diff
ref #8475 First (unstable) implementation of FeatureState details