use of org.yakindu.sct.model.stext.stext.EventSpec in project statecharts by Yakindu.
the class STextJavaValidator method checkReactionTriggerRegularEvent.
@Check(CheckType.FAST)
public void checkReactionTriggerRegularEvent(ReactionTrigger reactionTrigger) {
for (int i = 0; i < reactionTrigger.getTriggers().size(); i++) {
EventSpec eventSpec = reactionTrigger.getTriggers().get(i);
if (eventSpec instanceof RegularEventSpec) {
EObject element = unwrap(((RegularEventSpec) eventSpec).getEvent());
if (element != null && (!(element instanceof Event))) {
String elementName = "";
if (element instanceof NamedElement) {
elementName = "'" + ((NamedElement) element).getName() + "' ";
}
error("Trigger " + elementName + "is no event.", StextPackage.Literals.REACTION_TRIGGER__TRIGGERS, i, TRIGGER_IS_NO_EVENT);
}
}
}
}
use of org.yakindu.sct.model.stext.stext.EventSpec in project statecharts by Yakindu.
the class RefactoringHelper method getFirstEntryActions.
/**
* Returns the entry actions of a state. Returns null if no entry block is
* defined. If multiple entry blocks are defined, only the actions of the first
* one are returned.
*
* @param state
* @return list of actions of the first entry block defined in the specified
* state
*/
public EList<Expression> getFirstEntryActions(State state) {
EList<Reaction> localReactions = state.getLocalReactions();
for (Reaction reaction : localReactions) {
Trigger trigger = reaction.getTrigger();
if (trigger instanceof ReactionTrigger) {
ReactionTrigger reactionTrigger = (ReactionTrigger) trigger;
EList<EventSpec> triggers = reactionTrigger.getTriggers();
for (EventSpec eventSpec : triggers) {
if (eventSpec instanceof EntryEvent && reaction.getEffect() instanceof ReactionEffect) {
return ((ReactionEffect) reaction.getEffect()).getActions();
}
}
}
}
return null;
}
use of org.yakindu.sct.model.stext.stext.EventSpec in project statecharts by Yakindu.
the class RefactoringHelper method getFirstExitActions.
/**
* Returns the exit actions of a state. Returns null if no exit block is
* defined. If multiple exit blocks are defined, only the actions of the first
* one are returned.
*
* @param state
* @return list of actions of the first exit block defined in the specified
* state
*/
public EList<Expression> getFirstExitActions(State state) {
EList<Reaction> localReactions = state.getLocalReactions();
for (Reaction reaction : localReactions) {
Trigger trigger = reaction.getTrigger();
if (trigger instanceof ReactionTrigger) {
ReactionTrigger reactionTrigger = (ReactionTrigger) trigger;
EList<EventSpec> triggers = reactionTrigger.getTriggers();
for (EventSpec eventSpec : triggers) {
if (eventSpec instanceof ExitEvent && reaction.getEffect() instanceof ReactionEffect) {
return ((ReactionEffect) reaction.getEffect()).getActions();
}
}
}
}
return null;
}
Aggregations