63e0f03cbe71b1c61b2b22d858e1aaa3bc6d5d5d
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / selection / TaxonNodeSelectionElement.java
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.selection;
12
13 import org.eclipse.swt.events.SelectionEvent;
14
15 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16 import eu.etaxonomy.cdm.common.CdmUtils;
17 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
18 import eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.TaxonNodeSelectionDialog;
19 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
20 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
21
22 /**
23 * <p>
24 * TaxonNodeSelectionElement class.
25 * </p>
26 *
27 * @author n.hoffmann
28 * @created Sep 27, 2010
29 * @version 1.0
30 */
31 public class TaxonNodeSelectionElement extends
32 AbstractSelectionElement<TaxonNode> {
33
34 public static final int DEFAULT = DELETABLE;
35
36 /**
37 * <p>
38 * Constructor for TaxonNodeSelectionElement.
39 * </p>
40 *
41 * @param formFactory
42 * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
43 * object.
44 * @param conversation
45 * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
46 * object.
47 * @param parentElement
48 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
49 * object.
50 * @param labelString
51 * a {@link java.lang.String} object.
52 * @param entity
53 * a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
54 * @param style
55 * a int.
56 */
57 public TaxonNodeSelectionElement(CdmFormFactory formFactory,
58 ConversationHolder conversation, ICdmFormElement parentElement,
59 String labelString, TaxonNode entity, int mode, int style) {
60 super(formFactory, conversation, parentElement, labelString, entity,
61 mode, style);
62 }
63
64 /*
65 * (non-Javadoc)
66 *
67 * @see
68 * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt
69 * .events.SelectionEvent)
70 */
71 /** {@inheritDoc} */
72 @Override
73 public void widgetSelected(SelectionEvent e) {
74 TaxonNode newSelection = TaxonNodeSelectionDialog.select(getShell(),
75 getConversationHolder(), "Select parent taxon", null, null);
76 setSelectionInternal(newSelection);
77 }
78
79 /*
80 * (non-Javadoc)
81 *
82 * @see
83 * eu.etaxonomy.taxeditor.forms.selection.AbstractSelectionElement#getTitle
84 * ()
85 */
86 /** {@inheritDoc} */
87 @Override
88 protected String getTitle() {
89 if (getEntity() != null && getEntity().getTaxon() != null) {
90 return CdmUtils.Nz(getEntity().getTaxon().getTitleCache());
91 }
92 return super.getTitle();
93 }
94 }