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