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
.conversation
.ConversationHolder
;
17 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
18 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
19 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
20 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
23 import eu
.etaxonomy
.taxeditor
.newWizard
.NewFieldUnitWizard
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 * <p>FilteredFieldUnitSelectionDialog class.</p>
30 * @created Jun 17, 2010
33 public class FieldUnitSelectionDialog
extends
34 AbstractFilteredCdmResourceSelectionDialog
<FieldUnit
> {
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 observation a {@link eu.etaxonomy.cdm.model.occurrence.FieldUnit} object.
42 * @return a {@link eu.etaxonomy.cdm.model.occurrence.FieldUnit} object.
44 public static FieldUnit
select(Shell shell
, ConversationHolder conversation
, FieldUnit observation
){
45 FieldUnitSelectionDialog dialog
= new FieldUnitSelectionDialog(shell
, conversation
,
46 "Choose Derived Unit", false, FieldUnitSelectionDialog
.class.getCanonicalName(), observation
);
47 return getSelectionFromDialog(dialog
);
51 * <p>Constructor for FilteredFieldUnitSelectionDialog.</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.FieldUnit} object.
60 protected FieldUnitSelectionDialog(Shell shell
, ConversationHolder conversation
,
61 String title
, boolean multi
, String settings
,
62 FieldUnit cdmObject
) {
63 super(shell
, conversation
, title
, multi
, settings
, cdmObject
);
67 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
71 protected FieldUnit
getPersistentObject(UUID uuid
) {
72 Object object
= CdmStore
.getService(IOccurrenceService
.class).load(uuid
);
74 SpecimenOrObservationBase specimenObservationBase
= (SpecimenOrObservationBase
) HibernateProxyHelper
.deproxy(object
);
76 if(specimenObservationBase
instanceof FieldUnit
){
77 return (FieldUnit
) specimenObservationBase
;
79 MessagingUtils
.error(this.getClass(), "Selected object is not a field unit", null);
84 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
88 protected void initModel() {
89 model
= CdmStore
.getService(IOccurrenceService
.class).getFieldUnitUuidAndTitleCache();
94 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
95 return new NewFieldUnitWizard();
100 protected String
getNewWizardLinkText() {
101 return String
.format("Create a new <a>%1s</a>", "Field Unit ");