3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * 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.
11 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
;
14 import java
.util
.TreeMap
;
16 import org
.apache
.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
.bulkeditor
.BulkEditorUtil
;
25 import eu
.etaxonomy
.taxeditor
.newWizard
.NewDerivedUnitBaseWizard
;
29 * OccurrenceCreator class.
33 * @created Jun 16, 2010
36 public class OccurrenceCreator
implements
37 IEntityCreator
<SpecimenOrObservationBase
> {
38 private static final Logger logger
= Logger
39 .getLogger(OccurrenceCreator
.class);
43 public SpecimenOrObservationBase
createEntity(String text
) {
45 return createEntity(DerivedUnit
.class, text
);
50 public SpecimenOrObservationBase
createEntity(Object key
, String text
) {
52 SpecimenOrObservationBase specimenOrObservation
= null;
53 NewDerivedUnitBaseWizard wizard
= new NewDerivedUnitBaseWizard((SpecimenOrObservationType
)key
);
54 wizard
.init(null, null);
55 if(wizard
.getEntity() != null) {
56 WizardDialog dialog
= new WizardDialog(BulkEditorUtil
.getShell(), wizard
);
57 int status
= dialog
.open();
59 if (status
== IStatus
.OK
) {
60 specimenOrObservation
= wizard
.getEntity();
63 return specimenOrObservation
;
71 * @return a {@link java.util.Map} object.
74 public Map
<Object
, String
> getKeyLabelPairs() {
75 // Comparator<Object> comparator = new Comparator<Object>() {
76 // public int compare(Object o1, Object o2) {
77 // String key1 = ((SpecimenOrObservationType)o1).getKey();
78 // String key2 = ((SpecimenOrObservationType)o2).getKey();
79 // return key1.compareTo(key2);
82 // Map<Object, String> result = new TreeMap<Object, String>(comparator);
83 // Map<Object, String> result = new HashMap<Object, String>();
84 Map
<Object
, String
> result
= new TreeMap
<Object
, String
>();
86 for(SpecimenOrObservationType sooType
: SpecimenOrObservationType
.values()) {
87 result
.put(sooType
, sooType
.getMessage());
94 public boolean savesEntity() {
95 // TODO Auto-generated method stub