Project

General

Profile

Download (2.27 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.service.INameService;
19
import eu.etaxonomy.cdm.model.name.TaxonName;
20
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
21
import eu.etaxonomy.taxeditor.newWizard.NewNonViralNameWizard;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

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

    
30
	public static TaxonName select(Shell shell, //ConversationHolder conversation,
31
	        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,
38
	        String title, boolean multi, TaxonName name) {
39
		super(shell, //conversation,
40
		        title, multi, NameSelectionDialog.class.getCanonicalName(), name);
41
	}
42

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

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

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

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

    
71
	/** {@inheritDoc} */
72
	@Override
73
	protected String[] getNewWizardText() {
74
		return new String[]{"Name "};
75
	}
76
}
(19-19/39)