1
|
/**
|
2
|
* Copyright (C) 2018 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
|
package eu.etaxonomy.taxeditor.editor;
|
10
|
|
11
|
import java.util.Set;
|
12
|
|
13
|
import org.eclipse.core.runtime.IStatus;
|
14
|
import org.eclipse.swt.widgets.Shell;
|
15
|
import org.eclipse.ui.dialogs.ListDialog;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
18
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
19
|
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
|
20
|
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
|
21
|
|
22
|
/**
|
23
|
* @author k.luther
|
24
|
* @since 28.08.2018
|
25
|
*
|
26
|
*/
|
27
|
public class ChooseFromMultipleAcceptedTaxaDialog extends ListDialog{
|
28
|
|
29
|
public static TaxonNode choose(Set<TaxonNode> taxonNodes){
|
30
|
ChooseFromMultipleAcceptedTaxaDialog dialog = new ChooseFromMultipleAcceptedTaxaDialog(EditorUtil.getShell());
|
31
|
dialog.setInput(taxonNodes);
|
32
|
int result = dialog.open();
|
33
|
|
34
|
if(result == IStatus.OK){
|
35
|
TaxonNode selectedTaxonNode = (TaxonNode) dialog.getResult()[0];
|
36
|
|
37
|
return selectedTaxonNode;
|
38
|
|
39
|
}
|
40
|
return null;
|
41
|
}
|
42
|
|
43
|
public ChooseFromMultipleAcceptedTaxaDialog(Shell parent) {
|
44
|
super(parent);
|
45
|
setTitle(Messages.ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON);
|
46
|
setMessage(Messages.ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON_MESSAGE);
|
47
|
setContentProvider(new TaxonTreeNodeContentProvider());
|
48
|
setLabelProvider(new TaxonTreeNodeLabelProvider());
|
49
|
}
|
50
|
|
51
|
// private class ClassificationLabelProvider extends LabelProvider{
|
52
|
// @Override
|
53
|
// public String getText(Object element) {
|
54
|
// return super.getText(((Classification) element).getTitleCache());
|
55
|
// }
|
56
|
// }
|
57
|
|
58
|
// private class ClassificationContentProvider implements IStructuredContentProvider{
|
59
|
//
|
60
|
// @Override
|
61
|
// public Object[] getElements(Object inputElement) {
|
62
|
// Set<TaxonNode> taxonNodes = (Set<TaxonNode>) inputElement;
|
63
|
//
|
64
|
// List<Classification> classifications = new ArrayList<Classification>();
|
65
|
//
|
66
|
// for(TaxonNode node : taxonNodes){
|
67
|
// classifications.add(node.getClassification());
|
68
|
// }
|
69
|
//
|
70
|
// return classifications.toArray();
|
71
|
// }
|
72
|
//
|
73
|
// @Override
|
74
|
// public void dispose() {
|
75
|
//
|
76
|
// }
|
77
|
//
|
78
|
// @Override
|
79
|
// public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
80
|
//
|
81
|
// }
|
82
|
// }
|
83
|
// }
|
84
|
|
85
|
}
|