Revision 48a40f35
Added by Patrick Plitzner over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/AvailableFeaturesWizard.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.featuretree; |
11 | 11 |
|
12 |
import java.util.List; |
|
12 | 13 |
import java.util.Set; |
13 | 14 |
|
14 | 15 |
import org.eclipse.jface.wizard.Wizard; |
15 | 16 |
|
17 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
16 | 18 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
17 | 19 |
import eu.etaxonomy.cdm.model.term.TermType; |
20 |
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto; |
|
21 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
22 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
18 | 23 |
|
19 | 24 |
/** |
20 | 25 |
* <p>AvailableFeaturesWizard class.</p> |
... | ... | |
29 | 34 |
|
30 | 35 |
private Set<DefinedTermBase> additionalFeatures; |
31 | 36 |
|
32 |
private TermType termType; |
|
37 |
private List<TermVocabularyDto> vocabularyDtos; |
|
38 |
|
|
39 |
private boolean singleSelection = false; |
|
33 | 40 |
|
34 | 41 |
public AvailableFeaturesWizard(TermType termType){ |
35 |
this.termType = termType; |
|
42 |
vocabularyDtos = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByTermType(termType); |
|
43 |
} |
|
44 |
|
|
45 |
public AvailableFeaturesWizard(List<TermVocabularyDto> vocabularyDtos){ |
|
46 |
this.vocabularyDtos = vocabularyDtos; |
|
36 | 47 |
} |
37 | 48 |
|
38 | 49 |
/** {@inheritDoc} */ |
39 | 50 |
@Override |
40 | 51 |
public void addPages() { |
41 |
page = new AvailableFeaturesWizardPage(termType);
|
|
52 |
page = new AvailableFeaturesWizardPage(vocabularyDtos,singleSelection);
|
|
42 | 53 |
addPage(page); |
43 | 54 |
} |
44 | 55 |
|
56 |
@Override |
|
57 |
public boolean canFinish() { |
|
58 |
int size = page.getSelectedFeatures().size(); |
|
59 |
return singleSelection?size==1:size>0; |
|
60 |
} |
|
61 |
|
|
45 | 62 |
/** {@inheritDoc} */ |
46 | 63 |
@Override |
47 | 64 |
public boolean performFinish() { |
48 | 65 |
additionalFeatures = page.getSelectedFeatures(); |
66 |
if(singleSelection && additionalFeatures.size()>1){ |
|
67 |
MessagingUtils.warningDialog("Too many terms selected", this, "You can only select 1 term"); |
|
68 |
} |
|
49 | 69 |
return additionalFeatures.size() > 0; |
50 | 70 |
} |
51 | 71 |
|
52 | 72 |
public Set<DefinedTermBase> getAdditionalFeatures() { |
53 | 73 |
return additionalFeatures; |
54 | 74 |
} |
75 |
|
|
76 |
public void setSingleSelection(boolean singleSelection) { |
|
77 |
this.singleSelection = singleSelection; |
|
78 |
} |
|
55 | 79 |
} |
Also available in: Unified diff
ref #8475 Use feature selection dialog in feature state wizard