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
|
package eu.etaxonomy.taxeditor.ui.dialog.selection;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.eclipse.swt.widgets.Shell;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
16
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
17
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
18
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
19
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
20
|
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
|
21
|
import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
|
22
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
23
|
|
24
|
/**
|
25
|
* @author n.hoffmann
|
26
|
* @created Jun 17, 2010
|
27
|
*/
|
28
|
public class DerivedUnitSelectionDialog extends
|
29
|
AbstractFilteredCdmResourceSelectionDialog<DerivedUnit> {
|
30
|
|
31
|
public static DerivedUnit select(Shell shell,
|
32
|
DerivedUnit unit){
|
33
|
DerivedUnitSelectionDialog dialog = new DerivedUnitSelectionDialog(shell, //conversation,
|
34
|
"Choose Unit", false, DerivedUnitSelectionDialog.class.getCanonicalName(), unit);
|
35
|
return getSelectionFromDialog(dialog);
|
36
|
}
|
37
|
|
38
|
protected DerivedUnitSelectionDialog(Shell shell,
|
39
|
String title,
|
40
|
boolean multi, String settings, DerivedUnit cdmObject) {
|
41
|
super(shell, title, multi, settings, cdmObject);
|
42
|
}
|
43
|
|
44
|
@Override
|
45
|
protected DerivedUnit getPersistentObject(UUID uuid) {
|
46
|
Object object = CdmStore.getService(IOccurrenceService.class).load(uuid);
|
47
|
|
48
|
SpecimenOrObservationBase specimenObservationBase = (SpecimenOrObservationBase) HibernateProxyHelper.deproxy(object);
|
49
|
|
50
|
if(specimenObservationBase instanceof DerivedUnit){
|
51
|
return (DerivedUnit) specimenObservationBase;
|
52
|
}
|
53
|
MessagingUtils.error(this.getClass(), "Selected unit is not a derived unit", null);
|
54
|
return null;
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
protected void callService(String pattern) {
|
59
|
model = CdmStore.getService(IOccurrenceService.class).getDerivedUnitUuidAndTitleCache(limitOfInitialElements,pattern);
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
64
|
return new NewDerivedUnitBaseWizard();
|
65
|
}
|
66
|
|
67
|
@Override
|
68
|
protected String[] getNewWizardText() {
|
69
|
return new String[]{ "New Unit"};
|
70
|
}
|
71
|
}
|