ref #7998 Add termType to vocabulary selection dialog
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / selection / TermVocabularySelectionDialog.java
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.UUID;
13
14 import org.eclipse.swt.widgets.Shell;
15
16 import eu.etaxonomy.cdm.api.service.IVocabularyService;
17 import eu.etaxonomy.cdm.model.common.TermType;
18 import eu.etaxonomy.cdm.model.common.TermVocabulary;
19 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
20 import eu.etaxonomy.taxeditor.newWizard.NewFeatureVocabularyWizard;
21 import eu.etaxonomy.taxeditor.store.CdmStore;
22
23 /**
24 *
25 * @author pplitzner
26 * @since Jun 1, 2018
27 *
28 */
29 public class TermVocabularySelectionDialog extends
30 AbstractFilteredCdmResourceSelectionDialog<TermVocabulary> {
31
32 private TermType termType;
33
34 public static TermVocabulary select(String dialogTitle, Shell shell, TermVocabulary voc, TermType termType){
35 return select_internal(dialogTitle, shell, voc, termType);
36 }
37
38 public static TermVocabulary select(String dialogTitle, Shell shell, TermVocabulary voc){
39 return select_internal(dialogTitle, shell, voc, null);
40 }
41
42 public static TermVocabulary select(Shell shell, TermVocabulary voc){
43 return select_internal("Choose Vocabulary", shell, voc, null);
44 }
45
46 private static TermVocabulary select_internal(String dialogTitle, Shell shell, TermVocabulary voc,
47 TermType termType){
48 TermVocabularySelectionDialog dialog = new TermVocabularySelectionDialog(shell,
49 dialogTitle!=null?dialogTitle:"Choose Vocabulary",
50 false,
51 TermVocabularySelectionDialog.class.getCanonicalName(),
52 voc, termType);
53 return getSelectionFromDialog(dialog);
54 }
55
56 protected TermVocabularySelectionDialog(Shell shell,
57 String title, boolean multi,
58 String settings, TermVocabulary cdmObject, TermType termType) {
59 super(shell, title, multi, settings, cdmObject);
60 this.termType = termType;
61 }
62
63 @Override
64 protected TermVocabulary getPersistentObject(UUID uuid) {
65 return CdmStore.getService(IVocabularyService.class).load(uuid);
66 }
67
68 @Override
69 protected void callService(String pattern) {
70 model = CdmStore.getService(IVocabularyService.class).getUuidAndTitleCache(TermVocabulary.class, termType, limitOfInitialElements, pattern);
71 }
72
73 @Override
74 protected String[] getNewWizardText() {
75 return new String[]{ "New Vocabulary"};
76 }
77
78 @Override
79 protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
80 return new NewFeatureVocabularyWizard();
81 }
82
83 }