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.core.runtime.CoreException;
|
15
|
import org.eclipse.swt.widgets.Control;
|
16
|
import org.eclipse.swt.widgets.Shell;
|
17
|
import org.eclipse.swt.widgets.Text;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
20
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
21
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
22
|
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
|
23
|
import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
|
24
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
25
|
|
26
|
/**
|
27
|
* @author pplitzner
|
28
|
*/
|
29
|
public class SpecimenOrObservationBaseSelectionDialog extends
|
30
|
AbstractFilteredCdmResourceSelectionDialog<SpecimenOrObservationBase> {
|
31
|
|
32
|
public static SpecimenOrObservationBase select(Shell shell, //ConversationHolder conversation,
|
33
|
SpecimenOrObservationBase observation){
|
34
|
SpecimenOrObservationBaseSelectionDialog dialog = new SpecimenOrObservationBaseSelectionDialog(shell, //conversation,
|
35
|
"Choose field unit or derived unit", false, SpecimenOrObservationBaseSelectionDialog.class.getCanonicalName(), observation);
|
36
|
return getSelectionFromDialog(dialog);
|
37
|
}
|
38
|
|
39
|
protected SpecimenOrObservationBaseSelectionDialog(Shell shell, //ConversationHolder conversation,
|
40
|
String title, boolean multi, String settings,
|
41
|
SpecimenOrObservationBase cdmObject) {
|
42
|
super(shell, //conversation,
|
43
|
title, multi, settings, cdmObject);
|
44
|
}
|
45
|
|
46
|
/** {@inheritDoc} */
|
47
|
@Override
|
48
|
protected SpecimenOrObservationBase getPersistentObject(UUID uuid) {
|
49
|
Object object = CdmStore.getService(IOccurrenceService.class).load(uuid);
|
50
|
return HibernateProxyHelper.deproxy(object, SpecimenOrObservationBase.class);
|
51
|
}
|
52
|
|
53
|
/** {@inheritDoc} */
|
54
|
@Override
|
55
|
protected void search() {
|
56
|
|
57
|
Control control =getSearchField();
|
58
|
String pattern = null;
|
59
|
if (control != null){
|
60
|
pattern = ((Text)control).getText();
|
61
|
}
|
62
|
|
63
|
if (pattern == null || pattern.equals("?")){
|
64
|
model = CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache(null,null);
|
65
|
}else{
|
66
|
model =CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
|
67
|
}
|
68
|
try {
|
69
|
fillContentProvider(null);
|
70
|
} catch (CoreException e) {
|
71
|
// TODO Auto-generated catch block
|
72
|
e.printStackTrace();
|
73
|
}
|
74
|
}
|
75
|
|
76
|
/** {@inheritDoc} */
|
77
|
@Override
|
78
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
79
|
return new NewDerivedUnitBaseWizard();
|
80
|
}
|
81
|
|
82
|
/** {@inheritDoc} */
|
83
|
@Override
|
84
|
protected String[] getNewWizardText() {
|
85
|
return new String[]{"field unit/derived unit"};
|
86
|
}
|
87
|
}
|