import org.eclipse.jface.wizard.Wizard;
+import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureState;
+import eu.etaxonomy.cdm.model.term.TermNode;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
/**
private FeatureStateWizardPage page;
private CdmFormFactory formFactory;
private String comboLabel;
+ private TermNode<? extends Feature> termNode;
- public FeatureStateWizard(CdmFormFactory formFactory, String comboLabel) {
+ public FeatureStateWizard(String comboLabel, TermNode<? extends Feature> termNode, CdmFormFactory formFactory) {
super();
this.formFactory = formFactory;
+ this.termNode = termNode;
this.comboLabel = comboLabel;
setWindowTitle("Create Feature State");
}
@Override
public void addPages() {
- page = new FeatureStateWizardPage("Create Feature State", comboLabel, formFactory);
+ page = new FeatureStateWizardPage("Create Feature State", comboLabel, termNode, formFactory);
addPage(page);
}
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureState;
import eu.etaxonomy.cdm.model.description.State;
+import eu.etaxonomy.cdm.model.term.TermNode;
import eu.etaxonomy.cdm.model.term.TermVocabulary;
import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
/**
* @author pplitzner
*/
public class FeatureStateWizardPage extends AbstractEntityCollectionElementWizardPage {
+ private TermComboElement<Feature> comboFeature;
private TermComboElement<State> comboState;
- private EntitySelectionElement<Feature> selectFeature;
private String comboLabel;
+ private TermNode<? extends Feature> termNode;
- protected FeatureStateWizardPage(String pageName, String comboLabel, CdmFormFactory formFactory) {
+ protected FeatureStateWizardPage(String pageName, String comboLabel, TermNode<? extends Feature> termNode, CdmFormFactory formFactory) {
super(pageName, formFactory);
this.comboLabel = comboLabel;
+ this.termNode = termNode;
setTitle("Create Feature State");
setDescription("Select Feature and State");
}
public void createControl(Composite parent) {
super.createControl(parent);
- selectFeature = formFactory.createSelectionElement(Feature.class, rootElement, "Feature", null, EntitySelectionElement.SELECTABLE, SWT.NONE);
+ comboFeature = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, rootElement, "Parent Feature", null, SWT.NONE);
+ updateFeatureCombo();
+
comboState = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, rootElement, comboLabel, null, SWT.NONE);
comboState.setEnabled(false);
}
FeatureState getFeatureState(){
- return FeatureState.NewInstance(selectFeature.getSelection(), comboState.getSelection());
+ return FeatureState.NewInstance(comboFeature.getSelection(), comboState.getSelection());
+ }
+
+ private void updateFeatureCombo(){
+ List<Feature> features = new ArrayList<>();
+ TermNode<? extends Feature> parent = termNode.getParent();
+ while(parent!=null){
+ features.add(parent.getTerm());
+ parent = parent.getParent();
+ }
+ comboFeature.setTerms(features);
}
- private void updateCombo(Feature feature){
+ private void updateStateCombo(Feature feature){
comboState.setEnabled(true);
- List<State> stateTerms = new ArrayList<State>();
+ List<State> stateTerms = new ArrayList<>();
Set<TermVocabulary<State>> stateVocabularies = feature.getSupportedCategoricalEnumerations();
for (TermVocabulary<State> termVocabulary : stateVocabularies) {
stateTerms.addAll(termVocabulary.getTerms());
@Override
public boolean isPageComplete() {
- return selectFeature.getSelection()!=null && comboState.getSelection()!=null;
+ return comboFeature.getSelection()!=null && comboState.getSelection()!=null;
}
@Override
public void propertyChange(PropertyChangeEvent event) {
- if(event.getSource()==selectFeature){
- Feature feature = selectFeature.getSelection();
- updateCombo(feature);
+ if(event.getSource()==comboFeature){
+ Feature feature = comboFeature.getSelection();
+ updateStateCombo(feature);
}
getWizard().getContainer().updateButtons();
}
import org.eclipse.jface.wizard.WizardDialog;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureState;
import eu.etaxonomy.cdm.model.term.TermNode;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
* @date 06.03.2018
*
*/
-public class InapplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode, FeatureState>{
+public class InapplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode<? extends Feature>, FeatureState>{
public InapplicableIfEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation,
ICdmFormElement parentElement, int style) {
* {@inheritDoc}
*/
@Override
- public Collection<FeatureState> getCollection(TermNode entity) {
+ public Collection<FeatureState> getCollection(TermNode <? extends Feature>entity) {
return entity.getInapplicableIf();
}
*/
@Override
public FeatureState createNewElement() {
- FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Inapplicable If");
+ FeatureStateWizard wizard = new FeatureStateWizard("Inapplicable If", getEntity(), formFactory);
WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
int status = dialog.open();
if(status == IStatus.OK) {
import org.eclipse.jface.wizard.WizardDialog;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureState;
import eu.etaxonomy.cdm.model.term.TermNode;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
* @date 06.03.2018
*
*/
-public class OnlyApplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode, FeatureState>{
+public class OnlyApplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode<? extends Feature>, FeatureState>{
public OnlyApplicableIfEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation,
ICdmFormElement parentElement, int style) {
* {@inheritDoc}
*/
@Override
- public Collection<FeatureState> getCollection(TermNode entity) {
+ public Collection<FeatureState> getCollection(TermNode<? extends Feature> entity) {
return entity.getOnlyApplicableIf();
}
*/
@Override
public FeatureState createNewElement() {
- FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Only applicable if");
+ FeatureStateWizard wizard = new FeatureStateWizard("Only applicable if", getEntity(), formFactory);
WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
int status = dialog.open();
if(status == IStatus.OK) {