Merge branch 'hotfix/5.45.1'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / selection / NameSelectionDialog.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 package eu.etaxonomy.taxeditor.ui.dialog.selection;
10
11 import java.util.UUID;
12
13 import org.eclipse.swt.widgets.Shell;
14
15 import eu.etaxonomy.cdm.api.service.INameService;
16 import eu.etaxonomy.cdm.model.name.TaxonName;
17 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
18 import eu.etaxonomy.taxeditor.newWizard.NewNonViralNameWizard;
19 import eu.etaxonomy.taxeditor.store.CdmStore;
20
21 /**
22 * @author n.hoffmann
23 * @created 04.06.2009
24 */
25 public class NameSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonName> {
26
27 public static TaxonName select(Shell shell,
28 TaxonName name) {
29 NameSelectionDialog dialog = new NameSelectionDialog(shell,
30 "Choose a name", false, name);
31 return getSelectionFromDialog(dialog);
32 }
33
34 protected NameSelectionDialog(Shell shell,
35 String title, boolean multi, TaxonName name) {
36 super(shell,
37 title, multi, NameSelectionDialog.class.getCanonicalName(), name);
38 }
39
40 @Override
41 protected TaxonName getPersistentObject(UUID cdmUuid) {
42 return CdmStore.getService(INameService.class).load(cdmUuid);
43 }
44
45 @Override
46 protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
47 return new NewNonViralNameWizard();
48 }
49
50 @Override
51 protected String[] getNewWizardText() {
52 return new String[]{"New Name"};
53 }
54
55 @Override
56 protected void callService(String pattern) {
57 model = CdmStore.getService(INameService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
58 }
59 }