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
) {
47 TaxonNodeSelectionDialog dialog
= new TaxonNodeSelectionDialog(shell
,
53 return getSelectionFromDialog(dialog
);
56 private Combo classificationSelectionCombo
;
58 private List
<Classification
> classifications
;
60 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
) {
74 super(shell
, conversation
, title
, multi
, TaxonNodeSelectionDialog
.class.getCanonicalName(), node
);
76 ILabelProvider labelProvider
= new FilteredCdmResourceLabelProvider();
78 setListLabelProvider(labelProvider
);
79 setDetailsLabelProvider(labelProvider
);
85 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
89 protected Control
createExtendedContentArea(Composite parent
) {
90 return createTreeSelectionCombo(parent
);
94 * currently disabled tree selection composite
96 private Control
createTreeSelectionCombo(Composite parent
){
97 // classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
99 Composite classificationSelection
= new Composite(parent
, SWT
.NULL
);
100 classificationSelection
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
102 GridLayout layout
= new GridLayout();
103 classificationSelection
.setLayout(layout
);
105 Label label
= new Label(classificationSelection
, SWT
.NULL
);
106 // TODO not working is not really true but leave it there to remind everyone that this is under construction
107 label
.setText("Select Classification (experimental)");
108 classificationSelectionCombo
= new Combo(classificationSelection
, SWT
.BORDER
| SWT
.READ_ONLY
);
109 classificationSelectionCombo
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, true));
111 for(Classification tree
: classifications
){
112 classificationSelectionCombo
.add(tree
.getName().getText(), classifications
.indexOf(tree
));
115 classificationSelectionCombo
.select(classifications
.indexOf(selectedClassification
));
117 // TODO remember last selection
119 classificationSelectionCombo
.addSelectionListener(this);
121 return classificationSelection
;
126 protected String
getTitle(TaxonNode taxonNode
) {
127 return taxonNode
.getTaxon().getTitleCache();
131 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
135 protected TaxonNode
getPersistentObject(UUID uuid
) {
136 return CdmStore
.getService(IClassificationService
.class).getTaxonNodeByUuid(uuid
);
140 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
144 protected void initModel() {
145 // default to first tree
146 // TODO this will be problematic and can only be seen as workaround
149 if(classifications
== null){
150 classifications
= CdmStore
.getService(IClassificationService
.class).list(null, null, null, null, null);
151 selectedClassification
= classifications
.iterator().next();
154 model
= CdmStore
.getService(IClassificationService
.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification
);
159 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
165 protected String
getNewWizardLinkText() {
170 public void widgetSelected(SelectionEvent e
) {
171 selectedClassification
= classifications
.get(classificationSelectionCombo
.getSelectionIndex());
176 public void widgetDefaultSelected(SelectionEvent e
) {}