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
.UUID
;
14 import org
.eclipse
.swt
.widgets
.Control
;
15 import org
.eclipse
.swt
.widgets
.Shell
;
16 import org
.eclipse
.swt
.widgets
.Text
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
19 import eu
.etaxonomy
.cdm
.api
.service
.INameService
;
20 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
21 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.NewNonViralNameWizard
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 public class NameSelectionDialog
extends AbstractFilteredCdmResourceSelectionDialog
<TaxonNameBase
> {
32 public static TaxonNameBase
select(Shell shell
, ConversationHolder conversation
, TaxonNameBase name
) {
33 NameSelectionDialog dialog
= new NameSelectionDialog(shell
, conversation
,
34 "Choose a name", false, name
);
35 return getSelectionFromDialog(dialog
);
38 protected NameSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
, boolean multi
, TaxonNameBase name
) {
39 super(shell
, conversation
, title
, multi
, NameSelectionDialog
.class.getCanonicalName(), name
);
44 protected TaxonNameBase
getPersistentObject(UUID cdmUuid
) {
45 return CdmStore
.getService(INameService
.class).load(cdmUuid
);
50 protected void initModel() {
51 Control control
= getPatternControl();
52 String pattern
= null;
54 pattern
= ((Text
)control
).getText();
57 if (pattern
== null || pattern
.equals("?")){
58 model
= CdmStore
.getService(INameService
.class).getUuidAndTitleCache(null, null);
60 model
= CdmStore
.getService(INameService
.class).getUuidAndTitleCache(limitOfInitialElements
, pattern
);
66 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
67 return new NewNonViralNameWizard();
72 protected String
getNewWizardLinkText() {
73 return String
.format("Create a new <a>%1s</a>", "Name ");