2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
;
13 import org
.eclipse
.core
.runtime
.IStatus
;
14 import org
.eclipse
.swt
.widgets
.Shell
;
15 import org
.eclipse
.ui
.dialogs
.ListDialog
;
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
;
27 public class ChooseFromMultipleAcceptedTaxaDialog
extends ListDialog
{
29 public static TaxonNode
choose(Set
<TaxonNode
> taxonNodes
){
30 ChooseFromMultipleAcceptedTaxaDialog dialog
= new ChooseFromMultipleAcceptedTaxaDialog(EditorUtil
.getShell());
31 dialog
.setInput(taxonNodes
);
32 int result
= dialog
.open();
34 if(result
== IStatus
.OK
){
35 TaxonNode selectedTaxonNode
= (TaxonNode
) dialog
.getResult()[0];
37 return selectedTaxonNode
;
43 public ChooseFromMultipleAcceptedTaxaDialog(Shell parent
) {
45 setTitle(Messages
.ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON
);
46 setMessage(Messages
.ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON_MESSAGE
);
47 setContentProvider(new TaxonTreeNodeContentProvider());
48 setLabelProvider(new TaxonTreeNodeLabelProvider());
51 // private class ClassificationLabelProvider extends LabelProvider{
53 // public String getText(Object element) {
54 // return super.getText(((Classification) element).getTitleCache());
58 // private class ClassificationContentProvider implements IStructuredContentProvider{
61 // public Object[] getElements(Object inputElement) {
62 // Set<TaxonNode> taxonNodes = (Set<TaxonNode>) inputElement;
64 // List<Classification> classifications = new ArrayList<Classification>();
66 // for(TaxonNode node : taxonNodes){
67 // classifications.add(node.getClassification());
70 // return classifications.toArray();
74 // public void dispose() {
79 // public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {