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
.editor
.view
.descriptive
.operation
;
13 import java
.util
.Collection
;
14 import java
.util
.HashSet
;
16 import java
.util
.UUID
;
18 import org
.eclipse
.core
.commands
.ExecutionException
;
19 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
20 import org
.eclipse
.core
.runtime
.IAdaptable
;
21 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
22 import org
.eclipse
.core
.runtime
.IStatus
;
24 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
25 import eu
.etaxonomy
.cdm
.api
.service
.UpdateResult
;
26 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
27 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
28 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
29 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
34 * @created Feb 8, 2011
37 public class MoveDescriptionElementsOperation
extends AbstractPostTaxonOperation
{
39 private Collection
<DescriptionElementBase
> descriptionElements
;
40 private DescriptionBase targetDescription
;
41 private IDescriptionService service
;
42 private UUID targetTaxonUuid
;
43 private String moveMessage
;
44 private boolean isCopy
;
50 * @param targetDescription
51 * @param descriptionElements
53 * @param postOperationEnabled
55 public MoveDescriptionElementsOperation(String label
,
56 IUndoContext undoContext
, DescriptionBase targetDescription
,
57 Collection
<DescriptionElementBase
> descriptionElements
, boolean isCopy
,
58 IPostOperationEnabled postOperationEnabled
) {
59 super(label
, undoContext
, postOperationEnabled
);
60 this.targetDescription
= targetDescription
;
61 this.descriptionElements
= descriptionElements
;
64 service
= CdmStore
.getService(IDescriptionService
.class);
67 public MoveDescriptionElementsOperation(String label
,
68 IUndoContext undoContext
, UUID targetTaxonUuid
,String moveMessage
,
69 Collection
<DescriptionElementBase
> descriptionElements
, boolean isCopy
,
70 IPostOperationEnabled postOperationEnabled
) {
71 super(label
, undoContext
, postOperationEnabled
);
72 this.targetTaxonUuid
= targetTaxonUuid
;
73 this.descriptionElements
= descriptionElements
;
74 this.moveMessage
= moveMessage
;
77 service
= CdmStore
.getService(IDescriptionService
.class);
81 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
84 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
85 throws ExecutionException
{
87 Set
<UUID
> descriptionElementsUuid
= new HashSet
<UUID
>();
88 for(DescriptionElementBase deBase
: descriptionElements
) {
89 descriptionElementsUuid
.add(deBase
.getUuid());
92 if(targetDescription
== null){
93 UpdateResult result
= service
.moveDescriptionElementsToDescription(descriptionElementsUuid
, targetTaxonUuid
, moveMessage
, isCopy
);
96 UUID targetDescriptionUuid
= targetDescription
.getUuid();
97 service
.moveDescriptionElementsToDescription(descriptionElementsUuid
, targetDescriptionUuid
, isCopy
);
99 return postExecute(targetDescription
);
103 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
106 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
107 throws ExecutionException
{
108 // TODO Auto-generated method stub
113 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
116 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
117 throws ExecutionException
{
118 // TODO Auto-generated method stub