Project

General

Profile

Download (2.13 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.featuretree;
11

    
12
import java.util.List;
13
import java.util.Set;
14

    
15
import org.eclipse.jface.wizard.Wizard;
16

    
17
import eu.etaxonomy.cdm.api.service.IVocabularyService;
18
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
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;
23

    
24
/**
25
 * <p>AvailableFeaturesWizard class.</p>
26
 *
27
 * @author n.hoffmann
28
 * @created Aug 5, 2010
29
 * @version 1.0
30
 */
31
public class AvailableFeaturesWizard extends Wizard {
32

    
33
	private AvailableFeaturesWizardPage page;
34

    
35
	private Set<DefinedTermBase> additionalFeatures;
36

    
37
    private List<TermVocabularyDto> vocabularyDtos;
38

    
39
    private boolean singleSelection = false;
40

    
41
	public AvailableFeaturesWizard(TermType termType){
42
        vocabularyDtos = CdmStore.getService(IVocabularyService.class).findVocabularyDtoByTermType(termType);
43
	}
44

    
45
	public AvailableFeaturesWizard(List<TermVocabularyDto> vocabularyDtos){
46
	    this.vocabularyDtos = vocabularyDtos;
47
	}
48

    
49
	/** {@inheritDoc} */
50
	@Override
51
	public void addPages() {
52
		page = new AvailableFeaturesWizardPage(vocabularyDtos,singleSelection);
53
		addPage(page);
54
	}
55

    
56
	@Override
57
	public boolean canFinish() {
58
        int size = page.getSelectedFeatures().size();
59
        return singleSelection?size==1:size>0;
60
	}
61

    
62
	/** {@inheritDoc} */
63
	@Override
64
	public boolean performFinish() {
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
		}
69
		return additionalFeatures.size() > 0;
70
	}
71

    
72
	public Set<DefinedTermBase> getAdditionalFeatures() {
73
		return additionalFeatures;
74
	}
75

    
76
    public void setSingleSelection(boolean singleSelection) {
77
        this.singleSelection = singleSelection;
78
    }
79
}
(1-1/9)