package eu.etaxonomy.taxeditor.editor.name;
import org.apache.log4j.Logger;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
target.dragLeft();
}
- public void drop(DropTargetEvent event) {
+ public void drop(DropTargetEvent dropTargetEvent) {
- TaxonBase taxonBase = getDroppedTaxonBase(event);
+ TaxonBase taxonBase = getDroppedTaxonBase(dropTargetEvent);
- if (taxonBase != null) {
- // Execute operations at end of drag event
- AbstractPostOperation operation = createOperation(taxonBase);
-
-
- // Execute operation if it has been initiated
- if (operation == null) {
- logger.warn("User unsuccessfully tried to drop: " + taxonBase.getClass());
- } else {
- EditorUtil.executeOperation(operation);
- }
+ Assert.isNotNull(taxonBase);
+
+ if(taxonBase.getHomotypicGroup().equals(getHomotypicalGroup())){
+ // do nothing when dragged to the same group
+ dropTargetEvent.detail = DND.DROP_NONE;
+ return;
+ }
+
+ // Execute operations at end of drag event
+ AbstractPostOperation operation = createOperation(taxonBase);
+
+ // Execute operation if it has been initiated
+ if (operation == null) {
+ logger.warn("User unsuccessfully tried to drop: " + taxonBase.getClass() +
+ ". Target: " + target);
+ dropTargetEvent.detail = DND.DROP_NONE;
+ } else {
+ EditorUtil.executeOperation(operation);
}
}
private AbstractPostOperation createOperation(TaxonBase taxonBase) {
-
if(taxonBase instanceof Synonym){
Synonym synonym = (Synonym) taxonBase;
// pass
}
+
private HomotypicalGroup getHomotypicalGroup() {
if(target instanceof HomotypicalSynonymGroup){
return ((HomotypicalSynonymGroup) target).getGroup();