diff --git a/bundles/org.eclipse.vorto.perspective.vorto/src/org/eclipse/vorto/perspective/vorto/dnd/dropvalidation/DatatypeValidator.java b/bundles/org.eclipse.vorto.perspective.vorto/src/org/eclipse/vorto/perspective/vorto/dnd/dropvalidation/DatatypeValidator.java index 06d5ee3136..b3b31ec48f 100644 --- a/bundles/org.eclipse.vorto.perspective.vorto/src/org/eclipse/vorto/perspective/vorto/dnd/dropvalidation/DatatypeValidator.java +++ b/bundles/org.eclipse.vorto.perspective.vorto/src/org/eclipse/vorto/perspective/vorto/dnd/dropvalidation/DatatypeValidator.java @@ -17,6 +17,7 @@ import org.eclipse.vorto.core.api.model.datatype.Entity; import org.eclipse.vorto.core.api.model.datatype.Enum; import org.eclipse.vorto.core.api.model.model.Model; +import org.eclipse.vorto.core.ui.MessageDisplayFactory; import org.eclipse.vorto.core.ui.model.IModelElement; import org.eclipse.vorto.perspective.dnd.dropvalidator.TargetClassSourceClassValidator; @@ -30,8 +31,10 @@ public DatatypeValidator(Class targetClass, Class sourceClass) { public boolean allow(Object receivingModelElement, Object droppedObject) { if (receivingModelElement instanceof IModelElement && droppedObject instanceof IModelElement) { boolean entityDroppedToEnum = entityDroppedToEnum(((IModelElement)receivingModelElement).getModel(), ((IModelElement) droppedObject).getModel()); - return super.allow(receivingModelElement, droppedObject) && !entityDroppedToEnum; + boolean enumDroppedToEnum = enumDroppedToEnum(((IModelElement)receivingModelElement).getModel(), ((IModelElement) droppedObject).getModel()); + return super.allow(receivingModelElement, droppedObject) && !entityDroppedToEnum && !enumDroppedToEnum; } else { + MessageDisplayFactory.getMessageDisplay().displayError("You cannot drop an Entity or Enum into an Enum"); return false; } } @@ -39,4 +42,8 @@ public boolean allow(Object receivingModelElement, Object droppedObject) { private boolean entityDroppedToEnum(Model targetModel, Model droppedModel) { return targetModel instanceof Enum && droppedModel instanceof Entity; } + + private boolean enumDroppedToEnum(Model targetModel, Model droppedModel) { + return targetModel instanceof Enum && droppedModel instanceof Enum; + } } diff --git a/framework/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/dnd/dropvalidator/TargetClassModelTypeValidator.java b/framework/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/dnd/dropvalidator/TargetClassModelTypeValidator.java index eedb7882a2..7d50ab9700 100644 --- a/framework/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/dnd/dropvalidator/TargetClassModelTypeValidator.java +++ b/framework/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/dnd/dropvalidator/TargetClassModelTypeValidator.java @@ -39,7 +39,7 @@ public boolean allow(Object receivingModelElement, Object droppedObject) { ModelResource model = (ModelResource) droppedObject; return model.getId().getModelType() == modelType; } else { - if (!targetClass.isInstance(receivingModelElement)) { + if (droppedObject instanceof ModelResource && !targetClass.isInstance(receivingModelElement)) { MessageDisplayFactory.getMessageDisplay().displayError("Please create a Project first before dropping models from the repository."); } return false;