| /** |
| * generated by Xtext 2.11.0 |
| */ |
| package org.eclipse.osbp.xtext.action.validation; |
| |
| import org.eclipse.osbp.runtime.common.keystroke.KeyCodeUtil; |
| import org.eclipse.osbp.xtext.action.ActionCommand; |
| import org.eclipse.osbp.xtext.action.ActionDSLPackage; |
| import org.eclipse.osbp.xtext.action.validation.AbstractActionDSLValidator; |
| import org.eclipse.xtext.validation.Check; |
| import org.eclipse.xtext.xbase.lib.Conversions; |
| import org.eclipse.xtext.xbase.lib.IterableExtensions; |
| |
| /** |
| * This class contains custom validation rules. |
| * |
| * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation |
| */ |
| @SuppressWarnings("all") |
| public class ActionDSLValidator extends AbstractActionDSLValidator { |
| public final static String INVALID_KEY = "invalidKey"; |
| |
| @Check |
| public void checkKeyBinding(final ActionCommand command) { |
| boolean _isHasKeyBinding = command.isHasKeyBinding(); |
| if (_isHasKeyBinding) { |
| boolean error = false; |
| String[] parts = command.getKeyBinding().split(" "); |
| for (final String part : parts) { |
| { |
| final String[] _converted_parts = (String[])parts; |
| boolean _equals = part.equals(IterableExtensions.<Object>last(((Iterable<Object>)Conversions.doWrapArray(_converted_parts)))); |
| if (_equals) { |
| Integer _keyLookupInteger = KeyCodeUtil.keyLookupInteger(part); |
| boolean _equals_1 = ((_keyLookupInteger).intValue() == 0); |
| if (_equals_1) { |
| error = true; |
| } |
| } else { |
| int _modifierLookup = KeyCodeUtil.modifierLookup(part); |
| boolean _equals_2 = (_modifierLookup == 0); |
| if (_equals_2) { |
| error = true; |
| } |
| } |
| if (error) { |
| this.warning("Invalid key given for keyBinding. Modifier must be one of CTRL ALT SHIFT, Keys separated by blanks", |
| ActionDSLPackage.Literals.ACTION_COMMAND__KEY_BINDING, |
| ActionDSLValidator.INVALID_KEY); |
| } |
| } |
| } |
| } |
| } |
| } |