1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.dialog.selection;
|
12
|
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.eclipse.swt.widgets.Control;
|
16
|
import org.eclipse.swt.widgets.Shell;
|
17
|
import org.eclipse.swt.widgets.Text;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
20
|
import eu.etaxonomy.cdm.api.service.INameService;
|
21
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
22
|
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
|
23
|
import eu.etaxonomy.taxeditor.newWizard.NewNonViralNameWizard;
|
24
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
25
|
|
26
|
/**
|
27
|
* @author n.hoffmann
|
28
|
* @created 04.06.2009
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class NameSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonNameBase> {
|
32
|
|
33
|
public static TaxonNameBase select(Shell shell, ConversationHolder conversation, TaxonNameBase name) {
|
34
|
NameSelectionDialog dialog = new NameSelectionDialog(shell, conversation,
|
35
|
"Choose a name", false, name);
|
36
|
return getSelectionFromDialog(dialog);
|
37
|
}
|
38
|
|
39
|
protected NameSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonNameBase name) {
|
40
|
super(shell, conversation, title, multi, NameSelectionDialog.class.getCanonicalName(), name);
|
41
|
}
|
42
|
|
43
|
/** {@inheritDoc} */
|
44
|
@Override
|
45
|
protected TaxonNameBase getPersistentObject(UUID cdmUuid) {
|
46
|
return CdmStore.getService(INameService.class).load(cdmUuid);
|
47
|
}
|
48
|
|
49
|
/** {@inheritDoc} */
|
50
|
@Override
|
51
|
protected void initModel() {
|
52
|
Control control = getPatternControl();
|
53
|
String pattern = null;
|
54
|
if (control != null){
|
55
|
pattern = ((Text)control).getText();
|
56
|
}
|
57
|
|
58
|
|
59
|
model = CdmStore.getService(INameService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
|
60
|
}
|
61
|
|
62
|
/** {@inheritDoc} */
|
63
|
@Override
|
64
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
65
|
return new NewNonViralNameWizard();
|
66
|
}
|
67
|
|
68
|
/** {@inheritDoc} */
|
69
|
@Override
|
70
|
protected String getNewWizardLinkText() {
|
71
|
return String.format("Create a new <a>%1s</a>", "Name ");
|
72
|
}
|
73
|
}
|