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
.LinkedHashMap
;
16 import org
.apache
.logging
.log4j
.LogManager
;import org
.apache
.logging
.log4j
.Logger
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.jface
.wizard
.WizardDialog
;
20 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
21 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
22 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
23 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
24 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
25 import eu
.etaxonomy
.taxeditor
.newWizard
.NewDerivedUnitBaseWizard
;
29 * OccurrenceCreator class.
33 * @created Jun 16, 2010
35 public class OccurrenceCreator
implements
36 IEntityCreator
<SpecimenOrObservationBase
> {
38 @SuppressWarnings("unused")
39 private static final Logger logger
= LogManager
.getLogger(OccurrenceCreator
.class);
42 public SpecimenOrObservationBase
createEntity(String text
) {
43 return createEntity(DerivedUnit
.class, text
);
47 public SpecimenOrObservationBase
createEntity(Object key
, String text
) {
49 SpecimenOrObservationBase
<?
> specimenOrObservation
= null;
50 NewDerivedUnitBaseWizard wizard
= new NewDerivedUnitBaseWizard((SpecimenOrObservationType
)key
);
51 wizard
.init(null, null);
52 if(wizard
.getEntity() != null) {
53 WizardDialog dialog
= new WizardDialog(AbstractUtility
.getShell(), wizard
);
54 int status
= dialog
.open();
56 if (status
== IStatus
.OK
) {
57 specimenOrObservation
= wizard
.getEntity();
60 return specimenOrObservation
;
64 public Map
<Object
, String
> getKeyLabelPairs() {
65 Map
<Object
, String
> keyLabelPairs
= new LinkedHashMap
<>();
66 keyLabelPairs
.putAll(AbstractUtility
.orderTerms(Arrays
.asList(SpecimenOrObservationType
.values())));
71 public boolean savesEntity() {