forked from eclipse-vorto/vorto
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eclipse-vorto#124 from bsinno/bug/92-EntityDropped…
…OnEnums Don't allow entities to be dropped to enums. Closes eclipse-vorto#92
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...to.perspective/src/org/eclipse/vorto/perspective/dnd/dropvalidator/DatatypeValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.eclipse.vorto.perspective.dnd.dropvalidator; | ||
|
||
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.model.IModelProject; | ||
|
||
public class DatatypeValidator extends TargetClassSourceClassValidator { | ||
|
||
public DatatypeValidator(Class<?> targetClass, Class<?> sourceClass) { | ||
super(targetClass, sourceClass); | ||
} | ||
|
||
@Override | ||
public boolean allow(IModelProject receivingProject, Object droppedObject) { | ||
boolean entityDroppedToEnum = entityDroppedToEnum(receivingProject.getModel(), ((IModelProject) droppedObject).getModel()); | ||
return super.allow(receivingProject, droppedObject) && !entityDroppedToEnum; | ||
} | ||
|
||
private boolean entityDroppedToEnum(Model targetModel, Model droppedModel) { | ||
return targetModel instanceof Enum && droppedModel instanceof Entity; | ||
} | ||
} |