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
.ui
.dialog
.selection
;
13 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import org
.eclipse
.swt
.widgets
.Control
;
17 import org
.eclipse
.swt
.widgets
.Shell
;
18 import org
.eclipse
.swt
.widgets
.Text
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
21 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
25 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
26 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
27 import eu
.etaxonomy
.taxeditor
.newWizard
.NewTaxonWizard
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 * @created Sep 21, 2009
35 public class TaxonBaseSelectionDialog
extends AbstractFilteredCdmResourceSelectionDialog
<TaxonBase
> {
38 public static TaxonBase
selectTaxonBase(Shell shell
, ConversationHolder conversation
) {
39 AbstractFilteredCdmResourceSelectionDialog
<TaxonBase
> dialog
= new TaxonBaseSelectionDialog(TaxonBase
.class, shell
, conversation
,
40 "Choose a taxon/synonym", false, null, null);
41 return getSelectionFromDialog(dialog
);
44 public static Taxon
selectTaxon(Shell shell
, ConversationHolder conversation
, Taxon taxonToBeFiltered
) {
47 AbstractFilteredCdmResourceSelectionDialog
<TaxonBase
> dialog
= new TaxonBaseSelectionDialog(Taxon
.class, shell
, conversation
,
48 "Choose a taxon", false, null, taxonToBeFiltered
);
49 return (Taxon
) getSelectionFromDialog(dialog
);
52 public static Synonym
selectSynonym(Shell shell
, ConversationHolder conversation
) {
53 AbstractFilteredCdmResourceSelectionDialog
<TaxonBase
> dialog
= new TaxonBaseSelectionDialog(Synonym
.class, shell
, conversation
,
54 "Choose a synonym", false, null, null);
55 return (Synonym
) getSelectionFromDialog(dialog
);
58 private final Class
<?
extends TaxonBase
> clazz
;
60 protected TaxonBaseSelectionDialog(Class
<?
extends TaxonBase
> clazz
, Shell shell
, ConversationHolder conversation
, String title
, boolean multi
, TaxonBase taxon
, TaxonBase taxonToBeFiltered
) {
61 super(shell
, conversation
, title
, multi
, TaxonBaseSelectionDialog
.class.getCanonicalName(), taxon
);
62 this.cdmBaseToBeFiltered
= taxonToBeFiltered
;
69 protected TaxonBase
getPersistentObject(UUID uuid
) {
70 return CdmStore
.getService(ITaxonService
.class).load(uuid
);
74 @SuppressWarnings({ "unchecked", "rawtypes" })
76 protected void initModel() {
77 Control control
= getPatternControl();
78 String pattern
= null;
80 pattern
= ((Text
)control
).getText();
85 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 ");