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.description.Feature;
|
23
|
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
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
|
@Override
|
56
|
protected Feature getPersistentObject(UUID uuid) {
|
57
|
|
58
|
DefinedTermBase<?> term = CdmStore.getService(ITermService.class).load(uuid);
|
59
|
|
60
|
if(term instanceof Feature){
|
61
|
return (Feature) term;
|
62
|
}
|
63
|
|
64
|
return null;
|
65
|
}
|
66
|
|
67
|
@Override
|
68
|
protected void initModel() {
|
69
|
List<Feature> features = CdmStore.getService(ITermService.class).list(Feature.class, null, null, null, null);
|
70
|
|
71
|
List<UuidAndTitleCache<Feature>> featureUuidAndTitleCache = new ArrayList<UuidAndTitleCache<Feature>>();
|
72
|
|
73
|
for(Feature feature : features){
|
74
|
UuidAndTitleCache<Feature> uuidAndTitleCache = new UuidAndTitleCache<Feature>(Feature.class, feature.getUuid(), feature.getId(), feature.getTitleCache());
|
75
|
featureUuidAndTitleCache.add(uuidAndTitleCache);
|
76
|
}
|
77
|
|
78
|
model = featureUuidAndTitleCache;
|
79
|
}
|
80
|
|
81
|
/* (non-Javadoc)
|
82
|
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
|
83
|
*/
|
84
|
@Override
|
85
|
protected String getNewWizardLinkText() {
|
86
|
return null;
|
87
|
}
|
88
|
|
89
|
/* (non-Javadoc)
|
90
|
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard()
|
91
|
*/
|
92
|
@Override
|
93
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
94
|
return null;
|
95
|
}
|
96
|
|
97
|
}
|