1
|
/**
|
2
|
* Copyright (C) 2009 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
|
package eu.etaxonomy.taxeditor.editor.definedterm.operation;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.eclipse.core.commands.ExecutionException;
|
15
|
import org.eclipse.core.commands.operations.IUndoContext;
|
16
|
import org.eclipse.core.runtime.IAdaptable;
|
17
|
import org.eclipse.core.runtime.IProgressMonitor;
|
18
|
import org.eclipse.core.runtime.IStatus;
|
19
|
import org.eclipse.jface.viewers.ViewerDropAdapter;
|
20
|
|
21
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
22
|
import eu.etaxonomy.cdm.api.service.TermServiceImpl.TermMovePosition;
|
23
|
import eu.etaxonomy.cdm.persistence.dto.AbstractTermDto;
|
24
|
import eu.etaxonomy.cdm.persistence.dto.TermDto;
|
25
|
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
|
26
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
27
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
28
|
|
29
|
/**
|
30
|
* @author l.morris
|
31
|
* @date 10 Jan 2012
|
32
|
*
|
33
|
*/
|
34
|
public class MoveDefinedTermOperation extends AbstractPostTaxonOperation {
|
35
|
|
36
|
private final Collection<TermDto> sourceTerms;// the actual DefinedTermBase(s) we are moving
|
37
|
private final AbstractTermDto targetTermOrVocabulary;// the target VOCABULARY or DefinedTerm we are moving these to
|
38
|
private final int currentLocation;
|
39
|
|
40
|
public MoveDefinedTermOperation(String label,
|
41
|
IUndoContext undoContext,
|
42
|
AbstractTermDto target,
|
43
|
Collection<TermDto> sourceTerms,
|
44
|
IPostOperationEnabled postOperationEnabled,
|
45
|
int currentLocation) {
|
46
|
super(label, undoContext, postOperationEnabled);
|
47
|
|
48
|
this.targetTermOrVocabulary = target;
|
49
|
this.sourceTerms = sourceTerms;
|
50
|
this.currentLocation = currentLocation;
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
55
|
throws ExecutionException {
|
56
|
sourceTerms.forEach(term->
|
57
|
{
|
58
|
UUID parentUuid = targetTermOrVocabulary.getUuid();
|
59
|
TermMovePosition termMovePosition = TermMovePosition.ON;
|
60
|
if(currentLocation == ViewerDropAdapter.LOCATION_BEFORE) {
|
61
|
termMovePosition = TermMovePosition.BEFORE;
|
62
|
}
|
63
|
else if(currentLocation == ViewerDropAdapter.LOCATION_AFTER) {
|
64
|
termMovePosition = TermMovePosition.AFTER;
|
65
|
}
|
66
|
CdmStore.getService(ITermService.class).moveTerm(term, parentUuid, termMovePosition);
|
67
|
});
|
68
|
return postExecute(targetTermOrVocabulary);
|
69
|
}
|
70
|
|
71
|
@Override
|
72
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
73
|
throws ExecutionException {
|
74
|
return null;
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
79
|
throws ExecutionException {
|
80
|
return null;
|
81
|
}
|
82
|
|
83
|
}
|