blob: f6646e5de020b96ce8f14420b4c2214712b151fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package rba.tool.editor.validation.validators
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
import rba.core.RBACorePackage
import rba.core.Scene
import rba.tool.editor.messages.Messages
import rba.tool.editor.validation.AbstractRBAModelValidator
class SceneValidator extends AbstractRBAModelValidator {
private String SCENE_GLOBAL = Messages.SCENE_GLOBAL;
private String SCENE_PROPERTY_NEGATIVE = Messages.SCENE_PROPERTY_NEGATIVE;
override register(EValidatorRegistrar registrar) {
// not needed for classes used as ComposedCheck
}
@Check(NORMAL)
def checkSceneProperty(Scene scene) {
if (scene.properties.size > 0 && scene.global == false) {
error(SCENE_GLOBAL, RBACorePackage.Literals.SCENE__PROPERTIES);
return;
}
val properties = scene.properties
for (var int i = 0; i < properties.size; i++) {
var property = properties.get(i)
if (property instanceof rba.core.impl.IntegerPropertyImpl) {
var value = property.getValue()
if (value instanceof rba.core.impl.IntegerValueImpl) {
if (value.getValue() < 0) {
error(SCENE_PROPERTY_NEGATIVE, RBACorePackage.Literals.SCENE__PROPERTIES, i);
return;
}
}
}
}
}
}
|