Project

General

Profile

Download (2.98 KB) Statistics
| Branch: | Tag: | Revision:
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.Shell;
16

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

    
24
/**
25
 * <p>FilteredNameSelectionDialog class.</p>
26
 *
27
 * @author n.hoffmann
28
 * @created 04.06.2009
29
 * @version 1.0
30
 */
31
public class NameSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonNameBase> {
32

    
33
	/**
34
	 * Creates a filtered selection dialog to select a name.
35
	 *
36
	 * @param shell
37
	 * 				The shell for displaying this widget
38
	 * @param name
39
	 * 				A name that should be selected when the dialog opens
40
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
41
	 * @return a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
42
	 */
43
	public static TaxonNameBase select(Shell shell, ConversationHolder conversation, TaxonNameBase name) {
44
		NameSelectionDialog dialog = new NameSelectionDialog(shell, conversation,
45
				"Choose a name", false, name);
46
		return getSelectionFromDialog(dialog);
47
	}
48

    
49
	/**
50
	 * <p>Constructor for FilteredNameSelectionDialog.</p>
51
	 *
52
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
53
	 * @param title a {@link java.lang.String} object.
54
	 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
55
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
56
	 * @param multi a boolean.
57
	 */
58
	protected NameSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonNameBase name) {
59
		super(shell, conversation, title, multi, NameSelectionDialog.class.getCanonicalName(), name);
60
	}
61

    
62
	/* (non-Javadoc)
63
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
64
	 */
65
	/** {@inheritDoc} */
66
	@Override
67
	protected TaxonNameBase getPersistentObject(UUID cdmUuid) {
68
		return CdmStore.getService(INameService.class).load(cdmUuid);
69
	}
70

    
71
	/* (non-Javadoc)
72
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
73
	 */
74
	/** {@inheritDoc} */
75
	@Override
76
	protected void initModel() {
77
		model = CdmStore.getService(INameService.class).getUuidAndTitleCache();
78
	}
79

    
80
	/** {@inheritDoc} */
81
	@Override
82
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
83
		return new NewNonViralNameWizard();
84
	}
85

    
86
	/** {@inheritDoc} */
87
	@Override
88
	protected String getNewWizardLinkText() {
89
		return String.format("Create a new <a>%1s</a>", "Name ");
90
	}
91
}
(13-13/25)