Project

General

Profile

Download (2.31 KB) Statistics
| Branch: | Tag: | Revision:
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.FieldUnit;
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.NewFieldUnitWizard;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

    
24
/**
25
 * @author n.hoffmann
26
 * @created Jun 17, 2010
27
 */
28
public class FieldUnitSelectionDialog extends
29
		AbstractFilteredCdmResourceSelectionDialog<FieldUnit> {
30

    
31
	public static FieldUnit select(Shell shell,
32
	        FieldUnit observation){
33
		FieldUnitSelectionDialog dialog = new FieldUnitSelectionDialog(shell, //conversation,
34
				"Choose Derived Unit", false, FieldUnitSelectionDialog.class.getCanonicalName(), observation);
35
		return getSelectionFromDialog(dialog);
36
	}
37

    
38
	protected FieldUnitSelectionDialog(Shell shell,
39
			String title, boolean multi, String settings,
40
			FieldUnit cdmObject) {
41
		super(shell, title, multi, settings, cdmObject);
42
	}
43

    
44
	@Override
45
	protected FieldUnit 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 FieldUnit){
51
			return (FieldUnit) specimenObservationBase;
52
		}
53
		MessagingUtils.error(this.getClass(), "Selected object is not a field unit", null);
54
		return null;
55
	}
56

    
57
	@Override
58
	protected void callService(String pattern) {
59
	    model = CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache(FieldUnit.class, limitOfInitialElements, pattern);
60
	}
61

    
62
	@Override
63
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
64
		return new NewFieldUnitWizard();
65
	}
66

    
67
	@Override
68
	protected String[] getNewWizardText() {
69
		return new String[]{"New Field Unit"};
70
	}
71
}
(17-17/46)