Revision ebfb13c6
Added by Katja Luther almost 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TreeNodeDropAdapterE4.java | ||
---|---|---|
25 | 25 |
import org.eclipse.swt.dnd.DND; |
26 | 26 |
import org.eclipse.swt.dnd.DropTargetEvent; |
27 | 27 |
import org.eclipse.swt.dnd.TransferData; |
28 |
import org.eclipse.swt.widgets.Display; |
|
28 | 29 |
|
30 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
29 | 31 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
30 | 32 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
33 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
|
31 | 34 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
32 | 35 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
33 | 36 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
37 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
34 | 38 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
39 |
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled; |
|
35 | 40 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
36 | 41 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
37 | 42 |
|
... | ... | |
39 | 44 |
* @author k.luther |
40 | 45 |
* @date 02.06.2015 |
41 | 46 |
*/ |
42 |
public class TreeNodeDropAdapterE4 extends ViewerDropAdapter { |
|
47 |
public class TreeNodeDropAdapterE4 extends ViewerDropAdapter implements IPostMoniteredOperationEnabled{
|
|
43 | 48 |
|
44 | 49 |
protected static final String TREE_NODE_DROP_ADAPTER_UNSAVED_PARENT_MESSAGE = Messages.TreeNodeDropAdapter_UNSAVED_PARENT_MESSAGE; |
45 | 50 |
protected static final String TREE_NODE_DROP_ADAPTER_UNSAVED_PARENT = Messages.TreeNodeDropAdapter_UNSAVED_PARENT; |
... | ... | |
186 | 191 |
uuids.add(node.getUuid()); |
187 | 192 |
} |
188 | 193 |
IUndoContext workspaceUndoContext = taxonNavigator.getUndoContext(); |
194 |
int movingTypeInt = 0; |
|
189 | 195 |
if (!PreferencesUtil.getSortNodesNaturally()){ |
190 |
if (workspaceUndoContext == null) { |
|
191 |
logger.error("Workspace undo context is null. DND operation cancelled"); //$NON-NLS-1$ |
|
192 |
return false; |
|
193 |
} |
|
194 |
result =CdmStore.getService(ITaxonNodeService.class).moveTaxonNodes(uuids,targetITaxonTreeNode.getUuid(), 0); |
|
195 |
|
|
196 |
logger.info("Moved taxa to new parent " + targetITaxonTreeNode); //$NON-NLS-1$ |
|
197 |
return true; |
|
196 |
// if (workspaceUndoContext == null) {
|
|
197 |
// logger.error("Workspace undo context is null. DND operation cancelled"); //$NON-NLS-1$
|
|
198 |
// return false;
|
|
199 |
// }
|
|
200 |
// result =CdmStore.getService(ITaxonNodeService.class).moveTaxonNodes(uuids,targetITaxonTreeNode.getUuid(), 0);
|
|
201 |
// |
|
202 |
// logger.info("Moved taxa to new parent " + targetITaxonTreeNode); //$NON-NLS-1$
|
|
203 |
// return true;
|
|
198 | 204 |
}else{ |
199 | 205 |
String[] buttonLables = {TREE_NODE_DROP_ADAPTER_CHILD, TREE_NODE_DROP_ADAPTER_BEHIND,TREE_NODE_DROP_ADAPTER_CANCEL}; |
200 | 206 |
MessageDialog dialog = new MessageDialog(null, TARGET_NODE, null, DO_YOU_WANT_TO_MOVE_THE_TAXONNODE_AS_CHILD_OR_BEHIND_THE_TARGET_NODE, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0); |
... | ... | |
207 | 213 |
return false; |
208 | 214 |
} |
209 | 215 |
|
210 |
result = CdmStore.getService(ITaxonNodeService.class).moveTaxonNodes(uuids,targetITaxonTreeNode.getUuid(), 0); |
|
211 |
|
|
212 |
logger.info("Moved taxa to new parent " + targetITaxonTreeNode); //$NON-NLS-1$ |
|
213 |
return true; |
|
216 |
// result = CdmStore.getService(ITaxonNodeService.class).moveTaxonNodes(uuids,targetITaxonTreeNode.getUuid(), 0);
|
|
217 |
// |
|
218 |
// logger.info("Moved taxa to new parent " + targetITaxonTreeNode); //$NON-NLS-1$
|
|
219 |
// return true;
|
|
214 | 220 |
}else if (returnCode == 1){ |
215 | 221 |
if (workspaceUndoContext == null) { |
216 | 222 |
logger.error("Workspace undo context is null. DND operation cancelled"); //$NON-NLS-1$ |
217 | 223 |
return false; |
218 | 224 |
} |
219 | 225 |
|
220 |
|
|
221 |
CdmStore.getService(ITaxonNodeService.class).moveTaxonNodes(uuids,targetITaxonTreeNode.getUuid(), 2); |
|
222 |
logger.info("Moved taxa to new parent " + targetITaxonTreeNode); //$NON-NLS-1$ |
|
223 |
return true; |
|
226 |
movingTypeInt = 2; |
|
227 |
// CdmStore.getService(ITaxonNodeService.class).moveTaxonNodes(uuids,targetITaxonTreeNode.getUuid(), 2);
|
|
228 |
// logger.info("Moved taxa to new parent " + targetITaxonTreeNode); //$NON-NLS-1$
|
|
229 |
// return true;
|
|
224 | 230 |
} |
225 | 231 |
// } else if (returnCode == 2){ |
226 | 232 |
// IUndoContext workspaceUndoContext = NavigationUtil.getWorkbenchUndoContext(); |
... | ... | |
243 | 249 |
|
244 | 250 |
|
245 | 251 |
} |
252 |
moveNodes(uuids, targetITaxonTreeNode.getUuid(), movingTypeInt); |
|
253 |
return true; |
|
246 | 254 |
} |
247 | 255 |
|
256 |
private void moveNodes(Set<UUID> taxonNodesToMoveUuid, UUID newParentTreeNodeUuid, int movingTypeInt){ |
|
257 |
UUID uuid = CdmApplicationState.getLongRunningTasksService().monitLongRunningTask(taxonNodesToMoveUuid, |
|
258 |
newParentTreeNodeUuid, movingTypeInt); |
|
259 |
|
|
260 |
Display.getDefault().asyncExec(new Runnable() { |
|
261 |
@Override |
|
262 |
public void run() { |
|
263 |
AbstractUtility.executeMoniteredOperation("Move Taxon to new parent: ", |
|
264 |
uuid, |
|
265 |
1000, |
|
266 |
false, |
|
267 |
TreeNodeDropAdapterE4.this, |
|
268 |
null); |
|
269 |
} |
|
270 |
}); |
|
271 |
} |
|
272 |
|
|
273 |
|
|
248 | 274 |
@Override |
249 | 275 |
public void dragOver(DropTargetEvent event) { |
250 | 276 |
super.dragOver(event); |
251 | 277 |
event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_INSERT_AFTER; |
252 | 278 |
} |
253 | 279 |
|
280 |
/** |
|
281 |
* {@inheritDoc} |
|
282 |
*/ |
|
283 |
@Override |
|
284 |
public void postOperation(IRemotingProgressMonitor monitor) { |
|
285 |
taxonNavigator.refresh(); |
|
286 |
} |
|
287 |
|
|
254 | 288 |
} |
Also available in: Unified diff
move taxon is a longRunning task now