2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
;
12 import java
.util
.List
;
13 import java
.util
.UUID
;
15 import org
.eclipse
.swt
.widgets
.Control
;
16 import org
.eclipse
.swt
.widgets
.Shell
;
17 import org
.eclipse
.swt
.widgets
.Text
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
20 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
24 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
25 import eu
.etaxonomy
.taxeditor
.newWizard
.NewTaxonWizard
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 * @created Sep 21, 2009
33 public class TaxonBaseSelectionDialog
extends AbstractFilteredCdmResourceSelectionDialog
<TaxonBase
> {
36 public static TaxonBase
selectTaxonBase(Shell shell
, ConversationHolder conversation
) {
37 AbstractFilteredCdmResourceSelectionDialog
<TaxonBase
> dialog
= new TaxonBaseSelectionDialog(TaxonBase
.class, shell
, conversation
,
38 "Choose a taxon/synonym", false, null, null);
39 return getSelectionFromDialog(dialog
);
42 public static Taxon
selectTaxon(Shell shell
, ConversationHolder conversation
, Taxon taxonToBeFiltered
) {
45 AbstractFilteredCdmResourceSelectionDialog
<TaxonBase
> dialog
= new TaxonBaseSelectionDialog(Taxon
.class, shell
, conversation
,
46 "Choose a taxon", false, null, taxonToBeFiltered
);
47 return (Taxon
) getSelectionFromDialog(dialog
);
50 public static Synonym
selectSynonym(Shell shell
, ConversationHolder conversation
) {
51 AbstractFilteredCdmResourceSelectionDialog
<TaxonBase
> dialog
= new TaxonBaseSelectionDialog(Synonym
.class, shell
, conversation
,
52 "Choose a synonym", false, null, null);
53 return (Synonym
) getSelectionFromDialog(dialog
);
56 private final Class
<?
extends TaxonBase
> clazz
;
58 protected TaxonBaseSelectionDialog(Class
<?
extends TaxonBase
> clazz
, Shell shell
, ConversationHolder conversation
, String title
, boolean multi
, TaxonBase taxon
, TaxonBase taxonToBeFiltered
) {
59 super(shell
, conversation
, title
, multi
, TaxonBaseSelectionDialog
.class.getCanonicalName(), taxon
);
60 this.cdmBaseToBeFiltered
= taxonToBeFiltered
;
67 protected TaxonBase
getPersistentObject(UUID uuid
) {
68 return CdmStore
.getService(ITaxonService
.class).load(uuid
);
72 @SuppressWarnings({ "unchecked", "rawtypes" })
74 protected void initModel() {
75 Control control
= getPatternControl();
76 String pattern
= null;
78 pattern
= ((Text
)control
).getText();
81 if (pattern
== null || pattern
.equals("?")){
82 model
= (List
)CdmStore
.getService(ITaxonService
.class).getUuidAndTitleCache(Taxon
.class, null, null);
84 model
= (List
)CdmStore
.getService(ITaxonService
.class).getUuidAndTitleCache(Taxon
.class, limitOfInitialElements
, pattern
);
90 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
91 return new NewTaxonWizard();
96 protected String
getNewWizardLinkText() {
97 return String
.format("Create a new <a>%1s</a>", "Taxon ");