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
.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
.model
.TaxonUtil
;
24 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
31 public class CreateChildTaxonOperation
extends AbstractPostOperation
{
33 private static final Logger logger
= Logger
.getLogger(CreateChildTaxonOperation
.class);
35 private TaxonNameBase
<?
, ?
> newTaxonName
;
37 private Taxon childTaxon
;
44 * @param postOperationEnabled
45 * @param conversationEnabled
47 public CreateChildTaxonOperation(String label
, IUndoContext undoContext
,
48 Taxon taxon
, TaxonNameBase
<?
, ?
> name
, IPostOperationEnabled postOperationEnabled
) {
49 super(label
, undoContext
, taxon
, postOperationEnabled
);
51 this.newTaxonName
= name
;
56 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
59 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
60 throws ExecutionException
{
62 childTaxon
= TaxonUtil
.addChildTaxonBaseIsolated(taxon
.getUuid(), newTaxonName
);
64 if(childTaxon
!= null){
65 return postExecute(childTaxon
);
67 return new Status(IStatus
.ERROR
, TaxeditorStorePlugin
.PLUGIN_ID
, TaxeditorStorePlugin
.ERROR_SAVING_ZERO_NAME
, "Attempt to save taxon with zero length name", null);
72 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
75 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
76 throws ExecutionException
{
77 return execute(monitor
, info
);
81 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
84 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
85 throws ExecutionException
{
87 logger
.warn("Not yet implemented.");