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 java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
16 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.core
.runtime
.Status
;
20 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
30 public abstract class AbstractPostOperation
extends AbstractOperation
{
32 private static final Logger logger
= Logger
33 .getLogger(AbstractPostOperation
.class);
38 protected IPostOperationEnabled postOperationEnabled
;
41 * A reference to the taxon the concrete operation is working on
43 protected Taxon taxon
;
46 * A reference to the taxons TaxonNode
48 protected TaxonNode taxonNode
;
50 protected UUID parentNodeUuid
;
58 protected AbstractPostOperation(String label
, IUndoContext undoContext
) {
60 addContext(undoContext
);
69 public AbstractPostOperation(String label
, IUndoContext undoContext
,
71 this(label
, undoContext
);
81 * @param postOperationEnabled
83 public AbstractPostOperation(String label
, IUndoContext undoContext
,
84 Taxon taxon
, IPostOperationEnabled postOperationEnabled
) {
85 this(label
, undoContext
, taxon
);
86 this.postOperationEnabled
= postOperationEnabled
;
94 * @param postOperationEnabled
96 public AbstractPostOperation(String label
, IUndoContext undoContext
, TaxonNode taxonNode
, IPostOperationEnabled postOperationEnabled
){
97 this(label
, undoContext
, taxonNode
.getTaxon(), postOperationEnabled
);
98 this.taxonNode
= taxonNode
;
101 public AbstractPostOperation(String label
, IUndoContext undoContext
, UUID parentNodeUuid
, IPostOperationEnabled postOperationEnabled
){
102 this(label
, undoContext
);
104 this.parentNodeUuid
= parentNodeUuid
;
105 this.postOperationEnabled
= postOperationEnabled
;
109 * This method will try to call the post operation on a possibly registered
110 * IPostOperationEnabled implementor. Objects that were affected by the operation
111 * may be passed to the registered IPostOperationEnabled implementor.
114 * @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed
118 protected IStatus
postExecute(CdmBase objectAffectedByOperation
) {
119 if(postOperationEnabled
!= null){
120 logger
.trace("executing post operation");
121 return postOperationEnabled
.postOperation(objectAffectedByOperation
) ? Status
.OK_STATUS
: Status
.CANCEL_STATUS
;
123 return Status
.OK_STATUS
;