including changes from cdmlib-print
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / forms / selection / NamedAreaSelectionElement.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.forms.selection;
12
13 import org.apache.log4j.Logger;
14 import org.eclipse.swt.events.SelectionEvent;
15
16 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
17 import eu.etaxonomy.cdm.model.location.NamedArea;
18 import eu.etaxonomy.taxeditor.dialogs.filteredSelection.NamedAreaSelectionDialog;
19 import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
20 import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
21 import eu.etaxonomy.taxeditor.store.CdmStore;
22
23 /**
24 * <p>NamedAreaSelectionElement class.</p>
25 *
26 * @author n.hoffmann
27 * @created May 11, 2010
28 * @version 1.0
29 */
30 public class NamedAreaSelectionElement extends AbstractSelectionElement<NamedArea> {
31
32
33
34 private static final Logger logger = Logger
35 .getLogger(NamedAreaSelectionElement.class);
36
37 /**
38 * <p>Constructor for NamedAreaSelectionElement.</p>
39 *
40 * @param formFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
41 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
42 * @param parentElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
43 * @param labelString a {@link java.lang.String} object.
44 * @param entity a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
45 * @param style a int.
46 */
47 public NamedAreaSelectionElement(CdmFormFactory formFactory, ConversationHolder conversation,
48 ICdmFormElement parentElement, String labelString,
49 NamedArea entity, int style) {
50 super(formFactory, conversation, parentElement, labelString, entity,
51 false, false, true, style);
52 }
53
54 /** {@inheritDoc} */
55 public void widgetSelected(SelectionEvent e) {
56 NamedArea newSelection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), entity);
57 setSelectionInternal(newSelection);
58 }
59
60 /** {@inheritDoc} */
61 @Override
62 protected String getTitle() {
63 return (entity != null) ? NamedArea.labelWithLevel(entity, CdmStore.getDefaultLanguage()) : "";
64 }
65 }