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
.editor
.view
.descriptive
.operation
;
12 import java
.util
.Collection
;
13 import java
.util
.HashSet
;
15 import java
.util
.UUID
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
19 import org
.eclipse
.core
.runtime
.IAdaptable
;
20 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
21 import org
.eclipse
.core
.runtime
.IStatus
;
23 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
24 import eu
.etaxonomy
.cdm
.api
.service
.UpdateResult
;
25 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
26 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
27 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
28 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
29 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 * @created Feb 8, 2011
36 public class MoveDescriptionElementsOperation
extends AbstractPostTaxonOperation
{
38 private Collection
<DescriptionElementBase
> descriptionElements
;
39 private DescriptionBase targetDescription
;
40 private IDescriptionService service
;
41 private UUID targetTaxonUuid
;
42 private String moveMessage
;
43 private boolean isCopy
;
49 * @param targetDescription
50 * @param descriptionElements
52 * @param postOperationEnabled
54 public MoveDescriptionElementsOperation(String label
,
55 IUndoContext undoContext
, DescriptionBase targetDescription
,
56 Collection
<DescriptionElementBase
> descriptionElements
, boolean isCopy
,
57 IPostOperationEnabled postOperationEnabled
) {
58 super(label
, undoContext
, postOperationEnabled
);
59 this.targetDescription
= targetDescription
;
60 this.descriptionElements
= descriptionElements
;
63 service
= CdmStore
.getService(IDescriptionService
.class);
66 public MoveDescriptionElementsOperation(String label
,
67 IUndoContext undoContext
, UUID targetTaxonUuid
,String moveMessage
,
68 Collection
<DescriptionElementBase
> descriptionElements
, boolean isCopy
,
69 IPostOperationEnabled postOperationEnabled
) {
70 super(label
, undoContext
, postOperationEnabled
);
71 this.targetTaxonUuid
= targetTaxonUuid
;
72 this.descriptionElements
= descriptionElements
;
73 this.moveMessage
= moveMessage
;
76 service
= CdmStore
.getService(IDescriptionService
.class);
80 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
83 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
84 throws ExecutionException
{
86 Set
<UUID
> descriptionElementsUuid
= new HashSet
<UUID
>();
87 for(DescriptionElementBase deBase
: descriptionElements
) {
88 descriptionElementsUuid
.add(deBase
.getUuid());
91 if(targetDescription
== null){
92 result
= service
.moveDescriptionElementsToDescription(descriptionElementsUuid
, targetTaxonUuid
, moveMessage
, isCopy
);
95 UUID targetDescriptionUuid
= targetDescription
.getUuid();
96 result
= 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