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
.store
.operations
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.core
.runtime
.IStatus
;
19 import org
.eclipse
.core
.runtime
.Status
;
21 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
24 import eu
.etaxonomy
.taxeditor
.store
.model
.TaxonUtil
;
31 public class CreateChildTaxonOperation
extends AbstractPostOperation
{
33 private static final Logger logger
= Logger
34 .getLogger(CreateChildTaxonOperation
.class);
36 private TaxonNameBase newTaxonName
;
38 private Taxon childTaxon
;
45 * @param postOperationEnabled
46 * @param conversationEnabled
48 public CreateChildTaxonOperation(String label
, IUndoContext undoContext
,
49 Taxon parentTaxon
, TaxonNameBase name
, IPostOperationEnabled postOperationEnabled
) {
50 super(label
, undoContext
, parentTaxon
, postOperationEnabled
);
52 this.newTaxonName
= name
;
57 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
61 throws ExecutionException
{
63 childTaxon
= TaxonUtil
.addChildTaxonBaseIsolated(taxon
.getUuid(), newTaxonName
);
65 if(childTaxon
!= null){
66 return postExecute(childTaxon
);
68 return new Status(IStatus
.ERROR
, TaxeditorStorePlugin
.PLUGIN_ID
, TaxeditorStorePlugin
.ERROR_SAVING_ZERO_NAME
, "Attempt to save taxon with zero length name", null);
73 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
76 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
77 throws ExecutionException
{
78 return execute(monitor
, info
);
82 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
85 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
86 throws ExecutionException
{
88 logger
.warn("Not yet implemented.");
92 public Taxon
getChildTaxon() {