Search in sources :

Example 1 with PrototypeHolder

use of org.osate.ba.aadlba.PrototypeHolder in project osate2 by osate.

the class GroupPrototypeHolderItemProvider method getImage.

/**
 * This returns GroupPrototypeHolder.gif.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 */
@Override
public Object getImage(Object object) {
    String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
    PrototypeHolder holder = (PrototypeHolder) object;
    PrototypeBinding pb = holder.getPrototypeBinding();
    if (pb != null) {
        FeatureType type = FeatureType.ABSTRACT_FEATURE;
        if (pb instanceof ComponentPrototypeBinding) {
            type = AadlBaUtils.getCompPrototypeType((ComponentPrototypeBinding) pb);
        } else if (pb instanceof FeatureGroupPrototypeBinding) {
            type = FeatureType.FEATURE_GROUP_PROTOTYPE;
        } else if (pb instanceof FeaturePrototypeBinding) {
            type = AadlBaUtils.getFeatPrototypeType((FeaturePrototypeBinding) pb);
        }
        switch(type) {
            case FEATURE_GROUP_PROTOTYPE:
                {
                    imgFile += "FeatureGroup";
                    break;
                }
            case THREAD_GROUP_PROTOTYPE:
                {
                    imgFile += "ThreadGroup";
                    break;
                }
            case REQUIRES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
            case PROVIDES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
            case SUBPROGRAM_GROUP_PROTOTYPE:
                {
                    imgFile += "Subprogram";
                    break;
                }
            default:
                imgFile = "full/obj16/IfStatement";
        }
    }
    return overlayImage(object, getResourceLocator().getImage(imgFile));
}
Also used : FeatureType(org.osate.ba.aadlba.FeatureType) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder)

Example 2 with PrototypeHolder

use of org.osate.ba.aadlba.PrototypeHolder in project osate2 by osate.

the class DataAccessPrototypeHolderItemProvider method getImage.

/**
 * This returns DataAccessPrototypeHolder.gif.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 */
@Override
public Object getImage(Object object) {
    String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
    AccessType type = null;
    PrototypeHolder holder = (PrototypeHolder) object;
    FeaturePrototypeBinding fpb = (FeaturePrototypeBinding) holder.getPrototypeBinding();
    if (fpb != null) {
        type = ((AccessSpecification) fpb.getActual()).getKind();
    } else {
        type = AccessType.REQUIRES;
    }
    switch(type) {
        case PROVIDES:
            {
                imgFile += "ProvidesDataAccess";
                break;
            }
        default:
        case REQUIRES:
            {
                imgFile += "RequiresDataAccess";
                break;
            }
    }
    return overlayImage(object, getResourceLocator().getImage(imgFile));
}
Also used : FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) AccessType(org.osate.aadl2.AccessType) DataAccessPrototypeHolder(org.osate.ba.aadlba.DataAccessPrototypeHolder) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder)

Example 3 with PrototypeHolder

use of org.osate.ba.aadlba.PrototypeHolder in project osate2 by osate.

the class PortPrototypeHolderItemProvider method getImage.

/**
 * This returns PortPrototypeHolder.gif.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 */
@Override
public Object getImage(Object object) {
    String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
    DirectionType type = null;
    PrototypeHolder holder = (PrototypeHolder) object;
    FeaturePrototypeBinding fpb = (FeaturePrototypeBinding) holder.getPrototypeBinding();
    if (fpb != null) {
        type = ((PortSpecification) fpb.getActual()).getDirection();
    } else {
        type = DirectionType.IN;
    }
    switch(type) {
        default:
        case IN:
            {
                imgFile += "InDataPort";
                break;
            }
        case OUT:
            {
                imgFile += "OutDataPort";
                break;
            }
        case IN_OUT:
            {
                imgFile += "InOutDataPort";
                break;
            }
    }
    return overlayImage(object, getResourceLocator().getImage(imgFile));
}
Also used : DirectionType(org.osate.aadl2.DirectionType) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder)

Example 4 with PrototypeHolder

use of org.osate.ba.aadlba.PrototypeHolder in project osate2 by osate.

the class AadlBaParserVisitor method cloneHolder.

private ElementHolder cloneHolder(ElementHolder sourceElementHolder) {
    ElementHolder targetElementHolder = null;
    if (sourceElementHolder instanceof ClassifierFeatureHolder) {
        ClassifierFeatureHolder sourceCfh = (ClassifierFeatureHolder) sourceElementHolder;
        if (sourceElementHolder instanceof BehaviorVariableHolder) {
            // BehaviorVariableHolder
            targetElementHolder = _baFact.createBehaviorVariableHolder();
        } else if (sourceElementHolder instanceof FeatureHolder) {
            FeatureHolder sourceFeatureHolder = (FeatureHolder) sourceElementHolder;
            // FeatureHolder
            if (sourceFeatureHolder instanceof DataAccessHolder) {
                // DataAccessHolder
                targetElementHolder = _baFact.createDataAccessHolder();
            } else if (sourceFeatureHolder instanceof ParameterHolder) {
                // ParameterHolder
                targetElementHolder = _baFact.createParameterHolder();
            } else if (sourceFeatureHolder instanceof DataPortHolder) {
                targetElementHolder = _baFact.createDataPortHolder();
            } else if (sourceFeatureHolder instanceof EventDataPortHolder) {
                targetElementHolder = _baFact.createEventDataPortHolder();
            } else if (sourceFeatureHolder instanceof EventPortHolder) {
                targetElementHolder = _baFact.createEventPortHolder();
            } else if (sourceFeatureHolder instanceof SubprogramAccessHolder) {
                targetElementHolder = _baFact.createSubprogramAccessHolder();
            }
        } else // PrototypeHolder
        if (sourceElementHolder instanceof PrototypeHolder) {
            // DataAccessPrototypeHolder
            if (sourceElementHolder instanceof DataAccessPrototypeHolder) {
                targetElementHolder = _baFact.createDataAccessPrototypeHolder();
            } else if (sourceElementHolder instanceof FeaturePrototypeHolder) {
                targetElementHolder = _baFact.createFeaturePrototypeHolder();
            } else if (sourceElementHolder instanceof PortPrototypeHolder) {
                targetElementHolder = _baFact.createPortPrototypeHolder();
            } else if (sourceElementHolder instanceof SubprogramPrototypeHolder) {
                targetElementHolder = _baFact.createSubprogramPrototypeHolder();
            }
        } else // SubcomponentHolder
        if (sourceElementHolder instanceof SubcomponentHolder) {
            // DataSubcomponentHolder
            if (sourceElementHolder instanceof DataSubcomponentHolder) {
                targetElementHolder = _baFact.createDataSubcomponentHolder();
            } else if (sourceElementHolder instanceof SubprogramSubcomponentHolder) {
                targetElementHolder = _baFact.createSubprogramSubcomponentHolder();
            }
        }
        ClassifierFeatureHolder targetCfh = (ClassifierFeatureHolder) targetElementHolder;
        targetCfh.setClassifierFeature(sourceCfh.getClassifierFeature());
    }
    if (targetElementHolder != null) {
        targetElementHolder.setElement(sourceElementHolder.getElement());
    }
    return targetElementHolder;
}
Also used : DataAccessHolder(org.osate.ba.aadlba.DataAccessHolder) PortPrototypeHolder(org.osate.ba.aadlba.PortPrototypeHolder) ClassifierFeatureHolder(org.osate.ba.aadlba.ClassifierFeatureHolder) FeatureHolder(org.osate.ba.aadlba.FeatureHolder) FeaturePrototypeHolder(org.osate.ba.aadlba.FeaturePrototypeHolder) SubprogramSubcomponentHolder(org.osate.ba.aadlba.SubprogramSubcomponentHolder) ElementHolder(org.osate.ba.aadlba.ElementHolder) PropertyElementHolder(org.osate.ba.aadlba.PropertyElementHolder) ClassifierFeatureHolder(org.osate.ba.aadlba.ClassifierFeatureHolder) BehaviorVariableHolder(org.osate.ba.aadlba.BehaviorVariableHolder) EventPortHolder(org.osate.ba.aadlba.EventPortHolder) SubcomponentHolder(org.osate.ba.aadlba.SubcomponentHolder) DataSubcomponentHolder(org.osate.ba.aadlba.DataSubcomponentHolder) SubprogramSubcomponentHolder(org.osate.ba.aadlba.SubprogramSubcomponentHolder) EventDataPortHolder(org.osate.ba.aadlba.EventDataPortHolder) DataPortHolder(org.osate.ba.aadlba.DataPortHolder) DataSubcomponentHolder(org.osate.ba.aadlba.DataSubcomponentHolder) EventDataPortHolder(org.osate.ba.aadlba.EventDataPortHolder) DataAccessPrototypeHolder(org.osate.ba.aadlba.DataAccessPrototypeHolder) ParameterHolder(org.osate.ba.aadlba.ParameterHolder) SubprogramAccessHolder(org.osate.ba.aadlba.SubprogramAccessHolder) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder) PortPrototypeHolder(org.osate.ba.aadlba.PortPrototypeHolder) SubprogramPrototypeHolder(org.osate.ba.aadlba.SubprogramPrototypeHolder) DataAccessPrototypeHolder(org.osate.ba.aadlba.DataAccessPrototypeHolder) FeaturePrototypeHolder(org.osate.ba.aadlba.FeaturePrototypeHolder) SubprogramPrototypeHolder(org.osate.ba.aadlba.SubprogramPrototypeHolder)

Example 5 with PrototypeHolder

use of org.osate.ba.aadlba.PrototypeHolder in project osate2 by osate.

the class AadlBaUtils method getDataRepresentation.

/**
 * Returns the data representation of the given ValueVariable object
 * or DataRepresentation.UNKNOWN if Data_Model::Data_Representation
 * property is not set or if the ValueVariable object represents a data
 * structure.
 *
 * @param v the given ValueVariable object
 * @return the data representation or DataRepresentation.UNKNOWN
 */
public static DataRepresentation getDataRepresentation(ValueVariable v) {
    if (v instanceof PortCountValue) {
        return DataRepresentation.INTEGER;
    } else if (v instanceof PortFreshValue) {
        return DataRepresentation.BOOLEAN;
    } else {
        // Either ElementHolder or DataComponentReference object.
        Element el = null;
        if (v instanceof ElementHolder) {
            if (v instanceof PrototypeHolder) {
                PrototypeHolder ph = (PrototypeHolder) v;
                if (ph.getPrototypeBinding() != null) {
                    el = ph.getPrototypeBinding();
                } else {
                    el = ph.getPrototype();
                }
            } else {
                el = ((ElementHolder) v).getElement();
            }
        } else // DataComponentReference case.
        {
            DataComponentReference dcr = (DataComponentReference) v;
            DataHolder lastElement = dcr.getData().get(dcr.getData().size() - 1);
            el = lastElement.getElement();
        }
        if (el instanceof Abstract) {
            return DataRepresentation.UNKNOWN;
        } else if (el instanceof Feature) {
            Classifier c = ((Feature) el).getClassifier();
            if (c instanceof DataClassifier) {
                return getDataRepresentation((DataClassifier) c);
            } else {
                return DataRepresentation.UNKNOWN;
            }
        } else if (el instanceof DataSubcomponent) {
            final DataSubcomponent subcompo = (DataSubcomponent) el;
            final Classifier classifier = subcompo.getClassifier();
            // fixes 2401: Avoid crashing the editor when subcomponent is not resolved
            if (classifier == null || classifier.eIsProxy()) {
                return DataRepresentation.UNKNOWN;
            }
            return getDataRepresentation((DataClassifier) ((DataSubcomponent) el).getClassifier());
        } else if (el instanceof BehaviorVariable) {
            // Behavior case.
            return getDataRepresentation((BehaviorVariable) el);
        } else {
            // Prototype cases.
            Classifier klass;
            ComponentClassifier baParentComponent = (ComponentClassifier) v.getContainingClassifier();
            klass = AadlBaUtils.getClassifier(el, baParentComponent);
            return getDataRepresentation((DataClassifier) klass);
        }
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) Abstract(org.osate.aadl2.Abstract) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) IndexableElement(org.osate.ba.aadlba.IndexableElement) ElementHolder(org.osate.ba.aadlba.ElementHolder) PropertyElementHolder(org.osate.ba.aadlba.PropertyElementHolder) PortFreshValue(org.osate.ba.aadlba.PortFreshValue) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessClassifier(org.osate.aadl2.ProcessClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) DataClassifier(org.osate.aadl2.DataClassifier) DataComponentReference(org.osate.ba.aadlba.DataComponentReference) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature) DirectedFeature(org.osate.aadl2.DirectedFeature) PortCountValue(org.osate.ba.aadlba.PortCountValue) DataHolder(org.osate.ba.aadlba.DataHolder) DataSubcomponent(org.osate.aadl2.DataSubcomponent) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder) DataAccessPrototypeHolder(org.osate.ba.aadlba.DataAccessPrototypeHolder) FeaturePrototypeHolder(org.osate.ba.aadlba.FeaturePrototypeHolder)

Aggregations

PrototypeHolder (org.osate.ba.aadlba.PrototypeHolder)5 FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)3 DataAccessPrototypeHolder (org.osate.ba.aadlba.DataAccessPrototypeHolder)3 ElementHolder (org.osate.ba.aadlba.ElementHolder)2 FeaturePrototypeHolder (org.osate.ba.aadlba.FeaturePrototypeHolder)2 PropertyElementHolder (org.osate.ba.aadlba.PropertyElementHolder)2 Abstract (org.osate.aadl2.Abstract)1 AbstractFeature (org.osate.aadl2.AbstractFeature)1 AccessType (org.osate.aadl2.AccessType)1 ArrayableElement (org.osate.aadl2.ArrayableElement)1 Classifier (org.osate.aadl2.Classifier)1 ComponentClassifier (org.osate.aadl2.ComponentClassifier)1 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)1 DataClassifier (org.osate.aadl2.DataClassifier)1 DataSubcomponent (org.osate.aadl2.DataSubcomponent)1 DirectedFeature (org.osate.aadl2.DirectedFeature)1 DirectionType (org.osate.aadl2.DirectionType)1 Element (org.osate.aadl2.Element)1 Feature (org.osate.aadl2.Feature)1 FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)1