1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.editor.view.descriptive.operation;
|
11
|
|
12
|
import java.util.Collection;
|
13
|
import java.util.HashSet;
|
14
|
import java.util.Set;
|
15
|
import java.util.UUID;
|
16
|
|
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;
|
22
|
import org.eclipse.e4.ui.di.UISynchronize;
|
23
|
|
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;
|
31
|
|
32
|
/**
|
33
|
* @author n.hoffmann
|
34
|
* @created Feb 8, 2011
|
35
|
* @version 1.0
|
36
|
*/
|
37
|
public class MoveDescriptionElementsOperation extends AbstractPostTaxonOperation{
|
38
|
|
39
|
private Collection<DescriptionElementBase> descriptionElements;
|
40
|
private DescriptionBase targetDescription;
|
41
|
private DescriptionBase sourceDescription;
|
42
|
private IDescriptionService service;
|
43
|
private UUID targetTaxonUuid;
|
44
|
|
45
|
private String moveMessage;
|
46
|
private boolean isCopy;
|
47
|
private UISynchronize sync;
|
48
|
|
49
|
/**
|
50
|
*
|
51
|
* @param label
|
52
|
* @param undoContext
|
53
|
* @param targetDescription
|
54
|
* @param descriptionElements
|
55
|
* @param isCopy
|
56
|
* @param postOperationEnabled
|
57
|
*/
|
58
|
public MoveDescriptionElementsOperation(String label,
|
59
|
IUndoContext undoContext, DescriptionBase targetDescription, DescriptionBase sourceDescription,
|
60
|
Collection<DescriptionElementBase> descriptionElements, boolean isCopy,
|
61
|
IPostOperationEnabled postOperationEnabled, UISynchronize sync) {
|
62
|
super(label, undoContext, postOperationEnabled);
|
63
|
this.targetDescription = targetDescription;
|
64
|
this.sourceDescription = sourceDescription;
|
65
|
this.descriptionElements = descriptionElements;
|
66
|
this.isCopy = isCopy;
|
67
|
this.sync = sync;
|
68
|
service = CdmStore.getService(IDescriptionService.class);
|
69
|
}
|
70
|
|
71
|
public MoveDescriptionElementsOperation(String label,
|
72
|
IUndoContext undoContext, UUID targetTaxonUuid, String moveMessage,
|
73
|
Collection<DescriptionElementBase> descriptionElements, boolean isCopy,
|
74
|
IPostOperationEnabled postOperationEnabled, UISynchronize sync) {
|
75
|
super(label, undoContext, postOperationEnabled);
|
76
|
this.targetTaxonUuid = targetTaxonUuid;
|
77
|
this.descriptionElements = descriptionElements;
|
78
|
this.moveMessage = moveMessage;
|
79
|
this.isCopy = isCopy;
|
80
|
this.sync = sync;
|
81
|
service = CdmStore.getService(IDescriptionService.class);
|
82
|
}
|
83
|
|
84
|
/* (non-Javadoc)
|
85
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
86
|
*/
|
87
|
@Override
|
88
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
89
|
throws ExecutionException {
|
90
|
|
91
|
Set<UUID> descriptionElementsUuid = new HashSet<UUID>();
|
92
|
for(DescriptionElementBase deBase : descriptionElements) {
|
93
|
descriptionElementsUuid.add(deBase.getUuid());
|
94
|
}
|
95
|
UpdateResult result;
|
96
|
if(targetDescription == null){
|
97
|
result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetTaxonUuid, moveMessage, isCopy);
|
98
|
|
99
|
} else {
|
100
|
UUID targetDescriptionUuid = targetDescription.getUuid();
|
101
|
UUID sourceDescriptionUuid = sourceDescription.getUuid();
|
102
|
result = service.moveDescriptionElementsToDescription(descriptionElementsUuid, targetDescriptionUuid, isCopy);
|
103
|
|
104
|
}
|
105
|
return postExecute(null);
|
106
|
}
|
107
|
|
108
|
/* (non-Javadoc)
|
109
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
110
|
*/
|
111
|
@Override
|
112
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
113
|
throws ExecutionException {
|
114
|
// TODO Auto-generated method stub
|
115
|
return null;
|
116
|
}
|
117
|
|
118
|
/* (non-Javadoc)
|
119
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
120
|
*/
|
121
|
@Override
|
122
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
123
|
throws ExecutionException {
|
124
|
// TODO Auto-generated method stub
|
125
|
return null;
|
126
|
}
|
127
|
|
128
|
|
129
|
|
130
|
}
|