Search in sources :

Example 16 with NativeType

use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.

the class NativeTypesLibraryPropertiesEditionComponent method updateSemanticModel.

/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 */
public void updateSemanticModel(final IPropertiesEditionEvent event) {
    NativeTypesLibrary nativeTypesLibrary = (NativeTypesLibrary) semanticObject;
    if (TypeslibraryViewsRepository.NativeTypesLibrary.Properties.name == event.getAffectedEditor()) {
        nativeTypesLibrary.setName((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
    if (TypeslibraryViewsRepository.NativeTypesLibrary.Properties.nativeTypes == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.ADD) {
            EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, nativeTypesSettings, editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy policy = provider.getPolicy(context);
                if (policy instanceof CreateEditingPolicy) {
                    policy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.EDIT) {
            EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
                if (editionPolicy != null) {
                    editionPolicy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
            nativeTypesSettings.removeFromReference((EObject) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.MOVE) {
            nativeTypesSettings.move(event.getNewIndex(), (NativeType) event.getNewValue());
        }
    }
}
Also used : EObjectPropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext) PropertiesEditingProvider(org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider) NativeTypesLibrary(org.obeonetwork.dsl.typeslibrary.NativeTypesLibrary) EObject(org.eclipse.emf.ecore.EObject) NativeType(org.obeonetwork.dsl.typeslibrary.NativeType) PropertiesEditingPolicy(org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy) CreateEditingPolicy(org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy) EReferencePropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)

Example 17 with NativeType

use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.

the class H2DataBaseBuilder method createTypeInstance.

@Override
protected TypeInstance createTypeInstance(NativeTypesLibrary nativeTypesLibrary, String columnType, int columnSize, int decimalDigits) {
    String bkpColumnType = columnType;
    if (columnSize > 0) {
        columnType += "(%n";
    }
    if (decimalDigits > 0) {
        columnType += ",%p";
    }
    columnType += ")";
    NativeType nativeType = nativeTypesLibrary.findTypeByName(columnType);
    if (nativeType == null) {
        columnType = bkpColumnType;
    }
    return super.createTypeInstance(nativeTypesLibrary, columnType, columnSize, decimalDigits);
}
Also used : NativeType(org.obeonetwork.dsl.typeslibrary.NativeType)

Example 18 with NativeType

use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.

the class PostGresDataBaseBuilder method createTypeInstance.

@Override
protected TypeInstance createTypeInstance(NativeTypesLibrary nativeTypesLibrary, String columnType, int columnSize, int decimalDigits) {
    String bkpColumnType = columnType;
    if (columnSize > 0) {
        columnType += "(%n";
    }
    if (decimalDigits > 0) {
        columnType += ",%p";
    }
    columnType += ")";
    NativeType nativeType = nativeTypesLibrary.findTypeByName(columnType);
    if (nativeType == null) {
        columnType = bkpColumnType;
    }
    return super.createTypeInstance(nativeTypesLibrary, columnType, columnSize, decimalDigits);
}
Also used : NativeType(org.obeonetwork.dsl.typeslibrary.NativeType)

Example 19 with NativeType

use of org.obeonetwork.dsl.typeslibrary.NativeType in project InformationSystem by ObeoNetwork.

the class CreationUtils method createTypeInstance.

public static TypeInstance createTypeInstance(NativeTypesLibrary nativeTypesLibrary, String columnType, int columnSize, int decimalDigits) {
    NativeType nativeType = nativeTypesLibrary.findTypeByName(columnType);
    if (nativeType == null) {
        System.err.println("createTypeInstance : native type [" + columnType + "] not found.");
    }
    TypeInstance typeInstance = TypesLibraryFactory.eINSTANCE.createTypeInstance();
    typeInstance.setNativeType(nativeType);
    typeInstance.setLength(columnSize);
    typeInstance.setPrecision(decimalDigits);
    return typeInstance;
}
Also used : NativeType(org.obeonetwork.dsl.typeslibrary.NativeType) TypeInstance(org.obeonetwork.dsl.typeslibrary.TypeInstance)

Aggregations

NativeType (org.obeonetwork.dsl.typeslibrary.NativeType)19 TypeInstance (org.obeonetwork.dsl.typeslibrary.TypeInstance)11 EObject (org.eclipse.emf.ecore.EObject)5 Column (org.obeonetwork.dsl.database.Column)5 Test (org.junit.Test)4 AbstractTest (org.obeonetwork.database.m2doc.services.common.AbstractTest)4 NativeTypesLibrary (org.obeonetwork.dsl.typeslibrary.NativeTypesLibrary)3 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 BasicEList (org.eclipse.emf.common.util.BasicEList)1 EList (org.eclipse.emf.common.util.EList)1 EObjectPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext)1 EReferencePropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)1 PropertiesEditingPolicy (org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy)1 CreateEditingPolicy (org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy)1 PropertiesEditingProvider (org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider)1