Project

General

Profile

Download (3.64 KB) Statistics
| Branch: | Tag: | Revision:
1 2d9a13f7 n.hoffmann
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4 f0a072ff Patric Plitzner
* European Distributed Institute of Taxonomy
5 2d9a13f7 n.hoffmann
* http://www.e-taxonomy.eu
6 f0a072ff Patric Plitzner
*
7 2d9a13f7 n.hoffmann
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
11 78222507 n.hoffmann
package eu.etaxonomy.taxeditor.ui.dialog.selection;
12 2d9a13f7 n.hoffmann
13
import java.util.UUID;
14
15
import org.eclipse.swt.widgets.Shell;
16
17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18 db5e366d n.hoffmann
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
19 2d9a13f7 n.hoffmann
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
20 49a64920 Cherian Mathew
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
21 2d9a13f7 n.hoffmann
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
22 f211dd28 n.hoffmann
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
23 81c5aaf2 Andreas Müller
import eu.etaxonomy.taxeditor.newWizard.NewFieldUnitWizard;
24 2d9a13f7 n.hoffmann
import eu.etaxonomy.taxeditor.store.CdmStore;
25 f211dd28 n.hoffmann
import eu.etaxonomy.taxeditor.store.StoreUtil;
26 2d9a13f7 n.hoffmann
27
/**
28 68b83178 Andreas Müller
 * <p>FilteredFieldUnitSelectionDialog class.</p>
29 3be6ef3e n.hoffmann
 *
30 2d9a13f7 n.hoffmann
 * @author n.hoffmann
31
 * @created Jun 17, 2010
32
 * @version 1.0
33
 */
34 8c550777 Andreas Müller
public class FieldUnitSelectionDialog extends
35 49a64920 Cherian Mathew
		AbstractFilteredCdmResourceSelectionDialog<FieldUnit> {
36 f0a072ff Patric Plitzner
37 3be6ef3e n.hoffmann
	/**
38
	 * <p>select</p>
39
	 *
40
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
41
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
42 49a64920 Cherian Mathew
	 * @param observation a {@link eu.etaxonomy.cdm.model.occurrence.FieldUnit} object.
43
	 * @return a {@link eu.etaxonomy.cdm.model.occurrence.FieldUnit} object.
44 3be6ef3e n.hoffmann
	 */
45 49a64920 Cherian Mathew
	public static FieldUnit select(Shell shell, ConversationHolder conversation, FieldUnit observation){
46 8c550777 Andreas Müller
		FieldUnitSelectionDialog dialog = new FieldUnitSelectionDialog(shell, conversation,
47
				"Choose Derived Unit", false, FieldUnitSelectionDialog.class.getCanonicalName(), observation);
48 2d9a13f7 n.hoffmann
		return getSelectionFromDialog(dialog);
49
	}
50
51 3be6ef3e n.hoffmann
	/**
52 68b83178 Andreas Müller
	 * <p>Constructor for FilteredFieldUnitSelectionDialog.</p>
53 3be6ef3e n.hoffmann
	 *
54
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
55
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
56
	 * @param title a {@link java.lang.String} object.
57
	 * @param multi a boolean.
58
	 * @param settings a {@link java.lang.String} object.
59 68b83178 Andreas Müller
	 * @param cdmObject a {@link eu.etaxonomy.cdm.model.occurrence.FieldUnit} object.
60 3be6ef3e n.hoffmann
	 */
61 8c550777 Andreas Müller
	protected FieldUnitSelectionDialog(Shell shell, ConversationHolder conversation,
62 2d9a13f7 n.hoffmann
			String title, boolean multi, String settings,
63 49a64920 Cherian Mathew
			FieldUnit cdmObject) {
64 2d9a13f7 n.hoffmann
		super(shell, conversation, title, multi, settings, cdmObject);
65
	}
66 f0a072ff Patric Plitzner
67 2d9a13f7 n.hoffmann
	/* (non-Javadoc)
68
	 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
69
	 */
70 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
71 2d9a13f7 n.hoffmann
	@Override
72 49a64920 Cherian Mathew
	protected FieldUnit getPersistentObject(UUID uuid) {
73 db5e366d n.hoffmann
		Object object = CdmStore.getService(IOccurrenceService.class).load(uuid);
74 f0a072ff Patric Plitzner
75 2d9a13f7 n.hoffmann
		SpecimenOrObservationBase specimenObservationBase = (SpecimenOrObservationBase) HibernateProxyHelper.deproxy(object);
76 f0a072ff Patric Plitzner
77
		if(specimenObservationBase instanceof FieldUnit){
78
			return (FieldUnit) specimenObservationBase;
79 2d9a13f7 n.hoffmann
		}
80 8c550777 Andreas Müller
		StoreUtil.error(this.getClass(), "Selected object is not a field unit", null);
81 2d9a13f7 n.hoffmann
		return null;
82
	}
83
84
	/* (non-Javadoc)
85
	 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
86
	 */
87 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
88 2d9a13f7 n.hoffmann
	@Override
89
	protected void initModel() {
90 124424d0 Cherian Mathew
		model = CdmStore.getService(IOccurrenceService.class).getFieldUnitUuidAndTitleCache();
91 2d9a13f7 n.hoffmann
	}
92
93 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
94 2d9a13f7 n.hoffmann
	@Override
95 9a0f58cd n.hoffmann
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
96 81c5aaf2 Andreas Müller
		return new NewFieldUnitWizard();
97 2d9a13f7 n.hoffmann
	}
98
99 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
100 2d9a13f7 n.hoffmann
	@Override
101
	protected String getNewWizardLinkText() {
102 8c550777 Andreas Müller
		return String.format("Create a new <a>%1s</a>", "Field Unit ");
103 2d9a13f7 n.hoffmann
	}
104
}