-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't allow entities to be dropped to enums. Closes #92
Signed-off-by: Erle Czar Mantos <[email protected]>
- Loading branch information
Erle Czar Mantos
committed
Mar 28, 2016
1 parent
8f48306
commit 76b2b0b
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; | ||
} | ||
} |