2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
;
12 import java
.util
.Collections
;
14 import java
.util
.UUID
;
16 import org
.eclipse
.swt
.widgets
.Shell
;
18 import eu
.etaxonomy
.cdm
.api
.service
.IVocabularyService
;
19 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
20 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
21 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.NewFeatureVocabularyWizard
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 public class TermVocabularySelectionDialog
extends
32 AbstractFilteredCdmResourceSelectionDialog
<TermVocabulary
> {
34 private TermType termType
;
36 public static TermVocabulary
select(String dialogTitle
, Shell shell
, Set
<TermVocabulary
> vocabulariesToBeFiltered
,
38 return select_internal(dialogTitle
, shell
, vocabulariesToBeFiltered
, termType
);
41 public static TermVocabulary
select(String dialogTitle
, Shell shell
, TermVocabulary voc
){
42 return select_internal(dialogTitle
, shell
, voc
!=null?Collections
.singleton(voc
):null, null);
45 public static TermVocabulary
select(Shell shell
, TermVocabulary voc
){
46 return select_internal("Choose Vocabulary", shell
, voc
!=null?Collections
.singleton(voc
):null, null);
49 private static TermVocabulary
select_internal(String dialogTitle
, Shell shell
, Set
<TermVocabulary
> vocabulariesToBeFiltered
,
51 TermVocabularySelectionDialog dialog
= new TermVocabularySelectionDialog(shell
,
52 dialogTitle
!=null?dialogTitle
:"Choose Vocabulary",
54 TermVocabularySelectionDialog
.class.getCanonicalName(),
55 vocabulariesToBeFiltered
, termType
);
56 return getSelectionFromDialog(dialog
);
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
;
67 protected TermVocabulary
getPersistentObject(UUID uuid
) {
68 return CdmStore
.getService(IVocabularyService
.class).load(uuid
);
72 protected void callService(String pattern
) {
73 model
= CdmStore
.getService(IVocabularyService
.class).getUuidAndTitleCache(TermVocabulary
.class, termType
, limitOfInitialElements
, pattern
);
77 protected String
[] getNewWizardText() {
78 return new String
[]{ "New Vocabulary"};
82 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
83 return new NewFeatureVocabularyWizard();