Search in sources :

Example 1 with Literal

use of com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.Literal in project mechanoid by robotoworks.

the class PreferenceImpl method basicSetDefaultValue.

/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
public NotificationChain basicSetDefaultValue(Literal newDefaultValue, NotificationChain msgs) {
    Literal oldDefaultValue = defaultValue;
    defaultValue = newDefaultValue;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SharedPreferencesModelPackage.PREFERENCE__DEFAULT_VALUE, oldDefaultValue, newDefaultValue);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Literal(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.Literal)

Example 2 with Literal

use of com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.Literal in project mechanoid by robotoworks.

the class SharedPreferencesModelJavaValidator method checkDefaultValue.

@Check
public void checkDefaultValue(Preference preference) {
    PreferenceType type = preference.getType();
    Literal defaultValue = preference.getDefaultValue();
    if (defaultValue == null) {
        return;
    }
    switch(type) {
        case STRING:
            if (!(defaultValue instanceof StringLiteral)) {
                error("Type mismatch", SharedPreferencesModelPackage.Literals.PREFERENCE__DEFAULT_VALUE);
            }
            break;
        case BOOLEAN:
            if (!(defaultValue instanceof BooleanLiteral)) {
                error("Type mismatch", SharedPreferencesModelPackage.Literals.PREFERENCE__DEFAULT_VALUE);
            }
            break;
        case FLOAT:
        case INTEGER:
        case LONG:
            if (!(defaultValue instanceof NumericLiteral)) {
                error("Type mismatch", SharedPreferencesModelPackage.Literals.PREFERENCE__DEFAULT_VALUE);
            }
            break;
    }
}
Also used : StringLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.StringLiteral) NumericLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.NumericLiteral) BooleanLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.BooleanLiteral) BooleanLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.BooleanLiteral) StringLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.StringLiteral) Literal(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.Literal) NumericLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.NumericLiteral) PreferenceType(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.PreferenceType) Check(org.eclipse.xtext.validation.Check)

Aggregations

Literal (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.Literal)2 BooleanLiteral (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.BooleanLiteral)1 NumericLiteral (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.NumericLiteral)1 PreferenceType (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.PreferenceType)1 StringLiteral (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.StringLiteral)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Check (org.eclipse.xtext.validation.Check)1