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
.operations
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
14 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
16 import org
.eclipse
.core
.runtime
.Status
;
18 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
28 public abstract class AbstractPostOperation
extends AbstractOperation
{
30 private static final Logger logger
= Logger
31 .getLogger(AbstractPostOperation
.class);
36 protected IPostOperationEnabled postOperationEnabled
;
39 * A reference to the taxon the concrete operation is working on
41 protected Taxon taxon
;
44 * A reference to the taxons TaxonNode
46 protected TaxonNode taxonNode
;
54 public AbstractPostOperation(String label
, IUndoContext undoContext
,
57 addContext(undoContext
);
67 * @param postOperationEnabled
69 public AbstractPostOperation(String label
, IUndoContext undoContext
,
70 Taxon taxon
, IPostOperationEnabled postOperationEnabled
) {
71 this(label
, undoContext
, taxon
);
72 this.postOperationEnabled
= postOperationEnabled
;
80 * @param postOperationEnabled
82 public AbstractPostOperation(String label
, IUndoContext undoContext
, TaxonNode taxonNode
, IPostOperationEnabled postOperationEnabled
){
83 this(label
, undoContext
, taxonNode
.getTaxon(), postOperationEnabled
);
84 this.taxonNode
= taxonNode
;
88 * This method will try to call the post operation on a possibly registered
89 * IPostOperationEnabled implementor. Objects that were affected by the operation
90 * may be passed to the registered IPostOperationEnabled implementor.
93 * @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed
97 protected IStatus
postExecute(CdmBase objectAffectedByOperation
) {
98 if(postOperationEnabled
!= null){
99 logger
.trace("executing post operation");
100 return postOperationEnabled
.postOperation(objectAffectedByOperation
) ? Status
.OK_STATUS
: Status
.CANCEL_STATUS
;
102 return Status
.OK_STATUS
;