use of org.yakindu.sct.model.sgraph.Trigger in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkUnboundEntryPoints.
@Test
public void checkUnboundEntryPoints() {
statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "UnboundDefaultEntryPoints.sct");
Iterator<EObject> iter = statechart.eAllContents();
// create and add triggers to all transitions to prevent to trigger
// additional warnings
// (see Check in SGrapJavaValidator transitionsWithNoGuard)
Trigger trigger = StextFactoryImpl.init().createDefaultTrigger();
while (iter.hasNext()) {
EObject element = iter.next();
if (element instanceof Transition) {
((Transition) element).setTrigger(trigger);
validator.validate(element, diagnostics, new HashMap<>());
}
if (element instanceof State) {
validator.validate(element, diagnostics, new HashMap<>());
}
}
assertIssueCount(diagnostics, 4);
assertError(diagnostics, TRANSITION_UNBOUND_DEFAULT_ENTRY_POINT);
assertError(diagnostics, REGION_UNBOUND_DEFAULT_ENTRY_POINT);
resetDiagnostics();
statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "UnboundEntryPoints02.sct");
iter = statechart.eAllContents();
while (iter.hasNext()) {
EObject element = iter.next();
if (element instanceof Transition) {
((Transition) element).setTrigger(trigger);
validator.validate(element, diagnostics, new HashMap<>());
}
if (element instanceof State) {
validator.validate(element, diagnostics, new HashMap<>());
}
}
assertIssueCount(diagnostics, 4);
}
use of org.yakindu.sct.model.sgraph.Trigger in project statecharts by Yakindu.
the class StatechartObjectViewerFilter method select.
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof DomainNavigatorItem) {
DomainNavigatorItem navigatorItem = (DomainNavigatorItem) element;
EObject modelElement = navigatorItem.getEObject();
if (modelElement instanceof Diagram) {
return false;
}
if (modelElement instanceof Trigger) {
return false;
}
if (modelElement instanceof InternalScope || modelElement instanceof InterfaceScope) {
return true;
}
if (modelElement instanceof Scope) {
return false;
}
if (modelElement instanceof LocalReaction) {
return false;
}
if (modelElement instanceof ReactionEffect) {
return false;
}
if (modelElement instanceof Expression) {
return false;
}
}
return true;
}
use of org.yakindu.sct.model.sgraph.Trigger 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.sgraph.Trigger 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;
}
use of org.yakindu.sct.model.sgraph.Trigger in project statecharts by Yakindu.
the class ReactionImpl method basicSetTrigger.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTrigger(Trigger newTrigger, NotificationChain msgs) {
Trigger oldTrigger = trigger;
trigger = newTrigger;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SGraphPackage.REACTION__TRIGGER, oldTrigger, newTrigger);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations