/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
package eu.etaxonomy.taxeditor.featuretree;
+import java.util.List;
import java.util.Set;
import org.eclipse.jface.wizard.Wizard;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.FeatureTree;
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.term.DefinedTermBase;
+import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* <p>AvailableFeaturesWizard class.</p>
* @version 1.0
*/
public class AvailableFeaturesWizard extends Wizard {
-
- private FeatureTree featureTree;
private AvailableFeaturesWizardPage page;
- private Set<Feature> additionalFeatures;
-
- /**
- * <p>Constructor for AvailableFeaturesWizard.</p>
- *
- * @param featureTree a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
- */
- public AvailableFeaturesWizard(FeatureTree featureTree){
- this.featureTree = featureTree;
+ private Set<DefinedTermBase> additionalFeatures;
+
+ private List<TermVocabularyDto> vocabularyDtos;
+
+ private boolean singleSelection = false;
+
+ public AvailableFeaturesWizard(TermType termType){
+ vocabularyDtos = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByTermType(termType);
}
-
+
+ public AvailableFeaturesWizard(List<TermVocabularyDto> vocabularyDtos){
+ this.vocabularyDtos = vocabularyDtos;
+ }
+
/** {@inheritDoc} */
@Override
public void addPages() {
- page = new AvailableFeaturesWizardPage(featureTree);
+ page = new AvailableFeaturesWizardPage(vocabularyDtos,singleSelection);
addPage(page);
}
-
+
+ @Override
+ public boolean canFinish() {
+ int size = page.getSelectedFeatures().size();
+ return singleSelection?size==1:size>0;
+ }
+
/** {@inheritDoc} */
@Override
public boolean performFinish() {
additionalFeatures = page.getSelectedFeatures();
+ if(singleSelection && additionalFeatures.size()>1){
+ MessagingUtils.warningDialog("Too many terms selected", this, "You can only select 1 term");
+ }
return additionalFeatures.size() > 0;
}
- /**
- * <p>Getter for the field <code>additionalFeatures</code>.</p>
- *
- * @return a {@link java.util.Set} object.
- */
- public Set<Feature> getAdditionalFeatures() {
+ public Set<DefinedTermBase> getAdditionalFeatures() {
return additionalFeatures;
}
+
+ public void setSingleSelection(boolean singleSelection) {
+ this.singleSelection = singleSelection;
+ }
}