Project

General

Profile

Download (3.49 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.IFeatureTreeService;
20
import eu.etaxonomy.cdm.model.description.FeatureTree;
21
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
22
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25
/**
26
 * @author n.hoffmann
27
 * @created Sep 17, 2010
28
 * @version 1.0
29
 */
30
public class FeatureTreeSelectionDialog extends
31
		AbstractFilteredCdmResourceSelectionDialog<FeatureTree> {
32

    
33
	public static FeatureTree select(Shell shell, ConversationHolder conversation, FeatureTree featureTree) {
34
		FeatureTreeSelectionDialog dialog = new FeatureTreeSelectionDialog(shell, conversation,
35
				"Choose a feature tree", false, featureTree);
36
		return getSelectionFromDialog(dialog);
37
	}
38

    
39
	protected FeatureTreeSelectionDialog(Shell shell,
40
			ConversationHolder conversation, String title, boolean multi,
41
			FeatureTree cdmObject) {
42
		super(shell, conversation, title, multi, FeatureTreeSelectionDialog.class.getCanonicalName(), cdmObject);
43
	}
44

    
45
	/** {@inheritDoc} */
46
	@Override
47
	protected FeatureTree getPersistentObject(UUID uuid) {
48
		return CdmStore.getService(IFeatureTreeService.class).load(uuid);
49
	}
50

    
51
	/** {@inheritDoc} */
52
	@Override
53
	protected void search() {
54
		List<FeatureTree> featureTrees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null);
55

    
56
		if(model == null){
57
			model = new ArrayList<UuidAndTitleCache<FeatureTree>>();
58
		}
59
		model.clear();
60
		for(FeatureTree featureTree : featureTrees){
61
			UuidAndTitleCache<FeatureTree> element = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
62
			model.add(element);
63
		}
64
	}
65

    
66
//	/** {@inheritDoc} */
67
//	@Override
68
//	protected Control createExtendedContentArea(Composite parent) {
69
//		Link link = new Link(parent, SWT.NONE);
70
//		link.setText(getNewWizardLinkText());
71
//		link.addListener (SWT.Selection, new Listener () {
72
//			@Override
73
//            public void handleEvent(Event event) {
74
//
75
//			    InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
76
//				int status = input.open();
77
//				if (status == IStatus.OK) {
78
//				    String label = input.getValue();
79
//				    if(label!=null){
80
//				        FeatureTree featureTree = FeatureTree.NewInstance();
81
//				        featureTree.setTitleCache(label, false);
82
//				        CdmStore.getService(IFeatureTreeService.class).save(featureTree);
83
//			            UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
84
//			            model.add(uuidAndTitleCache);
85
//			            setPattern(featureTree);
86
//				    }
87
//				}
88
//			}
89
//		});
90
//		return link;
91
//	}
92

    
93
	/** {@inheritDoc} */
94
	@Override
95
	protected String[] getNewWizardText() {
96
		return new String[]{ "Feature tree "};
97
	}
98

    
99

    
100
	/** {@inheritDoc} */
101
	@Override
102
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
103
		return null;
104
	}
105
}
(12-12/39)