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));
}
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));
}
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));
}
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;
}
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);
}
}
}
Aggregations