3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.editor
.name
;
13 import java
.util
.List
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.swt
.widgets
.Shell
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
19 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 public class TaxonSearchDialog
extends NameSearchDialog
{
27 private static final Logger logger
= Logger
28 .getLogger(TaxonSearchDialog
.class);
30 protected String dialogTitle
= "Search for a taxib in datasource";
31 protected String dialogMessage
= "Enter a search term for a taxon, using '*' as a wildcard.";
34 private Taxon excludeTaxon
;
39 public TaxonSearchDialog(Shell parent
) {
46 public TaxonSearchDialog(Shell parent
, Taxon excludeTaxon
) {
49 this.excludeTaxon
= excludeTaxon
;
52 protected List
doSearch() {
53 List results
= CdmStore
.searchTaxaByName(searchTermText
.getText(), true);
54 if (excludeTaxon
!= null) {
55 results
.remove(excludeTaxon
);
63 protected String
getText(Object element
) {
64 if (element
instanceof Taxon
) {
65 return ((Taxon
) element
).getTitleCache();
74 protected boolean setSelection(Object data
) {
75 if (data
instanceof Taxon
) {
76 setSelectedTaxon((Taxon
) data
);
85 private void setSelectedTaxon(Taxon taxon
) {
92 private Object
getSelectedTaxon() {
96 protected void submitResult() {
97 result
= getSelectedTaxon();