org.eclipse.uml2.uml.BehavioralFeature Java Examples

The following examples show how to use org.eclipse.uml2.uml.BehavioralFeature. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StructureBehaviorGenerator.java    From textuml with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@link AOperationBody} is the first node we visit.
 */
@Override
public void caseABehavioralFeatureBody(ABehavioralFeatureBody node) {
	final BehavioralFeature feature = (BehavioralFeature) namespaceTracker
			.currentNamespace(IRepository.PACKAGE.getBehavioralFeature());
	if (feature.isAbstract()) {
		problemBuilder.addError("Behavioral feature is abstract", node.getBlock());
		throw new AbortedStatementCompilationException();
	}
	if (!(feature.getOwner() instanceof Class)) {
		problemBuilder.addError("Can only define behavioral feature in classes", node.getBlock());
		throw new AbortedStatementCompilationException();
	}
	final Class currentClass = (Class) feature.getOwner();
	Activity activity = (Activity) currentClass.createNestedClassifier(null, IRepository.PACKAGE.getActivity());
	activity.setIsReadOnly(feature instanceof Operation && ((Operation) feature).isQuery());
	activity.setSpecification(feature);
	activity.setName("__activity_" + feature.getName());
	activity.getOwnedParameters().addAll(EcoreUtil.copyAll(feature.getOwnedParameters()));
	createBody(node.getBlock(), activity);
}
 
Example #2
Source File: ElementModifiersAssigner.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
public static void assignModifiersForElementBasedOnDeclaration(NamedElement element, BodyDeclaration declaration) {
	int modifiers = declaration.getModifiers();
	VisibilityKind visibility = VisibilityProvider.getVisibilityOfNamedElementFromModifiers(element, modifiers);
	element.setVisibility(visibility);

	boolean isAbstract = Modifier.isAbstract(modifiers);
	boolean isStatic = Modifier.isStatic(modifiers);

	if (element instanceof Classifier) {
		Classifier classifierElem = (Classifier) element;
		classifierElem.setIsAbstract(isAbstract);
	}
	if (element instanceof BehavioralFeature) {
		BehavioralFeature featureElem = (BehavioralFeature) element;
		featureElem.setIsStatic(isStatic);
		featureElem.setIsAbstract(isAbstract);
	}
	if (element instanceof Property) {
		Property propertyElem = (Property) element;
		propertyElem.setIsStatic(isStatic);
	}
}
 
Example #3
Source File: ReadSelfActionBuilder.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void enhanceAction() {
    Activity currentActivity = getContext().getActivityBuilder().getCurrentActivity();
    while (MDDExtensionUtils.isClosure(currentActivity)) {
        ActivityNode rootNode = MDDExtensionUtils.getClosureContext(currentActivity);
        currentActivity = MDDUtil.getNearest(rootNode, Literals.ACTIVITY);
    }
    final BehavioralFeature operation = currentActivity.getSpecification();
    if (operation != null && operation.isStatic()) {
        getContext().getProblemTracker().add(new ReadSelfFromStaticContext());
        throw new AbortedStatementCompilationException();
    }
    getProduct().createResult(null, (Classifier) currentActivity.getNamespace());
}
 
Example #4
Source File: UMLBehavioralFeatureImpl.java    From ifml-editor with MIT License 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setBehavioralFeature(BehavioralFeature newBehavioralFeature) {
	BehavioralFeature oldBehavioralFeature = behavioralFeature;
	behavioralFeature = newBehavioralFeature;
	if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.UML_BEHAVIORAL_FEATURE__BEHAVIORAL_FEATURE, oldBehavioralFeature, behavioralFeature));
}
 
Example #5
Source File: UMLBehavioralFeatureImpl.java    From ifml-editor with MIT License 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eSet(int featureID, Object newValue) {
	switch (featureID) {
		case CorePackage.UML_BEHAVIORAL_FEATURE__BEHAVIORAL_FEATURE:
			setBehavioralFeature((BehavioralFeature)newValue);
			return;
	}
	super.eSet(featureID, newValue);
}
 
Example #6
Source File: UMLBehavioralFeatureImpl.java    From ifml-editor with MIT License 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void eUnset(int featureID) {
	switch (featureID) {
		case CorePackage.UML_BEHAVIORAL_FEATURE__BEHAVIORAL_FEATURE:
			setBehavioralFeature((BehavioralFeature)null);
			return;
	}
	super.eUnset(featureID);
}
 
Example #7
Source File: ActivityBuilder.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void enhance() {
    if (behavioralFeatureName != null)
        new ReferenceSetter<BehavioralFeature>(behavioralFeatureName, getParentProduct(), getContext()) {
            @Override
            protected void link(BehavioralFeature specification) {
                setSpecification(specification);
            }
        };
    else if (specification != null)
        setSpecification(specification.getProduct());
    else
        abortScope(new UnclassifiedProblem("No specification set"));
    // build children as the last step
    getContext().getReferenceTracker().add(new IDeferredReference() {
        @Override
        public void resolve(IBasicRepository repository) {
            if (specification.getProduct() != null)
                createActivityParameters(specification.getProduct());
            getContext().getActivityBuilder().createRootBlock(getProduct());
            try {
                ActivityBuilder.super.enhance();
            } finally {
                getContext().getActivityBuilder().closeRootBlock();
            }
        }
    }, Step.BEHAVIOR);
}
 
Example #8
Source File: FeatureUtils.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public static List<? extends BehavioralFeature> getBehavioralFeatures(Classifier classifier) {
    if (!(classifier instanceof Interface) && !(classifier instanceof Class))
        return classifier.getOperations();
    List<BehavioralFeature> combined = new ArrayList<>(classifier.getOperations());
    EList<Reception> receptions = (classifier instanceof Interface) ? ((Interface) classifier).getOwnedReceptions()
            : ((Class) classifier).getOwnedReceptions();
    combined.addAll(receptions);
    return combined;
}
 
Example #9
Source File: FeatureUtils.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public static BehavioralFeature findCompatibleOperation(IRepository repository, Classifier classifier,
        Operation operation) {
    List<TypedElement> parameters = new ArrayList<TypedElement>();
    for (Parameter parameter : FeatureUtils.getInputParameters(operation.getOwnedParameters()))
        parameters.add(parameter);
    return findOperation(repository, classifier, operation.getName(), parameters, null, false, true);
}
 
Example #10
Source File: AbstractGenerator.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
protected SignatureProcessor newSignatureProcessor(Namespace target) {
    if (target instanceof Behavior)
        return new BehaviorSignatureProcessor(sourceContext, (Behavior) target);
    if (target instanceof BehavioralFeature)
        return new BehavioralFeatureSignatureProcessor(sourceContext, (BehavioralFeature) target);
    throw new IllegalArgumentException("" + target);
}
 
Example #11
Source File: BehaviorGenerator.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
@Override
 public void caseASelfIdentifierExpression(ASelfIdentifierExpression node) {
     ReadSelfAction action = (ReadSelfAction) builder.createAction(IRepository.PACKAGE.getReadSelfAction());
     try {
         super.caseASelfIdentifierExpression(node);
         Activity currentActivity = builder.getCurrentActivity();
         while (MDDExtensionUtils.isClosure(currentActivity)) {
             // TODO refactor to use ActivityUtils
             ActivityNode rootNode = MDDExtensionUtils.getClosureContext(currentActivity);
             currentActivity = ActivityUtils.getActionActivity(rootNode);
         }
         final BehavioralFeature operation = currentActivity.getSpecification();
         boolean staticContext = false;
         if (operation != null) {
         	staticContext = operation.isStatic();
         } else if (MDDExtensionUtils.isConstraintBehavior(currentActivity)) {
         	Constraint constraint = MDDExtensionUtils.getBehaviorConstraint(currentActivity);
         	staticContext = MDDExtensionUtils.isStaticConstraint(constraint);
         }
         if (staticContext) {
             problemBuilder.addProblem(new ReadSelfFromStaticContext(), node);
             throw new AbortedStatementCompilationException();
         }
         Classifier currentClassifier = ActivityUtils.getContext(currentActivity);
         if (currentClassifier == null) {
             problemBuilder.addProblem(new InternalProblem("Could not determine context"), node);
             throw new AbortedStatementCompilationException();
         }
         OutputPin result = action.createResult(null, currentClassifier);
         result.setLower(1);
         result.setUpper(1);
builder.registerOutput(result);
         fillDebugInfo(action, node);
     } finally {
         builder.closeAction();
     }
     checkIncomings(action, node.getSelf(), getBoundElement());
 }
 
Example #12
Source File: BehavioralFeatureSignatureProcessor.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
public BehavioralFeatureSignatureProcessor(SourceCompilationContext<Node> sourceContext, BehavioralFeature parent,
        boolean supportExceptions, boolean unnamedParameters) {
    super(sourceContext, parent, supportExceptions, unnamedParameters);
}
 
Example #13
Source File: ActivityBuilder.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
private void createActivityParameters(BehavioralFeature specification) {
    getProduct().getOwnedParameters().addAll(EcoreUtil.copyAll(specification.getOwnedParameters()));
}
 
Example #14
Source File: ActivityBuilder.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
private void setSpecification(BehavioralFeature specification) {
    getProduct().setSpecification(specification);
    getProduct().setName(MDDUtil.getTokenFromQName(specification.getName()));
}
 
Example #15
Source File: ActivityUtils.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
public static Operation getOperation(Activity activity) {
    BehavioralFeature specification = activity.getSpecification();
    return specification instanceof Operation ? (Operation) specification : null;
}
 
Example #16
Source File: BehavioralFeatureSignatureProcessor.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
private BehavioralFeature getBehavioralFeature() {
    return (BehavioralFeature) parent;
}
 
Example #17
Source File: BehavioralFeatureSignatureProcessor.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
public BehavioralFeatureSignatureProcessor(SourceCompilationContext<Node> sourceContext, BehavioralFeature parent) {
    super(sourceContext, parent, true);
}
 
Example #18
Source File: ClassifierRenderer.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
protected List<? extends BehavioralFeature> getBehavioralFeatures(T element) {
    return FeatureUtils.getBehavioralFeatures(element);
}
 
Example #19
Source File: UMLBehavioralFeatureImpl.java    From ifml-editor with MIT License 2 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public BehavioralFeature basicGetBehavioralFeature() {
	return behavioralFeature;
}
 
Example #20
Source File: UMLBehavioralFeature.java    From ifml-editor with MIT License 2 votes vote down vote up
/**
 * Sets the value of the '{@link IFML.Core.UMLBehavioralFeature#getBehavioralFeature <em>Behavioral Feature</em>}' reference.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param value the new value of the '<em>Behavioral Feature</em>' reference.
 * @see #getBehavioralFeature()
 * @generated
 */
void setBehavioralFeature(BehavioralFeature value);
 
Example #21
Source File: UMLBehavioralFeature.java    From ifml-editor with MIT License 2 votes vote down vote up
/**
 * Returns the value of the '<em><b>Behavioral Feature</b></em>' reference.
 * <!-- begin-user-doc -->
 * <p>
 * If the meaning of the '<em>Behavioral Feature</em>' reference isn't clear,
 * there really should be more of a description here...
 * </p>
 * <!-- end-user-doc -->
 * @return the value of the '<em>Behavioral Feature</em>' reference.
 * @see #setBehavioralFeature(BehavioralFeature)
 * @see IFML.Core.CorePackage#getUMLBehavioralFeature_BehavioralFeature()
 * @model ordered="false"
 * @generated
 */
BehavioralFeature getBehavioralFeature();