Revision ebfb13c6
Added by Katja Luther almost 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/RemotingMoveTaxonOperation.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
import org.eclipse.core.runtime.IAdaptable; |
15 | 15 |
import org.eclipse.core.runtime.IProgressMonitor; |
16 |
import org.eclipse.swt.widgets.Display; |
|
16 | 17 |
|
17 | 18 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
18 | 19 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
19 | 20 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
20 | 21 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
22 |
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; |
|
21 | 26 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
27 |
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4; |
|
22 | 28 |
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TreeNodeDropAdapterE4.MovingType; |
29 |
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled; |
|
23 | 30 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
24 | 31 |
|
25 | 32 |
/** |
... | ... | |
27 | 34 |
* @date 19 Jun 2015 |
28 | 35 |
* |
29 | 36 |
*/ |
30 |
public class RemotingMoveTaxonOperation extends RemotingCdmUpdateOperation { |
|
37 |
public class RemotingMoveTaxonOperation extends RemotingCdmUpdateOperation implements IPostMoniteredOperationEnabled {
|
|
31 | 38 |
|
32 | 39 |
private final static String LABEL = Messages.RemotingMoveTaxonOperation_MOVE_OP; |
33 | 40 |
|
34 | 41 |
private Set<UUID> taxonNodesToMoveUuid; |
35 | 42 |
private final UUID newParentTreeNodeUuid; |
36 | 43 |
private final MovingType moveToParentNode; |
44 |
private TaxonNavigatorE4 taxonNavigator; |
|
37 | 45 |
|
38 | 46 |
public RemotingMoveTaxonOperation(Object source, |
39 | 47 |
boolean async, |
... | ... | |
44 | 52 |
taxonNodesToMoveUuid = taxonNodeToMoveUuid; |
45 | 53 |
this.newParentTreeNodeUuid = newParentTreeNodeUuid; |
46 | 54 |
this.moveToParentNode = moveToParentNode; |
55 |
|
|
47 | 56 |
} |
48 | 57 |
|
49 | 58 |
// public RemotingMoveTaxonOperation(Object source, |
... | ... | |
79 | 88 |
*/ |
80 | 89 |
@Override |
81 | 90 |
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception { |
91 |
// 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; |
|
82 | 113 |
switch (this.moveToParentNode) { |
83 |
case CHILD: |
|
84 |
return CdmApplicationState.getService(ITaxonNodeService.class).moveTaxonNodes(taxonNodesToMoveUuid, |
|
85 |
newParentTreeNodeUuid, 0); |
|
86 |
case BEHIND: |
|
87 |
return CdmApplicationState.getService(ITaxonNodeService.class).moveTaxonNodes(taxonNodesToMoveUuid, |
|
88 |
newParentTreeNodeUuid, 2); |
|
89 |
default: |
|
90 |
UpdateResult result = new UpdateResult(); |
|
91 |
result.setAbort(); |
|
92 |
result.addException(new Exception("The moving type is invalid.")); //$NON-NLS-1$ |
|
93 |
return result; |
|
114 |
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 |
}); |
|
94 | 142 |
} |
143 |
// 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 |
|
|
95 | 155 |
} |
96 | 156 |
|
97 | 157 |
} |
Also available in: Unified diff
move taxon is a longRunning task now