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
.store
.CdmStore
;
30 public class TermVocabularySelectionDialog
extends
31 AbstractFilteredCdmResourceSelectionDialog
<TermVocabulary
> {
33 public static TermVocabulary
select(String dialogTitle
, Shell shell
, TermVocabulary voc
){
34 return select_internal(dialogTitle
, shell
, voc
);
37 public static TermVocabulary
select(Shell shell
, TermVocabulary voc
){
38 return select_internal("Choose Vocabulary", shell
, voc
);
41 private static TermVocabulary
select_internal(String dialogTitle
, Shell shell
, TermVocabulary voc
){
42 TermVocabularySelectionDialog dialog
= new TermVocabularySelectionDialog(shell
,
43 dialogTitle
!=null?dialogTitle
:"Choose Vocabulary",
45 TermVocabularySelectionDialog
.class.getCanonicalName(),
47 return getSelectionFromDialog(dialog
);
50 protected TermVocabularySelectionDialog(Shell shell
,
51 String title
, boolean multi
,
52 String settings
, TermVocabulary cdmObject
) {
53 super(shell
, title
, multi
, settings
, cdmObject
);
57 protected TermVocabulary
getPersistentObject(UUID uuid
) {
58 return CdmStore
.getService(IVocabularyService
.class).load(uuid
);
62 protected void callService(String pattern
) {
63 List
<TermVocabulary
> vocabularies
= CdmStore
.getService(IVocabularyService
.class).list(TermVocabulary
.class, null, null, null, null);
65 List
<UuidAndTitleCache
<TermVocabulary
>> featureUuidAndTitleCache
= new ArrayList
<>();
67 for(TermVocabulary voc
: vocabularies
){
68 UuidAndTitleCache
<TermVocabulary
> uuidAndTitleCache
= new UuidAndTitleCache
<>(TermVocabulary
.class, voc
.getUuid(), voc
.getId(), voc
.getTitleCache());
69 if (pattern
== null || uuidAndTitleCache
.getTitleCache().matches("(?i)"+pattern
+ ".*")) {
70 featureUuidAndTitleCache
.add(uuidAndTitleCache
);
73 model
= featureUuidAndTitleCache
;
77 protected String
[] getNewWizardText() {
82 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {