Project

General

Profile

Download (2.9 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.ui.dialog.selection;
11

    
12
import java.util.Collections;
13
import java.util.Set;
14
import java.util.UUID;
15

    
16
import org.eclipse.swt.widgets.Shell;
17

    
18
import eu.etaxonomy.cdm.api.service.IVocabularyService;
19
import eu.etaxonomy.cdm.model.term.TermType;
20
import eu.etaxonomy.cdm.model.term.TermVocabulary;
21
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
22
import eu.etaxonomy.taxeditor.newWizard.NewFeatureVocabularyWizard;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25
/**
26
 *
27
 * @author pplitzner
28
 * @since Jun 1, 2018
29
 *
30
 */
31
public class TermVocabularySelectionDialog extends
32
		AbstractFilteredCdmResourceSelectionDialog<TermVocabulary> {
33

    
34
    private TermType termType;
35

    
36
    public static TermVocabulary select(String dialogTitle, Shell shell, Set<TermVocabulary> vocabulariesToBeFiltered,
37
            TermType termType){
38
        return select_internal(dialogTitle, shell, vocabulariesToBeFiltered, termType);
39
    }
40

    
41
    public static TermVocabulary select(String dialogTitle, Shell shell, TermVocabulary voc){
42
        return select_internal(dialogTitle, shell, voc!=null?Collections.singleton(voc):null, null);
43
    }
44

    
45
    public static TermVocabulary select(Shell shell, TermVocabulary voc){
46
        return select_internal("Choose Vocabulary", shell, voc!=null?Collections.singleton(voc):null, null);
47
    }
48

    
49
    private static TermVocabulary select_internal(String dialogTitle, Shell shell, Set<TermVocabulary> vocabulariesToBeFiltered,
50
            TermType termType){
51
		TermVocabularySelectionDialog dialog = new TermVocabularySelectionDialog(shell,
52
				dialogTitle!=null?dialogTitle:"Choose Vocabulary",
53
				false,
54
				TermVocabularySelectionDialog.class.getCanonicalName(),
55
				vocabulariesToBeFiltered, termType);
56
		return getSelectionFromDialog(dialog);
57
	}
58

    
59
    protected TermVocabularySelectionDialog(Shell shell,
60
            String title, boolean multi,
61
            String settings, Set<TermVocabulary> vocabulariesToBeFiltered, TermType termType) {
62
        super(shell, title, multi, settings, vocabulariesToBeFiltered);
63
        this.termType = termType;
64
    }
65

    
66
	@Override
67
	protected TermVocabulary getPersistentObject(UUID uuid) {
68
		return CdmStore.getService(IVocabularyService.class).load(uuid);
69
	}
70

    
71
	@Override
72
	protected void callService(String pattern) {
73
        model = CdmStore.getService(IVocabularyService.class).getUuidAndTitleCache(TermVocabulary.class, termType, limitOfInitialElements, pattern);
74
	}
75

    
76
	@Override
77
	protected String[] getNewWizardText() {
78
        return new String[]{ "New Vocabulary"};
79
	}
80

    
81
	@Override
82
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
83
        return new NewFeatureVocabularyWizard(termType);
84
	}
85

    
86
}
(45-45/46)