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.ArrayList;
|
14
|
import java.util.List;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import org.eclipse.swt.widgets.Shell;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
20
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
21
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
22
|
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
|
23
|
import eu.etaxonomy.cdm.model.description.Feature;
|
24
|
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
|
27
|
/**
|
28
|
* @author n.hoffmann
|
29
|
* @created Dec 6, 2010
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class FeatureSelectionDialog extends
|
33
|
AbstractFilteredCdmResourceSelectionDialog<Feature> {
|
34
|
|
35
|
public static Feature select(Shell shell, ConversationHolder conversation, Feature feature){
|
36
|
FeatureSelectionDialog dialog = new FeatureSelectionDialog(shell, conversation,
|
37
|
"Choose Feature", false, FeatureSelectionDialog.class.getCanonicalName(), feature);
|
38
|
return getSelectionFromDialog(dialog);
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* @param shell
|
43
|
* @param conversation
|
44
|
* @param title
|
45
|
* @param multi
|
46
|
* @param settings
|
47
|
* @param cdmObject
|
48
|
*/
|
49
|
protected FeatureSelectionDialog(Shell shell,
|
50
|
ConversationHolder conversation, String title, boolean multi,
|
51
|
String settings, Feature cdmObject) {
|
52
|
super(shell, conversation, title, multi, settings, cdmObject);
|
53
|
}
|
54
|
|
55
|
/* (non-Javadoc)
|
56
|
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
|
57
|
*/
|
58
|
@Override
|
59
|
protected Feature getPersistentObject(UUID uuid) {
|
60
|
|
61
|
DefinedTermBase term = CdmStore.getService(ITermService.class).load(uuid);
|
62
|
|
63
|
if(term instanceof Feature){
|
64
|
return (Feature) term;
|
65
|
}
|
66
|
|
67
|
return null;
|
68
|
}
|
69
|
|
70
|
/* (non-Javadoc)
|
71
|
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
|
72
|
*/
|
73
|
@Override
|
74
|
protected void initModel() {
|
75
|
List<Feature> features = CdmStore.getService(ITermService.class).listByTermClass(Feature.class, null, null, null, null);
|
76
|
|
77
|
List<UuidAndTitleCache<Feature>> featureUuidAndTitleCache = new ArrayList<UuidAndTitleCache<Feature>>();
|
78
|
|
79
|
for(Feature feature : features){
|
80
|
UuidAndTitleCache<Feature> uuidAndTitleCache = new UuidAndTitleCache<Feature>(Feature.class, feature.getUuid(), feature.getTitleCache());
|
81
|
featureUuidAndTitleCache.add(uuidAndTitleCache);
|
82
|
}
|
83
|
|
84
|
model = featureUuidAndTitleCache;
|
85
|
}
|
86
|
|
87
|
/* (non-Javadoc)
|
88
|
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
|
89
|
*/
|
90
|
@Override
|
91
|
protected String getNewWizardLinkText() {
|
92
|
return null;
|
93
|
}
|
94
|
|
95
|
/* (non-Javadoc)
|
96
|
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard()
|
97
|
*/
|
98
|
@Override
|
99
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
100
|
return null;
|
101
|
}
|
102
|
|
103
|
}
|