4 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
;
9 import org
.eclipse
.jface
.viewers
.ILabelProvider
;
10 import org
.eclipse
.swt
.SWT
;
11 import org
.eclipse
.swt
.events
.SelectionEvent
;
12 import org
.eclipse
.swt
.events
.SelectionListener
;
13 import org
.eclipse
.swt
.layout
.GridData
;
14 import org
.eclipse
.swt
.layout
.GridLayout
;
15 import org
.eclipse
.swt
.widgets
.Combo
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.swt
.widgets
.Control
;
18 import org
.eclipse
.swt
.widgets
.Label
;
19 import org
.eclipse
.swt
.widgets
.Shell
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
22 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
25 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 public class TaxonNodeSelectionDialog
extends AbstractFilteredCdmResourceSelectionDialog
<TaxonNode
> implements SelectionListener
{
34 public static TaxonNode
select(Shell shell
, ConversationHolder conversation
, String title
, List
<UUID
> excludeTaxa
, TaxonNode node
, Classification classification
) {
35 TaxonNodeSelectionDialog dialog
= new TaxonNodeSelectionDialog(shell
,
42 return getSelectionFromDialog(dialog
);
45 private Combo classificationSelectionCombo
;
47 private List
<Classification
> classifications
;
49 private Classification selectedClassification
;
51 protected TaxonNodeSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
, List
<UUID
> excludeTaxa
, boolean multi
, TaxonNode node
, Classification classification
) {
52 super(shell
, conversation
, title
, multi
, TaxonNodeSelectionDialog
.class.getCanonicalName(), node
);
54 ILabelProvider labelProvider
= new FilteredCdmResourceLabelProvider();
56 setListLabelProvider(labelProvider
);
57 setDetailsLabelProvider(labelProvider
);
59 if(classification
!= null){
60 selectedClassification
= classification
;
66 protected Control
createExtendedContentArea(Composite parent
) {
67 return createClassificationSelectionCombo(parent
);
71 * currently disabled tree selection composite
73 private Control
createClassificationSelectionCombo(Composite parent
){
74 // classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
76 Composite classificationSelection
= new Composite(parent
, SWT
.NULL
);
77 classificationSelection
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
79 GridLayout layout
= new GridLayout();
80 classificationSelection
.setLayout(layout
);
82 Label label
= new Label(classificationSelection
, SWT
.NULL
);
83 // TODO not working is not really true but leave it here to remind everyone that this is under construction
84 label
.setText("Select Classification");
85 classificationSelectionCombo
= new Combo(classificationSelection
, SWT
.BORDER
| SWT
.READ_ONLY
);
86 classificationSelectionCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, true));
88 for(Classification tree
: classifications
){
89 classificationSelectionCombo
.add(tree
.getName().getText(), classifications
.indexOf(tree
));
93 classificationSelectionCombo
.select(classifications
.indexOf(selectedClassification
));
95 // TODO remember last selection
96 classificationSelectionCombo
.addSelectionListener(this);
100 return classificationSelection
;
105 protected String
getTitle(TaxonNode taxonNode
) {
106 if(taxonNode
!= null && taxonNode
.getTaxon() != null){
107 return taxonNode
.getTaxon().getTitleCache();
115 protected TaxonNode
getPersistentObject(UUID uuid
) {
116 return CdmStore
.getService(IClassificationService
.class).getTaxonNodeByUuid(uuid
);
121 protected void initModel() {
122 // default to first tree
123 // TODO this will be problematic and can only be seen as workaround
126 if(classifications
== null){
127 classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, null);
128 selectedClassification
= classifications
.iterator().next();
131 model
= CdmStore
.getService(IClassificationService
.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification
);
136 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
142 protected String
getNewWizardLinkText() {
148 public void widgetSelected(SelectionEvent e
) {
149 selectedClassification
= classifications
.get(classificationSelectionCombo
.getSelectionIndex());
157 public void widgetDefaultSelected(SelectionEvent e
) {}