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
;
29 * <p>FilteredTaxonNodeSelectionDialog class.</p>
34 public class TaxonNodeSelectionDialog
extends AbstractFilteredCdmResourceSelectionDialog
<TaxonNode
> implements SelectionListener
{
39 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
40 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
41 * @param title a {@link java.lang.String} object.
42 * @param excludeTaxa a {@link java.util.List} object.
43 * @param node a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
44 * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
46 public static TaxonNode
select(Shell shell
, ConversationHolder conversation
, String title
, List
<UUID
> excludeTaxa
, TaxonNode node
, Classification classification
) {
47 TaxonNodeSelectionDialog dialog
= new TaxonNodeSelectionDialog(shell
,
54 return getSelectionFromDialog(dialog
);
57 private Combo classificationSelectionCombo
;
59 private List
<Classification
> classifications
;
61 private Classification selectedClassification
;
64 * <p>Constructor for FilteredTaxonNodeSelectionDialog.</p>
66 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
67 * @param title a {@link java.lang.String} object.
68 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
69 * @param excludeTaxa a {@link java.util.List} object.
70 * @param multi a boolean.
71 * @param node a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
73 protected TaxonNodeSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
, List
<UUID
> excludeTaxa
, boolean multi
, TaxonNode node
, Classification classification
) {
74 super(shell
, conversation
, title
, multi
, TaxonNodeSelectionDialog
.class.getCanonicalName(), node
);
76 ILabelProvider labelProvider
= new FilteredCdmResourceLabelProvider();
78 setListLabelProvider(labelProvider
);
79 setDetailsLabelProvider(labelProvider
);
81 if(classification
!= null){
82 selectedClassification
= classification
;
88 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
92 protected Control
createExtendedContentArea(Composite parent
) {
93 return createClassificationSelectionCombo(parent
);
97 * currently disabled tree selection composite
99 private Control
createClassificationSelectionCombo(Composite parent
){
100 // classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
102 Composite classificationSelection
= new Composite(parent
, SWT
.NULL
);
103 classificationSelection
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
105 GridLayout layout
= new GridLayout();
106 classificationSelection
.setLayout(layout
);
108 Label label
= new Label(classificationSelection
, SWT
.NULL
);
109 // TODO not working is not really true but leave it here to remind everyone that this is under construction
110 label
.setText("Select Classification");
111 classificationSelectionCombo
= new Combo(classificationSelection
, SWT
.BORDER
| SWT
.READ_ONLY
);
112 classificationSelectionCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, true));
114 for(Classification tree
: classifications
){
115 classificationSelectionCombo
.add(tree
.getName().getText(), classifications
.indexOf(tree
));
119 classificationSelectionCombo
.select(classifications
.indexOf(selectedClassification
));
121 // TODO remember last selection
122 classificationSelectionCombo
.addSelectionListener(this);
126 return classificationSelection
;
131 protected String
getTitle(TaxonNode taxonNode
) {
132 if(taxonNode
!= null && taxonNode
.getTaxon() != null){
133 return taxonNode
.getTaxon().getTitleCache();
140 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
144 protected TaxonNode
getPersistentObject(UUID uuid
) {
145 return CdmStore
.getService(IClassificationService
.class).getTaxonNodeByUuid(uuid
);
149 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
153 protected void initModel() {
154 // default to first tree
155 // TODO this will be problematic and can only be seen as workaround
158 if(classifications
== null){
159 classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, null);
160 selectedClassification
= classifications
.iterator().next();
163 model
= CdmStore
.getService(IClassificationService
.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification
);
168 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
174 protected String
getNewWizardLinkText() {
180 public void widgetSelected(SelectionEvent e
) {
181 selectedClassification
= classifications
.get(classificationSelectionCombo
.getSelectionIndex());
189 public void widgetDefaultSelected(SelectionEvent e
) {}