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 |
|
}
|
|
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 |
/**
|
|
39 |
* <p>select</p>
|
|
40 |
*
|
|
41 |
* @param shell a {@link org.eclipse.swt.widgets.Shell} object.
|
|
42 |
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
|
43 |
* @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
|
|
44 |
*/
|
|
45 |
public static TaxonBase selectTaxonBase(Shell shell, ConversationHolder conversation) {
|
|
46 |
AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(TaxonBase.class, shell, conversation,
|
|
47 |
"Choose a taxon", false, null, null);
|
|
48 |
return getSelectionFromDialog(dialog);
|
|
49 |
}
|
|
50 |
|
|
51 |
/**
|
|
52 |
* <p>select</p>
|
|
53 |
*
|
|
54 |
* @param shell a {@link org.eclipse.swt.widgets.Shell} object.
|
|
55 |
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
|
56 |
* @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
|
|
57 |
*/
|
|
58 |
public static Taxon selectTaxon(Shell shell, ConversationHolder conversation, Taxon taxonToBeFiltered) {
|
|
59 |
|
|
60 |
|
|
61 |
AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(Taxon.class, shell, conversation,
|
|
62 |
"Choose a taxon", false, null, taxonToBeFiltered);
|
|
63 |
return (Taxon) getSelectionFromDialog(dialog);
|
|
64 |
}
|
|
65 |
|
|
66 |
/**
|
|
67 |
* <p>select</p>
|
|
68 |
*
|
|
69 |
* @param shell a {@link org.eclipse.swt.widgets.Shell} object.
|
|
70 |
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
|
71 |
* @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
|
|
72 |
*/
|
|
73 |
public static Synonym selectSynonym(Shell shell, ConversationHolder conversation) {
|
|
74 |
AbstractFilteredCdmResourceSelectionDialog<TaxonBase> dialog = new TaxonBaseSelectionDialog(Synonym.class, shell, conversation,
|
|
75 |
"Choose a taxon", false, null, null);
|
|
76 |
return (Synonym) getSelectionFromDialog(dialog);
|
|
77 |
}
|
|
78 |
|
|
79 |
private final Class<? extends TaxonBase> clazz;
|
|
80 |
|
|
81 |
/**
|
|
82 |
* <p>Constructor for FilteredTaxonBaseSelectionDialog.</p>
|
|
83 |
*
|
|
84 |
* @param shell a {@link org.eclipse.swt.widgets.Shell} object.
|
|
85 |
* @param title a {@link java.lang.String} object.
|
|
86 |
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
|
87 |
* @param multi a boolean.
|
|
88 |
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
|
|
89 |
*/
|
|
90 |
protected TaxonBaseSelectionDialog(Class<? extends TaxonBase> clazz, Shell shell, ConversationHolder conversation, String title, boolean multi, TaxonBase taxon, TaxonBase taxonToBeFiltered) {
|
|
91 |
super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), taxon);
|
|
92 |
this.cdmBaseToBeFiltered = taxonToBeFiltered;
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
this.clazz = clazz;
|
|
97 |
}
|
|
98 |
|
|
99 |
/* (non-Javadoc)
|
|
100 |
* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
|
|
101 |
*/
|
|
102 |
/** {@inheritDoc} */
|
|
103 |
@Override
|
|
104 |
protected Control createExtendedContentArea(Composite parent) {
|
|
105 |
return null;
|
|
106 |
}
|
|
107 |
|
|
108 |
/* (non-Javadoc)
|
|
109 |
* @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
|
|
110 |
*/
|
|
111 |
/** {@inheritDoc} */
|
|
112 |
@Override
|
|
113 |
protected TaxonBase getPersistentObject(UUID uuid) {
|
|
114 |
return CdmStore.getService(ITaxonService.class).load(uuid);
|
|
115 |
}
|
|
116 |
|
|
117 |
/* (non-Javadoc)
|
|
118 |
* @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
|
|
119 |
*/
|
|
120 |
/** {@inheritDoc} */
|
|
121 |
@Override
|
|
122 |
protected void initModel() {
|
|
123 |
if(clazz == TaxonBase.class){
|
|
124 |
model = CdmStore.getService(ITaxonService.class).getUuidAndTitleCache();
|
|
125 |
}
|
|
126 |
else if(clazz == Taxon.class){
|
|
127 |
|
|
128 |
model = CdmStore.getService(ITaxonService.class).getUuidAndTitleCacheTaxon();
|
|
129 |
|
|
130 |
}
|
|
131 |
else if(clazz == Synonym.class){
|
|
132 |
model = CdmStore.getService(ITaxonService.class).getUuidAndTitleCacheSynonym();
|
|
133 |
}
|
|
134 |
}
|
|
135 |
|
|
136 |
/** {@inheritDoc} */
|
|
137 |
@Override
|
|
138 |
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
|
139 |
return null;
|
|
140 |
}
|
|
141 |
|
|
142 |
/** {@inheritDoc} */
|
|
143 |
@Override
|
|
144 |
protected String getNewWizardLinkText() {
|
|
145 |
return null;
|
|
146 |
}
|
|
147 |
}
|
Fixes #2681