refactoring of package names for consistency
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / selection / TaxonBaseSelectionDialog.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.dialog.selection;
12
13 import java.util.UUID;
14
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17 import org.eclipse.swt.widgets.Shell;
18
19 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
20 import eu.etaxonomy.cdm.api.service.ITaxonService;
21 import eu.etaxonomy.cdm.model.taxon.Synonym;
22 import eu.etaxonomy.cdm.model.taxon.Taxon;
23 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
24 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
25 import eu.etaxonomy.taxeditor.store.CdmStore;
26
27 /**
28 * <p>FilteredTaxonBaseSelectionDialog class.</p>
29 *
30 * @author n.hoffmann
31 * @created Sep 21, 2009
32 * @version 1.0
33 */
34 public class TaxonBaseSelectionDialog extends
35 AbstractFilteredCdmResourceSelectionDialog<TaxonBase> {
36
37 /**
38 * <p>select</p>
39 *
40 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
41 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
42 * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
43 */
44 public static TaxonBase selectTaxonBase(Shell shell, ConversationHolder conversation) {
45 TaxonBaseSelectionDialog dialog = new TaxonBaseSelectionDialog(TaxonBase.class, shell, conversation,
46 "Choose a taxon", false, null);
47 return getSelectionFromDialog(dialog);
48 }
49
50 /**
51 * <p>select</p>
52 *
53 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
54 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
55 * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
56 */
57 public static Taxon selectTaxon(Shell shell, ConversationHolder conversation) {
58 TaxonBaseSelectionDialog dialog = new TaxonBaseSelectionDialog(Taxon.class, shell, conversation,
59 "Choose a taxon", false, null);
60 return (Taxon) getSelectionFromDialog(dialog);
61 }
62
63 /**
64 * <p>select</p>
65 *
66 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
67 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
68 * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
69 */
70 public static Synonym selectSynonym(Shell shell, ConversationHolder conversation) {
71 TaxonBaseSelectionDialog dialog = new TaxonBaseSelectionDialog(Synonym.class, shell, conversation,
72 "Choose a taxon", false, null);
73 return (Synonym) getSelectionFromDialog(dialog);
74 }
75
76 private final Class<? extends TaxonBase> clazz;
77
78 /**
79 * <p>Constructor for FilteredTaxonBaseSelectionDialog.</p>
80 *
81 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
82 * @param title a {@link java.lang.String} object.
83 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
84 * @param multi a boolean.
85 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
86 */
87 protected TaxonBaseSelectionDialog(Class<? extends TaxonBase> clazz, Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonBase taxon) {
88 super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), taxon);
89 this.clazz = clazz;
90 }
91
92 /* (non-Javadoc)
93 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
94 */
95 /** {@inheritDoc} */
96 @Override
97 protected Control createExtendedContentArea(Composite parent) {
98 return null;
99 }
100
101 /* (non-Javadoc)
102 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
103 */
104 /** {@inheritDoc} */
105 @Override
106 protected TaxonBase getPersistentObject(UUID uuid) {
107 return CdmStore.getService(ITaxonService.class).load(uuid);
108 }
109
110 /* (non-Javadoc)
111 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
112 */
113 /** {@inheritDoc} */
114 @Override
115 protected void initModel() {
116 if(clazz == TaxonBase.class){
117 model = CdmStore.getService(ITaxonService.class).getUuidAndTitleCache();
118 }
119 else if(clazz == Taxon.class){
120 model = CdmStore.getService(ITaxonService.class).getUuidAndTitleCacheTaxon();
121 }
122 else if(clazz == Synonym.class){
123 model = CdmStore.getService(ITaxonService.class).getUuidAndTitleCacheSynonym();
124 }
125 }
126
127 /** {@inheritDoc} */
128 @Override
129 protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
130 return null;
131 }
132
133 /** {@inheritDoc} */
134 @Override
135 protected String getNewWizardLinkText() {
136 return null;
137 }
138 }