1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.ui.dialog.selection;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.eclipse.swt.widgets.Shell;
|
15
|
|
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;
|
25
|
|
26
|
/**
|
27
|
* <p>FilteredFieldUnitSelectionDialog class.</p>
|
28
|
*
|
29
|
* @author n.hoffmann
|
30
|
* @created Jun 17, 2010
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class FieldUnitSelectionDialog extends
|
34
|
AbstractFilteredCdmResourceSelectionDialog<FieldUnit> {
|
35
|
|
36
|
/**
|
37
|
* <p>select</p>
|
38
|
*
|
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.
|
43
|
*/
|
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);
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
* <p>Constructor for FilteredFieldUnitSelectionDialog.</p>
|
52
|
*
|
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.
|
59
|
*/
|
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);
|
64
|
}
|
65
|
|
66
|
/* (non-Javadoc)
|
67
|
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
|
68
|
*/
|
69
|
/** {@inheritDoc} */
|
70
|
@Override
|
71
|
protected FieldUnit getPersistentObject(UUID uuid) {
|
72
|
Object object = CdmStore.getService(IOccurrenceService.class).load(uuid);
|
73
|
|
74
|
SpecimenOrObservationBase specimenObservationBase = (SpecimenOrObservationBase) HibernateProxyHelper.deproxy(object);
|
75
|
|
76
|
if(specimenObservationBase instanceof FieldUnit){
|
77
|
return (FieldUnit) specimenObservationBase;
|
78
|
}
|
79
|
MessagingUtils.error(this.getClass(), "Selected object is not a field unit", null);
|
80
|
return null;
|
81
|
}
|
82
|
|
83
|
/* (non-Javadoc)
|
84
|
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#search
|
85
|
*/
|
86
|
/** {@inheritDoc} */
|
87
|
@Override
|
88
|
protected void search() {
|
89
|
model = CdmStore.getService(IOccurrenceService.class).getFieldUnitUuidAndTitleCache();
|
90
|
}
|
91
|
|
92
|
/** {@inheritDoc} */
|
93
|
@Override
|
94
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
95
|
return new NewFieldUnitWizard();
|
96
|
}
|
97
|
|
98
|
/** {@inheritDoc} */
|
99
|
@Override
|
100
|
protected String[] getNewWizardText() {
|
101
|
return new String[]{"Field Unit "};
|
102
|
}
|
103
|
}
|