1 |
83a1a479
|
Cherian Mathew
|
/**
|
2 |
|
|
* Copyright (C) 2015 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.navigation.navigator.operation;
|
10 |
|
|
|
11 |
025f3eb9
|
Cherian Mathew
|
import java.util.Set;
|
12 |
83a1a479
|
Cherian Mathew
|
import java.util.UUID;
|
13 |
|
|
|
14 |
|
|
import org.eclipse.core.runtime.IAdaptable;
|
15 |
|
|
import org.eclipse.core.runtime.IProgressMonitor;
|
16 |
ebfb13c6
|
Katja Luther
|
import org.eclipse.swt.widgets.Display;
|
17 |
83a1a479
|
Cherian Mathew
|
|
18 |
|
|
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
19 |
|
|
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
|
20 |
|
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
21 |
|
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
22 |
ebfb13c6
|
Katja Luther
|
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
|
23 |
|
|
import eu.etaxonomy.taxeditor.event.EventUtility;
|
24 |
|
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
25 |
|
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
26 |
939829bc
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
|
27 |
ebfb13c6
|
Katja Luther
|
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
|
28 |
5d6c432e
|
Katja Luther
|
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TreeNodeDropAdapterE4.MovingType;
|
29 |
ebfb13c6
|
Katja Luther
|
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
|
30 |
83a1a479
|
Cherian Mathew
|
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
|
31 |
|
|
|
32 |
|
|
/**
|
33 |
|
|
* @author cmathew
|
34 |
|
|
* @date 19 Jun 2015
|
35 |
|
|
*
|
36 |
|
|
*/
|
37 |
ebfb13c6
|
Katja Luther
|
public class RemotingMoveTaxonOperation extends RemotingCdmUpdateOperation implements IPostMoniteredOperationEnabled {
|
38 |
83a1a479
|
Cherian Mathew
|
|
39 |
939829bc
|
Patrick Plitzner
|
private final static String LABEL = Messages.RemotingMoveTaxonOperation_MOVE_OP;
|
40 |
83a1a479
|
Cherian Mathew
|
|
41 |
0fde7fba
|
Katja Luther
|
private Set<UUID> taxonNodesToMoveUuid;
|
42 |
83a1a479
|
Cherian Mathew
|
private final UUID newParentTreeNodeUuid;
|
43 |
e77e7f40
|
Katja Luther
|
private final MovingType moveToParentNode;
|
44 |
ebfb13c6
|
Katja Luther
|
private TaxonNavigatorE4 taxonNavigator;
|
45 |
83a1a479
|
Cherian Mathew
|
|
46 |
|
|
public RemotingMoveTaxonOperation(Object source,
|
47 |
|
|
boolean async,
|
48 |
0fde7fba
|
Katja Luther
|
Set<UUID> taxonNodeToMoveUuid,
|
49 |
83a1a479
|
Cherian Mathew
|
UUID newParentTreeNodeUuid,
|
50 |
e77e7f40
|
Katja Luther
|
MovingType moveToParentNode) {
|
51 |
83a1a479
|
Cherian Mathew
|
super(LABEL, Action.Update, source,async);
|
52 |
0fde7fba
|
Katja Luther
|
taxonNodesToMoveUuid = taxonNodeToMoveUuid;
|
53 |
83a1a479
|
Cherian Mathew
|
this.newParentTreeNodeUuid = newParentTreeNodeUuid;
|
54 |
|
|
this.moveToParentNode = moveToParentNode;
|
55 |
ebfb13c6
|
Katja Luther
|
|
56 |
83a1a479
|
Cherian Mathew
|
}
|
57 |
|
|
|
58 |
0fde7fba
|
Katja Luther
|
// public RemotingMoveTaxonOperation(Object source,
|
59 |
|
|
// boolean async,
|
60 |
|
|
// List<TaxonNode> taxonNodeToMove,
|
61 |
|
|
// TaxonNode newParentTreeNode,
|
62 |
|
|
// MovingType moveToParentNode) {
|
63 |
|
|
// super(LABEL, Action.Update, source,async);
|
64 |
|
|
//
|
65 |
|
|
// taxonNodesToMoveUuid=taxonNodeToMove;
|
66 |
|
|
// this.newParentTreeNodeUuid = newParentTreeNode.getUuid();
|
67 |
|
|
// this.moveToParentNode = moveToParentNode;
|
68 |
|
|
// }
|
69 |
025f3eb9
|
Cherian Mathew
|
|
70 |
cedc4ff1
|
Katja Luther
|
|
71 |
0fde7fba
|
Katja Luther
|
// /**
|
72 |
|
|
// * @param source
|
73 |
|
|
// * @param async
|
74 |
|
|
// * @param uuids
|
75 |
|
|
// * @param uuid
|
76 |
|
|
// * @param child
|
77 |
|
|
// */
|
78 |
|
|
// public RemotingMoveTaxonOperation(Object source, boolean async, Set<UUID> uuids, UUID uuid,
|
79 |
|
|
// MovingType child) {
|
80 |
|
|
// super(LABEL, Action.Update, source,async);
|
81 |
|
|
// this.taxonNodesToMoveUuid = uuids;
|
82 |
|
|
// this.newParentTreeNodeUuid = uuid;
|
83 |
|
|
// this.moveToParentNode = child;
|
84 |
|
|
// }
|
85 |
6c511765
|
Cherian Mathew
|
|
86 |
83a1a479
|
Cherian Mathew
|
/* (non-Javadoc)
|
87 |
|
|
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
88 |
|
|
*/
|
89 |
|
|
@Override
|
90 |
|
|
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
|
91 |
ebfb13c6
|
Katja Luther
|
// switch (this.moveToParentNode) {
|
92 |
|
|
// case CHILD:
|
93 |
|
|
// return CdmApplicationState.getService(ITaxonNodeService.class).moveTaxonNodes(taxonNodesToMoveUuid,
|
94 |
|
|
// newParentTreeNodeUuid, 0);
|
95 |
|
|
// case BEHIND:
|
96 |
|
|
// runMoniteredOperation();
|
97 |
|
|
// return updateResult;
|
98 |
|
|
// default:
|
99 |
|
|
// UpdateResult result = new UpdateResult();
|
100 |
|
|
// result.setAbort();
|
101 |
|
|
// result.addException(new Exception("The moving type is invalid.")); //$NON-NLS-1$
|
102 |
|
|
// return result;
|
103 |
|
|
// }
|
104 |
|
|
runMoniteredOperation();
|
105 |
|
|
// taxonNavigator.refresh();
|
106 |
|
|
return updateResult;
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
public void runMoniteredOperation() {
|
110 |
|
|
ITaxonNodeService nodeService;
|
111 |
|
|
final UUID uuid;
|
112 |
|
|
int movingTypeInt = -1;
|
113 |
e77e7f40
|
Katja Luther
|
switch (this.moveToParentNode) {
|
114 |
ebfb13c6
|
Katja Luther
|
case CHILD:
|
115 |
|
|
movingTypeInt = 0;
|
116 |
|
|
break;
|
117 |
|
|
case BEHIND:
|
118 |
|
|
movingTypeInt = 2;
|
119 |
|
|
break;
|
120 |
|
|
|
121 |
|
|
default:
|
122 |
|
|
updateResult = new UpdateResult();
|
123 |
|
|
updateResult.setAbort();
|
124 |
|
|
updateResult.addException(new Exception("The moving type is invalid.")); //$NON-NLS-1$
|
125 |
|
|
|
126 |
|
|
}
|
127 |
|
|
if (movingTypeInt >-1){
|
128 |
|
|
uuid = CdmApplicationState.getLongRunningTasksService().monitLongRunningTask(taxonNodesToMoveUuid,
|
129 |
|
|
newParentTreeNodeUuid, movingTypeInt);
|
130 |
|
|
|
131 |
|
|
Display.getDefault().asyncExec(new Runnable() {
|
132 |
|
|
@Override
|
133 |
|
|
public void run() {
|
134 |
|
|
AbstractUtility.executeMoniteredOperation("Move Taxon to new parent: ",
|
135 |
|
|
uuid,
|
136 |
|
|
1000,
|
137 |
|
|
false,
|
138 |
|
|
RemotingMoveTaxonOperation.this,
|
139 |
|
|
null);
|
140 |
|
|
}
|
141 |
|
|
});
|
142 |
e77e7f40
|
Katja Luther
|
}
|
143 |
ebfb13c6
|
Katja Luther
|
// monitor.done();
|
144 |
|
|
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
/**
|
148 |
|
|
* {@inheritDoc}
|
149 |
|
|
*/
|
150 |
|
|
@Override
|
151 |
|
|
public void postOperation(IRemotingProgressMonitor monitor) {
|
152 |
|
|
monitor.done();
|
153 |
|
|
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true);
|
154 |
|
|
|
155 |
83a1a479
|
Cherian Mathew
|
}
|
156 |
|
|
|
157 |
|
|
}
|