Search in sources :

Example 1 with PrimitiveType

use of org.obeonetwork.dsl.environment.PrimitiveType in project InformationSystem by ObeoNetwork.

the class ModelUtils method getKey.

public static String getKey(EObject object) {
    String prefix = object.eClass().getName() + "_";
    // Special case for Entity, index by physicalName
    if (object instanceof Entity) {
        Entity entity = (Entity) object;
        String physicalName = AnnotationHelper.getPhysicalName(entity);
        if (physicalName == null) {
            physicalName = LabelProvider.getNameFeatureValue(entity);
        }
        if (physicalName != null) {
            return prefix + physicalName;
        }
    }
    // Retrieve the value of the name feature
    EStructuralFeature nameFeature = object.eClass().getEStructuralFeature("name");
    if (nameFeature != null) {
        Object value = object.eGet(nameFeature);
        if (value != null && value instanceof String) {
            // Special case for Primitive types do not use prefix
            if (object instanceof PrimitiveType) {
                return (String) value;
            }
            return prefix + (String) value;
        }
    }
    return null;
}
Also used : Entity(org.obeonetwork.dsl.entity.Entity) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) EObject(org.eclipse.emf.ecore.EObject) PrimitiveType(org.obeonetwork.dsl.environment.PrimitiveType)

Example 2 with PrimitiveType

use of org.obeonetwork.dsl.environment.PrimitiveType in project InformationSystem by ObeoNetwork.

the class PrimitiveTypePrimitiveTypePropertiesEditionComponent method initPart.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
    setInitializing(true);
    if (editingPart != null && key == partKey) {
        editingPart.setContext(elt, allResource);
        final PrimitiveType primitiveType = (PrimitiveType) elt;
        final PrimitiveTypePropertiesEditionPart primitiveTypePart = (PrimitiveTypePropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(EnvironmentViewsRepository.PrimitiveType.Properties.name))
            primitiveTypePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, primitiveType.getName()));
        if (isAccessible(EnvironmentViewsRepository.PrimitiveType.Properties.description))
            primitiveTypePart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, primitiveType.getDescription()));
    // init filters
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : PrimitiveType(org.obeonetwork.dsl.environment.PrimitiveType) PrimitiveTypePropertiesEditionPart(org.obeonetwork.dsl.environment.parts.PrimitiveTypePropertiesEditionPart)

Aggregations

PrimitiveType (org.obeonetwork.dsl.environment.PrimitiveType)2 EObject (org.eclipse.emf.ecore.EObject)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1 Entity (org.obeonetwork.dsl.entity.Entity)1 PrimitiveTypePropertiesEditionPart (org.obeonetwork.dsl.environment.parts.PrimitiveTypePropertiesEditionPart)1