Project

General

Profile

Download (2.82 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11

    
12
import java.util.ArrayList;
13
import java.util.List;
14
import java.util.UUID;
15

    
16
import org.eclipse.swt.widgets.Shell;
17

    
18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19
import eu.etaxonomy.cdm.api.service.ITermService;
20
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
21
import eu.etaxonomy.cdm.model.description.Feature;
22
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
23
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25

    
26
/**
27
 * @author n.hoffmann
28
 * @created Dec 6, 2010
29
 * @version 1.0
30
 */
31
public class FeatureSelectionDialog extends
32
		AbstractFilteredCdmResourceSelectionDialog<Feature> {
33

    
34
	public static Feature select(Shell shell, ConversationHolder conversation, Feature feature){
35
		FeatureSelectionDialog dialog = new FeatureSelectionDialog(shell, conversation,
36
				"Choose Feature", false, FeatureSelectionDialog.class.getCanonicalName(), feature);
37
		return getSelectionFromDialog(dialog);
38
	}
39

    
40
	/**
41
	 * @param shell
42
	 * @param conversation
43
	 * @param title
44
	 * @param multi
45
	 * @param settings
46
	 * @param cdmObject
47
	 */
48
	protected FeatureSelectionDialog(Shell shell,
49
			ConversationHolder conversation, String title, boolean multi,
50
			String settings, Feature cdmObject) {
51
		super(shell, conversation, title, multi, settings, cdmObject);
52
	}
53

    
54
	@Override
55
	protected Feature getPersistentObject(UUID uuid) {
56

    
57
		DefinedTermBase<?> term = CdmStore.getService(ITermService.class).load(uuid);
58

    
59
		if(term instanceof Feature){
60
			return (Feature) term;
61
		}
62

    
63
		return null;
64
	}
65

    
66
	@Override
67
	protected void search() {
68
		List<Feature> features = CdmStore.getService(ITermService.class).list(Feature.class, null, null, null, null);
69

    
70
		List<UuidAndTitleCache<Feature>> featureUuidAndTitleCache = new ArrayList<UuidAndTitleCache<Feature>>();
71

    
72
		for(Feature feature : features){
73
			UuidAndTitleCache<Feature> uuidAndTitleCache = new UuidAndTitleCache<Feature>(Feature.class, feature.getUuid(), feature.getId(), feature.getTitleCache());
74
			featureUuidAndTitleCache.add(uuidAndTitleCache);
75
		}
76

    
77
		model =  featureUuidAndTitleCache;
78
	}
79

    
80
	/* (non-Javadoc)
81
	 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
82
	 */
83
	@Override
84
	protected String[] getNewWizardText() {
85
		return null;
86
	}
87

    
88
	/* (non-Javadoc)
89
	 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard()
90
	 */
91
	@Override
92
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
93
		return null;
94
	}
95

    
96
}
(11-11/40)