2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
;
12 import java
.util
.Arrays
;
13 import java
.util
.HashMap
;
14 import java
.util
.LinkedHashMap
;
17 import org
.apache
.log4j
.Logger
;
18 import org
.eclipse
.core
.runtime
.IStatus
;
19 import org
.eclipse
.jface
.wizard
.WizardDialog
;
21 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
22 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
23 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
24 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
25 import eu
.etaxonomy
.taxeditor
.bulkeditor
.BulkEditorUtil
;
26 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
27 import eu
.etaxonomy
.taxeditor
.newWizard
.NewDerivedUnitBaseWizard
;
31 * OccurrenceCreator class.
35 * @created Jun 16, 2010
38 public class OccurrenceCreator
implements
39 IEntityCreator
<SpecimenOrObservationBase
> {
40 private static final Logger logger
= Logger
41 .getLogger(OccurrenceCreator
.class);
45 public SpecimenOrObservationBase
createEntity(String text
) {
47 return createEntity(DerivedUnit
.class, text
);
52 public SpecimenOrObservationBase
createEntity(Object key
, String text
) {
54 SpecimenOrObservationBase specimenOrObservation
= null;
55 NewDerivedUnitBaseWizard wizard
= new NewDerivedUnitBaseWizard((SpecimenOrObservationType
)key
);
56 wizard
.init(null, null);
57 if(wizard
.getEntity() != null) {
58 WizardDialog dialog
= new WizardDialog(BulkEditorUtil
.getShell(), wizard
);
59 int status
= dialog
.open();
61 if (status
== IStatus
.OK
) {
62 specimenOrObservation
= wizard
.getEntity();
65 return specimenOrObservation
;
73 * @return a {@link java.util.Map} object.
76 public Map
<Object
, String
> getKeyLabelPairs() {
77 Map
<Object
, String
> keyLabelPairs
= new LinkedHashMap
<Object
, String
>();
78 keyLabelPairs
.putAll(AbstractUtility
.orderTerms(Arrays
.asList(SpecimenOrObservationType
.values())));
83 public boolean savesEntity() {