Search in sources :

Example 1 with Parameter

use of org.obeonetwork.dsl.soa.Parameter in project InformationSystem by ObeoNetwork.

the class SoaMigrationHelper method handleUnknownFeaturesAnyAttribute.

@Override
public void handleUnknownFeaturesAnyAttribute(EObject owner, FeatureMap featureMap) {
    if (owner instanceof Parameter) {
        Parameter parameter = (Parameter) owner;
        // Convert "lower + upper" to "multiplicity"
        // Previous default values were lower = 1 and upper = 1
        Iterator<FeatureMap.Entry> iter = featureMap.iterator();
        int lower = 1;
        int upper = 1;
        while (iter.hasNext()) {
            final FeatureMap.Entry entry = iter.next();
            if ("lower".equals(entry.getEStructuralFeature().getName())) {
                lower = Integer.parseInt((String) entry.getValue());
            }
            if ("upper".equals(entry.getEStructuralFeature().getName())) {
                upper = Integer.parseInt((String) entry.getValue());
            }
        }
        // Convert now
        if (lower == 0) {
            // lower == 0
            if (upper < 0 || upper > 1) {
                parameter.setMultiplicity(MultiplicityKind.ZERO_STAR_LITERAL);
            } else {
                parameter.setMultiplicity(MultiplicityKind.ZERO_ONE_LITERAL);
            }
        } else {
            // lower == 1
            if (upper < 0 || upper > 1) {
                parameter.setMultiplicity(MultiplicityKind.ONE_STAR_LITERAL);
            } else {
                parameter.setMultiplicity(MultiplicityKind.ONE_LITERAL);
            }
        }
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) Parameter(org.obeonetwork.dsl.soa.Parameter)

Example 2 with Parameter

use of org.obeonetwork.dsl.soa.Parameter in project InformationSystem by ObeoNetwork.

the class ParameterItemProvider method getImage.

/**
 * This returns Parameter.gif.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public Object getImage(Object object) {
    if (object instanceof Parameter) {
        Parameter parameter = (Parameter) object;
        EObject container = parameter.eContainer();
        if (container instanceof Operation) {
            Operation operation = (Operation) container;
            if (operation.getInput().contains(parameter)) {
                return overlayImage(object, getResourceLocator().getImage("full/obj16/Input"));
            } else if (operation.getOutput().contains(parameter)) {
                return overlayImage(object, getResourceLocator().getImage("full/obj16/Output"));
            } else {
                return overlayImage(object, getResourceLocator().getImage("full/obj16/Fault"));
            }
        }
    }
    return overlayImage(object, getResourceLocator().getImage("full/obj16/Parameter"));
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Parameter(org.obeonetwork.dsl.soa.Parameter) Operation(org.obeonetwork.dsl.soa.Operation)

Example 3 with Parameter

use of org.obeonetwork.dsl.soa.Parameter in project InformationSystem by ObeoNetwork.

the class ParameterParameterPropertiesEditionComponent 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 Parameter parameter = (Parameter) elt;
        final ParameterPropertiesEditionPart parameterPart = (ParameterPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(SoaViewsRepository.Parameter.Properties.name))
            parameterPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, parameter.getName()));
        if (isAccessible(SoaViewsRepository.Parameter.Properties.multiplicity)) {
            parameterPart.initMultiplicity(EEFUtils.choiceOfValues(parameter, SoaPackage.eINSTANCE.getParameter_Multiplicity()), parameter.getMultiplicity());
        }
        if (isAccessible(SoaViewsRepository.Parameter.Properties.isUnique)) {
            parameterPart.setIsUnique(parameter.isIsUnique());
        }
        if (isAccessible(SoaViewsRepository.Parameter.Properties.isOrdered)) {
            parameterPart.setIsOrdered(parameter.isIsOrdered());
        }
        if (isAccessible(SoaViewsRepository.Parameter.Properties.type)) {
            // init part
            typeSettings = new EObjectFlatComboSettings(parameter, SoaPackage.eINSTANCE.getParameter_Type());
            parameterPart.initType(typeSettings);
            // set the button mode
            parameterPart.setTypeButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(SoaViewsRepository.Parameter.Properties.description))
            parameterPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, parameter.getDescription()));
    // init filters
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : Parameter(org.obeonetwork.dsl.soa.Parameter) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings) ParameterPropertiesEditionPart(org.obeonetwork.dsl.soa.parts.ParameterPropertiesEditionPart)

Aggregations

Parameter (org.obeonetwork.dsl.soa.Parameter)3 Entry (java.util.Map.Entry)1 EObject (org.eclipse.emf.ecore.EObject)1 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)1 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)1 Operation (org.obeonetwork.dsl.soa.Operation)1 ParameterPropertiesEditionPart (org.obeonetwork.dsl.soa.parts.ParameterPropertiesEditionPart)1