blob: 676c1462ae05d6ade594941a6995a01948cbc05a [file] [log] [blame]
/******************************************************************************
* *
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) *
* *
* All rights reserved. This program and the accompanying materials *
* are made available under the terms of the Eclipse Public License v1.0 *
* which accompanies this distribution, and is available at *
* http://www.eclipse.org/legal/epl-v10.html *
* *
*============================================================================*
* Initial contribution: *
* Loetz GmbH & Co. KG *
* *
* generated by xtext *
******************************************************************************/
package org.eclipse.osbp.xtext.dialogdsl.validation
import java.util.List
import org.eclipse.core.databinding.DataBindingContext
import org.eclipse.core.databinding.beans.BeansObservables
import org.eclipse.osbp.xtext.dialogdsl.Dialog
import org.eclipse.osbp.xtext.dialogdsl.DialogDSLPackage
import org.eclipse.osbp.xtext.dialogdsl.DialogModel
import org.eclipse.xtext.common.types.JvmGenericType
import org.eclipse.xtext.validation.Check
//import org.eclipse.xtext.validation.Check
/**
* Custom validation rules.
*
* see http://www.eclipse.org/Xtext/documentation.html#validation
*/
class DialogDslValidator extends AbstractDialogDslValidator {
// public static val INVALID_NAME = 'invalidName'
//
// @Check
// def checkGreetingStartsWithCapital(Greeting greeting) {
// if (!Character.isUpperCase(greeting.name.charAt(0))) {
// warning('Name should start with a capital',
// MyDslPackage.Literals.GREETING__NAME,
// INVALID_NAME)
// }
// }
public static val String CODE__MISSING__L_RUNTIME_COMMON = "0_108"
public static val String CODE__MISSING__DATATYPE_LIB = "0_109"
public static val String CODE__MISSING__XBASE_LIB = "0_111"
public static val String CODE__MISSING__JDK_1_5 = "0_112"
public static val String CODE__NOT_ALLOWED_ACTION_TOOLBAR = "0_113"
// @Check
// def checkClassPath(DialogModel dialogModel) {
// var typeReferences = services.typeReferences
// val listType = typeReferences.findDeclaredType(List, dialogModel) as JvmGenericType
// if (listType == null || listType.getTypeParameters().isEmpty()) {
// error("Couldn't find a JDK 1.5 or higher on the project's classpath.",
// dialogModel, DialogDSLPackage.Literals.DIALOG_MODEL__PCKG,
// CODE__MISSING__JDK_1_5);
// }
// if (typeReferences.findDeclaredType(DataBindingContext, dialogModel) === null) {
// error("Couldn't find a the mandatory library 'org.eclipse.core.databinding' on the project's classpath.",
// dialogModel, DialogDSLPackage.Literals.DIALOG_MODEL__PCKG,
// "");
// }
// if (typeReferences.findDeclaredType(BeansObservables, dialogModel) === null) {
// error("Couldn't find a the mandatory library 'org.eclipse.core.databinding.beans' on the project's classpath.",
// dialogModel, DialogDSLPackage.Literals.DIALOG_MODEL__PCKG,
// "");
// }
// if (typeReferences.findDeclaredType(
// "org.eclipse.osbp.runtime.common.annotations.Dispose", dialogModel) === null) {
// error("Couldn't find the mandatory library 'org.eclipse.osbp.runtime.common' on the project's classpath.",
// dialogModel, DialogDSLPackage.Literals.DIALOG_MODEL__PCKG,
// CODE__MISSING__L_RUNTIME_COMMON);
// }
// if (typeReferences.findDeclaredType(Extension, dialogModel) === null) {
// error("Couldn't find the mandatory library 'org.eclipse.xtext.xbase.lib' 2.7.3 or higher on the project's classpath.",
// dialogModel, DialogDSLPackage.Literals.DIALOG_MODEL__PCKG,
// CODE__MISSING__XBASE_LIB);
// }
// if (typeReferences.findDeclaredType(
// "org.eclipse.osbp.dsl.common.datatypes.IDatatypeConstants", dialogModel) === null) {
// warning("Couldn't find the optional library 'org.eclipse.osbp.dsl.datatype.lib' on the project's classpath. This may cause resolving problems.",
// dialogModel, DialogDSLPackage.Literals.DIALOG_MODEL__PCKG,
// CODE__MISSING__DATATYPE_LIB);
// }
// if (typeReferences.findDeclaredType("javax.validation.Valid", dialogModel) === null) {
// error("Couldn't find the library 'javax.validation' on the project's classpath. This may cause resolving problems.",
// dialogModel, DialogDSLPackage.Literals.DIALOG_MODEL__PCKG,
// CODE__MISSING__DATATYPE_LIB);
// }
// }
@Check
def checkActionToolbar(Dialog dialog) {
if (dialog.toolbar !== null && dialog.embedded){
error("An action toolbar is not allowed on embedded dialogs.",
dialog, DialogDSLPackage.Literals.DIALOG__TOOLBAR,
CODE__NOT_ALLOWED_ACTION_TOOLBAR);
}
}
}