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
.UUID
;
14 import org
.eclipse
.swt
.widgets
.Shell
;
16 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
17 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
18 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
19 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
21 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.NewDerivedUnitBaseWizard
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 * <p>FilteredDerivedUnitSelectionDialog class.</p>
29 * @created Jun 17, 2010
32 public class DerivedUnitSelectionDialog
extends
33 AbstractFilteredCdmResourceSelectionDialog
<DerivedUnit
> {
38 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
39 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
40 * @param unit a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase} object.
41 * @return a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase} object.
43 public static DerivedUnit
select(Shell shell
, //ConversationHolder conversation,
45 DerivedUnitSelectionDialog dialog
= new DerivedUnitSelectionDialog(shell
, //conversation,
46 "Choose Unit", false, DerivedUnitSelectionDialog
.class.getCanonicalName(), unit
);
47 return getSelectionFromDialog(dialog
);
51 * <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
53 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
54 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
55 * @param title a {@link java.lang.String} object.
56 * @param multi a boolean.
57 * @param settings a {@link java.lang.String} object.
58 * @param cdmObject a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase} object.
60 protected DerivedUnitSelectionDialog(Shell shell
, //ConversationHolder conversation,
62 boolean multi
, String settings
, DerivedUnit cdmObject
) {
63 super(shell
, //conversation,
64 title
, multi
, settings
, cdmObject
);
69 protected DerivedUnit
getPersistentObject(UUID uuid
) {
70 Object object
= CdmStore
.getService(IOccurrenceService
.class).load(uuid
);
72 SpecimenOrObservationBase specimenObservationBase
= (SpecimenOrObservationBase
) HibernateProxyHelper
.deproxy(object
);
74 if(specimenObservationBase
instanceof DerivedUnit
){
75 return (DerivedUnit
) specimenObservationBase
;
77 MessagingUtils
.error(this.getClass(), "Selected unit is not a derived unit", null);
83 protected void callService(String pattern
) {
84 model
= CdmStore
.getService(IOccurrenceService
.class).getDerivedUnitUuidAndTitleCache(limitOfInitialElements
,pattern
);
89 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
90 return new NewDerivedUnitBaseWizard();
95 protected String
[] getNewWizardText() {
96 return new String
[]{ "New Unit"};