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
.ArrayList
;
13 import java
.util
.List
;
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
.TermVocabulary
;
20 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
21 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.NewVocabularyWizard
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 public class TermVocabularySelectionDialog
extends
32 AbstractFilteredCdmResourceSelectionDialog
<TermVocabulary
> {
34 public static TermVocabulary
select(String dialogTitle
, Shell shell
, TermVocabulary voc
){
35 return select_internal(dialogTitle
, shell
, voc
);
38 public static TermVocabulary
select(Shell shell
, TermVocabulary voc
){
39 return select_internal("Choose Vocabulary", shell
, voc
);
42 private static TermVocabulary
select_internal(String dialogTitle
, Shell shell
, TermVocabulary voc
){
43 TermVocabularySelectionDialog dialog
= new TermVocabularySelectionDialog(shell
,
44 dialogTitle
!=null?dialogTitle
:"Choose Vocabulary",
46 TermVocabularySelectionDialog
.class.getCanonicalName(),
48 return getSelectionFromDialog(dialog
);
51 protected TermVocabularySelectionDialog(Shell shell
,
52 String title
, boolean multi
,
53 String settings
, TermVocabulary cdmObject
) {
54 super(shell
, title
, multi
, settings
, cdmObject
);
58 protected TermVocabulary
getPersistentObject(UUID uuid
) {
59 return CdmStore
.getService(IVocabularyService
.class).load(uuid
);
63 protected void callService(String pattern
) {
64 List
<TermVocabulary
> vocabularies
= CdmStore
.getService(IVocabularyService
.class).list(TermVocabulary
.class, null, null, null, null);
66 List
<UuidAndTitleCache
<TermVocabulary
>> featureUuidAndTitleCache
= new ArrayList
<>();
68 for(TermVocabulary voc
: vocabularies
){
69 UuidAndTitleCache
<TermVocabulary
> uuidAndTitleCache
= new UuidAndTitleCache
<>(TermVocabulary
.class, voc
.getUuid(), voc
.getId(), voc
.getTitleCache());
70 if (pattern
== null || uuidAndTitleCache
.getTitleCache().matches("(?i)"+pattern
+ ".*")) {
71 featureUuidAndTitleCache
.add(uuidAndTitleCache
);
74 model
= featureUuidAndTitleCache
;
78 protected String
[] getNewWizardText() {
79 return new String
[]{ "New Vocabulary"};
83 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
84 return new NewVocabularyWizard();