import org.eclipse.jface.viewers.ViewerDropAdapter;
import org.eclipse.swt.dnd.TransferData;
+import eu.etaxonomy.cdm.model.common.IHasTermType;
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.common.TermVocabulary;
}
}
for (Object droppedObject : droppedObjects) {
+ //check term type compatibility
+ String title = "Term types do not match";
+ String message = "The term type of the dropped term does not match the target term type.";
+ TermType targetType = target.getTermType();
+ if(droppedObject instanceof IHasTermType){
+ TermType droppedType = ((IHasTermType)droppedObject).getTermType();
+ if(!droppedType.equals(targetType)){
+ MessagingUtils.warningDialog(title, this, message);
+ continue;
+ }
+ }
if(droppedObject instanceof FeatureNode){
FeatureNode droppedNode = (FeatureNode) droppedObject;
int currentPosition = target.getIndex(droppedNode);
}
else if(droppedObject instanceof TermDto){
TermDto termDto = (TermDto) droppedObject;
- if(termDto.getTermType().equals(TermType.Feature)){
+ // check if a feature or sub type is dropped
+ if(termDto.getTermType().equals(TermType.Feature) || termDto.getTermType().isKindOf(TermType.Feature)){
+ // check if target feature tree has the same type as the dropped term
+ if(!termDto.getTermType().equals(targetType)){
+ MessagingUtils.warningDialog(title, this, message);
+ continue;
+ }
AddFeatureOperation operation = new AddFeatureOperation(
termDto.getUuid(),
target, position, editor, editor);