Project

General

Profile

Download (2.32 KB) Statistics
| Branch: | Tag: | Revision:
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

    
10
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11

    
12
import java.util.UUID;
13

    
14
import org.eclipse.swt.widgets.Control;
15
import org.eclipse.swt.widgets.Shell;
16
import org.eclipse.swt.widgets.Text;
17

    
18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19
import eu.etaxonomy.cdm.api.service.INameService;
20
import eu.etaxonomy.cdm.model.name.TaxonName;
21
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
22
import eu.etaxonomy.taxeditor.newWizard.NewNonViralNameWizard;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25
/**
26
 * @author n.hoffmann
27
 * @created 04.06.2009
28
 */
29
public class NameSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonName> {
30

    
31
	public static TaxonName select(Shell shell, ConversationHolder conversation, TaxonName name) {
32
		NameSelectionDialog dialog = new NameSelectionDialog(shell, conversation,
33
				"Choose a name", false, name);
34
		return getSelectionFromDialog(dialog);
35
	}
36

    
37
	protected NameSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonName name) {
38
		super(shell, conversation, title, multi, NameSelectionDialog.class.getCanonicalName(), name);
39
	}
40

    
41
	/** {@inheritDoc} */
42
	@Override
43
	protected TaxonName getPersistentObject(UUID cdmUuid) {
44
		return CdmStore.getService(INameService.class).load(cdmUuid);
45
	}
46

    
47
	/** {@inheritDoc} */
48
	@Override
49
	protected void search() {
50
	    Control control =getSearchField();
51
        String pattern = null;
52
        if (control != null){
53
            pattern = ((Text)control).getText();
54
        }
55

    
56
        if (pattern == null || pattern.equals("?")){
57
            model = CdmStore.getService(INameService.class).getUuidAndTitleCache(null, null);
58
        }else{
59
            model = CdmStore.getService(INameService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
60
        }
61
	}
62

    
63
	/** {@inheritDoc} */
64
	@Override
65
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
66
		return new NewNonViralNameWizard();
67
	}
68

    
69
	/** {@inheritDoc} */
70
	@Override
71
	protected String getNewWizardLinkText() {
72
		return String.format("Create a new <a>%1s</a>", "Name ");
73
	}
74
}
(18-18/38)