4 package eu
.etaxonomy
.taxeditor
.ui
.dialogs
.filteredSelection
;
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
;
63 private final Classification defaultClassification
;
67 * <p>Constructor for FilteredTaxonNodeSelectionDialog.</p>
69 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
70 * @param title a {@link java.lang.String} object.
71 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
72 * @param excludeTaxa a {@link java.util.List} object.
73 * @param multi a boolean.
74 * @param node a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
76 protected TaxonNodeSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
, List
<UUID
> excludeTaxa
, boolean multi
, TaxonNode node
, Classification classification
) {
77 super(shell
, conversation
, title
, multi
, TaxonNodeSelectionDialog
.class.getCanonicalName(), node
);
79 ILabelProvider labelProvider
= new FilteredCdmResourceLabelProvider();
81 setListLabelProvider(labelProvider
);
82 setDetailsLabelProvider(labelProvider
);
84 if(classification
!= null){
85 selectedClassification
= classification
;
87 defaultClassification
= classification
;
92 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
96 protected Control
createExtendedContentArea(Composite parent
) {
97 return createClassificationSelectionCombo(parent
);
101 * currently disabled tree selection composite
103 private Control
createClassificationSelectionCombo(Composite parent
){
104 // classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
106 Composite classificationSelection
= new Composite(parent
, SWT
.NULL
);
107 classificationSelection
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
109 GridLayout layout
= new GridLayout();
110 classificationSelection
.setLayout(layout
);
112 Label label
= new Label(classificationSelection
, SWT
.NULL
);
113 // TODO not working is not really true but leave it here to remind everyone that this is under construction
114 label
.setText("Select Classification (experimental)");
115 classificationSelectionCombo
= new Combo(classificationSelection
, SWT
.BORDER
| SWT
.READ_ONLY
);
116 classificationSelectionCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, true));
118 for(Classification tree
: classifications
){
119 classificationSelectionCombo
.add(tree
.getName().getText(), classifications
.indexOf(tree
));
122 classificationSelectionCombo
.select(classifications
.indexOf(selectedClassification
));
124 // TODO remember last selection
125 classificationSelectionCombo
.addSelectionListener(this);
129 return classificationSelection
;
134 protected String
getTitle(TaxonNode taxonNode
) {
135 if(taxonNode
!= null && taxonNode
.getTaxon() != null){
136 return taxonNode
.getTaxon().getTitleCache();
143 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
147 protected TaxonNode
getPersistentObject(UUID uuid
) {
148 return CdmStore
.getService(IClassificationService
.class).getTaxonNodeByUuid(uuid
);
152 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
156 protected void initModel() {
157 // default to first tree
158 // TODO this will be problematic and can only be seen as workaround
161 if(classifications
== null){
162 classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, null);
163 selectedClassification
= classifications
.iterator().next();
166 model
= CdmStore
.getService(IClassificationService
.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification
);
171 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
177 protected String
getNewWizardLinkText() {
182 public void widgetSelected(SelectionEvent e
) {
183 selectedClassification
= classifications
.get(classificationSelectionCombo
.getSelectionIndex());
190 public void widgetDefaultSelected(SelectionEvent e
) {}